diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index 156c33294d974..751f5fc1193c6 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -188,10 +189,10 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) _ui->tabWidget->setStyleSheet(QStringLiteral( "QTabWidget { background: transparent; }" "QTabWidget::pane { background: palette(alternate-base); border: none; }" - "QWidget#standardSyncTab, QWidget#connectionSettingsTab, QWidget#fileProviderPanelContents {" + "QWidget#syncFoldersPanelContents, QWidget#connectionSettingsTab, QWidget#fileProviderPanelContents {" " background: palette(alternate-base); }")); - _ui->standardSyncTab->setAutoFillBackground(true); - _ui->standardSyncTab->setAttribute(Qt::WA_StyledBackground, true); + _ui->syncFoldersPanelContents->setAutoFillBackground(true); + _ui->syncFoldersPanelContents->setAttribute(Qt::WA_StyledBackground, true); _ui->fileProviderPanelContents->setAutoFillBackground(true); _ui->fileProviderPanelContents->setAttribute(Qt::WA_StyledBackground, true); _ui->connectionSettingsTab->setAutoFillBackground(true); @@ -206,6 +207,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) _ui->_folderList->setStyleSheet(QStringLiteral("QTreeView { background: palette(alternate-base); }")); _ui->_folderList->setItemDelegate(delegate); _ui->_folderList->setModel(_model); + _ui->_folderList->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); _ui->_folderList->setMinimumWidth(300); new ToolTipUpdater(_ui->_folderList); @@ -263,6 +265,12 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) refreshSelectiveSyncStatus(); connect(_model, &QAbstractItemModel::rowsInserted, this, &AccountSettings::refreshSelectiveSyncStatus); + connect(_model, &QAbstractItemModel::rowsInserted, + _ui->_folderList, &QWidget::updateGeometry); + connect(_model, &QAbstractItemModel::rowsRemoved, + _ui->_folderList, &QWidget::updateGeometry); + connect(_model, &QAbstractItemModel::modelReset, + _ui->_folderList, &QWidget::updateGeometry); auto *syncNowAction = new QAction(this); syncNowAction->setShortcut(QKeySequence(Qt::Key_F6)); diff --git a/src/gui/accountsettings.ui b/src/gui/accountsettings.ui index 6fa1dcd3c7654..3f1f5e88c7eb6 100644 --- a/src/gui/accountsettings.ui +++ b/src/gui/accountsettings.ui @@ -15,7 +15,8 @@ - 0 + 0 + 0 0 1 @@ -198,114 +199,137 @@ - + QFrame::NoFrame - - - 12 - - - 12 - - - 12 - - - 12 - + - - - QTabWidget::Rounded - - - 0 + + + Sync folders - - - Standard file sync - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Qt::CustomContextMenu - - - false - - - QFrame::Shape::NoFrame - - - QAbstractItemView::NoEditTriggers - - - true - - - - - - - - Connection settings - - - - + + + + 0 + + + 0 + + + 0 + + + 0 + - - - - - - 0 - 0 - - - - Unchecked folders will be <b>removed</b> from your local file system and will not be synchronized to this computer anymore - - - Qt::RichText - - - true - - - true - - - - + + + + 0 + 0 + + + + Qt::CustomContextMenu + + + false + + + QFrame::Shape::NoFrame + + + QAbstractItemView::NoEditTriggers + + + true + + + + + + + + + + + + + 0 + 0 + + + + Unchecked folders will be <b>removed</b> from your local file system and will not be synchronized to this computer anymore + + + Qt::RichText + + + true + + + true + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + Cancel + + + + + + + + 0 + 0 + + + + Apply + + + + + + + + - - + + 0 @@ -319,30 +343,55 @@ 0 - - - - 0 - 0 - + + + color: red - Cancel + + + + true - - - - 0 - 0 - - - - Apply - - + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Synchronize all + + + + + + + Synchronize none + + + + + + + Apply manual changes + + + + @@ -350,73 +399,40 @@ + + + + + + + QFrame::NoFrame + + + + 12 + + + 12 + + + 12 + + + 12 + - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - color: red - - - - - - true - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Synchronize all - - - - - - - Synchronize none - - - - - - - Apply manual changes - - - - - - + + + QTabWidget::Rounded + + + 0 + + + + Connection settings + + diff --git a/src/gui/folderstatusview.cpp b/src/gui/folderstatusview.cpp index 86d16e6fc1238..5bc0319cb6230 100644 --- a/src/gui/folderstatusview.cpp +++ b/src/gui/folderstatusview.cpp @@ -6,6 +6,9 @@ #include "folderstatusview.h" #include "folderstatusdelegate.h" +#include +#include + namespace OCC { FolderStatusView::FolderStatusView(QWidget *parent) : QTreeView(parent) @@ -30,4 +33,26 @@ QRect FolderStatusView::visualRect(const QModelIndex &index) const return rect; } +QSize FolderStatusView::sizeHint() const +{ + const auto baseHint = QTreeView::sizeHint(); + if (!model()) { + return baseHint; + } + + const int rowCount = model()->rowCount(); + const int rowSizeHint = rowCount > 0 ? sizeHintForRow(0) : -1; + const int fallbackRowHeight = fontMetrics().height() + 8; + const int rowHeight = rowSizeHint > 0 ? rowSizeHint : fallbackRowHeight; + const int visibleRows = qMax(1, rowCount); + int height = rowHeight * visibleRows; + + height += frameWidth() * 2; + if (horizontalScrollBar()->isVisible()) { + height += horizontalScrollBar()->sizeHint().height(); + } + + return {baseHint.width(), height}; +} + } // namespace OCC diff --git a/src/gui/folderstatusview.h b/src/gui/folderstatusview.h index 6c66853001cab..c7f93cc6e7157 100644 --- a/src/gui/folderstatusview.h +++ b/src/gui/folderstatusview.h @@ -23,6 +23,7 @@ class FolderStatusView : public QTreeView [[nodiscard]] QModelIndex indexAt(const QPoint &point) const override; [[nodiscard]] QRect visualRect(const QModelIndex &index) const override; + [[nodiscard]] QSize sizeHint() const override; }; } // namespace OCC