Define shortcuts for Save & Discard buttons of message box that appears when closing a document
This commit is contained in:
parent
6f38f91dd0
commit
94f07c85ee
|
@ -24,10 +24,12 @@
|
|||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QAbstractButton>
|
||||
# include <qapplication.h>
|
||||
# include <qdir.h>
|
||||
# include <qfileinfo.h>
|
||||
# include <QGLWidget>
|
||||
# include <QKeySequence>
|
||||
# include <qmessagebox.h>
|
||||
# include <qstatusbar.h>
|
||||
# include <boost/signals.hpp>
|
||||
|
@ -1203,6 +1205,22 @@ bool Document::canClose ()
|
|||
box.setInformativeText(QObject::tr("If you don't save, your changes will be lost."));
|
||||
box.setStandardButtons(QMessageBox::Discard | QMessageBox::Cancel | QMessageBox::Save);
|
||||
box.setDefaultButton(QMessageBox::Save);
|
||||
box.setEscapeButton(QMessageBox::Cancel);
|
||||
|
||||
// add shortcuts
|
||||
QAbstractButton* saveBtn = box.button(QMessageBox::Save);
|
||||
if (saveBtn->shortcut().isEmpty()) {
|
||||
QString text = saveBtn->text();
|
||||
text.prepend(QLatin1Char('&'));
|
||||
saveBtn->setShortcut(QKeySequence::mnemonic(text));
|
||||
}
|
||||
|
||||
QAbstractButton* discardBtn = box.button(QMessageBox::Discard);
|
||||
if (discardBtn->shortcut().isEmpty()) {
|
||||
QString text = discardBtn->text();
|
||||
text.prepend(QLatin1Char('&'));
|
||||
discardBtn->setShortcut(QKeySequence::mnemonic(text));
|
||||
}
|
||||
|
||||
switch (box.exec())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user