Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alex1701c committed Jul 15, 2019
1 parent cded251 commit 479f9db
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
6 changes: 1 addition & 5 deletions src/config/vscodeprojectsrunner_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <KPluginFactory>
#include <krunner/abstractrunner.h>
#include <QtCore/QDir>
#include <QDebug>
#include <QtWidgets/QFileDialog>

K_PLUGIN_FACTORY(VSCodeProjectsRunnerConfigFactory,
Expand All @@ -24,10 +23,7 @@ VSCodeProjectsRunnerConfig::VSCodeProjectsRunnerConfig(QWidget *parent, const QV
m_ui->showProjectsByApplication->setChecked(config.readEntry("appNameMatches", "true") == "true");
m_ui->showProjectsByName->setChecked(config.readEntry("projectNameMatches", "true") == "true");
m_ui->fileLabel->setText(
config.readEntry("path",
QDir::homePath() +
"/.config/Code/User/globalStorage/alefragnani.project-manager/projects.json"
)
config.readEntry("path", QDir::homePath() + "/.config/Code/User/globalStorage/alefragnani.project-manager/projects.json")
);

connect(m_ui->showProjectsByApplication, SIGNAL(clicked(bool)), this, SLOT(changed()));
Expand Down
2 changes: 1 addition & 1 deletion src/plasma-runner-vscodeprojectsrunner.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ X-KDE-PluginInfo-Author=%{AUTHOR}
X-KDE-PluginInfo-Email=%{EMAIL}
X-KDE-PluginInfo-Name=vscodeprojectsrunner
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-License=LGPL 2.1+
X-KDE-PluginInfo-License=LGPL 3
X-KDE-PluginInfo-EnabledByDefault=true
11 changes: 6 additions & 5 deletions src/vscodeprojectsrunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void VSCodeProjectsRunner::match(Plasma::RunnerContext &context) {
if (config.readEntry("projectNameMatches", "true") == "true") {
for (const auto &key:projects.keys()) {
if (key.startsWith(term, Qt::CaseInsensitive)) {
matches.append(addMatch("Open " + key, projects.value(key), (float) term.length() / key.length()));
matches.append(createMatch("Open " + key, projects.value(key), (float) term.length() / key.length()));
}
}
}
Expand All @@ -33,14 +33,14 @@ void VSCodeProjectsRunner::match(Plasma::RunnerContext &context) {
for (const auto &key:projects.keys()) {
if (key.startsWith(exp.capturedTexts().at(1), Qt::CaseInsensitive)) {
matches.append(
addMatch("Open " + key, projects.value(key), (float) term.length() / key.length() + 5)
createMatch("Open " + key, projects.value(key), (float) term.length() / key.length())
);
}
}
} else {
for (const auto &key:projects.keys()) {
matches.append(
addMatch("Open " + key, projects.value(key), (float) term.length() / key.length() + 5)
createMatch("Open " + key, projects.value(key), (float) term.length() / key.length())
);
}
}
Expand All @@ -58,7 +58,8 @@ void VSCodeProjectsRunner::init() {
void VSCodeProjectsRunner::reloadConfiguration() {
QString filePath = config.readEntry("path",
QDir::homePath() +
"/.config/Code/User/globalStorage/alefragnani.project-manager/projects.json");
"/.config/Code/User/globalStorage/alefragnani.project-manager/projects.json"
);
QFile file(filePath);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
QString content = file.readAll();
Expand All @@ -72,7 +73,7 @@ void VSCodeProjectsRunner::reloadConfiguration() {
}
}

Plasma::QueryMatch VSCodeProjectsRunner::addMatch(const QString &text, const QString &data, const float relevance) {
Plasma::QueryMatch VSCodeProjectsRunner::createMatch(const QString &text, const QString &data, float relevance) {
auto match = Plasma::QueryMatch(this);
match.setText(text);
match.setData(data);
Expand Down
7 changes: 4 additions & 3 deletions src/vscodeprojectsrunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ Q_OBJECT

~VSCodeProjectsRunner() override;

void reloadConfiguration() override;

KConfigGroup config;

QMap<QString, QString> projects;

Plasma::QueryMatch addMatch(const QString &text, const QString &data, float relevance);
Plasma::QueryMatch createMatch(const QString &text, const QString &data, float relevance);

protected Q_SLOTS:

Expand All @@ -28,6 +26,9 @@ protected Q_SLOTS:
void match(Plasma::RunnerContext &context) override;

void run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match) override;

void reloadConfiguration() override;

};

#endif

0 comments on commit 479f9db

Please sign in to comment.