Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KRuler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Graphics
KRuler
Commits
21f1528e
Commit
21f1528e
authored
Oct 26, 2014
by
Christoph Feck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port KRuler to KF5
- "Native Moving" does not work - icon installation is not ported
parent
7a49b65b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
130 additions
and
105 deletions
+130
-105
CMakeLists.txt
CMakeLists.txt
+33
-11
doc/CMakeLists.txt
doc/CMakeLists.txt
+1
-1
doc/index.docbook
doc/index.docbook
+1
-1
klineal.cpp
klineal.cpp
+64
-60
klineal.h
klineal.h
+7
-6
kruler.kcfg
kruler.kcfg
+2
-2
krulersystemtray.cpp
krulersystemtray.cpp
+5
-3
krulersystemtray.h
krulersystemtray.h
+3
-3
main.cpp
main.cpp
+14
-18
No files found.
CMakeLists.txt
View file @
21f1528e
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
)
k
de4_add_ui_files
(
kruler_SRCS cfg_appearance.ui cfg_advanced.ui
)
k
i18n_wrap_ui
(
kruler_SRCS cfg_appearance.ui cfg_advanced.ui
)
k
de4
_add_kcfg_files
(
kruler_SRCS kruler.kcfgc
)
k
config
_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
}
)
...
...
doc/CMakeLists.txt
View file @
21f1528e
########### install files ###############
#
#
kd
e4
_create_handbook
(
index.docbook INSTALL_DESTINATION
${
HTML_INSTALL_DIR
}
/en SUBDIR kruler
)
kd
octools
_create_handbook
(
index.docbook INSTALL_DESTINATION
${
HTML_INSTALL_DIR
}
/en SUBDIR kruler
)
doc/index.docbook
View file @
21f1528e
<?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 -->
...
...
klineal.cpp
View file @
21f1528e
...
...
@@ -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 <KA
ction
>
#include <KA
boutData
>
#include <KActionCollection>
#include <KColorDialog>
#include <KConfig>
#include <KConfigDialog>
#include <K
GlobalSettings
>
#include <K
HelpClient
>
#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
K
Menu
(
this
);
mMenu
->
add
Title
(
i18n
(
"KRuler"
)
);
KMenu
*
oriMenu
=
new
K
Menu
(
i18n
(
"&Orientation"
),
this
);
addAction
(
oriMenu
,
KIcon
(
QLatin1String
(
"kruler-north"
)
),
i18nc
(
"Turn Kruler North"
,
"&North"
),
mMenu
=
new
Q
Menu
(
this
);
mMenu
->
add
Section
(
i18n
(
"KRuler"
)
);
QMenu
*
oriMenu
=
new
Q
Menu
(
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
K
Menu
(
i18n
(
"&Length"
),
this
);
addAction
(
mLenMenu
,
K
Icon
(),
i18nc
(
"Make Kruler Height Short"
,
"&Short"
),
mLenMenu
=
new
Q
Menu
(
i18n
(
"&Length"
),
this
);
addAction
(
mLenMenu
,
Q
Icon
(),
i18nc
(
"Make Kruler Height Short"
,
"&Short"
),
this
,
SLOT
(
setShortLength
()),
Qt
::
CTRL
+
Qt
::
Key_S
,
QLatin1String
(
"length_short"
)
);
addAction
(
mLenMenu
,
K
Icon
(),
i18nc
(
"Make Kruler Height Medium"
,
"&Medium"
),
addAction
(
mLenMenu
,
Q
Icon
(),
i18nc
(
"Make Kruler Height Medium"
,
"&Medium"
),
this
,
SLOT
(
setMediumLength
()),
Qt
::
CTRL
+
Qt
::
Key_M
,
QLatin1String
(
"length_medium"
)
);
addAction
(
mLenMenu
,
K
Icon
(),
i18nc
(
"Make Kruler Height Tall"
,
"&Tall"
),
addAction
(
mLenMenu
,
Q
Icon
(),
i18nc
(
"Make Kruler Height Tall"
,
"&Tall"
),
this
,
SLOT
(
setTallLength
()),
Qt
::
CTRL
+
Qt
::
Key_T
,
QLatin1String
(
"length_tall"
)
);
addAction
(
mLenMenu
,
K
Icon
(),
i18n
(
"&Full Screen Width"
),
addAction
(
mLenMenu
,
Q
Icon
(),
i18n
(
"&Full Screen Width"
),
this
,
SLOT
(
setFullLength
()),
Qt
::
CTRL
+
Qt
::
Key_F
,
QLatin1String
(
"length_full_length"
)
);
mLenMenu
->
addSeparator
();
addAction
(
mLenMenu
,
K
Icon
(),
i18n
(
"Length..."
),
addAction
(
mLenMenu
,
Q
Icon
(),
i18n
(
"Length..."
),
this
,
SLOT
(
slotLength
()),
QKeySequence
(),
QLatin1String
(
"set_length"
)
);
mMenu
->
addMenu
(
mLenMenu
);
KMenu
*
scaleMenu
=
new
K
Menu
(
i18n
(
"&Scale"
),
this
);
mScaleDirectionAction
=
addAction
(
scaleMenu
,
K
Icon
(),
i18n
(
"Right to Left"
),
QMenu
*
scaleMenu
=
new
Q
Menu
(
i18n
(
"&Scale"
),
this
);
mScaleDirectionAction
=
addAction
(
scaleMenu
,
Q
Icon
(),
i18n
(
"Right to Left"
),
this
,
SLOT
(
switchDirection
()),
Qt
::
Key_D
,
QLatin1String
(
"right_to_left"
)
);
mCenterOriginAction
=
addAction
(
scaleMenu
,
K
Icon
(),
i18n
(
"Center Origin"
),
mCenterOriginAction
=
addAction
(
scaleMenu
,
Q
Icon
(),
i18n
(
"Center Origin"
),
this
,
SLOT
(
centerOrigin
()),
Qt
::
Key_C
,
QLatin1String
(
"center_origin"
)
);
mCenterOriginAction
->
setEnabled
(
!
mRelativeScale
);
mOffsetAction
=
addAction
(
scaleMenu
,
K
Icon
(),
i18n
(
"Offset..."
),
mOffsetAction
=
addAction
(
scaleMenu
,
Q
Icon
(),
i18n
(
"Offset..."
),
this
,
SLOT
(
slotOffset
()),
Qt
::
Key_O
,
QLatin1String
(
"set_offset"
)
);
mOffsetAction
->
setEnabled
(
!
mRelativeScale
);
scaleMenu
->
addSeparator
();
KAction
*
relativeScaleAction
=
addAction
(
scaleMenu
,
K
Icon
(),
i18n
(
"Percentage"
),
QAction
*
relativeScaleAction
=
addAction
(
scaleMenu
,
Q
Icon
(),
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
K
Menu
(
i18n
(
"O&pacity"
),
this
);
QMenu
*
opacityMenu
=
new
Q
Menu
(
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
);
K
Action
*
keyBindings
=
KStandardAction
::
keyBindings
(
this
,
SLOT
(
slotKeyBindings
()),
this
);
Q
Action
*
keyBindings
=
KStandardAction
::
keyBindings
(
this
,
SLOT
(
slotKeyBindings
()),
this
);
mActionCollection
->
addAction
(
QLatin1String
(
"key_bindings"
),
keyBindings
);
mMenu
->
addAction
(
keyBindings
);
K
Action
*
preferences
=
KStandardAction
::
preferences
(
this
,
SLOT
(
slotPreferences
()),
this
);
Q
Action
*
preferences
=
KStandardAction
::
preferences
(
this
,
SLOT
(
slotPreferences
()),
this
);
mActionCollection
->
addAction
(
QLatin1String
(
"preferences"
),
preferences
);
mMenu
->
addAction
(
preferences
);
mMenu
->
addSeparator
();
K
Action
*
copyColorAction
=
KStandardAction
::
copy
(
this
,
SLOT
(
copyColor
()),
this
);
Q
Action
*
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
,
K
Global
::
mainComponent
().
about
Data
(),
true
)
)
->
menu
()
);
mMenu
->
addMenu
(
(
new
KHelpMenu
(
this
,
K
AboutData
::
application
Data
(),
true
)
)
->
menu
()
);
mMenu
->
addSeparator
();
if
(
RulerSettings
::
self
()
->
trayIcon
()
)
{
createSystemTray
();
}
KAction
*
quit
=
KStandardAction
::
quit
(
ka
pp
,
SLOT
(
quit
()),
this
);
QAction
*
quit
=
KStandardAction
::
quit
(
qA
pp
,
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
K
Action
(
icon
,
text
,
mActionCollection
);
action
->
setShortcut
(
shortcut
);
QAction
*
action
=
new
Q
Action
(
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
()
{
ka
pp
->
quit
();
qA
pp
->
quit
();
}
void
KLineal
::
move
(
int
x
,
int
y
)
...
...
@@ -388,7 +385,7 @@ void KLineal::setOrientation( int inOrientation )
r
.
moveTo
(
newTopLeft
);
QRect
desktop
=
KGlobalSettings
::
desktop
Geometry
(
this
);
QRect
desktop
=
QApplication
::
desktop
()
->
screen
Geometry
(
this
);
if
(
r
.
top
()
<
desktop
.
top
()
)
{
r
.
moveTop
(
desktop
.
top
()
);
...
...
@@ -482,7 +479,7 @@ void KLineal::reLength( int percentOfScreen )
return
;
}
QRect
r
=
KGlobalSettings
::
desktop
Geometry
(
this
);
QRect
r
=
QApplication
::
desktop
()
->
screen
Geometry
(
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
::
desktop
Geometry
(
this
);
QRect
r
=
QApplication
::
desktop
()
->
screen
Geometry
(
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
:
K
ToolInvocation
::
invokeHelp
();
K
HelpClient
::
invokeHelp
();
return
;
case
Qt
::
Key_Left
:
...
...
@@ -903,7 +900,7 @@ void KLineal::mouseMoveEvent( QMouseEvent *inEvent )
break
;
}
QColor
color
=
KColorDialog
::
grab
Color
(
p
);
QColor
color
=
pixel
Color
(
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
)));
}
klineal.h
View file @
21f1528e
...
...
@@ -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
;
K
Menu
*
mMenu
;
Q
Menu
*
mMenu
;
QAction
*
mCloseAction
;
K
Menu
*
mLenMenu
;
Q
Menu
*
mLenMenu
;
QAction
*
mFullScreenAction
;
QAction
*
mScaleDirectionAction
;
QAction
*
mCenterOriginAction
;
...
...
kruler.kcfg
View file @
21f1528e
...
...
@@ -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"
>
QFont
Database::systemFont(QFontDatabase::SmallestReadableFont
)
</default>
</entry>
<entry
name=
"Orientation"
type=
"Int"
>
<label>
Orientation of the ruler
</label>
...
...
krulersystemtray.cpp
View file @
21f1528e
...
...
@@ -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
()
);
K
Menu
*
cm
=
contextMenu
();
Q
Menu
*
cm
=
contextMenu
();
cm
->
addAction
(
actions
->
action
(
QLatin1String
(
"preferences"
)
)
);
}
krulersystemtray.h
View file @
21f1528e
...
...
@@ -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
{
...
...
main.cpp
View file @
21f1528e
...
...
@@ -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@tzi.de"
);
aboutData
.
addAuthor
(
ki18n
(
"Till Krech"
),
ki18n
(
"Former Maintainer and Developer"
),
"till@snafu.de"
);
aboutData
.
addCredit
(
ki18n
(
"Gunnstein Lye"
),
ki18n
(
"Initial port to KDE 2"
),
"gl@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@tzi.de"
);
aboutData
.
addAuthor
(
i18n
(
"Till Krech"
),
i18n
(
"Former Maintainer and Developer"
),
"till@snafu.de"
);
aboutData
.
addCredit
(
i18n
(
"Gunnstein Lye"
),
i18n
(
"Initial port to KDE 2"
),
"gl@ez.no"
);
KApplication
a
;
QApplication
a
(
argc
,
argv
);
KAboutData
::
setApplicationData
(
aboutData
);
KLineal
*
ruler
=
new
KLineal
();
ruler
->
show
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment