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/settings/contextmenu/contextmenusettingspage.cpp | 9 --------- src/settings/dolphinsettingsdialog.cpp | 12 ------------ src/settings/viewpropertiesdialog.cpp | 8 -------- 3 files changed, 29 deletions(-) (limited to 'src/settings') 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; } -- cgit v1.3 From b45c57332f17fa82eb816179f20a84e392e51060 Mon Sep 17 00:00:00 2001 From: Méven Car Date: Mon, 28 Aug 2023 13:59:02 +0200 Subject: Confirmations setting: Add checkbox for ConfirmOpenManyFolders and ConfirmOpenManyTerminals We have to special handle the values saved as it is interpreted by KMessageBox --- src/settings/dolphin_generalsettings.kcfg | 10 ++++++++++ src/settings/interface/confirmationssettingspage.cpp | 18 +++++++++++++++++- src/settings/interface/confirmationssettingspage.h | 2 ++ 3 files changed, 29 insertions(+), 1 deletion(-) (limited to 'src/settings') diff --git a/src/settings/dolphin_generalsettings.kcfg b/src/settings/dolphin_generalsettings.kcfg index aedc24ea4..9bb202b71 100644 --- a/src/settings/dolphin_generalsettings.kcfg +++ b/src/settings/dolphin_generalsettings.kcfg @@ -142,4 +142,14 @@ + + + + false + + + + false + + diff --git a/src/settings/interface/confirmationssettingspage.cpp b/src/settings/interface/confirmationssettingspage.cpp index 61c3a14b6..491f8261f 100644 --- a/src/settings/interface/confirmationssettingspage.cpp +++ b/src/settings/interface/confirmationssettingspage.cpp @@ -60,9 +60,12 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget *parent) new QCheckBox(i18nc("@option:check Ask for confirmation when", "Closing windows with a program running in the Terminal panel"), this); #endif + m_confirmOpenManyFolders = new QCheckBox(i18nc("@option:check Ask for confirmation in Dolphin when", "Opening many folders at once"), this); + m_confirmOpenManyTerminals = new QCheckBox(i18nc("@option:check Ask for confirmation in Dolphin when", "Opening many terminals at once"), this); + QHBoxLayout *executableScriptLayout = new QHBoxLayout(); QLabel *executableScriptLabel = new QLabel(i18nc("@title:group", "When opening an executable file:"), this); - confirmLabelKde->setWordWrap(true); + executableScriptLabel->setWordWrap(true); executableScriptLayout->addWidget(executableScriptLabel); m_confirmScriptExecution = new QComboBox(this); @@ -81,6 +84,9 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget *parent) topLayout->addWidget(m_confirmClosingTerminalRunningProgram); #endif + topLayout->addWidget(m_confirmOpenManyFolders); + topLayout->addWidget(m_confirmOpenManyTerminals); + topLayout->addSpacing(Dolphin::VERTICAL_SPACER_HEIGHT); topLayout->addLayout(executableScriptLayout); @@ -93,6 +99,8 @@ ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget *parent) connect(m_confirmDelete, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); connect(m_confirmScriptExecution, QOverload::of(&QComboBox::currentIndexChanged), this, &ConfirmationsSettingsPage::changed); connect(m_confirmClosingMultipleTabs, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); + connect(m_confirmOpenManyFolders, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); + connect(m_confirmOpenManyTerminals, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); #if HAVE_TERMINAL connect(m_confirmClosingTerminalRunningProgram, &QCheckBox::toggled, this, &ConfirmationsSettingsPage::changed); @@ -128,6 +136,8 @@ void ConfirmationsSettingsPage::applySettings() GeneralSettings *settings = GeneralSettings::self(); settings->setConfirmClosingMultipleTabs(m_confirmClosingMultipleTabs->isChecked()); + settings->setConfirmOpenManyFolders(!m_confirmOpenManyFolders->isChecked()); + settings->setConfirmOpenManyTerminals(!m_confirmOpenManyTerminals->isChecked()); #if HAVE_TERMINAL settings->setConfirmClosingTerminalRunningProgram(m_confirmClosingTerminalRunningProgram->isChecked()); @@ -169,6 +179,12 @@ void ConfirmationsSettingsPage::loadSettings() m_confirmClosingMultipleTabs->setChecked(GeneralSettings::confirmClosingMultipleTabs()); + // 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()); + #if HAVE_TERMINAL m_confirmClosingTerminalRunningProgram->setChecked(GeneralSettings::confirmClosingTerminalRunningProgram()); #endif diff --git a/src/settings/interface/confirmationssettingspage.h b/src/settings/interface/confirmationssettingspage.h index 56dd1a78c..d9413d754 100644 --- a/src/settings/interface/confirmationssettingspage.h +++ b/src/settings/interface/confirmationssettingspage.h @@ -43,6 +43,8 @@ private: QCheckBox *m_confirmClosingMultipleTabs; QComboBox *m_confirmScriptExecution; + QCheckBox *m_confirmOpenManyFolders; + QCheckBox *m_confirmOpenManyTerminals; }; #endif -- 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/settings') 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/settings') 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 a85863befd616fe86669ac363d74fa7f466ca523 Mon Sep 17 00:00:00 2001 From: Eric Armbruster Date: Wed, 6 Sep 2023 06:34:13 +0200 Subject: Add open in split view action This action is shown only if a single folder is selected. The action opens the selected folder in the inactive split view (and opens the split view if necessary). FEATURE: 465500 --- src/dolphincontextmenu.cpp | 4 +++ src/dolphinmainwindow.cpp | 35 +++++++++++++++++++++- src/dolphinmainwindow.h | 5 ++++ src/dolphintabpage.h | 4 +-- src/panels/places/placespanel.cpp | 10 +++++++ src/panels/places/placespanel.h | 2 ++ .../contextmenu/contextmenusettingspage.cpp | 4 +++ src/settings/dolphin_contextmenusettings.kcfg | 4 +++ src/settings/dolphinsettingsdialog.cpp | 1 + 9 files changed, 66 insertions(+), 3 deletions(-) (limited to 'src/settings') diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 83329dd71..4dc54946f 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -165,6 +165,10 @@ void DolphinContextMenu::addDirectoryItemContextMenu() addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_window"))); } + if (ContextMenuSettings::showOpenInSplitView()) { + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_split_view"))); + } + // Insert 'Open With' entries addOpenWithActions(); diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index e3373efe2..744ad8f0a 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -497,6 +497,32 @@ void DolphinMainWindow::openInNewWindow() } } +void DolphinMainWindow::openInSplitView(const QUrl &url) +{ + QUrl newSplitViewUrl = url; + + if (newSplitViewUrl.isEmpty()) { + const KFileItemList list = m_activeViewContainer->view()->selectedItems(); + if (list.count() == 1) { + const KFileItem &item = list.first(); + newSplitViewUrl = DolphinView::openItemAsFolderUrl(item); + } + } + + if (newSplitViewUrl.isEmpty()) { + return; + } + + DolphinTabPage *tabPage = m_tabWidget->currentTabPage(); + if (tabPage->splitViewEnabled()) { + tabPage->switchActiveView(); + tabPage->activeViewContainer()->setUrl(newSplitViewUrl); + } else { + tabPage->setSplitViewEnabled(true, WithAnimation, newSplitViewUrl); + updateViewActions(); + } +} + void DolphinMainWindow::showTarget() { const KFileItem link = m_activeViewContainer->view()->selectedItems().at(0); @@ -885,7 +911,6 @@ void DolphinMainWindow::toggleSplitView() { DolphinTabPage *tabPage = m_tabWidget->currentTabPage(); tabPage->setSplitViewEnabled(!tabPage->splitViewEnabled(), WithAnimation); - updateViewActions(); } @@ -1985,6 +2010,13 @@ void DolphinMainWindow::setupActions() openInNewWindow->setText(i18nc("@action:inmenu", "Open in New Window")); openInNewWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new"))); connect(openInNewWindow, &QAction::triggered, this, &DolphinMainWindow::openInNewWindow); + + QAction *openInSplitViewAction = actionCollection()->addAction(QStringLiteral("open_in_split_view")); + openInSplitViewAction->setText(i18nc("@action:inmenu", "Open in Split View")); + openInSplitViewAction->setIcon(QIcon::fromTheme(QStringLiteral("view-right-new"))); + connect(openInSplitViewAction, &QAction::triggered, this, [this]() { + openInSplitView(QUrl()); + }); } void DolphinMainWindow::setupDockWidgets() @@ -2160,6 +2192,7 @@ void DolphinMainWindow::setupDockWidgets() connect(m_placesPanel, &PlacesPanel::newWindowRequested, this, [this](const QUrl &url) { Dolphin::openNewWindow({url}, this); }); + connect(m_placesPanel, &PlacesPanel::openInSplitViewRequested, this, &DolphinMainWindow::openInSplitView); connect(m_placesPanel, &PlacesPanel::errorMessage, this, &DolphinMainWindow::showErrorMessage); connect(this, &DolphinMainWindow::urlChanged, m_placesPanel, &PlacesPanel::setUrl); connect(placesDock, &DolphinDockWidget::visibilityChanged, &DolphinUrlNavigatorsController::slotPlacesPanelVisibilityChanged); diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 5bb17e79a..b45c846b8 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -476,6 +476,11 @@ private Q_SLOTS: */ void openInNewWindow(); + /** + * Opens the selected folder in the other inactive split view, enables split view if necessary. + */ + void openInSplitView(const QUrl &url); + /** * Show the target of the selected symlink */ diff --git a/src/dolphintabpage.h b/src/dolphintabpage.h index 0c691830e..4a8bd365a 100644 --- a/src/dolphintabpage.h +++ b/src/dolphintabpage.h @@ -138,6 +138,8 @@ public: */ void setActive(bool active); + void switchActiveView(); + Q_SIGNALS: void activeViewChanged(DolphinViewContainer *viewContainer); void activeViewUrlChanged(const QUrl &url); @@ -170,8 +172,6 @@ private Q_SLOTS: */ void slotViewUrlRedirection(const QUrl &oldUrl, const QUrl &newUrl); - void switchActiveView(); - private: /** * Creates a new view container and does the default initialization. diff --git a/src/panels/places/placespanel.cpp b/src/panels/places/placespanel.cpp index 3c3f7bb87..e3d133ff0 100644 --- a/src/panels/places/placespanel.cpp +++ b/src/panels/places/placespanel.cpp @@ -47,6 +47,15 @@ PlacesPanel::PlacesPanel(QWidget *parent) connect(m_configureTrashAction, &QAction::triggered, this, &PlacesPanel::slotConfigureTrash); addAction(m_configureTrashAction); + m_openInSplitView = new QAction(QIcon::fromTheme(QStringLiteral("view-right-new")), i18nc("@action:inmenu", "Open in Split View")); + m_openInSplitView->setPriority(QAction::HighPriority); + connect(m_openInSplitView, &QAction::triggered, this, [this]() { + const QUrl url = currentIndex().data(KFilePlacesModel::UrlRole).toUrl(); + Q_EMIT openInSplitViewRequested(url); + }); + + addAction(m_openInSplitView); + connect(this, &PlacesPanel::contextMenuAboutToShow, this, &PlacesPanel::slotContextMenuAboutToShow); connect(this, &PlacesPanel::iconSizeChanged, this, [](const QSize &newSize) { @@ -188,6 +197,7 @@ void PlacesPanel::slotContextMenuAboutToShow(const QModelIndex &index, QMenu *me const Solid::Device device = placesModel->deviceForIndex(index); m_configureTrashAction->setVisible(url.scheme() == QLatin1String("trash")); + m_openInSplitView->setVisible(url.isValid()); // show customContextMenuActions only on the view's context menu if (!url.isValid() && !device.isValid()) { diff --git a/src/panels/places/placespanel.h b/src/panels/places/placespanel.h index 2eb309483..cbd5fc224 100644 --- a/src/panels/places/placespanel.h +++ b/src/panels/places/placespanel.h @@ -51,6 +51,7 @@ Q_SIGNALS: void storageTearDownRequested(const QString &mountPath); void storageTearDownExternallyRequested(const QString &mountPath); void storageTearDownSuccessful(); + void openInSplitViewRequested(const QUrl &url); protected: void showEvent(QShowEvent *event) override; @@ -75,6 +76,7 @@ private: QPersistentModelIndex m_indexToTearDown; QAction *m_configureTrashAction; + QAction *m_openInSplitView; QAction *m_lockPanelsAction; }; diff --git a/src/settings/contextmenu/contextmenusettingspage.cpp b/src/settings/contextmenu/contextmenusettingspage.cpp index ea780550a..23ddfba31 100644 --- a/src/settings/contextmenu/contextmenusettingspage.cpp +++ b/src/settings/contextmenu/contextmenusettingspage.cpp @@ -122,6 +122,8 @@ bool ContextMenuSettingsPage::entryVisible(const QString &id) return ContextMenuSettings::showOpenInNewTab(); } else if (id == "open_in_new_window") { return ContextMenuSettings::showOpenInNewWindow(); + } else if (id == "open_in_split_view") { + return ContextMenuSettings::showOpenInSplitView(); } else if (id == "copy_location") { return ContextMenuSettings::showCopyLocation(); } else if (id == "duplicate") { @@ -148,6 +150,8 @@ void ContextMenuSettingsPage::setEntryVisible(const QString &id, bool visible) ContextMenuSettings::setShowOpenInNewTab(visible); } else if (id == "open_in_new_window") { ContextMenuSettings::setShowOpenInNewWindow(visible); + } else if (id == "open_in_split_view") { + return ContextMenuSettings::setShowOpenInSplitView(visible); } else if (id == "copy_location") { ContextMenuSettings::setShowCopyLocation(visible); } else if (id == "duplicate") { diff --git a/src/settings/dolphin_contextmenusettings.kcfg b/src/settings/dolphin_contextmenusettings.kcfg index 63ca079af..6e45d9bcd 100644 --- a/src/settings/dolphin_contextmenusettings.kcfg +++ b/src/settings/dolphin_contextmenusettings.kcfg @@ -30,6 +30,10 @@ true + + + true + true diff --git a/src/settings/dolphinsettingsdialog.cpp b/src/settings/dolphinsettingsdialog.cpp index 3a2ad31e9..d05d5a814 100644 --- a/src/settings/dolphinsettingsdialog.cpp +++ b/src/settings/dolphinsettingsdialog.cpp @@ -68,6 +68,7 @@ DolphinSettingsDialog::DolphinSettingsDialog(const QUrl &url, QWidget *parent, K QStringLiteral("view_mode"), QStringLiteral("open_in_new_tab"), QStringLiteral("open_in_new_window"), + QStringLiteral("open_in_split_view"), QStringLiteral("copy_location"), QStringLiteral("duplicate"), QStringLiteral("open_terminal_here"), -- cgit v1.3