From 7b89a88e2c8e49a43888b3e2d1e7c1af07ffcbf4 Mon Sep 17 00:00:00 2001 From: Hannah von Reth Date: Fri, 12 Jan 2024 13:10:16 +0100 Subject: [PATCH] use groupbox --- src/gui/accountsettings.cpp | 54 ++++++++++++++++++++----------------- src/gui/accountsettings.h | 2 ++ src/gui/settingsdialog.cpp | 2 -- src/gui/settingsdialog.ui | 36 ------------------------- 4 files changed, 32 insertions(+), 62 deletions(-) diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 9277026444b..a12f63c45ac 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -53,6 +53,9 @@ #include "loginrequireddialog.h" #include "oauthloginwidget.h" + +#include + namespace OCC { Q_LOGGING_CATEGORY(lcAccountSettings, "gui.account.settings", QtInfoMsg) @@ -429,11 +432,9 @@ void AccountSettings::slotAddFolder() qCInfo(lcAccountSettings) << "Folder wizard cancelled"; FolderMan::instance()->setSyncEnabled(true); }); - connect(folderWizard, &QWidget::destroyed, this, [this] { ocApp()->gui()->settingsDialog()->ceaseModality(_accountState->account().get()); }); - ui->stackedWidget->addWidget(folderWizard); - ui->stackedWidget->setCurrentWidget(folderWizard); - ocApp()->gui()->settingsDialog()->requestModality(_accountState->account().get()); + folderWizard->setMinimumSize(ui->stackedWidget->size() * 0.9); + addModalWidget(folderWizard); } @@ -762,26 +763,7 @@ void AccountSettings::slotAccountStateChanged() showConnectionLabel(tr("Reauthorization required.")); - // layout the dialog - auto widget = new QWidget(this); - connect(_askForOAuthLoginDialog, &QWidget::destroyed, widget, [widget, this] { - widget->deleteLater(); - ocApp()->gui()->settingsDialog()->ceaseModality(_accountState->account().get()); - }); - auto vLayout = new QVBoxLayout(widget); - vLayout->addStretch(); - auto layout = new QHBoxLayout; - vLayout->addLayout(layout); - vLayout->addStretch(); - - layout->addStretch(); - layout->addWidget(_askForOAuthLoginDialog); - layout->addStretch(); - - ui->stackedWidget->addWidget(widget); - ui->stackedWidget->setCurrentWidget(widget); - ocApp()->gui()->settingsDialog()->requestModality(_accountState->account().get()); - + addModalWidget(_askForOAuthLoginDialog); QTimer::singleShot(0, [contentWidget]() { contentWidget->setFocus(Qt::OtherFocusReason); }); @@ -888,6 +870,30 @@ AccountSettings::~AccountSettings() delete ui; } +void AccountSettings::addModalWidget(QWidget *widget) +{ + // create a widget filling the stacked widget + // this widget contains a wrapping group box with widget as content + auto outerWidget = new QWidget; + auto outerLayout = new QGridLayout(outerWidget); + + auto groupBox = new QGroupBox; + outerLayout->addWidget(groupBox, 0, 0, Qt::AlignCenter); + auto layout = new QGridLayout(groupBox); + + groupBox->setTitle(widget->windowTitle()); + layout->addWidget(widget); + + ui->stackedWidget->addWidget(outerWidget); + ui->stackedWidget->setCurrentWidget(outerWidget); + + connect(widget, &QWidget::destroyed, this, [this, outerWidget] { + outerWidget->deleteLater(); + ocApp()->gui()->settingsDialog()->ceaseModality(_accountState->account().get()); + }); + ocApp()->gui()->settingsDialog()->requestModality(_accountState->account().get()); +} + void AccountSettings::refreshSelectiveSyncStatus() { QString msg; diff --git a/src/gui/accountsettings.h b/src/gui/accountsettings.h index 2cd39c0354b..33148ce3be5 100644 --- a/src/gui/accountsettings.h +++ b/src/gui/accountsettings.h @@ -59,6 +59,8 @@ class AccountSettings : public QWidget AccountStatePtr accountsState() const { return _accountState; } + void addModalWidget(QWidget *widget); + signals: void folderChanged(); void showIssuesList(); diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index 69f4398fba0..d187b9e2410 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -269,8 +269,6 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) QTimer::singleShot(0, this, &SettingsDialog::showFirstPage); - connect(_ui->hideButton, &QPushButton::clicked, this, &SettingsDialog::hide); - QAction *showLogWindow = new QAction(this); showLogWindow->setShortcut(QKeySequence(QStringLiteral("F12"))); connect(showLogWindow, &QAction::triggered, gui, &ownCloudGui::slotToggleLogBrowser); diff --git a/src/gui/settingsdialog.ui b/src/gui/settingsdialog.ui index 37d2235e02e..953243f2465 100644 --- a/src/gui/settingsdialog.ui +++ b/src/gui/settingsdialog.ui @@ -53,42 +53,6 @@ - - - - 9 - - - 9 - - - 9 - - - 9 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Hide - - - - -