Skip to content

Commit a2c3667

Browse files
committed
Redesign local folder information in the account adding wizard
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
1 parent 0b355dc commit a2c3667

6 files changed

Lines changed: 660 additions & 713 deletions

src/gui/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ set(client_SRCS
245245
wizard/welcomepage.cpp
246246
wizard/linklabel.h
247247
wizard/linklabel.cpp
248+
wizard/elidedfilepathlabel.h
249+
wizard/elidedfilepathlabel.cpp
248250
)
249251

250252
if (Qt5WebEngine_FOUND AND Qt5WebEngineWidgets_FOUND)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (C) 2022 by Claudio Cambra <claudio.cambra@nextcloud.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but
10+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* for more details.
13+
*/
14+
15+
#include "elidedfilepathlabel.h"
16+
17+
#include <QDir>
18+
19+
namespace OCC {
20+
21+
ElidedFilePathLabel::ElidedFilePathLabel(QWidget *parent)
22+
: QLabel(parent)
23+
{
24+
setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
25+
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
26+
}
27+
28+
QString ElidedFilePathLabel::filePath() const
29+
{
30+
return _fullPath;
31+
}
32+
33+
void ElidedFilePathLabel::setFilePath(const QString &filePath)
34+
{
35+
_fullPath = filePath;
36+
Q_EMIT filePathChanged();
37+
updateLabelText();
38+
}
39+
40+
void ElidedFilePathLabel::resizeEvent(QResizeEvent *event)
41+
{
42+
Q_UNUSED(event);
43+
updateLabelText();
44+
}
45+
46+
void ElidedFilePathLabel::updateLabelText()
47+
{
48+
const QFontMetrics metrics(font());
49+
const auto elidedPath = metrics.elidedText(QDir::toNativeSeparators(_fullPath), Qt::ElideMiddle, width());
50+
setText(elidedPath);
51+
}
52+
53+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) 2022 by Claudio Cambra <claudio.cambra@nextcloud.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but
10+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* for more details.
13+
*/
14+
15+
#pragma once
16+
17+
#include <QLabel>
18+
19+
namespace OCC {
20+
21+
class ElidedFilePathLabel : public QLabel
22+
{
23+
Q_OBJECT
24+
Q_PROPERTY(QString filePath READ filePath WRITE setFilePath NOTIFY filePathChanged)
25+
26+
public:
27+
ElidedFilePathLabel(QWidget *parent = nullptr);
28+
29+
QString filePath() const;
30+
void setFilePath(const QString &filePath);
31+
32+
signals:
33+
void filePathChanged();
34+
35+
protected:
36+
void resizeEvent(QResizeEvent *event) override;
37+
38+
private:
39+
void updateLabelText();
40+
QString _fullPath;
41+
};
42+
43+
}

