keep in sync with 4.0 branch (767566)

svn path=/trunk/KDE/kdebase/apps/; revision=767567
This commit is contained in:
David Faure 2008-01-28 11:37:08 +00:00
parent f824a33461
commit a6f5c499ef
6 changed files with 150 additions and 86 deletions

View file

@ -191,16 +191,14 @@ void DolphinMainWindow::slotShowPreviewChanged()
void DolphinMainWindow::slotShowHiddenFilesChanged() void DolphinMainWindow::slotShowHiddenFilesChanged()
{ {
KToggleAction* showHiddenFilesAction = QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files");
static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
const DolphinView* view = m_activeViewContainer->view(); const DolphinView* view = m_activeViewContainer->view();
showHiddenFilesAction->setChecked(view->showHiddenFiles()); showHiddenFilesAction->setChecked(view->showHiddenFiles());
} }
void DolphinMainWindow::slotCategorizedSortingChanged() void DolphinMainWindow::slotCategorizedSortingChanged()
{ {
KToggleAction* showInGroupsAction = QAction* showInGroupsAction = actionCollection()->action("show_in_groups");
static_cast<KToggleAction*>(actionCollection()->action("show_in_groups"));
const DolphinView* view = m_activeViewContainer->view(); const DolphinView* view = m_activeViewContainer->view();
showInGroupsAction->setChecked(view->categorizedSorting()); showInGroupsAction->setChecked(view->categorizedSorting());
showInGroupsAction->setEnabled(view->supportsCategorizedSorting()); showInGroupsAction->setEnabled(view->supportsCategorizedSorting());
@ -244,14 +242,13 @@ void DolphinMainWindow::slotSortingChanged(DolphinView::Sorting sorting)
} }
if (action != 0) { if (action != 0) {
KToggleAction* toggleAction = static_cast<KToggleAction*>(action); action->setChecked(true);
toggleAction->setChecked(true);
} }
} }
void DolphinMainWindow::slotSortOrderChanged(Qt::SortOrder order) 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); const bool sortDescending = (order == Qt::DescendingOrder);
descending->setChecked(sortDescending); descending->setChecked(sortDescending);
} }
@ -297,8 +294,7 @@ void DolphinMainWindow::slotHistoryChanged()
void DolphinMainWindow::updateFilterBarAction(bool show) void DolphinMainWindow::updateFilterBarAction(bool show)
{ {
KToggleAction* showFilterBarAction = QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
showFilterBarAction->setChecked(show); showFilterBarAction->setChecked(show);
} }
@ -605,11 +601,10 @@ void DolphinMainWindow::toggleSortOrder()
m_activeViewContainer->view()->toggleSortOrder(); m_activeViewContainer->view()->toggleSortOrder();
} }
void DolphinMainWindow::toggleSortCategorization() void DolphinMainWindow::toggleSortCategorization(bool categorizedSorting)
{ {
DolphinView* view = m_activeViewContainer->view(); DolphinView* view = m_activeViewContainer->view();
const bool categorizedSorting = view->categorizedSorting(); view->setCategorizedSorting(categorizedSorting);
view->setCategorizedSorting(!categorizedSorting);
} }
void DolphinMainWindow::toggleSplitView() void DolphinMainWindow::toggleSplitView()
@ -657,31 +652,20 @@ void DolphinMainWindow::stopLoading()
{ {
} }
void DolphinMainWindow::togglePreview() void DolphinMainWindow::togglePreview(bool show)
{ {
clearStatusBar(); clearStatusBar();
const KToggleAction* showPreviewAction =
static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
const bool show = showPreviewAction->isChecked();
m_activeViewContainer->view()->setShowPreview(show); m_activeViewContainer->view()->setShowPreview(show);
} }
void DolphinMainWindow::toggleShowHiddenFiles() void DolphinMainWindow::toggleShowHiddenFiles(bool show)
{ {
clearStatusBar(); clearStatusBar();
const KToggleAction* showHiddenFilesAction =
static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
const bool show = showHiddenFilesAction->isChecked();
m_activeViewContainer->view()->setShowHiddenFiles(show); 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); m_activeViewContainer->showFilterBar(show);
} }
@ -701,11 +685,9 @@ void DolphinMainWindow::toggleEditLocation()
{ {
clearStatusBar(); clearStatusBar();
KToggleAction* action = static_cast<KToggleAction*>(actionCollection()->action("editable_location")); QAction* action = actionCollection()->action("editable_location");
bool editOrBrowse = action->isChecked();
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator(); KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
urlNavigator->setUrlEditable(editOrBrowse); urlNavigator->setUrlEditable(action->isChecked());
} }
void DolphinMainWindow::editLocation() void DolphinMainWindow::editLocation()
@ -978,6 +960,8 @@ void DolphinMainWindow::setupActions()
viewModeGroup->addAction(columnView); viewModeGroup->addAction(columnView);
connect(viewModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(setViewMode(QAction*))); connect(viewModeGroup, SIGNAL(triggered(QAction*)), this, SLOT(setViewMode(QAction*)));
// TODO use a QActionGroup
KToggleAction* sortByName = actionCollection()->add<KToggleAction>("sort_by_name"); KToggleAction* sortByName = actionCollection()->add<KToggleAction>("sort_by_name");
sortByName->setText(i18nc("@action:inmenu Sort By", "Name")); sortByName->setText(i18nc("@action:inmenu Sort By", "Name"));
connect(sortByName, SIGNAL(triggered()), this, SLOT(sortByName())); connect(sortByName, SIGNAL(triggered()), this, SLOT(sortByName()));
@ -1046,22 +1030,17 @@ void DolphinMainWindow::setupActions()
KAction* sortDescending = DolphinView::createSortDescendingAction(actionCollection()); KAction* sortDescending = DolphinView::createSortDescendingAction(actionCollection());
connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder())); connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
KToggleAction* showInGroups = actionCollection()->add<KToggleAction>("show_in_groups"); KAction* showInGroups = DolphinView::createShowInGroupsAction(actionCollection());
showInGroups->setText(i18nc("@action:inmenu View", "Show in Groups")); connect(showInGroups, SIGNAL(triggered(bool)), this, SLOT(toggleSortCategorization(bool)));
connect(showInGroups, SIGNAL(triggered()), this, SLOT(toggleSortCategorization()));
QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection()); QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection());
connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(toggleAdditionalInfo(QAction*))); connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(toggleAdditionalInfo(QAction*)));
KToggleAction* showPreview = actionCollection()->add<KToggleAction>("show_preview"); KAction* showPreview = DolphinView::createShowPreviewAction(actionCollection());
showPreview->setText(i18nc("@action:intoolbar", "Preview")); connect(showPreview, SIGNAL(triggered(bool)), this, SLOT(togglePreview(bool)));
showPreview->setIcon(KIcon("view-preview"));
connect(showPreview, SIGNAL(triggered()), this, SLOT(togglePreview()));
KToggleAction* showHiddenFiles = actionCollection()->add<KToggleAction>("show_hidden_files"); KAction* showHiddenFiles = DolphinView::createShowHiddenFilesAction(actionCollection());
showHiddenFiles->setText(i18nc("@action:inmenu View", "Show Hidden Files")); connect(showHiddenFiles, SIGNAL(triggered(bool)), this, SLOT(toggleShowHiddenFiles(bool)));
showHiddenFiles->setShortcut(Qt::ALT | Qt::Key_Period);
connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles()));
KAction* split = actionCollection()->addAction("split_view"); KAction* split = actionCollection()->addAction("split_view");
split->setShortcut(Qt::Key_F3); split->setShortcut(Qt::Key_F3);
@ -1116,7 +1095,7 @@ void DolphinMainWindow::setupActions()
KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar"); KToggleAction* showFilterBar = actionCollection()->add<KToggleAction>("show_filter_bar");
showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar")); showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I); 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"); KAction* compareFiles = actionCollection()->addAction("compare_files");
compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files")); compareFiles->setText(i18nc("@action:inmenu Tools", "Compare Files"));
@ -1277,8 +1256,7 @@ void DolphinMainWindow::updateViewActions()
QAction* action = actionCollection()->action(view->currentViewModeActionName()); QAction* action = actionCollection()->action(view->currentViewModeActionName());
if (action != 0) { if (action != 0) {
KToggleAction* toggleAction = static_cast<KToggleAction*>(action); action->setChecked(true);
toggleAction->setChecked(true);
} }
slotSortingChanged(view->sorting()); slotSortingChanged(view->sorting());
@ -1286,22 +1264,18 @@ void DolphinMainWindow::updateViewActions()
slotCategorizedSortingChanged(); slotCategorizedSortingChanged();
slotAdditionalInfoChanged(); slotAdditionalInfoChanged();
KToggleAction* showFilterBarAction = QAction* showFilterBarAction = actionCollection()->action("show_filter_bar");
static_cast<KToggleAction*>(actionCollection()->action("show_filter_bar"));
showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible()); showFilterBarAction->setChecked(m_activeViewContainer->isFilterBarVisible());
KToggleAction* showPreviewAction = QAction* showPreviewAction = actionCollection()->action("show_preview");
static_cast<KToggleAction*>(actionCollection()->action("show_preview"));
showPreviewAction->setChecked(view->showPreview()); showPreviewAction->setChecked(view->showPreview());
KToggleAction* showHiddenFilesAction = QAction* showHiddenFilesAction = actionCollection()->action("show_hidden_files");
static_cast<KToggleAction*>(actionCollection()->action("show_hidden_files"));
showHiddenFilesAction->setChecked(view->showHiddenFiles()); showHiddenFilesAction->setChecked(view->showHiddenFiles());
updateSplitAction(); updateSplitAction();
KToggleAction* editableLocactionAction = QAction* editableLocactionAction = actionCollection()->action("editable_location");
static_cast<KToggleAction*>(actionCollection()->action("editable_location"));
const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator(); const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
editableLocactionAction->setChecked(urlNavigator->isUrlEditable()); editableLocactionAction->setChecked(urlNavigator->isUrlEditable());
} }

