fixed window title and file modification dialog

master
Marc Wäckerlin 7 years ago
parent 62fefb3183
commit e527c94918
  1. 19
      src/testgui.hxx
  2. 18
      src/testgui.ui
  3. 4
      src/webtester.cxx

@ -35,6 +35,7 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
QMainWindow(parent),
_typing(false),
_inEventFilter(false) {
setWindowTitle("[*]");
setupUi(this);
menuViews->addAction(_scriptDock->toggleViewAction());
menuViews->addAction(_setupScriptDock->toggleViewAction());
@ -118,6 +119,8 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
+char(out.status()+48)+")");
_actionSave->setEnabled(true);
_actionRevertToSaved->setEnabled(true);
setWindowModified(false);
setWindowTitle(_filename+"[*]");
} catch(const std::exception& x) {
QMessageBox::critical(this, tr("Save Failed"),
tr("Saving test script failed, %2. "
@ -127,11 +130,18 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
_status->setCurrentIndex(STATUS_NONE);
}
void on__actionClear_triggered() {
if (isWindowModified() &&
QMessageBox::question(this, tr("Changes Not Saved"),
tr("Clear script without saving changes?"))
!= QMessageBox::Yes)
return;
_testscript->clear();
_log->clear();
_filename.clear();
_actionSave->setEnabled(false);
_actionRevertToSaved->setEnabled(false);
setWindowTitle("[*]");
setWindowModified(false);
_status->setCurrentIndex(STATUS_NONE);
}
void on__run_clicked() {
@ -332,6 +342,13 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
QSettings settings("mrw", "webtester");
settings.setValue("geometry", saveGeometry());
settings.setValue("windowstate", saveState());
if (isWindowModified() &&
QMessageBox::question(this, tr("Changes Not Saved"),
tr("Leave without saving changes?"))
!= QMessageBox::Yes) {
event->ignore();
return;
}
QMainWindow::closeEvent(event);
}
bool eventFilter(QObject*, QEvent* event) {
@ -442,6 +459,8 @@ class TestGUI: public QMainWindow, protected Ui::TestGUI {
_filename = name;
_actionSave->setEnabled(true);
_actionRevertToSaved->setEnabled(true);
setWindowTitle(name+"[*]");
setWindowModified(false);
} catch(const std::exception& x) {
QMessageBox::critical(this, tr("Open Failed"),
tr("Reading test script failed, %2. "

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
<string/>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_6">
@ -1089,5 +1089,21 @@ this.dispatchEvent(evObj);</string>
</hint>
</hints>
</connection>
<connection>
<sender>_testscript</sender>
<signal>modificationChanged(bool)</signal>
<receiver>TestGUI</receiver>
<slot>setWindowModified(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>126</x>
<y>144</y>
</hint>
<hint type="destinationlabel">
<x>443</x>
<y>589</y>
</hint>
</hints>
</connection>
</connections>
</ui>

@ -1,9 +1,13 @@
#include <testgui.hxx>
#include <QApplication>
#include <QCommandLineParser>
#include <version.hxx>
int main(int argc, char *argv[]) try {
QApplication a(argc, argv);
a.setApplicationDisplayName(a.tr("WebTester"));
a.setApplicationName(webtester::package_name().c_str());
a.setApplicationVersion(webtester::version().c_str());
QCommandLineParser parser;
parser.addHelpOption();
parser.addOption(QCommandLineOption

Loading…
Cancel
Save