]> git.lyx.org Git - features.git/commitdiff
* on Mac close GuiView when the last tab was closed
authorStefan Schimanski <sts@lyx.org>
Fri, 14 Mar 2008 23:24:59 +0000 (23:24 +0000)
committerStefan Schimanski <sts@lyx.org>
Fri, 14 Mar 2008 23:24:59 +0000 (23:24 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23730 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h
src/frontends/qt4/GuiWorkArea.cpp
src/frontends/qt4/GuiWorkArea.h

index d03842cd8f1850fc65b9efbc5182f4c7697e38fa..89fa9618ca0d6caaefc2e36f480e23e93aabd7b6 100644 (file)
@@ -534,6 +534,22 @@ void GuiView::on_currentWorkAreaChanged(GuiWorkArea * wa)
 }
 
 
+void GuiView::on_lastWorkAreaRemoved()
+{
+#ifdef Q_WS_MAC
+       // On Mac close the view if there is no Tab open anymore,
+       // but only if no splitter is visible
+       if (d.splitter_->count() == 1) {
+               TabWorkArea * twa = qobject_cast<TabWorkArea *>(d.splitter_->widget(0));
+               if (twa && twa->count() == 0) {
+                       // close the view, as no tab is open anymore
+                       QTimer::singleShot(0, this, SLOT(close()));
+               }
+       }
+#endif
+}
+
+
 void GuiView::updateStatusBar()
 {
        // let the user see the explicit message
@@ -716,6 +732,9 @@ TabWorkArea * GuiView::addTabWorkArea()
        TabWorkArea * twa = new TabWorkArea;
        QObject::connect(twa, SIGNAL(currentWorkAreaChanged(GuiWorkArea *)),
                this, SLOT(on_currentWorkAreaChanged(GuiWorkArea *)));
+       QObject::connect(twa, SIGNAL(lastWorkAreaRemoved()),
+                        this, SLOT(on_lastWorkAreaRemoved()));
+
        d.splitter_->addWidget(twa);
        d.stack_widget_->setCurrentWidget(d.splitter_);
        return twa;
@@ -1108,7 +1127,7 @@ Buffer * GuiView::loadDocument(FileName const & filename, bool tolastfiles)
                setBusy(false);
                return 0;
        }
-
+       
        setBuffer(newBuffer);
 
        // scroll to the position when the file was last closed
index de64048c00265f8a9030da45b0e5a937e9458aa1..4ccc9a9030f6ea5c846517e28f084eafb465042b 100644 (file)
@@ -151,6 +151,8 @@ private Q_SLOTS:
 
        ///
        void on_currentWorkAreaChanged(GuiWorkArea *);
+       ///
+       void on_lastWorkAreaRemoved();
 
        /// slots to change the icon size
        void smallSizedIcons();
index 23e644a1954886e3bb5b666f1f7a700c21bc56a9..23429f634e41e2e45a0b616c7dfa63a4bb9190a8 100644 (file)
@@ -1324,7 +1324,9 @@ bool TabWorkArea::removeWorkArea(GuiWorkArea * work_area)
                else
                        // Hide tabbar if there's only one tab.
                        showBar(count() > 1);
-       }
+       } else
+               lastWorkAreaRemoved();
+
        return true;
 }
 
index 6c808677e43eb59a9b759af2e7f9a0ed54585f83..8e1a0aa68cc221857d68853e94381ffe0a73c027 100644 (file)
@@ -258,6 +258,8 @@ public:
 Q_SIGNALS:
        ///
        void currentWorkAreaChanged(GuiWorkArea *);
+       ///
+       void lastWorkAreaRemoved();
 
 public Q_SLOTS:
        ///