Commit 58e9e839 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

Port charrunner to Plasma5/Qt5

Summary:
As it has been part of Plasma4, is mentioned in documentation still
and also all the time covered by translation system, someone out there
might perhaps still be happy to use it once in a while also with Plasma5.
Port has been straightforward, so no regressions expected.

Test Plan:
Entering "#hexdigits" works as advertized.
Changing trigger word in config UI and using new instead works as well.

Reviewers: broulik, jriddell, davidedmundson

Reviewed By: davidedmundson

Subscribers: davidedmundson, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D10104
parent e3acebab
......@@ -6,7 +6,7 @@ add_subdirectory(katesessions)
# add_subdirectory(kopete)
# add_subdirectory(mediawiki)
add_subdirectory(spellchecker)
# add_subdirectory(characters)
add_subdirectory(characters)
add_subdirectory(dictionary)
#
# if(KDEPIMLIBS_FOUND)
......
# We add our source code here
add_definitions(-DTRANSLATION_DOMAIN="plasma_runner_CharacterRunner")
set(krunner_charrunner_SRCS charrunner.cpp)
set(kcm_krunner_charrunner_SRCS charrunner_config.cpp)
kde4_add_ui_files(kcm_krunner_charrunner_SRCS charrunner_config.ui)
kde4_add_plugin(kcm_krunner_charrunner ${kcm_krunner_charrunner_SRCS})
ki18n_wrap_ui(kcm_krunner_charrunner_SRCS charrunner_config.ui)
add_library(kcm_krunner_charrunner MODULE ${kcm_krunner_charrunner_SRCS})
target_link_libraries(kcm_krunner_charrunner
${KDE4_KDECORE_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KCMUTILS_LIBS}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
)
KF5::Runner
KF5::KCMUtils
KF5::I18n
)
# Now make sure all files get to the right place
kde4_add_plugin(krunner_charrunner ${krunner_charrunner_SRCS})
target_link_libraries(krunner_charrunner ${KDE4_PLASMA_LIBS} ${KDE4_KIO_LIBS})
add_library(krunner_charrunner MODULE ${krunner_charrunner_SRCS})
target_link_libraries(krunner_charrunner
KF5::Runner
KF5::I18n
)
add_dependencies(krunner_charrunner kcm_krunner_charrunner)
# Install the library and .desktop file
install(TARGETS krunner_charrunner kcm_krunner_charrunner DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES CharacterRunner.desktop CharRunner_config.desktop DESTINATION ${SERVICES_INSTALL_DIR})
install(TARGETS krunner_charrunner kcm_krunner_charrunner DESTINATION ${KDE_INSTALL_PLUGINDIR})
install(FILES CharacterRunner.desktop CharRunner_config.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})
......@@ -19,9 +19,16 @@
#include "charrunner.h"
#include <KIcon>
// KF
#include <KRunner/QueryMatch>
#include <KLocalizedString>
//Names of config-entries
static const char CONFIG_TRIGGERWORD[] = "triggerWord";
static const char CONFIG_ALIASES[] = "aliases";
static const char CONFIG_CODES[] = "codes";
#include <Plasma/QueryMatch>
CharacterRunner::CharacterRunner( QObject* parent, const QVariantList &args )
: Plasma::AbstractRunner(parent, args)
......@@ -52,7 +59,6 @@ void CharacterRunner::reloadConfiguration()
void CharacterRunner::match(Plasma::RunnerContext &context)
{
QString term = context.query();
QString specChar;
term = term.replace(QLatin1Char( ' ' ), QLatin1String( "" )); //remove blanks
if (term.length() < 2) //ignore too short queries
......@@ -78,17 +84,18 @@ void CharacterRunner::match(Plasma::RunnerContext &context)
}
//make special caracter out of the hex.-code
specChar=QString();
specChar.toUtf8();
specChar[0]=hex;
const QString specChar = QChar(hex);
//create match
Plasma::QueryMatch match(this);
match.setType(Plasma::QueryMatch::InformationalMatch);
match.setIcon(KIcon(QLatin1String( "accessories-character-map" )));
match.setIconName(QStringLiteral("accessories-character-map"));
match.setText(specChar);
match.setData(specChar);
match.setId(QString());
context.addMatch(term, match);
context.addMatch(match);
}
K_EXPORT_PLASMA_RUNNER(CharacterRunner, CharacterRunner)
#include "charrunner.moc"
......@@ -20,8 +20,7 @@
#ifndef CHARRUNNER_H
#define CHARRUNNER_H
#include <Plasma/AbstractRunner>
#include "charrunner_config.h"
#include <KRunner/AbstractRunner>
class CharacterRunner : public Plasma::AbstractRunner
{
......@@ -29,9 +28,10 @@ class CharacterRunner : public Plasma::AbstractRunner
public:
CharacterRunner(QObject* parent, const QVariantList &args);
~CharacterRunner();
void match(Plasma::RunnerContext &context);
void reloadConfiguration();
~CharacterRunner() override;
void match(Plasma::RunnerContext &context) override;
void reloadConfiguration() override;
private:
//config-variables
......@@ -40,6 +40,4 @@ class CharacterRunner : public Plasma::AbstractRunner
QList<QString> m_codes;
};
K_EXPORT_PLASMA_RUNNER(CharacterRunner, CharacterRunner)
#endif
......@@ -17,20 +17,24 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
//Project-Includes
#include "charrunner_config.h"
//KDE-Includes
#include <plasma/abstractrunner.h>
K_EXPORT_RUNNER_CONFIG(CharacterRunner, CharacterRunnerConfig)
// KF
#include <KRunner/AbstractRunner>
#include <KSharedConfig>
//Names of config-entries
static const char CONFIG_TRIGGERWORD[] = "triggerWord";
static const char CONFIG_ALIASES[] = "aliases";
static const char CONFIG_CODES[] = "codes";
CharacterRunnerConfigForm::CharacterRunnerConfigForm(QWidget* parent) : QWidget(parent)
{
setupUi(this);
}
CharacterRunnerConfig::CharacterRunnerConfig(QWidget* parent, const QVariantList& args) :
KCModule(ConfigFactory::componentData(), parent, args)
CharacterRunnerConfig::CharacterRunnerConfig(QWidget* parent, const QVariantList& args)
: KCModule(parent, args)
{
m_ui = new CharacterRunnerConfigForm(this);
......@@ -119,3 +123,8 @@ void CharacterRunnerConfig::defaults()
emit changed(true);
}
K_PLUGIN_FACTORY(CharacterRunnerConfigFactory,
registerPlugin<CharacterRunnerConfig>(QStringLiteral("kcm_krunner_charrunner"));)
#include "charrunner_config.moc"
......@@ -22,13 +22,9 @@
//Project-Includes
#include "ui_charrunner_config.h"
//KDE-Includes
// KF
#include <KCModule>
//Names of config-entries
static const char CONFIG_TRIGGERWORD[] = "triggerWord";
static const char CONFIG_ALIASES[] = "aliases";
static const char CONFIG_CODES[] = "codes";
class CharacterRunnerConfigForm : public QWidget, public Ui::CharacterRunnerConfigUi
{
......@@ -43,12 +39,14 @@ class CharacterRunnerConfig : public KCModule
Q_OBJECT
public:
explicit CharacterRunnerConfig(QWidget* parent = 0, const QVariantList& args = QVariantList());
explicit CharacterRunnerConfig(QWidget* parent, const QVariantList& args = QVariantList());
public slots:
void save();
void load();
void defaults();
public Q_SLOTS:
void save() override;
void load() override;
void defaults() override;
private Q_SLOTS:
void addItem();
void deleteItem();
......
......@@ -31,8 +31,8 @@
</widget>
</item>
<item>
<widget class="KLineEdit" name="edit_trigger">
<property name="showClearButton" stdset="0">
<widget class="QLineEdit" name="edit_trigger">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
......@@ -147,13 +147,6 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>edit_trigger</tabstop>
</tabstops>
......
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