Skip to content

Commit 60ca0b3

Browse files
authored
[DC-232] part 2 - follow up fixes (#12478)
hopefully final text updates including the display of %complete and up/download bandwidths during sync
1 parent bf2b775 commit 60ca0b3

6 files changed

Lines changed: 90 additions & 61 deletions

File tree

src/gui/FoldersGui/accountfolderscontroller.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void AccountFoldersController::buildMenuActions()
136136
separator->setSeparator(true);
137137
itemActions.push_back(separator);
138138

139-
_forceSync = new QAction(tr("Force sync now"), this);
139+
_forceSync = new QAction(tr("Sync now"), this);
140140
_forceSync->setObjectName("forceSyncAction");
141141
itemActions.push_back(_forceSync);
142142
connect(_forceSync, &QAction::triggered, this, &AccountFoldersController::onForceSync);
@@ -146,7 +146,7 @@ void AccountFoldersController::buildMenuActions()
146146
itemActions.push_back(_pauseSync);
147147
connect(_pauseSync, &QAction::triggered, this, &AccountFoldersController::onTogglePauseSync);
148148

149-
_chooseSync = new QAction(tr("Choose what to sync"), this);
149+
_chooseSync = new QAction(tr("Manage subfolder sync"), this);
150150
_chooseSync->setObjectName("selectiveSyncAction");
151151

152152
Vfs::Mode mode = VfsPluginManager::instance().bestAvailableVfsMode();
@@ -175,7 +175,7 @@ void AccountFoldersController::buildMenuActions()
175175
connect(_chooseSync, &QAction::triggered, this, &AccountFoldersController::onChooseSync);
176176
}
177177

178-
QString removeSyncString = tr("Remove %1 sync connection").arg(CommonStrings::space());
178+
QString removeSyncString = tr("Remove %1 sync").arg(CommonStrings::space());
179179
_removeSync = new QAction(removeSyncString, this);
180180
_removeSync->setObjectName("removeFolderSyncAction");
181181
itemActions.push_back(_removeSync);
@@ -237,7 +237,7 @@ void AccountFoldersController::updateActions()
237237
_showInBrowser->setEnabled(_currentFolder && _currentFolder->isConnected() && _currentFolder->isAvailable());
238238

239239
_forceSync->setEnabled(_currentFolder && _currentFolder->canSync());
240-
_forceSync->setText(_currentFolder && _currentFolder->isSyncRunning() ? tr("Restart sync") : tr("Force sync now"));
240+
_forceSync->setText(_currentFolder && _currentFolder->isSyncRunning() ? tr("Restart sync") : tr("Sync now"));
241241

242242
_pauseSync->setText(_currentFolder && _currentFolder->syncPaused() ? tr("Resume sync") : tr("Pause sync"));
243243
// this is a bit nuanced: we want to enable pause if the folder is disconnected as this is always a safe operation. if it *is* connected

src/gui/FoldersGui/accountfoldersview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void AccountFoldersView::setItemModels(QStandardItemModel *model, QItemSelection
175175

176176
void AccountFoldersView::setSyncedFolderCount(int synced, int total)
177177
{
178-
_syncedFolderCountLabel->setText(tr("%1 of %2 %3 are synchronized").arg(QString::number(synced), QString::number(total), CommonStrings::spaces()));
178+
_syncedFolderCountLabel->setText(tr("%1 out of %2 %3 are synchronized").arg(QString::number(synced), QString::number(total), CommonStrings::spaces()));
179179
}
180180

181181
void AccountFoldersView::enableAddFolder(bool enableAdd)

src/gui/FoldersGui/folderitem.cpp

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,41 @@ void FolderItem::setProgress(const ProgressInfo &progress)
5656
// this might be premature - if so use one of the completion states from folder sync result
5757
_totalSize = 0;
5858
_completedSize = 0;
59+
_percentComplete = 0;
60+
_estimatedDownBw = 0;
61+
_estimatedUpBw = 0;
5962
return;
6063
}
6164