src/gui/wizard/owncloudadvancedsetuppage.cpp

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ OwncloudAdvancedSetupPage::OwncloudAdvancedSetupPage(OwncloudWizard *wizard)
4343
, _ocWizard(wizard)
4444
{
4545
_ui.setupUi(this);
46-
4746
setupResoultionWidget();
4847

48+
_filePathLabel.reset(new ElidedFilePathLabel);
49+
_ui.locationsGridLayout->addWidget(_filePathLabel.data(), 3, 3);
50+
4951
registerField(QLatin1String("OCSyncFromScratch"), _ui.cbSyncFromScratch);
5052

5153
auto sizePolicy = _progressIndi->sizePolicy();
@@ -116,6 +118,7 @@ void OwncloudAdvancedSetupPage::setupCustomization()
116118
variant = theme->customMedia(Theme::oCSetupBottom);
117119
WizardCommon::setupCustomMedia(variant, _ui.bottomLabel);
118120

121+
WizardCommon::customizeHintLabel(_filePathLabel.data());
119122
WizardCommon::customizeHintLabel(_ui.lFreeSpace);
120123
WizardCommon::customizeHintLabel(_ui.lSyncEverythingSizeLabel);
121124
WizardCommon::customizeHintLabel(_ui.lSelectiveSyncSizeLabel);
@@ -188,10 +191,11 @@ void OwncloudAdvancedSetupPage::fetchUserAvatar()
188191
{
189192
// Reset user avatar
190193
const auto appIcon = Theme::instance()->applicationIcon();
191-
_ui.lServerIcon->setPixmap(appIcon.pixmap(48));
194+
// To match the folder icon opposite the avatar -- that is 60x60, minus padding
195+
_ui.lServerIcon->setPixmap(appIcon.pixmap(32));
192196
// Fetch user avatar
193197
const auto account = _ocWizard->account();
194-
auto avatarSize = 64;
198+
auto avatarSize = 32;
195199
if (Theme::isHidpi()) {
196200
avatarSize *= 2;
197201
}
@@ -256,8 +260,6 @@ void OwncloudAdvancedSetupPage::updateStatus()
256260

257261
QString t;
258262

259-
setLocalFolderPushButtonPath(locFolder);
260-
261263
if (dataChanged()) {
262264
if (_remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/")) {
263265
t = "";
@@ -277,6 +279,8 @@ void OwncloudAdvancedSetupPage::updateStatus()
277279
setResolutionGuiVisible(false);
278280
}
279281

282+
_filePathLabel->setFilePath(locFolder);
283+
280284
QString lfreeSpaceStr = Utility::octetsToString(availableLocalSpace());
281285
_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));
282286

@@ -428,7 +432,6 @@ void OwncloudAdvancedSetupPage::slotSelectFolder()
428432
// TODO: remove when UX decision is made
429433
refreshVirtualFilesAvailibility(dir);
430434

431-
setLocalFolderPushButtonPath(dir);
432435
wizard()->setProperty("localFolder", dir);
433436
updateStatus();
434437
}
@@ -438,22 +441,6 @@ void OwncloudAdvancedSetupPage::slotSelectFolder()
438441
setErrorString(errorStr);
439442
}
440443

441-
442-
void OwncloudAdvancedSetupPage::setLocalFolderPushButtonPath(const QString &path)
443-
{
444-
const auto homeDir = QDir::homePath().endsWith('/') ? QDir::homePath() : QDir::homePath() + QLatin1Char('/');
445-
446-
if (!path.startsWith(homeDir)) {
447-
_ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(path));
448-
return;
449-
}
450-
451-
auto prettyPath = path;
452-
prettyPath.remove(0, homeDir.size());
453-
454-
_ui.pbSelectLocalFolder->setText(QDir::toNativeSeparators(prettyPath));
455-
}
456-
457444
void OwncloudAdvancedSetupPage::slotSelectiveSyncClicked()
458445
{
459446
AccountPtr acc = static_cast<OwncloudWizard *>(wizard())->account();

src/gui/wizard/owncloudadvancedsetuppage.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "wizard/owncloudwizardcommon.h"
2222
#include "ui_owncloudadvancedsetuppage.h"
23+
#include "elidedfilepathlabel.h"
2324

2425
class QProgressIndicator;
2526

@@ -76,7 +77,6 @@ private slots:
7677
QString checkLocalSpace(qint64 remoteSize) const;
7778
void customizeStyle();
7879
void setServerAddressLabelUrl(const QUrl &url);
79-
void setLocalFolderPushButtonPath(const QString &path);
8080
void styleSyncLogo();
8181
void styleLocalFolderLabel();
8282
void setResolutionGuiVisible(bool value);
@@ -93,10 +93,12 @@ private slots:
9393
bool _localFolderValid = false;
9494
QProgressIndicator *_progressIndi;
9595
QString _remoteFolder;
96+
QString _localPath;
9697
QStringList _selectiveSyncBlacklist;
9798
qint64 _rSize = -1;
9899
qint64 _rSelectedSize = -1;
99100
OwncloudWizard *_ocWizard;
101+
QScopedPointer<ElidedFilePathLabel> _filePathLabel;
100102
};
101103

102104
} // namespace OCC

0 commit comments

Comments
 (0)