[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeplasma-addons/applets/timer
From: Anne-Marie Mahfouf <annma () kde ! org>
Date: 2010-09-06 19:22:40
Message-ID: 20100906192240.4BEACAC884 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1172232 by annma:
implement configChanged()
M +38 -30 timer.cpp
M +10 -0 timer.h
--- trunk/KDE/kdeplasma-addons/applets/timer/timer.cpp #1172231:1172232
@@ -53,6 +53,7 @@
void Timer::init()
{
+ configChanged();
m_svg = new Plasma::Svg(this);
m_svg->setImagePath("widgets/timer");
m_svg->setContainsMultipleImages(true);
@@ -77,6 +78,13 @@
m_title = new Plasma::Label(this);
m_title->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
+ m_title->setVisible(m_showTitle);
+ m_title->setText(m_timerTitle);
+
+ m_secondsDigit[0]->setVisible(!m_hideSeconds);
+ m_secondsDigit[1]->setVisible(!m_hideSeconds);
+ m_separator[1]->setVisible(!m_hideSeconds);
+
connect(m_hoursDigit[0], SIGNAL(changed(int)), this, SLOT(digitChanged(int)));
connect(m_hoursDigit[1], SIGNAL(changed(int)), this, SLOT(digitChanged(int)));
connect(m_minutesDigit[0], SIGNAL(changed(int)), this, SLOT(digitChanged(int)));
@@ -84,32 +92,6 @@
connect(m_secondsDigit[0], SIGNAL(changed(int)), this, SLOT(digitChanged(int)));
connect(m_secondsDigit[1], SIGNAL(changed(int)), this, SLOT(digitChanged(int)));
- KConfigGroup cg = config();
- m_predefinedTimers = cg.readEntry("predefinedTimers", QStringList() << "00:00:30" << "00:01:00"
- << "00:02:00" << "00:05:00" << "00:07:30"
- << "00:10:00" << "00:15:00" << "00:20:00"
- << "00:25:00" << "00:30:00" << "00:45:00"
- << "01:00:00");
- m_title->setVisible(cg.readEntry("showTitle", false));
- m_title->setText(cg.readEntry("title", i18n("Timer")));
-
- bool hideSeconds = cg.readEntry("hideSeconds", false);
- m_secondsDigit[0]->setVisible(!hideSeconds);
- m_secondsDigit[1]->setVisible(!hideSeconds);
- m_separator[1]->setVisible(!hideSeconds);
-
- m_showMessage = cg.readEntry("showMessage", true);
- m_message = cg.readEntry("message", i18n("Timer Timeout"));
- m_runCommand = cg.readEntry("runCommand", false);
- m_command = cg.readEntry("command", "");
-
- // Timers are kept non-localized in the config, to work across language changes.
- QStringList localizedTimers;
- foreach (const QString &timer, m_predefinedTimers) {
- localizedTimers.append(CustomTimeEditor::toLocalizedTimer(timer));
- }
- m_predefinedTimers = localizedTimers;
-
connect(&timer, SIGNAL(timeout()), this, SLOT(updateTimer()));
m_startAction = new QAction(i18n("Start"), this);
@@ -125,12 +107,9 @@
connect(m_resetAction, SIGNAL(triggered(bool)), this, SLOT(resetTimer()));
createMenuAction();
- int running = cg.readEntry("running", 0);
m_running = running > 0;
- m_startingSeconds = cg.readEntry("seconds", 0);
if (m_running) {
- QDateTime startedAt = cg.readEntry("startedAt", QDateTime::currentDateTime());
- int tmpSeconds = running - startedAt.secsTo(QDateTime::currentDateTime());
+ int tmpSeconds = running - m_startedAt.secsTo(QDateTime::currentDateTime());
if (tmpSeconds > 0){
setSeconds(tmpSeconds);
startTimer();
@@ -147,6 +126,35 @@
}
}
+void Timer::configChanged()
+{
+ KConfigGroup cg = config();
+ m_predefinedTimers = cg.readEntry("predefinedTimers", QStringList() << "00:00:30" << "00:01:00"
+ << "00:02:00" << "00:05:00" << "00:07:30"
+ << "00:10:00" << "00:15:00" << "00:20:00"
+ << "00:25:00" << "00:30:00" << "00:45:00"
+ << "01:00:00");
+ m_showTitle = cg.readEntry("showTitle", false);
+ m_timerTitle = cg.readEntry("title", i18n("Timer"));
+ m_hideSeconds = cg.readEntry("hideSeconds", false);
+ m_showMessage = cg.readEntry("showMessage", true);
+ m_message = cg.readEntry("message", i18n("Timer Timeout"));
+ m_runCommand = cg.readEntry("runCommand", false);
+ m_command = cg.readEntry("command", "");
+
+ // Timers are kept non-localized in the config, to work across language changes.
+ QStringList localizedTimers;
+ foreach (const QString &timer, m_predefinedTimers) {
+ localizedTimers.append(CustomTimeEditor::toLocalizedTimer(timer));
+ }
+ m_predefinedTimers = localizedTimers;
+
+ m_startedAt = cg.readEntry("startedAt", QDateTime::currentDateTime());
+
+ running = cg.readEntry("running", 0);
+ m_startingSeconds = cg.readEntry("seconds", 0);
+}
+
void Timer::constraintsEvent(Plasma::Constraints constraints)
{
Q_UNUSED(constraints)
--- trunk/KDE/kdeplasma-addons/applets/timer/timer.h #1172231:1172232
@@ -54,6 +54,10 @@
void createConfigurationInterface(KConfigDialog *parent);
void createMenuAction();
void constraintsEvent(Plasma::Constraints constraints);
+
+ public slots:
+ void configChanged();
+
private slots:
void updateTimer();
void slotCountDone();
@@ -93,6 +97,12 @@
QList<QAction *>actions;
QActionGroup *lstActionTimer;
QString m_separatorBasename;
+ QDateTime m_startedAt;
+ int running;
+ bool m_showTitle;
+ QString m_timerTitle;
+ bool m_hideSeconds;
+
protected slots:
void configAccepted();
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic