X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/9c8e7f4e43d23c6d014ca4ffe2083ad8cc737753..b5cc2a6924cfd8f59611d3cec2edbb00a08b4ff1:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 2585a7b82..e0a0a5633 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -24,21 +24,21 @@ #include +#include "bookmarkssidebarpage.h" #include "dolphinapplication.h" #include "dolphinnewmenu.h" #include "dolphinsettings.h" #include "dolphinsettingsdialog.h" #include "dolphinstatusbar.h" -#include "dolphinapplication.h" -#include "urlnavigator.h" -#include "dolphinsettings.h" -#include "bookmarkssidebarpage.h" #include "infosidebarpage.h" -#include "dolphin_generalsettings.h" -#include "viewpropertiesdialog.h" -#include "viewproperties.h" #include "metadataloader.h" #include "mainwindowadaptor.h" +#include "treeviewsidebarpage.h" +#include "urlnavigator.h" +#include "viewpropertiesdialog.h" +#include "viewproperties.h" + +#include "dolphin_generalsettings.h" #include #include @@ -154,12 +154,12 @@ void DolphinMainWindow::dropUrls(const KUrl::List& urls, QString seq = QKeySequence(Qt::ShiftModifier).toString(); seq.chop(1); // chop superfluous '+' - QAction* moveAction = popup.addAction(KIcon("goto"), + QAction* moveAction = popup.addAction(KIcon("goto-page"), i18n("&Move Here") + '\t' + seq); seq = QKeySequence(Qt::ControlModifier).toString(); seq.chop(1); - QAction* copyAction = popup.addAction(KIcon("editcopy"), + QAction* copyAction = popup.addAction(KIcon("edit-copy"), i18n("&Copy Here") + '\t' + seq); seq = QKeySequence(Qt::ControlModifier + Qt::ShiftModifier).toString(); @@ -168,7 +168,7 @@ void DolphinMainWindow::dropUrls(const KUrl::List& urls, i18n("&Link Here") + '\t' + seq); popup.addSeparator(); - popup.addAction(KIcon("stop"), i18n("Cancel")); + popup.addAction(KIcon("process-stop"), i18n("Cancel")); QAction* activatedAction = popup.exec(QCursor::pos()); if (activatedAction == moveAction) { @@ -250,6 +250,13 @@ void DolphinMainWindow::slotViewModeChanged() updateViewActions(); } +void DolphinMainWindow::slotShowPreviewChanged() +{ + // It is not enough to update the 'Show Preview' action, also + // the 'Zoom In' and 'Zoom Out' actions must be adapted. + updateViewActions(); +} + void DolphinMainWindow::slotShowHiddenFilesChanged() { KToggleAction* showHiddenFilesAction = @@ -322,6 +329,7 @@ void DolphinMainWindow::slotHistoryChanged() void DolphinMainWindow::slotUrlChanged(const KUrl& url) { updateEditActions(); + updateViewActions(); updateGoActions(); setCaption(url.fileName()); } @@ -430,7 +438,7 @@ void DolphinMainWindow::deleteItems() const bool del = KMessageBox::warningContinueCancel(this, text, QString(), - KGuiItem(i18n("Delete"), KIcon("editdelete")) + KGuiItem(i18n("Delete"), KIcon("edit-delete")) ) == KMessageBox::Continue; if (del) { KIO::Job* job = KIO::del(list); @@ -520,11 +528,32 @@ void DolphinMainWindow::undo() void DolphinMainWindow::cut() { + QClipboard* clipboard = QApplication::clipboard(); + const QMimeData* currentMimeData = clipboard->mimeData(); + const bool hadCutSelection = KonqMimeData::decodeIsCutSelection(currentMimeData); + QMimeData* mimeData = new QMimeData(); const KUrl::List kdeUrls = m_activeView->selectedUrls(); const KUrl::List mostLocalUrls; KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, true); QApplication::clipboard()->setMimeData(mimeData); + + if (hadCutSelection) { + // If an old cut selection has been applied, the view must + // be reloaded to get the original icons of the items without an + // applied item effect. + m_view[PrimaryIdx]->reload(); + if (m_view[SecondaryIdx] != 0) { + m_view[SecondaryIdx]->reload(); + } + } + else { + // apply an item effect for the icons of all cut items + m_view[PrimaryIdx]->updateCutItems(); + if (m_view[SecondaryIdx] != 0) { + m_view[SecondaryIdx]->updateCutItems(); + } + } } void DolphinMainWindow::copy() @@ -587,13 +616,7 @@ void DolphinMainWindow::updatePasteAction() if (!urls.isEmpty()) { pasteAction->setEnabled(true); - const int count = urls.count(); - if (count == 1) { - pasteAction->setText(i18n("Paste 1 File")); - } - else { - pasteAction->setText(i18n("Paste %1 Files", count)); - } + pasteAction->setText(i18np("Paste One File", "Paste %1 Files", urls.count())); } else { pasteAction->setEnabled(false); @@ -911,16 +934,16 @@ void DolphinMainWindow::init() assert(manager != 0); KBookmarkGroup root = manager->root(); if (root.first().isNull()) { - root.addBookmark(manager, i18n("Home"), settings.generalSettings()->homeUrl(), "folder_home"); - root.addBookmark(manager, i18n("Storage Media"), KUrl("media:/"), "blockdevice"); - root.addBookmark(manager, i18n("Network"), KUrl("remote:/"), "network_local"); - root.addBookmark(manager, i18n("Root"), KUrl("/"), "folder_red"); - root.addBookmark(manager, i18n("Trash"), KUrl("trash:/"), "trashcan_full"); + root.addBookmark(manager, i18n("Home"), settings.generalSettings()->homeUrl(), "folder-home"); + root.addBookmark(manager, i18n("Storage Media"), KUrl("media:/"), "hdd-mount"); + root.addBookmark(manager, i18n("Network"), KUrl("remote:/"), "network-local"); + root.addBookmark(manager, i18n("Root"), KUrl("/"), "folder-red"); + root.addBookmark(manager, i18n("Trash"), KUrl("trash:/"), "user-trash"); } setupActions(); - const KUrl& homeUrl = root.first().url(); + const KUrl& homeUrl = settings.generalSettings()->homeUrl(); setCaption(homeUrl.fileName()); ViewProperties props(homeUrl); m_view[PrimaryIdx] = new DolphinView(this, @@ -990,14 +1013,15 @@ void DolphinMainWindow::setupActions() m_newMenu = new DolphinNewMenu(this); KMenu* menu = m_newMenu->menu(); menu->setTitle(i18n("Create New...")); - menu->setIcon(SmallIcon("filenew")); + menu->setIcon(SmallIcon("document-new")); connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateNewMenu())); - QAction* action = actionCollection()->addAction("new_window"); - action->setIcon(KIcon("window_new")); - action->setText(i18n("New &Window")); - connect(action, SIGNAL(triggered()), this, SLOT(openNewMainWindow())); + QAction* newWindow = actionCollection()->addAction("new_window"); + newWindow->setIcon(KIcon("window-new")); + newWindow->setText(i18n("New &Window")); + newWindow->setShortcut(Qt::CTRL | Qt::Key_N); + connect(newWindow, SIGNAL(triggered()), this, SLOT(openNewMainWindow())); QAction* rename = actionCollection()->addAction("rename"); rename->setText(i18n("Rename")); @@ -1006,14 +1030,14 @@ void DolphinMainWindow::setupActions() QAction* moveToTrash = actionCollection()->addAction("move_to_trash"); moveToTrash->setText(i18n("Move to Trash")); - moveToTrash->setIcon(KIcon("edittrash")); + moveToTrash->setIcon(KIcon("edit-trash")); moveToTrash->setShortcut(QKeySequence::Delete); connect(moveToTrash, SIGNAL(triggered()), this, SLOT(moveToTrash())); QAction* deleteAction = actionCollection()->addAction("delete"); deleteAction->setText(i18n("Delete")); - deleteAction->setShortcut(Qt::ALT | Qt::Key_Delete); - deleteAction->setIcon(KIcon("editdelete")); + deleteAction->setShortcut(Qt::SHIFT | Qt::Key_Delete); + deleteAction->setIcon(KIcon("edit-delete")); connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteItems())); QAction* properties = actionCollection()->addAction("properties"); @@ -1054,13 +1078,13 @@ void DolphinMainWindow::setupActions() KToggleAction* iconsView = actionCollection()->add("icons"); iconsView->setText(i18n("Icons")); iconsView->setShortcut(Qt::CTRL | Qt::Key_1); - iconsView->setIcon(KIcon("view_icon")); + iconsView->setIcon(KIcon("view-icon")); connect(iconsView, SIGNAL(triggered()), this, SLOT(setIconsView())); KToggleAction* detailsView = actionCollection()->add("details"); detailsView->setText(i18n("Details")); detailsView->setShortcut(Qt::CTRL | Qt::Key_2); - detailsView->setIcon(KIcon("view_text")); + detailsView->setIcon(KIcon("fileview-text")); connect(detailsView, SIGNAL(triggered()), this, SLOT(setDetailsView())); QActionGroup* viewModeGroup = new QActionGroup(this); @@ -1104,7 +1128,8 @@ void DolphinMainWindow::setupActions() connect(sortDescending, SIGNAL(triggered()), this, SLOT(toggleSortOrder())); KToggleAction* showPreview = actionCollection()->add("show_preview"); - showPreview->setText(i18n("Show Preview")); + showPreview->setText(i18n("Preview")); + showPreview->setIcon(KIcon("thumbnail-show")); connect(showPreview, SIGNAL(triggered()), this, SLOT(togglePreview())); KToggleAction* showHiddenFiles = actionCollection()->add("show_hidden_files"); @@ -1113,20 +1138,20 @@ void DolphinMainWindow::setupActions() connect(showHiddenFiles, SIGNAL(triggered()), this, SLOT(toggleShowHiddenFiles())); KToggleAction* split = actionCollection()->add("split_view"); - split->setText(i18n("Split View")); + split->setText(i18n("Split")); split->setShortcut(Qt::Key_F10); - split->setIcon(KIcon("view_left_right")); + split->setIcon(KIcon("view-left-right")); connect(split, SIGNAL(triggered()), this, SLOT(toggleSplitView())); QAction* reload = actionCollection()->addAction("reload"); reload->setText(i18n("Reload")); reload->setShortcut(Qt::Key_F5); - reload->setIcon(KIcon("reload")); + reload->setIcon(KIcon("view-refresh")); connect(reload, SIGNAL(triggered()), this, SLOT(reloadView())); QAction* stop = actionCollection()->addAction("stop"); stop->setText(i18n("Stop")); - stop->setIcon(KIcon("stop")); + stop->setIcon(KIcon("process-stop")); connect(stop, SIGNAL(triggered()), this, SLOT(stopLoading())); // TODO: the URL navigator must emit a signal if the editable state has been @@ -1162,7 +1187,7 @@ void DolphinMainWindow::setupActions() QAction* findFile = actionCollection()->addAction("find_file"); findFile->setText(i18n("Find File...")); findFile->setShortcut(Qt::Key_F); - findFile->setIcon(KIcon("filefind")); + findFile->setIcon(KIcon("file-find")); connect(findFile, SIGNAL(triggered()), this, SLOT(findFile())); KToggleAction* showFilterBar = actionCollection()->add("show_filter_bar"); @@ -1182,6 +1207,10 @@ void DolphinMainWindow::setupActions() void DolphinMainWindow::setupDockWidgets() { + // TODO: there's a lot copy/paste code here. Provide a generic approach + // after the dock concept has been finalized. + + // setup "Bookmarks" QDockWidget* shortcutsDock = new QDockWidget(i18n("Bookmarks")); shortcutsDock->setObjectName("bookmarksDock"); shortcutsDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); @@ -1192,6 +1221,7 @@ void DolphinMainWindow::setupDockWidgets() addDockWidget(Qt::LeftDockWidgetArea, shortcutsDock); + // setup "Information" QDockWidget* infoDock = new QDockWidget(i18n("Information")); infoDock->setObjectName("infoDock"); infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); @@ -1201,6 +1231,23 @@ void DolphinMainWindow::setupDockWidgets() actionCollection()->addAction("show_info_panel", infoDock->toggleViewAction()); addDockWidget(Qt::RightDockWidgetArea, infoDock); + + // setup "Tree View" + QDockWidget* treeViewDock = new QDockWidget(i18n("Folders")); // TODO: naming? + treeViewDock->setObjectName("treeViewDock"); + treeViewDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); + treeViewDock->setWidget(new TreeViewSidebarPage(this)); + + treeViewDock->toggleViewAction()->setText(i18n("Show Folders Panel")); + actionCollection()->addAction("show_folders_panel", treeViewDock->toggleViewAction()); + + addDockWidget(Qt::LeftDockWidgetArea, treeViewDock); + + const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun(); + if (firstRun) { + infoDock->hide(); + treeViewDock->hide(); + } } void DolphinMainWindow::updateHistory() @@ -1289,6 +1336,10 @@ void DolphinMainWindow::updateViewActions() static_cast(actionCollection()->action("show_filter_bar")); showFilterBarAction->setChecked(m_activeView->isFilterBarVisible()); + KToggleAction* showPreviewAction = + static_cast(actionCollection()->action("show_preview")); + showPreviewAction->setChecked(m_activeView->showPreview()); + KToggleAction* showHiddenFilesAction = static_cast(actionCollection()->action("show_hidden_files")); showHiddenFilesAction->setChecked(m_activeView->showHiddenFiles()); @@ -1336,6 +1387,8 @@ void DolphinMainWindow::connectViewSignals(int viewIndex) DolphinView* view = m_view[viewIndex]; connect(view, SIGNAL(modeChanged()), this, SLOT(slotViewModeChanged())); + connect(view, SIGNAL(showPreviewChanged()), + this, SLOT(slotShowPreviewChanged())); connect(view, SIGNAL(showHiddenFilesChanged()), this, SLOT(slotShowHiddenFilesChanged())); connect(view, SIGNAL(sortingChanged(DolphinView::Sorting)),