Main screen: Add Browse button on Windows to choose a folder easily

This commit is contained in:
Henrik Rydgard
2013-10-15 13:28:09 +02:00
parent e88a049e79
commit 5b9123b3c5
3 changed files with 18 additions and 8 deletions
+16 -6
View File
@@ -42,6 +42,11 @@
#include "GPU/GPUInterface.h"
#include "i18n/i18n.h"
#ifdef _WIN32
#include "Windows/W32Util/ShellUtil.h"
#include "Windows/WndMainWindow.h"
#endif
#ifdef USING_QT_UI
#include <QFileDialog>
#include <QFile>
@@ -50,12 +55,6 @@
#include <sstream>
#ifdef _WIN32
namespace MainWindow {
void BrowseAndBoot(std::string defaultPath, bool browseDirectory = false);
}
#endif
class GameButton : public UI::Clickable {
public:
GameButton(const std::string &gamePath, bool gridStyle, UI::LayoutParams *layoutParams = 0)
@@ -344,7 +343,16 @@ UI::EventReturn GameBrowser::LastClick(UI::EventParams &e) {
}
UI::EventReturn GameBrowser::HomeClick(UI::EventParams &e) {
#ifdef ANDROID
path_.SetPath(g_Config.memCardDirectory);
#elif defined(_WIN32)
I18NCategory *m = GetI18NCategory("MainMenu");
std::string folder = W32Util::BrowseForFolder(MainWindow::GetHWND(), m->T("Choose folder"));
if (!folder.size())
return UI::EVENT_DONE;
path_.SetPath(folder);
#endif
g_Config.currentDirectory = path_.GetPath();
Refresh();
return UI::EVENT_DONE;
@@ -365,6 +373,8 @@ void GameBrowser::Refresh() {
topBar->Add(new TextView(path_.GetFriendlyPath().c_str(), ALIGN_VCENTER, 0.7f, new LinearLayoutParams(WRAP_CONTENT, FILL_PARENT, 1.0f, pathMargins)));
#ifdef ANDROID
topBar->Add(new Choice(m->T("Home")))->OnClick.Handle(this, &GameBrowser::HomeClick);
#elif defined(_WIN32)
topBar->Add(new Choice(m->T("Browse", "Browse...")))->OnClick.Handle(this, &GameBrowser::HomeClick);
#endif
ChoiceStrip *layoutChoice = topBar->Add(new ChoiceStrip(ORIENT_HORIZONTAL));
layoutChoice->AddChoice(I_GRID);
+1 -1
View File
@@ -12,7 +12,7 @@
namespace W32Util
{
std::string BrowseForFolder(HWND parent, char *title)
std::string BrowseForFolder(HWND parent, const char *title)
{
std::wstring titleString = ConvertUTF8ToWString(title);
+1 -1
View File
@@ -6,7 +6,7 @@
namespace W32Util
{
std::string BrowseForFolder(HWND parent, char *title);
std::string BrowseForFolder(HWND parent, const char *title);
bool BrowseForFileName (bool _bLoad, HWND _hParent, const wchar_t*_pTitle,
const wchar_t *_pInitialFolder,const wchar_t *_pFilter,const wchar_t*_pExtension,
std::string& _strFileName);