[kde-doc-english] [kruler/frameworks] /: Port KRuler to KF5

Christoph Feck christoph at maxiom.de
Sun Oct 26 19:08:00 UTC 2014


Git commit 21f1528e9125aa3e3388cb97194fa740ce91c3ce by Christoph Feck.
Committed on 26/10/2014 at 19:06.
Pushed by cfeck into branch 'frameworks'.

Port KRuler to KF5

- "Native Moving" does not work
- icon installation is not ported

M  +33   -11   CMakeLists.txt
M  +1    -1    doc/CMakeLists.txt
M  +1    -1    doc/index.docbook
M  +64   -60   klineal.cpp
M  +7    -6    klineal.h
M  +2    -2    kruler.kcfg
M  +5    -3    krulersystemtray.cpp
M  +3    -3    krulersystemtray.h
M  +14   -18   main.cpp

http://commits.kde.org/kruler/21f1528e9125aa3e3388cb97194fa740ce91c3ce

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15c763b..0a1a6c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,26 +1,48 @@
 project(kruler)
 
-find_package(KDE4 REQUIRED)
-include(KDE4Defaults)
-
-add_subdirectory( pics )
+cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
+set(QT_MIN_VERSION "5.2.0")
+
+find_package(ECM 1.3.0 REQUIRED NO_MODULE)
+set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
+
+add_definitions(-DTRANSLATION_DOMAIN="kruler")
+
+include(KDEInstallDirs)
+include(KDECompilerSettings)
+include(KDECMakeSettings)
+include(ECMInstallIcons)
+include(FeatureSummary)
+
+find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
+    Core
+    Widgets
+)
+
+find_package(KF5 REQUIRED COMPONENTS
+    DocTools
+    I18n
+    Notifications
+    WindowSystem
+    XmlGui
+)
+
+#add_subdirectory( pics )
 add_subdirectory( doc )
 
-include_directories (${KDE4_INCLUDES})
-
 ########### next target ###############
 
 set(kruler_SRCS qautosizelabel.cpp klineal.cpp main.cpp krulersystemtray.cpp)
 
-kde4_add_ui_files(kruler_SRCS cfg_appearance.ui cfg_advanced.ui)
+ki18n_wrap_ui(kruler_SRCS cfg_appearance.ui cfg_advanced.ui)
 
-kde4_add_kcfg_files(kruler_SRCS kruler.kcfgc)
+kconfig_add_kcfg_files(kruler_SRCS kruler.kcfgc)
 
-kde4_add_app_icon(kruler_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/pics/hi*-apps-kruler.png")
+#kde4_add_app_icon(kruler_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/pics/hi*-apps-kruler.png")
 
-kde4_add_executable(kruler ${kruler_SRCS})
+add_executable(kruler ${kruler_SRCS})
 
-target_link_libraries(kruler ${KDE4_KDEUI_LIBS} ${X11_LIBRARIES})
+target_link_libraries(kruler KF5::I18n KF5::Notifications KF5::WindowSystem KF5::XmlGui)
 
 install(TARGETS kruler ${INSTALL_TARGETS_DEFAULT_ARGS})
 
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index 2dee2ae..718da5d 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 kruler)
+kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${HTML_INSTALL_DIR}/en SUBDIR kruler)
diff --git a/doc/index.docbook b/doc/index.docbook
index 953175f..d708f6b 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -1,5 +1,5 @@
 <?xml version="1.0" ?>
-<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.2-Based Variant V1.1//EN" "dtd/kdex.dtd" [
+<!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" "dtd/kdedbx45.dtd" [
   <!ENTITY kappname "&kruler;">
   <!ENTITY package "kdegraphics">
   <!ENTITY % English "INCLUDE" > <!-- change language only here -->
diff --git a/klineal.cpp b/klineal.cpp
index 039e102..4ba0d32 100644
--- a/klineal.cpp
+++ b/klineal.cpp
@@ -17,32 +17,33 @@
 
 #include "klineal.h"
 
+#include <QAction>
+#include <QApplication>
 #include <QBitmap>
 #include <QBrush>
 #include <QClipboard>
