[LyX/master] Use document mode on work area and docks on macOS

Stephan Witt switt at lyx.org
Fri Feb 26 18:57:32 UTC 2021


commit d74367a96e33e3f6cdea273261e262a13339d781
Author: Daniel Ramoeller <d.lyx at web.de>
Date:   Mon Feb 22 06:22:51 2021 +0100

    Use document mode on work area and docks on macOS
    
    - More fittingly (plain) looking tabs for documents and docks.
    - Also macOS fix for bug #9391.
---
 src/frontends/qt/GuiView.cpp     |    5 ++++
 src/frontends/qt/GuiWorkArea.cpp |   47 +++++++++++--------------------------
 2 files changed, 19 insertions(+), 33 deletions(-)

diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp
index c287889..a48540d 100644
--- a/src/frontends/qt/GuiView.cpp
+++ b/src/frontends/qt/GuiView.cpp
@@ -602,6 +602,11 @@ GuiView::GuiView(int id)
 	// (such as "source" and "messages")
 	setDockOptions(QMainWindow::ForceTabbedDocks);
 
+#ifdef Q_OS_MAC
+	// use document mode tabs on docks
+	setDocumentMode(true);
+#endif
+
 	// For Drag&Drop.
 	setAcceptDrops(true);
 
diff --git a/src/frontends/qt/GuiWorkArea.cpp b/src/frontends/qt/GuiWorkArea.cpp
index 02e03aa..39be80c 100644
--- a/src/frontends/qt/GuiWorkArea.cpp
+++ b/src/frontends/qt/GuiWorkArea.cpp
@@ -1470,41 +1470,9 @@ void EmbeddedWorkArea::disable()
 //
 ////////////////////////////////////////////////////////////////////
 
-#ifdef Q_OS_MAC
-class NoTabFrameMacStyle : public QProxyStyle {
-public:
-	///
-	QRect subElementRect(SubElement element, const QStyleOption * option,
-			     const QWidget * widget = 0) const
-	{
-		QRect rect = QProxyStyle::subElementRect(element, option, widget);
-		bool noBar = static_cast<QTabWidget const *>(widget)->count() <= 1;
-
-		// The Qt Mac style puts the contents into a 3 pixel wide box
-		// which looks very ugly and not like other Mac applications.
-		// Hence we remove this here, and moreover the 16 pixel round
-		// frame above if the tab bar is hidden.
-		if (element == QStyle::SE_TabWidgetTabContents) {
-			rect.adjust(- rect.left(), 0, rect.left(), 0);
-			if (noBar)
-				rect.setTop(0);
-		}
-
-		return rect;
-	}
-};
-
-NoTabFrameMacStyle noTabFrameMacStyle;
-#endif
-
-
 TabWorkArea::TabWorkArea(QWidget * parent)
 	: QTabWidget(parent), clicked_tab_(-1), midpressed_tab_(-1)
 {
-#ifdef Q_OS_MAC
-	setStyle(&noTabFrameMacStyle);
-#endif
-
 	QPalette pal = palette();
 	pal.setColor(QPalette::Active, QPalette::Button,
 		pal.color(QPalette::Active, QPalette::Window));
@@ -1544,6 +1512,10 @@ TabWorkArea::TabWorkArea(QWidget * parent)
 	        this, SLOT(closeTab(int)));
 
 	setUsesScrollButtons(true);
+#ifdef Q_OS_MAC
+	// use document mode tabs
+	setDocumentMode(true);
+#endif
 }
 
 
@@ -1634,7 +1606,16 @@ void TabWorkArea::showBar(bool show)
 {
 	tabBar()->setEnabled(show);
 	tabBar()->setVisible(show);
-	closeBufferButton->setVisible(show && lyxrc.single_close_tab_button);
+	if (documentMode()) {
+		// avoid blank corner widget when documentMode(true) is used
+		if (show && lyxrc.single_close_tab_button) {
+			setCornerWidget(closeBufferButton, Qt::TopRightCorner);
+			closeBufferButton->setVisible(true);
+		} else
+			// remove corner widget
+			setCornerWidget(nullptr);
+	} else
+		closeBufferButton->setVisible(show && lyxrc.single_close_tab_button);
 	setTabsClosable(!lyxrc.single_close_tab_button);
 }
 


More information about the lyx-cvs mailing list