6265
if (progress.totalSize() == 0) {
63-
// nothing is going to happen so ditch - with vfs this will always be the case?
66+
// nothing is going to happen, visually so ditch - with vfs this will always be the case?
6467
return;
6568
}
6669

67-
// completed size is literal - meaning if there was nothing to actually sync,
68-
// total size = 0
70+
// total size is literal - meaning if there was nothing to actually sync, total size = 0
6971
// this can happen if there are no files/folders in a space
70-
// or of the space is already 100% up to date, so no diffs, or if there is nothing to "move" between server/client (move or delete)
72+
// or of the space is already 100% up to date, so no diffs,
73+
// or if there is nothing to "move" between server/client (move or delete)
7174
_totalSize = progress.totalSize();
7275
_completedSize = progress.completedSize();
73-
//_percentComplete = progress.refresh();
76+
// the old impl added extra "bytes" to the calculation to account for "contentless" operations (move, delete, possibly vfs placeholder creation)
77+
// but I'm going with the simple calc because my strong gut feeling is that these tiny updates won't take long enough to substantially change the
78+
// info in the gui. If someone complains we can make it more complicated again.
79+
_percentComplete = qBound(0, qRound(double(_completedSize) / double(_totalSize) * 100.0), 100);
80+
81+
_estimatedUpBw = 0;
82+
_estimatedDownBw = 0;
83+
84+
for (const auto &citm : progress._currentItems) {
85+
// the idea here is the total available bandwidth will be "shared" among multiple items. So summing their individual bw consumption reveals
86+
// the total bw up or down.
87+
if (citm._item._direction == SyncFileItem::Up) {
88+
_estimatedUpBw += progress.fileProgress(citm._item).estimatedBandwidth;
89+
} else {
90+
_estimatedDownBw += progress.fileProgress(citm._item).estimatedBandwidth;
91+
}
92+
}
93+
7494
refresh();
7595
}
7696

@@ -134,8 +154,19 @@ QString FolderItem::statusAsString() const
134154
case SyncResult::SyncRunning: {
135155
QString completedFormatted = Utility::octetsToString(_completedSize);
136156
QString totalFormatted = Utility::octetsToString(_totalSize);
137-
138-
return tr("Syncing %1 of %2").arg(completedFormatted, totalFormatted);
157+
QString percentFormatted = QString::number(_percentComplete);
158+
QString progress = tr("Syncing %1 of %2 (%3 %").arg(completedFormatted, totalFormatted, percentFormatted);
159+
160+
if (_estimatedDownBw > 0) {
161+
QString formattedDownBw = Utility::octetsToString(_estimatedDownBw);
162+
progress.append(tr(", ⬇️ %1/s").arg(formattedDownBw));
163+
}
164+
if (_estimatedUpBw > 0) {
165+
QString formattedUpBw = Utility::octetsToString(_estimatedUpBw);
166+
progress.append(tr(", ⬆️ %1/s").arg(formattedUpBw));
167+
}
168+
progress.append(")");
169+
return progress;
139170
}
140171
};
141172

@@ -169,23 +200,7 @@ QVariant FolderItem::data(int role) const
169200
if (!_folder)
170201
return QVariant();
171202

