Skip to content

Commit a0e8991

Browse files
committed
[ref] mainwindow: refactore addAction
1 parent 05d9bd0 commit a0e8991

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/mainwindow.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
5757
// Tray icon
5858
trayIcon = new QSystemTrayIcon(QIcon(":/assets/icon.svg"), this);
5959
QMenu *trayMenu = new QMenu(this);
60-
QAction *restore = new QAction(tr("Restore"), this);
60+
QAction *restore = trayMenu->addAction(tr("Restore"));
6161
connect(restore, &QAction::triggered, this, &MainWindow::showNormal);
62-
trayMenu->addAction(restore);
63-
QAction *close = new QAction(tr("Close"), this);
62+
QAction *close = trayMenu->addAction(tr("Close"));
6463
connect(close, &QAction::triggered, this, &MainWindow::close);
65-
trayMenu->addAction(close);
6664
connect(trayIcon, &QSystemTrayIcon::activated, this, [this](QSystemTrayIcon::ActivationReason reason) {
6765
switch (reason) {
6866
case QSystemTrayIcon::Trigger: {

0 commit comments

Comments
 (0)