From 58be45bc6109272fe398479331f74d6f5c9ed425 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Wed, 20 Dec 2023 13:39:22 +0300 Subject: [PATCH] UI: ZonesWindow: Add "Update Zones" button --- src/ui/form/zone/zoneswindow.cpp | 35 ++++++++++++++++++++++++-------- src/ui/form/zone/zoneswindow.h | 3 +++ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/ui/form/zone/zoneswindow.cpp b/src/ui/form/zone/zoneswindow.cpp index 8e0944ae..1e701d2f 100644 --- a/src/ui/form/zone/zoneswindow.cpp +++ b/src/ui/form/zone/zoneswindow.cpp @@ -133,6 +133,7 @@ void ZonesWindow::onRetranslateUi() m_actEditZone->setText(tr("Edit")); m_actRemoveZone->setText(tr("Remove")); m_btSaveAsText->setText(tr("Save As Text")); + m_btUpdateZones->setText(tr("Update Zones")); m_formZoneEdit->unsetLocale(); m_formZoneEdit->setWindowTitle(tr("Edit Zone")); @@ -368,6 +369,26 @@ QLayout *ZonesWindow::setupHeader() m_btEdit->setMenu(editMenu); // Save As Text + setupSaveAsText(); + + // Run Task + setupTaskRun(); + + // Menu button + m_btMenu = windowManager()->createMenuButton(); + + layout->addWidget(m_btEdit); + layout->addWidget(m_btSaveAsText); + layout->addWidget(ControlUtil::createSeparator(Qt::Vertical)); + layout->addWidget(m_btUpdateZones); + layout->addStretch(); + layout->addWidget(m_btMenu); + + return layout; +} + +void ZonesWindow::setupSaveAsText() +{ m_btSaveAsText = ControlUtil::createButton(":/icons/save_as.png", [&] { const auto filePath = DialogUtil::getSaveFileName( m_btSaveAsText->text(), tr("Text files (*.txt);;All files (*.*)")); @@ -380,16 +401,12 @@ QLayout *ZonesWindow::setupHeader() windowManager()->showErrorBox(tr("Cannot save Zone addresses as text file")); } }); +} - // Menu button - m_btMenu = windowManager()->createMenuButton(); - - layout->addWidget(m_btEdit); - layout->addWidget(m_btSaveAsText); - layout->addStretch(); - layout->addWidget(m_btMenu); - - return layout; +void ZonesWindow::setupTaskRun() +{ + m_btUpdateZones = ControlUtil::createButton( + ":/icons/play.png", [&] { taskManager()->runTask(TaskInfo::ZoneDownloader); }); } void ZonesWindow::setupTableZones() diff --git a/src/ui/form/zone/zoneswindow.h b/src/ui/form/zone/zoneswindow.h index 30a0bfc0..fc05d8b4 100644 --- a/src/ui/form/zone/zoneswindow.h +++ b/src/ui/form/zone/zoneswindow.h @@ -62,6 +62,8 @@ private: QLayout *setupZoneEditTextLayout(); QLayout *setupZoneEditButtons(); QLayout *setupHeader(); + void setupSaveAsText(); + void setupTaskRun(); void setupTableZones(); void setupTableZonesHeader(); void setupTableZonesChanged(); @@ -94,6 +96,7 @@ private: QAction *m_actEditZone = nullptr; QAction *m_actRemoveZone = nullptr; QPushButton *m_btSaveAsText = nullptr; + QPushButton *m_btUpdateZones = nullptr; QPushButton *m_btMenu = nullptr; QLabel *m_labelZoneName = nullptr; QLineEdit *m_editZoneName = nullptr;