X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/6e765826941e1858e7246deea3fa50c930a6df85..f63daef339dde16c7ef598f6fdaa5d2191da4685:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index d1f1c1a86..34ff8b71b 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -49,7 +49,6 @@ #endif #include "dolphin_generalsettings.h" -#include "dolphin_iconsmodesettings.h" #include "dolphin_searchsettings.h" #include @@ -96,6 +95,12 @@ #include #include +namespace { + // Used for GeneralSettings::version() to determine whether + // an updated version of Dolphin is running. + const int CurrentDolphinVersion = 200; +}; + /* * Menu shown when pressing the configure-button in the toolbar. */ @@ -166,7 +171,7 @@ DolphinMainWindow::DolphinMainWindow() : const DolphinSettings& settings = DolphinSettings::instance(); GeneralSettings* generalSettings = settings.generalSettings(); - const bool firstRun = generalSettings->firstRun(); + const bool firstRun = (generalSettings->version() < 200); if (firstRun) { generalSettings->setViewPropsTimestamp(QDateTime::currentDateTime()); } @@ -325,8 +330,10 @@ void DolphinMainWindow::openFiles(const QList& files) const int tabCount = m_viewTab.count(); for (int i = 0; i < tabCount; ++i) { m_viewTab[i].primaryView->view()->markUrlsAsSelected(files); + m_viewTab[i].primaryView->view()->markUrlAsCurrent(files.at(0)); if (m_viewTab[i].secondaryView) { m_viewTab[i].secondaryView->view()->markUrlsAsSelected(files); + m_viewTab[i].secondaryView->view()->markUrlAsCurrent(files.at(0)); } } } @@ -434,14 +441,14 @@ void DolphinMainWindow::updateHistory() const int index = urlNavigator->historyIndex(); QAction* backAction = actionCollection()->action("go_back"); - backAction->setToolTip(i18nc("@info", "Go back")); if (backAction) { + backAction->setToolTip(i18nc("@info", "Go back")); backAction->setEnabled(index < urlNavigator->historySize() - 1); } QAction* forwardAction = actionCollection()->action("go_forward"); - forwardAction->setToolTip(i18nc("@info", "Go forward")); if (forwardAction) { + forwardAction->setToolTip(i18nc("@info", "Go forward")); forwardAction->setEnabled(index > 0); } } @@ -646,8 +653,7 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) } } - generalSettings->setFirstRun(false); - + generalSettings->setVersion(CurrentDolphinVersion); settings.save(); if (m_searchDockIsTemporaryVisible) { @@ -1368,13 +1374,14 @@ void DolphinMainWindow::slotSearchModeChanged(bool enabled) #endif } -void DolphinMainWindow::openContextMenu(const KFileItem& item, +void DolphinMainWindow::openContextMenu(const QPoint& pos, + const KFileItem& item, const KUrl& url, const QList& customActions) { - QPointer contextMenu = new DolphinContextMenu(this, item, url); - contextMenu->setCustomActions(customActions); - const DolphinContextMenu::Command command = contextMenu->open(); + QWeakPointer contextMenu = new DolphinContextMenu(this, pos, item, url); + contextMenu.data()->setCustomActions(customActions); + const DolphinContextMenu::Command command = contextMenu.data()->open(); switch (command) { case DolphinContextMenu::OpenParentFolderInNewWindow: { @@ -1391,7 +1398,7 @@ void DolphinMainWindow::openContextMenu(const KFileItem& item, break; } - delete contextMenu; + delete contextMenu.data(); } void DolphinMainWindow::updateToolBarMenu() @@ -1762,9 +1769,7 @@ void DolphinMainWindow::setupDockWidgets() infoDock->setWidget(infoPanel); QAction* infoAction = infoDock->toggleViewAction(); - infoAction->setIcon(KIcon("dialog-information")); - infoAction->setShortcut(Qt::Key_F11); - addActionCloneToCollection(infoAction, "show_information_panel"); + createPanelAction(KIcon("dialog-information"), Qt::Key_F11, infoAction, "show_information_panel"); addDockWidget(Qt::RightDockWidgetArea, infoDock); connect(this, SIGNAL(urlChanged(KUrl)), @@ -1784,9 +1789,7 @@ void DolphinMainWindow::setupDockWidgets() foldersDock->setWidget(foldersPanel); QAction* foldersAction = foldersDock->toggleViewAction(); - foldersAction->setShortcut(Qt::Key_F7); - foldersAction->setIcon(KIcon("folder")); - addActionCloneToCollection(foldersAction, "show_folders_panel"); + createPanelAction(KIcon("folder"), Qt::Key_F7, foldersAction, "show_folders_panel"); addDockWidget(Qt::LeftDockWidgetArea, foldersDock); connect(this, SIGNAL(urlChanged(KUrl)), @@ -1809,9 +1812,7 @@ void DolphinMainWindow::setupDockWidgets() terminalPanel, SLOT(dockVisibilityChanged())); QAction* terminalAction = terminalDock->toggleViewAction(); - terminalAction->setShortcut(Qt::Key_F4); - terminalAction->setIcon(KIcon("utilities-terminal")); - addActionCloneToCollection(terminalAction, "show_terminal_panel"); + createPanelAction(KIcon("utilities-terminal"), Qt::Key_F4, terminalAction, "show_terminal_panel"); addDockWidget(Qt::BottomDockWidgetArea, terminalDock); connect(this, SIGNAL(urlChanged(KUrl)), @@ -1830,16 +1831,13 @@ void DolphinMainWindow::setupDockWidgets() searchDock->setWidget(searchPanel); QAction* searchAction = searchDock->toggleViewAction(); - searchAction->setShortcut(Qt::Key_F12); - searchAction->setIcon(KIcon("system-search")); - addActionCloneToCollection(searchAction, "show_search_panel"); + createPanelAction(KIcon("system-search"), Qt::Key_F12, searchAction, "show_search_panel"); addDockWidget(Qt::RightDockWidgetArea, searchDock); connect(this, SIGNAL(urlChanged(KUrl)), searchPanel, SLOT(setUrl(KUrl))); #endif - const bool firstRun = DolphinSettings::instance().generalSettings()->firstRun(); - if (firstRun) { + if (DolphinSettings::instance().generalSettings()->version() < 200) { infoDock->hide(); foldersDock->hide(); #ifndef Q_OS_WIN @@ -1868,9 +1866,7 @@ void DolphinMainWindow::setupDockWidgets() placesDock->setWidget(placesPanel); QAction* placesAction = placesDock->toggleViewAction(); - placesAction->setShortcut(Qt::Key_F9); - placesAction->setIcon(KIcon("bookmarks")); - addActionCloneToCollection(placesAction, "show_places_panel"); + createPanelAction(KIcon("bookmarks"), Qt::Key_F9, placesAction, "show_places_panel"); addDockWidget(Qt::LeftDockWidgetArea, placesDock); connect(placesPanel, SIGNAL(urlChanged(KUrl,Qt::MouseButtons)), @@ -2106,8 +2102,8 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) this, SLOT(toggleActiveView())); connect(view, SIGNAL(tabRequested(KUrl)), this, SLOT(openNewTab(KUrl))); - connect(view, SIGNAL(requestContextMenu(KFileItem,KUrl,QList)), - this, SLOT(openContextMenu(KFileItem,KUrl,QList))); + connect(view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList)), + this, SLOT(openContextMenu(QPoint,KFileItem,KUrl,QList))); connect(view, SIGNAL(startedPathLoading(KUrl)), this, SLOT(enableStopAction())); connect(view, SIGNAL(finishedPathLoading(KUrl)), @@ -2216,12 +2212,18 @@ QString DolphinMainWindow::squeezedText(const QString& text) const return fm.elidedText(text, Qt::ElideMiddle, fm.maxWidth() * 10); } -void DolphinMainWindow::addActionCloneToCollection(QAction* action, const QString& actionName) +void DolphinMainWindow::createPanelAction(const KIcon& icon, + const QKeySequence& shortcut, + QAction* dockAction, + const QString& actionName) { - KAction* actionClone = actionCollection()->addAction(actionName); - actionClone->setText(action->text()); - actionClone->setIcon(action->icon()); - connect(actionClone, SIGNAL(triggered()), action, SLOT(trigger())); + KAction* panelAction = actionCollection()->addAction(actionName); + panelAction->setText(dockAction->text()); + panelAction->setIcon(icon); + panelAction->setShortcut(shortcut); + + dockAction->setIcon(icon); + connect(panelAction, SIGNAL(triggered()), dockAction, SLOT(trigger())); } DolphinMainWindow::UndoUiInterface::UndoUiInterface() :