172-
/* auto getErrors = [f] {
173-
auto errors = f->syncResult().errorStrings();
174-
const Result<void, QString> notLegacyError = FolderMan::instance()->unsupportedConfiguration(f->path());
175-
if (!notLegacyError) {
176-
errors.append(notLegacyError.error());
177-
}
178-
if (f->syncResult().hasUnresolvedConflicts()) {
179-
errors.append(tr("There are unresolved conflicts."));
180-
}
181-
return errors;
182-
};*/
183-
184203
switch (role) {
185-
// case Roles::Subtitle:
186-
// return getDescription();
187-
// case Roles::FolderErrorMsg:
188-
// return getErrors();
189204
case Qt::DisplayRole:
190205
return _folder->displayName();
191206
case Qt::DecorationRole:
@@ -194,27 +209,10 @@ QVariant FolderItem::data(int role) const
194209
return Resources::getCoreIcon(statusIconName());
195210
case FolderItemRoles::StatusStringRole:
196211
return _statusString;
197-
// case ItemRoles::StatusInfoRole:
198-
// return _progress._progressString;
199-
/*case Roles::SyncProgressOverallPercent:
200-
return folderInfo->_progress._overallPercent / 100.0;
201-
case Roles::SyncProgressOverallString:
202-
return folderInfo->_progress._overallSyncString; */
203212
case FolderItemRoles::SortPriorityRole:
204213
// everything will be sorted in descending order, multiply the priority by 100 and prefer A over Z by applying a negative factor
205214
return QVariant::fromValue(
206215
_folder->sortPriority() * 100 - (_folder->displayName().isEmpty() ? 0 : static_cast<int64_t>(_folder->displayName().at(0).toLower().unicode())));
207-
/*
208-
209-
case Roles::AccessibleDescriptionRole: {
210-
QStringList desc = {f->displayName(), Utility::enumToDisplayName(f->syncResult().status())};
211-
desc << getErrors();
212-
if (f->syncResult().status() == SyncResult::SyncRunning) {
213-
desc << folderInfo->_progress._overallSyncString << QStringLiteral("%1%").arg(QString::number(folderInfo->_progress._overallPercent));
214-
}
215-
desc << getDescription();
216-
return desc.join(QLatin1Char(','));
217-
}*/
218216
}
219217
return QStandardItem::data(role);
220218
}

src/gui/FoldersGui/folderitem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ class FolderItem : public QStandardItem
5353

5454
quint64 _totalSize = 0;
5555
quint64 _completedSize = 0;
56+
quint64 _estimatedUpBw = 0;
57+
quint64 _estimatedDownBw = 0;
58+
int _percentComplete = 0;
59+
5660
QString _statusString;
5761
QIcon _image;
5862
// ProgressInfo _progress;

test/gui/shared/scripts/names.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,4 @@
6767
confirm_Folder_Sync_Connection_Removal_QMessageBox_2 = {"type": "QMessageBox", "unnamed": 1, "visible": 1, "windowTitle": "Confirm Folder Sync Connection Removal"}
6868
confirmRemoveFolderSyncDialog_QMessageBox = {"name": "confirmRemoveFolderSyncDialog", "type": "QMessageBox", "visible": 1}
6969
confirmRemoveFolderSyncDialog_removeFolderSyncButton_QPushButton = {"name": "removeFolderSyncButton", "type": "QPushButton", "visible": 1, "window": confirmRemoveFolderSyncDialog_QMessageBox}
70+
settings_folderOptionsMenu_QMenu = {"name": "folderOptionsMenu", "type": "QMenu", "visible": 1, "window": settings_OCC_SettingsDialog}

test/gui/shared/scripts/pageObjects/SyncConnection.py

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@ class SyncConnection:
3030
"type": "QPushButton",
3131
"visible": 1,
3232
}
33-
MENU = {
34-
"type": "QMenu",
35-
"window": names.settings_OCC_SettingsDialog,
36-
"name": "folderOptionsMenu",
37-
"visible": 1,
38-
}
3933
DISABLE_VFS_CONFIRMATION_BUTTON = {
4034
"name": "DisableVFSSupportButton",
4135
"type": "QPushButton",
@@ -59,6 +53,36 @@ class SyncConnection:
5953
"visible": 1,
6054
"window": names.confirmRemoveFolderSyncDialog_QMessageBox,
6155
}
56+
FORCE_SYNC_ACTION_MENU_OPTION = {
57+
"container": names.settings_folderOptionsMenu_QMenu,
58+
"name": "forceSyncAction",
59+
"type": "QAction",
60+
"visible": True,
61+
}
62+
PAUSE_SYNC_ACTION_MENU_OPTION = {
63+
"container": names.settings_folderOptionsMenu_QMenu,
64+
"name": "pauseSyncAction",
65+
"type": "QAction",
66+
"visible": True,
67+
}
68+
SELECTIVE_SYNC_ACTION_MENU_OPTION = {
69+
"container": names.settings_folderOptionsMenu_QMenu,
70+
"name": "selectiveSyncAction",
71+
"type": "QAction",
72+
"visible": True,
73+
}
74+
REMOVE_FOLDER_SYNC_ACTION_MENU_OPTION = {
75+
"container": names.settings_folderOptionsMenu_QMenu,
76+
"name": "removeFolderSyncAction",
77+
"type": "QAction",
78+
"visible": True,
79+
}
80+
ENABLE_VFS_ACTION_MENU_OPTION = {
81+
"container": names.settings_folderOptionsMenu_QMenu,
82+
"name": "enableVfsAction",
83+
"type": "QAction",
84+
"visible": True,
85+
}
6286

