Skip to content

Commit 325d667

Browse files
committed
Wip: Focus
1 parent 6b4e11e commit 325d667

9 files changed

+198
-134
lines changed

src/gui/folderstatusmodel.cpp

+29-31
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <QVarLengthArray>
3333

3434
#include <set>
35+
#include <winrt/base.h>
3536

3637
using namespace std::chrono_literals;
3738

@@ -181,7 +182,7 @@ namespace {
181182

182183

183184
FolderStatusModel::FolderStatusModel(QObject *parent)
184-
: QAbstractTableModel(parent)
185+
: QAbstractListModel(parent)
185186
, _accountState(nullptr)
186187
{
187188
}
@@ -243,23 +244,7 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
243244
if (!f)
244245
return QVariant();
245246

246-
const auto getSpace = [&]() -> GraphApi::Space * {
247-
if (_accountState->supportsSpaces()) {
248-
return _accountState->account()->spacesManager()->space(f->spaceId());
249-
}
250-
return nullptr;
251-
};
252-
253-
switch (static_cast<Roles>(role)) {
254-
case Roles::Subtitle: {
255-
if (auto *space = getSpace()) {
256-
if (!space->drive().getDescription().isEmpty()) {
257-
return space->drive().getDescription();
258-
}
259-
}
260-
return tr("Local folder: %1").arg(f->shortGuiLocalPath());
261-
}
262-
case Roles::FolderErrorMsg: {
247+
auto getErrors = [f] {
263248
auto errors = f->syncResult().errorStrings();
264249
const auto legacyError = FolderMan::instance()->unsupportedConfiguration(f->path());
265250
if (!legacyError) {
@@ -276,13 +261,24 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
276261
});
277262
}
278263
return errors;
279-
}
280-
case Roles::DisplayName: {
281-
if (auto *space = getSpace()) {
282-
return space->displayName();
264+
};
265+
266+
auto getDescription = [f] {
267+
if (auto *space = f->space()) {
268+
if (!space->drive().getDescription().isEmpty()) {
269+
return space->drive().getDescription();
270+
}
283271
}
272+
return tr("Local folder: %1").arg(f->shortGuiLocalPath());
273+
};
274+
275+
switch (static_cast<Roles>(role)) {
276+
case Roles::Subtitle:
277+
return getDescription();
278+
case Roles::FolderErrorMsg:
279+
return getErrors();
280+
case Roles::DisplayName:
284281
return f->displayName();
285-
}
286282
case Roles::FolderImageUrl:
287283
if (f->accountState()->supportsSpaces()) {
288284
// TODO: the url hast random parts to enforce a reload
@@ -323,15 +319,17 @@ QVariant FolderStatusModel::data(const QModelIndex &index, int role) const
323319
}
324320
return tr("%1 of %2 used").arg(Utility::octetsToString(used), Utility::octetsToString(total));
325321
}
326-
case Roles::ToolTip: {
327-
if (_accountState->isConnected()) {
328-
return tr("The status of %1 is %2").arg(f->displayName(), Utility::enumToDisplayName(f->syncResult().status()));
329-
} else {
330-
return tr("The account %1 is currently not connected.").arg(f->accountState()->account()->displayName());
331-
}
332-
}
333322
case Roles::Folder:
334323
return QVariant::fromValue(f);
324+
case Roles::AccessibleDescriptionRole: {
325+
QStringList desc = {f->displayName(), Utility::enumToDisplayName(f->syncResult().status())};
326+
desc << getErrors();
327+
if (f->syncResult().status() == SyncResult::SyncRunning) {
328+
desc << folderInfo->_progress._overallSyncString << QStringLiteral("%1%").arg(QString::number(folderInfo->_progress._overallPercent));
329+
}
330+
desc << getDescription();
331+
return desc.join(QLatin1Char(','));
332+
}
335333
}
336334
return {};
337335
}
@@ -365,8 +363,8 @@ QHash<int, QByteArray> FolderStatusModel::roleNames() const
365363
{static_cast<int>(Roles::SyncProgressItemString), "itemText"},
366364
{static_cast<int>(Roles::FolderErrorMsg), "errorMsg"},
367365
{static_cast<int>(Roles::Quota), "quota"},
368-
{static_cast<int>(Roles::ToolTip), "toolTip"},
369366
{static_cast<int>(Roles::Folder), "folder"},
367+
{static_cast<int>(Roles::AccessibleDescriptionRole), "accessibleDescription"},
370368
};
371369
}
372370

src/gui/folderstatusmodel.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ namespace {
4040
* @brief The FolderStatusModel class
4141
* @ingroup gui
4242
*/
43-
class FolderStatusModel : public QAbstractTableModel
43+
class FolderStatusModel : public QAbstractListModel
4444
{
4545
Q_OBJECT
4646
QML_ELEMENT
4747
public:
4848
enum class Roles {
49-
ToolTip = Qt::ToolTipRole,
49+
AccessibleDescriptionRole,
5050
DisplayName = Qt::UserRole + 1, // must be 0 as it is also used from the default delegate
5151
Subtitle,
5252
FolderErrorMsg,

src/gui/qml/AccountBar.qml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Pane {
6060
Layout.maximumWidth: widthHint
6161
icon.source: "image://ownCloud/core/plus-solid"
6262
text: qsTr("Add Account")
63-
visible: Theme.multiAccount | !AccountManager.accounts
63+
visible: Theme.multiAccount || AccountManager.accounts.length === 0
6464

6565
Keys.onBacktabPressed: event => {
6666
// If there are no account buttons, we're the first button, so handle the back-tab

src/gui/qml/AccountButton.qml

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ ToolButton {
2727
implicitWidth: Math.min(implicitContentWidth + leftPadding + rightPadding, widthHint)
2828

2929
// make the current button pop
30-
palette.button: palette.highlight
30+
// don't get highlight from our own palette or we create a binding loop
31+
palette.button: parent.palette.highlight
3132

3233
contentItem: ColumnLayout {
3334
spacing: control.spacing

0 commit comments

Comments
 (0)