mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-10-31 13:00:26 -04:00 
			
		
		
		
	Autostack: Fix channel windows being made to wide when SDRangel starts
This commit is contained in:
		
							parent
							
								
									28f44b5a6b
								
							
						
					
					
						commit
						b6dca29167
					
				| @ -49,7 +49,8 @@ Workspace::Workspace(int index, QWidget *parent, Qt::WindowFlags flags) : | ||||
|     m_featureAddDialog(this), | ||||
|     m_stacking(false), | ||||
|     m_autoStack(false), | ||||
|     m_userChannelMinWidth(0) | ||||
|     m_userChannelMinWidth(0), | ||||
|     m_autoStackChannelMinWidth(0) | ||||
| { | ||||
|     m_mdi = new QMdiArea(this); | ||||
|     m_mdi->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); | ||||
| @ -692,7 +693,7 @@ void Workspace::stackSubWindows() | ||||
|     } | ||||
| 
 | ||||
|     // Calculate width & height needed for channels
 | ||||
|     int channelMinWidth = m_userChannelMinWidth; // channels.size() > 0 ? m_userChannelMinWidth : 0;
 | ||||
|     int channelMinWidth = m_userChannelMinWidth; | ||||
|     int channelTotalMinHeight = 0; | ||||
|     int expandingChannels = 0; | ||||
|     for (auto window : channels) | ||||
| @ -756,6 +757,8 @@ void Workspace::stackSubWindows() | ||||
|     if ((spectrumFeaturesMinWidth == 0) && expandingChannels > 0) { | ||||
|         channelMinWidth = mdiSize.width() - devicesFeaturesWidth - spacing1; | ||||
|     } | ||||
|     // Save min width, for use in resize event handling
 | ||||
|     m_autoStackChannelMinWidth = channelMinWidth; | ||||
| 
 | ||||
|     // Now position the windows
 | ||||
|     int x = 0; | ||||
| @ -1022,6 +1025,9 @@ bool Workspace::eventFilter(QObject *obj, QEvent *event) | ||||
|     } | ||||
|     else if (event->type() == QEvent::Resize) | ||||
|     { | ||||
|         // We try to use m_stacking to ignore resize event as the result of a resize called in stackSubWindows
 | ||||
|         // However, this isn't reliable, as sometimes the resize event arrives after stackSubWindows has finished, and so m_stacking has been cleared
 | ||||
|         // What is a better way of doing this?
 | ||||
|         if (!m_stacking && m_autoStack) | ||||
|         { | ||||
|             QWidget *widget = qobject_cast<QWidget *>(obj); | ||||
| @ -1033,10 +1039,14 @@ bool Workspace::eventFilter(QObject *obj, QEvent *event) | ||||
|                 // but we can tell as window size matches mdi size
 | ||||
|                 if (m_mdi->size() != resizeEvent->size()) | ||||
|                 { | ||||
|                     // Allow width of channels column to be set by user when they
 | ||||
|                     // resize a channel window
 | ||||
|                     m_userChannelMinWidth = resizeEvent->size().width(); | ||||
|                     stackSubWindows(); | ||||
|                     // Allow width of channels column to be set by user when they resize a channel window
 | ||||
|                     // We use m_autoStackChannelMinWidth to indicate the width was set by stackSubWindows, rather than the user
 | ||||
|                     int width = resizeEvent->size().width(); | ||||
|                     if (width != m_autoStackChannelMinWidth) | ||||
|                     { | ||||
|                         m_userChannelMinWidth = width; | ||||
|                         stackSubWindows(); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
| @ -1115,3 +1125,4 @@ void Workspace::adjustSubWindowsAfterRestore() | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -95,6 +95,7 @@ private: | ||||
|     bool m_stacking;                // Set when stackSubWindows() is running
 | ||||
|     bool m_autoStack;               // Automatically stack
 | ||||
|     int m_userChannelMinWidth;      // Minimum width of channels column for stackSubWindows(), set by user resizing a channel window
 | ||||
|     int m_autoStackChannelMinWidth; // Width of channel requested by stackSubWindows()
 | ||||
| 
 | ||||
|     void unmaximizeSubWindows(); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user