]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Avoid opening unused tabs which are closed again after startup has finished (when...
authorEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Tue, 8 Jul 2014 17:16:17 +0000 (19:16 +0200)
committerEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Tue, 8 Jul 2014 17:16:17 +0000 (19:16 +0200)
Instead of always opening a new tab with the home url and closing it again when directory/file urls are passed on,
we now use the given directories/files directly to open new tabs on startup.

Makes the code easier and we can reuse openDirectories/openFiles in future (if needed).

REVIEW: 118966

src/dolphinapplication.cpp
src/dolphinmainwindow.cpp

index 8e83a85928a0dadf56f5b0969c99c9f409e4d8f6..a4b105b90f31dfbb2be0c9243be710e65f9f889c 100644 (file)
@@ -34,7 +34,6 @@ DolphinApplication::DolphinApplication() :
 
     m_mainWindow = new DolphinMainWindow();
     m_mainWindow->setAttribute(Qt::WA_DeleteOnClose);
 
     m_mainWindow = new DolphinMainWindow();
     m_mainWindow->setAttribute(Qt::WA_DeleteOnClose);
-    m_mainWindow->show();
 
     KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
 
 
     KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
 
@@ -71,6 +70,9 @@ DolphinApplication::DolphinApplication() :
         } else {
             m_mainWindow->openDirectories(urls);
         }
         } else {
             m_mainWindow->openDirectories(urls);
         }
+    } else {
+        const KUrl homeUrl(GeneralSettings::homeUrl());
+        m_mainWindow->openNewActivatedTab(homeUrl);
     }
 
     if (resetSplitSettings) {
     }
 
     if (resetSplitSettings) {
@@ -78,6 +80,8 @@ DolphinApplication::DolphinApplication() :
     }
 
     args->clear();
     }
 
     args->clear();
+
+    m_mainWindow->show();
 }
 
 DolphinApplication::~DolphinApplication()
 }
 
 DolphinApplication::~DolphinApplication()
index d9fe6458d7dc3f4cd0bf2ed6a20882dbe77d0247..0c48928bf482b5356dd762aa6dc514b8ab7c6ebc 100644 (file)
@@ -198,9 +198,6 @@ DolphinMainWindow::DolphinMainWindow() :
     if (!showMenu) {
         createControlButton();
     }
     if (!showMenu) {
         createControlButton();
     }
-
-    const KUrl homeUrl(generalSettings->homeUrl());
-    openNewActivatedTab(homeUrl);
 }
 
 DolphinMainWindow::~DolphinMainWindow()
 }
 
 DolphinMainWindow::~DolphinMainWindow()
@@ -209,17 +206,6 @@ DolphinMainWindow::~DolphinMainWindow()
 
 void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
 {
 
 void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
 {
-    if (dirs.isEmpty()) {
-        return;
-    }
-
-    if (dirs.count() == 1) {
-        m_activeViewContainer->setUrl(dirs.first());
-        return;
-    }
-
-    const int oldOpenTabsCount = m_viewTab.count();
-
     const bool hasSplitView = GeneralSettings::splitView();
 
     // Open each directory inside a new tab. If the "split view" option has been enabled,
     const bool hasSplitView = GeneralSettings::splitView();
 
     // Open each directory inside a new tab. If the "split view" option has been enabled,
@@ -234,11 +220,6 @@ void DolphinMainWindow::openDirectories(const QList<KUrl>& dirs)
             openNewTab(primaryUrl);
         }
     }
             openNewTab(primaryUrl);
         }
     }
-
-    // Remove the previously opened tabs
-    for (int i = 0; i < oldOpenTabsCount; ++i) {
-        closeTab(0);
-    }
 }
 
 void DolphinMainWindow::openFiles(const QList<KUrl>& files)
 }
 
 void DolphinMainWindow::openFiles(const QList<KUrl>& files)
@@ -516,6 +497,13 @@ void DolphinMainWindow::openInNewWindow()
 void DolphinMainWindow::showEvent(QShowEvent* event)
 {
     KXmlGuiWindow::showEvent(event);
 void DolphinMainWindow::showEvent(QShowEvent* event)
 {
     KXmlGuiWindow::showEvent(event);
+
+    if (!m_activeViewContainer && m_viewTab.count() > 0) {
+        // If we have no active view container yet, we set the primary view container
+        // of the first tab as active view container.
+        setActiveTab(0);
+    }
+
     if (!event->spontaneous()) {
         m_activeViewContainer->view()->setFocus();
     }
     if (!event->spontaneous()) {
         m_activeViewContainer->view()->setFocus();
     }