]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
use DolphinMainWindow::showErrorMessage instead of DolphinMainWindow::slotPanelErrorM...
[dolphin.git] / src / dolphinmainwindow.cpp
index c9b559439770b516b25c6d5db9f5024c5d6fe113..830669726644ec56699f5a13f2adb28db5e6ca40 100644 (file)
@@ -53,7 +53,7 @@
 #include <kdualaction.h>
 #include <KDialog>
 #include <KJobWidgets>
-#include <KLineEdit>
+#include <QLineEdit>
 #include <KToolBar>
 #include <KIO/NetAccess>
 #include <KIO/JobUiDelegate>
@@ -340,7 +340,7 @@ void DolphinMainWindow::openInNewWindow()
     }
 
     if (!newWindowUrl.isEmpty()) {
-        KRun::run("dolphin %u", QList<QUrl>() << newWindowUrl, this);
+        KRun::run("dolphin %u", {newWindowUrl}, this);
     }
 }
 
@@ -623,7 +623,7 @@ void DolphinMainWindow::goHome()
 void DolphinMainWindow::goBack(Qt::MouseButtons buttons)
 {
     // The default case (left button pressed) is handled in goBack().
-    if (buttons == Qt::MidButton) {
+    if (buttons == Qt::MiddleButton) {
         KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
         const int index = urlNavigator->historyIndex() + 1;
         openNewTab(urlNavigator->locationUrl(index));
@@ -633,7 +633,7 @@ void DolphinMainWindow::goBack(Qt::MouseButtons buttons)
 void DolphinMainWindow::goForward(Qt::MouseButtons buttons)
 {
     // The default case (left button pressed) is handled in goForward().
-    if (buttons == Qt::MidButton) {
+    if (buttons == Qt::MiddleButton) {
         KUrlNavigator* urlNavigator = activeViewContainer()->urlNavigator();
         const int index = urlNavigator->historyIndex() - 1;
         openNewTab(urlNavigator->locationUrl(index));
@@ -643,7 +643,7 @@ void DolphinMainWindow::goForward(Qt::MouseButtons buttons)
 void DolphinMainWindow::goUp(Qt::MouseButtons buttons)
 {
     // The default case (left button pressed) is handled in goUp().
-    if (buttons == Qt::MidButton) {
+    if (buttons == Qt::MiddleButton) {
         openNewTab(KIO::upUrl(activeViewContainer()->url()));
     }
 }
@@ -651,7 +651,7 @@ void DolphinMainWindow::goUp(Qt::MouseButtons buttons)
 void DolphinMainWindow::goHome(Qt::MouseButtons buttons)
 {
     // The default case (left button pressed) is handled in goHome().
-    if (buttons == Qt::MidButton) {
+    if (buttons == Qt::MiddleButton) {
         openNewTab(GeneralSettings::self()->homeUrl());
     }
 }
@@ -774,7 +774,7 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos,
 
     case DolphinContextMenu::OpenParentFolderInNewWindow: {
 
-        KRun::run("dolphin %u", QList<QUrl>() << KIO::upUrl(item.url()), this);
+        KRun::run("dolphin %u", {KIO::upUrl(item.url())}, this);
         break;
     }
 
@@ -899,11 +899,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 +964,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 +994,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>() << 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<void(DolphinMainWindow::*)()>(&DolphinMainWindow::openNewActivatedTab));
 
     QAction* closeTab = actionCollection()->addAction("close_tab");
@@ -1118,12 +1117,10 @@ void DolphinMainWindow::setupActions()
     KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
 
     // not in menu actions
-    QList<QKeySequence> nextTabKeys;
-    nextTabKeys.append(KStandardShortcut::tabNext().first()); //TODO: is this correct
+    QList<QKeySequence> nextTabKeys = KStandardShortcut::tabNext();
     nextTabKeys.append(QKeySequence(Qt::CTRL | Qt::Key_Tab));
 
-    QList<QKeySequence> prevTabKeys;
-    prevTabKeys.append(KStandardShortcut::tabPrev().first()); //TODO: is this correct
+    QList<QKeySequence> prevTabKeys = KStandardShortcut::tabPrev();
     prevTabKeys.append(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Tab));
 
     QAction* activateNextTab = actionCollection()->addAction("activate_next_tab");
@@ -1175,7 +1172,7 @@ void DolphinMainWindow::setupDockWidgets()
     infoDock->setObjectName("infoDock");
     infoDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
     InformationPanel* infoPanel = new InformationPanel(infoDock);
-    infoPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+    infoPanel->setCustomContextMenuActions({lockLayoutAction});
     connect(infoPanel, &InformationPanel::urlActivated, this, &DolphinMainWindow::handleUrl);
     infoDock->setWidget(infoPanel);
 
@@ -1196,7 +1193,7 @@ void DolphinMainWindow::setupDockWidgets()
     foldersDock->setObjectName("foldersDock");
     foldersDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
     FoldersPanel* foldersPanel = new FoldersPanel(foldersDock);
-    foldersPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+    foldersPanel->setCustomContextMenuActions({lockLayoutAction});
     foldersDock->setWidget(foldersPanel);
 
     QAction* foldersAction = foldersDock->toggleViewAction();
@@ -1210,7 +1207,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 +1216,7 @@ void DolphinMainWindow::setupDockWidgets()
     terminalDock->setObjectName("terminalDock");
     terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
     TerminalPanel* terminalPanel = new TerminalPanel(terminalDock);
-    terminalPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+    terminalPanel->setCustomContextMenuActions({lockLayoutAction});
     terminalDock->setWidget(terminalPanel);
 
     connect(terminalPanel, &TerminalPanel::hideTerminalPanel, terminalDock, &DolphinDockWidget::hide);
@@ -1250,7 +1247,7 @@ void DolphinMainWindow::setupDockWidgets()
     placesDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
 
     PlacesPanel* placesPanel = new PlacesPanel(placesDock);
-    placesPanel->setCustomContextMenuActions(QList<QAction*>() << lockLayoutAction);
+    placesPanel->setCustomContextMenuActions({lockLayoutAction});
     placesDock->setWidget(placesPanel);
 
     QAction* placesAction = placesDock->toggleViewAction();
@@ -1262,7 +1259,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,