]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
Paint icons at the correct size
[dolphin.git] / src / dolphinmainwindow.cpp
index 830669726644ec56699f5a13f2adb28db5e6ca40..da6c5319d6eb52c4a6830f2e02abc7ad84ca67a2 100644 (file)
@@ -21,7 +21,6 @@
 
 #include "dolphinmainwindow.h"
 
-#include "dolphinapplication.h"
 #include "dolphindockwidget.h"
 #include "dolphincontextmenu.h"
 #include "dolphinnewfilemenu.h"
 #include <KActionCollection>
 #include <KActionMenu>
 #include <KConfig>
-#include <kdeversion.h>
 #include <kdualaction.h>
-#include <KDialog>
 #include <KJobWidgets>
 #include <QLineEdit>
 #include <KToolBar>
-#include <KIO/NetAccess>
 #include <KIO/JobUiDelegate>
 #include <KLocalizedString>
 #include <KProtocolManager>
@@ -70,6 +66,7 @@
 #include <KToolInvocation>
 #include <KUrlComboBox>
 
+#include <QApplication>
 #include <QMenuBar>
 #include <QClipboard>
 #include <QToolButton>
@@ -78,6 +75,7 @@
 #include <QPushButton>
 #include <QCloseEvent>
 #include <QShowEvent>
+#include <QDialog>
 
 namespace {
     // Used for GeneralSettings::version() to determine whether
@@ -263,11 +261,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();
@@ -358,17 +351,16 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event)
     // Find out if Dolphin is closed directly by the user or
     // by the session manager because the session is closed
     bool closedByUser = true;
-    DolphinApplication *application = qobject_cast<DolphinApplication*>(qApp);
-    if (application && application->sessionSaving()) {
+    if (qApp->isSessionRestored()) {
         closedByUser = false;
     }
 
     if (m_tabWidget->count() > 1 && GeneralSettings::confirmClosingMultipleTabs() && closedByUser) {
         // Ask the user if he really wants to quit and close all tabs.
         // Open a confirmation dialog with 3 buttons:
-        // KDialog::Yes    -> Quit
-        // KDialog::No     -> Close only the current tab
-        // KDialog::Cancel -> do nothing
+        // QDialogButtonBox::Yes    -> Quit
+        // QDialogButtonBox::No     -> Close only the current tab
+        // QDialogButtonBox::Cancel -> do nothing
         QDialog *dialog = new QDialog(this, Qt::Dialog);
         dialog->setWindowTitle(i18nc("@title:window", "Confirmation"));
         dialog->setModal(true);
@@ -693,7 +685,10 @@ void DolphinMainWindow::openTerminal()
 
     // If the given directory is not local, it can still be the URL of an
     // ioslave using UDS_LOCAL_PATH which to be converted first.
-    QUrl url = KIO::NetAccess::mostLocalUrl(m_activeViewContainer->url(), this);
+    KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
+    KJobWidgets::setWindow(statJob, this);
+    statJob->exec();
+    QUrl url = statJob->mostLocalUrl();
 
     //If the URL is local after the above conversion, set the directory.
     if (url.isLocalFile()) {
@@ -763,7 +758,7 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos,
                                         const QUrl& url,
                                         const QList<QAction*>& customActions)
 {
-    QWeakPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
+    QPointer<DolphinContextMenu> contextMenu = new DolphinContextMenu(this, pos, item, url);
     contextMenu.data()->setCustomActions(customActions);
     const DolphinContextMenu::Command command = contextMenu.data()->open();
 
@@ -787,7 +782,10 @@ void DolphinMainWindow::openContextMenu(const QPoint& pos,
         break;
     }
 
-    delete contextMenu.data();
+    // Delete the menu, unless it has been deleted in its own nested event loop already.
+    if (contextMenu) {
+        contextMenu->deleteLater();
+    }
 }
 
 void DolphinMainWindow::updateControlMenu()
@@ -971,7 +969,7 @@ void DolphinMainWindow::setUrlAsCaption(const QUrl& url)
 
     caption.append(fileName);
 
-    setCaption(caption);
+    setWindowTitle(caption);
 }
 
 void DolphinMainWindow::setupActions()
@@ -1087,6 +1085,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());
@@ -1420,7 +1421,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,