]> cloud.milkyroute.net Git - dolphin.git/commitdiff
* fixed issue that when having a split view, that both views get the same color after...
authorPeter Penz <peter.penz19@gmail.com>
Sun, 12 Aug 2007 17:48:29 +0000 (17:48 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 12 Aug 2007 17:48:29 +0000 (17:48 +0000)
* prepare for toggling the view icon depending from the activation state

svn path=/trunk/KDE/kdebase/apps/; revision=699311

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinview.cpp
src/dolphinview.h

index 641f12c050b629431b164ac1063937bb56276ad3..3f1153340a8d84628c9b41eca5b96793d9da11d5 100644 (file)
@@ -796,23 +796,31 @@ void DolphinMainWindow::showDateInfo()
 void DolphinMainWindow::toggleSplitView()
 {
     if (m_viewContainer[SecondaryView] == 0) {
-        const int newWidth = (m_viewContainer[PrimaryView]->width() - m_splitter->handleWidth()) / 2;
         // create a secondary view
+        const int newWidth = (m_viewContainer[PrimaryView]->width() - m_splitter->handleWidth()) / 2;
+
         const DolphinView* view = m_viewContainer[PrimaryView]->view();
-        m_viewContainer[SecondaryView] = new DolphinViewContainer(this,
-                                                                 0,
-                                                                 view->rootUrl());
+        m_viewContainer[SecondaryView] = new DolphinViewContainer(this, 0, view->rootUrl());
         connectViewSignals(SecondaryView);
         m_splitter->addWidget(m_viewContainer[SecondaryView]);
         m_splitter->setSizes(QList<int>() << newWidth << newWidth);
         m_viewContainer[SecondaryView]->view()->reload();
         m_viewContainer[SecondaryView]->setActive(false);
         m_viewContainer[SecondaryView]->show();
-    } else {
+    } else if (m_activeViewContainer == m_viewContainer[PrimaryView]) {
         // remove secondary view
         m_viewContainer[SecondaryView]->close();
         m_viewContainer[SecondaryView]->deleteLater();
         m_viewContainer[SecondaryView] = 0;
+    } else {
+        // The secondary view is active, hence from a users point of view
+        // the content of the secondary view should be moved to the primary view.
+        // From an implementation point of view it is more efficient to close
+        // the primary view and exchange the internal pointers afterwards.
+        m_viewContainer[PrimaryView]->close();
+        m_viewContainer[PrimaryView]->deleteLater();
+        m_viewContainer[PrimaryView] = m_viewContainer[SecondaryView];
+        m_viewContainer[SecondaryView] = 0;
     }
 
     setActiveViewContainer(m_viewContainer[PrimaryView]);
@@ -1028,11 +1036,9 @@ void DolphinMainWindow::init()
     updatePasteAction();
     updateGoActions();
 
-    const bool split = generalSettings->splitView();
-    if (split) {
+    if (generalSettings->splitView()) {
         toggleSplitView();
     }
-    updateSplitAction(split);
     updateViewActions();
 
     if (firstRun) {
@@ -1267,7 +1273,7 @@ void DolphinMainWindow::setupActions()
 
     QAction* split = actionCollection()->addAction("split_view");
     split->setShortcut(Qt::Key_F10);
-    updateSplitAction(false);
+    updateSplitAction();
     connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView()));
 
     QAction* reload = actionCollection()->addAction("reload");
@@ -1507,7 +1513,7 @@ void DolphinMainWindow::updateViewActions()
         static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
     showHiddenFilesAction->setChecked(view->showHiddenFiles());
 
-    updateSplitAction(m_viewContainer[SecondaryView] != 0);
+    updateSplitAction();
 
     KToggleAction* editableLocactionAction =
         static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
@@ -1580,12 +1586,17 @@ void DolphinMainWindow::connectViewSignals(int viewIndex)
             this, SLOT(slotHistoryChanged()));
 }
 
-void DolphinMainWindow::updateSplitAction(bool isSplit)
+void DolphinMainWindow::updateSplitAction()
 {
     QAction* splitAction = actionCollection()->action("split_view");
-    if (isSplit) {
+    if (m_viewContainer[SecondaryView] != 0) {
         splitAction->setText(i18nc("@action:intoolbar Join views", "Join"));
-        splitAction->setIcon(KIcon("fileview-join"));
+        if (m_activeViewContainer == m_viewContainer[PrimaryView]) {
+            splitAction->setIcon(KIcon("fileview-join"));
+        } else {
+            // TODO: replace by alternative icon as soon as it is available in Oxygen
+            splitAction->setIcon(KIcon("fileview-join"));
+        }
     } else {
         splitAction->setText(i18nc("@action:intoolbar Split view", "Split"));
         splitAction->setIcon(KIcon("fileview-split"));
index f8c0367e8e82dc21f4329f0d4b3429e61aee3946..b23e34136e1d84d913b0fffcf589fe797005c240 100644 (file)
@@ -457,11 +457,11 @@ private:
 
     /**
      * Updates the text of the split action:
-     * If \a isSplit is true, the text is set to "Split",
+     * If two views are shown, the text is set to "Split",
      * otherwise the text is set to "Join". The icon
-     * is updated to match with the text.
+     * is updated to match with the text and the currently active view.
      */
-    void updateSplitAction(bool isSplit);
+    void updateSplitAction();
 
 private:
     /**
index a9f160d007035ea00c84f31278793e8151b3aec9..197b4d8f95d966b6f6c674b814635980fd52f1fe 100644 (file)
@@ -134,19 +134,7 @@ void DolphinView::setActive(bool active)
 
     m_active = active;
 
-    QColor color = KColorScheme(KColorScheme::View).background();
-    if (active) {
-        emit urlChanged(url());
-        emit selectionChanged(selectedItems());
-    } else {
-        color.setAlpha(0);
-    }
-
-    QWidget* viewport = itemView()->viewport();
-    QPalette palette;
-    palette.setColor(viewport->backgroundRole(), color);
-    viewport->setPalette(palette);
-
+    updateViewportColor();
     update();
 
     if (active) {
@@ -438,6 +426,7 @@ void DolphinView::refresh()
     createView();
     applyViewProperties(m_controller->url());
     reload();
+    updateViewportColor();
 }
 
 void DolphinView::setUrl(const KUrl& url)
@@ -964,4 +953,20 @@ void DolphinView::applyCutItemEffect()
     }
 }
 
+void DolphinView::updateViewportColor()
+{
+    QColor color = KColorScheme(KColorScheme::View).background();
+    if (m_active) {
+        emit urlChanged(url());
+        emit selectionChanged(selectedItems());
+    } else {
+        color.setAlpha(0);
+    }
+
+    QWidget* viewport = itemView()->viewport();
+    QPalette palette;
+    palette.setColor(viewport->backgroundRole(), color);
+    viewport->setPalette(palette);
+}
+
 #include "dolphinview.moc"
index 39e39ef3f2fcff4ce1da0a5d604114c25728c922..a18b87d08ecc2cc7028d0a5beb3001b4ac3337ae 100644 (file)
@@ -517,6 +517,12 @@ private:
     /** Applies an item effect to all cut items. */
     void applyCutItemEffect();
 
+    /**
+     * Updates the color of the viewport depending from the
+     * activation state (see DolphinView::isActive()).
+     */
+    void updateViewportColor();
+
     /**
      * Returns true, if the ColumnView is activated. As the column view
      * requires some special handling for iterating through directories,