X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/037d5db85bb0bd798d40c557d424c5c9b87457a8..7745a9354776c6043b4f691260e434c29de6ca0c:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index df04cee69..398af70a8 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include #include @@ -263,11 +263,6 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection) emit selectionChanged(selection); } -void DolphinMainWindow::slotRequestItemInfo(const KFileItem& item) -{ - emit requestItemInfo(item); -} - void DolphinMainWindow::updateHistory() { const KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator(); @@ -340,7 +335,7 @@ void DolphinMainWindow::openInNewWindow() } if (!newWindowUrl.isEmpty()) { - KRun::run("dolphin %u", QList() << newWindowUrl, this); + KRun::run("dolphin %u", {newWindowUrl}, this); } } @@ -763,7 +758,7 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos, const QUrl& url, const QList& customActions) { - QWeakPointer contextMenu = new DolphinContextMenu(this, pos, item, url); + QScopedPointer contextMenu(new DolphinContextMenu(this, pos, item, url)); contextMenu.data()->setCustomActions(customActions); const DolphinContextMenu::Command command = contextMenu.data()->open(); @@ -774,7 +769,7 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos, case DolphinContextMenu::OpenParentFolderInNewWindow: { - KRun::run("dolphin %u", QList() << KIO::upUrl(item.url()), this); + KRun::run("dolphin %u", {KIO::upUrl(item.url())}, this); break; } @@ -786,8 +781,6 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos, default: break; } - - delete contextMenu.data(); } void DolphinMainWindow::updateControlMenu() @@ -899,11 +892,6 @@ void DolphinMainWindow::slotControlButtonDeleted() m_updateToolBarTimer->start(); } -void DolphinMainWindow::slotPanelErrorMessage(const QString& error) -{ - activeViewContainer()->showMessage(error, DolphinViewContainer::Error); -} - void DolphinMainWindow::slotPlaceActivated(const QUrl& url) { DolphinViewContainer* view = activeViewContainer(); @@ -969,7 +957,11 @@ void DolphinMainWindow::setUrlAsCaption(const QUrl& url) } } - const QString fileName = url.fileName().isEmpty() ? "/" : url.fileName(); + QString fileName = url.adjusted(QUrl::StripTrailingSlash).fileName(); + if (fileName.isEmpty()) { + fileName = '/'; + } + caption.append(fileName); setCaption(caption); @@ -995,7 +987,7 @@ void DolphinMainWindow::setupActions() QAction* newTab = actionCollection()->addAction("new_tab"); newTab->setIcon(QIcon::fromTheme("tab-new")); newTab->setText(i18nc("@action:inmenu File", "New Tab")); - actionCollection()->setDefaultShortcuts(newTab, QList() << QKeySequence(Qt::CTRL | Qt::Key_T) << QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_N)); + actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL | Qt::Key_T, Qt::CTRL | Qt::SHIFT | Qt::Key_N}); connect(newTab, &QAction::triggered, this, static_cast(&DolphinMainWindow::openNewActivatedTab)); QAction* closeTab = actionCollection()->addAction("close_tab"); @@ -1088,6 +1080,9 @@ void DolphinMainWindow::setupActions() undoCloseTab->setEnabled(false); connect(undoCloseTab, SIGNAL(triggered()), recentTabsMenu, SLOT(undoCloseTab())); + auto undoAction = actionCollection()->action(KStandardAction::name(KStandardAction::Undo)); + undoAction->setEnabled(false); // undo should be disabled by default + KStandardAction::forward(this, SLOT(goForward()), actionCollection()); KStandardAction::up(this, SLOT(goUp()), actionCollection()); KStandardAction::home(this, SLOT(goHome()), actionCollection()); @@ -1118,12 +1113,10 @@ void DolphinMainWindow::setupActions() KStandardAction::preferences(this, SLOT(editSettings()), actionCollection()); // not in menu actions - QList nextTabKeys; - nextTabKeys.append(KStandardShortcut::tabNext().first()); //TODO: is this correct + QList nextTabKeys = KStandardShortcut::tabNext(); nextTabKeys.append(QKeySequence(Qt::CTRL | Qt::Key_Tab)); - QList prevTabKeys; - prevTabKeys.append(KStandardShortcut::tabPrev().first()); //TODO: is this correct + QList prevTabKeys = KStandardShortcut::tabPrev(); prevTabKeys.append(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Tab)); QAction* activateNextTab = actionCollection()->addAction("activate_next_tab"); @@ -1175,7 +1168,7 @@ void DolphinMainWindow::setupDockWidgets() infoDock->setObjectName("infoDock"); infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); InformationPanel* infoPanel = new InformationPanel(infoDock); - infoPanel->setCustomContextMenuActions(QList() << lockLayoutAction); + infoPanel->setCustomContextMenuActions({lockLayoutAction}); connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl); infoDock->setWidget(infoPanel); @@ -1196,7 +1189,7 @@ void DolphinMainWindow::setupDockWidgets() foldersDock->setObjectName("foldersDock"); foldersDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); FoldersPanel* foldersPanel = new FoldersPanel(foldersDock); - foldersPanel->setCustomContextMenuActions(QList() << lockLayoutAction); + foldersPanel->setCustomContextMenuActions({lockLayoutAction}); foldersDock->setWidget(foldersPanel); QAction* foldersAction = foldersDock->toggleViewAction(); @@ -1210,7 +1203,7 @@ void DolphinMainWindow::setupDockWidgets() connect(foldersPanel, &FoldersPanel::folderMiddleClicked, this, &DolphinMainWindow::openNewTab); connect(foldersPanel, &FoldersPanel::errorMessage, - this, &DolphinMainWindow::slotPanelErrorMessage); + this, &DolphinMainWindow::showErrorMessage); // Setup "Terminal" #ifndef Q_OS_WIN @@ -1219,7 +1212,7 @@ void DolphinMainWindow::setupDockWidgets() terminalDock->setObjectName("terminalDock"); terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea); TerminalPanel* terminalPanel = new TerminalPanel(terminalDock); - terminalPanel->setCustomContextMenuActions(QList() << lockLayoutAction); + terminalPanel->setCustomContextMenuActions({lockLayoutAction}); terminalDock->setWidget(terminalPanel); connect(terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide); @@ -1250,7 +1243,7 @@ void DolphinMainWindow::setupDockWidgets() placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); PlacesPanel* placesPanel = new PlacesPanel(placesDock); - placesPanel->setCustomContextMenuActions(QList() << lockLayoutAction); + placesPanel->setCustomContextMenuActions({lockLayoutAction}); placesDock->setWidget(placesPanel); QAction* placesAction = placesDock->toggleViewAction(); @@ -1262,7 +1255,7 @@ void DolphinMainWindow::setupDockWidgets() connect(placesPanel, SIGNAL(placeMiddleClicked(QUrl)), this, SLOT(openNewTab(QUrl))); connect(placesPanel, &PlacesPanel::errorMessage, - this, &DolphinMainWindow::slotPanelErrorMessage); + this, &DolphinMainWindow::showErrorMessage); connect(this, &DolphinMainWindow::urlChanged, placesPanel, &PlacesPanel::setUrl); connect(placesDock, &DolphinDockWidget::visibilityChanged, @@ -1423,7 +1416,7 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) connect(view, &DolphinView::selectionChanged, this, &DolphinMainWindow::slotSelectionChanged); connect(view, &DolphinView::requestItemInfo, - this, &DolphinMainWindow::slotRequestItemInfo); + this, &DolphinMainWindow::requestItemInfo); connect(view, &DolphinView::tabRequested, this, &DolphinMainWindow::openNewTab); connect(view, &DolphinView::requestContextMenu,