Entails new strings, but I think the severity allows for that.
/// To be called when the buffer view has changed
virtual void onBufferViewChanged() = 0;
///
+ virtual void onClosing(int) = 0;
+ ///
void connectToNewInset();
private:
{
connect(&lv, SIGNAL(bufferViewChanged()),
this, SLOT(onBufferViewChanged()));
+ connect(&lv, SIGNAL(closing(int)),
+ this, SLOT(onClosing(int)));
// remove question marks from Windows dialogs
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
protected Q_SLOTS:
void onBufferViewChanged() override {}
+ void onClosing(int) override {}
};
} // namespace frontend
protected Q_SLOTS:
void onBufferViewChanged() override {}
+ void onClosing(int) override {}
};
} // namespace frontend
{
connect(&lv, SIGNAL(bufferViewChanged()),
this, SLOT(onBufferViewChanged()));
+ connect(&lv, SIGNAL(closing(int)),
+ this, SLOT(onClosing(int)));
// remove question marks from Windows dialogs
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
protected Q_SLOTS:
void onBufferViewChanged() override {}
+ void onClosing(int) override {}
public:
/** Check whether we may apply our data.
}
+void GuiDocument::onClosing(int const id)
+{
+ if (!guiApp || !guiApp->currentView()
+ || guiApp->currentView()->id() != id
+ || !bc().policy().buttonStatus(ButtonPolicy::RESTORE))
+ // notthing to do
+ return;
+
+ int const ret = Alert::prompt(_("Unapplied changes"),
+ _("Some changes in the document were not yet applied.\n"
+ "Do you want to apply them before closing?"),
+ 1, 1, _("Yes, &Apply"), _("No, &Dismiss Changes"));
+ if (ret == 0)
+ slotOK();
+}
+
+
void GuiDocument::onBufferViewChanged()
{
if (switchback_) {
// Only ask if we haven't yet in this cycle
int const ret = prompted_ ? 3 : Alert::prompt(_("Unapplied changes"),
_("Some changes in the previous document were not yet applied.\n"
- "Do you want to switch back and apply them?"),
- 1, 1, _("Yes, &Switch Back"), _("No, &Dismiss Changes"));
+ "Do you want to switch back in order to apply them or dismiss the changes?"),
+ 1, 1, _("&Switch Back"), _("&Dismiss Changes"));
if (ret == 0) {
// Switch to previous buffer view and apply
switchback_ = true;
public Q_SLOTS:
void onBufferViewChanged() override;
+ void onClosing(int) override;
// OK button clicked
void slotOK();
// Apply button clicked
// it can happen that this event arrives without selecting the view,
// e.g. when clicking the close button on a background window.
setFocus();
+ Q_EMIT closing(id_);
if (!closeWorkAreaAll()) {
closing_ = false;
close_event->ignore();