diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/options.cpp | 42 | ||||
-rw-r--r-- | gui/options.h | 9 | ||||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout.stx | 3 | ||||
-rw-r--r-- | gui/themes/scummmodern/scummmodern_layout_lowres.stx | 3 |
4 files changed, 56 insertions, 1 deletions
diff --git a/gui/options.cpp b/gui/options.cpp index ac3cc0cc3a..2ab6b1eb6b 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -91,7 +91,8 @@ enum { #ifdef USE_CLOUD enum { - kConfigureStorageCmd = 'cfst' + kConfigureStorageCmd = 'cfst', + kRefreshStorageCmd = 'rfst' }; #endif @@ -1290,8 +1291,10 @@ GlobalOptionsDialog::GlobalOptionsDialog() _storageLastSync = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageLastSyncLabel", "<never>"); _storageConnectButton = new ButtonWidget(tab, "GlobalOptions_Cloud.ConnectButton", _("Connect"), _("Open wizard dialog to connect your cloud storage account"), kConfigureStorageCmd); + _storageRefreshButton = new ButtonWidget(tab, "GlobalOptions_Cloud.RefreshButton", _("Refresh"), _("Refresh current cloud storage information (username and usage)"), kRefreshStorageCmd); setupCloudTab(); + _redrawCloudTab = false; #endif // Activate the first tab @@ -1587,6 +1590,14 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 draw(); break; } + case kRefreshStorageCmd: + { + CloudMan.info(new Common::Callback<GlobalOptionsDialog, Cloud::Storage::StorageInfoResponse>(this, &GlobalOptionsDialog::storageInfoCallback), nullptr); + Common::String dir = CloudMan.savesDirectoryPath(); + if (dir.lastChar() == '/') dir.deleteLastChar(); + CloudMan.listDirectory(dir, new Common::Callback<GlobalOptionsDialog, Cloud::Storage::ListDirectoryResponse>(this, &GlobalOptionsDialog::storageListDirectoryCallback), nullptr); + break; + } #endif #ifdef GUI_ENABLE_KEYSDIALOG case kChooseKeyMappingCmd: @@ -1609,6 +1620,17 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 } } +void GlobalOptionsDialog::handleTickle() { + OptionsDialog::handleTickle(); +#ifdef USE_CLOUD + if (_redrawCloudTab) { + setupCloudTab(); + draw(); + _redrawCloudTab = false; + } +#endif +} + void GlobalOptionsDialog::reflowLayout() { int activeTab = _tabWidget->getActiveTab(); @@ -1673,6 +1695,24 @@ void GlobalOptionsDialog::setupCloudTab() { _storageLastSync->setVisible(shown); } if (_storageConnectButton) _storageConnectButton->setVisible(shown); + if (_storageRefreshButton) _storageRefreshButton->setVisible(shown && _selectedStorageIndex == CloudMan.getStorageIndex()); +} + +void GlobalOptionsDialog::storageInfoCallback(Cloud::Storage::StorageInfoResponse response) { + //we could've used response.value.email() + //but Storage already notified CloudMan + //so we just set the flag to redraw our cloud tab + _redrawCloudTab = true; +} + +void GlobalOptionsDialog::storageListDirectoryCallback(Cloud::Storage::ListDirectoryResponse response) { + Common::Array<Cloud::StorageFile> &files = response.value; + uint64 totalSize = 0; + for (uint32 i = 0; i < files.size(); ++i) + if (!files[i].isDirectory()) + totalSize += files[i].size(); + CloudMan.setStorageUsedSpace(CloudMan.getStorageIndex(), totalSize); + _redrawCloudTab = true; } #endif diff --git a/gui/options.h b/gui/options.h index 4addf717b8..1454ddbfc8 100644 --- a/gui/options.h +++ b/gui/options.h @@ -37,6 +37,10 @@ #include "gui/fluidsynth-dialog.h" #endif +#ifdef USE_CLOUD +#include "backends/cloud/storage.h" +#endif + namespace GUI { class CheckboxWidget; @@ -206,6 +210,7 @@ public: void open(); void close(); void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); + void handleTickle(); virtual void reflowLayout(); @@ -256,8 +261,12 @@ protected: StaticTextWidget *_storageLastSyncDesc; StaticTextWidget *_storageLastSync; ButtonWidget *_storageConnectButton; + ButtonWidget *_storageRefreshButton; + bool _redrawCloudTab; void setupCloudTab(); + void storageInfoCallback(Cloud::Storage::StorageInfoResponse response); + void storageListDirectoryCallback(Cloud::Storage::ListDirectoryResponse response); #endif }; diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 8406fc9b28..824c6fa790 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -576,6 +576,9 @@ <widget name = 'ConnectButton' type = 'Button' /> + <widget name = 'RefreshButton' + type = 'Button' + /> </layout> </layout> </dialog> diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index 13d854c9ac..3d2c3b49a7 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -573,6 +573,9 @@ <widget name = 'ConnectButton' type = 'Button' /> + <widget name = 'RefreshButton' + type = 'Button' + /> </layout> </layout> </dialog> |