#include "settings/viewpropertiesdialog.h"
#include "dolphinview.h"
#include "zoomlevelinfo.h"
-
#include <konq_operations.h>
#include <kaction.h>
#include <kactioncollection.h>
#include <klocale.h>
+#include <knewmenu.h>
#include <ktoggleaction.h>
#include <krun.h>
#include <kpropertiesdialog.h>
+
DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent)
: QObject(parent),
m_actionCollection(collection),
this, SLOT(slotShowPreviewChanged()));
connect(view, SIGNAL(sortOrderChanged(Qt::SortOrder)),
this, SLOT(slotSortOrderChanged(Qt::SortOrder)));
+ connect(view, SIGNAL(sortFoldersFirstChanged(bool)),
+ this, SLOT(slotSortFoldersFirstChanged(bool)));
connect(view, SIGNAL(additionalInfoChanged()),
this, SLOT(slotAdditionalInfoChanged()));
connect(view, SIGNAL(categorizedSortingChanged()),
this, SLOT(slotZoomLevelChanged(int)));
}
+DolphinView* DolphinViewActionHandler::currentView()
+{
+ return m_currentView;
+}
+
void DolphinViewActionHandler::createActions()
{
// This action doesn't appear in the GUI, it's for the shortcut only.
newDirAction->setText(i18nc("@action", "Create Folder..."));
newDirAction->setShortcut(Qt::Key_F10);
newDirAction->setIcon(KIcon("folder-new"));
- connect(newDirAction, SIGNAL(triggered()), SLOT(slotCreateDir()));
+ connect(newDirAction, SIGNAL(triggered()), this, SIGNAL(createDirectory()));
// Edit menu
sortDescending->setText(i18nc("@action:inmenu Sort", "Descending"));
connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder()));
+ KToggleAction* sortFoldersFirst = m_actionCollection->add<KToggleAction>("folders_first");
+ sortFoldersFirst->setText(i18nc("@action:inmenu Sort", "Folders First"));
+ connect(sortFoldersFirst, SIGNAL(triggered()), this, SLOT(toggleSortFoldersFirst()));
+
QActionGroup* sortByActionGroup = createSortByActionGroup();
connect(sortByActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(slotSortTriggered(QAction*)));
return sortByActionGroup;
}
-void DolphinViewActionHandler::slotCreateDir()
-{
- Q_ASSERT(m_currentView);
- KonqOperations::newDir(m_currentView, m_currentView->url());
-}
-
void DolphinViewActionHandler::slotViewModeActionTriggered(QAction* action)
{
const DolphinView::Mode mode = action->data().value<DolphinView::Mode>();
return QString(); // can't happen
}
+KActionCollection* DolphinViewActionHandler::actionCollection()
+{
+ return m_actionCollection;
+}
+
void DolphinViewActionHandler::updateViewActions()
{
QAction* viewModeAction = m_actionCollection->action(currentViewModeActionName());
showPreviewAction->setChecked(m_currentView->showPreview());
slotSortOrderChanged(m_currentView->sortOrder());
+ slotSortFoldersFirstChanged(m_currentView->sortFoldersFirst());
slotAdditionalInfoChanged();
slotCategorizedSortingChanged();
slotSortingChanged(m_currentView->sorting());
m_currentView->toggleSortOrder();
}
+void DolphinViewActionHandler::toggleSortFoldersFirst()
+{
+ m_currentView->toggleSortFoldersFirst();
+}
+
void DolphinViewActionHandler::slotSortOrderChanged(Qt::SortOrder order)
{
QAction* descending = m_actionCollection->action("descending");
descending->setChecked(sortDescending);
}
+void DolphinViewActionHandler::slotSortFoldersFirstChanged(bool foldersFirst)
+{
+ m_actionCollection->action("folders_first")->setChecked(foldersFirst);
+}
+
void DolphinViewActionHandler::toggleAdditionalInfo(QAction* action)
{
emit actionBeingHandled();
void DolphinViewActionHandler::slotAdjustViewProperties()
{
emit actionBeingHandled();
- ViewPropertiesDialog dlg(m_currentView);
- dlg.exec();
+ QPointer<ViewPropertiesDialog> dialog = new ViewPropertiesDialog(m_currentView);
+ dialog->exec();
+ delete dialog;
}
void DolphinViewActionHandler::slotFindFile()