From 97c0bbd2388ac049970fc3c99ebdc072c75724f1 Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Sun, 3 Jul 2016 20:09:51 +0600 Subject: GUI: Add DownloadDialog sketch --- gui/downloaddialog.cpp | 88 ++++++++++++++++++++++ gui/downloaddialog.h | 56 ++++++++++++++ gui/module.mk | 1 + gui/options.cpp | 12 ++- gui/options.h | 1 + gui/themes/scummmodern/scummmodern_layout.stx | 21 ++++++ .../scummmodern/scummmodern_layout_lowres.stx | 21 ++++++ 7 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 gui/downloaddialog.cpp create mode 100644 gui/downloaddialog.h diff --git a/gui/downloaddialog.cpp b/gui/downloaddialog.cpp new file mode 100644 index 0000000000..b449be5ca8 --- /dev/null +++ b/gui/downloaddialog.cpp @@ -0,0 +1,88 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "gui/downloaddialog.h" +#include "gui/widgets/list.h" +#include "gui/widget.h" +#include "gui/gui-manager.h" +#include "backends/cloud/cloudmanager.h" +#include "common/translation.h" +#include "widgets/edittext.h" + +namespace GUI { + +enum { + kDownloadDialogButtonCmd = 'Dldb' +}; + +DownloadDialog::DownloadDialog(uint32 storageId): + Dialog("GlobalOptions_Cloud_DownloadDialog"), _wasInProgress(true), _inProgress(false), _close(false) { + _backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain; + + _messageText = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.DialogDesc", _("Press the button to download a directory")); + _mainButton = new ButtonWidget(this, "GlobalOptions_Cloud_DownloadDialog.MainButton", _("Start download"), 0, kDownloadDialogButtonCmd); + _closeButton = new ButtonWidget(this, "GlobalOptions_Cloud_DownloadDialog.CloseButton", _("OK"), 0, kCloseCmd); + updateButtons(); +} + +void DownloadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { + switch (cmd) { + case kDownloadDialogButtonCmd: { + _inProgress = !_inProgress; + reflowLayout(); + break; + } + default: + Dialog::handleCommand(sender, cmd, data); + } +} + +void DownloadDialog::handleTickle() { + if (_close) { + setResult(1); + close(); + } + + Dialog::handleTickle(); +} + +void DownloadDialog::reflowLayout() { + Dialog::reflowLayout(); + updateButtons(); +} + +void DownloadDialog::updateButtons() { + if (_wasInProgress == _inProgress) return; + + if (_inProgress) { + _messageText->setLabel(_("Press the button to cancel the download")); + _mainButton->setLabel(_("Cancel the download")); + } else { + _messageText->setLabel(_("Press the button to download a directory")); + _mainButton->setLabel(_("Start download")); + } + + _wasInProgress = _inProgress; +} + + +} // End of namespace GUI diff --git a/gui/downloaddialog.h b/gui/downloaddialog.h new file mode 100644 index 0000000000..333ce0e03b --- /dev/null +++ b/gui/downloaddialog.h @@ -0,0 +1,56 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef GUI_DOWNLOADDIALOG_H +#define GUI_DOWNLOADDIALOG_H + +#include "gui/dialog.h" +#include "common/str.h" + +namespace GUI { + +class CommandSender; +class EditTextWidget; +class StaticTextWidget; +class ButtonWidget; + +class DownloadDialog : public Dialog { + StaticTextWidget *_messageText; + ButtonWidget *_mainButton; + ButtonWidget *_closeButton; + + bool _wasInProgress, _inProgress; + bool _close; + + void updateButtons(); + +public: + DownloadDialog(uint32 storageId); + + virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); + virtual void handleTickle(); + virtual void reflowLayout(); +}; + +} // End of namespace GUI + +#endif diff --git a/gui/module.mk b/gui/module.mk index ef005311cd..2d71c45106 100644 --- a/gui/module.mk +++ b/gui/module.mk @@ -6,6 +6,7 @@ MODULE_OBJS := \ console.o \ debugger.o \ dialog.o \ + downloaddialog.o \ error.o \ EventRecorder.o \ filebrowser-dialog.o \ diff --git a/gui/options.cpp b/gui/options.cpp index 2ab6b1eb6b..1ea64cab3d 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -42,6 +42,7 @@ #include "audio/musicplugin.h" #include "audio/mixer.h" #include "audio/fmopl.h" +#include "downloaddialog.h" #ifdef USE_CLOUD #include "backends/cloud/cloudmanager.h" @@ -92,7 +93,8 @@ enum { #ifdef USE_CLOUD enum { kConfigureStorageCmd = 'cfst', - kRefreshStorageCmd = 'rfst' + kRefreshStorageCmd = 'rfst', + kDownloadStorageCmd = 'dlst' }; #endif @@ -1292,6 +1294,7 @@ GlobalOptionsDialog::GlobalOptionsDialog() _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); + _storageDownloadButton = new ButtonWidget(tab, "GlobalOptions_Cloud.DownloadButton", _("Downloads"), _("Open downloads manager dialog"), kDownloadStorageCmd); setupCloudTab(); _redrawCloudTab = false; @@ -1598,6 +1601,12 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3 CloudMan.listDirectory(dir, new Common::Callback(this, &GlobalOptionsDialog::storageListDirectoryCallback), nullptr); break; } + case kDownloadStorageCmd: + { + DownloadDialog dialog(_selectedStorageIndex); + dialog.runModal(); + break; + } #endif #ifdef GUI_ENABLE_KEYSDIALOG case kChooseKeyMappingCmd: @@ -1696,6 +1705,7 @@ void GlobalOptionsDialog::setupCloudTab() { } if (_storageConnectButton) _storageConnectButton->setVisible(shown); if (_storageRefreshButton) _storageRefreshButton->setVisible(shown && _selectedStorageIndex == CloudMan.getStorageIndex()); + if (_storageDownloadButton) _storageDownloadButton->setVisible(shown && _selectedStorageIndex == CloudMan.getStorageIndex()); } void GlobalOptionsDialog::storageInfoCallback(Cloud::Storage::StorageInfoResponse response) { diff --git a/gui/options.h b/gui/options.h index 1454ddbfc8..fa7a1d28b9 100644 --- a/gui/options.h +++ b/gui/options.h @@ -262,6 +262,7 @@ protected: StaticTextWidget *_storageLastSync; ButtonWidget *_storageConnectButton; ButtonWidget *_storageRefreshButton; + ButtonWidget *_storageDownloadButton; bool _redrawCloudTab; void setupCloudTab(); diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx index 5954196f7e..f9ec30b81b 100644 --- a/gui/themes/scummmodern/scummmodern_layout.stx +++ b/gui/themes/scummmodern/scummmodern_layout.stx @@ -579,6 +579,27 @@ + + + + + + + + + + + + + diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx index ad9a3b6961..fe15dc2410 100644 --- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx +++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx @@ -576,6 +576,27 @@ + + + + + + + + + + + + + -- cgit v1.2.3