mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
minor changes to the close tab confirm dialog
This commit is contained in:
parent
17f5fd0ff1
commit
66014d07a0
|
@ -49,10 +49,10 @@ Notebook::Notebook(Window *parent, bool _showButtons, const std::string &setting
|
|||
|
||||
this->loadTabs();
|
||||
|
||||
closeConfirmDialog.setText("Are you sure to close this tab?");
|
||||
closeConfirmDialog.setText("Are you sure you want to close this tab?");
|
||||
closeConfirmDialog.setIcon(QMessageBox::Icon::Question);
|
||||
closeConfirmDialog.setStandardButtons(QMessageBox::Close | QMessageBox::Abort);
|
||||
closeConfirmDialog.setDefaultButton(QMessageBox::Close);
|
||||
closeConfirmDialog.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
|
||||
closeConfirmDialog.setDefaultButton(QMessageBox::Yes);
|
||||
}
|
||||
|
||||
SplitContainer *Notebook::addNewPage()
|
||||
|
@ -80,8 +80,9 @@ SplitContainer *Notebook::addPage(const std::string &uuid, bool select)
|
|||
|
||||
void Notebook::removePage(SplitContainer *page)
|
||||
{
|
||||
if (closeConfirmDialog.exec() != QMessageBox::Close)
|
||||
if (page->splitCount() > 0 && closeConfirmDialog.exec() != QMessageBox::Yes) {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = this->pages.indexOf(page);
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ SplitContainer::SplitContainer(Notebook *parent, NotebookTab *_tab, const std::s
|
|||
, chats(fS("{}/chats", this->settingRoot))
|
||||
, tab(_tab)
|
||||
, dropPreview(this)
|
||||
, chatWidgets()
|
||||
, splits()
|
||||
{
|
||||
this->tab->page = this;
|
||||
|
||||
|
@ -64,12 +64,17 @@ void SplitContainer::updateFlexValues()
|
|||
}
|
||||
}
|
||||
|
||||
int SplitContainer::splitCount() const
|
||||
{
|
||||
return this->splits.size();
|
||||
}
|
||||
|
||||
std::pair<int, int> SplitContainer::removeFromLayout(Split *widget)
|
||||
{
|
||||
// remove reference to chat widget from chatWidgets vector
|
||||
auto it = std::find(std::begin(this->chatWidgets), std::end(this->chatWidgets), widget);
|
||||
if (it != std::end(this->chatWidgets)) {
|
||||
this->chatWidgets.erase(it);
|
||||
auto it = std::find(std::begin(this->splits), std::end(this->splits), widget);
|
||||
if (it != std::end(this->splits)) {
|
||||
this->splits.erase(it);
|
||||
|
||||
this->refreshTitle();
|
||||
}
|
||||
|
@ -102,7 +107,7 @@ std::pair<int, int> SplitContainer::removeFromLayout(Split *widget)
|
|||
|
||||
void SplitContainer::addToLayout(Split *widget, std::pair<int, int> position)
|
||||
{
|
||||
this->chatWidgets.push_back(widget);
|
||||
this->splits.push_back(widget);
|
||||
|
||||
this->refreshTitle();
|
||||
|
||||
|
@ -139,7 +144,7 @@ void SplitContainer::addToLayout(Split *widget, std::pair<int, int> position)
|
|||
|
||||
const std::vector<Split *> &SplitContainer::getChatWidgets() const
|
||||
{
|
||||
return this->chatWidgets;
|
||||
return this->splits;
|
||||
}
|
||||
|
||||
NotebookTab *SplitContainer::getTab() const
|
||||
|
@ -448,7 +453,7 @@ void SplitContainer::refreshTitle()
|
|||
QString newTitle = "";
|
||||
bool first = true;
|
||||
|
||||
for (const auto &chatWidget : this->chatWidgets) {
|
||||
for (const auto &chatWidget : this->splits) {
|
||||
auto channelName = QString::fromStdString(chatWidget->channelName.getValue());
|
||||
|
||||
if (channelName.isEmpty()) {
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
void requestFocus(int x, int y);
|
||||
|
||||
void updateFlexValues();
|
||||
int splitCount() const;
|
||||
|
||||
protected:
|
||||
virtual bool eventFilter(QObject *object, QEvent *event) override;
|
||||
|
@ -86,7 +87,7 @@ private:
|
|||
QHBoxLayout hbox;
|
||||
} ui;
|
||||
|
||||
std::vector<Split *> chatWidgets;
|
||||
std::vector<Split *> splits;
|
||||
std::vector<DropRegion> dropRegions;
|
||||
|
||||
pajlada::Settings::Setting<std::vector<std::vector<std::string>>> chats;
|
||||
|
|
Loading…
Reference in a new issue