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
21ed0371
Commit
21ed0371
authored
Dec 14, 2008
by
Mathias Soeken
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New maintainer
svn path=/trunk/KDE/kdegraphics/kruler/; revision=896851
parent
92914828
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
69 deletions
+76
-69
klineal.cpp
klineal.cpp
+49
-46
klineal.h
klineal.h
+23
-20
main.cpp
main.cpp
+4
-3
No files found.
klineal.cpp
View file @
21ed0371
...
...
@@ -133,7 +133,7 @@ KLineal::KLineal( QWidget*parent )
mMenu
=
new
KMenu
(
this
);
mMenu
->
addTitle
(
i18n
(
"KRuler"
)
);
KMenu
*
oriMenu
=
new
KMenu
(
i18n
(
"&Orientation"
),
this
);
KMenu
*
oriMenu
=
new
KMenu
(
i18n
(
"&Orientation"
),
this
);
oriMenu
->
addAction
(
KIcon
(
"kruler-north"
),
i18nc
(
"Turn Kruler North"
,
"&North"
),
this
,
SLOT
(
setNorth
()
),
Qt
::
Key_N
);
...
...
@@ -176,13 +176,13 @@ KLineal::KLineal( QWidget*parent )
new
QShortcut
(
Qt
::
CTRL
+
Qt
::
Key_F
,
this
,
SLOT
(
setFullLength
()
)
);
mMenu
->
addMenu
(
mLenMenu
);
mMenu
->
addAction
(
KIcon
(
"preferences-desktop-color"
),
i18n
(
"&Choose Color..."
),
this
,
SLOT
(
choseColor
()
),
i18n
(
"&Choose Color..."
),
this
,
SLOT
(
cho
o
seColor
()
),
Qt
::
CTRL
+
Qt
::
Key_C
);
mMenu
->
addAction
(
KIcon
(
"preferences-desktop-font"
),
i18n
(
"Choose &Font..."
),
this
,
SLOT
(
choseFont
()
),
i18n
(
"Choose &Font..."
),
this
,
SLOT
(
cho
o
seFont
()
),
Qt
::
Key_F
);
new
QShortcut
(
Qt
::
CTRL
+
Qt
::
Key_C
,
this
,
SLOT
(
choseColor
()
)
);
new
QShortcut
(
Qt
::
Key_F
,
this
,
SLOT
(
choseFont
()
)
);
new
QShortcut
(
Qt
::
CTRL
+
Qt
::
Key_C
,
this
,
SLOT
(
cho
o
seColor
()
)
);
new
QShortcut
(
Qt
::
Key_F
,
this
,
SLOT
(
cho
o
seFont
()
)
);
mMenu
->
addSeparator
();
mMenu
->
addMenu
(
(
new
KHelpMenu
(
this
,
KGlobal
::
mainComponent
().
aboutData
(),
true
)
)
->
menu
()
);
mMenu
->
addSeparator
();
...
...
@@ -379,82 +379,85 @@ void KLineal::setTallLength() {
void
KLineal
::
setFullLength
()
{
reLength
(
100
);
}
void
KLineal
::
choseColor
()
{
QRect
r
=
KGlobalSettings
::
desktopGeometry
(
this
);
void
KLineal
::
chooseColor
()
{
QRect
r
=
KGlobalSettings
::
desktopGeometry
(
this
);
QPoint
pos
=
QCursor
::
pos
();
if
(
pos
.
x
()
+
mColorSelector
.
width
()
>
r
.
width
()
)
{
pos
.
setX
(
r
.
width
()
-
mColorSelector
.
width
()
);
if
(
pos
.
x
()
+
mColorSelector
.
width
()
>
r
.
width
()
)
{
pos
.
setX
(
r
.
width
()
-
mColorSelector
.
width
()
);
}
if
(
pos
.
y
()
+
mColorSelector
.
height
()
>
r
.
height
()
)
{
pos
.
setY
(
r
.
height
()
-
mColorSelector
.
height
()
);
if
(
pos
.
y
()
+
mColorSelector
.
height
()
>
r
.
height
()
)
{
pos
.
setY
(
r
.
height
()
-
mColorSelector
.
height
()
);
}
mStoredColor
=
mColor
;
mColorSelector
.
move
(
pos
);
mColorSelector
.
setColor
(
mColor
);
mColorSelector
.
move
(
pos
);
mColorSelector
.
setColor
(
mColor
);
mColorSelector
.
setDefaultColor
(
DEFAULT_RULER_COLOR
);
mColorSelector
.
show
();
connect
(
&
mColorSelector
,
SIGNAL
(
closeClicked
()),
this
,
SLOT
(
setColor
()));
connect
(
&
mColorSelector
,
SIGNAL
(
colorSelected
(
const
QColor
&
)),
this
,
SLOT
(
setColor
(
const
QColor
&
)));
/*
connect(&mColorSelector, SIGNAL(cancelPressed()), this, SLOT(restoreColor()));
connect(&mColorSelector, SIGNAL(okPressed()), this, SLOT(saveColor()));
*/
connect
(
&
mColorSelector
,
SIGNAL
(
closeClicked
()
),
this
,
SLOT
(
setColor
()
)
);
connect
(
&
mColorSelector
,
SIGNAL
(
colorSelected
(
const
QColor
&
)
),
this
,
SLOT
(
setColor
(
const
QColor
&
)
)
);
}
/**
* slot to choose a font
*/
void
KLineal
::
choseFont
()
{
* slot to choose a font
*/
void
KLineal
::
chooseFont
()
{
QFont
font
=
mScaleFont
;
int
result
=
KFontDialog
::
getFont
(
font
,
false
,
this
);
if
(
result
==
KFontDialog
::
Accepted
)
{
setFont
(
font
);
int
result
=
KFontDialog
::
getFont
(
font
,
false
,
this
);
if
(
result
==
KFontDialog
::
Accepted
)
{
setFont
(
font
);
}
}
/**
* set the ruler color to the previously selected color
*/
void
KLineal
::
setFont
(
QFont
&
font
)
{
mScaleFont
=
font
;
saveSettings
();
* set the ruler color to the previously selected color
*/
void
KLineal
::
setFont
(
const
QFont
&
font
)
{
mScaleFont
=
font
;
saveSettings
();
repaint
();
}
/**
* set the ruler color to the previously selected color
*/
* set the ruler color to the previously selected color
*/
void
KLineal
::
setColor
()
{
setColor
(
mColorSelector
.
color
()
);
saveSettings
();
setColor
(
mColorSelector
.
color
()
);
saveSettings
();
}
/**
* set the ruler color to some color
*/
* set the ruler color to some color
*/
void
KLineal
::
setColor
(
const
QColor
&
color
)
{
mColor
=
color
;
if
(
!
mColor
.
isValid
()
)
if
(
!
mColor
.
isValid
()
)
{
mColor
=
DEFAULT_RULER_COLOR
;
}
repaint
();
}
/**
* save the ruler color to the config file
*/
* save the ruler color to the config file
*/
void
KLineal
::
saveSettings
()
{
KSharedConfig
::
Ptr
cfg
=
KGlobal
::
config
();
// new KConfig(locateLocal("config", kapp->name()+"rc"));
if
(
cfg
)
{
QColor
color
=
mColor
;
KConfigGroup
cfgcg
(
cfg
,
CFG_GROUP_SETTINGS
);
cfgcg
.
writeEntry
(
QString
(
CFG_KEY_BGCOLOR
),
color
);
cfgcg
.
writeEntry
(
QString
(
CFG_KEY_SCALE_FONT
),
mScaleFont
);
cfgcg
.
writeEntry
(
QString
(
CFG_KEY_LENGTH
),
mLongEdgeLen
);
cfg
->
sync
();
if
(
cfg
)
{
QColor
color
=
mColor
;
KConfigGroup
cfgcg
(
cfg
,
CFG_GROUP_SETTINGS
);
cfgcg
.
writeEntry
(
QString
(
CFG_KEY_BGCOLOR
),
color
);
cfgcg
.
writeEntry
(
QString
(
CFG_KEY_SCALE_FONT
),
mScaleFont
);
cfgcg
.
writeEntry
(
QString
(
CFG_KEY_LENGTH
),
mLongEdgeLen
);
cfg
->
sync
();
}
}
...
...
klineal.h
View file @
21ed0371
...
...
@@ -27,31 +27,32 @@ class KMenu;
class
KLineal
:
public
QWidget
{
Q_OBJECT
public:
enum
{
North
=
0
,
West
=
1
,
South
=
2
,
East
=
3
};
enum
{
North
=
0
,
West
,
South
,
East
};
/** constructor */
KLineal
(
QWidget
*
parent
=
0
);
KLineal
(
QWidget
*
parent
=
0
);
/** destructor */
~
KLineal
();
void
move
(
int
x
,
int
y
);
void
move
(
const
QPoint
&
p
);
void
move
(
int
x
,
int
y
);
void
move
(
const
QPoint
&
p
);
QPoint
pos
();
int
x
();
int
y
();
protected:
void
keyPressEvent
(
QKeyEvent
*
e
);
void
mousePressEvent
(
QMouseEvent
*
e
);
void
mouseReleaseEvent
(
QMouseEvent
*
e
);
void
mouseMoveEvent
(
QMouseEvent
*
e
);
void
paintEvent
(
QPaintEvent
*
e
);
void
enterEvent
(
QEvent
*
e
);
void
leaveEvent
(
QEvent
*
e
);
protected:
void
keyPressEvent
(
QKeyEvent
*
e
);
void
mousePressEvent
(
QMouseEvent
*
e
);
void
mouseReleaseEvent
(
QMouseEvent
*
e
);
void
mouseMoveEvent
(
QMouseEvent
*
e
);
void
paintEvent
(
QPaintEvent
*
e
);
void
enterEvent
(
QEvent
*
e
);
void
leaveEvent
(
QEvent
*
e
);
private:
void
drawScale
(
QPainter
&
painter
);
void
drawBackground
(
QPainter
&
painter
);
void
reLength
(
int
percentOfScreen
);
void
drawScale
(
QPainter
&
painter
);
void
drawBackground
(
QPainter
&
painter
);
void
reLength
(
int
percentOfScreen
);
bool
mDragging
;
QPoint
mLastClickPos
;
QPoint
mDragOffset
;
...
...
@@ -74,8 +75,9 @@ private:
KColorDialog
mColorSelector
;
QFont
mScaleFont
;
bool
_clicked
;
public
slots
:
void
setOrientation
(
int
);
void
setOrientation
(
int
inOrientation
);
void
setNorth
();
void
setEast
();
void
setSouth
();
...
...
@@ -91,12 +93,13 @@ public slots:
void
setTallLength
();
void
setFullLength
();
void
setColor
();
void
setFont
(
QFont
&
);
void
setColor
(
const
QColor
&
color
);
void
choseColor
();
void
choseFont
();
void
setFont
(
const
QFont
&
font
);
void
setColor
(
const
QColor
&
color
);
void
cho
o
seColor
();
void
cho
o
seFont
();
void
restoreColor
();
void
saveSettings
();
void
slotQuit
();
};
#endif
main.cpp
View file @
21ed0371
...
...
@@ -28,9 +28,10 @@ int main(int argc, char *argv[])
KDE_VERSION_STRING
,
ki18n
(
"A screen ruler for the K Desktop Environment"
),
KAboutData
::
License_GPL
,
ki18n
(
"(c) 2000, Till Krech"
));
aboutData
.
addAuthor
(
ki18n
(
"Till Krech"
),
ki18n
(
"Programming"
),
"till@snafu.de"
);
aboutData
.
addCredit
(
ki18n
(
"Gunnstein Lye"
),
ki18n
(
"Initial port to KDE 2"
),
"gl@ez.no"
);
ki18n
(
"(c) 2008, Mathias Soeken
\n
(c) 2000 - 2008, Till Krech"
)
);
aboutData
.
addAuthor
(
ki18n
(
"Mathias Soeken"
),
ki18n
(
"Maintainer"
),
"msoeken@informatik.uni-bremen.de"
);
aboutData
.
addAuthor
(
ki18n
(
"Till Krech"
),
ki18n
(
"Former Maintainer/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
;
...
...
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