The attached patch applies to the directory kdeplasma-addons/applets/timer of trunk.
This patch adds functionality to the Plasma Applet Timer so that the user can set a title for each timer. This is as per the feature request Bug# 183673. The applet has been tested for proper functionality, and here's the screenshot - http://www.shantanutushar.com/screenshots/plasma-applet-timer-1.jpg . I've made few minor changes to the UI file timerConfig.ui using Qt4 designer, so that the configuration page "General" looks better. Hope its fine :) -- Shantanu Tushar http://www.shantanutushar.com
Index: timer.cpp =================================================================== --- timer.cpp (revision 929557) +++ timer.cpp (working copy) @@ -43,7 +43,8 @@ Timer::Timer(QObject *parent, const QVariantList &args) : Plasma::Applet(parent, args), m_seconds(), - m_running(false) + m_running(false), + m_title("Timer") { resize(315, 125); setHasConfigurationInterface(true); @@ -66,6 +67,8 @@ << "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", true); + m_title = cg.readEntry("title", i18n("Timer")); m_showMessage = cg.readEntry("showMessage", true); m_message = cg.readEntry("message", i18n("Timer Timeout")); m_runCommand = cg.readEntry("runCommand", false); @@ -145,12 +148,13 @@ connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted())); connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted())); + ui.showTitleCheckBox->setChecked(m_showTitle); + ui.titleLineEdit->setEnabled(m_showTitle); + ui.titleLineEdit->setText(m_title); ui.showMessageCheckBox->setChecked(m_showMessage); - ui.messageLabel->setEnabled(m_showMessage); ui.messageLineEdit->setEnabled(m_showMessage); ui.messageLineEdit->setText(m_message); ui.runCommandCheckBox->setChecked(m_runCommand); - ui.commandLabel->setEnabled(m_runCommand); ui.commandLineEdit->setEnabled(m_runCommand); ui.commandLineEdit->setText(m_command); @@ -170,6 +174,12 @@ } cg.writePathEntry("predefinedTimers", unlocalizedTimers); + m_showTitle = ui.showTitleCheckBox->isChecked(); + cg.writeEntry("showTitle", m_showTitle); + + m_title = ui.titleLineEdit->text(); + cg.writeEntry("title", m_title); + m_showMessage = ui.showMessageCheckBox->isChecked(); cg.writeEntry("showMessage", m_showMessage); @@ -208,7 +218,10 @@ { if (m_showMessage){ //TODO: probably something with an OK button is better. - KNotification::event(KNotification::Notification, m_message); + if (m_showTitle) + KNotification::event(KNotification::Notification, m_title + " - " + m_message); + else + KNotification::event(KNotification::Notification, m_message); } if (m_runCommand && !m_command.isEmpty()){ @@ -368,6 +381,18 @@ 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); + + //Draw the title + QFont font = this->font(); + font.setPixelSize( y - 6 ); // Minor + QRect rectText( 0, 4, appletWidth, y - 2 ); // adjustments + p->save(); + p->setFont( font ); + p->setPen(Qt::white); + p->drawText(rectText, + Qt::AlignTop | Qt::AlignHCenter, + m_title); + p->restore(); } #include "timer.moc" Index: timerConfig.ui =================================================================== --- timerConfig.ui (revision 929557) +++ timerConfig.ui (working copy) @@ -1,7 +1,8 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <class>timerConfig</class> - <widget class="QWidget" name="timerConfig" > - <property name="geometry" > + <widget class="QWidget" name="timerConfig"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> @@ -9,98 +10,56 @@ <height>156</height> </rect> </property> - <layout class="QGridLayout" name="gridLayout" > - <item row="0" column="0" colspan="3" > - <widget class="QLabel" name="label" > - <property name="font" > + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QCheckBox" name="showTitleCheckBox"> + <property name="text"> + <string>Show Title</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="KLineEdit" name="titleLineEdit"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label"> + <property name="font"> <font> <weight>75</weight> <bold>true</bold> </font> </property> - <property name="text" > + <property name="text"> <string>Actions on Timeout</string> </property> </widget> </item> - <item row="2" column="3" > - <widget class="KLineEdit" name="messageLineEdit" /> - </item> - <item row="3" column="1" colspan="2" > - <widget class="QCheckBox" name="runCommandCheckBox" > - <property name="text" > - <string>Run a command</string> + <item row="2" column="0"> + <widget class="QCheckBox" name="showMessageCheckBox"> + <property name="text"> + <string>Show a message</string> </property> </widget> </item> - <item row="4" column="2" > - <widget class="QLabel" name="commandLabel" > - <property name="text" > - <string>Command:</string> - </property> - <property name="alignment" > - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> + <item row="2" column="1"> + <widget class="KLineEdit" name="messageLineEdit"/> </item> - <item row="4" column="3" > - <widget class="KLineEdit" name="commandLineEdit" /> - </item> - <item row="2" column="2" > - <widget class="QLabel" name="messageLabel" > - <property name="text" > - <string>Message:</string> + <item row="3" column="0"> + <widget class="QCheckBox" name="runCommandCheckBox"> + <property name="text"> + <string>Run a command</string> </property> - <property name="alignment" > - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> </widget> </item> - <item row="1" column="1" colspan="2" > - <widget class="QCheckBox" name="showMessageCheckBox" > - <property name="text" > - <string>Show a message</string> - </property> - </widget> + <item row="3" column="1"> + <widget class="KLineEdit" name="commandLineEdit"/> </item> - <item row="1" column="0" > - <spacer name="horizontalSpacer" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="1" > - <spacer name="horizontalSpacer_2" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="5" column="3" > - <spacer name="verticalSpacer" > - <property name="orientation" > + <item row="4" column="1"> + <spacer name="verticalSpacer"> + <property name="orientation"> <enum>Qt::Vertical</enum> </property> - <property name="sizeHint" stdset="0" > + <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>40</height> @@ -125,61 +84,45 @@ <receiver>messageLineEdit</receiver> <slot>setEnabled(bool)</slot> <hints> - <hint type="sourcelabel" > - <x>300</x> - <y>228</y> + <hint type="sourcelabel"> + <x>154</x> + <y>82</y> </hint> - <hint type="destinationlabel" > - <x>341</x> - <y>258</y> + <hint type="destinationlabel"> + <x>393</x> + <y>85</y> </hint> </hints> </connection> <connection> - <sender>showMessageCheckBox</sender> - <signal>toggled(bool)</signal> - <receiver>messageLabel</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel" > - <x>300</x> - <y>228</y> - </hint> - <hint type="destinationlabel" > - <x>64</x> - <y>258</y> - </hint> - </hints> - </connection> - <connection> <sender>runCommandCheckBox</sender> <signal>toggled(bool)</signal> <receiver>commandLineEdit</receiver> <slot>setEnabled(bool)</slot> <hints> - <hint type="sourcelabel" > - <x>300</x> - <y>310</y> + <hint type="sourcelabel"> + <x>154</x> + <y>114</y> </hint> - <hint type="destinationlabel" > - <x>343</x> - <y>340</y> + <hint type="destinationlabel"> + <x>393</x> + <y>117</y> </hint> </hints> </connection> <connection> - <sender>runCommandCheckBox</sender> + <sender>showTitleCheckBox</sender> <signal>toggled(bool)</signal> - <receiver>commandLabel</receiver> + <receiver>titleLineEdit</receiver> <slot>setEnabled(bool)</slot> <hints> - <hint type="sourcelabel" > - <x>300</x> - <y>310</y> + <hint type="sourcelabel"> + <x>52</x> + <y>14</y> </hint> - <hint type="destinationlabel" > - <x>66</x> - <y>340</y> + <hint type="destinationlabel"> + <x>177</x> + <y>17</y> </hint> </hints> </connection> Index: timer.h =================================================================== --- timer.h (revision 929557) +++ timer.h (working copy) @@ -73,6 +73,8 @@ Ui::timerConfig ui; QStringList m_predefinedTimers; + bool m_showTitle; + QString m_title; bool m_showMessage; QString m_message; bool m_runCommand;
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel