GUI: non-modal message box (#1416)
This commit is contained in:
parent
8d6783f91c
commit
81dc667177
|
@ -449,7 +449,6 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
|||
if(bCanClose)
|
||||
{
|
||||
saveWindowSettings();
|
||||
emit Bridge::getBridge()->close();
|
||||
}
|
||||
if(BridgeSettingGetUint("Gui", "NoCloseDialog", &noClose) && noClose)
|
||||
mCloseDialog->hide();
|
||||
|
@ -465,6 +464,7 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
|||
CloseSnowman(mSnowmanView);
|
||||
Sleep(100);
|
||||
mCloseThread->start();
|
||||
emit Bridge::getBridge()->close();
|
||||
}
|
||||
if(bCanClose)
|
||||
{
|
||||
|
|
|
@ -24,6 +24,12 @@ ScriptView::ScriptView(StdTable* parent) : StdTable(parent)
|
|||
|
||||
setupContextMenu();
|
||||
|
||||
//message box
|
||||
msg = new QMessageBox(this);
|
||||
msg->setWindowFlags(msg->windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
msg->setModal(false);
|
||||
connect(msg, SIGNAL(finished(int)), this, SLOT(messageResult(int)));
|
||||
|
||||
// Slots
|
||||
connect(Bridge::getBridge(), SIGNAL(scriptAdd(int, const char**)), this, SLOT(add(int, const char**)));
|
||||
connect(Bridge::getBridge(), SIGNAL(scriptClear()), this, SLOT(clear()));
|
||||
|
@ -34,6 +40,7 @@ ScriptView::ScriptView(StdTable* parent) : StdTable(parent)
|
|||
connect(Bridge::getBridge(), SIGNAL(scriptMessage(QString)), this, SLOT(message(QString)));
|
||||
connect(Bridge::getBridge(), SIGNAL(scriptQuestion(QString)), this, SLOT(question(QString)));
|
||||
connect(Bridge::getBridge(), SIGNAL(scriptEnableHighlighting(bool)), this, SLOT(enableHighlighting(bool)));
|
||||
connect(Bridge::getBridge(), SIGNAL(close()), msg, SLOT(close()));
|
||||
connect(this, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(contextMenuSlot(QPoint)));
|
||||
|
||||
Initialize();
|
||||
|
@ -505,12 +512,12 @@ void ScriptView::cmdExec()
|
|||
|
||||
void ScriptView::message(QString message)
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Information, tr("Message"), message);
|
||||
msg.setWindowIcon(DIcon("information.png"));
|
||||
msg.setParent(this, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
msg.exec();
|
||||
Bridge::getBridge()->setResult();
|
||||
msg->setIcon(QMessageBox::Information);
|
||||
msg->setWindowTitle(tr("Message"));
|
||||
msg->setText(message);
|
||||
msg->setStandardButtons(QMessageBox::Ok);
|
||||
msg->setWindowIcon(DIcon("information.png"));
|
||||
msg->show();
|
||||
}
|
||||
|
||||
void ScriptView::newIp()
|
||||
|
@ -524,17 +531,20 @@ void ScriptView::newIp()
|
|||
|
||||
void ScriptView::question(QString message)
|
||||
{
|
||||
QMessageBox msg(QMessageBox::Question, tr("Question"), message, QMessageBox::Yes | QMessageBox::No);
|
||||
msg.setWindowIcon(DIcon("question.png"));
|
||||
msg.setParent(this, Qt::Dialog);
|
||||
msg.setWindowFlags(msg.windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
if(msg.exec() == QMessageBox::Yes)
|
||||
Bridge::getBridge()->setResult(1);
|
||||
else
|
||||
Bridge::getBridge()->setResult(0);
|
||||
msg->setIcon(QMessageBox::Question);
|
||||
msg->setWindowTitle(tr("Question"));
|
||||
msg->setText(message);
|
||||
msg->setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msg->setWindowIcon(DIcon("question.png"));
|
||||
msg->show();
|
||||
}
|
||||
|
||||
void ScriptView::enableHighlighting(bool enable)
|
||||
{
|
||||
mEnableSyntaxHighlighting = enable;
|
||||
}
|
||||
|
||||
void ScriptView::messageResult(int result)
|
||||
{
|
||||
Bridge::getBridge()->setResult(result == QMessageBox::Yes);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "StdTable.h"
|
||||
|
||||
class QMessageBox;
|
||||
|
||||
class ScriptView : public StdTable
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -39,6 +41,7 @@ public slots:
|
|||
void newIp();
|
||||
void question(QString message);
|
||||
void enableHighlighting(bool enable);
|
||||
void messageResult(int result);
|
||||
|
||||
private:
|
||||
//private functions
|
||||
|
@ -52,6 +55,7 @@ private:
|
|||
QString filename;
|
||||
|
||||
MenuBuilder* mMenu;
|
||||
QMessageBox* msg = nullptr;
|
||||
};
|
||||
|
||||
#endif // SCRIPTVIEW_H
|
||||
|
|
Loading…
Reference in New Issue