#include <KDualAction>
#include <KFileItemListProperties>
#include <KIO/CommandLauncherJob>
-#include <kio_version.h>
-#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
#include <KIO/JobUiDelegateFactory>
-#else
-#include <KIO/JobUiDelegate>
-#endif
#include <KIO/OpenFileManagerWindowJob>
#include <KIO/OpenUrlJob>
#include <KJobWidgets>
#include <KShell>
#include <KShortcutsDialog>
#include <KStandardAction>
-#include <KStartupInfo>
#include <KSycoca>
#include <KTerminalLauncherJob>
#include <KToggleAction>
#include <KWindowSystem>
#include <KXMLGUIFactory>
-#include <kio_version.h>
#include <kwidgetsaddons_version.h>
#include <QApplication>
#include <algorithm>
+#if HAVE_X11
+#include <KStartupInfo>
+#endif
+
namespace
{
// Used for GeneralSettings::version() to determine whether
connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinMainWindow::createDirectory);
connect(m_actionHandler, &DolphinViewActionHandler::selectionModeChangeTriggered, this, &DolphinMainWindow::slotSetSelectionMode);
-#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
- m_newFileMenu->setNewFolderShortcutAction(actionCollection()->action("create_dir"));
-#endif
+ Q_CHECK_PTR(actionCollection()->action(QStringLiteral("create_dir")));
+ m_newFileMenu->setNewFolderShortcutAction(actionCollection()->action(QStringLiteral("create_dir")));
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
connect(this, &DolphinMainWindow::urlChanged, m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
openFiles(QUrl::fromStringList(files), splitView);
}
-bool DolphinMainWindow::isOnCurrentDesktop() const
-{
-#if HAVE_X11
- if (KWindowSystem::isPlatformX11()) {
- const NET::Properties properties = NET::WMDesktop;
- KWindowInfo info(this->winId(), properties);
- return info.isOnCurrentDesktop();
- }
-#endif
- return true;
-}
-
-bool DolphinMainWindow::isOnActivity(const QString &activityId) const
-{
-#if HAVE_X11 && HAVE_KACTIVITIES
- if (KWindowSystem::isPlatformX11()) {
- const NET::Properties properties = NET::Supported;
- const NET::Properties2 properties2 = NET::WM2Activities;
- KWindowInfo info(this->winId(), properties, properties2);
- return info.activities().contains(activityId);
- }
-#endif
- return true;
-}
-
void DolphinMainWindow::activateWindow(const QString &activationToken)
{
window()->setAttribute(Qt::WA_NativeWindow, true);
if (KWindowSystem::isPlatformWayland()) {
KWindowSystem::setCurrentXdgActivationToken(activationToken);
- } else {
+ } else if (KWindowSystem::isPlatformX11()) {
+#if HAVE_X11
KStartupInfo::setNewStartupId(window()->windowHandle(), activationToken.toUtf8());
+#endif
}
KWindowSystem::activateWindow(window()->windowHandle());
QStringList(),
i18n("Do not ask again"),
&doNotAskAgainCheckboxResult,
- KMessageBox::Dangerous);
+ KMessageBox::Notify | KMessageBox::Dangerous);
if (doNotAskAgainCheckboxResult) {
GeneralSettings::setConfirmClosingTerminalRunningProgram(false);
void DolphinMainWindow::updateNewMenu()
{
m_newFileMenu->checkUpToDate();
-#if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0)
m_newFileMenu->setWorkingDirectory(activeViewContainer()->url());
-#else
- m_newFileMenu->setPopupFiles(QList<QUrl>() << activeViewContainer()->url());
-#endif
}
void DolphinMainWindow::createDirectory()
{
-#if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0)
m_newFileMenu->setWorkingDirectory(activeViewContainer()->url());
-#else
- m_newFileMenu->setPopupFiles(QList<QUrl>() << activeViewContainer()->url());
-#endif
m_newFileMenu->createDirectory();
}
{
const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
int entries = 0;
- m_backAction->menu()->clear();
+ QMenu *menu = m_backAction->popupMenu();
+ menu->clear();
for (int i = urlNavigator->historyIndex() + 1; i < urlNavigator->historySize() && entries < MaxNumberOfNavigationentries; ++i, ++entries) {
- QAction *action = urlNavigatorHistoryAction(urlNavigator, i, m_backAction->menu());
- m_backAction->menu()->addAction(action);
+ QAction *action = urlNavigatorHistoryAction(urlNavigator, i, menu);
+ menu->addAction(action);
}
}
{
const KUrlNavigator *urlNavigator = m_activeViewContainer->urlNavigatorInternalWithHistory();
int entries = 0;
- m_forwardAction->menu()->clear();
+ QMenu *menu = m_forwardAction->popupMenu();
for (int i = urlNavigator->historyIndex() - 1; i >= 0 && entries < MaxNumberOfNavigationentries; --i, ++entries) {
- QAction *action = urlNavigatorHistoryAction(urlNavigator, i, m_forwardAction->menu());
- m_forwardAction->menu()->addAction(action);
+ QAction *action = urlNavigatorHistoryAction(urlNavigator, i, menu);
+ menu->addAction(action);
}
}
activeViewContainer()->setUrl(url);
} else {
m_lastHandleUrlOpenJob = new KIO::OpenUrlJob(url);
-#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0)
m_lastHandleUrlOpenJob->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
-#else
- m_lastHandleUrlOpenJob->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this));
-#endif
m_lastHandleUrlOpenJob->setShowOpenOrExecuteDialog(true);
connect(m_lastHandleUrlOpenJob, &KIO::OpenUrlJob::mimeTypeFound, this, [this, url](const QString &mimetype) {
auto hamburgerMenuAction = KStandardAction::hamburgerMenu(nullptr, nullptr, actionCollection());
// setup 'File' menu
- m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
+ m_newFileMenu = new DolphinNewFileMenu(nullptr, this);
+ actionCollection()->addAction(QStringLiteral("new_menu"), m_newFileMenu);
QMenu *menu = m_newFileMenu->menu();
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
menu->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
connect(moveToOtherViewAction, &QAction::triggered, this, &DolphinMainWindow::moveToInactiveSplitView);
QAction *showFilterBar = actionCollection()->addAction(QStringLiteral("show_filter_bar"));
- showFilterBar->setText(i18nc("@action:inmenu Tools", "Filter..."));
+ showFilterBar->setText(i18nc("@action:inmenu Tools", "Filter…"));
showFilterBar->setToolTip(i18nc("@info:tooltip", "Show Filter Bar"));
showFilterBar->setWhatsThis(xi18nc("@info:whatsthis",
"This opens the "
connect(toggleFilter, &QAction::triggered, this, &DolphinMainWindow::toggleFilterBar);
QAction *searchAction = KStandardAction::find(this, &DolphinMainWindow::find, actionCollection());
- searchAction->setText(i18n("Search..."));
+ searchAction->setText(i18n("Search…"));
searchAction->setToolTip(i18nc("@info:tooltip", "Search for files and folders"));
searchAction->setWhatsThis(xi18nc("@info:whatsthis find",
"<para>This helps you "
toggleSelectionModeToolBarAction->setWhatsThis(toggleSelectionModeAction->whatsThis());
actionCollection()->addAction(QStringLiteral("toggle_selection_mode_tool_bar"), toggleSelectionModeToolBarAction);
toggleSelectionModeToolBarAction->setCheckable(true);
- toggleSelectionModeToolBarAction->setPopupMode(QToolButton::DelayedPopup);
+ toggleSelectionModeToolBarAction->setPopupMode(KToolBarPopupAction::DelayedPopup);
connect(toggleSelectionModeToolBarAction, &QAction::triggered, toggleSelectionModeAction, &QAction::trigger);
connect(toggleSelectionModeAction, &QAction::toggled, toggleSelectionModeToolBarAction, &QAction::setChecked);
stashSplit->setVisible(sessionInterface && sessionInterface->isServiceRegistered(QStringLiteral("org.kde.kio.StashNotifier")));
connect(stashSplit, &QAction::triggered, this, &DolphinMainWindow::toggleSplitStash);
- KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection());
+ QAction *redisplay = KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection());
+ redisplay->setToolTip(i18nc("@info:tooltip", "Refresh view"));
+ redisplay->setWhatsThis(xi18nc("@info:whatsthis refresh",
+ "<para>This refreshes "
+ "the folder view.</para>"
+ "<para>If the contents of this folder have changed, refreshing will re-scan this folder "
+ "and show you a newly-updated view of the files and folders contained here.</para>"
+ "<para>If the view is split, this refreshes the one that is currently in focus.</para>"));
QAction *stop = actionCollection()->addAction(QStringLiteral("stop"));
stop->setText(i18nc("@action:inmenu View", "Stop"));
replaceLocation->setWhatsThis(xi18nc("@info:whatsthis",
"This switches to editing the location and selects it "
"so you can quickly enter a different location."));
- actionCollection()->setDefaultShortcut(replaceLocation, Qt::CTRL | Qt::Key_L);
+ actionCollection()->setDefaultShortcuts(replaceLocation, {Qt::CTRL | Qt::Key_L, Qt::ALT | Qt::Key_D});
connect(replaceLocation, &QAction::triggered, this, &DolphinMainWindow::replaceLocation);
// setup 'Go' menu
m_backAction->setObjectName(backAction->objectName());
m_backAction->setShortcuts(backAction->shortcuts());
}
- m_backAction->setPopupMode(QToolButton::DelayedPopup);
+ m_backAction->setPopupMode(KToolBarPopupAction::DelayedPopup);
connect(m_backAction, &QAction::triggered, this, &DolphinMainWindow::goBack);
- connect(m_backAction->menu(), &QMenu::aboutToShow, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu);
- connect(m_backAction->menu(), &QMenu::triggered, this, &DolphinMainWindow::slotGoBack);
+ connect(m_backAction->popupMenu(), &QMenu::aboutToShow, this, &DolphinMainWindow::slotAboutToShowBackPopupMenu);
+ connect(m_backAction->popupMenu(), &QMenu::triggered, this, &DolphinMainWindow::slotGoBack);
actionCollection()->addAction(m_backAction->objectName(), m_backAction);
auto backShortcuts = m_backAction->shortcuts();
m_forwardAction->setObjectName(forwardAction->objectName());
m_forwardAction->setShortcuts(forwardAction->shortcuts());
}
- m_forwardAction->setPopupMode(QToolButton::DelayedPopup);
+ m_forwardAction->setPopupMode(KToolBarPopupAction::DelayedPopup);
connect(m_forwardAction, &QAction::triggered, this, &DolphinMainWindow::goForward);
- connect(m_forwardAction->menu(), &QMenu::aboutToShow, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu);
- connect(m_forwardAction->menu(), &QMenu::triggered, this, &DolphinMainWindow::slotGoForward);
+ connect(m_forwardAction->popupMenu(), &QMenu::aboutToShow, this, &DolphinMainWindow::slotAboutToShowForwardPopupMenu);
+ connect(m_forwardAction->popupMenu(), &QMenu::triggered, this, &DolphinMainWindow::slotGoForward);
actionCollection()->addAction(m_forwardAction->objectName(), m_forwardAction);
actionCollection()->setDefaultShortcuts(m_forwardAction, m_forwardAction->shortcuts());
// enable middle-click to open in a new tab
auto *middleClickEventFilter = new MiddleClickActionEventFilter(this);
connect(middleClickEventFilter, &MiddleClickActionEventFilter::actionMiddleClicked, this, &DolphinMainWindow::slotBackForwardActionMiddleClicked);
- m_backAction->menu()->installEventFilter(middleClickEventFilter);
- m_forwardAction->menu()->installEventFilter(middleClickEventFilter);
+ m_backAction->popupMenu()->installEventFilter(middleClickEventFilter);
+ m_forwardAction->popupMenu()->installEventFilter(middleClickEventFilter);
KStandardAction::up(this, &DolphinMainWindow::goUp, actionCollection());
QAction *homeAction = KStandardAction::home(this, &DolphinMainWindow::goHome, actionCollection());
homeAction->setWhatsThis(xi18nc("@info:whatsthis",
panelAction->setText(dockAction->text());
panelAction->setIcon(icon);
dockAction->setIcon(icon);
+ dockAction->setEnabled(true);
actionCollection()->setDefaultShortcut(panelAction, shortcut);
connect(panelAction, &QAction::triggered, dockAction, &QAction::trigger);
{
return m_tabWidget->isItemVisibleInAnyView(QUrl::fromUserInput(urlOfItem));
}
+
+#include "moc_dolphinmainwindow.cpp"