diff options
| author | Jeremy Rimpo <jeremy.rimpo@servermonkey.com> | 2017-12-13 15:58:43 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-13 15:58:43 -0600 |
| commit | 554b46847589fffb6cd7bc5c54689665c34ed95b (patch) | |
| tree | 235f1cad320f73e6b22cdf330d9a14d42bd33092 /src/lockeddialog.cpp | |
| parent | e4b952278d978567af3210d6a4be992eef3ba205 (diff) | |
| parent | 604d86ed07711651bc71871f6d37a794d916da6a (diff) | |
Merge pull request #148 from erasmux/lockeddialog_fixes
Lockeddialog fixes
Diffstat (limited to 'src/lockeddialog.cpp')
| -rw-r--r-- | src/lockeddialog.cpp | 47 |
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);
}
|
