Backlog fixes (#141)

* Backlog fixes

* Clear searching

* slider units

* Run lint

* errant editing

* Toggle selected

* Update Mods.vue

* update disablers

* titlebar position

---------

Co-authored-by: Jai A <jaiagr+gpg@pm.me>
This commit is contained in:
Adrian O.V
2023-06-14 20:16:16 -04:00
committed by GitHub
parent 3535f0c4b4
commit 6198cc961a
13 changed files with 542 additions and 124 deletions

View File

@@ -13,6 +13,7 @@ pub mod profile_create;
pub mod settings;
pub mod tags;
pub mod utils;
pub mod window_ext;
pub type Result<T> = std::result::Result<T, TheseusSerializableError>;

View File

@@ -0,0 +1,71 @@
/// from: https://github.com/tauri-apps/tauri/issues/4789, full credit to haasal
#[cfg(target_os = "macos")]
use tauri::{Runtime, Window};
#[cfg(target_os = "macos")]
pub trait WindowExt {
fn set_transparent_titlebar(&self, transparent: bool);
fn position_traffic_lights(&self, x: f64, y: f64);
}
#[cfg(target_os = "macos")]
impl<R: Runtime> WindowExt for Window<R> {
fn set_transparent_titlebar(&self, transparent: bool) {
use cocoa::appkit::{NSWindow, NSWindowTitleVisibility};
let window = self.ns_window().unwrap() as cocoa::base::id;
unsafe {
window.setTitleVisibility_(
NSWindowTitleVisibility::NSWindowTitleHidden,
);
if transparent {
window.setTitlebarAppearsTransparent_(cocoa::base::YES);
} else {
window.setTitlebarAppearsTransparent_(cocoa::base::NO);
}
}
}
fn position_traffic_lights(&self, x: f64, y: f64) {
use cocoa::appkit::{NSView, NSWindow, NSWindowButton};
use cocoa::foundation::NSRect;
use objc::{msg_send, sel, sel_impl};
let window = self.ns_window().unwrap() as cocoa::base::id;
unsafe {
let close = window
.standardWindowButton_(NSWindowButton::NSWindowCloseButton);
let miniaturize = window.standardWindowButton_(
NSWindowButton::NSWindowMiniaturizeButton,
);
let zoom = window
.standardWindowButton_(NSWindowButton::NSWindowZoomButton);
let title_bar_container_view = close.superview().superview();
let close_rect: NSRect = msg_send![close, frame];
let button_height = close_rect.size.height;
let title_bar_frame_height = button_height + y;
let mut title_bar_rect = NSView::frame(title_bar_container_view);
title_bar_rect.size.height = title_bar_frame_height;
title_bar_rect.origin.y =
NSView::frame(window).size.height - title_bar_frame_height;
let _: () =
msg_send![title_bar_container_view, setFrame: title_bar_rect];
let window_buttons = vec![close, miniaturize, zoom];
let space_between = NSView::frame(miniaturize).origin.x
- NSView::frame(close).origin.x;
for (i, button) in window_buttons.into_iter().enumerate() {
let mut rect: NSRect = NSView::frame(button);
rect.origin.x = x + (i as f64 * space_between);
button.setFrameOrigin(rect.origin);
}
}
}
}

View File

@@ -5,7 +5,7 @@
use theseus::prelude::*;
use tauri::Manager;
use tauri::{Manager, WindowEvent};
use tracing_error::ErrorLayer;
use tracing_subscriber::EnvFilter;
@@ -55,86 +55,108 @@ fn main() {
tracing::subscriber::set_global_default(subscriber)
.expect("setting default subscriber failed");
tauri::Builder::default()
let mut builder = tauri::Builder::default()
.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
app.emit_all("single-instance", Payload { args: argv, cwd })
.unwrap();
}))
.plugin(tauri_plugin_window_state::Builder::default().build())
.invoke_handler(tauri::generate_handler![
initialize_state,
api::progress_bars_list,
api::profile_create::profile_create_empty,
api::profile_create::profile_create,
api::profile::profile_remove,
api::profile::profile_get,
api::profile::profile_get_optimal_jre_key,
api::profile::profile_list,
api::profile::profile_install,
api::profile::profile_update_all,
api::profile::profile_update_project,
api::profile::profile_add_project_from_version,
api::profile::profile_add_project_from_path,
api::profile::profile_toggle_disable_project,
api::profile::profile_remove_project,
api::profile::profile_run,
api::profile::profile_run_wait,
api::profile::profile_run_credentials,
api::profile::profile_run_wait_credentials,
api::profile::profile_edit,
api::profile::profile_edit_icon,
api::profile::profile_check_installed,
api::pack::pack_install_version_id,
api::pack::pack_install_file,
api::auth::auth_authenticate_begin_flow,
api::auth::auth_authenticate_await_completion,
api::auth::auth_cancel_flow,
api::auth::auth_refresh,
api::auth::auth_remove_user,
api::auth::auth_has_user,
api::auth::auth_users,
api::auth::auth_get_user,
api::tags::tags_get_categories,
api::tags::tags_get_donation_platforms,
api::tags::tags_get_game_versions,
api::tags::tags_get_loaders,
api::tags::tags_get_report_types,
api::tags::tags_get_tag_bundle,
api::settings::settings_get,
api::settings::settings_set,
api::jre::jre_get_all_jre,
api::jre::jre_autodetect_java_globals,
api::jre::jre_find_jre_18plus_jres,
api::jre::jre_find_jre_17_jres,
api::jre::jre_find_jre_8_jres,
api::jre::jre_validate_globals,
api::jre::jre_get_jre,
api::jre::jre_auto_install_java,
api::jre::jre_get_max_memory,
api::process::process_get_all_uuids,
api::process::process_get_all_running_uuids,
api::process::process_get_uuids_by_profile_path,
api::process::process_get_all_running_profile_paths,
api::process::process_get_all_running_profiles,
api::process::process_get_exit_status_by_uuid,
api::process::process_has_finished_by_uuid,
api::process::process_get_stderr_by_uuid,
api::process::process_get_stdout_by_uuid,
api::process::process_kill_by_uuid,
api::process::process_wait_for_by_uuid,
api::metadata::metadata_get_game_versions,
api::metadata::metadata_get_fabric_versions,
api::metadata::metadata_get_forge_versions,
api::metadata::metadata_get_quilt_versions,
api::logs::logs_get_logs,
api::logs::logs_get_logs_by_datetime,
api::logs::logs_get_stdout_by_datetime,
api::logs::logs_get_stderr_by_datetime,
api::logs::logs_delete_logs,
api::logs::logs_delete_logs_by_datetime,
api::utils::show_in_folder,
api::utils::should_disable_mouseover,
])
.plugin(tauri_plugin_window_state::Builder::default().build());
#[cfg(target_os = "macos")]
{
builder = builder
.setup(|app| {
use api::window_ext::WindowExt;
let win = app.get_window("main").unwrap();
win.set_transparent_titlebar(true);
win.position_traffic_lights(0.0, 0.0);
Ok(())
})
.on_window_event(|e| {
use api::window_ext::WindowExt;
if let WindowEvent::Resized(..) = e.event() {
let win = e.window();
win.position_traffic_lights(0., 0.);
}
})
}
builder = builder.invoke_handler(tauri::generate_handler![
initialize_state,
api::progress_bars_list,
api::profile_create::profile_create_empty,
api::profile_create::profile_create,
api::profile::profile_remove,
api::profile::profile_get,
api::profile::profile_get_optimal_jre_key,
api::profile::profile_list,
api::profile::profile_install,
api::profile::profile_update_all,
api::profile::profile_update_project,
api::profile::profile_add_project_from_version,
api::profile::profile_add_project_from_path,
api::profile::profile_toggle_disable_project,
api::profile::profile_remove_project,
api::profile::profile_run,
api::profile::profile_run_wait,
api::profile::profile_run_credentials,
api::profile::profile_run_wait_credentials,
api::profile::profile_edit,
api::profile::profile_edit_icon,
api::profile::profile_check_installed,
api::pack::pack_install_version_id,
api::pack::pack_install_file,
api::auth::auth_authenticate_begin_flow,
api::auth::auth_authenticate_await_completion,
api::auth::auth_cancel_flow,
api::auth::auth_refresh,
api::auth::auth_remove_user,
api::auth::auth_has_user,
api::auth::auth_users,
api::auth::auth_get_user,
api::tags::tags_get_categories,
api::tags::tags_get_donation_platforms,
api::tags::tags_get_game_versions,
api::tags::tags_get_loaders,
api::tags::tags_get_report_types,
api::tags::tags_get_tag_bundle,
api::settings::settings_get,
api::settings::settings_set,
api::jre::jre_get_all_jre,
api::jre::jre_autodetect_java_globals,
api::jre::jre_find_jre_18plus_jres,
api::jre::jre_find_jre_17_jres,
api::jre::jre_find_jre_8_jres,
api::jre::jre_validate_globals,
api::jre::jre_get_jre,
api::jre::jre_auto_install_java,
api::jre::jre_get_max_memory,
api::process::process_get_all_uuids,
api::process::process_get_all_running_uuids,
api::process::process_get_uuids_by_profile_path,
api::process::process_get_all_running_profile_paths,
api::process::process_get_all_running_profiles,
api::process::process_get_exit_status_by_uuid,
api::process::process_has_finished_by_uuid,
api::process::process_get_stderr_by_uuid,
api::process::process_get_stdout_by_uuid,
api::process::process_kill_by_uuid,
api::process::process_wait_for_by_uuid,
api::metadata::metadata_get_game_versions,
api::metadata::metadata_get_fabric_versions,
api::metadata::metadata_get_forge_versions,
api::metadata::metadata_get_quilt_versions,
api::logs::logs_get_logs,
api::logs::logs_get_logs_by_datetime,
api::logs::logs_get_stdout_by_datetime,
api::logs::logs_get_stderr_by_datetime,
api::logs::logs_delete_logs,
api::logs::logs_delete_logs_by_datetime,
api::utils::show_in_folder,
api::utils::should_disable_mouseover,
]);
builder
.run(tauri::generate_context!())
.expect("error while running tauri application");
}