Skip to content

Commit

Permalink
Merge pull request #4638 from nextcloud/feature/local-folder-button
Browse files Browse the repository at this point in the history
Redesign local folder information in the account-adding wizard
  • Loading branch information
mgallien authored Jun 24, 2022
2 parents e50ac34 + d8d72e8 commit 5337d4b
Show file tree
Hide file tree
Showing 3 changed files with 565 additions and 713 deletions.
34 changes: 12 additions & 22 deletions src/gui/wizard/owncloudadvancedsetuppage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage(OwncloudWizard *wizard)
, _ocWizard(wizard)
{
_ui.setupUi(this);

setupResoultionWidget();

_filePathLabel.reset(new ElidedLabel);
_filePathLabel->setElideMode(Qt::ElideMiddle);
_filePathLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
_filePathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
_ui.locationsGridLayout->addWidget(_filePathLabel.data(), 3, 3);

registerField(QLatin1String("OCSyncFromScratch"), _ui.cbSyncFromScratch);

auto sizePolicy = _progressIndi->sizePolicy();
Expand Down Expand Up @@ -116,6 +121,7 @@ void OwncloudAdvancedSetupPage::setupCustomization()
variant = theme->customMedia(Theme::oCSetupBottom);
WizardCommon::setupCustomMedia(variant, _ui.bottomLabel);

WizardCommon::customizeHintLabel(_filePathLabel.data());
WizardCommon::customizeHintLabel(_ui.lFreeSpace);
WizardCommon::customizeHintLabel(_ui.lSyncEverythingSizeLabel);
WizardCommon::customizeHintLabel(_ui.lSelectiveSyncSizeLabel);
Expand Down Expand Up @@ -188,10 +194,11 @@ void OwncloudAdvancedSetupPage::fetchUserAvatar()
{
// Reset user avatar
const auto appIcon = Theme::instance()->applicationIcon();
_ui.lServerIcon->setPixmap(appIcon.pixmap(48));
// To match the folder icon opposite the avatar -- that is 60x60, minus padding
_ui.lServerIcon->setPixmap(appIcon.pixmap(32));
// Fetch user avatar
const auto account = _ocWizard->account();
auto avatarSize = 64;
auto avatarSize = 32;
if (Theme::isHidpi()) {
avatarSize *= 2;
}
Expand Down Expand Up @@ -256,8 +263,6 @@ void OwncloudAdvancedSetupPage::updateStatus()

QString t;

setLocalFolderPushButtonPath(locFolder);

if (dataChanged()) {
if (_remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/")) {
t = "";
Expand All @@ -277,6 +282,8 @@ void OwncloudAdvancedSetupPage::updateStatus()
setResolutionGuiVisible(false);
}

_filePathLabel->setText(QDir::toNativeSeparators(locFolder));

QString lfreeSpaceStr = Utility::octetsToString(availableLocalSpace());
_ui.lFreeSpace->setText(QString(tr("%1 free space", "%1 gets replaced with the size and a matching unit. Example: 3 MB or 5 GB")).arg(lfreeSpaceStr));

Expand Down Expand Up @@ -428,7 +435,6 @@ void OwncloudAdvancedSetupPage::slotSelectFolder()
// TODO: remove when UX decision is made
refreshVirtualFilesAvailibility(dir);

setLocalFolderPushButtonPath(dir);
wizard()->setProperty("localFolder", dir);
updateStatus();
}
Expand All @@ -438,22 +444,6 @@ void OwncloudAdvancedSetupPage::slotSelectFolder()
setErrorString(errorStr);
}


void OwncloudAdvancedSetupPage::setLocalFolderPushButtonPath(const QString &path)
{
const auto homeDir = QDir::homePath().endsWith('/') ? QDir::homePath() : QDir::homePath() + QLatin1Char('/');

if (!path.startsWith(homeDir)) {
_ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(path));
return;
}

auto prettyPath = path;
prettyPath.remove(0, homeDir.size());

_ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(prettyPath));
}

void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()
{
AccountPtr acc = static_cast<OwncloudWizard *>(wizard())->account();
Expand Down
4 changes: 3 additions & 1 deletion src/gui/wizard/owncloudadvancedsetuppage.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "wizard/owncloudwizardcommon.h"
#include "ui_owncloudadvancedsetuppage.h"
#include "elidedlabel.h"

class QProgressIndicator;

Expand Down Expand Up @@ -76,7 +77,6 @@ private slots:
QString checkLocalSpace(qint64 remoteSize) const;
void customizeStyle();
void setServerAddressLabelUrl(const QUrl &url);
void setLocalFolderPushButtonPath(const QString &path);
void styleSyncLogo();
void styleLocalFolderLabel();
void setResolutionGuiVisible(bool value);
Expand All @@ -93,10 +93,12 @@ private slots:
bool _localFolderValid = false;
QProgressIndicator *_progressIndi;
QString _remoteFolder;
QString _localPath;
QStringList _selectiveSyncBlacklist;
qint64 _rSize = -1;
qint64 _rSelectedSize = -1;
OwncloudWizard *_ocWizard;
QScopedPointer<ElidedLabel> _filePathLabel;
};

} // namespace OCC
Expand Down
Loading

0 comments on commit 5337d4b

Please sign in to comment.