diff --git a/runners/CMakeLists.txt b/runners/CMakeLists.txt index abe294694..4e7ed4bce 100644 --- a/runners/CMakeLists.txt +++ b/runners/CMakeLists.txt @@ -1,26 +1,26 @@ # add_subdirectory(browserhistory) add_subdirectory(converter) add_subdirectory(datetime) add_subdirectory(katesessions) # add_subdirectory(konquerorsessions) # add_subdirectory(kopete) # add_subdirectory(mediawiki) add_subdirectory(spellchecker) -# add_subdirectory(characters) +add_subdirectory(characters) add_subdirectory(dictionary) # # if(KDEPIMLIBS_FOUND) # if (NOT KDE_PLATFORM_FEATURE_DISABLE_DEPRECATED) # add_subdirectory(contacts) # endif (NOT KDE_PLATFORM_FEATURE_DISABLE_DEPRECATED) # add_subdirectory(events) # endif(KDEPIMLIBS_FOUND) # # if(NOT WIN32) # add_subdirectory(konsolesessions) # endif(NOT WIN32) # # if(QJSON_FOUND) # add_subdirectory(youtube) # add_subdirectory(translator) # endif(QJSON_FOUND) diff --git a/runners/characters/CMakeLists.txt b/runners/characters/CMakeLists.txt index 1a45abd72..49f659b0d 100644 --- a/runners/characters/CMakeLists.txt +++ b/runners/characters/CMakeLists.txt @@ -1,22 +1,24 @@ -# 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}) diff --git a/runners/characters/charrunner.cpp b/runners/characters/charrunner.cpp index a094f2d91..e7083c353 100644 --- a/runners/characters/charrunner.cpp +++ b/runners/characters/charrunner.cpp @@ -1,94 +1,101 @@ /* Copyright 2010 Anton Kreuzkamp * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #include "charrunner.h" -#include +// KF +#include +#include + + +//Names of config-entries +static const char CONFIG_TRIGGERWORD[] = "triggerWord"; +static const char CONFIG_ALIASES[] = "aliases"; +static const char CONFIG_CODES[] = "codes"; -#include CharacterRunner::CharacterRunner( QObject* parent, const QVariantList &args ) : Plasma::AbstractRunner(parent, args) { Q_UNUSED(args) setObjectName(QLatin1String( "CharacterRunner" )); setIgnoredTypes(Plasma::RunnerContext::Directory | Plasma::RunnerContext::File | Plasma::RunnerContext::NetworkLocation | Plasma::RunnerContext::Executable | Plasma::RunnerContext::ShellCommand); reloadConfiguration(); } CharacterRunner::~CharacterRunner() { } void CharacterRunner::reloadConfiguration() { KConfigGroup grp = config(); //Create config-object m_triggerWord = grp.readEntry(CONFIG_TRIGGERWORD, "#"); //read out the triggerword m_aliases = grp.readEntry(CONFIG_ALIASES, QStringList()); m_codes = grp.readEntry(CONFIG_CODES, QStringList()); addSyntax(Plasma::RunnerSyntax(m_triggerWord + QLatin1String( ":q:" ), i18n("Creates Characters from :q: if it is a hexadecimal code or defined alias."))); } 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 { return; } if (!term.startsWith(m_triggerWord)) //ignore queries without the triggerword { return; } term = term.remove(0, m_triggerWord.length()); //remove the triggerword if (m_aliases.contains(term)) //replace aliases by their hex.-code { term = m_codes[m_aliases.indexOf(term)]; } bool ok; //checkvariable int hex = term.toInt(&ok, 16); //convert query into int if (!ok) //check if conversion was successful { return; } //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" diff --git a/runners/characters/charrunner.h b/runners/characters/charrunner.h index f67bd6a50..1e7c9e07e 100644 --- a/runners/characters/charrunner.h +++ b/runners/characters/charrunner.h @@ -1,45 +1,43 @@ /* Copyright 2010 Anton Kreuzkamp * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef CHARRUNNER_H #define CHARRUNNER_H -#include -#include "charrunner_config.h" +#include class CharacterRunner : public Plasma::AbstractRunner { Q_OBJECT 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 QString m_triggerWord; QList m_aliases; QList m_codes; }; -K_EXPORT_PLASMA_RUNNER(CharacterRunner, CharacterRunner) - #endif diff --git a/runners/characters/charrunner_config.cpp b/runners/characters/charrunner_config.cpp index f59e931f4..3730b387e 100644 --- a/runners/characters/charrunner_config.cpp +++ b/runners/characters/charrunner_config.cpp @@ -1,121 +1,130 @@ /* Copyright 2010 Anton Kreuzkamp * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ -//Project-Includes #include "charrunner_config.h" -//KDE-Includes -#include -K_EXPORT_RUNNER_CONFIG(CharacterRunner, CharacterRunnerConfig) +// KF +#include +#include + +//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); QGridLayout* layout = new QGridLayout(this); layout->addWidget(m_ui, 0, 0); connect(m_ui->edit_trigger, SIGNAL(textChanged(QString)), this, SLOT(changed())); connect(m_ui->addItem, SIGNAL(clicked()), this, SLOT(addItem())); connect(m_ui->deleteItem, SIGNAL(clicked()), this, SLOT(deleteItem())); } void CharacterRunnerConfig::addItem() //add Item to the list-view widget { QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->list, 2); item->setText(0, m_ui->edit_alias->text()); item->setText(1, m_ui->edit_hex->text()); m_ui->list->addTopLevelItem(item); m_ui->edit_alias->clear(); m_ui->edit_hex->clear(); emit changed(true); } void CharacterRunnerConfig::deleteItem() //remove Item to the list-view widget { m_ui->list->takeTopLevelItem(m_ui->list->indexOfTopLevelItem(m_ui->list->currentItem())); emit changed(true); } void CharacterRunnerConfig::load() { KCModule::load(); //create config-object KSharedConfig::Ptr cfg = KSharedConfig::openConfig(QLatin1String( "krunnerrc" )); KConfigGroup grp = cfg->group("Runners"); grp = KConfigGroup(&grp, "CharacterRunner"); m_ui->edit_trigger->setText(grp.readEntry(CONFIG_TRIGGERWORD, "#")); //read out triggerword and put into the trigger-lineEdit for(int i=0; i()).size(); i++) //read out aliaslist and add Items to the list-view widget { QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->list, 2); item->setText(0, grp.readEntry(CONFIG_ALIASES, QList())[i]); item->setText(1, grp.readEntry(CONFIG_CODES, QList())[i]); m_ui->list->addTopLevelItem(item); } emit changed(false); } void CharacterRunnerConfig::save() { KCModule::save(); //create config-object KSharedConfig::Ptr cfg = KSharedConfig::openConfig(QLatin1String( "krunnerrc" )); KConfigGroup grp = cfg->group("Runners"); grp = KConfigGroup(&grp, "CharacterRunner"); grp.writeEntry(CONFIG_TRIGGERWORD,m_ui->edit_trigger->text()); //write content from the triggerword-line Edit into the config //Write the content of the List into the config QList aliaslist; QList codelist; for(int i=0; i < m_ui->list->topLevelItemCount(); i++) { QString blub = m_ui->list->topLevelItem(i)->text(0); aliaslist.append(blub); codelist.append(m_ui->list->topLevelItem(i)->text(1)); } grp.writeEntry(CONFIG_ALIASES, aliaslist); grp.writeEntry(CONFIG_CODES, codelist); emit changed(false); } void CharacterRunnerConfig::defaults() { KCModule::defaults(); m_ui->edit_trigger->setText(QLatin1String( "#" )); //set the content of the triggerword-lineEdit to default '#' for(int i=0; ilist->topLevelItemCount(); i++) //remove every item from the alias-list { m_ui->list->takeTopLevelItem(i); } emit changed(true); } + +K_PLUGIN_FACTORY(CharacterRunnerConfigFactory, + registerPlugin(QStringLiteral("kcm_krunner_charrunner"));) + +#include "charrunner_config.moc" diff --git a/runners/characters/charrunner_config.h b/runners/characters/charrunner_config.h index 29f93722d..5398b5636 100644 --- a/runners/characters/charrunner_config.h +++ b/runners/characters/charrunner_config.h @@ -1,58 +1,56 @@ /* Copyright 2010 Anton Kreuzkamp * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef CHARRUNNERCONFIG_H #define CHARRUNNERCONFIG_H //Project-Includes #include "ui_charrunner_config.h" -//KDE-Includes +// KF #include -//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 { Q_OBJECT public: explicit CharacterRunnerConfigForm(QWidget* parent); }; 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(); private: CharacterRunnerConfigForm* m_ui; }; #endif diff --git a/runners/characters/charrunner_config.ui b/runners/characters/charrunner_config.ui index ad84afb7e..74b52dcad 100644 --- a/runners/characters/charrunner_config.ui +++ b/runners/characters/charrunner_config.ui @@ -1,162 +1,155 @@ Anton Kreuzkamp CharacterRunnerConfigUi 0 0 308 252 Character Runner Config &Trigger word: edit_trigger - - + + true Alias: Hex Code: 2 75 75 Alias Code Add Item Delete Item Qt::Vertical 20 40 Qt::Vertical 20 40 - - - KLineEdit - QLineEdit -
klineedit.h
-
-
edit_trigger