reverted the ui method and added filewatcher

I implemented the filewatcher method as described by @yuriks
This commit is contained in:
noah the goodra 2017-02-09 11:22:54 -06:00
parent 400fa7f9a0
commit 13611e3f68
3 changed files with 9 additions and 10 deletions

View File

@ -230,8 +230,7 @@ void GMainWindow::ConnectWidgetEvents() {
connect(ui.action_Load_Symbol_Map, SIGNAL(triggered()), this, SLOT(OnMenuLoadSymbolMap()));
connect(ui.action_Select_Game_List_Root, SIGNAL(triggered()), this,
SLOT(OnMenuSelectGameListRoot()));
connect(ui.action_Refresh_Game_Directory, SIGNAL(triggered()), this,
SLOT(OnMenuRefreshGameDirectory()));
connect(&watcher, SIGNAL(directoryChanged(QString)), SLOT(RefreshGameDirectory()));
connect(ui.action_Start, SIGNAL(triggered()), this, SLOT(OnStartGame()));
connect(ui.action_Pause, SIGNAL(triggered()), this, SLOT(OnPauseGame()));
connect(ui.action_Stop, SIGNAL(triggered()), this, SLOT(OnStopGame()));
@ -490,12 +489,16 @@ void GMainWindow::OnMenuLoadSymbolMap() {
void GMainWindow::OnMenuSelectGameListRoot() {
QString dir_path = QFileDialog::getExistingDirectory(this, tr("Select Directory"));
if (!UISettings::values.gamedir.isEmpty()) {
watcher.removePath(UISettings::values.gamedir);
}
if (!dir_path.isEmpty()) {
UISettings::values.gamedir = dir_path;
game_list->PopulateAsync(dir_path, UISettings::values.gamedir_deepscan);
watcher.addPath(dir_path);
}
}
void GMainWindow::OnMenuRefreshGameDirectory() {
void GMainWindow::RefreshGameDirectory() {
if (!UISettings::values.gamedir.isEmpty()) {
game_list->PopulateAsync(UISettings::values.gamedir, UISettings::values.gamedir_deepscan);
}

View File

@ -6,6 +6,7 @@
#define _CITRA_QT_MAIN_HXX_
#include <memory>
#include <QFileSystemWatcher>
#include <QMainWindow>
#include "ui_main.h"
@ -123,7 +124,7 @@ private slots:
void OnMenuLoadSymbolMap();
/// Called whenever a user selects the "File->Select Game List Root" menu item
void OnMenuSelectGameListRoot();
void OnMenuRefreshGameDirectory();
void RefreshGameDirectory();
void OnMenuRecentFile();
void OnSwapScreens();
void OnConfigure();
@ -154,6 +155,7 @@ private:
GraphicsVertexShaderWidget* graphicsVertexShaderWidget;
GraphicsTracingWidget* graphicsTracingWidget;
WaitTreeWidget* waitTreeWidget;
QFileSystemWatcher watcher;
QAction* actions_recent_files[max_recent_files_item];
};

View File

@ -61,7 +61,6 @@
<addaction name="action_Load_Symbol_Map"/>
<addaction name="separator"/>
<addaction name="action_Select_Game_List_Root"/>
<addaction name="action_Refresh_Game_Directory"/>
<addaction name="menu_recent_files"/>
<addaction name="separator"/>
<addaction name="action_Exit"/>
@ -168,11 +167,6 @@
<string>Selects a folder to display in the game list</string>
</property>
</action>
<action name="action_Refresh_Game_Directory">
<property name="text">
<string>Refresh Game Directory</string>
</property>
</action>
</widget>
<resources/>
<connections>