[kde-doc-english] [kcharselect/frameworks] /: Port KCharSelect to KF5
Christoph Feck
christoph at maxiom.de
Sun Oct 26 14:02:40 UTC 2014
Git commit e3704252cea041e41daa39fb31b39dc8783d716f by Christoph Feck.
Committed on 26/10/2014 at 14:02.
Pushed by cfeck into branch 'frameworks'.
Port KCharSelect to KF5
I didn't feel like making individual commits
for the few small changes. Excuse me :)
M +26 -19 CMakeLists.txt
M +1 -1 doc/CMakeLists.txt
M +1 -1 doc/index.docbook
M +20 -24 kcharselectdia.cc
M +4 -4 kcharselectdia.h
M +22 -22 main.cc
http://commits.kde.org/kcharselect/e3704252cea041e41daa39fb31b39dc8783d716f
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 34cedb6..d29b47e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,37 +1,44 @@
project(kcharselect)
-########### next target ###############
+cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
+set (QT_MIN_VERSION "5.2.0")
-if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
- find_package(KDE4)
- include( KDE4Defaults )
- include_directories(${KDE4_INCLUDES})
+find_package (ECM 1.3.0 REQUIRED NO_MODULE)
+set (CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
- add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
- add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
+add_definitions(-DTRANSLATION_DOMAIN="kcharselect")
- # If definitions like -D_GNU_SOURCE are needed for these checks they
- # should be added to _KDE4_PLATFORM_DEFINITIONS when it is originally
- # defined outside this file. Here we include these definitions in
- # CMAKE_REQUIRED_DEFINITIONS so they will be included in the build of
- # checks below.
- set( CMAKE_REQUIRED_DEFINITIONS ${_KDE4_PLATFORM_DEFINITIONS} )
-endif()
+include(KDEInstallDirs)
+include(KDECompilerSettings)
+include(KDECMakeSettings)
+
+find_package (Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
+ Core
+ Widgets
+)
+
+find_package(KF5 REQUIRED COMPONENTS
+ DocTools
+ I18n
+ WidgetsAddons
+ XmlGui
+)
+
+add_definitions(-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS)
set(kcharselect_SRCS kcharselectdia.cc main.cc )
-kde4_add_app_icon(kcharselect_SRCS "${KDE4_INSTALL_DIR}/share/icons/oxygen/*/apps/accessories-character-map.png")
+#kde4_add_app_icon(kcharselect_SRCS "${KDE4_INSTALL_DIR}/share/icons/oxygen/*/apps/accessories-character-map.png")
-kde4_add_executable(kcharselect ${kcharselect_SRCS})
+add_executable(kcharselect ${kcharselect_SRCS})
-target_link_libraries(kcharselect ${KDE4_KDEUI_LIBS} )
+target_link_libraries(kcharselect KF5::I18n KF5::WidgetsAddons KF5::XmlGui )
install(TARGETS kcharselect ${INSTALL_TARGETS_DEFAULT_ARGS} )
########### install files ###############
install( PROGRAMS KCharSelect.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})
-install( FILES kcharselectui.rc DESTINATION ${DATA_INSTALL_DIR}/kcharselect)
+install( FILES kcharselectui.rc DESTINATION ${KXMLGUI_INSTALL_DIR}/kcharselect)
-kde4_install_icons( ${ICON_INSTALL_DIR} )
add_subdirectory(doc)
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 9eb9efd..dcdaa42 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -1,4 +1,4 @@
########### install files ###############
#
#
-kde4_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR kcharselect)
+kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR kcharselect)
diff --git a/doc/index.docbook b/doc/index.docbook
index 835f42e..ec63da6 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -1,5 +1,5 @@
<?xml version="1.0" ?>
-<!DOCTYPE article PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN" "dtd/kdex.dtd" [
+<!DOCTYPE article PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" "dtd/kdedbx45.dtd" [
<!ENTITY kappname "&kcharselect;">
<!ENTITY package "kdeutils">
diff --git a/kcharselectdia.cc b/kcharselectdia.cc
index 493ead2..56cdf8f 100644
--- a/kcharselectdia.cc
+++ b/kcharselectdia.cc
@@ -17,17 +17,17 @@
#include "kcharselectdia.h"
-#include <KAction>
+#include <QAction>
+#include <QApplication>
+#include <QFontDatabase>
+#include <QIcon>
+
#include <KActionCollection>
-#include <KApplication>
-#include <KConfig>
-#include <KDebug>
-#include <KDialog>
-#include <KGlobal>
-#include <KIcon>
-#include <KLocale>
+#include <KConfigGroup>
+#include <KLocalizedString>
#include <KStandardAction>
#include <KStandardShortcut>
+#include <KSharedConfig>
#include <KToggleAction>
/******************************************************************/
@@ -38,10 +38,10 @@
KCharSelectDia::KCharSelectDia()
: KXmlGuiWindow()
{
- KSharedConfig::Ptr config = KGlobal::config();
+ KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup gr = config->group("General");
- vFont = gr.readEntry("selectedFont", KGlobalSettings::generalFont());
+ vFont = gr.readEntry("selectedFont", QFontDatabase::systemFont(QFontDatabase::GeneralFont));
vChr = QChar(static_cast<unsigned short>(gr.readEntry("char", 33)));
_rtl = gr.readEntry("rtl", false);
@@ -49,8 +49,6 @@ KCharSelectDia::KCharSelectDia()
setCentralWidget(mainWidget);
grid = new QGridLayout( mainWidget );
- grid->setMargin( KDialog::marginHint() );
- grid->setSpacing( KDialog::spacingHint() );
// Add character selection widget from library kdeui
charSelect = new KCharSelect(mainWidget, actionCollection());
@@ -66,9 +64,9 @@ KCharSelectDia::KCharSelectDia()
grid->addWidget(charSelect, 0, 0, 1, 4);
// Build line editor
- lined = new KLineEdit(mainWidget);
+ lined = new QLineEdit(mainWidget);
lined->resize(lined->sizeHint());
- lined->setClearButtonShown(true);
+ lined->setClearButtonEnabled(true);
lined->setFont( vFont );
@@ -76,8 +74,8 @@ KCharSelectDia::KCharSelectDia()
SLOT(lineEditChanged()));
grid->addWidget(lined, 1, 0, 1, 3);
- bClip = new KPushButton( KGuiItem( i18n( "&To Clipboard" ),
- QLatin1String( "edit-copy" ) ), mainWidget );
+ bClip = new QPushButton( i18n( "&To Clipboard" ), mainWidget );
+ bClip->setIcon( QIcon::fromTheme( QLatin1String( "edit-copy" ) ));
bClip->setFixedSize( bClip->sizeHint() );
connect(bClip,SIGNAL(clicked()),this,SLOT(toClip()));
grid->addWidget(bClip, 1, 3);
@@ -85,11 +83,11 @@ KCharSelectDia::KCharSelectDia()
// Build menu
KStandardAction::quit( this, SLOT(close()), actionCollection() );
- KAction *action = actionCollection()->addAction( QLatin1String( "copy_clip" ) );
+ QAction *action = actionCollection()->addAction( QLatin1String( "copy_clip" ) );
action->setText( i18n("&To Clipboard") );
- action->setIcon( KIcon( QLatin1String( "edit-copy" )) );
+ action->setIcon( QIcon::fromTheme( QLatin1String( "edit-copy" )) );
connect(action, SIGNAL(triggered(bool)), SLOT(toClip()));
- action->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::Copy));
+ actionCollection()->setDefaultShortcuts(action, KStandardShortcut::shortcut(KStandardShortcut::Copy));
action = actionCollection()->addAction( QLatin1String( "copy_utf_8" ) );
action->setText( i18n("To Clipboard &UTF-8") );
@@ -100,9 +98,9 @@ KCharSelectDia::KCharSelectDia()
action = actionCollection()->addAction( QLatin1String( "from_clip" ) );
action->setText( i18n("&From Clipboard") );
- action->setIcon( KIcon( QLatin1String( "edit-paste" )) );
+ action->setIcon( QIcon::fromTheme( QLatin1String( "edit-paste" )) );
connect(action, SIGNAL(triggered(bool)), SLOT(fromClip()));
- action->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::Paste));
+ actionCollection()->setDefaultShortcuts(action, KStandardShortcut::shortcut(KStandardShortcut::Paste));
action = actionCollection()->addAction( QLatin1String( "from_clip_utf8" ) );
action->setText( i18n( "From Clipboard UTF-8") );
connect(action, SIGNAL(triggered(bool) ), SLOT(fromClipUTF8()));
@@ -131,7 +129,7 @@ KCharSelectDia::KCharSelectDia()
//==================================================================
void KCharSelectDia::closeEvent(QCloseEvent *event)
{
- KSharedConfig::Ptr config = KGlobal::config();
+ KSharedConfig::Ptr config = KSharedConfig::openConfig();
KConfigGroup gr = config->group("General");
gr.writeEntry("selectedFont", vFont);
@@ -287,5 +285,3 @@ void KCharSelectDia::lineEditChanged()
lined->setCursorPosition( lined->cursorPosition() - 1 );
}
}
-
-#include "kcharselectdia.moc"
diff --git a/kcharselectdia.h b/kcharselectdia.h
index bd71deb..626da63 100644
--- a/kcharselectdia.h
+++ b/kcharselectdia.h
@@ -20,10 +20,10 @@
#include <QClipboard>
#include <QLayout>
+#include <QLineEdit>
+#include <QPushButton>
#include <KCharSelect>
-#include <KLineEdit>
-#include <KPushButton>
#include <KXmlGuiWindow>
/******************************************************************/
@@ -42,8 +42,8 @@ protected:
QGridLayout *grid;
KCharSelect *charSelect;
- KLineEdit *lined;
- KPushButton *bClip;
+ QLineEdit *lined;
+ QPushButton *bClip;
QChar vChr;
QFont vFont;
diff --git a/main.cc b/main.cc
index 67cefa5..841f0aa 100644
--- a/main.cc
+++ b/main.cc
@@ -15,42 +15,42 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "kcharselectdia.h"
+#include <QApplication>
+#include <QCommandLineParser>
#include <KAboutData>
-#include <KApplication>
-#include <KCmdLineArgs>
+#include <KLocalizedString>
-static const char version[] = "v1.11";
-static const char description[] = I18N_NOOP("KDE character selection utility");
-static const char text[] = I18N_NOOP("A wrapper around the KCharSelect widget.");
-static const char homepageUrl[] = "http://utils.kde.org/projects/kcharselect";
+#include "kcharselectdia.h"
-/*================================================================*/
int main(int argc, char **argv)
{
- KAboutData aboutData( "kcharselect", 0, ki18n("KCharSelect"),
- version, ki18n(description), KAboutData::License_GPL,
- KLocalizedString(), ki18n(text), homepageUrl );
+ KAboutData aboutData( "kcharselect", i18n("KCharSelect"),
+ "1.12", i18n("KDE character selection utility"), KAboutLicense::GPL,
+ QString(), i18n("A wrapper around the KCharSelect widget."), "http://utils.kde.org/projects/kcharselect" );
- aboutData.addAuthor(ki18n("Daniel Laidig"), ki18n("Author and maintainer"), "d.laidig at gmx.de" );
- aboutData.addAuthor(ki18n("Reginald Stadlbauer"), ki18n("Author"), "reggie at kde.org");
+ aboutData.addAuthor(i18n("Daniel Laidig"), i18n("Author and maintainer"), "d.laidig at gmx.de" );
+ aboutData.addAuthor(i18n("Reginald Stadlbauer"), i18n("Author"), "reggie at kde.org");
- aboutData.addCredit( ki18n("Daniel Laidig"), ki18n("New GUI, Unicode information, incremental search,"
+ aboutData.addCredit( i18n("Daniel Laidig"), i18n("New GUI, Unicode information, incremental search,"
" and general improvements"), "d.laidig at gmx.de" );
- aboutData.addCredit( ki18n("Constantin Berzan"), ki18n("Previous maintainer"), "exit3219 at gmail.com" );
- aboutData.addCredit( ki18n("Nadeem Hasan"), ki18n( "GUI cleanup and fixes" ),
+ aboutData.addCredit( i18n("Constantin Berzan"), i18n("Previous maintainer"), "exit3219 at gmail.com" );
+ aboutData.addCredit( i18n("Nadeem Hasan"), i18n( "GUI cleanup and fixes" ),
"nhasan at kde.org" );
- aboutData.addCredit( ki18n("Ryan Cumming"), ki18n( "GUI cleanup and fixes" ),
+ aboutData.addCredit( i18n("Ryan Cumming"), i18n( "GUI cleanup and fixes" ),
"bodnar42 at phalynx.dhs.org" );
- aboutData.addCredit( ki18n("Benjamin C. Meyer"), ki18n("XMLUI conversion"),
+ aboutData.addCredit( i18n("Benjamin C. Meyer"), i18n("XMLUI conversion"),
"ben+kcharselect at meyerhome.net" );
- aboutData.addCredit( ki18n("Bryce Nesbitt"), ki18n("RTL support") );
+ aboutData.addCredit( i18n("Bryce Nesbitt"), i18n("RTL support") );
- aboutData.setProgramIconName(QLatin1String( "accessories-character-map" ));
- KCmdLineArgs::init( argc, argv, &aboutData );
+ QApplication app( argc, argv );
+ KAboutData::setApplicationData( aboutData );
+ app.setWindowIcon( QIcon::fromTheme( QLatin1String( "accessories-character-map" )));
- KApplication app;
+ QCommandLineParser parser;
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.process(app);
KCharSelectDia *dia = new KCharSelectDia;
dia->show();
More information about the kde-doc-english
mailing list