Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
KTimer
Commits
d2d66da6
Commit
d2d66da6
authored
Aug 19, 2022
by
Laurent Montel
Browse files
USe clang-format
parent
ead21986
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
ktimer.cpp
View file @
d2d66da6
This diff is collapsed.
Click to expand it.
ktimer.h
View file @
d2d66da6
...
...
@@ -19,19 +19,20 @@
#ifndef KTIMER_H_INCLUDED
#define KTIMER_H_INCLUDED
#include
"ui_prefwidget.h"
#include
<QDialog>
#include
<QWidget>
#include
<QProcess>
#include
"ui_prefw
idget
.h"
#include
<QW
idget
>
class
QTreeWidgetItem
;
class
KConfig
;
class
KTimerJob
:
public
QObject
{
Q_OBJECT
class
KTimerJob
:
public
QObject
{
Q_OBJECT
public:
explicit
KTimerJob
(
QObject
*
parent
=
nullptr
);
public:
explicit
KTimerJob
(
QObject
*
parent
=
nullptr
);
~
KTimerJob
()
override
;
enum
States
{
Stopped
,
Paused
,
Started
};
...
...
@@ -44,83 +45,81 @@ class KTimerJob : public QObject {
unsigned
value
()
const
;
States
state
()
const
;
void
*
user
();
void
setUser
(
void
*
user
);
void
load
(
KConfig
*
cfg
,
const
QString
&
grp
);
void
save
(
KConfig
*
cfg
,
const
QString
&
grp
);
QString
formatTime
(
int
seconds
)
const
;
int
timeToSeconds
(
int
hours
,
int
minutes
,
int
seconds
)
const
;
void
secondsToHMS
(
int
secs
,
int
*
hours
,
int
*
minutes
,
int
*
seconds
)
const
;
public
Q_SLOTS
:
void
setDelay
(
unsigned
int
sec
);
void
setDelay
(
int
sec
);
void
setCommand
(
const
QString
&
cmd
);
void
setLoop
(
bool
loop
);
void
setOneInstance
(
bool
one
);
void
setConsecutive
(
bool
consecutive
);
void
setValue
(
unsigned
int
value
);
void
setValue
(
int
value
);
void
setState
(
KTimerJob
::
States
state
);
void
setUser
(
void
*
user
);
void
load
(
KConfig
*
cfg
,
const
QString
&
grp
);
void
save
(
KConfig
*
cfg
,
const
QString
&
grp
);
QString
formatTime
(
int
seconds
)
const
;
int
timeToSeconds
(
int
hours
,
int
minutes
,
int
seconds
)
const
;
void
secondsToHMS
(
int
secs
,
int
*
hours
,
int
*
minutes
,
int
*
seconds
)
const
;
public
Q_SLOTS
:
void
setDelay
(
unsigned
int
sec
);
void
setDelay
(
int
sec
);
void
setCommand
(
const
QString
&
cmd
);
void
setLoop
(
bool
loop
);
void
setOneInstance
(
bool
one
);
void
setConsecutive
(
bool
consecutive
);
void
setValue
(
unsigned
int
value
);
void
setValue
(
int
value
);
void
setState
(
KTimerJob
::
States
state
);
void
pause
();
void
stop
();
void
start
();
Q_SIGNALS:
void
stateChanged
(
KTimerJob
*
job
,
KTimerJob
::
States
state
);
void
delayChanged
(
KTimerJob
*
job
,
unsigned
int
sec
);
void
commandChanged
(
KTimerJob
*
job
,
const
QString
&
cmd
);
void
loopChanged
(
KTimerJob
*
job
,
bool
loop
);
void
oneInstanceChanged
(
KTimerJob
*
job
,
bool
one
);
void
consecutiveChanged
(
KTimerJob
*
job
,
bool
consecutive
);
void
valueChanged
(
KTimerJob
*
job
,
unsigned
int
value
);
void
changed
(
KTimerJob
*
job
);
void
fired
(
KTimerJob
*
job
);
void
finished
(
KTimerJob
*
job
,
bool
error
);
void
error
(
KTimerJob
*
job
);
protected
Q_SLOTS
:
Q_SIGNALS:
void
stateChanged
(
KTimerJob
*
job
,
KTimerJob
::
States
state
);
void
delayChanged
(
KTimerJob
*
job
,
unsigned
int
sec
);
void
commandChanged
(
KTimerJob
*
job
,
const
QString
&
cmd
);
void
loopChanged
(
KTimerJob
*
job
,
bool
loop
);
void
oneInstanceChanged
(
KTimerJob
*
job
,
bool
one
);
void
consecutiveChanged
(
KTimerJob
*
job
,
bool
consecutive
);
void
valueChanged
(
KTimerJob
*
job
,
unsigned
int
value
);
void
changed
(
KTimerJob
*
job
);
void
fired
(
KTimerJob
*
job
);
void
finished
(
KTimerJob
*
job
,
bool
error
);
void
error
(
KTimerJob
*
job
);
protected
Q_SLOTS
:
virtual
void
fire
();
private
Q_SLOTS
:
private
Q_SLOTS
:
void
timeout
();
void
processExited
(
int
,
QProcess
::
ExitStatus
);
private:
private:
struct
KTimerJobPrivate
*
d
;
};
class
KTimerPref
:
public
QDialog
,
public
Ui
::
PrefWidget
{
Q_OBJECT
public:
explicit
KTimerPref
(
QWidget
*
parent
=
nullptr
);
public:
explicit
KTimerPref
(
QWidget
*
parent
=
nullptr
);
~
KTimerPref
()
override
;
public
Q_SLOTS
:
public
Q_SLOTS
:
void
exit
();
void
done
(
int
result
)
Q_DECL_OVERRIDE
;
protected
Q_SLOTS
:
protected
Q_SLOTS
:
void
add
();
void
remove
();
void
help
();
void
currentChanged
(
QTreeWidgetItem
*
,
QTreeWidgetItem
*
);
void
currentChanged
(
QTreeWidgetItem
*
,
QTreeWidgetItem
*
);
void
saveJobs
(
KConfig
*
cfg
);
void
loadJobs
(
KConfig
*
cfg
);
void
saveJobs
(
KConfig
*
cfg
);
void
loadJobs
(
KConfig
*
cfg
);
void
saveAllJobs
();
private
Q_SLOTS
:
void
jobChanged
(
KTimerJob
*
job
);
void
jobFinished
(
KTimerJob
*
job
,
bool
error
);
private
Q_SLOTS
:
void
jobChanged
(
KTimerJob
*
job
);
void
jobFinished
(
KTimerJob
*
job
,
bool
error
);
void
delayChanged
();
private:
private:
struct
KTimerPrefPrivate
*
d
;
};
...
...
main.cpp
View file @
d2d66da6
...
...
@@ -16,18 +16,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include
"ktimer.h"
#include
<KAboutData>
#include
<
QApplication
>
#include
<
KDBusService
>
#include
<KLocalizedString>
#include
<QCommandLineParser>
#include
<Kdelibs4ConfigMigrator>
#include
<
KDBusService
>
#include
"ktimer.h"
#include
<
QApplication
>
#include
<QCommandLineParser>
#include
<config-ktimer.h>
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
QApplication
app
(
argc
,
argv
);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
...
...
@@ -41,18 +39,21 @@ int main( int argc, char **argv )
migrate
.
migrate
();
#endif
KLocalizedString
::
setApplicationDomain
(
"ktimer"
);
KAboutData
aboutData
(
QStringLiteral
(
"ktimer"
),
i18n
(
"KTimer"
),
QStringLiteral
(
KTIMER_VERSION
),
i18n
(
"KDE Timer"
),
KAboutLicense
::
GPL
,
i18n
(
"(c) 2001, Stefan Schimanski"
),
QStringLiteral
(
"https://utils.kde.org/projects/ktimer/"
));
aboutData
.
addAuthor
(
i18n
(
"Stefan Schimanski"
),
QString
(),
QStringLiteral
(
"schimmi@kde.org"
));
KAboutData
aboutData
(
QStringLiteral
(
"ktimer"
),
i18n
(
"KTimer"
),
QStringLiteral
(
KTIMER_VERSION
),
i18n
(
"KDE Timer"
),
KAboutLicense
::
GPL
,
i18n
(
"(c) 2001, Stefan Schimanski"
),
QStringLiteral
(
"https://utils.kde.org/projects/ktimer/"
));
aboutData
.
addAuthor
(
i18n
(
"Stefan Schimanski"
),
QString
(),
QStringLiteral
(
"schimmi@kde.org"
));
QCommandLineParser
parser
;
KAboutData
::
setApplicationData
(
aboutData
);
aboutData
.
setupCommandLine
(
&
parser
);
parser
.
process
(
app
);
aboutData
.
processCommandLine
(
&
parser
);
app
.
setQuitOnLastWindowClosed
(
false
);
app
.
setQuitOnLastWindowClosed
(
false
);
KDBusService
service
;
auto
timer
=
new
KTimerPref
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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