Skip to content

Commit

Permalink
#209: Add button to browse pga.db path
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Jun 23, 2024
1 parent a3f04ec commit a2dbc5e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/gui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,7 @@ impl Application for App {
Command::none()
}
Message::SelectedRootStore(index, store) => {
self.text_histories.roots[index].clear_secondary();
self.config.roots[index].set_store(store);
self.save_config();
Command::none()
Expand Down Expand Up @@ -1978,6 +1979,12 @@ impl Application for App {
self.text_histories.rclone_executable.push(&path.raw());
self.config.apps.rclone.path = path;
}
BrowseFileSubject::RootLutrisDatabase(i) => {
self.text_histories.roots[i].lutris_database.push(&path.raw());
if let RootsConfig::Lutris(root) = &mut self.config.roots[i] {
root.database = Some(path);
}
}
BrowseFileSubject::SecondaryManifest(i) => {
self.text_histories.secondary_manifests[i].push(&path.raw());
self.config.manifest.secondary[i].set(path.raw());
Expand Down Expand Up @@ -2061,6 +2068,15 @@ impl Application for App {
Message::OpenFileSubject(subject) => {
let path = match subject {
BrowseFileSubject::RcloneExecutable => self.config.apps.rclone.path.clone(),
BrowseFileSubject::RootLutrisDatabase(i) => {
let RootsConfig::Lutris(root) = &self.config.roots[i] else {
return Command::none();
};
let Some(database) = root.database.as_ref() else {
return Command::none();
};
database.clone()
}
BrowseFileSubject::SecondaryManifest(i) => {
let Some(path) = self.config.manifest.secondary[i].path() else {
return Command::none();
Expand Down
1 change: 1 addition & 0 deletions src/gui/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ pub enum BrowseSubject {
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum BrowseFileSubject {
RcloneExecutable,
RootLutrisDatabase(usize),
SecondaryManifest(usize),
}

Expand Down
3 changes: 2 additions & 1 deletion src/gui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ pub fn root<'a>(config: &Config, histories: &TextHistories, modifiers: &keyboard
.align_items(Alignment::Center)
.push(horizontal_space().width(70))
.push(text(TRANSLATOR.field("pga.db")))
.push(histories.input(UndoSubject::RootLutrisDatabase(i))),
.push(histories.input(UndoSubject::RootLutrisDatabase(i)))
.push(button::choose_file(BrowseFileSubject::RootLutrisDatabase(i), modifiers)),
),
_ => parent.push(
Row::new()
Expand Down
6 changes: 6 additions & 0 deletions src/gui/shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ pub struct RootHistory {
pub lutris_database: TextHistory,
}

impl RootHistory {
pub fn clear_secondary(&mut self) {
self.lutris_database.clear();
}
}

#[derive(Default)]
pub struct RedirectHistory {
pub source: TextHistory,
Expand Down

0 comments on commit a2dbc5e

Please sign in to comment.