summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.cpp8
-rw-r--r--config.h1
-rw-r--r--config.ui7
-rwxr-xr-xinstall.sh4
-rw-r--r--pass.cpp39
-rw-r--r--pass.h5
-rwxr-xr-xuninstall.sh1
7 files changed, 23 insertions, 42 deletions
diff --git a/config.cpp b/config.cpp
index 73f0bc3..6eff86f 100644
--- a/config.cpp
+++ b/config.cpp
@@ -141,7 +141,6 @@ PassConfig::PassConfig(QWidget *parent, const QVariantList &args)
#endif
connect(this->ui, &PassConfigForm::passActionAdded, this, changedSlotPointer);
connect(this->ui, &PassConfigForm::passActionRemoved, this, changedSlotPointer);
- connect(this->ui->checkShowOnlyPrefixed, &QCheckBox::stateChanged, this, changedSlotPointer);
connect(this->ui->checkAdditionalActions, &QCheckBox::stateChanged, this, changedSlotPointer);
connect(this->ui->checkShowFileContentAction, &QCheckBox::stateChanged, this, changedSlotPointer);
connect(this->ui->listSavedActions, &QListWidget::itemSelectionChanged, this, changedSlotPointer);
@@ -154,11 +153,9 @@ void PassConfig::load()
KSharedConfig::Ptr cfg = KSharedConfig::openConfig(QStringLiteral("krunnerrc"));
KConfigGroup passCfg = cfg->group("Runners").group("Pass");
- bool showOnlyPrefixed = passCfg.readEntry(Config::showOnlyPrefixed, false);
bool showActions = passCfg.readEntry(Config::showActions, false);
bool showFileContentAction = passCfg.readEntry(Config::showFileContentAction, false);
- this->ui->checkShowOnlyPrefixed->setChecked(showOnlyPrefixed);
this->ui->checkAdditionalActions->setChecked(showActions);
this->ui->checkShowFileContentAction->setChecked(showFileContentAction);
@@ -180,11 +177,9 @@ void PassConfig::save()
KSharedConfig::Ptr cfg = KSharedConfig::openConfig(QStringLiteral("krunnerrc"));
KConfigGroup passCfg = cfg->group("Runners").group("Pass");
- auto showOnlyPrefixed = this->ui->checkShowOnlyPrefixed->isChecked();
auto showActions = this->ui->checkAdditionalActions->isChecked();
auto showFileContentAction = this->ui->checkShowFileContentAction->isChecked();
- passCfg.writeEntry(Config::showOnlyPrefixed, showOnlyPrefixed);
passCfg.writeEntry(Config::showActions, showActions);
passCfg.writeEntry(Config::showFileContentAction, showFileContentAction);
@@ -203,14 +198,13 @@ void PassConfig::defaults()
{
KCModule::defaults();
- ui->checkShowOnlyPrefixed->setChecked(false);
ui->checkAdditionalActions->setChecked(false);
ui->checkShowFileContentAction->setChecked(false);
ui->clearPassActions();
ui->clearInputs();
#if KCMUTILS_VERSION >= QT_VERSION_CHECK(5, 64, 0)
- emit markAsChanged();
+ markAsChanged();
#else
emit changed(true);
#endif
diff --git a/config.h b/config.h
index 4a3c267..474c7cd 100644
--- a/config.h
+++ b/config.h
@@ -25,7 +25,6 @@
struct Config {
- constexpr static const char *showOnlyPrefixed = "showOnlyPrefixed";
constexpr static const char *showActions = "showAdditionalActions";
constexpr static const char *showFileContentAction = "showFullFileContentAction";
struct Group {
diff --git a/config.ui b/config.ui
index 761d5dc..8a06b41 100644
--- a/config.ui
+++ b/config.ui
@@ -108,13 +108,6 @@
</property>
</widget>
</item>
- <item row="0" column="0">
- <widget class="QCheckBox" name="checkShowOnlyPrefixed">
- <property name="text">
- <string>Show only options when query starts with &quot;pass&quot;</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
<resources/>
diff --git a/install.sh b/install.sh
index 6d24456..73144ae 100755
--- a/install.sh
+++ b/install.sh
@@ -11,5 +11,5 @@ sudo make install
set +e
-kquitapp5 krunner 2> /dev/null
-kstart5 --windowclass krunner krunner > /dev/null 2>&1 &
+kquitapp5 krunner
+kstart5 --windowclass krunner krunner
diff --git a/pass.cpp b/pass.cpp
index 422416e..a4cf786 100644
--- a/pass.cpp
+++ b/pass.cpp
@@ -40,33 +40,29 @@ using namespace std;
Pass::Pass(QObject *parent, const QVariantList &args)
: Plasma::AbstractRunner(parent, args)
{
- Q_UNUSED(args);
-
// General runner configuration
- setObjectName(QString("Pass"));
+ setObjectName(QStringLiteral("Pass"));
setSpeed(AbstractRunner::NormalSpeed);
setPriority(HighestPriority);
- auto comment = i18n("Looks for a password matching :q:. Pressing ENTER copies the password to the clipboard.");
- setDefaultSyntax(Plasma::RunnerSyntax(QString(":q:"), comment));
}
Pass::~Pass() = default;
void Pass::reloadConfiguration()
{
- actions().clear();
+ clearActions();
orderedActions.clear();
KConfigGroup cfg = config();
+ cfg.config()->reparseConfiguration(); // Just to be sure
this->showActions = cfg.readEntry(Config::showActions, false);
- this->showOnlyPrefixed = cfg.readEntry(Config::showOnlyPrefixed, false);
-
if (showActions) {
const auto configActions = cfg.group(Config::Group::Actions);
// Create actions for every additional field
- for (const auto &name: configActions.groupList()) {
+ const auto configActionsList = configActions.groupList();
+ for (const auto &name: configActionsList) {
auto group = configActions.group(name);
auto passAction = PassAction::fromConfig(group);
@@ -86,6 +82,12 @@ void Pass::reloadConfiguration()
act->setData(Config::showFileContentAction);
this->orderedActions << act;
}
+
+ setDefaultSyntax(Plasma::RunnerSyntax(QString(":q:"),
+ i18n("Looks for a password matching :q:. Pressing ENTER copies the password to the clipboard.")));
+
+ addSyntax(Plasma::RunnerSyntax(QString("pass :q:"),
+ i18n("Looks for a password matching :q:. This way you avoid results from other runners")));
}
void Pass::init()
@@ -142,7 +144,7 @@ void Pass::initPasswords()
void Pass::reinitPasswords(const QString &path)
{
- Q_UNUSED(path);
+ Q_UNUSED(path)
lock.lockForWrite();
initPasswords();
@@ -156,12 +158,11 @@ void Pass::match(Plasma::RunnerContext &context)
}
auto input = context.query();
- if (showOnlyPrefixed) {
- if (input.startsWith(queryPrefix)) {
- input = input.remove(queryPrefix).simplified();
- } else {
- return;
- }
+ // If we use the prefix we want to remove it
+ if (input.startsWith(queryPrefix)) {
+ input = input.remove(queryPrefix).simplified();
+ } else if (input.count() < 3 && !context.singleRunnerQueryMode()) {
+ return;
}
QList<Plasma::QueryMatch> matches;
@@ -207,16 +208,12 @@ void Pass::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &m
connect(pass, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
[=](int exitCode, QProcess::ExitStatus exitStatus) {
- Q_UNUSED(exitCode);
- Q_UNUSED(exitStatus);
+ Q_UNUSED(exitStatus)
if (exitCode == 0) {
-
const auto output = pass->readAllStandardOutput();
-
if (match.selectedAction() != nullptr) {
const auto data = match.selectedAction()->data().toString();
-
if (data == Config::showFileContentAction) {
QMessageBox::information(nullptr, match.text(), output);
} else {
diff --git a/pass.h b/pass.h
index 38aa2ea..a12c737 100644
--- a/pass.h
+++ b/pass.h
@@ -39,7 +39,7 @@ public:
void reloadConfiguration() override;
-public slots:
+public Q_SLOTS:
void reinitPasswords(const QString &path);
protected:
@@ -58,8 +58,7 @@ private:
bool showActions;
QList<QAction *> orderedActions;
- bool showOnlyPrefixed;
- QLatin1String queryPrefix = QLatin1String("pass");
+ const QLatin1String queryPrefix = QLatin1String("pass");
};
#endif
diff --git a/uninstall.sh b/uninstall.sh
index 7e9fbfc..e3efe5b 100755
--- a/uninstall.sh
+++ b/uninstall.sh
@@ -7,4 +7,3 @@ cd build
sudo make uninstall
kquitapp5 krunner
kstart5 --windowclass krunner krunner
-