View file

@ -271,7 +271,7 @@ private slots:
void toggleSortOrder(); void toggleSortOrder();
/** Switches between sorting by categories or not. */ /** Switches between sorting by categories or not. */
void toggleSortCategorization(); void toggleSortCategorization(bool);
/** /**
* Switches on or off the displaying of additional information * Switches on or off the displaying of additional information
@ -293,19 +293,17 @@ private slots:
void stopLoading(); void stopLoading();
/** Switches between showing a preview of the file content and showing the icon. */ /** 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 * Switches between showing and hiding of hidden marked files
* from the current state of the 'Show Hidden Files' menu toggle action.
*/ */
void toggleShowHiddenFiles(); void toggleShowHiddenFiles(bool);
/** /**
* Toggles between showing and hiding of the filter bar dependent * Toggles between showing and hiding of the filter bar
* from the current state of the 'Show Filter Bar' menu toggle action.
*/ */
void toggleFilterBarVisibility(); void toggleFilterBarVisibility(bool show);
/** Increases the size of the current set view mode. */ /** Increases the size of the current set view mode. */
void zoomIn(); void zoomIn();

View file

@ -93,6 +93,13 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
this, SLOT(slotUrlChanged(KUrl))); this, SLOT(slotUrlChanged(KUrl)));
connect(m_view, SIGNAL(modeChanged()), connect(m_view, SIGNAL(modeChanged()),
this, SLOT(updateViewActions())); 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)), connect(m_view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
this, SLOT(slotSortOrderChanged(Qt::SortOrder))); this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
connect(m_view, SIGNAL(additionalInfoChanged()), connect(m_view, SIGNAL(additionalInfoChanged()),
@ -110,7 +117,6 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
// [Q_PROPERTY introspection?] // [Q_PROPERTY introspection?]
// TODO sort_by_* actions // 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 // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
// (sort of spacial navigation) // (sort of spacial navigation)
@ -158,6 +164,15 @@ void DolphinPart::createActions()
QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection()); QActionGroup* showInformationActionGroup = DolphinView::createAdditionalInformationActionGroup(actionCollection());
connect(showInformationActionGroup, SIGNAL(triggered(QAction*)), m_view, SLOT(toggleAdditionalInfo(QAction*))); 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 // Go menu
KAction* newDirAction = DolphinView::createNewDirAction(actionCollection()); KAction* newDirAction = DolphinView::createNewDirAction(actionCollection());
@ -457,4 +472,25 @@ void DolphinPart::slotAdditionalInfoChanged()
m_view->updateAdditionalInfoActions(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" #include "dolphinpart.moc"

View file

@ -136,6 +136,15 @@ private Q_SLOTS:
*/ */
void createDir(); 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. */ /** Updates the state of the 'Sort Ascending/Descending' action. */
void slotSortOrderChanged(Qt::SortOrder); void slotSortOrderChanged(Qt::SortOrder);

View file

@ -1224,6 +1224,29 @@ KAction* DolphinView::createSortDescendingAction(KActionCollection* collection)
return sortDescending; 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* DolphinView::createAdditionalInformationActionGroup(KActionCollection* collection)
{ {
QActionGroup* showInformationGroup = new QActionGroup(collection); QActionGroup* showInformationGroup = new QActionGroup(collection);

View file

@ -164,39 +164,18 @@ public:
* Changes the view mode for the current directory to \a mode. * Changes the view mode for the current directory to \a mode.
* If the view properties should be remembered for each directory * If the view properties should be remembered for each directory
* (GeneralSettings::globalViewProps() returns false), then the * (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); void setMode(Mode mode);
Mode mode() const; Mode mode() const;
/** /** See setShowPreview */
* 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);
bool showPreview() const; bool showPreview() const;
/** /** See setShowHiddenFiles */
* 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);
bool showHiddenFiles() const; bool showHiddenFiles() const;
/** /** See setCategorizedSorting */
* 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);
bool categorizedSorting() const; bool categorizedSorting() const;
/** /**
@ -379,6 +358,24 @@ public:
*/ */
static QActionGroup* createAdditionalInformationActionGroup(KActionCollection* collection); 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. * Updates the state of the 'Additional Information' actions in \a collection.
*/ */
@ -439,6 +436,33 @@ public slots:
/** Pastes the clipboard data to this view. */ /** Pastes the clipboard data to this view. */
void paste(); 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. */ /** Switches between an ascending and descending sorting order. */
void toggleSortOrder(); void toggleSortOrder();