GUI: Replace Cloud tab's StorageBrowser with PopUp

This commit is contained in:
Alexander Tkachev 2016-06-09 15:55:53 +06:00
parent 9b15ec9989
commit e1e48968b4
7 changed files with 54 additions and 172 deletions

View File

@ -18,7 +18,6 @@ MODULE_OBJS := \
predictivedialog.o \
saveload.o \
saveload-dialog.o \
storagebrowser.o \
themebrowser.o \
ThemeEngine.o \
ThemeEval.o \

View File

@ -45,7 +45,6 @@
#ifdef USE_CLOUD
#include "backends/cloud/cloudmanager.h"
#include "gui/storagebrowser.h"
#endif
namespace GUI {
@ -1273,16 +1272,20 @@ GlobalOptionsDialog::GlobalOptionsDialog()
_selectedStorageIndex = CloudMan.getStorageIndex();
new ButtonWidget(tab, "GlobalOptions_Cloud.StorageButton", _("Storage:"), 0, kChooseStorageCmd);
_curStorage = new StaticTextWidget(tab, "GlobalOptions_Cloud.CurStorage", CloudMan.listStorages()[_selectedStorageIndex]);
_storagePopUpDesc = new StaticTextWidget(tab, "GlobalOptions_Cloud.StoragePopupDesc", _("Storage:"), _("Active cloud storage"));
_storagePopUp = new PopUpWidget(tab, "GlobalOptions_Cloud.StoragePopup");
Common::StringArray list = CloudMan.listStorages();
for (uint32 i = 0; i < list.size(); ++i)
_storagePopUp->appendEntry(list[i], i);
_storagePopUp->setSelected(_selectedStorageIndex);
_storageUsernameDesc = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageUsernameDesc", _("Username:"), _("Username used by this storage"));
_storageUsername = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageUsernameLabel", "<none>");
_storageUsedSpaceDesc = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageUsedSpaceDesc", _("Used space:"), _("Space used by ScummVM on this storage"));
_storageUsedSpaceDesc = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageUsedSpaceDesc", _("Used space:"), _("Space used by ScummVM's saves on this storage"));
_storageUsedSpace = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageUsedSpaceLabel", "0 bytes");
_storageLastSyncDesc = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageLastSyncDesc", _("Last sync time:"), _("When this storage did last saves sync"));
_storageLastSyncDesc = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageLastSyncDesc", _("Last sync time:"), _("When this storage did saves sync last time"));
_storageLastSync = new StaticTextWidget(tab, "GlobalOptions_Cloud.StorageLastSyncLabel", "<never>");
setupCloudTab();
@ -1567,15 +1570,10 @@ void GlobalOptionsDialog::handleCommand(CommandSender *sender, uint32 cmd, uint3
break;
}
#ifdef USE_CLOUD
case kChooseStorageCmd:
case kPopUpItemSelectedCmd:
{
StorageBrowser storageBrowser;
if (storageBrowser.runModal() > 0) {
// User made his choice...
_selectedStorageIndex = storageBrowser.getSelected();
setupCloudTab();
draw();
}
setupCloudTab();
draw();
break;
}
#endif
@ -1637,8 +1635,7 @@ void GlobalOptionsDialog::reflowLayout() {
#ifdef USE_CLOUD
void GlobalOptionsDialog::setupCloudTab() {
if (_curStorage)
_curStorage->setLabel(CloudMan.listStorages()[_selectedStorageIndex]);
_selectedStorageIndex = _storagePopUp->getSelectedTag();
bool shown = (_selectedStorageIndex != Cloud::kStorageNoneId);
if (_storageUsernameDesc) _storageUsernameDesc->setVisible(shown);

View File

@ -247,7 +247,8 @@ protected:
// Cloud controls
//
uint32 _selectedStorageIndex;
StaticTextWidget *_curStorage;
StaticTextWidget *_storagePopUpDesc;
PopUpWidget *_storagePopUp;
StaticTextWidget *_storageUsernameDesc;
StaticTextWidget *_storageUsername;
StaticTextWidget *_storageUsedSpaceDesc;

View File

@ -1,96 +0,0 @@
/* 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/storagebrowser.h"
#include "gui/widgets/list.h"
#include "gui/widget.h"
#include "gui/gui-manager.h"
#include "common/translation.h"
#ifdef USE_CLOUD
#include "backends/cloud/cloudmanager.h"
#endif
namespace GUI {
enum {
kChooseCmd = 'Chos'
};
StorageBrowser::StorageBrowser() : Dialog("Browser") {
new StaticTextWidget(this, "Browser.Headline", _("Select a Storage"));
// Add storages list
_storagesList = new ListWidget(this, "Browser.List");
_storagesList->setNumberingMode(kListNumberingOff);
_storagesList->setEditable(false);
_backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain;
// Buttons
new ButtonWidget(this, "Browser.Cancel", _("Cancel"), 0, kCloseCmd);
new ButtonWidget(this, "Browser.Choose", _("Choose"), 0, kChooseCmd);
}
void StorageBrowser::open() {
// Always refresh storages list
updateListing();
// Call super implementation
Dialog::open();
}
void StorageBrowser::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
switch (cmd) {
case kChooseCmd:
case kListItemActivatedCmd:
case kListItemDoubleClickedCmd: {
int selection = _storagesList->getSelected();
if (selection < 0)
break;
_selectionIndex = selection;
setResult(1);
close();
break;
}
default:
Dialog::handleCommand(sender, cmd, data);
}
}
void StorageBrowser::updateListing() {
Common::StringArray list;
uint32 currentStorageIndex = 0;
#ifdef USE_CLOUD
list = CloudMan.listStorages();
currentStorageIndex = CloudMan.getStorageIndex();
#endif
_storagesList->setList(list);
_storagesList->scrollTo(0);
_storagesList->setSelected(currentStorageIndex);
// Finally, redraw
draw();
}
} // End of namespace GUI

View File

@ -1,51 +0,0 @@
/* 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_STORAGEBROWSER_H
#define GUI_STORAGEBROWSER_H
#include "gui/dialog.h"
#include "common/str.h"
namespace GUI {
class CommandSender;
class ListWidget;
class StorageBrowser : public Dialog {
public:
StorageBrowser();
void open();
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
uint32 getSelected() const { return _selectionIndex; }
private:
ListWidget *_storagesList;
uint32 _selectionIndex;
void updateListing();
};
} // End of namespace GUI
#endif

View File

@ -541,11 +541,11 @@
<dialog name = 'GlobalOptions_Cloud' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'>
<widget name = 'StorageButton'
type = 'Button'
<widget name = 'StoragePopupDesc'
type = 'OptionsLabel'
/>
<widget name = 'CurStorage'
height = 'Globals.Line.Height'
<widget name = 'StoragePopup'
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'>

View File

@ -529,11 +529,43 @@
<dialog name = 'GlobalOptions_Cloud' overlays = 'Dialog.GlobalOptions.TabWidget'>
<layout type = 'vertical' padding = '16, 16, 16, 16' spacing = '8'>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' center = 'true'>
<widget name = 'StorageButton'
type = 'Button'
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'>
<widget name = 'StoragePopupDesc'
width = '80'
height = 'Globals.Line.Height'
textalign = 'right'
/>
<widget name = 'CurStorage'
<widget name = 'StoragePopup'
type = 'PopUp'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'>
<widget name = 'StorageUsernameDesc'
width = '80'
height = 'Globals.Line.Height'
textalign = 'right'
/>
<widget name = 'StorageUsernameLabel'
height = 'Globals.Line.Height'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'>
<widget name = 'StorageUsedSpaceDesc'
width = '80'
height = 'Globals.Line.Height'
textalign = 'right'
/>
<widget name = 'StorageUsedSpaceLabel'
height = 'Globals.Line.Height'
/>
</layout>
<layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' center = 'true'>
<widget name = 'StorageLastSyncDesc'
width = '80'
height = 'Globals.Line.Height'
textalign = 'right'
/>
<widget name = 'StorageLastSyncLabel'
height = 'Globals.Line.Height'
/>
</layout>