summaryrefslogtreecommitdiffstats
path: root/src/gui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui.cpp')
-rw-r--r--src/gui.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/gui.cpp b/src/gui.cpp
index e27086a..02925ad 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -11,6 +11,7 @@
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
+#include <QCloseEvent>
static QString STATE_COPYING("COPYING"); // Still busy copying original file, new chunks are only accepted in already copied range
static QString STATE_WAITING_FOR_UPLOAD_DONE("WAITING_FOR_UPLOAD_DONE"); // Copying done, just waiting for new chunks until client signals that it's done
@@ -27,13 +28,14 @@ Gui::Gui(const char *urlbase, const char *uuid, QWidget *parent)
, _urlAbort(QString(urlbase).append("abort/").append(uuid))
, _urlFinish(QString(urlbase).append("finish/").append(uuid))
, _denyInteraction(false)
+ , _allowClose(false)
, _tmrStatus(new QTimer(this))
, _status(nullptr)
{
_nam->setAutoDeleteReplies(true);
_nam->setTransferTimeout(5000);
setupUi();
- auto flags = windowFlags();
+ auto flags = windowFlags() | Qt::WindowStaysOnTopHint;
setWindowFlags(flags & ~(Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint));
_tmrStatus->start(2500);
QObject::connect(_tmrStatus, &QTimer::timeout, [this]() {
@@ -154,6 +156,7 @@ void Gui::updateButtons()
void Gui::pushedCancel(bool)
{
if (_remoteState == STATE_ERROR) {
+ _allowClose = true;
this->close();
return;
}
@@ -181,6 +184,7 @@ void Gui::pushedCancel(bool)
_remoteState = STATE_ERROR;
QMessageBox::information(this, tr("Ergebnis"), msg);
QTimer::singleShot(2000, [this]() {
+ _allowClose = true;
this->close();
});
}
@@ -190,6 +194,7 @@ void Gui::pushedCancel(bool)
void Gui::pushedOk(bool)
{
if (_remoteState == STATE_COMPLETELY_DONE || _remoteState == STATE_PROCESSING) {
+ _allowClose = true;
this->close();
return;
}
@@ -215,3 +220,12 @@ void Gui::pushedOk(bool)
}
});
}
+
+void Gui::closeEvent(QCloseEvent *e)
+{
+ if (_allowClose) {
+ QDialog::closeEvent(e);
+ } else {
+ e->ignore();
+ }
+}