Skip to content

Commit

Permalink
use groupbox
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOneRing committed Jan 12, 2024
1 parent 7982bde commit 7b89a88
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 62 deletions.
54 changes: 30 additions & 24 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
#include "loginrequireddialog.h"
#include "oauthloginwidget.h"


#include <QGroupBox>

namespace OCC {

Q_LOGGING_CATEGORY(lcAccountSettings, "gui.account.settings", QtInfoMsg)
Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/accountsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class AccountSettings : public QWidget

AccountStatePtr accountsState() const { return _accountState; }

void addModalWidget(QWidget *widget);

signals:
void folderChanged();
void showIssuesList();
Expand Down
2 changes: 0 additions & 2 deletions src/gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
36 changes: 0 additions & 36 deletions src/gui/settingsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -53,42 +53,6 @@
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="hideButton">
<property name="text">
<string>Hide</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
Expand Down

0 comments on commit 7b89a88

Please sign in to comment.