summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/kteatime/index.docbook4
-rw-r--r--kteatime/main.cpp1
-rw-r--r--kteatime/toplevel.cpp74
-rw-r--r--kteatime/toplevel.h29
4 files changed, 68 insertions, 40 deletions
diff --git a/doc/kteatime/index.docbook b/doc/kteatime/index.docbook
index 0d4f0f9..c75912e 100644
--- a/doc/kteatime/index.docbook
+++ b/doc/kteatime/index.docbook
@@ -68,7 +68,7 @@
<sect1 id="timing-your-tea">
<title>Timing Your Tea</title>
-<para>Upon starting, the panel icon will be that of an empty tea mug. If you click on the mug and select your tea, the icon will change to a filled mug. After the specified time, the tea will be finished, and a suitable message box will be shown. At this point, you can close the message box by clicking on it and reset the timer by clicking on the icon. The mug will be shown as empty again.</para>
+<para>Upon starting, the panel icon will be that of an empty tea mug. If you click on the mug and select your tea, the icon will change to a filled mug. After the specified time, the tea will be finished, and a suitable notification box will be shown. At this point, you can close the notification box by clicking on it and reset the timer by clicking on the icon or by having the <guilabel>Reset on popup click</guilabel> check box enabled in the options. The mug will be shown as empty again.</para>
<note><para>The timer should only be reset by those who really enjoy tea.</para></note>
@@ -107,7 +107,7 @@ box.</phrase></textobject>
<para>As shown in the picture, you may add new entries for other tea or change names, times and the order of existing entries. This is useful if you are brewing a cup of tea that is not on the list or if you do not agree with the predefined times. To edit one entry, mark it in the <guilabel>Tea List</guilabel> on the left and change the values in the <guilabel>Tea Properties</guilabel> on the right.</para>
-<para>The box below is the <guilabel>Action</guilabel> field. Here you can define an action that will be executed when the time is up. The button <guibutton>Configure Events...</guibutton> brings up the &kde; Notification Settings for &kteatime;. The <guilabel>Event</guilabel> check box below enables the event selected in the &kde; Notification Settings. If <guilabel>Popup</guilabel> is selected, a message box will appear alerting you to the fact that your tea is ready. The third check box can hold any valid system command. Probably, you will want to leave it blank.</para>
+<para>The box below is the <guilabel>Actions</guilabel> field. Here you can define an action that will be executed when the time is up. The button <guibutton>Configure Events...</guibutton> brings up the &kde; Notification Settings for &kteatime;. The <guilabel>Event</guilabel> check box below enables the event selected in the &kde; Notification Settings. If <guilabel>Popup</guilabel> is selected, a notification box will appear alerting you to the fact that your tea is ready. If <guilabel>Reset on popup click</guilabel> is selected, clicking on the notification box will reset the tea. The next check box can hold any valid system command. Probably, you will want to leave it blank.</para>
<para>If you enable the check box labeled <guilabel>Visualize progress in icon tray</guilabel>, the progress will be shown as a little animated pie chart inside the icon.</para>
diff --git a/kteatime/main.cpp b/kteatime/main.cpp
index 6962e4c..be661b3 100644
--- a/kteatime/main.cpp
+++ b/kteatime/main.cpp
@@ -25,6 +25,7 @@
*/
#include <twin.h>
+#include <tdeapplication.h>
#include <tdestartupinfo.h>
#include <tdecmdlineargs.h>
#include <tdeaboutdata.h>
diff --git a/kteatime/toplevel.cpp b/kteatime/toplevel.cpp
index f38437a..0944d3c 100644
--- a/kteatime/toplevel.cpp
+++ b/kteatime/toplevel.cpp
@@ -28,16 +28,16 @@
#include <tqhbox.h>
#include <tqvbox.h>
#include <tqlineedit.h>
+#include <tqlistview.h>
#include <tqpainter.h>
#include <tqtooltip.h>
#include <tqfile.h>
#include <tqcursor.h>
#include <tqpushbutton.h>
#include <tqgroupbox.h>
-#include <tqheader.h>
-#include <tqpixmap.h>
#include <tqbitmap.h>
+#include <tdeapplication.h>
#include <tdeconfig.h>
#include <khelpmenu.h>
#include <kiconloader.h>
@@ -45,17 +45,14 @@
#include <tdemessagebox.h>
#include <kpassivepopup.h>
#include <knotifyclient.h>
-#include <knuminput.h>
-#include <kseparator.h>
+#include <knotifydialog.h>
#include <tdepopupmenu.h>
#include <kdialogbase.h>
#include <tdeaction.h>
-#include <knotifydialog.h>
#include "tealist.h"
#include "timeedit.h"
#include "toplevel.h"
-#include "toplevel.moc"
const int TopLevel::DEFAULT_TEA_TIME = 3*60;
@@ -115,7 +112,7 @@ TopLevel::TopLevel() : KSystemTray()
current_selected = 0;
listempty = (teas.count() == 0);
-
+ popupBox = nullptr;
startAct = new TDEAction(i18n("&Start"), "1rightarrow", 0,
this, TQ_SLOT(start()), actionCollection(), "start");
@@ -167,6 +164,7 @@ TopLevel::TopLevel() : KSystemTray()
// read remaining entries from config-file
useNotify = config->readBoolEntry("Beep", true); // "Beep" should really be named "Notify"
usePopup = config->readBoolEntry("Popup", true);
+ useResetOnPopup = config->readBoolEntry("ResetOnPopupClick", false);
useAction = config->readBoolEntry("UseAction", true);
action = config->readEntry("Action");
useTrayVis = config->readBoolEntry("UseTrayVis", true);
@@ -182,16 +180,6 @@ TopLevel::TopLevel() : KSystemTray()
stop(); // reset timer, disable some menu entries, etc.
}
-/* slot: signal shutDown() from TDEApplication */
-/* (not currently needed)
-void TopLevel::queryExit()
-{
- TDEConfig *config = kapp->config();
-// config->sync();
-}
-*/
-
-
/** Destructor */
TopLevel::~TopLevel()
{
@@ -325,9 +313,11 @@ void TopLevel::timerEvent(TQTimerEvent *)
system(TQFile::encodeName(cmd));
}
if (usePopup)
- KPassivePopup::message(i18n("The Tea Cooker"),
- teaMessage, teaAnim1Pixmap, this, "popup", 0);
- // FIXME: does auto-deletion work without timeout?
+ {
+ popupBox = KPassivePopup::message(i18n("The Tea Cooker"),
+ teaMessage, teaAnim1Pixmap, this, "popup", 0);
+ connect(popupBox, TQ_SIGNAL(clicked()), this, TQ_SLOT(popupClicked()));
+ }
setToolTip(teaMessage);
repaint();
} else {
@@ -480,6 +470,23 @@ void TopLevel::stop()
setToolTip(i18n("The Tea Cooker"), true);
repaint();
+
+ // Close popup if still open. The popupBox autodeletes when
+ // hidden, so no need to manually delete it
+ if (popupBox)
+ {
+ popupBox->hide();
+ popupBox = nullptr;
+ }
+}
+
+void TopLevel::popupClicked()
+{
+ popupBox = nullptr;
+ if (usePopup && useResetOnPopup)
+ {
+ stop(); // reset tooltip and stop animation
+ }
}
/* open dialog to start an 'anonymous' tea */
@@ -648,6 +655,11 @@ void TopLevel::downButtonClicked() {
enable_controls();
}
+void TopLevel::popupEnableToggled(bool on)
+{
+ resetOnPopupEnable->setEnabled(on);
+}
+
/* config-slot: checkbox next to "action" field toggled*/
void TopLevel::actionEnableToggled(bool on)
{
@@ -731,10 +743,10 @@ void TopLevel::config()
TQBoxLayout *rightside = new TQVBoxLayout(box);
editgroup = new TQGroupBox(2,TQt::Vertical, i18n("Tea Properties"), page);
rightside->addWidget(editgroup, 0, 0);
+ rightside->addStretch();
+
TQHBox *propbox = new TQHBox(editgroup);
- // FIXME: - must enforce correct vertical alignment of each label-editor pair
- // (better use one HBox for each label-editor pair?)
TQVBox *propleft = new TQVBox(propbox);
TQVBox *propright = new TQVBox(propbox);
nameEdit = new TQLineEdit(propright);
@@ -751,7 +763,7 @@ void TopLevel::config()
connect(timeEdit, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(spinBoxValueChanged(int)));
/* bottom - timeout actions */
- TQGroupBox *actiongroup = new TQGroupBox(4,TQt::Vertical, i18n("Action"), page);
+ TQGroupBox *actiongroup = new TQGroupBox(5,TQt::Vertical, i18n("Actions"), page);
top_box->addWidget(actiongroup, 0, 0);
TQWidget *actionconf_widget = new TQWidget(actiongroup);
@@ -762,9 +774,16 @@ void TopLevel::config()
actionconf_hbox->addStretch(10);
eventEnable = new TQCheckBox(i18n("Event"), actiongroup);
- popupEnable = new TQCheckBox(i18n("Popup"), actiongroup);
eventEnable->setFixedHeight(eventEnable->sizeHint().height());
+ TQHBox *popupBox = new TQHBox(actiongroup);
+ popupEnable = new TQCheckBox(i18n("Popup"), popupBox);
popupEnable->setFixedHeight(popupEnable->sizeHint().height());
+ TQToolTip::add(popupEnable, i18n("Show a popup notification when the tea is ready"));
+ connect(popupEnable, TQ_SIGNAL(toggled(bool)), TQ_SLOT(popupEnableToggled(bool)));
+
+ resetOnPopupEnable = new TQCheckBox(i18n("Reset on popup click"), popupBox);
+ resetOnPopupEnable->setFixedHeight(resetOnPopupEnable->sizeHint().height());
+ TQToolTip::add(resetOnPopupEnable, i18n("Reset tea when the popup notification is clicked"));
TQHBox *actionbox = new TQHBox(actiongroup);
actionEnable = new TQCheckBox(actionbox);
@@ -774,7 +793,6 @@ void TopLevel::config()
actionEdit->setFixedHeight(actionEdit->sizeHint().height());
TQToolTip::add(actionEdit, i18n("Enter command here; '%t' will be replaced with name of steeping tea"));
connect(actionEnable, TQ_SIGNAL(toggled(bool)), TQ_SLOT(actionEnableToggled(bool)));
- rightside->addStretch();
// single checkbox
visEnable = new TQCheckBox(i18n("Visualize progress in icon tray"), page);
@@ -812,6 +830,8 @@ void TopLevel::config()
eventEnable->setChecked(useNotify);
popupEnable->setChecked(usePopup);
+ resetOnPopupEnable->setChecked(useResetOnPopup);
+ resetOnPopupEnable->setEnabled(usePopup);
actionEnable->setChecked(useAction);
actionEdit->setText(action);
actionEdit->setEnabled(useAction);
@@ -822,6 +842,7 @@ void TopLevel::config()
// activate new settings
useNotify = eventEnable->isChecked();
usePopup = popupEnable->isChecked();
+ useResetOnPopup = resetOnPopupEnable->isChecked();
useAction = actionEnable->isChecked();
action = actionEdit->text();
useTrayVis = visEnable->isChecked();
@@ -853,6 +874,7 @@ void TopLevel::config()
config->setGroup("General");
config->writeEntry("Beep", useNotify);
config->writeEntry("Popup", usePopup);
+ config->writeEntry("ResetOnPopupClick", useResetOnPopup);
config->writeEntry("UseAction", useAction);
config->writeEntry("Action", action);
config->writeEntry("Tea", current_selected);
@@ -874,3 +896,5 @@ void TopLevel::config()
config->sync();
}
}
+
+#include "toplevel.moc"
diff --git a/kteatime/toplevel.h b/kteatime/toplevel.h
index 7eebf8f..ca3e592 100644
--- a/kteatime/toplevel.h
+++ b/kteatime/toplevel.h
@@ -23,27 +23,27 @@
#ifndef TOPLEVEL_H
#define TOPLEVEL_H
-#include <tdeapplication.h>
-#include <tqpopupmenu.h>
-#include <tqtimer.h>
-#include <tqlineedit.h>
#include <tqvaluevector.h>
-#include <tqlistview.h>
-#include <tqpushbutton.h>
-#include <tqgroupbox.h>
-#include <knuminput.h>
#include <ksystemtray.h>
#include <tqpixmap.h>
-class TDEAction;
-class KDialogBase;
class TQCheckBox;
+class TQGroupBox;
+class TQLineEdit;
+class TQListView;
+class TQListViewItem;
+class TQPopupMenu;
+class TQPushButton;
+
+class KDialogBase;
+class KPassivePopup;
+class TDEAction;
+
class TimeEdit;
class TopLevel : public KSystemTray
{
TQ_OBJECT
-
public:
@@ -64,6 +64,7 @@ private slots:
void teaStartSelected(int index);
void start();
void stop();
+ void popupClicked();
void config();
void help();
void anonymous();
@@ -82,6 +83,7 @@ private slots:
void disable_properties();
void enable_properties();
void enable_controls();
+ void popupEnableToggled(bool on);
void actionEnableToggled(bool on);
private:
@@ -107,7 +109,7 @@ private:
TQString current_name; // name of currently +running+ tea (if any)
bool shooting; // anonymous tea currently steeping?
- bool useNotify, usePopup, useAction;
+ bool useNotify, usePopup, useResetOnPopup, useAction;
TQString action;
bool useTrayVis; // visualize progress in tray icon
@@ -120,11 +122,12 @@ private:
TimeEdit *timeEdit;
TQGroupBox *editgroup;
TQPushButton *btn_new, *btn_del, *btn_up, *btn_down, *btn_conf;
+ KPassivePopup *popupBox;
TQString lastTip;
KDialogBase *anondlg, *confdlg;
TimeEdit *anon_time;
- TQCheckBox *eventEnable, *popupEnable, *actionEnable, *visEnable;
+ TQCheckBox *eventEnable, *popupEnable, *actionEnable, *visEnable, *resetOnPopupEnable;
};
#endif