*/
#include "dolphinpart.h"
+#include <kpropertiesdialog.h>
+#include <kglobalsettings.h>
#include "dolphinsortfilterproxymodel.h"
#include "dolphinview.h"
#include "dolphinmodel.h"
#include <kactioncollection.h>
#include <kdirlister.h>
+#include <kiconloader.h>
#include <kmessagebox.h>
#include <kparts/genericfactory.h>
#include <ktoggleaction.h>
setComponentData( DolphinPartFactory::componentData() );
m_extension = new DolphinPartBrowserExtension(this);
+ // make sure that other apps using this part find Dolphin's view-file-columns icons
+ KIconLoader::global()->addAppDir("dolphin");
+
m_dirLister = new KDirLister;
m_dirLister->setAutoUpdate(true);
m_dirLister->setMainWindow(parentWidget->topLevelWidget());
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()),
// [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)
KAction* deleteAction = DolphinView::createDeleteAction(actionCollection());
connect(deleteAction, SIGNAL(triggered()), m_view, SLOT(deleteSelectedItems()));
- // 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);
+ KAction *editMimeTypeAction = actionCollection()->addAction( "editMimeType" );
+ editMimeTypeAction->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
+ connect(editMimeTypeAction, SIGNAL(triggered()), SLOT(slotEditMimeType()));
+
+ KAction *propertiesAction = actionCollection()->addAction( "properties" );
+ propertiesAction->setText( i18nc("@action:inmenu Edit", "Properties") );
+ propertiesAction->setShortcut(Qt::ALT+Qt::Key_Return);
+ connect(propertiesAction, SIGNAL(triggered()), SLOT(slotProperties()));
+
+ // 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*)));
+
+ createGoAction("go_applications", "start-here-kde",
+ i18nc("@action:inmenu Go", "App&lications"), QString("programs:/"),
+ goActionGroup);
+ createGoAction("go_network_folders", "folder-remote",
+ i18nc("@action:inmenu Go", "&Network Folders"), QString("remote:/"),
+ goActionGroup);
+ createGoAction("go_settings", "preferences-system",
+ i18nc("@action:inmenu Go", "Sett&ings"), QString("settings:/"),
+ goActionGroup);
+ createGoAction("go_trash", "user-trash",
+ i18nc("@action:inmenu Go", "Trash"), QString("trash:/"),
+ goActionGroup);
+ createGoAction("go_autostart", "",
+ i18nc("@action:inmenu Go", "Autostart"), KGlobalSettings::autostartPath(),
+ goActionGroup);
+}
+
+void DolphinPart::createGoAction(const char* name, const char* iconName,
+ const QString& text, const QString& url,
+ QActionGroup* actionGroup)
+{
+ KAction* action = actionCollection()->addAction(name);
+ action->setIcon(KIcon(iconName));
+ action->setText(text);
+ action->setData(url);
+ action->setActionGroup(actionGroup);
+}
+
+void DolphinPart::slotGoTriggered(QAction* action)
+{
+ const QString url = action->data().toString();
+ emit m_extension->openUrlRequest(KUrl(url));
}
void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
}
QStringList actions;
- actions << "rename" << "move_to_trash" << "delete";
+ actions << "rename" << "move_to_trash" << "delete" << "editMimeType" << "properties";
foreach(const QString& actionName, actions) {
QAction* action = actionCollection()->action(actionName);
Q_ASSERT(action);
void DolphinPart::slotItemTriggered(const KFileItem& item)
{
+ KParts::OpenUrlArguments args;
+ args.setMimeType(item.mimetype());
+
+ // Ideally, konqueror should be changed to not require trustedSource for directory views,
+ // since the idea was not to need BrowserArguments for non-browser stuff...
+ KParts::BrowserArguments browserArgs;
+ browserArgs.trustedSource = true;
+
// MMB click support.
// TODO: this doesn't work, mouseButtons() is always 0.
// Issue N176832 for the missing QAIV signal; task 177399
if (QApplication::mouseButtons() & Qt::MidButton) {
kDebug() << "MMB!!" << item.mimetype();
if (item.mimeTypePtr()->is("inode/directory")) {
- KParts::OpenUrlArguments args;
- args.setMimeType( item.mimetype() );
- emit m_extension->createNewWindow( item.url(), args );
+ emit m_extension->createNewWindow(item.url(), args);
} else {
kDebug() << "run()";
item.run();
} else {
// Left button. [Right button goes to slotOpenContextMenu before triggered can be emitted]
kDebug() << "LMB";
- emit m_extension->openUrlRequest(item.url());
+ emit m_extension->openUrlRequest(item.url(), args, browserArgs);
}
}
if (m_view->url() != url) {
// If the view URL is not equal to 'url', then an inner URL change has
// been done (e. g. by activating an existing column in the column view).
- // From the hosts point of view this must be handled like changing the URL.
- emit m_extension->openUrlRequest(url);
+ openUrl(url);
+ emit m_extension->openUrlNotify();
}
}
m_view->trashSelectedItems();
}
-void DolphinPart::slotNewDir()
+void DolphinPart::slotEditMimeType()
{
- KonqOperations::newDir(widget(), url());
+ const KFileItemList items = m_view->selectedItems();
+ if (!items.isEmpty()) {
+ KonqOperations::editMimeType(items.first().mimetype(), m_view);
+ }
}
+void DolphinPart::slotProperties()
+{
+ const KFileItemList items = m_view->selectedItems();
+ if (!items.isEmpty()) {
+ KPropertiesDialog dialog(items.first().url(), m_view);
+ dialog.exec();
+ }
+}
+
+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"