X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/cadfb2a3c621b875fa3df7ac629bf0b402ac3823..abb6807645598e8117e98bbf232cd9cd90fe019a:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 64aba63a5..e83b8ac48 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -30,13 +30,13 @@ #include "settings/dolphinsettings.h" #include "settings/dolphinsettingsdialog.h" #include "dolphinsearchbox.h" -#include "dolphinstatusbar.h" #include "dolphinviewcontainer.h" #include "panels/folders/folderspanel.h" #include "panels/places/placespanel.h" #include "panels/information/informationpanel.h" #include "panels/information/metadatawidget.h" #include "mainwindowadaptor.h" +#include "statusbar/dolphinstatusbar.h" #include "viewproperties.h" #ifndef Q_OS_WIN @@ -84,7 +84,6 @@ #include #include #include -#include #include #include #include @@ -236,9 +235,9 @@ void DolphinMainWindow::changeUrl(const KUrl& url) updateEditActions(); updateViewActions(); updateGoActions(); - setCaption(url.fileName()); + setUrlAsCaption(url); if (m_viewTab.count() > 1) { - m_tabBar->setTabText(m_tabIndex, tabName(url)); + m_tabBar->setTabText(m_tabIndex, squeezedText(tabName(m_activeViewContainer->url()))); } const QString iconName = KMimeType::iconNameForUrl(url); m_tabBar->setTabIcon(m_tabIndex, KIcon(iconName)); @@ -275,8 +274,6 @@ void DolphinMainWindow::slotSelectionChanged(const KFileItemList& selection) compareFilesAction->setEnabled(false); } - m_activeViewContainer->updateStatusBar(); - emit selectionChanged(selection); } @@ -340,11 +337,11 @@ void DolphinMainWindow::openNewTab(const KUrl& url) if (m_viewTab.count() == 1) { // Only one view is open currently and hence no tab is shown at // all. Before creating a tab for 'url', provide a tab for the current URL. - m_tabBar->addTab(icon, tabName(m_activeViewContainer->url())); + m_tabBar->addTab(icon, squeezedText(tabName(m_activeViewContainer->url()))); m_tabBar->blockSignals(false); } - m_tabBar->addTab(icon, tabName(url)); + m_tabBar->addTab(icon, squeezedText(tabName(url))); ViewTab viewTab; viewTab.splitter = new QSplitter(this); @@ -429,7 +426,15 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) DolphinSettings& settings = DolphinSettings::instance(); GeneralSettings* generalSettings = settings.generalSettings(); - if ((m_viewTab.count() > 1) && generalSettings->confirmClosingMultipleTabs()) { + // 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(qApp); + if (application && application->sessionSaving()) { + closedByUser = false; + } + + if ((m_viewTab.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 @@ -646,7 +651,7 @@ void DolphinMainWindow::selectAll() // URL instead of all items of the view KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator(); - QLineEdit* lineEdit = urlNavigator->editor()->lineEdit(); + QLineEdit* lineEdit = urlNavigator->editor()->lineEdit(); // krazy:exclude=qclasses const bool selectUrl = urlNavigator->isUrlEditable() && lineEdit->hasFocus(); if (selectUrl) { @@ -722,7 +727,7 @@ void DolphinMainWindow::replaceLocation() navigator->setFocus(); // select the whole text of the combo box editor - QLineEdit* lineEdit = navigator->editor()->lineEdit(); + QLineEdit* lineEdit = navigator->editor()->lineEdit(); // krazy:exclude=qclasses const QString text = lineEdit->text(); lineEdit->setSelection(0, text.length()); } @@ -813,7 +818,18 @@ void DolphinMainWindow::toggleShowMenuBar() void DolphinMainWindow::openTerminal() { - KToolInvocation::invokeTerminal(QString(), m_activeViewContainer->url().path()); + QString dir(QDir::homePath()); + + // 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. + KUrl url = KIO::NetAccess::mostLocalUrl(m_activeViewContainer->url(), this); + + //If the URL is local after the above conversion, set the directory. + if (url.isLocalFile()) { + dir = url.toLocalFile(); + } + + KToolInvocation::invokeTerminal(QString(), dir); } void DolphinMainWindow::editSettings() @@ -987,7 +1003,7 @@ void DolphinMainWindow::init() setupActions(); const KUrl& homeUrl = generalSettings->homeUrl(); - setCaption(homeUrl.fileName()); + setUrlAsCaption(homeUrl); m_actionHandler = new DolphinViewActionHandler(actionCollection(), this); connect(m_actionHandler, SIGNAL(actionBeingHandled()), SLOT(clearStatusBar())); connect(m_actionHandler, SIGNAL(createDirectory()), SLOT(createDirectory())); @@ -1096,7 +1112,7 @@ void DolphinMainWindow::setActiveViewContainer(DolphinViewContainer* viewContain updateGoActions(); const KUrl& url = m_activeViewContainer->url(); - setCaption(url.fileName()); + setUrlAsCaption(url); if (m_viewTab.count() > 1 && m_viewTab[m_tabIndex].secondaryView != 0) { m_tabBar->setTabText(m_tabIndex, tabName(url)); m_tabBar->setTabIcon(m_tabIndex, KIcon(KMimeType::iconNameForUrl(url))); @@ -1220,6 +1236,7 @@ void DolphinMainWindow::setupActions() KToggleAction* showFilterBar = actionCollection()->add("show_filter_bar"); showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar")); + showFilterBar->setIcon(KIcon("view-filter")); showFilterBar->setShortcut(Qt::CTRL | Qt::Key_I); connect(showFilterBar, SIGNAL(triggered(bool)), this, SLOT(toggleFilterBarVisibility(bool))); @@ -1231,7 +1248,7 @@ void DolphinMainWindow::setupActions() KAction* openTerminal = actionCollection()->addAction("open_terminal"); openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal")); - openTerminal->setIcon(KIcon("terminal")); + openTerminal->setIcon(KIcon("utilities-terminal")); openTerminal->setShortcut(Qt::SHIFT | Qt::Key_F4); connect(openTerminal, SIGNAL(triggered()), this, SLOT(openTerminal())); @@ -1331,7 +1348,7 @@ void DolphinMainWindow::setupDockWidgets() QAction* terminalAction = terminalDock->toggleViewAction(); terminalAction->setText(i18nc("@title:window Shell terminal", "Terminal")); terminalAction->setShortcut(Qt::Key_F4); - terminalAction->setIcon(KIcon("terminal")); + terminalAction->setIcon(KIcon("utilities-terminal")); actionCollection()->addAction("show_terminal_panel", terminalDock->toggleViewAction()); addDockWidget(Qt::BottomDockWidgetArea, terminalDock); @@ -1424,10 +1441,7 @@ void DolphinMainWindow::rememberClosedTab(int index) const QString primaryPath = m_viewTab[index].primaryView->url().path(); const QString iconName = KMimeType::iconNameForUrl(primaryPath); - const QFontMetrics fm = fontMetrics(); - const QString actionText = fm.elidedText(primaryPath, Qt::ElideMiddle, fm.maxWidth() * 20); - - QAction* action = new QAction(actionText, tabsMenu); + QAction* action = new QAction(squeezedText(primaryPath), tabsMenu); ClosedTab closedTab; closedTab.primaryUrl = m_viewTab[index].primaryView->url(); @@ -1508,7 +1522,7 @@ QString DolphinMainWindow::tabName(const KUrl& url) const { QString name; if (url.equals(KUrl("file:///"))) { - name = "/"; + name = '/'; } else { name = url.fileName(); if (name.isEmpty()) { @@ -1555,6 +1569,27 @@ QString DolphinMainWindow::tabProperty(const QString& property, int tabIndex) co return "Tab " + QString::number(tabIndex) + ' ' + property; } +void DolphinMainWindow::setUrlAsCaption(const KUrl& url) +{ + QString caption; + if (url.equals(KUrl("file:///"))) { + caption = '/'; + } else { + caption = url.fileName(); + if (caption.isEmpty()) { + caption = url.protocol(); + } + } + + setCaption(caption); +} + +QString DolphinMainWindow::squeezedText(const QString& text) const +{ + const QFontMetrics fm = fontMetrics(); + return fm.elidedText(text, Qt::ElideMiddle, fm.maxWidth() * 10); +} + DolphinMainWindow::UndoUiInterface::UndoUiInterface() : KIO::FileUndoManager::UiInterface() {