@@ -165,85 +165,45 @@ void QgsGeorefPluginGui::on_mArrangeWindowsButton_clicked()
165
165
return ;
166
166
}
167
167
168
- int width, height ; // width and height of screen
168
+ int myScreenWidth, myScreenHeight ; // width and height of screen
169
169
170
170
// store initial size and position of qgis window
171
171
mPluginWindowsArranged = true ;
172
172
origSize = mainWindow->size ();
173
173
origPos = mainWindow->pos ();
174
174
175
-
176
- // qt distinguishes between geometry with and without window frame
177
- int widthIncrMainWindow, heightIncrMainWindow;
178
- int widthIncrPointDialog, heightIncrPointDialog;
179
- int widthIncrThis, heightIncrThis;
180
-
181
175
// read the desktop geometry
182
176
QDesktopWidget* desktop = QApplication::desktop ();
183
177
QRect screenGeometry = desktop->availableGeometry ();
184
- width = screenGeometry.width ();
185
- height = screenGeometry.height ();
186
-
187
- int leftRightBorder; // border between plugin/point dialogs on the left and qgis main window on the right
188
- int pluginPointDialogBorder; // border on y-axis between plugin dialog and point dialog
189
-
178
+ myScreenWidth = screenGeometry.width ();
179
+ myScreenHeight = screenGeometry.height ();
190
180
191
- leftRightBorder = width/3 ;
192
- pluginPointDialogBorder = height/5 ;
193
-
194
- // consider minimum heights of plugin dialog and mPointDialog
195
- int minPluginDialogHeight = minimumHeight () + (frameSize ().height () - this ->height ());
196
- int minPointDialogHeight = mPointDialog ->minimumHeight () + \
197
- (mPointDialog ->frameSize ().height () - mPointDialog ->height ());
198
-
199
- if ((height - pluginPointDialogBorder) < minPointDialogHeight)
200
- {
201
- pluginPointDialogBorder = (height - minPointDialogHeight);
202
- }
203
- if (pluginPointDialogBorder < minPluginDialogHeight)
204
- {
205
- pluginPointDialogBorder = minPluginDialogHeight;
206
- }
207
-
208
- // consider minimum widths of plugin/point dialogs and qgis main window
209
- int minPluginDialogWidth = minimumWidth () + (frameSize ().width () - this ->width ());
210
- int minPointDialogWidth = mPointDialog ->minimumWidth () + \
211
- (mPointDialog ->frameSize ().width () - mPointDialog ->width ());
212
- int minMainWindowWidth = mainWindow->minimumWidth () + \
213
- (mainWindow->frameSize ().width () - mainWindow->width ());
214
-
215
- if (leftRightBorder < minPointDialogWidth)
216
- {
217
- leftRightBorder = minPointDialogWidth;
218
- }
219
- if (leftRightBorder < minPluginDialogWidth)
220
- {
221
- leftRightBorder = minPluginDialogWidth;
222
- }
223
- if ((width - leftRightBorder) < minMainWindowWidth)
224
- {
225
- leftRightBorder = width - minMainWindowWidth;
226
- }
181
+ int newPluginDialogHeight = qMax (int (myScreenHeight * 0.2 ), minimumHeight ());
182
+ int newPluginDialogWidth = qMax (int (myScreenWidth * 0.33 ), minimumWidth ());
183
+ int newPointDialogHeight = qMax (int (myScreenHeight * 0.70 ), mPointDialog ->minimumHeight ());
184
+ int newPointDialogWidth = qMax (int (myScreenWidth * 0.33 ), mPointDialog ->minimumWidth ());
185
+ int newMainWindowHeight = qMax (int (myScreenHeight * 0.95 ), mainWindow->minimumHeight ());
186
+ int newMainWindowWidth = qMax (int (myScreenWidth * 0.65 ), mainWindow->minimumHeight ());
227
187
228
188
// place main window
229
- widthIncrMainWindow = (width -leftRightBorder) - mainWindow->frameSize ().width ();
230
- heightIncrMainWindow = height - mainWindow->frameSize ().height ();
231
189
mainWindow->setEnabled (false ); // avoid getting two resize events for the main canvas
232
- mainWindow->resize (mainWindow->width () + widthIncrMainWindow, mainWindow->height () + heightIncrMainWindow);
233
- mainWindow->move (leftRightBorder, 0 );
190
+ mainWindow->resize (newMainWindowWidth, newMainWindowHeight);
191
+ // Resize again to account for frame border width -- Probably a better way to do this.
192
+ mainWindow->resize (newMainWindowWidth - (mainWindow->width () - newMainWindowWidth), newMainWindowHeight - (mainWindow->height () - newMainWindowHeight));
193
+ mainWindow->move (myScreenWidth - newMainWindowWidth, 0 );
234
194
mainWindow->setEnabled (true );
235
-
236
- // place point dialog
237
- widthIncrPointDialog = leftRightBorder - mPointDialog ->frameSize ().width ();
238
- heightIncrPointDialog = height - pluginPointDialogBorder - mPointDialog ->frameSize ().height ();
239
- mPointDialog ->resize (mPointDialog ->width () + widthIncrPointDialog, mPointDialog ->height () + heightIncrPointDialog);
240
- mPointDialog ->move (0 , pluginPointDialogBorder);
241
-
195
+
242
196
// place this dialog
243
- widthIncrThis = leftRightBorder - frameSize ().width ();
244
- heightIncrThis = pluginPointDialogBorder - frameSize ().height ();
245
- resize (this ->width () + widthIncrThis, this ->height () + heightIncrThis);
197
+ resize (newPluginDialogWidth, newPluginDialogHeight);
198
+ resize (newPluginDialogWidth - (width () - newPluginDialogWidth), newPluginDialogHeight - (height () - newPluginDialogHeight));
246
199
move (0 , 0 );
200
+
201
+ // place point dialog
202
+ mPointDialog ->resize (newPointDialogWidth, newPointDialogHeight);
203
+ mPointDialog ->resize (newPointDialogWidth - (mPointDialog ->width () - newPointDialogWidth), newPointDialogHeight - (mPointDialog ->height () - newPointDialogHeight));
204
+ mPointDialog ->move (0 , int (myScreenHeight * 0.3 ));
205
+
206
+
247
207
}
248
208
}
249
209
0 commit comments