mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Added a confirmation Dialog when trying to close a tab
This commit is contained in:
parent
0ca916717c
commit
17f5fd0ff1
2 changed files with 12 additions and 0 deletions
|
@ -31,6 +31,7 @@ Notebook::Notebook(Window *parent, bool _showButtons, const std::string &setting
|
|||
, userButton(this)
|
||||
, showButtons(_showButtons)
|
||||
, tabs(fS("{}/tabs", this->settingRoot))
|
||||
, closeConfirmDialog(this)
|
||||
{
|
||||
this->connect(&this->settingsButton, SIGNAL(clicked()), this, SLOT(settingsButtonClicked()));
|
||||
this->connect(&this->userButton, SIGNAL(clicked()), this, SLOT(usersButtonClicked()));
|
||||
|
@ -47,6 +48,11 @@ Notebook::Notebook(Window *parent, bool _showButtons, const std::string &setting
|
|||
settingsManager.hideUserButton.connectSimple([this](auto) { this->performLayout(); });
|
||||
|
||||
this->loadTabs();
|
||||
|
||||
closeConfirmDialog.setText("Are you sure to close this tab?");
|
||||
closeConfirmDialog.setIcon(QMessageBox::Icon::Question);
|
||||
closeConfirmDialog.setStandardButtons(QMessageBox::Close | QMessageBox::Abort);
|
||||
closeConfirmDialog.setDefaultButton(QMessageBox::Close);
|
||||
}
|
||||
|
||||
SplitContainer *Notebook::addNewPage()
|
||||
|
@ -74,6 +80,9 @@ SplitContainer *Notebook::addPage(const std::string &uuid, bool select)
|
|||
|
||||
void Notebook::removePage(SplitContainer *page)
|
||||
{
|
||||
if (closeConfirmDialog.exec() != QMessageBox::Close)
|
||||
return;
|
||||
|
||||
int index = this->pages.indexOf(page);
|
||||
|
||||
if (this->pages.size() == 1) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "widgets/splitcontainer.hpp"
|
||||
|
||||
#include <QList>
|
||||
#include <QMessageBox>
|
||||
#include <QWidget>
|
||||
|
||||
namespace chatterino {
|
||||
|
@ -73,6 +74,8 @@ private:
|
|||
|
||||
void loadTabs();
|
||||
|
||||
QMessageBox closeConfirmDialog;
|
||||
|
||||
public:
|
||||
void save();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue