From 11fb9344c0fac2544479dbd7a9913eba740b74b5 Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Tue, 22 Aug 2023 12:15:22 +0000 Subject: Allow to not ask again confirmation when opening 5 or more files or terminal at once BUG: 473513 --- src/views/dolphinview.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/views/dolphinview.cpp') diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index e0d01d1e8..1d01b4c98 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -1093,11 +1093,12 @@ void DolphinView::slotItemsActivated(const KItemSet &indexes) {}, #endif KGuiItem(i18ncp("@action:button", "Open %1 Item", "Open %1 Items", indexes.count()), QStringLiteral("document-open")), - KStandardGuiItem::cancel()); + KStandardGuiItem::cancel(), + QStringLiteral("ConfirmOpenManyFolders")); #if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) - if (answer != KMessageBox::PrimaryAction) { + if (answer != KMessageBox::PrimaryAction && answer != KMessageBox::Continue) { #else - if (answer != KMessageBox::Yes) { + if (answer != KMessageBox::Yes && answer != KMessageBox::Continue) { #endif return; } -- cgit v1.3 From 1318f16fd7b84de79c04eb468d61e1c9b7b52e15 Mon Sep 17 00:00:00 2001 From: Méven Car Date: Mon, 28 Aug 2023 10:32:35 +0200 Subject: Clean obsolete ifdefs since dolphin requires KF 5.101+ --- src/dolphincontextmenu.cpp | 8 ---- src/dolphinmainwindow.cpp | 30 --------------- src/dolphinpart.cpp | 8 ---- src/dolphinviewcontainer.cpp | 16 +------- src/kitemviews/kfileitemmodel.cpp | 12 ------ src/panels/folders/treeviewcontextmenu.cpp | 30 +-------------- .../contextmenu/contextmenusettingspage.cpp | 9 ----- src/settings/dolphinsettingsdialog.cpp | 12 ------ src/settings/viewpropertiesdialog.cpp | 8 ---- src/tests/kfileitemmodeltest.cpp | 3 -- src/trash/dolphintrash.cpp | 19 +-------- src/views/dolphinview.cpp | 45 +--------------------- 12 files changed, 5 insertions(+), 195 deletions(-) (limited to 'src/views/dolphinview.cpp') diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 4addf53cd..99db5584c 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -171,11 +171,7 @@ void DolphinContextMenu::addDirectoryItemContextMenu() // set up 'Create New' menu DolphinNewFileMenu *newFileMenu = new DolphinNewFileMenu(m_mainWindow->actionCollection(), m_mainWindow); newFileMenu->checkUpToDate(); -#if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0) newFileMenu->setWorkingDirectory(m_fileInfo.url()); -#else - newFileMenu->setPopupFiles(QList() << m_fileInfo.url()); -#endif newFileMenu->setEnabled(selectedItemsProps.supportsWriting()); connect(newFileMenu, &DolphinNewFileMenu::fileCreated, newFileMenu, &DolphinNewFileMenu::deleteLater); connect(newFileMenu, &DolphinNewFileMenu::directoryCreated, newFileMenu, &DolphinNewFileMenu::deleteLater); @@ -281,11 +277,7 @@ void DolphinContextMenu::addViewportContextMenu() // Set up and insert 'Create New' menu KNewFileMenu *newFileMenu = m_mainWindow->newFileMenu(); newFileMenu->checkUpToDate(); -#if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0) newFileMenu->setWorkingDirectory(m_baseUrl); -#else - newFileMenu->setPopupFiles(QList() << m_baseUrl); -#endif addMenu(newFileMenu->menu()); // Show "open with" menu items even if the dir is empty, because there are legitimate diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index afb86e152..38843f82c 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -42,12 +42,7 @@ #include #include #include -#include -#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0) #include -#else -#include -#endif #include #include #include @@ -69,9 +64,7 @@ #include #include #include - #include -#include #include #include @@ -676,20 +669,12 @@ void DolphinMainWindow::readProperties(const KConfigGroup &group) 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() << 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() << activeViewContainer()->url()); -#endif m_newFileMenu->createDirectory(); } @@ -1177,25 +1162,14 @@ void DolphinMainWindow::openTerminalHere() if (urls.count() > 5) { QString question = i18np("Are you sure you want to open 1 terminal window?", "Are you sure you want to open %1 terminal windows?", urls.count()); -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) const int answer = KMessageBox::warningTwoActions( this, question, {}, -#else - const int answer = KMessageBox::warningYesNo( - this, - question, - {}, -#endif KGuiItem(i18ncp("@action:button", "Open %1 Terminal", "Open %1 Terminals", urls.count()), QStringLiteral("utilities-terminal")), KStandardGuiItem::cancel(), QStringLiteral("ConfirmOpenManyTerminals")); -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) if (answer != KMessageBox::PrimaryAction && answer != KMessageBox::Continue) { -#else - if (answer != KMessageBox::Yes && answer != KMessageBox::Continue) { -#endif return; } } @@ -1265,11 +1239,7 @@ void DolphinMainWindow::handleUrl(const QUrl &url) 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) { diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index f8da1c353..aac278035 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -548,11 +548,7 @@ void DolphinPart::updateNewMenu() // As requested by KNewFileMenu : m_newFileMenu->checkUpToDate(); // And set the files that the menu apply on : -#if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0) m_newFileMenu->setWorkingDirectory(url()); -#else - m_newFileMenu->setPopupFiles(QList() << url()); -#endif } void DolphinPart::updateStatusBar() @@ -567,11 +563,7 @@ void DolphinPart::updateProgress(int percent) void DolphinPart::createDirectory() { -#if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0) m_newFileMenu->setWorkingDirectory(url()); -#else - m_newFileMenu->setPopupFiles(QList() << url()); -#endif m_newFileMenu->createDirectory(); } diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 2811a1ee4..63d5bd27b 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -23,20 +23,16 @@ #if HAVE_KACTIVITIES #include #endif +#include #include #include -#include -#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0) #include -#else -#include -#endif -#include #include #include #include #include #include +#include #include #include @@ -731,11 +727,7 @@ void DolphinViewContainer::slotItemActivated(const KFileItem &item) } KIO::OpenUrlJob *job = new KIO::OpenUrlJob(item.targetUrl(), item.mimetype()); -#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0) job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); -#else - job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); -#endif job->setShowOpenOrExecuteDialog(true); connect(job, &KIO::OpenUrlJob::finished, this, &DolphinViewContainer::slotOpenUrlFinished); job->start(); @@ -766,11 +758,7 @@ void DolphinViewContainer::slotfileMiddleClickActivated(const KFileItem &item) KIO::ApplicationLauncherJob *job = new KIO::ApplicationLauncherJob(service, this); job->setUrls({item.url()}); -#if KIO_VERSION >= QT_VERSION_CHECK(5, 98, 0) job->setUiDelegate(KIO::createDefaultJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); -#else - job->setUiDelegate(new KIO::JobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, this)); -#endif connect(job, &KIO::OpenUrlJob::finished, this, &DolphinViewContainer::slotOpenUrlFinished); job->start(); } diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index bbe725dfd..40c76c7ef 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -263,11 +263,7 @@ void KFileItemModel::setShowTrashMime(bool show) void KFileItemModel::setShowHiddenFiles(bool show) { -#if KIO_VERSION < QT_VERSION_CHECK(5, 100, 0) - m_dirLister->setShowingDotFiles(show); -#else m_dirLister->setShowHiddenFiles(show); -#endif setShowTrashMime(show); m_dirLister->emitChanges(); if (show) { @@ -277,11 +273,7 @@ void KFileItemModel::setShowHiddenFiles(bool show) bool KFileItemModel::showHiddenFiles() const { -#if KIO_VERSION < QT_VERSION_CHECK(5, 100, 0) - return m_dirLister->showingDotFiles(); -#else return m_dirLister->showHiddenFiles(); -#endif } void KFileItemModel::setShowDirectoriesOnly(bool enabled) @@ -624,9 +616,7 @@ bool KFileItemModel::setExpanded(int index, bool expanded) m_expandedDirs.remove(targetUrl); m_dirLister->stop(url); -#if KIO_VERSION >= QT_VERSION_CHECK(5, 92, 0) m_dirLister->forgetDirs(url); -#endif const int parentLevel = expandedParentsCount(index); const int itemCount = m_itemData.count(); @@ -642,9 +632,7 @@ bool KFileItemModel::setExpanded(int index, bool expanded) const QUrl url = itemData->item.url(); m_expandedDirs.remove(targetUrl); m_dirLister->stop(url); // TODO: try to unit-test this, see https://bugs.kde.org/show_bug.cgi?id=332102#c11 -#if KIO_VERSION >= QT_VERSION_CHECK(5, 92, 0) m_dirLister->forgetDirs(url); -#endif expandedChildren.append(targetUrl); } ++childIndex; diff --git a/src/panels/folders/treeviewcontextmenu.cpp b/src/panels/folders/treeviewcontextmenu.cpp index e063ca85e..45e146a2e 100644 --- a/src/panels/folders/treeviewcontextmenu.cpp +++ b/src/panels/folders/treeviewcontextmenu.cpp @@ -22,13 +22,8 @@ #include #include -#include -#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0) #include -#else -#include -#include -#endif +#include #include #include @@ -197,39 +192,16 @@ void TreeViewContextMenu::rename() void TreeViewContextMenu::moveToTrash() { -#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0) using Iface = KIO::AskUserActionInterface; auto *deleteJob = new KIO::DeleteOrTrashJob(QList{m_fileItem.url()}, Iface::Trash, Iface::DefaultConfirmation, m_parent); deleteJob->start(); -#else - const QList list{m_fileItem.url()}; - KIO::JobUiDelegate uiDelegate; - uiDelegate.setWindow(m_parent); - if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) { - KIO::Job *job = KIO::trash(list); - KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, QUrl(QStringLiteral("trash:/")), job); - KJobWidgets::setWindow(job, m_parent); - job->uiDelegate()->setAutoErrorHandlingEnabled(true); - } -#endif } void TreeViewContextMenu::deleteItem() { -#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0) using Iface = KIO::AskUserActionInterface; auto *deleteJob = new KIO::DeleteOrTrashJob(QList{m_fileItem.url()}, Iface::Delete, Iface::DefaultConfirmation, m_parent); deleteJob->start(); -#else - const QList list{m_fileItem.url()}; - KIO::JobUiDelegate uiDelegate; - uiDelegate.setWindow(m_parent); - if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) { - KIO::Job *job = KIO::del(list); - KJobWidgets::setWindow(job, m_parent); - job->uiDelegate()->setAutoErrorHandlingEnabled(true); - } -#endif } void TreeViewContextMenu::showProperties() diff --git a/src/settings/contextmenu/contextmenusettingspage.cpp b/src/settings/contextmenu/contextmenusettingspage.cpp index 03e55ba32..fa3d0b256 100644 --- a/src/settings/contextmenu/contextmenusettingspage.cpp +++ b/src/settings/contextmenu/contextmenusettingspage.cpp @@ -206,24 +206,15 @@ void ContextMenuSettingsPage::applySettings() VersionControlSettings::self()->save(); if (!laterSelected) { -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) KMessageBox::ButtonCode promptRestart = KMessageBox::questionTwoActions(window(), -#else - KMessageBox::ButtonCode promptRestart = - KMessageBox::questionYesNo(window(), -#endif i18nc("@info", "Dolphin must be restarted to apply the " "updated version control system settings."), i18nc("@info", "Restart now?"), KGuiItem(QApplication::translate("KStandardGuiItem", "&Restart"), QStringLiteral("dialog-restart")), KGuiItem(QApplication::translate("KStandardGuiItem", "&Later"), QStringLiteral("dialog-later"))); -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) if (promptRestart == KMessageBox::ButtonCode::PrimaryAction) { -#else - if (promptRestart == KMessageBox::ButtonCode::Yes) { -#endif Dolphin::openNewWindow(); qApp->quit(); } else { diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp index 45aa7b65a..3a2ad31e9 100644 --- a/src/settings/dolphinsettingsdialog.cpp +++ b/src/settings/dolphinsettingsdialog.cpp @@ -160,29 +160,17 @@ void DolphinSettingsDialog::closeEvent(QCloseEvent *event) return; } -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) const auto response = KMessageBox::warningTwoActionsCancel(this, -#else - const auto response = KMessageBox::warningYesNoCancel(this, -#endif i18n("You have unsaved changes. Do you want to apply the changes or discard them?"), i18n("Warning"), KStandardGuiItem::save(), KStandardGuiItem::discard(), KStandardGuiItem::cancel()); switch (response) { -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) case KMessageBox::PrimaryAction: -#else - case KMessageBox::Yes: -#endif applySettings(); Q_FALLTHROUGH(); -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) case KMessageBox::SecondaryAction: -#else - case KMessageBox::No: -#endif event->accept(); break; case KMessageBox::Cancel: diff --git a/src/settings/viewpropertiesdialog.cpp b/src/settings/viewpropertiesdialog.cpp index f7bd754b1..c630f8113 100644 --- a/src/settings/viewpropertiesdialog.cpp +++ b/src/settings/viewpropertiesdialog.cpp @@ -333,11 +333,7 @@ void ViewPropertiesDialog::applyViewProperties() const bool applyToSubFolders = m_applyToSubFolders && m_applyToSubFolders->isChecked(); if (applyToSubFolders) { const QString text(i18nc("@info", "The view properties of all sub-folders will be changed. Do you want to continue?")); -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) if (KMessageBox::questionTwoActions(this, text, {}, KStandardGuiItem::cont(), KStandardGuiItem::cancel()) == KMessageBox::SecondaryAction) { -#else - if (KMessageBox::questionYesNo(this, text, {}, KStandardGuiItem::cont(), KStandardGuiItem::cancel()) == KMessageBox::No) { -#endif return; } @@ -367,11 +363,7 @@ void ViewPropertiesDialog::applyViewProperties() if (applyToAllFolders) { const QString text(i18nc("@info", "The view properties of all folders will be changed. Do you want to continue?")); -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) if (KMessageBox::questionTwoActions(this, text, {}, KStandardGuiItem::cont(), KStandardGuiItem::cancel()) == KMessageBox::SecondaryAction) { -#else - if (KMessageBox::questionYesNo(this, text, {}, KStandardGuiItem::cont(), KStandardGuiItem::cancel()) == KMessageBox::No) { -#endif return; } diff --git a/src/tests/kfileitemmodeltest.cpp b/src/tests/kfileitemmodeltest.cpp index 38d2544aa..753960a08 100644 --- a/src/tests/kfileitemmodeltest.cpp +++ b/src/tests/kfileitemmodeltest.cpp @@ -2479,9 +2479,6 @@ void KFileItemModelTest::testInsertAfterExpand() // Insert additional files into "a/b/" m_testDir->createFile("a/b/2"); -#if KIO_VERSION < QT_VERSION_CHECK(5, 92, 0) - QEXPECT_FAIL("", "Requires new API from frameworks", Abort); -#endif QVERIFY(!itemsInsertedSpy.wait(5000)); diff --git a/src/trash/dolphintrash.cpp b/src/trash/dolphintrash.cpp index b37a7430d..007f48a33 100644 --- a/src/trash/dolphintrash.cpp +++ b/src/trash/dolphintrash.cpp @@ -13,13 +13,8 @@ #include #include -#include -#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0) #include -#else -#include -#include -#endif +#include Trash::Trash() : m_trashDirLister(new KDirLister()) @@ -62,22 +57,10 @@ static void notifyEmptied() void Trash::empty(QWidget *window) { -#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0) using Iface = KIO::AskUserActionInterface; auto *emptyJob = new KIO::DeleteOrTrashJob(QList{}, Iface::EmptyTrash, Iface::DefaultConfirmation, window); QObject::connect(emptyJob, &KIO::Job::result, notifyEmptied); emptyJob->start(); -#else - KIO::JobUiDelegate uiDelegate; - uiDelegate.setWindow(window); - bool confirmed = uiDelegate.askDeleteConfirmation(QList(), KIO::JobUiDelegate::EmptyTrash, KIO::JobUiDelegate::DefaultConfirmation); - if (confirmed) { - KIO::Job *job = KIO::emptyTrash(); - KJobWidgets::setWindow(job, window); - job->uiDelegate()->setAutoErrorHandlingEnabled(true); - QObject::connect(job, &KIO::Job::result, notifyEmptied); - } -#endif } bool Trash::isEmpty() diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 1d01b4c98..d525df4c6 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -49,10 +49,8 @@ #include -#include -#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0) #include -#endif +#include #include #include @@ -758,43 +756,22 @@ void DolphinView::trashSelectedItems() { const QList list = simplifiedSelectedUrls(); -#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0) using Iface = KIO::AskUserActionInterface; auto *trashJob = new KIO::DeleteOrTrashJob(list, Iface::Trash, Iface::DefaultConfirmation, this); connect(trashJob, &KJob::result, this, &DolphinView::slotTrashFileFinished); m_selectNextItem = true; trashJob->start(); -#else - KIO::JobUiDelegate uiDelegate; - uiDelegate.setWindow(window()); - if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) { - KIO::Job *job = KIO::trash(list); - KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, list, QUrl(QStringLiteral("trash:/")), job); - KJobWidgets::setWindow(job, this); - connect(job, &KIO::Job::result, this, &DolphinView::slotTrashFileFinished); - } -#endif } void DolphinView::deleteSelectedItems() { const QList list = simplifiedSelectedUrls(); -#if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0) using Iface = KIO::AskUserActionInterface; auto *trashJob = new KIO::DeleteOrTrashJob(list, Iface::Delete, Iface::DefaultConfirmation, this); connect(trashJob, &KJob::result, this, &DolphinView::slotTrashFileFinished); m_selectNextItem = true; trashJob->start(); -#else - KIO::JobUiDelegate uiDelegate; - uiDelegate.setWindow(window()); - if (uiDelegate.askDeleteConfirmation(list, KIO::JobUiDelegate::Delete, KIO::JobUiDelegate::DefaultConfirmation)) { - KIO::Job *job = KIO::del(list); - KJobWidgets::setWindow(job, this); - connect(job, &KIO::Job::result, this, &DolphinView::slotDeleteFileFinished); - } -#endif } void DolphinView::cutSelectedItemsToClipboard() @@ -1081,25 +1058,14 @@ void DolphinView::slotItemsActivated(const KItemSet &indexes) if (indexes.count() > 5) { QString question = i18np("Are you sure you want to open 1 item?", "Are you sure you want to open %1 items?", indexes.count()); -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) const int answer = KMessageBox::warningTwoActions( this, question, {}, -#else - const int answer = - KMessageBox::warningYesNo(this, - question, - {}, -#endif KGuiItem(i18ncp("@action:button", "Open %1 Item", "Open %1 Items", indexes.count()), QStringLiteral("document-open")), KStandardGuiItem::cancel(), QStringLiteral("ConfirmOpenManyFolders")); -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) if (answer != KMessageBox::PrimaryAction && answer != KMessageBox::Continue) { -#else - if (answer != KMessageBox::Yes && answer != KMessageBox::Continue) { -#endif return; } } @@ -2025,13 +1991,8 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray &role, con if (!hiddenFilesShown() && newName.startsWith(QLatin1Char('.')) && !oldItem.name().startsWith(QLatin1Char('.'))) { KGuiItem yesGuiItem(i18nc("@action:button", "Rename and Hide"), QStringLiteral("view-hidden")); -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) const auto code = KMessageBox::questionTwoActions(this, -#else - const auto code = - KMessageBox::questionYesNo(this, -#endif oldItem.isFile() ? i18n("Adding a dot to the beginning of this file's name will hide it from view.\n" "Do you still want to rename it?") : i18n("Adding a dot to the beginning of this folder's name will hide it from view.\n" @@ -2041,11 +2002,7 @@ void DolphinView::slotRoleEditingFinished(int index, const QByteArray &role, con KStandardGuiItem::cancel(), QStringLiteral("ConfirmHide")); -#if KWIDGETSADDONS_VERSION >= QT_VERSION_CHECK(5, 100, 0) if (code == KMessageBox::SecondaryAction) { -#else - if (code == KMessageBox::No) { -#endif return; } } -- cgit v1.3 From 0cbc912319f503e94f13b8f06bd83f6e945dd26f Mon Sep 17 00:00:00 2001 From: Méven Car Date: Mon, 28 Aug 2023 10:13:21 +0200 Subject: Use KMessageBox::warningContinueCancel when appropriate This will prevent saving the "Cancel" + "don't show again" result, which is meaningless. --- src/dolphinmainwindow.cpp | 2 +- src/settings/dolphin_generalsettings.kcfg | 4 ++-- src/settings/interface/confirmationssettingspage.cpp | 8 ++++---- src/views/dolphinview.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/views/dolphinview.cpp') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 38843f82c..637cd55af 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1162,7 +1162,7 @@ void DolphinMainWindow::openTerminalHere() if (urls.count() > 5) { QString question = i18np("Are you sure you want to open 1 terminal window?", "Are you sure you want to open %1 terminal windows?", urls.count()); - const int answer = KMessageBox::warningTwoActions( + const int answer = KMessageBox::warningContinueCancel( this, question, {}, diff --git a/src/settings/dolphin_generalsettings.kcfg b/src/settings/dolphin_generalsettings.kcfg index 9bb202b71..2abd7da49 100644 --- a/src/settings/dolphin_generalsettings.kcfg +++ b/src/settings/dolphin_generalsettings.kcfg @@ -145,11 +145,11 @@ - false + true - false + true diff --git a/src/settings/interface/confirmationssettingspage.cpp b/src/settings/interface/confirmationssettingspage.cpp index 491f8261f..5f1abb4cd 100644 --- a/src/settings/interface/confirmationssettingspage.cpp +++ b/src/settings/interface/confirmationssettingspage.cpp @@ -136,8 +136,8 @@ void ConfirmationsSettingsPage::applySettings() GeneralSettings *settings = GeneralSettings::self(); settings->setConfirmClosingMultipleTabs(m_confirmClosingMultipleTabs->isChecked()); - settings->setConfirmOpenManyFolders(!m_confirmOpenManyFolders->isChecked()); - settings->setConfirmOpenManyTerminals(!m_confirmOpenManyTerminals->isChecked()); + settings->setConfirmOpenManyFolders(m_confirmOpenManyFolders->isChecked()); + settings->setConfirmOpenManyTerminals(m_confirmOpenManyTerminals->isChecked()); #if HAVE_TERMINAL settings->setConfirmClosingTerminalRunningProgram(m_confirmClosingTerminalRunningProgram->isChecked()); @@ -182,8 +182,8 @@ void ConfirmationsSettingsPage::loadSettings() // KMessageBox for its dontshowAgain settings are true => Yes, false => No, No value => ask // we use default = false to not write false into the rc file, but have no value // the UI has inversed meaning compared to the interpretation - m_confirmOpenManyFolders->setChecked(!GeneralSettings::confirmOpenManyFolders()); - m_confirmOpenManyTerminals->setChecked(!GeneralSettings::confirmOpenManyTerminals()); + m_confirmOpenManyFolders->setChecked(GeneralSettings::confirmOpenManyFolders()); + m_confirmOpenManyTerminals->setChecked(GeneralSettings::confirmOpenManyTerminals()); #if HAVE_TERMINAL m_confirmClosingTerminalRunningProgram->setChecked(GeneralSettings::confirmClosingTerminalRunningProgram()); diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index d525df4c6..d0d524196 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -1058,7 +1058,7 @@ void DolphinView::slotItemsActivated(const KItemSet &indexes) if (indexes.count() > 5) { QString question = i18np("Are you sure you want to open 1 item?", "Are you sure you want to open %1 items?", indexes.count()); - const int answer = KMessageBox::warningTwoActions( + const int answer = KMessageBox::warningContinueCancel( this, question, {}, -- cgit v1.3 From 079f903bc8691866b4aa3c3e41204a47e735c062 Mon Sep 17 00:00:00 2001 From: Méven Car Date: Mon, 28 Aug 2023 14:39:00 +0200 Subject: Fix a bunch of clazy warnings --- src/dolphincontextmenu.cpp | 2 -- src/dolphinmainwindow.cpp | 5 +++-- src/dolphinpart.h | 2 +- src/dolphintabwidget.h | 4 +++- src/kitemviews/kitemlistcontroller.h | 7 ++----- src/kitemviews/kitemlistview.h | 4 ++-- src/kitemviews/private/kitemlistheaderwidget.cpp | 2 +- src/kitemviews/private/kitemlistrubberband.h | 2 +- src/search/dolphinquery.cpp | 2 +- src/selectionmode/backgroundcolorhelper.cpp | 2 +- src/selectionmode/bottombarcontentscontainer.cpp | 8 ++++---- .../contextmenu/contextmenusettingspage.cpp | 1 - src/settings/viewmodes/viewsettingstab.h | 3 --- src/views/dolphinitemlistview.cpp | 2 +- src/views/dolphinview.cpp | 24 ++++++++-------------- src/views/dolphinview.h | 2 ++ 16 files changed, 31 insertions(+), 41 deletions(-) (limited to 'src/views/dolphinview.cpp') diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 99db5584c..705f8e4a5 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -7,7 +7,6 @@ #include "dolphincontextmenu.h" #include "dolphin_contextmenusettings.h" -#include "dolphin_generalsettings.h" #include "dolphinmainwindow.h" #include "dolphinnewfilemenu.h" #include "dolphinplacesmodelsingleton.h" @@ -16,7 +15,6 @@ #include "global.h" #include "trash/dolphintrash.h" #include "views/dolphinview.h" -#include "views/viewmodecontroller.h" #include #include diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 637cd55af..e3373efe2 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1144,7 +1144,8 @@ void DolphinMainWindow::openTerminalHere() { QList urls = {}; - for (const KFileItem &item : m_activeViewContainer->view()->selectedItems()) { + const auto selectedItems = m_activeViewContainer->view()->selectedItems(); + for (const KFileItem &item : selectedItems) { QUrl url = item.targetUrl(); if (item.isFile()) { url.setPath(QFileInfo(url.path()).absolutePath()); @@ -1174,7 +1175,7 @@ void DolphinMainWindow::openTerminalHere() } } - for (const QUrl &url : urls) { + for (const QUrl &url : std::as_const(urls)) { openTerminalJob(url); } } diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 94f83d0ef..af0acb171 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -29,7 +29,7 @@ class DolphinPart : public KParts::ReadOnlyPart // Used by konqueror. Technically it means "we want undo enabled if // there are things in the undo history and the current part is a dolphin part". // Even though it's konqueror doing the undo... - Q_PROPERTY(bool supportsUndo READ supportsUndo) + Q_PROPERTY(bool supportsUndo READ supportsUndo CONSTANT) Q_PROPERTY(QString currentViewMode READ currentViewMode WRITE setCurrentViewMode) diff --git a/src/dolphintabwidget.h b/src/dolphintabwidget.h index 75c6e3471..5bc708b38 100644 --- a/src/dolphintabwidget.h +++ b/src/dolphintabwidget.h @@ -123,7 +123,9 @@ public Q_SLOTS: * Opens a new tab in the background showing the URL \a primaryUrl and the * optional URL \a secondaryUrl. */ - void openNewTab(const QUrl &primaryUrl, const QUrl &secondaryUrl = QUrl(), NewTabPosition position = NewTabPosition::FollowSetting); + void openNewTab(const QUrl &primaryUrl, + const QUrl &secondaryUrl = QUrl(), + DolphinTabWidget::NewTabPosition position = DolphinTabWidget::NewTabPosition::FollowSetting); /** * Opens each directory in \p dirs in a separate tab unless it is already open. diff --git a/src/kitemviews/kitemlistcontroller.h b/src/kitemviews/kitemlistcontroller.h index 122ef836d..0576fc7fd 100644 --- a/src/kitemviews/kitemlistcontroller.h +++ b/src/kitemviews/kitemlistcontroller.h @@ -49,11 +49,8 @@ class QTouchEvent; class DOLPHIN_EXPORT KItemListController : public QObject { Q_OBJECT - Q_PROPERTY(KItemModelBase *model READ model WRITE setModel) - Q_PROPERTY(KItemListView *view READ view WRITE setView) - Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior) - Q_PROPERTY(AutoActivationBehavior autoActivationBehavior READ autoActivationBehavior WRITE setAutoActivationBehavior) - Q_PROPERTY(MouseDoubleClickAction mouseDoubleClickAction READ mouseDoubleClickAction WRITE setMouseDoubleClickAction) + Q_PROPERTY(KItemModelBase *model READ model WRITE setModel NOTIFY modelChanged) + Q_PROPERTY(KItemListView *view READ view WRITE setView NOTIFY viewChanged) public: enum SelectionBehavior { NoSelection, SingleSelection, MultiSelection }; diff --git a/src/kitemviews/kitemlistview.h b/src/kitemviews/kitemlistview.h index 6c3d3648d..ff51af922 100644 --- a/src/kitemviews/kitemlistview.h +++ b/src/kitemviews/kitemlistview.h @@ -53,8 +53,8 @@ class DOLPHIN_EXPORT KItemListView : public QGraphicsWidget { Q_OBJECT - Q_PROPERTY(qreal scrollOffset READ scrollOffset WRITE setScrollOffset) - Q_PROPERTY(qreal itemOffset READ itemOffset WRITE setItemOffset) + Q_PROPERTY(qreal scrollOffset READ scrollOffset WRITE setScrollOffset NOTIFY scrollOffsetChanged) + Q_PROPERTY(qreal itemOffset READ itemOffset WRITE setItemOffset NOTIFY itemOffsetChanged) public: explicit KItemListView(QGraphicsWidget *parent = nullptr); diff --git a/src/kitemviews/private/kitemlistheaderwidget.cpp b/src/kitemviews/private/kitemlistheaderwidget.cpp index 850f49406..82e5dde97 100644 --- a/src/kitemviews/private/kitemlistheaderwidget.cpp +++ b/src/kitemviews/private/kitemlistheaderwidget.cpp @@ -136,7 +136,7 @@ void KItemListHeaderWidget::setSidePadding(qreal width) { if (m_sidePadding != width) { m_sidePadding = width; - sidePaddingChanged(width); + Q_EMIT sidePaddingChanged(width); update(); } } diff --git a/src/kitemviews/private/kitemlistrubberband.h b/src/kitemviews/private/kitemlistrubberband.h index fd1416b56..64ce9ba29 100644 --- a/src/kitemviews/private/kitemlistrubberband.h +++ b/src/kitemviews/private/kitemlistrubberband.h @@ -18,7 +18,7 @@ class DOLPHIN_EXPORT KItemListRubberBand : public QObject { Q_OBJECT - Q_PROPERTY(QPointF endPosition MEMBER m_endPos READ endPosition WRITE setEndPosition) + Q_PROPERTY(QPointF endPosition MEMBER m_endPos READ endPosition WRITE setEndPosition NOTIFY endPositionChanged) public: explicit KItemListRubberBand(QObject *parent = nullptr); diff --git a/src/search/dolphinquery.cpp b/src/search/dolphinquery.cpp index f9e5da84f..ed2a6a766 100644 --- a/src/search/dolphinquery.cpp +++ b/src/search/dolphinquery.cpp @@ -49,7 +49,7 @@ QStringList splitOutsideQuotes(const QString &text) // - Groups with two leading quotes must close both on them (filename:""abc xyz" tuv") // - Groups enclosed in quotes // - Words separated by spaces - const QRegularExpression subTermsRegExp("(\\S*?\"\"[^\"]+\"[^\"]+\"+|\\S*?\"[^\"]+\"+|(?<=\\s|^)\\S+(?=\\s|$))"); + static const QRegularExpression subTermsRegExp("(\\S*?\"\"[^\"]+\"[^\"]+\"+|\\S*?\"[^\"]+\"+|(?<=\\s|^)\\S+(?=\\s|$))"); auto subTermsMatchIterator = subTermsRegExp.globalMatch(text); QStringList textParts; diff --git a/src/selectionmode/backgroundcolorhelper.cpp b/src/selectionmode/backgroundcolorhelper.cpp index 74f5bda1a..fa3e55ac4 100644 --- a/src/selectionmode/backgroundcolorhelper.cpp +++ b/src/selectionmode/backgroundcolorhelper.cpp @@ -46,7 +46,7 @@ void BackgroundColorHelper::controlBackgroundColor(QWidget *widget) BackgroundColorHelper::BackgroundColorHelper() { updateBackgroundColor(); - QObject::connect(qApp, &QGuiApplication::paletteChanged, [=]() { + QObject::connect(qApp, &QGuiApplication::paletteChanged, qApp, [=]() { slotPaletteChanged(); }); } diff --git a/src/selectionmode/bottombarcontentscontainer.cpp b/src/selectionmode/bottombarcontentscontainer.cpp index d53d2e4b9..d571b0302 100644 --- a/src/selectionmode/bottombarcontentscontainer.cpp +++ b/src/selectionmode/bottombarcontentscontainer.cpp @@ -166,7 +166,7 @@ void BottomBarContentsContainer::addCopyContents() auto *copyButton = new QPushButton(this); // We claim to have PasteContents already so triggering the copy action next won't instantly hide the bottom bar. - connect(copyButton, &QAbstractButton::clicked, [this]() { + connect(copyButton, &QAbstractButton::clicked, this, [this]() { if (GeneralSettings::showPasteBarAfterCopying()) { m_contents = BottomBar::Contents::PasteContents; // prevents hiding } @@ -174,7 +174,7 @@ void BottomBarContentsContainer::addCopyContents() // Connect the copy action as a second step. m_mainAction = ActionWithWidget(m_actionCollection->action(KStandardAction::name(KStandardAction::Copy)), copyButton); // Finally connect the lambda that actually changes the contents to the PasteContents. - connect(copyButton, &QAbstractButton::clicked, [this]() { + connect(copyButton, &QAbstractButton::clicked, this, [this]() { if (GeneralSettings::showPasteBarAfterCopying()) { resetContents(BottomBar::Contents::PasteContents); // resetContents() needs to be connected last because // it instantly deletes the button and then the other slots won't be called. @@ -244,7 +244,7 @@ void BottomBarContentsContainer::addCutContents() auto *cutButton = new QPushButton(this); // We claim to have PasteContents already so triggering the cut action next won't instantly hide the bottom bar. - connect(cutButton, &QAbstractButton::clicked, [this]() { + connect(cutButton, &QAbstractButton::clicked, this, [this]() { if (GeneralSettings::showPasteBarAfterCopying()) { m_contents = BottomBar::Contents::PasteContents; // prevents hiding } @@ -252,7 +252,7 @@ void BottomBarContentsContainer::addCutContents() // Connect the cut action as a second step. m_mainAction = ActionWithWidget(m_actionCollection->action(KStandardAction::name(KStandardAction::Cut)), cutButton); // Finally connect the lambda that actually changes the contents to the PasteContents. - connect(cutButton, &QAbstractButton::clicked, [this]() { + connect(cutButton, &QAbstractButton::clicked, this, [this]() { if (GeneralSettings::showPasteBarAfterCopying()) { resetContents(BottomBar::Contents::PasteContents); // resetContents() needs to be connected last because // it instantly deletes the button and then the other slots won't be called. diff --git a/src/settings/contextmenu/contextmenusettingspage.cpp b/src/settings/contextmenu/contextmenusettingspage.cpp index fa3d0b256..ea780550a 100644 --- a/src/settings/contextmenu/contextmenusettingspage.cpp +++ b/src/settings/contextmenu/contextmenusettingspage.cpp @@ -7,7 +7,6 @@ #include "contextmenusettingspage.h" #include "dolphin_contextmenusettings.h" -#include "dolphin_generalsettings.h" #include "dolphin_versioncontrolsettings.h" #include "global.h" #include "settings/serviceitemdelegate.h" diff --git a/src/settings/viewmodes/viewsettingstab.h b/src/settings/viewmodes/viewsettingstab.h index fd4cc85a7..5181e8018 100644 --- a/src/settings/viewmodes/viewsettingstab.h +++ b/src/settings/viewmodes/viewsettingstab.h @@ -32,9 +32,6 @@ public: void applySettings() override; void restoreDefaults() override; -Q_SIGNALS: - void changed(); - private Q_SLOTS: void slotDefaultSliderMoved(int value); diff --git a/src/views/dolphinitemlistview.cpp b/src/views/dolphinitemlistview.cpp index 0efea844c..418c9bfe8 100644 --- a/src/views/dolphinitemlistview.cpp +++ b/src/views/dolphinitemlistview.cpp @@ -22,7 +22,7 @@ DolphinItemListView::DolphinItemListView(QGraphicsWidget *parent) : KFileItemListView(parent) , m_zoomLevel(0) { - updateFont(); + DolphinItemListView::updateFont(); updateGridSize(); } diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index d0d524196..a91d76358 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -1419,6 +1419,14 @@ void DolphinView::slotItemCreated(const QUrl &url) } } +void DolphinView::onDirectoryLoadingCompleted() +{ + // the model should now contain all the items created by the job + updateSelectionState(); + m_selectJobCreatedItems = false; + m_selectedUrls.clear(); +} + void DolphinView::slotJobResult(KJob *job) { if (job->error() && job->error() != KIO::ERR_USER_CANCELED) { @@ -1434,21 +1442,7 @@ void DolphinView::slotJobResult(KJob *job) updateSelectionState(); if (!m_selectedUrls.isEmpty()) { // not all urls were found, the model may not be up to date - // TODO KF6 replace with Qt::singleShotConnection - QMetaObject::Connection *const connection = new QMetaObject::Connection; - *connection = connect( - m_model, - &KFileItemModel::directoryLoadingCompleted, - this, - [this, connection]() { - // the model should now contain all the items created by the job - updateSelectionState(); - m_selectJobCreatedItems = false; - m_selectedUrls.clear(); - QObject::disconnect(*connection); - delete connection; - }, - Qt::UniqueConnection); + connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::onDirectoryLoadingCompleted, Qt::UniqueConnection); } else { m_selectJobCreatedItems = false; m_selectedUrls.clear(); diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h index f851724c2..05b9e009c 100644 --- a/src/views/dolphinview.h +++ b/src/views/dolphinview.h @@ -824,6 +824,8 @@ private Q_SLOTS: void slotTwoClicksRenamingTimerTimeout(); + void onDirectoryLoadingCompleted(); + private: void loadDirectory(const QUrl &url, bool reload = false); -- cgit v1.3 From 0e4d428e84099bf5d76e81640a2417d5457d83a4 Mon Sep 17 00:00:00 2001 From: Amol Godbole Date: Sun, 3 Sep 2023 12:33:21 -0500 Subject: DolphinView: Reset scrollbars before changing view mode When view modes are changed, the scrollbars are not reset. This can cause the scroll area to be moved out of view after changing the view mode, making the view unusable. This commit resets the scrollbars. BUG: 393152 --- src/views/dolphinview.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/views/dolphinview.cpp') diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index a91d76358..d0db814e4 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -279,6 +279,10 @@ bool DolphinView::isActive() const void DolphinView::setViewMode(Mode mode) { if (mode != m_mode) { + // Reset scrollbars before changing the view mode. + m_container->horizontalScrollBar()->setValue(0); + m_container->verticalScrollBar()->setValue(0); + ViewProperties props(viewPropertiesUrl()); props.setViewMode(mode); -- cgit v1.3 From 5c33e0211ff09f37adb5b48c59cf15b67c0059dc Mon Sep 17 00:00:00 2001 From: Méven Car Date: Sun, 10 Sep 2023 14:58:36 +0200 Subject: Copy Location: Make sure to export path with native separators --- src/views/dolphinview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/views/dolphinview.cpp') diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index d0db814e4..21e23d5ac 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -2283,7 +2283,7 @@ void DolphinView::copyPathToClipboard() if (clipboard == nullptr) { return; } - clipboard->setText(path); + clipboard->setText(QDir::toNativeSeparators(path)); } void DolphinView::slotIncreaseZoom() -- cgit v1.3