Commit 026e84ec authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Copy result by default

This makes it consistent with what the other runners.
Also it is confusing to have two actions with the same icon.

A similar patch was done to the spellchecker some time ago.

Test Plan:
Running `1m` copies the number to the clipboard

Running `1m` by clicking the action or pressing Shift+Return
copies the number and the resulting unit to the clipboard
parent 4e0cdfe1
......@@ -42,9 +42,7 @@ void ConverterRunner::init()
insertCompatibleUnits();
addAction(copyActionId, QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy number"));
addAction(copyUnitActionId, QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy unit and number"));
actionList = {action(copyActionId), action(copyUnitActionId)};
actionList = {addAction(QStringLiteral("copy-unit"), QIcon::fromTheme(QStringLiteral("edit-copy")), i18n("Copy unit and number"))};
setMinLetterCount(2);
setMatchRegex(valueRegex);
}
......@@ -97,7 +95,7 @@ void ConverterRunner::match(Plasma::RunnerContext &context)
}
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::InformationalMatch);
match.setType(Plasma::QueryMatch::HelperMatch);
match.setIconName(QStringLiteral("accessories-calculator"));
if (outputUnit.categoryId() == KUnitConversion::CurrencyCategory) {
outputValue.round(2);
......@@ -118,10 +116,11 @@ void ConverterRunner::run(const Plasma::RunnerContext &context, const Plasma::Qu
{
Q_UNUSED(context)
if (match.selectedAction() == action(copyActionId)) {
QGuiApplication::clipboard()->setText(match.data().toString());
if (match.selectedAction()) {
const QString text = match.text();
QGuiApplication::clipboard()->setText(text.left(text.indexOf(QLatin1String(" ("))));
} else {
QGuiApplication::clipboard()->setText(match.text().split(QLatin1String(" (")).first());
QGuiApplication::clipboard()->setText(match.data().toString());
}
}
......
......@@ -40,8 +40,6 @@ private:
QMap<QString, QString> compatibleUnits;
QList<QAction *> actionList;
QLatin1String copyActionId = QLatin1String("copy");
QLatin1String copyUnitActionId = QLatin1String("copy-unit");
QPair<bool, double> stringToDouble(const QStringRef &value);
QPair<bool, double> getValidatedNumberValue(const QString &value);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment