[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdeplasma-addons/applets/timer
From: Davide Bettio <davide.bettio () kdemail ! net>
Date: 2008-12-09 16:44:49
Message-ID: 1228841089.439334.9665.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 894927 by bettio:
Separators are localized, thanks to Chusslove Illich.
M +45 -2 customtimeeditor.cpp
M +3 -0 customtimeeditor.h
M +24 -4 timer.cpp
M +1 -0 timer.h
M +98 -3 timer.svg
--- trunk/KDE/kdeplasma-addons/applets/timer/customtimeeditor.cpp #894926:894927
@@ -20,6 +20,7 @@
#include "customtimeeditor.h"
#include <QTimeEdit>
#include <klineedit.h>
+#include <klocale.h>
const QString CustomTimeEditor::TIME_FORMAT("hh:mm:ss");
@@ -27,7 +28,7 @@
: QObject()
{
timeEdit=new QTimeEdit();
- timeEdit->setDisplayFormat(TIME_FORMAT);
+ timeEdit->setDisplayFormat(toLocalizedTimer(TIME_FORMAT));
editor=new KLineEdit();
customEditor=new KEditListBox::CustomEditor(timeEdit, editor);
connect(timeEdit, SIGNAL(timeChanged( const QTime& )), this, SLOT(setEdit(const \
QTime&) )); @@ -49,7 +50,7 @@
*/
void CustomTimeEditor::setEdit(const QTime &time)
{
- editor->setText(time.toString() );
+ editor->setText(toLocalizedTimer(time.toString()));
}
#include "customtimeeditor.moc"
@@ -61,3 +62,45 @@
{
return customEditor;
}
+
+/*!
+ \fn CustomTimeEditor::timerSeparator()
+ */
+QString CustomTimeEditor::timerSeparator()
+{
+ return i18nc("separator of hours:minutes:seconds in timer strings", ":");
+}
+
+/*!
+ \fn CustomTimeEditor::toLocalizedTimer(const QString &timer)
+ */
+QString CustomTimeEditor::toLocalizedTimer(const QString &timer)
+{
+ QString separator = timerSeparator();
+ int p1 = timer.indexOf(':');
+ if (p1 < 0) {
+ return timer;
+ }
+ int p2 = timer.indexOf(':', p1 + 1);
+ if (p2 < 0) {
+ return timer;
+ }
+ return timer.left(p1) + separator + timer.mid(p1 + 1, p2 - p1 - 1) + separator + \
timer.mid(p2 + 1); +}
+
+/*!
+ \fn CustomTimeEditor::fromLocalizedTimer(const QString &timer)
+ */
+QString CustomTimeEditor::fromLocalizedTimer(const QString &timer)
+{
+ QString separator = timerSeparator();
+ int p1 = timer.indexOf(separator);
+ if (p1 < 0) {
+ return timer;
+ }
+ int p2 = timer.indexOf(separator, p1 + 1);
+ if (p2 < 0) {
+ return timer;
+ }
+ return timer.left(p1) + ':' + timer.mid(p1 + 1, p2 - p1 - 1) + ':' + \
timer.mid(p2 + 1); +}
--- trunk/KDE/kdeplasma-addons/applets/timer/customtimeeditor.h #894926:894927
@@ -36,6 +36,9 @@
~CustomTimeEditor();
KEditListBox::CustomEditor *getCustomEditor();
+ static QString timerSeparator();
+ static QString toLocalizedTimer(const QString &timer);
+ static QString fromLocalizedTimer(const QString &timer);
static const QString TIME_FORMAT;
private:
QTimeEdit* timeEdit;
--- trunk/KDE/kdeplasma-addons/applets/timer/timer.cpp #894926:894927
@@ -71,6 +71,22 @@
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 (QString timer, m_predefinedTimers) {
+ localizedTimers.append(CustomTimeEditor::toLocalizedTimer(timer));
+ }
+ m_predefinedTimers = localizedTimers;
+
+ // Choose graphical separator based on the text one.
+ m_separatorBasename = QString("separator");
+ QString textSeparator = CustomTimeEditor::timerSeparator().remove(' ');
+ if (textSeparator == QString('.')) {
+ m_separatorBasename += 'B';
+ } else if (textSeparator == QString(' ')) {
+ m_separatorBasename += 'C';
+ }
+
connect(&timer, SIGNAL(timeout()), this, SLOT(updateTimer()));
m_startAction = new QAction(i18n("Start"), this);
@@ -106,7 +122,7 @@
lstActionTimer = new QActionGroup(this);
for (QStringList::const_iterator it = m_predefinedTimers.constBegin(); it != \
end; ++it) { action = new QAction(*it, this);
- action->setProperty("seconds", QTime(0, 0, 0).secsTo(QTime::fromString(*it, \
CustomTimeEditor::TIME_FORMAT))); + action->setProperty("seconds", QTime(0, 0, \
0).secsTo(QTime::fromString(*it, \
CustomTimeEditor::toLocalizedTimer(CustomTimeEditor::TIME_FORMAT)))); \
lstActionTimer->addAction(action);
connect(action, SIGNAL(triggered(bool)), this, \
SLOT(startTimerFromAction())); actions.append(action);
@@ -148,7 +164,11 @@
KConfigGroup cg = config();
m_predefinedTimers = predefinedTimersUi.defaulttimers->items();
- cg.writePathEntry("predefinedTimers", m_predefinedTimers);
+ QStringList unlocalizedTimers;
+ foreach (QString timer, m_predefinedTimers) {
+ unlocalizedTimers.append(CustomTimeEditor::fromLocalizedTimer(timer));
+ }
+ cg.writePathEntry("predefinedTimers", unlocalizedTimers);
m_showMessage = ui.showMessageCheckBox->isChecked();
cg.writeEntry("showMessage", m_showMessage);
@@ -339,12 +359,12 @@
m_svg->paint(p, QRectF(x, y, w, h), QString::number(hours / 10) + suffix);
m_svg->paint(p, QRectF(x + w, y, w, h), QString::number(hours % 10) + suffix);
- m_svg->paint(p, QRectF(x + (w * 2), y, w/2, h), "separator" + suffix);
+ m_svg->paint(p, QRectF(x + (w * 2), y, w/2, h), m_separatorBasename + suffix);
m_svg->paint(p, QRectF(x + (w * 2) + (w/2), y, w, h), QString::number(mins / 10) \
+ suffix);
m_svg->paint(p, QRectF(x + (w * 3) + (w/2), y, w, h), QString::number(mins % 10) \
+ suffix);
- m_svg->paint(p, QRectF(x + (w * 4) + (w/2), y, w/2, h), "separator" + suffix);
+ m_svg->paint(p, QRectF(x + (w * 4) + (w/2), y, w/2, h), m_separatorBasename + \
suffix);
m_svg->paint(p, QRectF(x + (w * 5), y, w, h), QString::number(seconds / 10) + \
suffix);
m_svg->paint(p, QRectF(x + (w * 6), y, w, h), QString::number(seconds % 10) + \
suffix);
--- trunk/KDE/kdeplasma-addons/applets/timer/timer.h #894926:894927
@@ -79,6 +79,7 @@
QString m_command;
QList<QAction *>actions;
QActionGroup *lstActionTimer;
+ QString m_separatorBasename;
protected slots:
void configAccepted();
};
--- trunk/KDE/kdeplasma-addons/applets/timer/timer.svg #894926:894927
@@ -2,7 +2,7 @@
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:cc="http://web.resource.org/cc/"
+ xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
@@ -13,12 +13,19 @@
height="1052.3622047"
id="svg2"
sodipodi:version="0.32"
- inkscape:version="0.45.1"
+ inkscape:version="0.46"
sodipodi:docname="timer.svg"
sodipodi:docbase="/home/kde-devel/working/playground/base/plasma/applets/timer"
inkscape:output_extension="org.inkscape.output.svg.inkscape">
<defs
id="defs4">
+ <inkscape:perspective
+ sodipodi:type="inkscape:persp3d"
+ inkscape:vp_x="0 : 526.18109 : 1"
+ inkscape:vp_y="0 : 1000 : 0"
+ inkscape:vp_z="744.09448 : 526.18109 : 1"
+ inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
+ id="perspective172" />
<linearGradient
id="linearGradient3493">
<stop
@@ -507,7 +514,7 @@
inkscape:cx="372.04724"
inkscape:cy="346.32616"
inkscape:document-units="px"
- inkscape:current-layer="separator_1"
+ inkscape:current-layer="layer1"
showgrid="true"
showguides="true"
inkscape:guide-bbox="true"
@@ -1165,5 +1172,93 @@
x="199.02405"
sodipodi:role="line">:</tspan></text>
</g>
+ <g
+ id="separatorB_1"
+ inkscape:label="#g3536"
+ transform="translate(-134.80315,175.1705)">
+ <rect
+ y="324.28006"
+ x="200"
+ height="163.08212"
+ width="45"
+ id="rect2561"
+ style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-opacity:1" />
+ <text
+ id="text2563"
+ y="442.08881"
+ x="199.02405"
+ style="font-size:144px;font-style:normal;font-weight:normal;fill:#eb0000;fil \
l-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream \
Vera Sans" + xml:space="preserve"><tspan
+ id="tspan2565"
+ y="442.08881"
+ x="199.02405"
+ sodipodi:role="line">.</tspan></text>
+ </g>
+ <g
+ id="separatorB"
+ inkscape:label="#g3536"
+ transform="translate(-196.19095,181.74775)">
+ <rect
+ y="324.28006"
+ x="200"
+ height="163.08212"
+ width="45"
+ id="rect2569"
+ style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-opacity:1" />
+ <text
+ id="text2571"
+ y="442.08881"
+ x="199.02405"
+ style="font-size:144px;font-style:normal;font-weight:normal;fill:#ebebeb;fil \
l-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream \
Vera Sans" + xml:space="preserve"><tspan
+ id="tspan2573"
+ y="442.08881"
+ x="199.02405"
+ sodipodi:role="line">.</tspan></text>
+ </g>
+ <g
+ id="separatorC"
+ inkscape:label="#g3536"
+ transform="translate(-193.99853,354.94902)">
+ <rect
+ y="324.28006"
+ x="200"
+ height="163.08212"
+ width="45"
+ id="rect2577"
+ style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-opacity:1" />
+ <text
+ id="text2579"
+ y="442.08881"
+ x="199.02405"
+ style="font-size:144px;font-style:normal;font-weight:normal;fill:#ebebeb;fil \
l-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream \
Vera Sans" + xml:space="preserve"><tspan
+ id="tspan2581"
+ y="442.08881"
+ x="199.02405"
+ sodipodi:role="line"> </tspan></text>
+ </g>
+ <g
+ id="separatorC_1"
+ inkscape:label="#g3536"
+ transform="translate(-134.80314,350.56418)">
+ <rect
+ y="324.28006"
+ x="200"
+ height="163.08212"
+ width="45"
+ id="rect2585"
+ style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-opacity:1" />
+ <text
+ id="text2587"
+ y="442.08881"
+ x="199.02405"
+ style="font-size:144px;font-style:normal;font-weight:normal;fill:#eb0000;fil \
l-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Bitstream \
Vera Sans" + xml:space="preserve"><tspan
+ id="tspan2589"
+ y="442.08881"
+ x="199.02405"
+ sodipodi:role="line"> </tspan></text>
+ </g>
</g>
</svg>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic