[LyX/master] Force a uniform style for group boxes, on Mac non-flat works better, on Linux flat is standard

Stephan Witt switt at lyx.org
Fri Aug 7 08:33:28 UTC 2020


commit 3af8ff39fc07831539cc594531d1400f789328ff
Author: Stephan Witt <switt at lyx.org>
Date:   Fri Aug 7 10:54:12 2020 +0200

    Force a uniform style for group boxes, on Mac non-flat works better, on Linux flat is standard
---
 src/frontends/qt/GuiView.cpp |   17 +++++++++++++++++
 src/frontends/qt/GuiView.h   |    2 ++
 2 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index 3160a1f..a316fe5 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -95,6 +95,7 @@
 #include <QDropEvent>
 #include <QFuture>
 #include <QFutureWatcher>
+#include <QGroupBox>
 #include <QLabel>
 #include <QList>
 #include <QMenu>
@@ -4786,6 +4787,19 @@ void GuiView::resetDialogs()
 }
 
 
+void GuiView::flatGroupBoxes(const QObject * widget, bool flag)
+{
+	for (const QObject * child: qAsConst(widget->children())) {
+		if (child->inherits("QGroupBox")) {
+			QGroupBox * box = (QGroupBox*) child;
+			box->setFlat(flag);
+		} else {
+			flatGroupBoxes(child, flag);
+		}
+	}
+}
+
+
 Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
 {
 	if (!isValidName(name))
@@ -4801,6 +4815,9 @@ Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
 
 	Dialog * dialog = build(name);
 	d.dialogs_[name].reset(dialog);
+	// Force a uniform style for group boxes
+	// On Mac non-flat works better, on Linux flat is standard
+	flatGroupBoxes(dialog->asQWidget(), guiApp->platformName() != "cocoa");
 	if (lyxrc.allow_geometry_session)
 		dialog->restoreSession();
 	if (hide_it)
diff --git a/src/frontends/qt/GuiView.h b/src/frontends/qt/GuiView.h
index ab60098..d611b39 100644
--- a/src/frontends/qt/GuiView.h
+++ b/src/frontends/qt/GuiView.h
@@ -236,6 +236,8 @@ private Q_SLOTS:
 	///
 	void resetWindowTitle();
 
+	void flatGroupBoxes(const QObject * object, bool flag);
+
 	///
 	void checkCancelBackground();
 	///


More information about the lyx-cvs mailing list