summaryrefslogtreecommitdiff
path: root/src/lockeddialog.cpp
diff options
context:
space:
mode:
authorBrian Munro <brian.alexander.munro@gmail.com>2018-03-05 11:35:58 +0200
committerGitHub <noreply@github.com>2018-03-05 11:35:58 +0200
commitc7e1d9738f06c6c6e7c9b41cdd8d35062d7c06b6 (patch)
treec9c92380fcc82a64df8956face14e22bc3d2b4f7 /src/lockeddialog.cpp
parent7dfe0c9a8feae35ba7554493eea4fdb4e33a64d3 (diff)
parenta540a542a47fe75d0d0e4594158422aef4340b3a (diff)
Merge pull request #252 from LePresidente/new_vfs_library
Update master to latest stable code.
Diffstat (limited to 'src/lockeddialog.cpp')
-rw-r--r--src/lockeddialog.cpp47
1 files changed, 20 insertions, 27 deletions
diff --git a/src/lockeddialog.cpp b/src/lockeddialog.cpp
index 519abd5b..143d5838 100644
--- a/src/lockeddialog.cpp
+++ b/src/lockeddialog.cpp
@@ -25,27 +25,26 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <QWidget>
#include <Qt> // for Qt::FramelessWindowHint, etc
-LockedDialog::LockedDialog(QWidget *parent, const QString &text, bool unlockButton)
- : QDialog(parent)
+LockedDialog::LockedDialog(QWidget *parent, bool unlockByButton)
+ : LockedDialogBase(parent, !unlockByButton)
, ui(new Ui::LockedDialog)
- , m_UnlockClicked(false)
{
ui->setupUi(this);
- this->setWindowFlags(this->windowFlags() | Qt::ToolTip | Qt::FramelessWindowHint);
+ // Supposedly the Qt::CustomizeWindowHint should use a customized window
+ // allowing us to select if there is a close button. In practice this doesn't
+ // seem to work. We will ignore pressing the close button if unlockByButton == true
+ Qt::WindowFlags flags =
+ this->windowFlags() | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint;
+ if (m_allowClose)
+ flags |= Qt::WindowCloseButtonHint;
+ this->setWindowFlags(flags);
- if (parent != nullptr) {
- QPoint position = parent->mapToGlobal(QPoint(parent->width() / 2, parent->height() / 2));
- position.rx() -= this->width() / 2;
- position.ry() -= this->height() / 2;
- move(position);
- }
-
- if (text.length() > 0) {
- ui->label->setText(text);
- }
- if (!unlockButton) {
+ if (!unlockByButton)
+ {
ui->unlockButton->hide();
+ ui->verticalLayout->addItem(
+ new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
}
}
@@ -60,19 +59,13 @@ void LockedDialog::setProcessName(const QString &name)
ui->processLabel->setText(name);
}
-
-void LockedDialog::resizeEvent(QResizeEvent *event)
+void LockedDialog::on_unlockButton_clicked()
{
- QWidget *par = parentWidget();
- if (par != nullptr) {
- QPoint position = par->mapToGlobal(QPoint(par->width() / 2, par->height() / 2));
- position.rx() -= event->size().width() / 2;
- position.ry() -= event->size().height() / 2;
- move(position);
- }
+ unlock();
}
-void LockedDialog::on_unlockButton_clicked()
-{
- m_UnlockClicked = true;
+void LockedDialog::unlock() {
+ LockedDialogBase::unlock();
+ ui->label->setText("unlocking may take a few seconds");
+ ui->unlockButton->setEnabled(false);
}