[rkward/frameworks] /: Finally found out the cause of plugin window mis-placement (or at least how to work around this).
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Fri Mar 18 13:05:47 UTC 2016
Git commit c8e06e556a703bbf63a511c44ad8b287bba695e5 by Thomas Friedrichsmeier.
Committed on 18/03/2016 at 13:03.
Pushed by tfry into branch 'frameworks'.
Finally found out the cause of plugin window mis-placement (or at least how to work around this).
Apparently it seems to happen, whenever the widget's sizeHint() is _too small_ on initial show.
Presumably, then, the size gets fixed up in the middle of showing, somehow, and this messes up the placement.
M +0 -1 TODO
M +7 -5 rkward/plugin/rkstandardcomponentgui.cpp
http://commits.kde.org/rkward/c8e06e556a703bbf63a511c44ad8b287bba695e5
diff --git a/TODO b/TODO
index d68ff16..9371cd9 100644
--- a/TODO
+++ b/TODO
@@ -9,7 +9,6 @@ Things to test at the end:
- Everthing concerning loading / saving, from recent files, scripts, workspace, etc.
- Moved installations, moved workspaces.
Knwon issues to fix:
-- Initial window placement for plugins is completely borked. One way around this seems to be to inherit RKStandardComponentGUI from QDialog. Does that work for inline embedded plugins?
- Initial window placement for plots is always 0, 0 on screen 1, apparently. The above workaround may not be available, here?
Minor layout stuff to fix in plugins:
diff --git a/rkward/plugin/rkstandardcomponentgui.cpp b/rkward/plugin/rkstandardcomponentgui.cpp
index 280c45b..f6ad9cc 100644
--- a/rkward/plugin/rkstandardcomponentgui.cpp
+++ b/rkward/plugin/rkstandardcomponentgui.cpp
@@ -171,16 +171,12 @@ RKStandardComponentGUI::~RKStandardComponentGUI () {
void RKStandardComponentGUI::createDialog (bool switchable) {
RK_TRACE (PLUGIN);
- QVBoxLayout *main_vbox = new QVBoxLayout (this);
- main_vbox->setContentsMargins (0, 0, 0, 0);
-
QWidget *central_widget = new QWidget ();
QHBoxLayout *hbox = new QHBoxLayout (central_widget);
// build standard elements
main_widget = new QWidget (central_widget);
new QVBoxLayout (main_widget);
- main_widget->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); // HACK to achieve sane initial size. Will be reset to Preferred/Preferred after show.
hbox->addWidget (main_widget);
// lines
@@ -241,6 +237,9 @@ void RKStandardComponentGUI::createDialog (bool switchable) {
hsplitter->setOrientation (Qt::Horizontal);
vsplitter = new RKExtensionSplitter (this, this, hsplitter, vpreview_area);
vsplitter->setOrientation (Qt::Vertical);
+
+ QVBoxLayout *main_vbox = new QVBoxLayout (this);
+ main_vbox->setContentsMargins (0, 0, 0, 0);
main_vbox->addWidget (vsplitter);
}
@@ -296,6 +295,10 @@ void RKStandardComponentGUI::finalize () {
} else {
vpreview_area->hide ();
}
+
+ // (With Qt 5.4.1) it seems *very* important to call this before the first show. Otherwise we will see strange placement issues, esp. in multi-monitor setup.
+ // Yes, that's right. placement, not initial size. For whatever reason.
+ main_widget->updateGeometry ();
}
RKXMLGUIPreviewArea* RKStandardComponentGUI::addDockedPreview (RKComponentPropertyBool *controller, const QString& label, const QString &id, bool bottom) {
@@ -379,7 +382,6 @@ void RKStandardComponentGUI::doPostShowCleanup () {
if (toggle_code_box) { // is Dialog
hpreview_area->setMinimumWidth (80);
vpreview_area->setMinimumHeight (40);
- main_widget->setSizePolicy (QSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred));
previewVisibilityChanged (0);
}
}
More information about the rkward-tracker
mailing list