X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/a4ede4e0ebaf0bba57da8fc2924577f1a8ff7b54..64afe7b22622f79b34aafd54501b08120ab2fc5c:/src/views/dolphinviewactionhandler.cpp diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp index eb127e2f7..48ec95c70 100644 --- a/src/views/dolphinviewactionhandler.cpp +++ b/src/views/dolphinviewactionhandler.cpp @@ -20,7 +20,7 @@ #include "dolphinviewactionhandler.h" -#include +#include #include "settings/viewpropertiesdialog.h" #include "views/dolphinview.h" @@ -36,15 +36,15 @@ #include #include #include -#include #include - -#ifdef HAVE_NEPOMUK - #include -#endif +#include #include +#ifdef HAVE_BALOO + #include +#endif + DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) : QObject(parent), m_actionCollection(collection), @@ -84,6 +84,8 @@ void DolphinViewActionHandler::setCurrentView(DolphinView* view) this, SLOT(slotSortRoleChanged(QByteArray))); connect(view, SIGNAL(zoomLevelChanged(int,int)), this, SLOT(slotZoomLevelChanged(int,int))); + connect(view, SIGNAL(writeStateChanged(bool)), + this, SLOT(slotWriteStateChanged(bool))); } DolphinView* DolphinViewActionHandler::currentView() @@ -99,6 +101,7 @@ void DolphinViewActionHandler::createActions() newDirAction->setText(i18nc("@action", "Create Folder...")); newDirAction->setShortcut(Qt::Key_F10); newDirAction->setIcon(KIcon("folder-new")); + newDirAction->setEnabled(false); // Will be enabled in slotWriteStateChanged(bool) if the current URL is writable connect(newDirAction, SIGNAL(triggered()), this, SIGNAL(createDirectory())); // File menu @@ -137,7 +140,7 @@ void DolphinViewActionHandler::createActions() // Well, it's the File menu in dolphinmainwindow and the Edit menu in dolphinpart... :) propertiesAction->setText( i18nc("@action:inmenu File", "Properties") ); propertiesAction->setIcon(KIcon("document-properties")); - propertiesAction->setShortcut(Qt::ALT | Qt::Key_Return); + propertiesAction->setShortcuts(QList() << Qt::ALT + Qt::Key_Return << Qt::ALT + Qt::Key_Enter); connect(propertiesAction, SIGNAL(triggered()), SLOT(slotProperties())); // View menu @@ -234,20 +237,16 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt KActionMenu* groupMenu = 0; QActionGroup* groupMenuGroup = 0; - bool nepomukRunning = false; bool indexingEnabled = false; -#ifdef HAVE_NEPOMUK - nepomukRunning = (Nepomuk::ResourceManager::instance()->init() == 0); - if (nepomukRunning) { - KConfig config("nepomukserverrc"); - indexingEnabled = config.group("Service-nepomukfileindexer").readEntry("autostart", false); - } +#ifdef HAVE_BALOO + Baloo::IndexerConfig config; + indexingEnabled = config.fileIndexingEnabled(); #endif const QList rolesInfo = KFileItemModel::rolesInformation(); foreach (const KFileItemModel::RoleInfo& info, rolesInfo) { - if (!isSortGroup && info.role == "name") { - // It should not be possible to hide the "name" role + if (!isSortGroup && info.role == "text") { + // It should not be possible to hide the "text" role continue; } @@ -281,8 +280,8 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt action->setText(info.translation); action->setData(info.role); - const bool enable = (!info.requiresNepomuk && !info.requiresIndexer) || - (info.requiresNepomuk && nepomukRunning) || + const bool enable = (!info.requiresBaloo && !info.requiresIndexer) || + (info.requiresBaloo) || (info.requiresIndexer && indexingEnabled); action->setEnabled(enable); @@ -314,14 +313,7 @@ void DolphinViewActionHandler::slotRename() void DolphinViewActionHandler::slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers modifiers) { emit actionBeingHandled(); - // Note: kde3's konq_mainwindow.cpp used to check - // reason == KAction::PopupMenuActivation && ... - // but this isn't supported anymore - if (modifiers & Qt::ShiftModifier) { - m_currentView->deleteSelectedItems(); - } else { - m_currentView->trashSelectedItems(); - } + m_currentView->trashSelectedItems(); } void DolphinViewActionHandler::slotDeleteItems() @@ -489,6 +481,11 @@ void DolphinViewActionHandler::slotHiddenFilesShownChanged(bool shown) showHiddenFilesAction->setChecked(shown); } +void DolphinViewActionHandler::slotWriteStateChanged(bool isFolderWritable) +{ + m_actionCollection->action("create_dir")->setEnabled(isFolderWritable); +} + KToggleAction* DolphinViewActionHandler::iconsModeAction() { KToggleAction* iconsView = m_actionCollection->add("icons"); @@ -528,8 +525,10 @@ void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray& role) if (action) { action->setChecked(true); - QAction* sortByMenu = m_actionCollection->action("sort"); - sortByMenu->setIcon(KIcon(action->icon())); + if (!action->icon().isNull()) { + QAction* sortByMenu = m_actionCollection->action("sort"); + sortByMenu->setIcon(KIcon(action->icon())); + } } }