From b58aa1271abac18808762834471984a8a5415d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0lker=20Avc=C4=B1?= Date: Mon, 14 Oct 2024 15:52:40 +0300 Subject: [PATCH] dbpage: show import option when the db is empty --- src/UI/DatabasePage/databasepage.cpp | 20 ++++++++++++++++---- src/UI/DatabasePage/databasepage.h | 10 +++++++--- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/UI/DatabasePage/databasepage.cpp b/src/UI/DatabasePage/databasepage.cpp index 7d9579c..da4005c 100644 --- a/src/UI/DatabasePage/databasepage.cpp +++ b/src/UI/DatabasePage/databasepage.cpp @@ -158,7 +158,7 @@ namespace UI { ui->btnAdd->setMenu(menuAdd); - QMenu* menuMore = new QMenu(); + menuMore = new QMenu(); QAction* eotyAction = new QAction("Yıl sonu işlemlerini yap"); eotyAction->setIcon(icon); connect(eotyAction, &QAction::triggered, this, &DatabasePage::actionEoty_clicked); @@ -175,6 +175,11 @@ namespace UI { exportAction->setIcon(icon); connect(exportAction, &QAction::triggered, this, &DatabasePage::exportUserData); + btnMoreActions[0] = eotyAction; + btnMoreActions[1] = removeClassAction; + btnMoreActions[2] = importAction; + btnMoreActions[3] = exportAction; + menuMore->addAction(eotyAction); menuMore->addAction(removeClassAction); menuMore->addAction(importAction); @@ -247,8 +252,6 @@ namespace UI { return; } - - response = QMessageBox::information(this, "Dışarı Aktar", "ikoOSKAR uygulama verilerinin bulunduğu yedek dosyası başarıyla oluşturuldu!" @@ -335,7 +338,16 @@ namespace UI { ui->btnDelete->setVisible(!classNames->empty()); ui->btnEdit->setVisible(!classNames->empty()); - ui->btnMore->setVisible(!classNames->empty()); + + menuMore->clear(); + if (!classNames->empty()) { + menuMore->addAction(btnMoreActions[0]); + menuMore->addAction(btnMoreActions[1]); + } + menuMore->addAction(btnMoreActions[2]); + if (!classNames->empty()) { + menuMore->addAction(btnMoreActions[3]); + } // Enable the signal back connect(tabWidget, &QTabWidget::currentChanged, this, [&]() { diff --git a/src/UI/DatabasePage/databasepage.h b/src/UI/DatabasePage/databasepage.h index e4d6513..faa7b7e 100644 --- a/src/UI/DatabasePage/databasepage.h +++ b/src/UI/DatabasePage/databasepage.h @@ -5,6 +5,7 @@ #include "UI/Common/page.h" #include #include +#include namespace ikoOSKAR { namespace UI { @@ -43,14 +44,17 @@ namespace UI { void on_btnEdit_clicked(); private: + Ui::DatabasePage* ui; + ikoOSKAR::BLL::DatabaseHelper* bll; + inline static DatabasePage* instance; + std::array btnMoreActions; + QMenu* menuMore; + void refresh(); void createButtonMenus(); void createTabWidget(); void createStudentContextMenu(); inline QString currentClassname(); - Ui::DatabasePage* ui; - ikoOSKAR::BLL::DatabaseHelper* bll; - inline static DatabasePage* instance; explicit DatabasePage(QWidget* parent = nullptr); void importUserData(); void exportUserData();