Skip to content

Commit 121dbb6

Browse files
mrpilot2claude
andcommitted
feat(demo): add dialog banner controls to the notification launcher
Adds a "Dialog banner" section with an "Open dialog banner demo" button that shows a new NotificationDemoDialog (AideDialog subclass) whose Info/Success/Warning/Error buttons drive showBanner()/ clearBanner() on itself. Closes #166. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent c65ddd6 commit 121dbb6

16 files changed

Lines changed: 612 additions & 11 deletions

demo/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ add_executable(
3434
colorschemereactor.hpp
3535
demosettingspage.cpp
3636
main.cpp
37+
notificationdemodialog.cpp
3738
notificationlauncherdialog.cpp
3839
reportbugpreviewlauncher.cpp
3940
${CMAKE_CURRENT_LIST_DIR}/../../tools/sanitizerdefaults.cpp
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include "notificationdemodialog.hpp"
2+
3+
#include <array>
4+
5+
#include <QDialogButtonBox>
6+
#include <QHBoxLayout>
7+
#include <QPushButton>
8+
#include <QString>
9+
#include <QVBoxLayout>
10+
11+
#include <aide/notificationtype.hpp>
12+
13+
using aide::NotificationType;
14+
using aide::widgets::AideDialog;
15+
using demo::NotificationDemoDialog;
16+
17+
namespace
18+
{
19+
struct SeverityButton
20+
{
21+
NotificationType type;
22+
QString buttonLabel;
23+
QString message;
24+
};
25+
} // namespace
26+
27+
NotificationDemoDialog::NotificationDemoDialog(QWidget* parent)
28+
: AideDialog(parent)
29+
{
30+
setWindowTitle(tr("Dialog Banner Demo"));
31+
32+
auto* buttonsRow = new QHBoxLayout;
33+
34+
const std::array<SeverityButton, 4> severityButtons{{
35+
{NotificationType::Information, tr("Info"),
36+
tr("This is an informational banner.")},
37+
{NotificationType::Success, tr("Success"),
38+
tr("This is a success banner.")},
39+
{NotificationType::Warning, tr("Warning"),
40+
tr("This is a warning banner.")},
41+
{NotificationType::Error, tr("Error"), tr("This is an error banner.")},
42+
}};
43+
44+
for (const auto& severityButton : severityButtons) {
45+
auto* button = new QPushButton(severityButton.buttonLabel, this);
46+
connect(button, &QPushButton::clicked, this, [this, severityButton]() {
47+
showBanner(severityButton.type, severityButton.message);
48+
});
49+
buttonsRow->addWidget(button);
50+
}
51+
52+
auto* clearButton = new QPushButton(tr("Clear"), this);
53+
connect(clearButton, &QPushButton::clicked, this, &AideDialog::clearBanner);
54+
buttonsRow->addWidget(clearButton);
55+
56+
contentLayout()->addLayout(buttonsRow);
57+
58+
auto* buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
59+
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
60+
contentLayout()->addWidget(buttonBox);
61+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef DEMO_NOTIFICATION_DEMO_DIALOG_HPP
2+
#define DEMO_NOTIFICATION_DEMO_DIALOG_HPP
3+
4+
#include <aide/gui/widgets/aidedialog.hpp>
5+
6+
class QWidget;
7+
8+
namespace demo
9+
{
10+
// Opened by NotificationLauncherDialog's "Dialog banner" section (#166):
11+
// demonstrates AideDialog's shared banner slot (showBanner()/
12+
// clearBanner(), see #146) directly, without going through
13+
// NotificationManager.
14+
class NotificationDemoDialog : public aide::widgets::AideDialog
15+
{
16+
Q_OBJECT
17+
public:
18+
explicit NotificationDemoDialog(QWidget* parent = nullptr);
19+
};
20+
} // namespace demo
21+
22+
#endif // DEMO_NOTIFICATION_DEMO_DIALOG_HPP

demo/src/notificationlauncherdialog.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include <aide/notificationmanagerinterface.hpp>
2222
#include <aide/settingsinterface.hpp>
2323

24+
#include "notificationdemodialog.hpp"
25+
2426
using aide::AideSettingsProvider;
2527
using aide::HierarchicalId;
2628
using aide::Notification;
@@ -67,6 +69,7 @@ NotificationLauncherDialog::NotificationLauncherDialog(
6769
auto* mainLayout = new QVBoxLayout(this);
6870
mainLayout->addWidget(createBalloonSection());
6971
mainLayout->addWidget(createGotItSection());
72+
mainLayout->addWidget(createDialogBannerSection());
7073

7174
auto* buttonBox = new QDialogButtonBox(QDialogButtonBox::Close, this);
7275
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
@@ -163,6 +166,23 @@ QWidget* NotificationLauncherDialog::createGotItSection()
163166
return group;
164167
}
165168

169+
QWidget* NotificationLauncherDialog::createDialogBannerSection()
170+
{
171+
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
172+
auto* group = new QGroupBox(tr("Dialog banner"));
173+
auto* groupLayout = new QVBoxLayout(group);
174+
175+
auto* openButton = new QPushButton(tr("Open dialog banner demo"), group);
176+
connect(openButton, &QPushButton::clicked, this, [this]() {
177+
demo::NotificationDemoDialog dialog(this);
178+
dialog.exec();
179+
});
180+
181+
groupLayout->addWidget(openButton);
182+
183+
return group;
184+
}
185+
166186
void NotificationLauncherDialog::showGotIt()
167187
{
168188
const auto settings = AideSettingsProvider::unversionableSettings();

demo/src/notificationlauncherdialog.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ namespace aide
1818
namespace demo
1919
{
2020
// Shell opened by the demo's "Demo -> Notifications" menu action (#164).
21-
// Owns the "Balloon" and "Got it" (#165) sections; the dialog banner
22-
// (#166) and editor banner (#167) sections attach their own QGroupBox
23-
// here as those tickets land.
21+
// Owns the "Balloon", "Got it" (#165) and "Dialog banner" (#166)
22+
// sections; the editor banner (#167) section attaches its own QGroupBox
23+
// here as that ticket lands.
2424
class NotificationLauncherDialog : public QDialog
2525
{
2626
Q_OBJECT
@@ -34,6 +34,7 @@ namespace demo
3434
private:
3535
[[nodiscard]] QWidget* createBalloonSection();
3636
[[nodiscard]] QWidget* createGotItSection();
37+
[[nodiscard]] QWidget* createDialogBannerSection();
3738

3839
void postBalloon(aide::NotificationType type, const QString& title,
3940
const QString& content);

demo/src/res/demo_ar_SA.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,49 @@
114114
<translation type="unfinished"></translation>
115115
</message>
116116
</context>
117+
<context>
118+
<name>demo::NotificationDemoDialog</name>
119+
<message>
120+
<source>Dialog Banner Demo</source>
121+
<translation type="unfinished"></translation>
122+
</message>
123+
<message>
124+
<source>Info</source>
125+
<translation type="unfinished"></translation>
126+
</message>
127+
<message>
128+
<source>This is an informational banner.</source>
129+
<translation type="unfinished"></translation>
130+
</message>
131+
<message>
132+
<source>Success</source>
133+
<translation type="unfinished"></translation>
134+
</message>
135+
<message>
136+
<source>This is a success banner.</source>
137+
<translation type="unfinished"></translation>
138+
</message>
139+
<message>
140+
<source>Warning</source>
141+
<translation type="unfinished"></translation>
142+
</message>
143+
<message>
144+
<source>This is a warning banner.</source>
145+
<translation type="unfinished"></translation>
146+
</message>
147+
<message>
148+
<source>Error</source>
149+
<translation type="unfinished"></translation>
150+
</message>
151+
<message>
152+
<source>This is an error banner.</source>
153+
<translation type="unfinished"></translation>
154+
</message>
155+
<message>
156+
<source>Clear</source>
157+
<translation type="unfinished"></translation>
158+
</message>
159+
</context>
117160
<context>
118161
<name>demo::NotificationLauncherDialog</name>
119162
<message>
@@ -228,5 +271,13 @@
228271
<source>This is a sample &quot;Got it&quot; tooltip shown by the demo launcher.</source>
229272
<translation type="unfinished"></translation>
230273
</message>
274+
<message>
275+
<source>Dialog banner</source>
276+
<translation type="unfinished"></translation>
277+
</message>
278+
<message>
279+
<source>Open dialog banner demo</source>
280+
<translation type="unfinished"></translation>
281+
</message>
231282
</context>
232283
</TS>

demo/src/res/demo_de.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,49 @@
114114
<translation type="unfinished"></translation>
115115
</message>
116116
</context>
117+
<context>
118+
<name>demo::NotificationDemoDialog</name>
119+
<message>
120+
<source>Dialog Banner Demo</source>
121+
<translation type="unfinished"></translation>
122+
</message>
123+
<message>
124+
<source>Info</source>
125+
<translation type="unfinished"></translation>
126+
</message>
127+
<message>
128+
<source>This is an informational banner.</source>
129+
<translation type="unfinished"></translation>
130+
</message>
131+
<message>
132+
<source>Success</source>
133+
<translation type="unfinished"></translation>
134+
</message>
135+
<message>
136+
<source>This is a success banner.</source>
137+
<translation type="unfinished"></translation>
138+
</message>
139+
<message>
140+
<source>Warning</source>
141+
<translation type="unfinished"></translation>
142+
</message>
143+
<message>
144+
<source>This is a warning banner.</source>
145+
<translation type="unfinished"></translation>
146+
</message>
147+
<message>
148+
<source>Error</source>
149+
<translation type="unfinished"></translation>
150+
</message>
151+
<message>
152+
<source>This is an error banner.</source>
153+
<translation type="unfinished"></translation>
154+
</message>
155+
<message>
156+
<source>Clear</source>
157+
<translation type="unfinished"></translation>
158+
</message>
159+
</context>
117160
<context>
118161
<name>demo::NotificationLauncherDialog</name>
119162
<message>
@@ -228,5 +271,13 @@
228271
<source>This is a sample &quot;Got it&quot; tooltip shown by the demo launcher.</source>
229272
<translation type="unfinished"></translation>
230273
</message>
274+
<message>
275+
<source>Dialog banner</source>
276+
<translation type="unfinished"></translation>
277+
</message>
278+
<message>
279+
<source>Open dialog banner demo</source>
280+
<translation type="unfinished"></translation>
281+
</message>
231282
</context>
232283
</TS>

demo/src/res/demo_en.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,49 @@
112112
<translation type="unfinished"></translation>
113113
</message>
114114
</context>
115+
<context>
116+
<name>demo::NotificationDemoDialog</name>
117+
<message>
118+
<source>Dialog Banner Demo</source>
119+
<translation type="unfinished"></translation>
120+
</message>
121+
<message>
122+
<source>Info</source>
123+
<translation type="unfinished"></translation>
124+
</message>
125+
<message>
126+
<source>This is an informational banner.</source>
127+
<translation type="unfinished"></translation>
128+
</message>
129+
<message>
130+
<source>Success</source>
131+
<translation type="unfinished"></translation>
132+
</message>
133+
<message>
134+
<source>This is a success banner.</source>
135+
<translation type="unfinished"></translation>
136+
</message>
137+
<message>
138+
<source>Warning</source>
139+
<translation type="unfinished"></translation>
140+
</message>
141+
<message>
142+
<source>This is a warning banner.</source>
143+
<translation type="unfinished"></translation>
144+
</message>
145+
<message>
146+
<source>Error</source>
147+
<translation type="unfinished"></translation>
148+
</message>
149+
<message>
150+
<source>This is an error banner.</source>
151+
<translation type="unfinished"></translation>
152+
</message>
153+
<message>
154+
<source>Clear</source>
155+
<translation type="unfinished"></translation>
156+
</message>
157+
</context>
115158
<context>
116159
<name>demo::NotificationLauncherDialog</name>
117160
<message>
@@ -226,5 +269,13 @@
226269
<source>This is a sample &quot;Got it&quot; tooltip shown by the demo launcher.</source>
227270
<translation type="unfinished"></translation>
228271
</message>
272+
<message>
273+
<source>Dialog banner</source>
274+
<translation type="unfinished"></translation>
275+
</message>
276+
<message>
277+
<source>Open dialog banner demo</source>
278+
<translation type="unfinished"></translation>
279+
</message>
229280
</context>
230281
</TS>

0 commit comments

Comments
 (0)