From d8df65532e92f6597a2a0574b88242f786c7f9d4 Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Tue, 4 Mar 2008 18:53:44 +0000 Subject: [PATCH] * make lyx look a bit more like a Mac application by removing frames around the work area. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23459 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiView.cpp | 3 +-- src/frontends/qt4/GuiWorkArea.cpp | 44 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 5b1c65575f..45a252f592 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1906,11 +1906,10 @@ void GuiView::lfunUiToggle(FuncRequest const & cmd) int l, t, r, b; getContentsMargins(&l, &t, &r, &b); //are the frames in default state? + d.current_work_area_->setFrameStyle(QFrame::NoFrame); if (l == 0) { - d.current_work_area_->setFrameStyle(QFrame::NoFrame); setContentsMargins(-2, -2, -2, -2); } else { - d.current_work_area_->setFrameStyle(QFrame::NoFrame); setContentsMargins(0, 0, 0, 0); } return; diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 1229d6b801..9a7c2fd9da 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -47,6 +47,9 @@ #include #include #include +#ifdef Q_WS_MAC +#include +#endif #include #include #include @@ -248,6 +251,11 @@ GuiWorkArea::GuiWorkArea(Buffer & buffer, GuiView & lv) setAcceptDrops(true); setMouseTracking(true); setMinimumSize(100, 70); +#ifdef Q_WS_MACX + setFrameStyle(QFrame::NoFrame); +#else + setFrameStyle(QFrame::Box); +#endif updateWindowTitle(); viewport()->setAutoFillBackground(false); @@ -298,7 +306,11 @@ void GuiWorkArea::setFullScreen(bool full_screen) if (lyxrc.full_screen_scrollbar) setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); } else { +#ifdef Q_WS_MACX + setFrameStyle(QFrame::NoFrame); +#else setFrameStyle(QFrame::Box); +#endif setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); } } @@ -1115,8 +1127,40 @@ bool GuiWorkArea::isFullScreen() // //////////////////////////////////////////////////////////////////// +#ifdef Q_WS_MACX +class NoTabFrameMacStyle : public QMacStyle { +public: + /// + QRect subElementRect(SubElement element, const QStyleOption * option, + const QWidget * widget = 0 ) const + { + QRect rect = QMacStyle::subElementRect(element, option, widget); + bool noBar = static_cast(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) { +#ifdef Q_WS_MACX + setStyle(&noTabFramemacStyle); +#endif + QPalette pal = palette(); pal.setColor(QPalette::Active, QPalette::Button, pal.color(QPalette::Active, QPalette::Window)); -- 2.39.2