X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/f6549f08ea0797bcdf5d584ce41005a741db12cb..c72fdaa77380ef811dfef626a4edadbb824ed252:/src/dolphinmainwindow.cpp diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index cd4800b7d..3e4a60571 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -21,6 +21,7 @@ #include "dolphinmainwindow.h" +#include "config-terminal.h" #include "global.h" #include "dolphindockwidget.h" #include "dolphincontextmenu.h" @@ -47,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -78,7 +80,6 @@ #include #include #include -#include namespace { // Used for GeneralSettings::version() to determine whether @@ -327,7 +328,7 @@ void DolphinMainWindow::openInNewTab() foreach (const KFileItem& item, list) { const QUrl& url = DolphinView::openItemAsFolderUrl(item); if (!url.isEmpty()) { - openNewTab(url); + m_tabWidget->openNewTab(url, QUrl(), DolphinTabWidget::AfterCurrentTab); tabCreated = true; } } @@ -335,7 +336,7 @@ void DolphinMainWindow::openInNewTab() // if no new tab has been created from the selection // open the current directory in a new tab if (!tabCreated) { - openNewTab(m_activeViewContainer->url()); + m_tabWidget->openNewTab(m_activeViewContainer->url(), QUrl(), DolphinTabWidget::AfterCurrentTab); } } @@ -407,7 +408,7 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) bool doNotAskAgainCheckboxResult = false; - const int result = KMessageBox::createKMessageBox(dialog, + const auto result = KMessageBox::createKMessageBox(dialog, buttons, QMessageBox::Warning, i18n("You have multiple tabs open in this window, are you sure you want to quit?"), @@ -434,6 +435,58 @@ void DolphinMainWindow::closeEvent(QCloseEvent* event) } } + if (m_terminalPanel->hasProgramRunning() && GeneralSettings::confirmClosingTerminalRunningProgram() && closedByUser) { + // Ask if the user really wants to quit Dolphin with a program that is still running in the Terminal panel + // Open a confirmation dialog with 3 buttons: + // QDialogButtonBox::Yes -> Quit + // QDialogButtonBox::No -> Show Terminal Panel + // QDialogButtonBox::Cancel -> do nothing + QDialog *dialog = new QDialog(this, Qt::Dialog); + dialog->setWindowTitle(i18nc("@title:window", "Confirmation")); + dialog->setModal(true); + auto standardButtons = QDialogButtonBox::Yes | QDialogButtonBox::Cancel; + if (!m_terminalPanel->isVisible()) { + standardButtons |= QDialogButtonBox::No; + } + QDialogButtonBox *buttons = new QDialogButtonBox(standardButtons); + KGuiItem::assign(buttons->button(QDialogButtonBox::Yes), KStandardGuiItem::quit()); + if (!m_terminalPanel->isVisible()) { + KGuiItem::assign( + buttons->button(QDialogButtonBox::No), + KGuiItem(i18n("Show &Terminal Panel"), QIcon::fromTheme(QStringLiteral("utilities-terminal")))); + } + KGuiItem::assign(buttons->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel()); + + bool doNotAskAgainCheckboxResult = false; + + const auto result = KMessageBox::createKMessageBox( + dialog, + buttons, + QMessageBox::Warning, + i18n("The program '%1' is still running in the Terminal panel. Are you sure you want to quit?", m_terminalPanel->runningProgramName()), + QStringList(), + i18n("Do not ask again"), + &doNotAskAgainCheckboxResult, + KMessageBox::Dangerous); + + if (doNotAskAgainCheckboxResult) { + GeneralSettings::setConfirmClosingTerminalRunningProgram(false); + } + + switch (result) { + case QDialogButtonBox::Yes: + // Quit + break; + case QDialogButtonBox::No: + actionCollection()->action("show_terminal_panel")->trigger(); + // Do not quit, ignore quit event + Q_FALLTHROUGH(); + default: + event->ignore(); + return; + } + } + GeneralSettings::setVersion(CurrentDolphinVersion); GeneralSettings::self()->save(); @@ -551,7 +604,7 @@ void DolphinMainWindow::selectAll() // URL instead of all items of the view KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator(); - QLineEdit* lineEdit = urlNavigator->editor()->lineEdit(); // krazy:exclude=qclasses + QLineEdit* lineEdit = urlNavigator->editor()->lineEdit(); const bool selectUrl = urlNavigator->isUrlEditable() && lineEdit->hasFocus(); if (selectUrl) { @@ -621,12 +674,19 @@ void DolphinMainWindow::toggleEditLocation() void DolphinMainWindow::replaceLocation() { KUrlNavigator* navigator = m_activeViewContainer->urlNavigator(); - navigator->setUrlEditable(true); - navigator->setFocus(); - - // select the whole text of the combo box editor - QLineEdit* lineEdit = navigator->editor()->lineEdit(); // krazy:exclude=qclasses - lineEdit->selectAll(); + QLineEdit* lineEdit = navigator->editor()->lineEdit(); + + // If the text field currently has focus and everything is selected, + // pressing the keyboard shortcut returns the whole thing to breadcrumb mode + if (navigator->isUrlEditable() + && lineEdit->hasFocus() + && lineEdit->selectedText() == lineEdit->text() ) { + navigator->setUrlEditable(false); + } else { + navigator->setUrlEditable(true); + navigator->setFocus(); + lineEdit->selectAll(); + } } void DolphinMainWindow::togglePanelLockState() @@ -1001,7 +1061,10 @@ void DolphinMainWindow::tabCountChanged(int count) void DolphinMainWindow::updateWindowTitle() { - setWindowTitle(m_activeViewContainer->caption()); + const QString newTitle = m_activeViewContainer->caption(); + if (windowTitle() != newTitle) { + setWindowTitle(newTitle); + } } void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath) @@ -1151,7 +1214,7 @@ void DolphinMainWindow::setupActions() compareFiles->setEnabled(false); connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles); -#ifndef Q_OS_WIN +#ifdef HAVE_TERMINAL if (KAuthorized::authorize(QStringLiteral("shell_access"))) { QAction* openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal")); openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal")); @@ -1270,7 +1333,7 @@ void DolphinMainWindow::setupDockWidgets() this, &DolphinMainWindow::showErrorMessage); // Setup "Terminal" -#ifndef Q_OS_WIN +#ifdef HAVE_TERMINAL if (KAuthorized::authorize(QStringLiteral("shell_access"))) { DolphinDockWidget* terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal")); terminalDock->setLocked(lock); @@ -1543,7 +1606,7 @@ void DolphinMainWindow::updateSplitAction() QAction* splitAction = actionCollection()->action(QStringLiteral("split_view")); const DolphinTabPage* tabPage = m_tabWidget->currentTabPage(); if (tabPage->splitViewEnabled()) { - if (tabPage->primaryViewActive()) { + if (GeneralSettings::closeActiveSplitView() ? tabPage->primaryViewActive() : !tabPage->primaryViewActive()) { splitAction->setText(i18nc("@action:intoolbar Close left view", "Close")); splitAction->setToolTip(i18nc("@info", "Close left view")); splitAction->setIcon(QIcon::fromTheme(QStringLiteral("view-left-close")));