From 2a9c64d6850e4632ef7318a8fbc88edace610601 Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Sat, 12 Jun 2021 21:24:15 +0200 Subject: [PATCH] feat(modulo): add early work on Wizard GUI --- espanso-modulo/build.rs | 2 + espanso-modulo/src/lib.rs | 1 + espanso-modulo/src/sys/interop/mod.rs | 3 + espanso-modulo/src/sys/mod.rs | 1 + espanso-modulo/src/sys/wizard/mod.rs | 172 +++ espanso-modulo/src/sys/wizard/wizard.cpp | 78 ++ espanso-modulo/src/sys/wizard/wizard.fbp | 1201 ++++++++++++++++++ espanso-modulo/src/sys/wizard/wizard_gui.cpp | 152 +++ espanso-modulo/src/sys/wizard/wizard_gui.h | 68 + espanso-modulo/src/wizard/mod.rs | 20 + 10 files changed, 1698 insertions(+) create mode 100644 espanso-modulo/src/sys/wizard/mod.rs create mode 100644 espanso-modulo/src/sys/wizard/wizard.cpp create mode 100644 espanso-modulo/src/sys/wizard/wizard.fbp create mode 100644 espanso-modulo/src/sys/wizard/wizard_gui.cpp create mode 100644 espanso-modulo/src/sys/wizard/wizard_gui.h create mode 100644 espanso-modulo/src/wizard/mod.rs diff --git a/espanso-modulo/build.rs b/espanso-modulo/build.rs index 03c663d..7810bc8 100644 --- a/espanso-modulo/build.rs +++ b/espanso-modulo/build.rs @@ -113,6 +113,8 @@ fn build_native() { .file("src/sys/form/form.cpp") .file("src/sys/search/search.cpp") .file("src/sys/common/common.cpp") + .file("src/sys/wizard/wizard.cpp") + .file("src/sys/wizard/wizard_gui.cpp") .flag("/EHsc") .include(wx_include_dir) .include(wx_include_msvc_dir) diff --git a/espanso-modulo/src/lib.rs b/espanso-modulo/src/lib.rs index 377a605..fe69ad7 100644 --- a/espanso-modulo/src/lib.rs +++ b/espanso-modulo/src/lib.rs @@ -22,4 +22,5 @@ extern crate lazy_static; pub mod form; pub mod search; +pub mod wizard; mod sys; \ No newline at end of file diff --git a/espanso-modulo/src/sys/interop/mod.rs b/espanso-modulo/src/sys/interop/mod.rs index 344ec0f..1ec8281 100644 --- a/espanso-modulo/src/sys/interop/mod.rs +++ b/espanso-modulo/src/sys/interop/mod.rs @@ -130,4 +130,7 @@ extern "C" { ); pub(crate) fn update_items(app: *const c_void, items: *const SearchItem, itemCount: c_int); + + // WIZARD + pub(crate) fn interop_show_wizard(); } diff --git a/espanso-modulo/src/sys/mod.rs b/espanso-modulo/src/sys/mod.rs index 91e5b41..b07c15a 100644 --- a/espanso-modulo/src/sys/mod.rs +++ b/espanso-modulo/src/sys/mod.rs @@ -19,6 +19,7 @@ pub mod form; pub mod search; +pub mod wizard; #[allow(non_upper_case_globals)] #[allow(dead_code)] diff --git a/espanso-modulo/src/sys/wizard/mod.rs b/espanso-modulo/src/sys/wizard/mod.rs new file mode 100644 index 0000000..9b35438 --- /dev/null +++ b/espanso-modulo/src/sys/wizard/mod.rs @@ -0,0 +1,172 @@ +/* + * This file is part of modulo. + * + * Copyright (C) 2020-2021 Federico Terzi + * + * modulo 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 3 of the License, or + * (at your option) any later version. + * + * modulo 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 modulo. If not, see . + */ + +use std::ffi::CStr; +use std::os::raw::{c_char, c_int, c_void}; + +pub mod types { + // #[derive(Debug)] + // pub struct Search { + // pub title: String, + // pub icon: Option, + // pub items: Vec, + // } +} + +#[allow(dead_code)] +mod interop { + use super::types; + use super::super::interop::*; + use std::ffi::{c_void, CString}; + + // pub(crate) struct OwnedSearch { + // title: CString, + // icon_path: CString, + // items: Vec, + // pub(crate) interop_items: Vec, + // _interop: Box, + // } + + // impl Interoperable for OwnedSearch { + // fn as_ptr(&self) -> *const c_void { + // &(*self._interop) as *const SearchMetadata as *const c_void + // } + // } + + // impl From<&types::Search> for OwnedSearch { + // fn from(search: &types::Search) -> Self { + // let title = + // CString::new(search.title.clone()).expect("unable to convert search title to CString"); + + // let items: Vec = search.items.iter().map(|item| item.into()).collect(); + + // let interop_items: Vec = items.iter().map(|item| item.to_search_item()).collect(); + + // let icon_path = if let Some(icon_path) = search.icon.as_ref() { + // icon_path.clone() + // } else { + // "".to_owned() + // }; + + // let icon_path = CString::new(icon_path).expect("unable to convert search icon to CString"); + + // let icon_path_ptr = if search.icon.is_some() { + // icon_path.as_ptr() + // } else { + // std::ptr::null() + // }; + + // let _interop = Box::new(SearchMetadata { + // iconPath: icon_path_ptr, + // windowTitle: title.as_ptr(), + // }); + + // Self { + // title, + // items, + // icon_path, + // interop_items, + // _interop, + // } + // } + // } + + // pub(crate) struct OwnedSearchItem { + // id: CString, + // label: CString, + // trigger: CString, + // } + + // impl OwnedSearchItem { + // fn to_search_item(&self) -> SearchItem { + // SearchItem { + // id: self.id.as_ptr(), + // label: self.label.as_ptr(), + // trigger: self.trigger.as_ptr(), + // } + // } + // } + + // impl From<&types::SearchItem> for OwnedSearchItem { + // fn from(item: &types::SearchItem) -> Self { + // let id = CString::new(item.id.clone()).expect("unable to convert item id to CString"); + // let label = + // CString::new(item.label.clone()).expect("unable to convert item label to CString"); + + // let trigger = if let Some(trigger) = item.trigger.as_deref() { + // CString::new(trigger.to_string()).expect("unable to convert item trigger to CString") + // } else { + // CString::new("".to_string()).expect("unable to convert item trigger to CString") + // }; + + // Self { id, label, trigger } + // } + // } +} + +// struct SearchData { +// owned_search: interop::OwnedSearch, +// items: Vec, +// algorithm: Box Vec>, +// } + +pub fn show() { + use super::interop::*; + + // extern "C" fn search_callback(query: *const c_char, app: *const c_void, data: *const c_void) { + // let query = unsafe { CStr::from_ptr(query) }; + // let query = query.to_string_lossy().to_string(); + + // let search_data = data as *const SearchData; + // let search_data = unsafe { &*search_data }; + + // let indexes = (*search_data.algorithm)(&query, &search_data.items); + // let items: Vec = indexes + // .into_iter() + // .map(|index| search_data.owned_search.interop_items[index]) + // .collect(); + + // unsafe { + // update_items(app, items.as_ptr(), items.len() as c_int); + // } + // } + + // let mut result: Option = None; + + // extern "C" fn result_callback(id: *const c_char, result: *mut c_void) { + // let id = unsafe { CStr::from_ptr(id) }; + // let id = id.to_string_lossy().to_string(); + // let result: *mut Option = result as *mut Option; + // unsafe { + // *result = Some(id); + // } + // } + + unsafe { + interop_show_wizard( + // metadata, + // search_callback, + // &search_data as *const SearchData as *const c_void, + // result_callback, + // &mut result as *mut Option as *mut c_void, + ); + } + + //result +} diff --git a/espanso-modulo/src/sys/wizard/wizard.cpp b/espanso-modulo/src/sys/wizard/wizard.cpp new file mode 100644 index 0000000..5d443e0 --- /dev/null +++ b/espanso-modulo/src/sys/wizard/wizard.cpp @@ -0,0 +1,78 @@ +/* + * This file is part of modulo. + * + * Copyright (C) 2020-2021 Federico Terzi + * + * modulo 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 3 of the License, or + * (at your option) any later version. + * + * modulo 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 modulo. If not, see . + */ + +#define _UNICODE + +#include "../common/common.h" +#include "../interop/interop.h" +#include "./wizard_gui.h" + +#include +#include +#include + +// App Code + +class WizardApp : public wxApp +{ +public: + virtual bool OnInit(); +}; + +class DerivedFrame : public WizardFrame +{ +protected: + void welcome_start_clicked(wxCommandEvent &event); + +public: + DerivedFrame(wxWindow *parent); +}; + +DerivedFrame::DerivedFrame(wxWindow *parent) + : WizardFrame(parent) +{ +} + +void DerivedFrame::welcome_start_clicked(wxCommandEvent &event) +{ + this->m_simplebook->ChangeSelection(2); +} + +bool WizardApp::OnInit() +{ + DerivedFrame *frame = new DerivedFrame(NULL); + //setFrameIcon(formMetadata->iconPath, frame); + frame->Show(true); + + Activate(frame); + + return true; +} + +extern "C" void interop_show_wizard() +{ +// Setup high DPI support on Windows +#ifdef __WXMSW__ + SetProcessDPIAware(); +#endif + + wxApp::SetInstance(new WizardApp()); + int argc = 0; + wxEntry(argc, (char **)nullptr); +} \ No newline at end of file diff --git a/espanso-modulo/src/sys/wizard/wizard.fbp b/espanso-modulo/src/sys/wizard/wizard.fbp new file mode 100644 index 0000000..8f62512 --- /dev/null +++ b/espanso-modulo/src/sys/wizard/wizard.fbp @@ -0,0 +1,1201 @@ + + + + + ; + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + wizard_gui + 1000 + none + + 0 + Wizard + + . + #define _UNICODE + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + wxSYS_COLOUR_WINDOW + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + WizardFrame + + 546,572 + wxCAPTION|wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER + ; ; forward_declare + Espanso + + + + wxTAB_TRAVERSAL + 1 + + + bSizer1 + wxVERTICAL + none + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_simplebook + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + + + a page + 0 + + 1 + 1 + 1 + 1 + + + + + + wxSYS_COLOUR_WINDOW + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + welcome_panel + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + bSizer2 + wxVERTICAL + none + + 20 + wxALIGN_CENTER_HORIZONTAL|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,92,18,70,0 + 0 + 0 + wxID_ANY + Welcome to Espanso! + 0 + + 0 + + + 0 + + 1 + welcome_title_text + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxALIGN_CENTER_HORIZONTAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + (version 1.2.3) + 0 + + 0 + + + 0 + + 1 + welcome_version_text + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 20 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + This wizard will help you to quickly get started with the tool + 0 + + 0 + + + 0 + + 1 + welcome_description_text + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 10 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 1 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Start + + 0 + + 0 + + + 0 + + 1 + welcome_start_button + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + welcome_start_clicked + + + + + + + a page + 0 + + 1 + 1 + 1 + 1 + + + + + + wxSYS_COLOUR_WINDOW + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + legacy_version_panel + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + bSizer21 + wxVERTICAL + none + + 20 + wxALIGN_CENTER_HORIZONTAL|wxALIGN_LEFT|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,92,18,70,0 + 0 + 0 + wxID_ANY + Legacy version detected + 0 + + 0 + + + 0 + + 1 + legacy_version_title + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 20 + wxLEFT|wxRIGHT|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + A legacy espanso process has been detected and prevents the new version from working correctly. Please terminate and uninstall the old espanso version to proceed. For more information, see: + 0 + + 0 + + + 0 + + 1 + legacy_version_description + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 20 + wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + + wxID_ANY + https://espanso.org/migration#uninstall + + 0 + + + 0 + + 1 + legacy_version_docs_link + + 1 + + + protected + 1 + + Resizable + 1 + + wxHL_DEFAULT_STYLE + ; ; forward_declare + 0 + + https://espanso.org/migration#uninstall + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 10 + wxALIGN_RIGHT|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 1 + 0 + + Dock + 0 + Left + 0 + + 1 + + + 0 + 0 + wxID_ANY + Continue + + 0 + + 0 + + + 0 + + 1 + legacy_version_continue_button + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + a page + 0 + + 1 + 1 + 1 + 1 + + + + + + wxSYS_COLOUR_WINDOW + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + migrate_panel + 1 + + + protected + 1 + + Resizable + 1 + + ; ; forward_declare + 0 + + + + wxTAB_TRAVERSAL + + + bSizer211 + wxVERTICAL + none + + 20 + wxALIGN_CENTER_HORIZONTAL|wxALIGN_LEFT|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,92,18,70,0 + 0 + 0 + wxID_ANY + Migrate configuration + 0 + + 0 + + + 0 + + 1 + migrate_title + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 20 + wxLEFT|wxRIGHT|wxTOP + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + The new version uses a slightly different configuration format that powers some exciting new features. To ease the transition, espanso offers two possible choices: - Automatically backup the old configuration in the Documents folder and migrate to the new format (recommended). - Use compatibility mode without changing the configs. Keep in mind that: - Compatibility mode does not support all new espanso features - You can always migrate the configs later For more information, see: + 0 + + 0 + + + 0 + + 1 + migrate_description + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + + + -1 + + + + 20 + wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + + wxID_ANY + https://espanso.org/migration + + 0 + + + 0 + + 1 + migrate_link + + 1 + + + protected + 1 + + Resizable + 1 + + wxHL_DEFAULT_STYLE + ; ; forward_declare + 0 + + https://espanso.org/migration + + + + + + + + 5 + wxEXPAND + 10 + + 0 + protected + 0 + + + + 5 + wxEXPAND + 1 + + -1,-1 + bSizer8 + wxHORIZONTAL + none + + 10 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Use compatibility mode + + 0 + + 0 + + + 0 + + 1 + migrate_compatibility_mode_button + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 10 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 1 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Backup && Migrate + + 0 + + 0 + + + 0 + + 1 + migrate_backup_and_migrate_button + 1 + + + protected + 1 + + + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + diff --git a/espanso-modulo/src/sys/wizard/wizard_gui.cpp b/espanso-modulo/src/sys/wizard/wizard_gui.cpp new file mode 100644 index 0000000..b666b03 --- /dev/null +++ b/espanso-modulo/src/sys/wizard/wizard_gui.cpp @@ -0,0 +1,152 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#define _UNICODE + +#include "wizard_gui.h" + +/////////////////////////////////////////////////////////////////////////// + +WizardFrame::WizardFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); + + wxBoxSizer* bSizer1; + bSizer1 = new wxBoxSizer( wxVERTICAL ); + + m_simplebook = new wxSimplebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + welcome_panel = new wxPanel( m_simplebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + welcome_panel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); + + wxBoxSizer* bSizer2; + bSizer2 = new wxBoxSizer( wxVERTICAL ); + + welcome_title_text = new wxStaticText( welcome_panel, wxID_ANY, wxT("Welcome to Espanso!"), wxDefaultPosition, wxDefaultSize, 0 ); + welcome_title_text->Wrap( -1 ); + welcome_title_text->SetFont( wxFont( 18, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); + + bSizer2->Add( welcome_title_text, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP, 20 ); + + welcome_version_text = new wxStaticText( welcome_panel, wxID_ANY, wxT("(version 1.2.3)"), wxDefaultPosition, wxDefaultSize, 0 ); + welcome_version_text->Wrap( -1 ); + bSizer2->Add( welcome_version_text, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + + welcome_description_text = new wxStaticText( welcome_panel, wxID_ANY, wxT("This wizard will help you to quickly get started with the tool"), wxDefaultPosition, wxDefaultSize, 0 ); + welcome_description_text->Wrap( -1 ); + bSizer2->Add( welcome_description_text, 0, wxALL, 20 ); + + + bSizer2->Add( 0, 0, 1, wxEXPAND, 5 ); + + welcome_start_button = new wxButton( welcome_panel, wxID_ANY, wxT("Start"), wxDefaultPosition, wxDefaultSize, 0 ); + + welcome_start_button->SetDefault(); + bSizer2->Add( welcome_start_button, 0, wxALIGN_RIGHT|wxALL, 10 ); + + + welcome_panel->SetSizer( bSizer2 ); + welcome_panel->Layout(); + bSizer2->Fit( welcome_panel ); + m_simplebook->AddPage( welcome_panel, wxT("a page"), false ); + legacy_version_panel = new wxPanel( m_simplebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + legacy_version_panel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); + + wxBoxSizer* bSizer21; + bSizer21 = new wxBoxSizer( wxVERTICAL ); + + legacy_version_title = new wxStaticText( legacy_version_panel, wxID_ANY, wxT("Legacy version detected"), wxDefaultPosition, wxDefaultSize, 0 ); + legacy_version_title->Wrap( -1 ); + legacy_version_title->SetFont( wxFont( 18, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); + + bSizer21->Add( legacy_version_title, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_LEFT|wxTOP, 20 ); + + legacy_version_description = new wxStaticText( legacy_version_panel, wxID_ANY, wxT("A legacy espanso process has been detected and prevents the new version from working correctly.\n\nPlease terminate and uninstall the old espanso version to proceed.\n\nFor more information, see: \n"), wxDefaultPosition, wxDefaultSize, 0 ); + legacy_version_description->Wrap( -1 ); + bSizer21->Add( legacy_version_description, 0, wxLEFT|wxRIGHT|wxTOP, 20 ); + + legacy_version_docs_link = new wxHyperlinkCtrl( legacy_version_panel, wxID_ANY, wxT("https://espanso.org/migration#uninstall"), wxT("https://espanso.org/migration#uninstall"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); + bSizer21->Add( legacy_version_docs_link, 0, wxLEFT|wxRIGHT, 20 ); + + + bSizer21->Add( 0, 0, 1, wxEXPAND, 5 ); + + legacy_version_continue_button = new wxButton( legacy_version_panel, wxID_ANY, wxT("Continue"), wxDefaultPosition, wxDefaultSize, 0 ); + + legacy_version_continue_button->SetDefault(); + legacy_version_continue_button->Enable( false ); + + bSizer21->Add( legacy_version_continue_button, 0, wxALIGN_RIGHT|wxALL, 10 ); + + + legacy_version_panel->SetSizer( bSizer21 ); + legacy_version_panel->Layout(); + bSizer21->Fit( legacy_version_panel ); + m_simplebook->AddPage( legacy_version_panel, wxT("a page"), false ); + migrate_panel = new wxPanel( m_simplebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + migrate_panel->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); + + wxBoxSizer* bSizer211; + bSizer211 = new wxBoxSizer( wxVERTICAL ); + + migrate_title = new wxStaticText( migrate_panel, wxID_ANY, wxT("Migrate configuration"), wxDefaultPosition, wxDefaultSize, 0 ); + migrate_title->Wrap( -1 ); + migrate_title->SetFont( wxFont( 18, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); + + bSizer211->Add( migrate_title, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_LEFT|wxTOP, 20 ); + + migrate_description = new wxStaticText( migrate_panel, wxID_ANY, wxT("The new version uses a slightly different configuration format that powers some exciting new features.\n\nTo ease the transition, espanso offers two possible choices:\n\n - Automatically backup the old configuration in the Documents folder and migrate to the new format (recommended).\n - Use compatibility mode without changing the configs.\n\nKeep in mind that:\n\n - Compatibility mode does not support all new espanso features\n - You can always migrate the configs later\n\nFor more information, see:\n\n"), wxDefaultPosition, wxDefaultSize, 0 ); + migrate_description->Wrap( -1 ); + bSizer211->Add( migrate_description, 0, wxLEFT|wxRIGHT|wxTOP, 20 ); + + migrate_link = new wxHyperlinkCtrl( migrate_panel, wxID_ANY, wxT("https://espanso.org/migration"), wxT("https://espanso.org/migration"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE ); + bSizer211->Add( migrate_link, 0, wxLEFT|wxRIGHT, 20 ); + + + bSizer211->Add( 0, 0, 10, wxEXPAND, 5 ); + + wxBoxSizer* bSizer8; + bSizer8 = new wxBoxSizer( wxHORIZONTAL ); + + migrate_compatibility_mode_button = new wxButton( migrate_panel, wxID_ANY, wxT("Use compatibility mode"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer8->Add( migrate_compatibility_mode_button, 0, wxALL, 10 ); + + + bSizer8->Add( 0, 0, 1, wxEXPAND, 5 ); + + migrate_backup_and_migrate_button = new wxButton( migrate_panel, wxID_ANY, wxT("Backup && Migrate"), wxDefaultPosition, wxDefaultSize, 0 ); + + migrate_backup_and_migrate_button->SetDefault(); + bSizer8->Add( migrate_backup_and_migrate_button, 0, wxALL, 10 ); + + + bSizer211->Add( bSizer8, 1, wxEXPAND, 5 ); + + + migrate_panel->SetSizer( bSizer211 ); + migrate_panel->Layout(); + bSizer211->Fit( migrate_panel ); + m_simplebook->AddPage( migrate_panel, wxT("a page"), false ); + + bSizer1->Add( m_simplebook, 1, wxEXPAND | wxALL, 5 ); + + + this->SetSizer( bSizer1 ); + this->Layout(); + + this->Centre( wxBOTH ); + + // Connect Events + welcome_start_button->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WizardFrame::welcome_start_clicked ), NULL, this ); +} + +WizardFrame::~WizardFrame() +{ + // Disconnect Events + welcome_start_button->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WizardFrame::welcome_start_clicked ), NULL, this ); + +} diff --git a/espanso-modulo/src/sys/wizard/wizard_gui.h b/espanso-modulo/src/sys/wizard/wizard_gui.h new file mode 100644 index 0000000..799f308 --- /dev/null +++ b/espanso-modulo/src/sys/wizard/wizard_gui.h @@ -0,0 +1,68 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class WizardFrame +/////////////////////////////////////////////////////////////////////////////// +class WizardFrame : public wxFrame +{ + private: + + protected: + wxSimplebook* m_simplebook; + wxPanel* welcome_panel; + wxStaticText* welcome_title_text; + wxStaticText* welcome_version_text; + wxStaticText* welcome_description_text; + wxButton* welcome_start_button; + wxPanel* legacy_version_panel; + wxStaticText* legacy_version_title; + wxStaticText* legacy_version_description; + wxHyperlinkCtrl* legacy_version_docs_link; + wxButton* legacy_version_continue_button; + wxPanel* migrate_panel; + wxStaticText* migrate_title; + wxStaticText* migrate_description; + wxHyperlinkCtrl* migrate_link; + wxButton* migrate_compatibility_mode_button; + wxButton* migrate_backup_and_migrate_button; + + // Virtual event handlers, overide them in your derived class + virtual void welcome_start_clicked( wxCommandEvent& event ) { event.Skip(); } + + + public: + + WizardFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Espanso"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 546,572 ), long style = wxCAPTION|wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxTAB_TRAVERSAL ); + + ~WizardFrame(); + +}; + diff --git a/espanso-modulo/src/wizard/mod.rs b/espanso-modulo/src/wizard/mod.rs new file mode 100644 index 0000000..8c0fe43 --- /dev/null +++ b/espanso-modulo/src/wizard/mod.rs @@ -0,0 +1,20 @@ +/* + * This file is part of modulo. + * + * Copyright (C) 2020-2021 Federico Terzi + * + * modulo 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 3 of the License, or + * (at your option) any later version. + * + * modulo 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 modulo. If not, see . + */ + +pub use crate::sys::wizard::show; \ No newline at end of file