1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02:00

Asking whether to close window everytime it makes sense.

- you will be asked even when you have set "Restore session"
  and you are closing second+ window that won't be restored

closes #501
This commit is contained in:
nowrep 2012-08-14 12:35:24 +02:00
parent 2458cb8469
commit 93507492d8

View File

@ -1690,6 +1690,31 @@ void QupZilla::closeEvent(QCloseEvent* event)
return;
}
Settings settings;
int afterLaunch = settings.value("Web-URL-Settings/afterLaunch", 1).toInt();
bool askOnClose = settings.value("Browser-Tabs-Settings/AskOnClosing", true).toBool();
if (afterLaunch == 3 && mApp->windowCount() == 1) {
askOnClose = false;
}
if (askOnClose && m_tabWidget->count() > 1) {
CheckBoxDialog dialog(QDialogButtonBox::Yes | QDialogButtonBox::No, this);
dialog.setText(tr("There are still %1 open tabs and your session won't be stored. \nAre you sure to quit QupZilla?").arg(m_tabWidget->count()));
dialog.setCheckBoxText(tr("Don't ask again"));
dialog.setWindowTitle(tr("There are still open tabs"));
dialog.setIcon(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning));
if (dialog.exec() != QDialog::Accepted) {
event->ignore();
return;
}
if (dialog.isChecked()) {
settings.setValue("Browser-Tabs-Settings/AskOnClosing", false);
}
}
m_isClosing = true;
mApp->saveStateSlot();
@ -1759,9 +1784,6 @@ bool QupZilla::quitApp()
if (!mApp->isPrivateSession()) {
Settings settings;
int afterLaunch = settings.value("Web-URL-Settings/afterLaunch", 1).toInt();
bool askOnClose = settings.value("Browser-Tabs-Settings/AskOnClosing", true).toBool();
settings.beginGroup("Browser-View-Settings");
settings.setValue("WindowMaximised", windowState().testFlag(Qt::WindowMaximized));
settings.setValue("WindowGeometry", saveGeometry());
@ -1770,20 +1792,6 @@ bool QupZilla::quitApp()
settings.setValue("SideBarWidth", m_sideBarWidth);
settings.setValue("WebViewWidth", m_webViewWidth);
settings.endGroup();
if (askOnClose && afterLaunch != 3 && m_tabWidget->count() > 1) {
CheckBoxDialog dialog(QDialogButtonBox::Yes | QDialogButtonBox::No, this);
dialog.setText(tr("There are still %1 open tabs and your session won't be stored. \nAre you sure to quit QupZilla?").arg(m_tabWidget->count()));
dialog.setCheckBoxText(tr("Don't ask again"));
dialog.setWindowTitle(tr("There are still open tabs"));
dialog.setIcon(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning));
if (dialog.exec() != QDialog::Accepted) {
return false;
}
if (dialog.isChecked()) {
settings.setValue("Browser-Tabs-Settings/AskOnClosing", false);
}
}
}
QTimer::singleShot(0, mApp, SLOT(quitApplication()));