#include "panels/folders/folderspanel.h"
#include "panels/places/placespanel.h"
#include "panels/information/informationpanel.h"
+#include "panels/terminal/terminalpanel.h"
#include "settings/dolphinsettingsdialog.h"
#include "statusbar/dolphinstatusbar.h"
#include "views/dolphinviewactionhandler.h"
#include "views/draganddrophelper.h"
#include "views/viewproperties.h"
#include "views/dolphinnewfilemenuobserver.h"
-
-#ifndef Q_OS_WIN
-#include "panels/terminal/terminalpanel.h"
-#endif
-
#include "dolphin_generalsettings.h"
#include <KActionCollection>
#include <KActionMenu>
#include <KAuthorized>
#include <KConfig>
-#include <kdualaction.h>
+#include <KFileItemListProperties>
+#include <KFilePlacesModel>
#include <KHelpMenu>
-#include <KJobWidgets>
-#include <QLineEdit>
-#include <KToolBar>
#include <KIO/JobUiDelegate>
+#include <KJobWidgets>
#include <KLocalizedString>
-#include <KProtocolManager>
-#include <KProtocolInfo>
-#include <QMenu>
#include <KMessageBox>
-#include <KFilePlacesModel>
-#include <KFileItemListProperties>
+#include <KProtocolInfo>
+#include <KProtocolManager>
#include <KRun>
#include <KShell>
#include <KStandardAction>
#include <KToggleAction>
-#include <KUrlNavigator>
+#include <KToolBar>
#include <KToolInvocation>
#include <KUrlComboBox>
+#include <KUrlNavigator>
#include <QApplication>
-#include <QMenuBar>
#include <QClipboard>
-#include <QToolButton>
-#include <QTimer>
-#include <QStandardPaths>
-#include <QPushButton>
#include <QCloseEvent>
-#include <QShowEvent>
#include <QDialog>
+#include <QLineEdit>
+#include <QMenu>
+#include <QMenuBar>
+#include <QPushButton>
+#include <QShowEvent>
+#include <QStandardPaths>
+#include <QTimer>
+#include <QToolButton>
+#include <kdualaction.h>
namespace {
// Used for GeneralSettings::version() to determine whether
m_controlButton(nullptr),
m_updateToolBarTimer(nullptr),
m_lastHandleUrlStatJob(nullptr),
-#ifndef Q_OS_WIN
m_terminalPanel(nullptr),
-#endif
m_placesPanel(nullptr),
m_tearDownFromPlacesRequested(false)
{
case QDialogButtonBox::No:
// Close only the current tab
m_tabWidget->closeTab();
+ // Do not quit, ignore quit event
+ // fall through
default:
event->ignore();
return;
GeneralSettings::setLockPanels(newLockState);
}
+void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
+{
+ if (m_terminalPanel->isHiddenInVisibleWindow()) {
+ m_activeViewContainer->view()->setFocus();
+ }
+}
+
void DolphinMainWindow::goBack()
{
KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
if (m_activeViewContainer->isSearchModeEnabled()) {
if(m_activeViewContainer->currentSearchText().isEmpty()){
- setWindowTitle(i18n("Empty Search"));
+ setWindowTitle(i18n("Search"));
} else {
const auto searchText = i18n("Search for %1", m_activeViewContainer->currentSearchText());
setWindowTitle(searchText);
void DolphinMainWindow::slotStorageTearDownFromPlacesRequested(const QString& mountPath)
{
-#ifndef Q_OS_WIN
if (m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = true;
m_terminalPanel->goHome();
} else {
m_placesPanel->proceedWithTearDown();
}
-#endif
}
void DolphinMainWindow::slotStorageTearDownExternallyRequested(const QString& mountPath)
{
-#ifndef Q_OS_WIN
if (m_terminalPanel->currentWorkingDirectory().startsWith(mountPath)) {
m_tearDownFromPlacesRequested = false;
m_terminalPanel->goHome();
}
-#endif
}
void DolphinMainWindow::setupActions()
QAction* newWindow = actionCollection()->addAction(QStringLiteral("new_window"));
newWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
- actionCollection()->setDefaultShortcut(newWindow, Qt::CTRL | Qt::Key_N);
+ actionCollection()->setDefaultShortcut(newWindow, Qt::CTRL + Qt::Key_N);
connect(newWindow, &QAction::triggered, this, &DolphinMainWindow::openNewMainWindow);
QAction* newTab = actionCollection()->addAction(QStringLiteral("new_tab"));
newTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-new")));
newTab->setText(i18nc("@action:inmenu File", "New Tab"));
- actionCollection()->setDefaultShortcuts(newTab, {Qt::CTRL | Qt::Key_T, 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(QStringLiteral("close_tab"));
closeTab->setIcon(QIcon::fromTheme(QStringLiteral("tab-close")));
closeTab->setText(i18nc("@action:inmenu File", "Close Tab"));
- actionCollection()->setDefaultShortcut(closeTab, Qt::CTRL | Qt::Key_W);
+ actionCollection()->setDefaultShortcut(closeTab, Qt::CTRL + Qt::Key_W);
closeTab->setEnabled(false);
connect(closeTab, &QAction::triggered, m_tabWidget, static_cast<void(DolphinTabWidget::*)()>(&DolphinTabWidget::closeTab));
QAction* selectAll = actionCollection()->addAction(QStringLiteral("select_all"));
selectAll->setText(i18nc("@action:inmenu Edit", "Select All"));
- actionCollection()->setDefaultShortcut(selectAll, Qt::CTRL | Qt::Key_A);
+ selectAll->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-all")));
+ actionCollection()->setDefaultShortcut(selectAll, Qt::CTRL + Qt::Key_A);
connect(selectAll, &QAction::triggered, this, &DolphinMainWindow::selectAll);
QAction* invertSelection = actionCollection()->addAction(QStringLiteral("invert_selection"));
invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
- actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL | Qt::SHIFT | Qt::Key_A);
+ invertSelection->setIcon(QIcon::fromTheme(QStringLiteral("edit-select-invert")));
+ actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL + Qt::SHIFT + Qt::Key_A);
connect(invertSelection, &QAction::triggered, this, &DolphinMainWindow::invertSelection);
// setup 'View' menu
connect(split, &QAction::triggered, this, &DolphinMainWindow::toggleSplitView);
QAction* stashSplit = actionCollection()->addAction(QStringLiteral("split_stash"));
- actionCollection()->setDefaultShortcut(stashSplit, Qt::CTRL | Qt::Key_S);
+ actionCollection()->setDefaultShortcut(stashSplit, Qt::CTRL + Qt::Key_S);
stashSplit->setText(i18nc("@action:intoolbar Stash", "Stash"));
stashSplit->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
stashSplit->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
QAction* replaceLocation = actionCollection()->addAction(QStringLiteral("replace_location"));
replaceLocation->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
- actionCollection()->setDefaultShortcut(replaceLocation, Qt::CTRL | Qt::Key_L);
+ actionCollection()->setDefaultShortcut(replaceLocation, Qt::CTRL + Qt::Key_L);
connect(replaceLocation, &QAction::triggered, this, &DolphinMainWindow::replaceLocation);
// setup 'Go' menu
QAction* undoCloseTab = actionCollection()->addAction(QStringLiteral("undo_close_tab"));
undoCloseTab->setText(i18nc("@action:inmenu File", "Undo close tab"));
- actionCollection()->setDefaultShortcut(undoCloseTab, Qt::CTRL | Qt::SHIFT | Qt::Key_T);
+ actionCollection()->setDefaultShortcut(undoCloseTab, Qt::CTRL + Qt::SHIFT + Qt::Key_T);
undoCloseTab->setIcon(QIcon::fromTheme(QStringLiteral("edit-undo")));
undoCloseTab->setEnabled(false);
connect(undoCloseTab, &QAction::triggered, recentTabsMenu, &DolphinRecentTabsMenu::undoCloseTab);
QAction* showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar"));
showFilterBar->setText(i18nc("@action:inmenu Tools", "Show Filter Bar"));
showFilterBar->setIcon(QIcon::fromTheme(QStringLiteral("view-filter")));
- actionCollection()->setDefaultShortcut(showFilterBar, Qt::CTRL | Qt::Key_I);
+ actionCollection()->setDefaultShortcuts(showFilterBar, {Qt::CTRL + Qt::Key_I, Qt::Key_Slash});
connect(showFilterBar, &QAction::triggered, this, &DolphinMainWindow::showFilterBar);
QAction* compareFiles = actionCollection()->addAction(QStringLiteral("compare_files"));
compareFiles->setEnabled(false);
connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles);
+#ifndef Q_OS_WIN
if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
QAction* openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal"));
openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
openTerminal->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
- actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT | Qt::Key_F4);
+ actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT + Qt::Key_F4);
connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
}
+#endif
// setup 'Settings' menu
KToggleAction* showMenuBar = KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
connect(showMenuBar, &KToggleAction::triggered, // Fixes #286822
this, &DolphinMainWindow::toggleShowMenuBar, Qt::QueuedConnection);
- KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
+ KStandardAction::preferences(this, &DolphinMainWindow::editSettings, actionCollection());
// not in menu actions
QList<QKeySequence> nextTabKeys = KStandardShortcut::tabNext();
- nextTabKeys.append(QKeySequence(Qt::CTRL | Qt::Key_Tab));
+ nextTabKeys.append(QKeySequence(Qt::CTRL + Qt::Key_Tab));
QList<QKeySequence> prevTabKeys = KStandardShortcut::tabPrev();
- prevTabKeys.append(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Tab));
+ prevTabKeys.append(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab));
QAction* activateNextTab = actionCollection()->addAction(QStringLiteral("activate_next_tab"));
activateNextTab->setIconText(i18nc("@action:inmenu", "Next Tab"));
DolphinDockWidget* terminalDock = new DolphinDockWidget(i18nc("@title:window Shell terminal", "Terminal"));
terminalDock->setLocked(lock);
terminalDock->setObjectName(QStringLiteral("terminalDock"));
- terminalDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
m_terminalPanel = new TerminalPanel(terminalDock);
m_terminalPanel->setCustomContextMenuActions({lockLayoutAction});
terminalDock->setWidget(m_terminalPanel);
connect(m_terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged);
connect(terminalDock, &DolphinDockWidget::visibilityChanged,
m_terminalPanel, &TerminalPanel::dockVisibilityChanged);
+ connect(terminalDock, &DolphinDockWidget::visibilityChanged,
+ this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged);
QAction* terminalAction = terminalDock->toggleViewAction();
createPanelAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), Qt::Key_F4, terminalAction, QStringLiteral("show_terminal_panel"));
panelsMenu->addAction(ac->action(QStringLiteral("show_places_panel")));
panelsMenu->addAction(ac->action(QStringLiteral("show_information_panel")));
panelsMenu->addAction(ac->action(QStringLiteral("show_folders_panel")));
-#ifndef Q_OS_WIN
panelsMenu->addAction(ac->action(QStringLiteral("show_terminal_panel")));
-#endif
panelsMenu->addSeparator();
panelsMenu->addAction(lockLayoutAction);
}