]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinpart.cpp
Centralize three more actions so that they are available in DolphinPart: 'Show previe...
[dolphin.git] / src / dolphinpart.cpp
index d26f14061fd00722fd383fd8cba7ace4f0de0e5b..4d2eebcc63037c798b08445efc4df445b528e5c2 100644 (file)
@@ -93,6 +93,17 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
             this, SLOT(slotUrlChanged(KUrl)));
     connect(m_view, SIGNAL(modeChanged()),
             this, SLOT(updateViewActions()));
+    connect(m_view, SIGNAL(showPreviewChanged()),
+            this, SLOT(slotShowPreviewChanged()));
+    connect(m_view, SIGNAL(showHiddenFilesChanged()),
+            this, SLOT(slotShowHiddenFilesChanged()));
+    connect(m_view, SIGNAL(categorizedSortingChanged()),
+            this, SLOT(slotCategorizedSortingChanged()));
+    // TODO slotSortingChanged
+    connect(m_view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
+            this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
+    connect(m_view, SIGNAL(additionalInfoChanged()),
+            this, SLOT(slotAdditionalInfoChanged()));
 
     QClipboard* clipboard = QApplication::clipboard();
     connect(clipboard, SIGNAL(dataChanged()),
@@ -106,7 +117,6 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
     // [Q_PROPERTY introspection?]
 
     // TODO sort_by_* actions
-    // TODO show_*_info actions
 
     // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
     // (sort of spacial navigation)
@@ -144,16 +154,30 @@ void DolphinPart::createActions()
     propertiesAction->setShortcut(Qt::ALT+Qt::Key_Return);
     connect(propertiesAction, SIGNAL(triggered()), SLOT(slotProperties()));
 
-    // This action doesn't appear in the GUI, it's for the shortcut only.
-    // KNewMenu takes care of the GUI stuff.
-    KAction* newDirAction = actionCollection()->addAction( "create_dir" );
-    newDirAction->setText( i18n("Create Folder..." ) );
-    connect(newDirAction, SIGNAL(triggered()), SLOT(slotNewDir()));
-    newDirAction->setShortcut(Qt::Key_F10);
-    widget()->addAction(newDirAction);
+    // View menu
+
+    // TODO sort_by_*
+
+    KAction* sortDescending = DolphinView::createSortDescendingAction(actionCollection());
+    connect(sortDescending, SIGNAL(triggered()), m_view, SLOT(toggleSortOrder()));
+
+    QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection());
+    connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), m_view, SLOT(toggleAdditionalInfo(QAction*)));
+
+    KAction* showPreview = DolphinView::createShowPreviewAction(actionCollection());
+    connect(showPreview, SIGNAL(triggered(bool)), m_view, SLOT(setShowPreview(bool)));
+
+    KAction* showInGroups = DolphinView::createShowInGroupsAction(actionCollection());
+    connect(showInGroups, SIGNAL(triggered(bool)), m_view, SLOT(setCategorizedSorting(bool)));
+
+    KAction* showHiddenFiles = DolphinView::createShowHiddenFilesAction(actionCollection());
+    connect(showHiddenFiles, SIGNAL(triggered(bool)), m_view, SLOT(setShowHiddenFiles(bool)));
 
     // Go menu
 
+    KAction* newDirAction = DolphinView::createNewDirAction(actionCollection());
+    connect(newDirAction, SIGNAL(triggered()), SLOT(createDir()));
+
     QActionGroup* goActionGroup = new QActionGroup(this);
     connect(goActionGroup, SIGNAL(triggered(QAction*)),
             this, SLOT(slotGoTriggered(QAction*)));
@@ -414,11 +438,6 @@ void DolphinPart::slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers mod
         m_view->trashSelectedItems();
 }
 
-void DolphinPart::slotNewDir()
-{
-    KonqOperations::newDir(widget(), url());
-}
-
 void DolphinPart::slotEditMimeType()
 {
     const KFileItemList items = m_view->selectedItems();
@@ -436,4 +455,42 @@ void DolphinPart::slotProperties()
     }
 }
 
+void DolphinPart::createDir()
+{
+    KonqOperations::newDir(m_view, url());
+}
+
+void DolphinPart::slotSortOrderChanged(Qt::SortOrder order)
+{
+    KToggleAction* descending = static_cast<KToggleAction*>(actionCollection()->action("descending"));
+    const bool sortDescending = (order == Qt::DescendingOrder);
+    descending->setChecked(sortDescending);
+}
+
+void DolphinPart::slotAdditionalInfoChanged()
+{
+    m_view->updateAdditionalInfoActions(actionCollection());
+}
+
+void DolphinPart::slotShowPreviewChanged()
+{
+    updateViewActions(); // see DolphinMainWindow
+}
+
+void DolphinPart::slotShowHiddenFilesChanged()
+{
+    QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files");
+    showHiddenFilesAction->setChecked(m_view->showHiddenFiles());
+}
+
+void DolphinPart::slotCategorizedSortingChanged()
+{
+    // Duplicated from DolphinMainWindow too.
+    QAction* showInGroupsAction = actionCollection()->action("show_in_groups");
+    showInGroupsAction->setChecked(m_view->categorizedSorting());
+    showInGroupsAction->setEnabled(m_view->supportsCategorizedSorting());
+}
+
+// TODO a DolphinViewActionHandler for reducing the duplication in the action handling
+
 #include "dolphinpart.moc"