void DolphinMainWindow::slotShowHiddenFilesChanged()
{
- KToggleAction* showHiddenFilesAction =
- static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
+ QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files");
const DolphinView* view = m_activeViewContainer->view();
showHiddenFilesAction->setChecked(view->showHiddenFiles());
}
void DolphinMainWindow::slotCategorizedSortingChanged()
{
- KToggleAction* showInGroupsAction =
- static_cast<KToggleAction*>(actionCollection()->action("show_in_groups"));
+ QAction* showInGroupsAction = actionCollection()->action("show_in_groups");
const DolphinView* view = m_activeViewContainer->view();
showInGroupsAction->setChecked(view->categorizedSorting());
showInGroupsAction->setEnabled(view->supportsCategorizedSorting());
}
if (action != 0) {
- KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
- toggleAction->setChecked(true);
+ action->setChecked(true);
}
}
void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order)
{
- KToggleAction* descending = static_cast<KToggleAction*>(actionCollection()->action("descending"));
+ QAction* descending = actionCollection()->action("descending");
const bool sortDescending = (order == Qt::DescendingOrder);
descending->setChecked(sortDescending);
}
void DolphinMainWindow::updateFilterBarAction(bool show)
{
- KToggleAction* showFilterBarAction =
- static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
+ QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
showFilterBarAction->setChecked(show);
}
m_activeViewContainer->view()->toggleSortOrder();
}
-void DolphinMainWindow::toggleSortCategorization()
+void DolphinMainWindow::toggleSortCategorization(bool categorizedSorting)
{
DolphinView* view = m_activeViewContainer->view();
- const bool categorizedSorting = view->categorizedSorting();
- view->setCategorizedSorting(!categorizedSorting);
+ view->setCategorizedSorting(categorizedSorting);
}
void DolphinMainWindow::toggleSplitView()
{
}
-void DolphinMainWindow::togglePreview()
+void DolphinMainWindow::togglePreview(bool show)
{
clearStatusBar();
-
- const KToggleAction* showPreviewAction =
- static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
- const bool show = showPreviewAction->isChecked();
m_activeViewContainer->view()->setShowPreview(show);
}
-void DolphinMainWindow::toggleShowHiddenFiles()
+void DolphinMainWindow::toggleShowHiddenFiles(bool show)
{
clearStatusBar();
-
- const KToggleAction* showHiddenFilesAction =
- static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
- const bool show = showHiddenFilesAction->isChecked();
m_activeViewContainer->view()->setShowHiddenFiles(show);
}
-void DolphinMainWindow::toggleFilterBarVisibility()
+void DolphinMainWindow::toggleFilterBarVisibility(bool show)
{
- const KToggleAction* showFilterBarAction =
- static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
- const bool show = showFilterBarAction->isChecked();
m_activeViewContainer->showFilterBar(show);
}
{
clearStatusBar();
- KToggleAction* action = static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
-
- bool editOrBrowse = action->isChecked();
+ QAction* action = actionCollection()->action("editable_location");
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
- urlNavigator->setUrlEditable(editOrBrowse);
+ urlNavigator->setUrlEditable(action->isChecked());
}
void DolphinMainWindow::editLocation()
viewModeGroup->addAction(columnView);
connect(viewModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(setViewMode(QAction*)));
+ // TODO use a QActionGroup
+
KToggleAction* sortByName = actionCollection()->add<KToggleAction>("sort_by_name");
sortByName->setText(i18nc("@action:inmenu Sort By", "Name"));
connect(sortByName, SIGNAL(triggered()), this, SLOT(sortByName()));
KAction* sortDescending = DolphinView::createSortDescendingAction(actionCollection());
connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
- KToggleAction* showInGroups = actionCollection()->add<KToggleAction>("show_in_groups");
- showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups"));
- connect(showInGroups, SIGNAL(triggered()), this, SLOT(toggleSortCategorization()));
+ KAction* showInGroups = DolphinView::createShowInGroupsAction(actionCollection());
+ connect(showInGroups, SIGNAL(triggered(bool)), this, SLOT(toggleSortCategorization(bool)));
QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection());
connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(toggleAdditionalInfo(QAction*)));
- KToggleAction* showPreview = actionCollection()->add<KToggleAction>("show_preview");
- showPreview->setText(i18nc("@action:intoolbar", "Preview"));
- showPreview->setIcon(KIcon("view-preview"));
- connect(showPreview, SIGNAL(triggered()), this, SLOT(togglePreview()));
+ KAction* showPreview = DolphinView::createShowPreviewAction(actionCollection());
+ connect(showPreview, SIGNAL(triggered(bool)), this, SLOT(togglePreview(bool)));
- KToggleAction* showHiddenFiles = actionCollection()->add<KToggleAction>("show_hidden_files");
- showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files"));
- showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period);
- connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles()));
+ KAction* showHiddenFiles = DolphinView::createShowHiddenFilesAction(actionCollection());
+ connect(showHiddenFiles, SIGNAL(triggered(bool)), this, SLOT(toggleShowHiddenFiles(bool)));
KAction* split = actionCollection()->addAction("split_view");
split->setShortcut(Qt::Key_F3);
KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I);
- connect(showFilterBar, SIGNAL(triggered()), this, SLOT(toggleFilterBarVisibility()));
+ connect(showFilterBar, SIGNAL(triggered(bool)), this, SLOT(toggleFilterBarVisibility(bool)));
KAction* compareFiles = actionCollection()->addAction("compare_files");
compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
QAction* action = actionCollection()->action(view->currentViewModeActionName());
if (action != 0) {
- KToggleAction* toggleAction = static_cast<KToggleAction*>(action);
- toggleAction->setChecked(true);
+ action->setChecked(true);
}
slotSortingChanged(view->sorting());
slotCategorizedSortingChanged();
slotAdditionalInfoChanged();
- KToggleAction* showFilterBarAction =
- static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
+ QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
- KToggleAction* showPreviewAction =
- static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
+ QAction* showPreviewAction = actionCollection()->action("show_preview");
showPreviewAction->setChecked(view->showPreview());
- KToggleAction* showHiddenFilesAction =
- static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
+ QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files");
showHiddenFilesAction->setChecked(view->showHiddenFiles());
updateSplitAction();
- KToggleAction* editableLocactionAction =
- static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
+ QAction* editableLocactionAction = actionCollection()->action("editable_location");
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
editableLocactionAction->setChecked(urlNavigator->isUrlEditable());
}
void toggleSortOrder();
/** Switches between sorting by categories or not. */
- void toggleSortCategorization();
+ void toggleSortCategorization(bool);
/**
* Switches on or off the displaying of additional information
void stopLoading();
/** Switches between showing a preview of the file content and showing the icon. */
- void togglePreview();
+ void togglePreview(bool);
/**
- * Switches between showing and hiding of hidden marked files dependent
- * from the current state of the 'Show Hidden Files' menu toggle action.
+ * Switches between showing and hiding of hidden marked files
*/
- void toggleShowHiddenFiles();
+ void toggleShowHiddenFiles(bool);
/**
- * Toggles between showing and hiding of the filter bar dependent
- * from the current state of the 'Show Filter Bar' menu toggle action.
+ * Toggles between showing and hiding of the filter bar
*/
- void toggleFilterBarVisibility();
+ void toggleFilterBarVisibility(bool show);
/** Increases the size of the current set view mode. */
void zoomIn();
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()),
// [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)
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());
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"
*/
void createDir();
+ /** Updates the state of the 'Show preview' menu action. */
+ void slotShowPreviewChanged();
+
+ /** Updates the state of the 'Show hidden files' menu action. */
+ void slotShowHiddenFilesChanged();
+
+ /** Updates the state of the 'Categorized sorting' menu action. */
+ void slotCategorizedSortingChanged();
+
/** Updates the state of the 'Sort Ascending/Descending' action. */
void slotSortOrderChanged(Qt::SortOrder);
return sortDescending;
}
+KAction* DolphinView::createShowPreviewAction(KActionCollection* collection)
+{
+ KToggleAction* showPreview = collection->add<KToggleAction>("show_preview");
+ showPreview->setText(i18nc("@action:intoolbar", "Preview"));
+ showPreview->setIcon(KIcon("view-preview"));
+ return showPreview;
+}
+
+KAction* DolphinView::createShowInGroupsAction(KActionCollection* collection)
+{
+ KToggleAction* showInGroups = collection->add<KToggleAction>("show_in_groups");
+ showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups"));
+ return showInGroups;
+}
+
+KAction* DolphinView::createShowHiddenFilesAction(KActionCollection* collection)
+{
+ KToggleAction* showHiddenFiles = collection->add<KToggleAction>("show_hidden_files");
+ showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files"));
+ showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period);
+ return showHiddenFiles;
+}
+
QActionGroup* DolphinView::createAdditionalInformationActionGroup(KActionCollection* collection)
{
QActionGroup* showInformationGroup = new QActionGroup(collection);
* Changes the view mode for the current directory to \a mode.
* If the view properties should be remembered for each directory
* (GeneralSettings::globalViewProps() returns false), then the
- * changed view mode will be be stored automatically.
+ * changed view mode will be stored automatically.
*/
void setMode(Mode mode);
Mode mode() const;
- /**
- * Turns on the file preview for the all files of the current directory,
- * if \a show is true.
- * If the view properties should be remembered for each directory
- * (GeneralSettings::globalViewProps() returns false), then the
- * preview setting will be be stored automatically.
- */
- void setShowPreview(bool show);
+ /** See setShowPreview */
bool showPreview() const;
- /**
- * Shows all hidden files of the current directory,
- * if \a show is true.
- * If the view properties should be remembered for each directory
- * (GeneralSettings::globalViewProps() returns false), then the
- * show hidden file setting will be be stored automatically.
- */
- void setShowHiddenFiles(bool show);
+ /** See setShowHiddenFiles */
bool showHiddenFiles() const;
- /**
- * Summarizes all sorted items by their category \a categorized
- * is true.
- * If the view properties should be remembered for each directory
- * (GeneralSettings::globalViewProps() returns false), then the
- * categorized sorting setting will be be stored automatically.
- */
- void setCategorizedSorting(bool categorized);
+ /** See setCategorizedSorting */
bool categorizedSorting() const;
/**
*/
static QActionGroup* createAdditionalInformationActionGroup(KActionCollection* collection);
+ /**
+ * Creates the "show preview" action.
+ * This code is here to share it between the mainwindow and the part
+ */
+ static KAction* createShowPreviewAction(KActionCollection* collection);
+
+ /**
+ * Creates the "show in groups" action.
+ * This code is here to share it between the mainwindow and the part
+ */
+ static KAction* createShowInGroupsAction(KActionCollection* collection);
+
+ /**
+ * Creates the "show hidden files" action.
+ * This code is here to share it between the mainwindow and the part
+ */
+ static KAction* createShowHiddenFilesAction(KActionCollection* collection);
+
/**
* Updates the state of the 'Additional Information' actions in \a collection.
*/
/** Pastes the clipboard data to this view. */
void paste();
+ /**
+ * Turns on the file preview for the all files of the current directory,
+ * if \a show is true.
+ * If the view properties should be remembered for each directory
+ * (GeneralSettings::globalViewProps() returns false), then the
+ * preview setting will be stored automatically.
+ */
+ void setShowPreview(bool show);
+
+ /**
+ * Shows all hidden files of the current directory,
+ * if \a show is true.
+ * If the view properties should be remembered for each directory
+ * (GeneralSettings::globalViewProps() returns false), then the
+ * show hidden file setting will be stored automatically.
+ */
+ void setShowHiddenFiles(bool show);
+
+ /**
+ * Summarizes all sorted items by their category \a categorized
+ * is true.
+ * If the view properties should be remembered for each directory
+ * (GeneralSettings::globalViewProps() returns false), then the
+ * categorized sorting setting will be stored automatically.
+ */
+ void setCategorizedSorting(bool categorized);
+
/** Switches between an ascending and descending sorting order. */
void toggleSortOrder();