aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-04 18:30:23 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commita5765a339e150952dca27035357bbfb1f88a4718 (patch)
tree243922d32dba938709b8dcca130beb4987ecc931
parent1cfdb9661678a5cabb77c2cf60d2fa357121d584 (diff)
downloadscummvm-rg350-a5765a339e150952dca27035357bbfb1f88a4718.tar.gz
scummvm-rg350-a5765a339e150952dca27035357bbfb1f88a4718.tar.bz2
scummvm-rg350-a5765a339e150952dca27035357bbfb1f88a4718.zip
GUI: Update DownloadDialog
It now less empty, because if there is no download in progress, user sees the RemoteBrowser instead of empty dialog. The cancel button is now in the left bottom corner.
-rw-r--r--gui/downloaddialog.cpp81
-rw-r--r--gui/downloaddialog.h12
-rw-r--r--gui/themes/scummmodern/scummmodern_layout.stx9
-rw-r--r--gui/themes/scummmodern/scummmodern_layout_lowres.stx9
4 files changed, 51 insertions, 60 deletions
diff --git a/gui/downloaddialog.cpp b/gui/downloaddialog.cpp
index 05d87c21d8..9c48111153 100644
--- a/gui/downloaddialog.cpp
+++ b/gui/downloaddialog.cpp
@@ -38,14 +38,12 @@ enum {
};
DownloadDialog::DownloadDialog(uint32 storageId):
- Dialog("GlobalOptions_Cloud_DownloadDialog"), _reflow(false) {
+ Dialog("GlobalOptions_Cloud_DownloadDialog"), _close(false), _reflow(false) {
_backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain;
_browser = new BrowserDialog(_("Select directory where to download game data"), true);
_remoteBrowser = new RemoteBrowserDialog(_("Select directory with game data"));
-
- _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);
+
_remoteDirectoryLabel = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.RemoteDirectory", _("From: "));
_localDirectoryLabel = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.LocalDirectory", _("To: "));
uint32 progress = (uint32)(100 * CloudMan.getDownloadingProgress());
@@ -55,9 +53,10 @@ DownloadDialog::DownloadDialog(uint32 storageId):
_progressBar->setValue(progress);
_progressBar->setEnabled(false);
_percentLabel = new StaticTextWidget(this, "GlobalOptions_Cloud_DownloadDialog.PercentText", Common::String::format("%u %%", progress));
+ _cancelButton = new ButtonWidget(this, "GlobalOptions_Cloud_DownloadDialog.MainButton", _("Cancel download"), 0, kDownloadDialogButtonCmd);
_closeButton = new ButtonWidget(this, "GlobalOptions_Cloud_DownloadDialog.CloseButton", _("OK"), 0, kCloseCmd);
- updateButtons();
-
+ refreshWidgets();
+
CloudMan.setDownloadTarget(this);
}
@@ -65,6 +64,15 @@ DownloadDialog::~DownloadDialog() {
CloudMan.setDownloadTarget(nullptr);
}
+void DownloadDialog::open() {
+ Dialog::open();
+ if (!CloudMan.isDownloading())
+ if (!selectDirectories())
+ close();
+ reflowLayout();
+ draw();
+}
+
void DownloadDialog::close() {
CloudMan.setDownloadTarget(nullptr);
Dialog::close();
@@ -72,16 +80,10 @@ void DownloadDialog::close() {
void DownloadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
- case kDownloadDialogButtonCmd: {
- if (CloudMan.isDownloading()) {
- CloudMan.setDownloadTarget(nullptr);
- CloudMan.cancelDownload();
- } else {
- selectDirectories();
- }
-
- reflowLayout();
- draw();
+ case kDownloadDialogButtonCmd: {
+ CloudMan.setDownloadTarget(nullptr);
+ CloudMan.cancelDownload();
+ close();
break;
}
case kDownloadProgressCmd:
@@ -90,28 +92,28 @@ void DownloadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
_reflow = true;
break;
case kDownloadEndedCmd:
- _reflow = true;
+ _close = true;
break;
default:
Dialog::handleCommand(sender, cmd, data);
}
}
-void DownloadDialog::selectDirectories() {
+bool DownloadDialog::selectDirectories() {
//first user should select remote directory to download
- if (_remoteBrowser->runModal() <= 0) return;
+ if (_remoteBrowser->runModal() <= 0) return false;
Cloud::StorageFile remoteDirectory = _remoteBrowser->getResult();
//now user should select local directory to download into
- if (_browser->runModal() <= 0) return;
+ if (_browser->runModal() <= 0) return false;
Common::FSNode dir(_browser->getResult());
Common::FSList files;
if (!dir.getChildren(files, Common::FSNode::kListAll)) {
MessageDialog alert(_("ScummVM couldn't open the specified directory!"));
alert.runModal();
- return;
+ return false;
}
//check that there is no file with the remote directory's name in the local one
@@ -121,14 +123,14 @@ void DownloadDialog::selectDirectories() {
if (!i->isDirectory()) {
GUI::MessageDialog alert(_("Cannot create a directory to download - the specified directory has a file with the same name."), _("OK"));
alert.runModal();
- return;
+ return false;
}
GUI::MessageDialog alert(
Common::String::format(_("The \"%s\" already exists in the specified directory.\nDo you really want to download files into that directory?"), remoteDirectory.name().c_str()),
_("Yes"),
_("No")
);
- if (alert.runModal() != GUI::kMessageOK) return;
+ if (alert.runModal() != GUI::kMessageOK) return false;
break;
}
}
@@ -149,9 +151,16 @@ void DownloadDialog::selectDirectories() {
CloudMan.startDownload(remoteDirectory.path(), localPath);
CloudMan.setDownloadTarget(this);
+ return true;
}
void DownloadDialog::handleTickle() {
+ if (_close) {
+ close();
+ _close = false;
+ return;
+ }
+
if (_reflow) {
reflowLayout();
draw();
@@ -163,27 +172,15 @@ void DownloadDialog::handleTickle() {
void DownloadDialog::reflowLayout() {
Dialog::reflowLayout();
- updateButtons();
+ refreshWidgets();
}
-void DownloadDialog::updateButtons() {
- bool downloading = CloudMan.isDownloading();
- if (downloading) {
- _messageText->setLabel(_("Press the button to cancel the download"));
- _mainButton->setLabel(_("Cancel the download"));
- _remoteDirectoryLabel->setLabel(_("From: ") + CloudMan.getDownloadRemoteDirectory());
- _localDirectoryLabel->setLabel(_("To: ") + CloudMan.getDownloadLocalDirectory());
- uint32 progress = (uint32)(100 * CloudMan.getDownloadingProgress());
- _percentLabel->setLabel(Common::String::format("%u %%", progress));
- _progressBar->setValue(progress);
- } else {
- _messageText->setLabel(_("Press the button to download a directory"));
- _mainButton->setLabel(_("Start download"));
- }
- _remoteDirectoryLabel->setVisible(downloading);
- _localDirectoryLabel->setVisible(downloading);
- _percentLabel->setVisible(downloading);
- _progressBar->setVisible(downloading);
+void DownloadDialog::refreshWidgets() {
+ _remoteDirectoryLabel->setLabel(_("From: ") + CloudMan.getDownloadRemoteDirectory());
+ _localDirectoryLabel->setLabel(_("To: ") + CloudMan.getDownloadLocalDirectory());
+ uint32 progress = (uint32)(100 * CloudMan.getDownloadingProgress());
+ _percentLabel->setLabel(Common::String::format("%u %%", progress));
+ _progressBar->setValue(progress);
}
} // End of namespace GUI
diff --git a/gui/downloaddialog.h b/gui/downloaddialog.h
index 429e20af98..74dd1e2e39 100644
--- a/gui/downloaddialog.h
+++ b/gui/downloaddialog.h
@@ -45,24 +45,24 @@ enum DownloadProgress {
class DownloadDialog : public Dialog {
BrowserDialog *_browser;
RemoteBrowserDialog *_remoteBrowser;
-
- StaticTextWidget *_messageText;
- ButtonWidget *_mainButton;
+
StaticTextWidget *_remoteDirectoryLabel;
StaticTextWidget *_localDirectoryLabel;
StaticTextWidget *_percentLabel;
SliderWidget *_progressBar;
+ ButtonWidget *_cancelButton;
ButtonWidget *_closeButton;
- bool _reflow;
+ bool _close, _reflow;
- void updateButtons();
- void selectDirectories();
+ void refreshWidgets();
+ bool selectDirectories();
public:
DownloadDialog(uint32 storageId);
virtual ~DownloadDialog();
+ virtual void open();
virtual void close();
virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
virtual void handleTickle();
diff --git a/gui/themes/scummmodern/scummmodern_layout.stx b/gui/themes/scummmodern/scummmodern_layout.stx
index e6493ba160..d2e60d7456 100644
--- a/gui/themes/scummmodern/scummmodern_layout.stx
+++ b/gui/themes/scummmodern/scummmodern_layout.stx
@@ -588,12 +588,6 @@
<dialog name = 'GlobalOptions_Cloud_DownloadDialog' overlays = 'Dialog.GlobalOptions'>
<layout type = 'vertical' padding = '16, 16, 16, 8' spacing = '8'>
- <widget name = 'DialogDesc'
- height = 'Globals.Line.Height'
- />
- <widget name = 'MainButton'
- type = 'Button'
- />
<widget name = 'RemoteDirectory'
height = 'Globals.Line.Height'
/>
@@ -610,6 +604,9 @@
/>
<space/>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10'>
+ <widget name = 'MainButton'
+ type = 'Button'
+ />
<space/>
<widget name = 'CloseButton'
type = 'Button'
diff --git a/gui/themes/scummmodern/scummmodern_layout_lowres.stx b/gui/themes/scummmodern/scummmodern_layout_lowres.stx
index ab78d3aee1..1ff2e9f524 100644
--- a/gui/themes/scummmodern/scummmodern_layout_lowres.stx
+++ b/gui/themes/scummmodern/scummmodern_layout_lowres.stx
@@ -585,12 +585,6 @@
<dialog name = 'GlobalOptions_Cloud_DownloadDialog' overlays = 'Dialog.GlobalOptions'>
<layout type = 'vertical' padding = '8, 8, 8, 4' spacing = '8'>
- <widget name = 'DialogDesc'
- height = 'Globals.Line.Height'
- />
- <widget name = 'MainButton'
- type = 'Button'
- />
<widget name = 'RemoteDirectory'
height = 'Globals.Line.Height'
/>
@@ -607,6 +601,9 @@
/>
<space/>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6'>
+ <widget name = 'MainButton'
+ type = 'Button'
+ />
<space/>
<widget name = 'CloseButton'
type = 'Button'