6387
@staticmethod
6488
def open_menu(sync_folder=""):
@@ -80,45 +104,45 @@ def open_menu(sync_folder=""):
80104
@staticmethod
81105
def perform_action(action, sync_folder=""):
82106
SyncConnection.open_menu(sync_folder)
83-
squish.activateItem(squish.waitForObjectItem(SyncConnection.MENU, action))
107+
squish.activateItem(squish.waitForObject(action))
84108

85109
@staticmethod
86110
def force_sync():
87-
SyncConnection.perform_action("Force sync now")
111+
SyncConnection.perform_action(SyncConnection.FORCE_SYNC_ACTION_MENU_OPTION)
88112

89113
@staticmethod
90114
def pause_sync():
91-
SyncConnection.perform_action("Pause sync")
115+
SyncConnection.perform_action(SyncConnection.PAUSE_SYNC_ACTION_MENU_OPTION)
92116

93117
@staticmethod
94118
def resume_sync():
95-
SyncConnection.perform_action("Resume sync")
119+
SyncConnection.perform_action(SyncConnection.PAUSE_SYNC_ACTION_MENU_OPTION)
96120

97121
@staticmethod
98122
def enable_vfs():
99-
SyncConnection.perform_action("Enable virtual file support")
123+
SyncConnection.perform_action(SyncConnection.ENABLE_VFS_ACTION_MENU_OPTION)
100124

101125
@staticmethod
102126
def disable_vfs():
103-
SyncConnection.perform_action("Disable virtual file support")
127+
SyncConnection.perform_action(SyncConnection.ENABLE_VFS_ACTION_MENU_OPTION)
104128
squish.clickButton(
105129
squish.waitForObject(SyncConnection.DISABLE_VFS_CONFIRMATION_BUTTON)
106130
)
107131

108132
@staticmethod
109133
def has_menu_item(item):
110-
return squish.waitForObjectItem(SyncConnection.MENU, item)
134+
return squish.waitForObjectItem(names.settings_folderOptionsMenu_QMenu, item)
111135

112136
@staticmethod
113137
def menu_item_exists(menu_item):
114-
obj = SyncConnection.MENU.copy()
138+
obj = names.settings_folderOptionsMenu_QMenu.copy()
115139
obj.update({"type": "QAction", "text": menu_item})
116140
return object.exists(obj)
117141

118142
@staticmethod
119143
def choose_what_to_sync():
120144
SyncConnection.open_menu()
121-
SyncConnection.perform_action("Choose what to sync")
145+
SyncConnection.perform_action(SyncConnection.SELECTIVE_SYNC_ACTION_MENU_OPTION)
122146

123147
@staticmethod
124148
def unselect_folder_in_selective_sync(folder_name):
@@ -156,7 +180,9 @@ def get_folder_connection_count():
156180

157181
@staticmethod
158182
def remove_folder_sync_connection(sync_folder=""):
159-
SyncConnection.perform_action("Remove space sync connection", sync_folder)
183+
SyncConnection.perform_action(
184+
SyncConnection.REMOVE_FOLDER_SYNC_ACTION_MENU_OPTION, sync_folder
185+
)
160186

161187
@staticmethod
162188
def cancel_folder_sync_connection_removal():

0 commit comments

Comments
 (0)