diff options
Diffstat (limited to 'src/settings/services')
4 files changed, 40 insertions, 5 deletions
diff --git a/src/settings/services/servicemenuinstaller/CMakeLists.txt b/src/settings/services/servicemenuinstaller/CMakeLists.txt index 988899936..deb08421b 100644 --- a/src/settings/services/servicemenuinstaller/CMakeLists.txt +++ b/src/settings/services/servicemenuinstaller/CMakeLists.txt @@ -6,5 +6,6 @@ target_link_libraries(servicemenuinstaller PRIVATE Qt5::Core Qt5::Gui KF5::I18n + KF5::CoreAddons ) install(TARGETS servicemenuinstaller ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp b/src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp index 06f34c6b9..60621921a 100644 --- a/src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp +++ b/src/settings/services/servicemenuinstaller/servicemenuinstaller.cpp @@ -30,6 +30,7 @@ #include <QGuiApplication> #include <KLocalizedString> +#include <KShell> // @param msg Error that gets logged to CLI Q_NORETURN void fail(const QString &str) @@ -59,6 +60,11 @@ struct UncompressCommand QStringList args2; }; +enum ScriptExecution{ + Process, + Konsole +}; + void runUncompress(const QString &inputPath, const QString &outputPath) { QVector<QPair<QStringList, UncompressCommand>> mimeTypeToCommand; @@ -126,12 +132,24 @@ QString findRecursive(const QString &dir, const QString &basename) return QString(); } -bool runScriptOnce(const QString &path, const QStringList &args) +bool runScriptOnce(const QString &path, const QStringList &args, ScriptExecution execution) { QProcess process; process.setWorkingDirectory(QFileInfo(path).absolutePath()); - process.start(path, args, QIODevice::NotOpen); + const static bool konsoleAvailable = !QStandardPaths::findExecutable("konsole").isEmpty(); + if (konsoleAvailable && execution == ScriptExecution::Konsole) { + QString bashCommand = KShell::quoteArg(path) + ' '; + if (!args.isEmpty()) { + bashCommand.append(args.join(' ')); + } + bashCommand.append("|| $SHELL"); + // If the install script fails a shell opens and the user can fix the problem + // without an error konsole closes + process.start("konsole", QStringList() << "-e" << "bash" << "-c" << bashCommand, QIODevice::NotOpen); + } else { + process.start(path, args, QIODevice::NotOpen); + } if (!process.waitForStarted()) { fail(i18n("Failed to run installer script %1", path)); } @@ -163,11 +181,11 @@ bool runScriptVariants(const QString &path, bool hasArgVariants, const QStringLi qInfo() << "[servicemenuinstaller]: Trying to run installer/uninstaller" << path; if (hasArgVariants) { for (const auto &arg : argVariants) { - if (runScriptOnce(path, {arg})) { + if (runScriptOnce(path, {arg}, ScriptExecution::Process)) { return true; } } - } else if (runScriptOnce(path, {})) { + } else if (runScriptOnce(path, {}, ScriptExecution::Konsole)) { return true; } @@ -247,7 +265,11 @@ bool cmdInstall(const QString &archive, QString &errorText) } if (!installerPath.isEmpty()) { - return runScriptVariants(installerPath, true, {"--local", "--local-install", "--install"}, errorText); + // Try to run script without variants first + if (!runScriptVariants(installerPath, false, {}, errorText)) { + return runScriptVariants(installerPath, true, {"--local", "--local-install", "--install"}, errorText); + } + return true; } fail(i18n("Failed to find an installation script in %1", dir)); diff --git a/src/settings/services/servicessettingspage.cpp b/src/settings/services/servicessettingspage.cpp index fe900bc5c..ba6c48f80 100644 --- a/src/settings/services/servicessettingspage.cpp +++ b/src/settings/services/servicessettingspage.cpp @@ -38,6 +38,7 @@ #include <QListWidget> #include <QShowEvent> #include <QSortFilterProxyModel> +#include <QLineEdit> namespace { @@ -61,6 +62,11 @@ ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) : "Select which services should " "be shown in the context menu:"), this); label->setWordWrap(true); + m_searchLineEdit = new QLineEdit(this); + m_searchLineEdit->setPlaceholderText(i18nc("@label:textbox", "Search...")); + connect(m_searchLineEdit, &QLineEdit::textChanged, this, [=](const QString &filter){ + m_sortModel->setFilterFixedString(filter); + }); m_listView = new QListView(this); ServiceItemDelegate* delegate = new ServiceItemDelegate(m_listView, m_listView); @@ -69,6 +75,8 @@ ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) : m_sortModel->setSourceModel(m_serviceModel); m_sortModel->setSortRole(Qt::DisplayRole); m_sortModel->setSortLocaleAware(true); + m_sortModel->setFilterRole(Qt::DisplayRole); + m_sortModel->setFilterCaseSensitivity(Qt::CaseInsensitive); m_listView->setModel(m_sortModel); m_listView->setItemDelegate(delegate); m_listView->setVerticalScrollMode(QListView::ScrollPerPixel); @@ -80,6 +88,7 @@ ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) : connect(downloadButton, &KNS3::Button::dialogFinished, this, &ServicesSettingsPage::loadServices); topLayout->addWidget(label); + topLayout->addWidget(m_searchLineEdit); topLayout->addWidget(m_listView); topLayout->addWidget(downloadButton); @@ -236,6 +245,7 @@ void ServicesSettingsPage::loadServices() } m_sortModel->sort(Qt::DisplayRole); + m_searchLineEdit->setFocus(Qt::OtherFocusReason); } void ServicesSettingsPage::loadVersionControlSystems() diff --git a/src/settings/services/servicessettingspage.h b/src/settings/services/servicessettingspage.h index cd4cbe52f..dd53cf5dd 100644 --- a/src/settings/services/servicessettingspage.h +++ b/src/settings/services/servicessettingspage.h @@ -26,6 +26,7 @@ class QListView; class QSortFilterProxyModel; class ServiceModel; +class QLineEdit; /** * @brief Page for the 'Services' settings of the Dolphin settings dialog. @@ -74,6 +75,7 @@ private: ServiceModel* m_serviceModel; QSortFilterProxyModel* m_sortModel; QListView* m_listView; + QLineEdit *m_searchLineEdit; QStringList m_enabledVcsPlugins; }; |