-#include <QPainter>
+#include <QDesktopWidget>
+#include <QFontDatabase>
+#include <QInputDialog>
+#include <QMenu>
 #include <QMouseEvent>
+#include <QPainter>
+#include <QScreen>
 #include <QSlider>
 #include <QToolButton>
 #include <QWidgetAction>
 
-#include <KAction>
+#include <KAboutData>
 #include <KActionCollection>
-#include <KColorDialog>
 #include <KConfig>
 #include <KConfigDialog>
-#include <KGlobalSettings>
+#include <KHelpClient>
 #include <KHelpMenu>
-#include <KInputDialog>
-#include <KLocale>
-#include <KMenu>
+#include <KLocalizedString>
 #include <KNotification>
 #include <KShortcutsDialog>
 #include <KStandardAction>
-#include <KSystemTrayIcon>
-#include <KToolInvocation>
 #include <KWindowSystem>
-#include <KApplication>
 
 #include <netwm.h>
 
@@ -88,10 +89,10 @@ KLineal::KLineal( QWidget *parent )
     mCloseButton( 0 ),
     mTrayIcon( 0 )
 {
+  setAttribute( Qt::WA_TranslucentBackground );
   KWindowSystem::setType( winId(), NET::Override );   // or NET::Normal
   KWindowSystem::setState( winId(), NET::KeepAbove );
 
-  setAttribute( Qt::WA_TranslucentBackground );
   setWindowFlags( Qt::FramelessWindowHint );
   setWindowTitle( i18nc( "@title:window", "KRuler" ) );
 
@@ -123,14 +124,10 @@ KLineal::KLineal( QWidget *parent )
 
   mLabel = new QAutoSizeLabel( this );
   mLabel->setGeometry( 0, height() - 12, 32, 12 );
-  QFont labelFont( KGlobalSettings::generalFont().family(), 10 );
-  labelFont.setPixelSize( 10 );
-  mLabel->setFont( labelFont );
   mLabel->setWhatsThis( i18n( "This is the current distance measured in pixels." ) );
   mColorLabel = new QAutoSizeLabel( this );
   mColorLabel->setAutoFillBackground( true );
-  QFont colorFont( KGlobalSettings::fixedFont().family(), 10 );
-  colorFont.setPixelSize( 10 );
+  QFont colorFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
   mColorLabel->setFont( colorFont );
   mColorLabel->move( mLabel->pos() + QPoint(0, 20) );
   mColorLabel->setWhatsThis(i18n("This is the current color in hexadecimal rgb representation"
@@ -139,12 +136,12 @@ KLineal::KLineal( QWidget *parent )
                                  "little square at the end of the line cursor." ) );
 
   mBtnRotateLeft = new QToolButton( this );
-  mBtnRotateLeft->setIcon( KIcon( QLatin1String(  "object-rotate-left" ) ) );
+  mBtnRotateLeft->setIcon( QIcon::fromTheme( QLatin1String(  "object-rotate-left" ) ) );
   mBtnRotateLeft->setToolTip( i18n( "Turn Left" ) );
   connect( mBtnRotateLeft, SIGNAL(clicked()), this, SLOT(turnLeft()) );
 
   mBtnRotateRight = new QToolButton( this );
-  mBtnRotateRight->setIcon( KIcon( QLatin1String(  "object-rotate-right" ) ) );
+  mBtnRotateRight->setIcon( QIcon::fromTheme( QLatin1String(  "object-rotate-right" ) ) );
   mBtnRotateRight->setToolTip( i18n( "Turn Right" ) );
   connect( mBtnRotateRight, SIGNAL(clicked()), this, SLOT(turnRight()) );
 
@@ -154,48 +151,48 @@ KLineal::KLineal( QWidget *parent )
   mActionCollection = new KActionCollection( this );
   mActionCollection->setConfigGroup( QLatin1String( "Actions" ) );
 
-  mMenu = new KMenu( this );
-  mMenu->addTitle( i18n( "KRuler" ) );
-  KMenu *oriMenu = new KMenu( i18n( "&Orientation"), this );
-  addAction( oriMenu, KIcon( QLatin1String( "kruler-north" ) ), i18nc( "Turn Kruler North", "&North" ),
+  mMenu = new QMenu( this );
+  mMenu->addSection( i18n( "KRuler" ) );
+  QMenu *oriMenu = new QMenu( i18n( "&Orientation"), this );
+  addAction( oriMenu, QIcon::fromTheme( QLatin1String( "kruler-north" ) ), i18nc( "Turn Kruler North", "&North" ),
              this, SLOT(setNorth()), Qt::Key_N, QLatin1String( "turn_north" ) );
-  addAction( oriMenu, KIcon( QLatin1String( "kruler-east" ) ), i18nc( "Turn Kruler East", "&East" ),
+  addAction( oriMenu, QIcon::fromTheme( QLatin1String( "kruler-east" ) ), i18nc( "Turn Kruler East", "&East" ),
              this, SLOT(setEast()), Qt::Key_E, QLatin1String( "turn_east" ) );
-  addAction( oriMenu, KIcon( QLatin1String( "kruler-south" ) ), i18nc( "Turn Kruler South", "&South" ),
+  addAction( oriMenu, QIcon::fromTheme( QLatin1String( "kruler-south" ) ), i18nc( "Turn Kruler South", "&South" ),
              this, SLOT(setSouth()), Qt::Key_S, QLatin1String( "turn_south" ) );
-  addAction( oriMenu, KIcon( QLatin1String( "kruler-west" ) ), i18nc( "Turn Kruler West", "&West" ),
+  addAction( oriMenu, QIcon::fromTheme( QLatin1String( "kruler-west" ) ), i18nc( "Turn Kruler West", "&West" ),
              this, SLOT(setWest()), Qt::Key_W, QLatin1String( "turn_west" ) );
-  addAction( oriMenu, KIcon( QLatin1String( "object-rotate-right" ) ), i18n( "&Turn Right" ),
+  addAction( oriMenu, QIcon::fromTheme( QLatin1String( "object-rotate-right" ) ), i18n( "&Turn Right" ),
              this, SLOT(turnRight()), Qt::Key_R, QLatin1String( "turn_right" ) );
-  addAction( oriMenu, KIcon( QLatin1String( "object-rotate-left" ) ), i18n( "Turn &Left" ),
+  addAction( oriMenu, QIcon::fromTheme( QLatin1String( "object-rotate-left" ) ), i18n( "Turn &Left" ),
              this, SLOT(turnLeft()), Qt::Key_L, QLatin1String( "turn_left" ) );
   mMenu->addMenu( oriMenu );
 
-  mLenMenu = new KMenu( i18n( "&Length" ), this );
-  addAction( mLenMenu, KIcon(), i18nc( "Make Kruler Height Short", "&Short" ),
+  mLenMenu = new QMenu( i18n( "&Length" ), this );
+  addAction( mLenMenu, QIcon(), i18nc( "Make Kruler Height Short", "&Short" ),
              this, SLOT(setShortLength()), Qt::CTRL + Qt::Key_S, QLatin1String( "length_short" ) );
-  addAction( mLenMenu, KIcon(), i18nc( "Make Kruler Height Medium", "&Medium" ),
+  addAction( mLenMenu, QIcon(), i18nc( "Make Kruler Height Medium", "&Medium" ),
              this, SLOT(setMediumLength()), Qt::CTRL + Qt::Key_M, QLatin1String( "length_medium" ) );
-  addAction( mLenMenu, KIcon(), i18nc( "Make Kruler Height Tall", "&Tall" ),
+  addAction( mLenMenu, QIcon(), i18nc( "Make Kruler Height Tall", "&Tall" ),
              this, SLOT(setTallLength()), Qt::CTRL + Qt::Key_T, QLatin1String( "length_tall" ) );
-  addAction( mLenMenu, KIcon(), i18n("&Full Screen Width"),
+  addAction( mLenMenu, QIcon(), i18n("&Full Screen Width"),
              this, SLOT(setFullLength()), Qt::CTRL + Qt::Key_F, QLatin1String( "length_full_length" ) );
   mLenMenu->addSeparator();
-  addAction( mLenMenu, KIcon(), i18n( "Length..." ),
+  addAction( mLenMenu, QIcon(), i18n( "Length..." ),
              this, SLOT(slotLength()), QKeySequence(), QLatin1String( "set_length" ) );
   mMenu->addMenu( mLenMenu );
 
-  KMenu* scaleMenu = new KMenu( i18n( "&Scale" ), this );
-  mScaleDirectionAction = addAction( scaleMenu, KIcon(), i18n( "Right to Left" ),
+  QMenu* scaleMenu = new QMenu( i18n( "&Scale" ), this );
+  mScaleDirectionAction = addAction( scaleMenu, QIcon(), i18n( "Right to Left" ),
                                      this, SLOT(switchDirection()), Qt::Key_D, QLatin1String( "right_to_left" ) );
-  mCenterOriginAction = addAction( scaleMenu, KIcon(), i18n( "Center Origin" ),
+  mCenterOriginAction = addAction( scaleMenu, QIcon(), i18n( "Center Origin" ),
                                    this, SLOT(centerOrigin()), Qt::Key_C, QLatin1String( "center_origin" ) );
   mCenterOriginAction->setEnabled( !mRelativeScale );
-  mOffsetAction = addAction( scaleMenu, KIcon(), i18n( "Offset..." ),
+  mOffsetAction = addAction( scaleMenu, QIcon(), i18n( "Offset..." ),
                              this, SLOT(slotOffset()), Qt::Key_O, QLatin1String( "set_offset" ) );
   mOffsetAction->setEnabled( !mRelativeScale );
   scaleMenu->addSeparator();
-  KAction *relativeScaleAction = addAction( scaleMenu, KIcon(), i18n( "Percentage" ),
+  QAction *relativeScaleAction = addAction( scaleMenu, QIcon(), i18n( "Percentage" ),
                                             0, 0, QKeySequence(), QLatin1String( "toggle_percentage" ) );
   relativeScaleAction->setCheckable( true );
   relativeScaleAction->setChecked( mRelativeScale );
@@ -203,7 +200,7 @@ KLineal::KLineal( QWidget *parent )
   mMenu->addMenu( scaleMenu );
 
   mOpacity = RulerSettings::self()->opacity();
-  KMenu* opacityMenu = new KMenu( i18n( "O&pacity" ), this );
+  QMenu* opacityMenu = new QMenu( i18n( "O&pacity" ), this );
   QWidgetAction *opacityAction = new QWidgetAction( this );
   QSlider *slider = new QSlider( this );
   slider->setMinimum( 0 );
@@ -216,25 +213,25 @@ KLineal::KLineal( QWidget *parent )
   opacityMenu->addAction( opacityAction );
   mMenu->addMenu( opacityMenu );
 
-  KAction *keyBindings = KStandardAction::keyBindings( this, SLOT(slotKeyBindings()), this );
+  QAction *keyBindings = KStandardAction::keyBindings( this, SLOT(slotKeyBindings()), this );
   mActionCollection->addAction( QLatin1String(  "key_bindings" ), keyBindings );
   mMenu->addAction( keyBindings );
-  KAction *preferences = KStandardAction::preferences( this, SLOT(slotPreferences()), this );
+  QAction *preferences = KStandardAction::preferences( this, SLOT(slotPreferences()), this );
   mActionCollection->addAction( QLatin1String(  "preferences" ), preferences );
   mMenu->addAction( preferences );
   mMenu->addSeparator();
-  KAction *copyColorAction = KStandardAction::copy( this, SLOT(copyColor()), this );
+  QAction *copyColorAction = KStandardAction::copy( this, SLOT(copyColor()), this );
   copyColorAction->setText( i18n( "Copy Color" ) );
   mActionCollection->addAction( QLatin1String(  "copy_color" ), copyColorAction );
   mMenu->addAction( copyColorAction );
   mMenu->addSeparator();
-  mMenu->addMenu( ( new KHelpMenu( this, KGlobal::mainComponent().aboutData(), true ) )->menu() );
+  mMenu->addMenu( ( new KHelpMenu( this, KAboutData::applicationData(), true ) )->menu() );
   mMenu->addSeparator();
   if ( RulerSettings::self()->trayIcon() ) {
       createSystemTray();
   }
 
-  KAction *quit = KStandardAction::quit( kapp, SLOT(quit()), this );
+  QAction *quit = KStandardAction::quit( qApp, SLOT(quit()), this );
   mActionCollection->addAction( QLatin1String(  "quit" ), quit );
   mMenu->addAction( quit );
 
@@ -275,12 +272,12 @@ void KLineal::createSystemTray()
 }
 
 
-KAction* KLineal::addAction( KMenu *menu, KIcon icon, const QString& text,
+QAction* KLineal::addAction( QMenu *menu, const QIcon& icon, const QString& text,
                              const QObject* receiver, const char* member,
                              const QKeySequence &shortcut, const QString& name )
 {
-  KAction *action = new KAction( icon, text, mActionCollection );
-  action->setShortcut( shortcut );
+  QAction *action = new QAction( icon, text, mActionCollection );
+  mActionCollection->setDefaultShortcut( action, shortcut );
   if ( receiver ) {
     connect( action, SIGNAL(triggered()), receiver, member );
   }
@@ -296,7 +293,7 @@ void KLineal::slotClose()
 
 void KLineal::slotQuit()
 {
-   kapp->quit();
+   qApp->quit();
 }
 
 void KLineal::move( int x, int y )
@@ -388,7 +385,7 @@ void KLineal::setOrientation( int inOrientation )
 
   r.moveTo(newTopLeft);
 
-  QRect desktop = KGlobalSettings::desktopGeometry( this );
+  QRect desktop = QApplication::desktop()->screenGeometry( this );
 
   if ( r.top() < desktop.top() ) {
     r.moveTop( desktop.top() );
@@ -482,7 +479,7 @@ void KLineal::reLength( int percentOfScreen )
     return;
   }
 
-  QRect r = KGlobalSettings::desktopGeometry( this );
+  QRect r = QApplication::desktop()->screenGeometry( this );
 
   if ( mOrientation == North || mOrientation == South ) {
     mLongEdgeLen = r.width() * percentOfScreen / 100;
@@ -584,9 +581,9 @@ void KLineal::centerOrigin()
 void KLineal::slotOffset()
 {
   bool ok;
-  int newOffset = KInputDialog::getInteger( i18nc( "@title:window", "Scale Offset" ),
+  int newOffset = QInputDialog::getInt( this, i18nc( "@title:window", "Scale Offset" ),
                                             i18n( "Offset:" ), mOffset,
-                                            -2147483647, 2147483647, 1, &ok, this );
+                                            -2147483647, 2147483647, 1, &ok );
 
   if ( ok ) {
     mOffset = newOffset;
@@ -599,11 +596,11 @@ void KLineal::slotOffset()
 void KLineal::slotLength()
 {
   bool ok;
-  QRect r = KGlobalSettings::desktopGeometry( this );
+  QRect r = QApplication::desktop()->screenGeometry( this );
   int width = ( ( mOrientation == North ) || ( mOrientation == South ) ) ? r.width() : r.height();
-  int newLength = KInputDialog::getInteger( i18nc( "@title:window", "Ruler Length" ),
+  int newLength = QInputDialog::getInt( this, i18nc( "@title:window", "Ruler Length" ),
                                             i18n( "Length:" ), mLongEdgeLen,
-                                            0, width, 1, &ok, this );
+                                            0, width, 1, &ok );
 
   if ( ok ) {
     reLengthAbsolute( newLength );
@@ -615,7 +612,7 @@ void KLineal::slotOpacity( int value )
   mOpacity = value;
   repaint();
   RulerSettings::self()->setOpacity( value );
-  RulerSettings::self()->writeConfig();
+  RulerSettings::self()->save();
 }
 
 void KLineal::slotKeyBindings()
@@ -691,7 +688,7 @@ void KLineal::saveSettings()
   RulerSettings::self()->setLeftToRight( mLeftToRight );
   RulerSettings::self()->setOffset( mOffset );
   RulerSettings::self()->setRelativeScale( mRelativeScale );
-  RulerSettings::self()->writeConfig();
+  RulerSettings::self()->save();
 }
 
 void KLineal::copyColor()
@@ -840,7 +837,7 @@ void KLineal::keyPressEvent( QKeyEvent *e )
 
   switch ( e->key() ) {
   case Qt::Key_F1:
-    KToolInvocation::invokeHelp();
+    KHelpClient::invokeHelp();
     return;
 
   case Qt::Key_Left:
@@ -903,7 +900,7 @@ void KLineal::mouseMoveEvent( QMouseEvent *inEvent )
       break;
     }
 
-    QColor color = KColorDialog::grabColor( p );
+    QColor color = pixelColor( p );
     int h, s, v;
     color.getHsv( &h, &s, &v );
     mColorLabel->setText( color.name().toUpper() );
@@ -1198,4 +1195,11 @@ void KLineal::paintEvent(QPaintEvent *inEvent )
   drawScale( painter );
 }
 
-#include "klineal.moc"
+QColor KLineal::pixelColor(const QPoint &p)
+{
+  const QDesktopWidget *desktop = QApplication::desktop();
+  QScreen *screen = QGuiApplication::screens().at(desktop->screenNumber());
+  const QPixmap pixmap = screen->grabWindow(desktop->winId(), p.x(), p.y(), 1, 1);
+  return QColor(pixmap.toImage().pixel(QPoint(0, 0)));
+}
+
diff --git a/klineal.h b/klineal.h
index 872b910..3fcc35a 100644
--- a/klineal.h
+++ b/klineal.h
@@ -20,13 +20,13 @@
 
 #include <QWidget>
 
+class QAction;
 class QAutoSizeLabel;
+class QIcon;
+class QMenu;
 class QToolButton;
 
-class KAction;
 class KActionCollection;
-class KIcon;
-class KMenu;
 class KRulerSystemTray;
 
 class KLineal : public QWidget {
@@ -57,7 +57,7 @@ protected:
   void createSystemTray();
 
 private:
-  KAction* addAction( KMenu *menu, KIcon icon, const QString& text,
+  QAction* addAction( QMenu *menu, const QIcon& icon, const QString& text,
                       const QObject* receiver, const char* member,
                       const QKeySequence &shortcut, const QString& name );
   void drawScale( QPainter &painter );
@@ -65,6 +65,7 @@ private:
   void reLength( int percentOfScreen );
   void reLengthAbsolute( int length );
   void updateScaleDirectionMenuItem();
+  QColor pixelColor( const QPoint &p );
 
   bool mDragging;
   QPoint mLastClickPos;
@@ -74,9 +75,9 @@ private:
   int mOrientation;
   int mLongEdgeLen;
   int mShortEdgeLen;
-  KMenu *mMenu;
+  QMenu *mMenu;
   QAction *mCloseAction;
-  KMenu *mLenMenu;
+  QMenu *mLenMenu;
   QAction *mFullScreenAction;
   QAction *mScaleDirectionAction;
   QAction *mCenterOriginAction;
diff --git a/kruler.kcfg b/kruler.kcfg
index a2aa953..61427ec 100644
--- a/kruler.kcfg
+++ b/kruler.kcfg
@@ -2,7 +2,7 @@
 <!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
 <kcfg>
   <kcfgfile name="krulerrc"/>
-  <include>KGlobalSettings</include>
+  <include>QFontDatabase</include>
   <group name="StoredSettings">
     <entry name="BgColor" type="Color">
       <label>Background color of the ruler.</label>
@@ -14,7 +14,7 @@
     </entry>
     <entry name="ScaleFont" type="Font">
       <label>Font of the text on the ruler scale.</label>
-      <default code="true">QFont( KGlobalSettings::generalFont().family(), 6 )</default>
+      <default code="true">QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)</default>
     </entry>
     <entry name="Orientation" type="Int">
       <label>Orientation of the ruler</label>
diff --git a/krulersystemtray.cpp b/krulersystemtray.cpp
index 157525f..67f33ca 100644
--- a/krulersystemtray.cpp
+++ b/krulersystemtray.cpp
@@ -15,8 +15,10 @@
 
 #include "krulersystemtray.h"
 
-#include <KLocale>
-#include <KMenu>
+#include <QMenu>
+
+#include <KActionCollection>
+#include <KLocalizedString>
 
 KRulerSystemTray::KRulerSystemTray( const QString& iconName, QWidget *parent, KActionCollection *actions)
   : KStatusNotifierItem( parent )
@@ -24,6 +26,6 @@ KRulerSystemTray::KRulerSystemTray( const QString& iconName, QWidget *parent, KA
   setIconByName( iconName );
   setStatus(KStatusNotifierItem::Active);
   setToolTip( iconName, i18n( "KDE Screen Ruler" ), QString() );
-  KMenu *cm = contextMenu();
+  QMenu *cm = contextMenu();
   cm->addAction( actions->action( QLatin1String( "preferences" ) ) );
 }
diff --git a/krulersystemtray.h b/krulersystemtray.h
index 18173d0..df5b3d6 100644
--- a/krulersystemtray.h
+++ b/krulersystemtray.h
@@ -16,9 +16,9 @@
 #ifndef KRULERSYSTEMTRAY_H
 #define KRULERSYSTEMTRAY_H
 
-#include <kactioncollection.h>
-#include <kicon.h>
-#include <kstatusnotifieritem.h>
+#include <KStatusNotifierItem>
+
+class KActionCollection;
 
 class KRulerSystemTray : public KStatusNotifierItem
 {
diff --git a/main.cpp b/main.cpp
index 81c06d8..22cb855 100644
--- a/main.cpp
+++ b/main.cpp
@@ -14,30 +14,26 @@
  *                                                                         *
  ***************************************************************************/
 
-#include <kapplication.h>
-#include <kdeversion.h>
-#include <kcmdlineargs.h>
-#include <kaboutdata.h>
-#include <klocale.h>
+#include <QApplication>
+
+#include <KAboutData>
+#include <KLocalizedString>
 
 #include "klineal.h"
 
 int main(int argc, char *argv[])
 {
-  KAboutData aboutData( "kruler", 0, ki18n( "KDE Screen Ruler" ),
-    KDE_VERSION_STRING,
-    ki18n( "A screen ruler for KDE" ),
-    KAboutData::License_GPL,
-    ki18n( "(c) 2000 - 2008, Till Krech\n(c) 2009, Mathias Soeken" ) );
-  aboutData.addAuthor( ki18n( "Mathias Soeken" ), ki18n( "Maintainer" ), "msoeken at tzi.de" );
-  aboutData.addAuthor( ki18n( "Till Krech" ), ki18n( "Former Maintainer and Developer" ), "till at snafu.de" );
-  aboutData.addCredit( ki18n( "Gunnstein Lye" ),ki18n( "Initial port to KDE 2" ), "gl at ez.no" );
-  KCmdLineArgs::init( argc, argv, &aboutData );
-
-  KCmdLineOptions options;
-  KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
+  KAboutData aboutData( "kruler", i18n( "KDE Screen Ruler" ),
+    "5.0", // version string
+    i18n( "A screen ruler for KDE" ),
+    KAboutLicense::GPL,
+    i18n( "(c) 2000 - 2008, Till Krech\n(c) 2009, Mathias Soeken" ) );
+  aboutData.addAuthor( i18n( "Mathias Soeken" ), i18n( "Maintainer" ), "msoeken at tzi.de" );
+  aboutData.addAuthor( i18n( "Till Krech" ), i18n( "Former Maintainer and Developer" ), "till at snafu.de" );
+  aboutData.addCredit( i18n( "Gunnstein Lye" ),i18n( "Initial port to KDE 2" ), "gl at ez.no" );
 
-  KApplication a;
+  QApplication a( argc, argv );
+  KAboutData::setApplicationData(aboutData);
 
   KLineal *ruler = new KLineal();
   ruler->show();


More information about the kde-doc-english mailing list