ft: Closing windows asks to save queries before closing the window.
fix: closetab did incorrectly close when cancel was choosen.
This commit is contained in:
parent
adb44fc157
commit
dea76e17c5
7 changed files with 59 additions and 10 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include "TaskExecutor.h"
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QCloseEvent>
|
||||
#include <QFileDialog>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
|
|
@ -24,6 +25,9 @@
|
|||
namespace pg = Pgsql;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DatabaseWindow::DatabaseWindow(MasterController *master, QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, m_masterController(master)
|
||||
|
|
@ -84,6 +88,20 @@ CrudTab *DatabaseWindow::GetActiveCrud()
|
|||
return ct;
|
||||
}
|
||||
|
||||
void DatabaseWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
for (int idx = 0; idx < m_tabWidget->count(); ++idx) {
|
||||
auto widget = m_tabWidget->widget(idx);
|
||||
auto mp = dynamic_cast<ManagedPage*>(widget);
|
||||
if (mp) {
|
||||
if (!mp->CanClose(true)) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::setConfig(const ConnectionConfig &config)
|
||||
{
|
||||
m_config = config;
|
||||
|
|
@ -352,13 +370,15 @@ void DatabaseWindow::closeTab(int index)
|
|||
{
|
||||
QWidget *widget = m_tabWidget->widget(index);
|
||||
|
||||
auto qt = dynamic_cast<QueryTool*>(widget);
|
||||
if (qt && qt->canClose()) {
|
||||
m_tabWidget->removeTab(index);
|
||||
auto mp = dynamic_cast<ManagedPage*>(widget);
|
||||
if (mp) {
|
||||
if (mp->CanClose(true)) {
|
||||
m_tabWidget->removeTab(index);
|
||||
}
|
||||
}
|
||||
else if (index >= 0) {
|
||||
m_tabWidget->removeTab(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWindow::catalogLoaded()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue