From 0d6e58d97a71ec2f48de983829dbce7ec010347e Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Thu, 10 Apr 2025 17:24:13 +0900
Subject: kteatime: improve layout of the configuration dialog

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 kteatime/toplevel.cpp | 58 +++++++++++++++++++++++++++++++--------------------
 kteatime/toplevel.h   |  1 +
 2 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/kteatime/toplevel.cpp b/kteatime/toplevel.cpp
index 01fb00c..af22fed 100644
--- a/kteatime/toplevel.cpp
+++ b/kteatime/toplevel.cpp
@@ -655,6 +655,11 @@ void TopLevel::downButtonClicked() {
 	enable_controls();
 }
 
+void TopLevel::eventEnableToggled(bool on)
+{
+	btn_conf->setEnabled(on);
+}
+
 void TopLevel::popupEnableToggled(bool on)
 {
 	resetOnPopupEnable->setEnabled(on);
@@ -747,6 +752,8 @@ void TopLevel::config()
 
     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);
@@ -763,41 +770,45 @@ void TopLevel::config()
     connect(timeEdit, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(spinBoxValueChanged(int)));
 
     /* bottom - timeout actions */
-    TQGroupBox *actiongroup = new TQGroupBox(5,TQt::Vertical, i18n("Actions"), page);
-    top_box->addWidget(actiongroup, 0, 0);
-
-    TQWidget *actionconf_widget = new TQWidget(actiongroup);
-    TQBoxLayout *actionconf_hbox = new TQHBoxLayout(actionconf_widget);
-    btn_conf = new TQPushButton(i18n("Configure Events..."), actionconf_widget);
-    actionconf_hbox->addWidget(btn_conf);
+    TQGridLayout *actionsGrid = new TQGridLayout(top_box, 5, 2, 5);
+    TQLabel *actionsLabel = new TQLabel(i18n("Actions"), page);
+    TQFont actionsLblFont = actionsLabel->font();
+    actionsLblFont.setBold(true);
+    actionsLabel->setFont(actionsLblFont);
+    actionsGrid->addMultiCellWidget(actionsLabel, 0, 0, 0, 1);
+
+    eventEnable = new TQCheckBox(i18n("Event"), page);
+    TQToolTip::add(eventEnable, i18n("Enable events when the tea is ready"));
+    connect(eventEnable, TQ_SIGNAL(toggled(bool)), TQ_SLOT(eventEnableToggled(bool)));
+    actionsGrid->addWidget(eventEnable, 1, 0);
+
+    btn_conf = new TQPushButton(i18n("Configure Events..."), page);
+    btn_conf->setFixedSize(btn_conf->sizeHint());
     connect(btn_conf, TQ_SIGNAL(clicked()), TQ_SLOT(confButtonClicked()));
-    actionconf_hbox->addStretch(10);
+    actionsGrid->addWidget(btn_conf, 1, 1);
 
-    eventEnable = new TQCheckBox(i18n("Event"), actiongroup);
-    eventEnable->setFixedHeight(eventEnable->sizeHint().height());
-    TQHBox *popupBox = new TQHBox(actiongroup);
-    popupEnable = new TQCheckBox(i18n("Popup"), popupBox);
-    popupEnable->setFixedHeight(popupEnable->sizeHint().height());
+    popupEnable = new TQCheckBox(i18n("Popup"), page);
     TQToolTip::add(popupEnable, i18n("Show a popup notification when the tea is ready"));
     connect(popupEnable, TQ_SIGNAL(toggled(bool)), TQ_SLOT(popupEnableToggled(bool)));
+    actionsGrid->addWidget(popupEnable, 2, 0);
 
-    resetOnPopupEnable = new TQCheckBox(i18n("Reset on popup click"), popupBox);
-    resetOnPopupEnable->setFixedHeight(resetOnPopupEnable->sizeHint().height());
+    resetOnPopupEnable = new TQCheckBox(i18n("Reset on popup click"), page);
     TQToolTip::add(resetOnPopupEnable, i18n("Reset tea when the popup notification is clicked"));
+    actionsGrid->addWidget(resetOnPopupEnable, 2, 1);
 
-    TQHBox *actionbox = new TQHBox(actiongroup);
-    actionEnable = new TQCheckBox(actionbox);
-//    FIXME: add text to this line:
-//    TQLabel *actionLabel = new TQLabel(i18n("Execute: "), actiongroup);
-    actionEdit = new TQLineEdit(actionbox);
+    actionEnable = new TQCheckBox(i18n("Command"), page);
+    TQToolTip::add(actionEnable, i18n("Run a command when the tea is ready"));
+    connect(actionEnable, TQ_SIGNAL(toggled(bool)), TQ_SLOT(actionEnableToggled(bool)));
+    actionsGrid->addWidget(actionEnable, 3, 0);
+
+    actionEdit = new TQLineEdit(page);
     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)));
+    actionsGrid->addWidget(actionEdit, 3, 1);
 
     // single checkbox
     visEnable = new TQCheckBox(i18n("Visualize progress in icon tray"), page);
-    top_box->addWidget(visEnable, 0, 0);
-
+    actionsGrid->addMultiCellWidget(visEnable, 4, 4, 0, 1);
 
     // let listbox claim all remaining vertical space
     top_box->setStretchFactor(box, 10);
@@ -829,6 +840,7 @@ void TopLevel::config()
   // -------------------------
 
   eventEnable->setChecked(useNotify);
+  btn_conf->setEnabled(useNotify);
   popupEnable->setChecked(usePopup);
   resetOnPopupEnable->setChecked(useResetOnPopup);
   resetOnPopupEnable->setEnabled(usePopup);
diff --git a/kteatime/toplevel.h b/kteatime/toplevel.h
index ca3e592..fafbe7c 100644
--- a/kteatime/toplevel.h
+++ b/kteatime/toplevel.h
@@ -83,6 +83,7 @@ private slots:
 	void disable_properties();
 	void enable_properties();
 	void enable_controls();
+	void eventEnableToggled(bool on);
 	void popupEnableToggled(bool on);
 	void actionEnableToggled(bool on);
 
-- 
cgit v1.2.3

