From c55bd4f826dcd5b1b9b23abe8bd421c73bd964db Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 21 May 2023 22:54:37 +0200 Subject: [PATCH 01/14] Fix Fixed language menu entries check-state --- installer/mainwindow.ui | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/installer/mainwindow.ui b/installer/mainwindow.ui index 31d8185..9f4ca01 100644 --- a/installer/mainwindow.ui +++ b/installer/mainwindow.ui @@ -1019,6 +1019,12 @@ + + true + + + true + :/flags/flags/en.png:/flags/flags/en.png @@ -1031,6 +1037,9 @@ + + true + :/flags/flags/es.png:/flags/flags/es.png @@ -1043,6 +1052,9 @@ + + true + :/flags/flags/fr.png:/flags/flags/fr.png @@ -1055,6 +1067,9 @@ + + true + :/flags/flags/it.png:/flags/flags/it.png -- 2.30.2 From 565cd39bbd53e9b5366cc480dfcd5414fc683e46 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 21 May 2023 22:55:37 +0200 Subject: [PATCH 02/14] Improvements Code improvements. Moved OS check to compile time. --- installer/main.cpp | 8 +- installer/mainwindow.cpp | 307 ++++++++++++++++++--------------------- installer/mainwindow.h | 38 ++--- 3 files changed, 167 insertions(+), 186 deletions(-) diff --git a/installer/main.cpp b/installer/main.cpp index c9ae2b6..b848b42 100644 --- a/installer/main.cpp +++ b/installer/main.cpp @@ -1,8 +1,12 @@ -#include "mainwindow.h" - #include +#if !(defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) || defined( Q_OS_WINDOWS ) || defined( Q_OS_MACOS )) +# error "System not supported" +#endif + +#include "mainwindow.h" + int main(int argc, char *argv[]) { diff --git a/installer/mainwindow.cpp b/installer/mainwindow.cpp index 7803488..ef2140d 100644 --- a/installer/mainwindow.cpp +++ b/installer/mainwindow.cpp @@ -73,6 +73,11 @@ MainWindow::~MainWindow() delete this->installer_timer; } +void MainWindow::on_button_Close_clicked() +{ + this->close(); +} + /////////////// //// UTILS //// @@ -274,27 +279,31 @@ void MainWindow::Install() } } - if ( ok && this->OS != 3 ) { // mac .app contains it - this->ui->progressBar_Install->setValue( 85 ); - this->ui->label_Install_Info->setText( MainWindow::tr( "Copying the uninstaller ..." ) ); - // move the uninstaller - ok = this->copyUninstaller(); - } + #if !defined( Q_OS_MACOS ) + if ( ok ) { // mac .app contains it + this->ui->progressBar_Install->setValue( 85 ); + this->ui->label_Install_Info->setText( MainWindow::tr( "Copying the uninstaller ..." ) ); + // move the uninstaller + ok = this->copyUninstaller(); + } + #endif } - if ( ok && this->OS != 3 ) { // mac .app contains these - this->ui->progressBar_Install->setValue( 90 ); - this->ui->label_Install_Info->setText( MainWindow::tr( "Copying the icon ..." ) ); - // move the icon - ok = this->copyIcon(); + #if !defined( Q_OS_MACOS ) + if ( ok ) { // mac .app contains these + this->ui->progressBar_Install->setValue( 90 ); + this->ui->label_Install_Info->setText( MainWindow::tr( "Copying the icon ..." ) ); + // move the icon + ok = this->copyIcon(); - // make the menu entry - if ( ok && this->make_menu_entry ) { - this->ui->progressBar_Install->setValue( 95 ); - this->ui->label_Install_Info->setText( MainWindow::tr( "Creating the menu entry ..." ) ); - ok = this->makeMenuEntry(); + // make the menu entry + if ( ok && this->make_menu_entry ) { + this->ui->progressBar_Install->setValue( 95 ); + this->ui->label_Install_Info->setText( MainWindow::tr( "Creating the menu entry ..." ) ); + ok = this->makeMenuEntry(); + } } - } + #endif // proocess finished if ( ok ) { @@ -323,8 +332,21 @@ bool MainWindow::checkExecutablePath() if ( ! std::filesystem::exists( this->exec_path ) ) { this->ui->progressBar_Install->setValue( 10 ); // path does not exists - if ( this->OS != 2 ) { - // on unix/mac. path is (supposedly) always present + #if defined( Q_OS_WINDOWS ) + // must create the new folder + ok = std::filesystem::create_directory( this->exec_path, err ); + if ( !ok ) { + // failed to create + DialogMsg dialog = DialogMsg( + MainWindow::tr( "Installation failed" ), + QString("%1:\n%2").arg( + MainWindow::tr( "Failed to create the directory" ), + QString::fromStdString( this->exec_path.string() ) ), + QString::fromStdString( err.message() ), 2, nullptr ); + std::ignore = dialog.exec(); + } + #else + // unix-like. path is (supposedly) always present ok = false; DialogMsg dialog = DialogMsg( MainWindow::tr( "Installation failed" ), @@ -333,27 +355,14 @@ bool MainWindow::checkExecutablePath() QString::fromStdString( this->exec_path.string() ) ), QString::fromStdString( err.message() ), 2, nullptr ); std::ignore = dialog.exec(); - } else { - // on windows. must create the new folder - ok = std::filesystem::create_directory( this->exec_path, err ); - if ( !ok ) { - // failed to create - DialogMsg dialog = DialogMsg( - MainWindow::tr( "Installation failed" ), - QString("%1:\n%2").arg( - MainWindow::tr( "Failed to create the directory" ), - QString::fromStdString( this->exec_path.string() ) ), - QString::fromStdString( err.message() ), 2, nullptr ); - std::ignore = dialog.exec(); - } - } + #endif } else { this->ui->progressBar_Install->setValue( 5 ); // path exists - if ( this->OS == 1 ) { - // on unix. check if the executable already exists - const std::filesystem::path path = this->exec_path.string() + "/logdoctor"; + #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + // check if the executable already exists + const std::filesystem::path path = this->exec_path / "logdoctor"; if ( std::filesystem::exists( path ) ) { // an entry already exists, ask to overwrite it { @@ -385,7 +394,7 @@ bool MainWindow::checkExecutablePath() } } } - } else { + #else // on windows/mac if ( ! std::filesystem::is_directory( this->exec_path ) ) { // not a directory, ask to overwrite it @@ -430,13 +439,13 @@ bool MainWindow::checkExecutablePath() } else { this->ui->progressBar_Install->setValue( 5 ); // installation altready exists, check the executable - const std::string ext = (this->OS==2) ? ".exe" : ".app"; - std::vector names = {"/LogDoctor","/uninstall"}; - if ( this->OS == 3 ) { - names.pop_back(); - } + #if defined( Q_OS_WINDOWS ) + const std::vector names = {"LogDoctor.exe","uninstall.exe"}; + #elif defined( Q_OS_MACOS ) + const std::vector names = {"LogDoctor.app"}; + #endif for ( const auto& name : names ) { - const std::filesystem::path path = this->exec_path.string() + name + ext; + const std::filesystem::path path = this->exec_path / name; if ( std::filesystem::exists( path ) ) { // an entry already exists, ask to overwrite it { @@ -470,7 +479,7 @@ bool MainWindow::checkExecutablePath() } } } - } + #endif } return ok; } @@ -541,7 +550,7 @@ bool MainWindow::checkConfigsPath() } else { this->ui->progressBar_Install->setValue( 20 ); // is a directory: probably an installation already exists, check if a cofiguration file is present - const std::filesystem::path path = this->conf_path.string() + "/logdoctor.conf"; + const std::filesystem::path path = this->conf_path / "logdoctor.conf"; if ( std::filesystem::exists( path ) ) { // a configuration file already exists, ask to overwrite it or not { @@ -663,11 +672,14 @@ bool MainWindow::checkAppdataPath() if ( ok ) { this->ui->progressBar_Install->setValue( 40 ); // agreed on overwriting content, remove it - std::vector paths = { - this->data_path.string() + "/help" }; - if ( this->OS != 3 ) { // mac .app already contains it - paths.push_back( this->data_path.string() + "/licenses" ); - } + #if defined( Q_OS_MACOS ) + const std::vector paths = { + this->data_path / "help" }; + #else + const std::vector paths = { + this->data_path / "help", + this->data_path / "licenses" }; // mac .app already contains it + #endif for ( const auto& path : paths ) { // remove the entries if ( !std::filesystem::exists( path ) ) { @@ -698,29 +710,25 @@ bool MainWindow::copyExecutable() bool ok = true; std::error_code err; - std::string exec_name; - switch ( this->OS ) { - case 1: - exec_name = "logdoctor"; break; - case 2: - exec_name = "LogDoctor.exe"; break; - case 3: - exec_name = "LogDoctor.app"; break; - default: - throw( "LogDoctor: copyExecutable(): Unexpected OS: "[this->OS] ); - } + #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + const std::string exec_name = "logdoctor"; + #elif defined( Q_OS_WINDOWS ) + const std::string exec_name = "LogDoctor.exe"; + #elif defined( Q_OS_MACOS ) + const std::string exec_name = "LogDoctor.app"; + #endif const std::filesystem::path src_path = "installation_stuff/"+exec_name; - const std::filesystem::path dst_path = this->exec_path.string()+"/"+exec_name; + const std::filesystem::path dst_path = this->exec_path / exec_name; - if ( this->OS == 3 ) { + #if defined( Q_OS_MACOS ) std::filesystem::copy( src_path, dst_path, std::filesystem::copy_options::overwrite_existing | std::filesystem::copy_options::recursive, err ); if ( err.value() != 0 ) { ok = false; } - } else { + #else ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); - } + #endif if ( !ok ) { // failed to copy @@ -740,21 +748,18 @@ bool MainWindow::copyExecutable() std::filesystem::permissions( dst_path, std::filesystem::perms::group_all, std::filesystem::perm_options::remove ); std::filesystem::permissions( dst_path, std::filesystem::perms::group_read, std::filesystem::perm_options::add ); std::filesystem::permissions( dst_path, std::filesystem::perms::others_all, std::filesystem::perm_options::remove ); - switch ( this->OS ) { - case 1: - // 7 5 5 - std::filesystem::permissions( dst_path, std::filesystem::perms::others_exec, std::filesystem::perm_options::add ); - case 3: - // 7 5 4 - std::filesystem::permissions( dst_path, std::filesystem::perms::group_exec, std::filesystem::perm_options::add ); - std::filesystem::permissions( dst_path, std::filesystem::perms::others_read, std::filesystem::perm_options::add ); - break; - case 2: - // rw r - - break; - default: - throw( "LogDoctor: copyExecutable(): Unexpected OS: "[this->OS] ); - } + #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + // 7 5 5 + std::filesystem::permissions( dst_path, std::filesystem::perms::group_exec, std::filesystem::perm_options::add ); + std::filesystem::permissions( dst_path, std::filesystem::perms::others_read, std::filesystem::perm_options::add ); + std::filesystem::permissions( dst_path, std::filesystem::perms::others_exec, std::filesystem::perm_options::add ); + #elif defined( Q_OS_MACOS ) + // 7 5 4 + std::filesystem::permissions( dst_path, std::filesystem::perms::group_exec, std::filesystem::perm_options::add ); + std::filesystem::permissions( dst_path, std::filesystem::perms::others_read, std::filesystem::perm_options::add ); + #elif defined( Q_OS_WINDOWS ) + // rw r - + #endif } catch (...) { ok = false; @@ -778,7 +783,7 @@ bool MainWindow::copyConfigfile() std::error_code err; const std::filesystem::path src_path = "installation_stuff/logdoctor.conf"; - const std::filesystem::path dst_path = this->conf_path.string()+"/logdoctor.conf"; + const std::filesystem::path dst_path = this->conf_path / "logdoctor.conf"; ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); if ( !ok ) { @@ -800,14 +805,18 @@ bool MainWindow::copyResources() bool ok = true; std::error_code err; - std::vector names = { "help" }; - if ( this->OS != 3 ) { // mac .app already contains it - names.push_back( "licenses" ); - } + #if defined( Q_OS_MACOS ) + const std::vector names = { + "help" }; + #else + const std::vector names = { + "help", + "licenses" }; // mac .app already contains it + #endif for ( const auto& name : names ) { // remove the entries const std::filesystem::path src_path = "installation_stuff/logdocdata/"+name; - const std::filesystem::path dst_path = this->data_path.string()+"/"+name; + const std::filesystem::path dst_path = this->data_path / name; std::filesystem::copy( src_path, dst_path, std::filesystem::copy_options::overwrite_existing | std::filesystem::copy_options::recursive, err ); if ( err.value() != 0 ) { // failed to move @@ -831,20 +840,16 @@ bool MainWindow::copyUninstaller() bool ok = true; std::error_code err; - std::filesystem::path src_path; - std::filesystem::path dst_path; - switch ( this->OS ) { - case 1: - src_path = "installation_stuff/uninstall"; - dst_path = this->data_path.string()+"/uninstall"; - break; - case 2: - src_path = "installation_stuff/uninstall.exe"; - dst_path = this->exec_path.string()+"/uninstall.exe"; - break; - default: - throw( "LogDoctor: copyUninstaller(): Unexpected OS: "[this->OS] ); - } + #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + const std::filesystem::path src_path = "installation_stuff/uninstall"; + const std::filesystem::path dst_path = this->data_path / "uninstall"; + #elif defined( Q_OS_WINDOWS ) + const std::filesystem::path src_path = "installation_stuff/uninstall.exe"; + const std::filesystem::path dst_path = this->exec_path / "uninstall.exe"; + #else + // macOS should not run this method + throw( "LogDoctor: copyUninstaller(): Unexpected OS" ); + #endif ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); if ( !ok ) { @@ -864,18 +869,14 @@ bool MainWindow::copyUninstaller() std::filesystem::permissions( dst_path, std::filesystem::perms::group_all, std::filesystem::perm_options::remove ); std::filesystem::permissions( dst_path, std::filesystem::perms::group_read, std::filesystem::perm_options::add ); std::filesystem::permissions( dst_path, std::filesystem::perms::others_all, std::filesystem::perm_options::remove ); - switch ( this->OS ) { - case 1: - // 7 5 4 + #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + // 7 5 5 std::filesystem::permissions( dst_path, std::filesystem::perms::group_exec, std::filesystem::perm_options::add ); std::filesystem::permissions( dst_path, std::filesystem::perms::others_read, std::filesystem::perm_options::add ); - break; - case 2: - // rw r - - break; - default: - throw( "LogDoctor: copyUninstaller(): Unexpected OS: "[this->OS] ); - } + std::filesystem::permissions( dst_path, std::filesystem::perms::others_exec, std::filesystem::perm_options::add ); + #elif defined( Q_OS_WINDOWS ) + // rw r - + #endif } catch (...) { ok = false; @@ -899,19 +900,14 @@ bool MainWindow::copyIcon() std::error_code err; const std::filesystem::path src_path = "installation_stuff/LogDoctor.svg"; - std::filesystem::path dst_path; - switch ( this->OS ) { - case 1: - // unix - dst_path = "/usr/share/LogDoctor/LogDoctor.svg"; - break; - case 2: - // windows - dst_path = this->exec_path.string() + "/LogDoctor.svg"; - break; - default: - throw( "LogDoctor: copyIcon(): Unexpected OS: "[this->OS] ); - } + #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + const std::filesystem::path dst_path = "/usr/share/LogDoctor/LogDoctor.svg"; + #elif defined( Q_OS_WINDOWS ) + const std::filesystem::path dst_path = this->exec_path / "LogDoctor.svg"; + #else + // macOS should not run this method + throw( "LogDoctor: copyIcon(): Unexpected OS" ); + #endif ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); if ( !ok ) { @@ -933,37 +929,33 @@ bool MainWindow::makeMenuEntry() bool ok = true; std::error_code err; - std::filesystem::path src_path; - std::filesystem::path dst_path; - switch ( this->OS ) { - - case 1: - // unix - src_path = "installation_stuff/LogDoctor.desktop"; - dst_path = this->home_path+"/.local/share/applications/LogDoctor.desktop"; - ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); - break; - - case 2: - // windows - src_path = this->exec_path.string()+"/LogDoctor.exe"; - dst_path = this->home_path.substr(0,2) + "/ProgramData/Microsoft/Windows/Start Menu/Programs/LogDoctor.exe"; - if ( std::filesystem::exists( dst_path ) ) { - // an old entry already exists, remove it - std::ignore = std::filesystem::remove( dst_path, err ); - ok = ! std::filesystem::exists( dst_path ); + #if defined( Q_OS_LINUX ) + const std::filesystem::path src_path = "installation_stuff/LogDoctor.desktop"; + const std::filesystem::path dst_path = "/usr/share/applications/LogDoctor.desktop"; + ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); + #elif defined( Q_OS_BSD4 ) + const std::filesystem::path src_path = "installation_stuff/LogDoctor.desktop"; + const std::filesystem::path dst_path = "/usr/local/share/applications/LogDoctor.desktop"; + ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); + #elif defined( Q_OS_WINDOWS ) + const std::filesystem::path src_path = this->exec_path / "LogDoctor.exe"; + const std::filesystem::path dst_path = this->home_path.substr(0,2) + "/ProgramData/Microsoft/Windows/Start Menu/Programs/LogDoctor.exe"; + if ( std::filesystem::exists( dst_path ) ) { + // an old entry already exists, remove it + std::ignore = std::filesystem::remove( dst_path, err ); + ok = ! std::filesystem::exists( dst_path ); + } + if ( ok ) { + std::filesystem::create_symlink( src_path, dst_path, err ); + if ( !std::filesystem::exists( dst_path ) ) { + // failed to create + ok = false; } - if ( ok ) { - std::filesystem::create_symlink( src_path, dst_path, err ); - if ( !std::filesystem::exists( dst_path ) ) { - // failed to create - ok = false; - } - } - break; - default: - throw( "LogDoctor: makeMenuEntry(): Unexpected OS: "[this->OS] ); - } + } + #else + // macOS should not run this method + throw( "LogDoctor: makeMenuEntry(): Unexpected OS" ); + #endif if ( !ok ) { // failed @@ -977,12 +969,3 @@ bool MainWindow::makeMenuEntry() } return ok; } - - - - - -void MainWindow::on_button_Close_clicked() -{ - this->close(); -} diff --git a/installer/mainwindow.h b/installer/mainwindow.h index 4585e70..8018315 100644 --- a/installer/mainwindow.h +++ b/installer/mainwindow.h @@ -20,7 +20,7 @@ class MainWindow : public QMainWindow Q_OBJECT public: - MainWindow(QWidget *parent = nullptr); + explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); private slots: @@ -57,33 +57,27 @@ private: // operating system const std::string cleanPath( const QString& path ); - // 1: linux, 2:windows, 3:mac - const std::string home_path = this->cleanPath( QStandardPaths::locate( QStandardPaths::HomeLocation, "", QStandardPaths::LocateDirectory ) ); - #if defined( Q_OS_DARWIN ) - // Darwin-based systems: macOS, macOS, iOS, watchOS and tvOS. - const unsigned int OS = 3; - const std::filesystem::path exec_path = "/Applications"; - const std::filesystem::path conf_path = home_path + "/Lybrary/Preferences/LogDoctor"; - const std::filesystem::path data_path = home_path + "/Lybrary/Application Support/LogDoctor"; - #elif defined( Q_OS_WIN ) - // Microsoft Windows systems - const unsigned int OS = 2; - const std::filesystem::path exec_path = home_path.substr(0,2) + "/Program Files/LogDoctor"; - const std::filesystem::path conf_path = home_path + "/AppData/Local/LogDoctor"; - const std::filesystem::path data_path = home_path + "/AppData/Local/LogDoctor"; - #elif defined( Q_OS_UNIX ) - // Unix-like systems: Linux, BSD and SysV - const unsigned int OS = 1; - const std::filesystem::path exec_path = "/usr/bin"; - const std::filesystem::path conf_path = home_path + "/.config/LogDoctor"; - const std::filesystem::path data_path = "/usr/share/LogDoctor"; + + const std::string home_path{ this->cleanPath( QStandardPaths::locate( QStandardPaths::HomeLocation, "", QStandardPaths::LocateDirectory ) ) }; + #if defined( Q_OS_MACOS ) + const std::filesystem::path exec_path{ "/Applications" }; + const std::filesystem::path conf_path{ home_path + "/Lybrary/Preferences/LogDoctor" }; + const std::filesystem::path data_path{ home_path + "/Lybrary/Application Support/LogDoctor" }; + #elif defined( Q_OS_WINDOWS ) + const std::filesystem::path exec_path{ home_path.substr(0,2) + "/Program Files/LogDoctor" }; + const std::filesystem::path conf_path{ home_path + "/AppData/Local/LogDoctor" }; + const std::filesystem::path data_path{ home_path + "/AppData/Local/LogDoctor" }; + #elif defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + const std::filesystem::path exec_path{ "/usr/bin" }; + const std::filesystem::path conf_path{ home_path + "/.config/LogDoctor" }; + const std::filesystem::path data_path{ "/usr/share/LogDoctor" }; #else #error "System not supported" #endif // language QTranslator translator; - std::string language = "en"; + std::string language{ "en" }; void updateUiLanguage(); // fonts -- 2.30.2 From cfef802152e7ef6d6aa64de9c7792b8dc6e38aee Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sat, 23 Sep 2023 14:52:52 +0200 Subject: [PATCH 03/14] Updated translation files --- .../translations/LogDoctorInstaller_en.ts | 110 ------------------ .../translations/LogDoctorInstaller_es.ts | 110 ------------------ .../translations/LogDoctorInstaller_fr.ts | 110 ------------------ .../translations/LogDoctorInstaller_it.ts | 110 ------------------ 4 files changed, 440 deletions(-) diff --git a/installer/translations/LogDoctorInstaller_en.ts b/installer/translations/LogDoctorInstaller_en.ts index 92a32b7..b3bc399 100644 --- a/installer/translations/LogDoctorInstaller_en.ts +++ b/installer/translations/LogDoctorInstaller_en.ts @@ -4,12 +4,10 @@ DialogBool - Yes Yes - No No @@ -17,7 +15,6 @@ DialogMsg - Ok Ok @@ -25,321 +22,214 @@ MainWindow - LogDoctor - Installer LogDoctor - Installer - Application paths Application paths - Installation options Installation options - Standard paths will be used for the application's files. You'll be able to edit other paths while running the program after the installation. Standard paths will be used for the application's files. You'll be able to edit other paths while running the program after the installation. - - The path where the executable file will be placed in The path where the executable file will be placed in - Executable Executable - The path where the configuration file will be saved and searched in The path where the configuration file will be saved and searched in - Configuration file Configuration file - The path where the application will search in for extra resources The path where the application will search in for extra resources - Application data Application data - Utilities Utilities - Create a menu entry Create a menu entry - Back Back - - Next Next - Installing Installing - Installation process details Installation process details - Installation progress Installation progress - Close Close - Language Language - Translate to English Translate to English - Translate to Spanish Translate to Spanish - Translate to French Translate to French - Translate to Italian Translate to Italian - Checking the executable path ... Checking the executable path ... - Checking the configuration path ... Checking the configuration path ... - Checking the application data path ... Checking the application data path ... - Creating the menu entry ... Creating the menu entry ... - Final steps ... Final steps ... - Install Install - - - - - - - - - - - - - - - - - - - - - - Installation failed Installation failed - The path does not exist The path does not exist - - - - - - - Conflict Conflict - Copying the executable file ... Copying the executable file ... - - - - - Failed to copy the resource Failed to copy the resource - - Failed to assign permissions to the resource Failed to assign permissions to the resource - Copying the configuration file ... Copying the configuration file ... - Copying the application resources ... Copying the application resources ... - Copying the uninstaller ... Copying the uninstaller ... - Copying the icon ... Copying the icon ... - Error Error - Installation successful Installation successful - An error occured while installing LogDoctor An error occured while installing LogDoctor - Failed to create the menu entry Failed to create the menu entry - - An executable already exists An executable already exists - - - - - - An entry with the same name already exists An entry with the same name already exists - - - - - - - Failed to remove the entry Failed to remove the entry - An old configuration file already exists An old configuration file already exists - A directory already exists for the application data A directory already exists for the application data - - - - - - Failed to create the directory Failed to create the directory - It's suggested to renew it, but you can keep it by answering 'No' Overwrite the file? It's suggested to renew it, but you can keep it by answering 'No' Overwrite the file? - - - - - If you choose to proceed, it will be overwritten Continue? If you choose to proceed, it will be overwritten Continue? - If you choose to proceed, the content will be overwritten, exception made for databases, which won't be affected Continue? diff --git a/installer/translations/LogDoctorInstaller_es.ts b/installer/translations/LogDoctorInstaller_es.ts index c0ca7da..e7fcd49 100644 --- a/installer/translations/LogDoctorInstaller_es.ts +++ b/installer/translations/LogDoctorInstaller_es.ts @@ -4,12 +4,10 @@ DialogBool - Yes - No No @@ -17,7 +15,6 @@ DialogMsg - Ok Ok @@ -25,321 +22,214 @@ MainWindow - LogDoctor - Installer LogDoctor - Instalador - Application paths Rutas de la aplicación - Installation options Opciones de instalación - Standard paths will be used for the application's files. You'll be able to edit other paths while running the program after the installation. Se utilizarán las rutas estándar para los archivos de la aplicación. Tu podrá editar las otras rutas mientras ejecuta el programa, después de la instalación. - - The path where the executable file will be placed in La ruta donde se colocará el archivo ejecutable - Executable Ejecutable - The path where the configuration file will be saved and searched in La ruta donde se guardará y buscará el archivo de configuración - Configuration file Archivo de configuración - The path where the application will search in for extra resources La ruta donde la aplicación buscará los recursos adicionales - Application data Recursos de la aplicacion - Utilities Utilidades - Create a menu entry Crear una entrada en el menú - Back Atrás - - Next Próximo - Installing Instalando - Installation process details Detalles del proceso de instalación - Installation progress Progreso de la instalación - Close Cerrar - Language Idioma - Translate to English Traducir al Ingles - Translate to Spanish Traducir al Español - Translate to French Traducir al Francés - Translate to Italian Traducir al Italiano - Checking the executable path ... Comprobando la ruta para el ejecutable ... - Checking the configuration path ... Comprobando la ruta para el archivo de configuración ... - Checking the application data path ... Comprobando la ruta para los recursos de la aplicación... - Creating the menu entry ... Creando la entrada del menú ... - Final steps ... Pasos finales ... - Install Instalar - - - - - - - - - - - - - - - - - - - - - - Installation failed Instalación fallida - The path does not exist El camino no existe - - - - - - - Conflict Conflicto - Copying the executable file ... Copiando el archivo ejecutable ... - - - - - Failed to copy the resource Error al copiar el recurso - - Failed to assign permissions to the resource Error al asignar permisos al recurso - Copying the configuration file ... Copiando el archivo de configuración ... - Copying the application resources ... Copiando los recursos de la aplicación ... - Copying the uninstaller ... Copiando el desinstalador... - Copying the icon ... Copiando el icono ... - Error Error - Installation successful Instalación exitosa - An error occured while installing LogDoctor Ocurrió un error durante la instalación de LogDoctor - Failed to create the menu entry Error al crear la entrada del menú - - An executable already exists Ya existe un ejecutable - - - - - - An entry with the same name already exists Ya existe una entrada con el mismo nombre - - - - - - - Failed to remove the entry Error al eliminar - An old configuration file already exists Ya existe un archivo de configuración antiguo - A directory already exists for the application data Ya existe un directorio para los recursos de la aplicación - - - - - - Failed to create the directory Error al crear el directorio - It's suggested to renew it, but you can keep it by answering 'No' Overwrite the file? Se sugiere renovarlo, pero puede conservarlo respondiendo 'No' ¿Sobrescribir el archivo? - - - - - If you choose to proceed, it will be overwritten Continue? Si elige continuar, se sobrescribirá ¿Continuar? - If you choose to proceed, the content will be overwritten, exception made for databases, which won't be affected Continue? diff --git a/installer/translations/LogDoctorInstaller_fr.ts b/installer/translations/LogDoctorInstaller_fr.ts index 3a08f31..22c45ce 100644 --- a/installer/translations/LogDoctorInstaller_fr.ts +++ b/installer/translations/LogDoctorInstaller_fr.ts @@ -4,12 +4,10 @@ DialogBool - Yes Oui - No Non @@ -17,7 +15,6 @@ DialogMsg - Ok Ok @@ -25,321 +22,214 @@ MainWindow - LogDoctor - Installer LogDoctor - Installateur - Application paths Chemins de l'application - Installation options Choix d'installation - Standard paths will be used for the application's files. You'll be able to edit other paths while running the program after the installation. Les chemins standard seront utilisés pour les fichiers de l'application. Vous pourrez modifier d'autres chemins lors de l'exécution du programme, après l'installation. - - The path where the executable file will be placed in Le chemin où sera placé le fichier exécutable - Executable Exécutable - The path where the configuration file will be saved and searched in Le chemin où le fichier de configuration sera enregistré et recherché dans - Configuration file Fichier de configuration - The path where the application will search in for extra resources Le chemin où l'application recherchera des ressources supplémentaires - Application data Ressources de l'application - Utilities Utilitaires - Create a menu entry Créer une entrée dans le menu - Back Retour - - Next Prochain - Installing Installation - Installation process details Détails du processus d'installation - Installation progress Avancement de l'installation - Close Conclure - Language Langage - Translate to English Traduire en Anglais - Translate to Spanish Traduire en Espagnol - Translate to French Traduire en Français - Translate to Italian Traduire en Italien - Checking the executable path ... Vérification du chemin pour le l'exécutable ... - Checking the configuration path ... Vérification du chemin pour le fichier de configuration ... - Checking the application data path ... Vérification du chemin pour les ressources d'application... - Creating the menu entry ... Création de l'entrée de menu ... - Final steps ... Dernières étapes ... - Install Installer - - - - - - - - - - - - - - - - - - - - - - Installation failed L'installation a échoué - The path does not exist Le chemin n'existe - - - - - - - Conflict Conflit - Copying the executable file ... Copie du fichier exécutable ... - - - - - Failed to copy the resource Échec en la copie de la ressource - - Failed to assign permissions to the resource Échec en l'attribution des autorisations à la ressource - Copying the configuration file ... Copie du fichier de configuration ... - Copying the application resources ... Copie des ressources de l'application... - Copying the uninstaller ... Copie du programme de désinstallation ... - Copying the icon ... Copie de l'icône ... - Error Erreur - Installation successful Installation réussie - An error occured while installing LogDoctor Une erreur s'est produite lors de l'installation de LogDoctor - Failed to create the menu entry Impossible de créer l'entrée de menu - - An executable already exists Un exécutable existe déjà - - - - - - An entry with the same name already exists Une entrée avec le même nom existe déjà - - - - - - - Failed to remove the entry Échec de la suppression - An old configuration file already exists Un ancien fichier de configuration existe déjà - A directory already exists for the application data Un répertoire existe déjà pour les ressources de l'application - - - - - - Failed to create the directory Impossible de créer le répertoire - It's suggested to renew it, but you can keep it by answering 'No' Overwrite the file? Il est suggéré de le renouveler, mais vous pouvez le conserver en répondant 'Non' Ecraser le fichier? - - - - - If you choose to proceed, it will be overwritten Continue? Si vous choisissez de continuer, il sera écrasé Continuer? - If you choose to proceed, the content will be overwritten, exception made for databases, which won't be affected Continue? diff --git a/installer/translations/LogDoctorInstaller_it.ts b/installer/translations/LogDoctorInstaller_it.ts index 9e8b543..40b5c73 100644 --- a/installer/translations/LogDoctorInstaller_it.ts +++ b/installer/translations/LogDoctorInstaller_it.ts @@ -4,12 +4,10 @@ DialogBool - Yes - No No @@ -17,7 +15,6 @@ DialogMsg - Ok Ok @@ -25,321 +22,214 @@ MainWindow - LogDoctor - Installer LogDoctor - Installazione - Application paths Percorso dell'applicazione - Installation options Opzioni di installazione - Standard paths will be used for the application's files. You'll be able to edit other paths while running the program after the installation. Verranno usati i percorsi standard per i file dell'applicazione. Potrai modificare gli altri percorsi dopo l'installazione, durante l'esecuzione del programma. - - The path where the executable file will be placed in Il percorso in cui verrà posizionato l'eseguibile - Executable Eseguibile - The path where the configuration file will be saved and searched in Il percorso in cui verrà salvato e cercato il file di configurazione - Configuration file File di configurazione - The path where the application will search in for extra resources Il percorso in cui l'applicazione cercherà le risorse extra - Application data Risorse dell'applicazione - Utilities Utilità - Create a menu entry Crea un collegamento nel menù - Back Indietro - - Next Avanti - Installing Installazione - Installation process details Dettagli del processo di installazione - Installation progress Progresso dell'installazione - Close Chiudi - Language Lingua - Translate to English Traduci in Inglese - Translate to Spanish Traduci in Spagnolo - Translate to French Traduci in Francese - Translate to Italian Traduci in Italiano - Checking the executable path ... Controllo del percorso dell'eseguibile ... - Checking the configuration path ... Controllo del percorso del file di configurazione ... - Checking the application data path ... Controllo del percorso delle risorse dell'applicazione ... - Creating the menu entry ... Creazione del collegamento al menù ... - Final steps ... Passi finali ... - Install Installa - - - - - - - - - - - - - - - - - - - - - - Installation failed Installazione fallita - The path does not exist Il percorso non esiste - - - - - - - Conflict Conflitto - Copying the executable file ... Copia del file eseguibile in corso ... - - - - - Failed to copy the resource Errore nel copiare le risorse - - Failed to assign permissions to the resource Errore nell'assegnare i permessi alle risorse - Copying the configuration file ... Copia del file di configurazione in corso ... - Copying the application resources ... Copia delle risorse dell'applicazione in corso ... - Copying the uninstaller ... Copia del disinstallatore in corso ... - Copying the icon ... Copia dell'icona in corso ... - Error Errore - Installation successful Installazione riuscita - An error occured while installing LogDoctor È avvenuto un errore durante l'installazione di LogDoctor - Failed to create the menu entry Errore nel creare il collegamento al menù - - An executable already exists Esiste già un eseguibile - - - - - - An entry with the same name already exists Esiste già un oggetto con lo stesso nome - - - - - - - Failed to remove the entry Errore nella rimozione - An old configuration file already exists Un file di configurazione è già presente - A directory already exists for the application data Esiste già una directory per le risorse dell'applicazione - - - - - - Failed to create the directory Errore nella creazione della cartella - It's suggested to renew it, but you can keep it by answering 'No' Overwrite the file? Sarebbe meglio rinnovarlo, ma puoi decidere di tenerlo scegliendo 'No' Sovrascrivere il file? - - - - - If you choose to proceed, it will be overwritten Continue? Se scegli di procedere, verrà sovrascritto Continuare? - If you choose to proceed, the content will be overwritten, exception made for databases, which won't be affected Continue? -- 2.30.2 From 647fd33f0979568f18c09c6ce6d63c726afdd58e Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sat, 23 Sep 2023 19:31:49 +0200 Subject: [PATCH 04/14] Improvements and fixes Code improvements. Fixed issues with Windows paths. --- installer/mainwindow.cpp | 306 +++++++++++++++++++-------------------- installer/mainwindow.h | 16 +- 2 files changed, 161 insertions(+), 161 deletions(-) diff --git a/installer/mainwindow.cpp b/installer/mainwindow.cpp index ef2140d..7874413 100644 --- a/installer/mainwindow.cpp +++ b/installer/mainwindow.cpp @@ -231,7 +231,7 @@ void MainWindow::checkInstallProgress() void MainWindow::Install() { - bool ok = true; + bool ok{ true }; this->ui->progressBar_Install->setValue( 0 ); this->ui->label_Install_Info->setText( MainWindow::tr( "Checking the executable path ..." ) ); @@ -279,8 +279,8 @@ void MainWindow::Install() } } - #if !defined( Q_OS_MACOS ) - if ( ok ) { // mac .app contains it + #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + if ( ok ) { // OSX app bundle contains it, Windows copyed it already this->ui->progressBar_Install->setValue( 85 ); this->ui->label_Install_Info->setText( MainWindow::tr( "Copying the uninstaller ..." ) ); // move the uninstaller @@ -326,47 +326,30 @@ void MainWindow::Install() /////////////////// bool MainWindow::checkExecutablePath() { - bool ok = true; + bool ok{ true }; std::error_code err; if ( ! std::filesystem::exists( this->exec_path ) ) { - this->ui->progressBar_Install->setValue( 10 ); - // path does not exists - #if defined( Q_OS_WINDOWS ) - // must create the new folder - ok = std::filesystem::create_directory( this->exec_path, err ); - if ( !ok ) { - // failed to create - DialogMsg dialog = DialogMsg( - MainWindow::tr( "Installation failed" ), - QString("%1:\n%2").arg( - MainWindow::tr( "Failed to create the directory" ), - QString::fromStdString( this->exec_path.string() ) ), - QString::fromStdString( err.message() ), 2, nullptr ); - std::ignore = dialog.exec(); - } - #else - // unix-like. path is (supposedly) always present - ok = false; - DialogMsg dialog = DialogMsg( - MainWindow::tr( "Installation failed" ), - QString("%1:\n%2").arg( - MainWindow::tr( "The path does not exist" ), - QString::fromStdString( this->exec_path.string() ) ), - QString::fromStdString( err.message() ), 2, nullptr ); - std::ignore = dialog.exec(); - #endif + // base executable path does not exists + ok = false; + DialogMsg dialog( + MainWindow::tr( "Installation failed" ), + QString("%1:\n%2").arg( + MainWindow::tr( "The path does not exist" ), + QString::fromStdString( this->exec_path.string() ) ), + QString::fromStdString( err.message() ), 2, nullptr ); + std::ignore = dialog.exec(); } else { this->ui->progressBar_Install->setValue( 5 ); // path exists #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) // check if the executable already exists - const std::filesystem::path path = this->exec_path / "logdoctor"; + const std::filesystem::path path{ this->exec_path / "logdoctor" }; if ( std::filesystem::exists( path ) ) { // an entry already exists, ask to overwrite it { - DialogBool dialog = DialogBool( + DialogBool dialog( MainWindow::tr( "Conflict" ), QString("%1:\n%2\n\n%3").arg( (std::filesystem::is_regular_file( path )) @@ -384,7 +367,7 @@ bool MainWindow::checkExecutablePath() ok = ! std::filesystem::exists( path ); if ( !ok ) { // failed to remove - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to remove the entry" ), @@ -399,10 +382,10 @@ bool MainWindow::checkExecutablePath() if ( ! std::filesystem::is_directory( this->exec_path ) ) { // not a directory, ask to overwrite it { - DialogBool dialog = DialogBool( + DialogBool dialog( MainWindow::tr( "Conflict" ), QString("%1:\n%2\n\n%3").arg( - MainWindow::tr( "An entry with the same name already exists" ), + MainWindow::tr( "An entry with the same name already exists, but it's not a directory" ), QString::fromStdString( this->exec_path.string() ), MainWindow::tr( "If you choose to proceed, it will be overwritten\nContinue?" ) ), nullptr ); @@ -410,10 +393,11 @@ bool MainWindow::checkExecutablePath() } if ( ok ) { // agreed on overwriting the entry - ok = std::filesystem::remove( this->exec_path, err ); + std::ignore = std::filesystem::remove_all( this->exec_path, err ); + ok = ! std::filesystem::exists( this->exec_path ); if ( !ok ) { // failed to remove - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to remove the entry" ), @@ -426,7 +410,7 @@ bool MainWindow::checkExecutablePath() ok = std::filesystem::create_directory( this->exec_path, err ); if ( !ok ) { // failed to create - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to create the directory" ), @@ -440,41 +424,37 @@ bool MainWindow::checkExecutablePath() this->ui->progressBar_Install->setValue( 5 ); // installation altready exists, check the executable #if defined( Q_OS_WINDOWS ) - const std::vector names = {"LogDoctor.exe","uninstall.exe"}; + const std::filesystem::path path{ this->exec_path / "LogDoctor" }; #elif defined( Q_OS_MACOS ) - const std::vector names = {"LogDoctor.app"}; + const std::filesystem::path path{ this->exec_path / "LogDoctor.app" }; #endif - for ( const auto& name : names ) { - const std::filesystem::path path = this->exec_path / name; - if ( std::filesystem::exists( path ) ) { - // an entry already exists, ask to overwrite it - { - DialogBool dialog = DialogBool( - MainWindow::tr( "Conflict" ), - QString("%1:\n%2\n\n%3").arg( - (std::filesystem::is_regular_file( path )) - ? MainWindow::tr( "An executable already exists" ) - : MainWindow::tr( "An entry with the same name already exists" ), - QString::fromStdString( path.string() ), - MainWindow::tr( "If you choose to proceed, it will be overwritten\nContinue?" ) ), - nullptr ); - ok = dialog.exec(); - } - if ( ok ) { - // agreed on overwriting the entry - std::ignore = std::filesystem::remove_all( path, err ); - ok = ! std::filesystem::exists( path ); - if ( !ok ) { - // failed to remove - DialogMsg dialog = DialogMsg( - MainWindow::tr( "Installation failed" ), - QString("%1:\n%2").arg( - MainWindow::tr( "Failed to remove the entry" ), - QString::fromStdString( this->exec_path.string() ) ), - QString::fromStdString( err.message() ), 2, nullptr ); - std::ignore = dialog.exec(); - break; - } + if ( std::filesystem::exists( path ) ) { + // an entry already exists, ask to overwrite it + { + DialogBool dialog( + MainWindow::tr( "Conflict" ), + QString("%1:\n%2\n\n%3").arg( + (std::filesystem::is_regular_file( path )) + ? MainWindow::tr( "Installation path already exists" ) + : MainWindow::tr( "An entry with the same name already exists" ), + QString::fromStdString( path.string() ), + MainWindow::tr( "If you choose to proceed, it will be overwritten\nContinue?" ) ), + nullptr ); + ok = dialog.exec(); + } + if ( ok ) { + // agreed on overwriting the entry + std::ignore = std::filesystem::remove_all( path, err ); + ok = ! std::filesystem::exists( path ); + if ( !ok ) { + // failed to remove + DialogMsg dialog( + MainWindow::tr( "Installation failed" ), + QString("%1:\n%2").arg( + MainWindow::tr( "Failed to remove the entry" ), + QString::fromStdString( path.string() ) ), + QString::fromStdString( err.message() ), 2, nullptr ); + std::ignore = dialog.exec(); } } } @@ -487,7 +467,7 @@ bool MainWindow::checkExecutablePath() bool MainWindow::checkConfigsPath() { - bool ok = true; + bool ok{ true }; std::error_code err; if ( ! std::filesystem::exists( this->conf_path ) ) { @@ -496,7 +476,7 @@ bool MainWindow::checkConfigsPath() ok = std::filesystem::create_directory( this->conf_path, err ); if ( !ok ) { // failed to create - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to create the directory" ), @@ -510,7 +490,7 @@ bool MainWindow::checkConfigsPath() if ( !std::filesystem::is_directory( this->conf_path ) ) { // not a directory, ask to overwrite it { - DialogBool dialog = DialogBool( + DialogBool dialog( MainWindow::tr( "Conflict" ), QString("%1:\n%2\n\n%3").arg( MainWindow::tr( "An entry with the same name already exists" ), @@ -524,7 +504,7 @@ bool MainWindow::checkConfigsPath() ok = std::filesystem::remove( this->conf_path, err ); if ( !ok ) { // failed to remove - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to remove the entry" ), @@ -537,7 +517,7 @@ bool MainWindow::checkConfigsPath() ok = std::filesystem::create_directory( this->conf_path, err ); if ( !ok ) { // failed to create - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to create the directory" ), @@ -550,11 +530,11 @@ bool MainWindow::checkConfigsPath() } else { this->ui->progressBar_Install->setValue( 20 ); // is a directory: probably an installation already exists, check if a cofiguration file is present - const std::filesystem::path path = this->conf_path / "logdoctor.conf"; + const std::filesystem::path path{ this->conf_path / "logdoctor.conf" }; if ( std::filesystem::exists( path ) ) { // a configuration file already exists, ask to overwrite it or not { - DialogBool dialog = DialogBool( + DialogBool dialog( MainWindow::tr( "Conflict" ), QString("%1:\n%2\n\n%3").arg( (std::filesystem::is_regular_file( path )) @@ -563,10 +543,7 @@ bool MainWindow::checkConfigsPath() QString::fromStdString( path.string() ), MainWindow::tr( "It's suggested to renew it, but you can keep it by answering 'No'\nOverwrite the file?" ) ), nullptr ); - const bool choice = dialog.exec(); - if ( choice ) { - this->overwrite_conf_file = true; - } + this->overwrite_conf_file = dialog.exec(); } if ( this->overwrite_conf_file ) { this->ui->progressBar_Install->setValue( 25 ); @@ -575,7 +552,7 @@ bool MainWindow::checkConfigsPath() ok = ! std::filesystem::exists( path ); if ( !ok ) { // failed to remove - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to remove the entry" ), @@ -596,7 +573,7 @@ bool MainWindow::checkConfigsPath() bool MainWindow::checkAppdataPath() { - bool ok = true; + bool ok{ true }; std::error_code err; if ( !std::filesystem::exists( this->data_path ) ) { @@ -605,7 +582,7 @@ bool MainWindow::checkAppdataPath() ok = std::filesystem::create_directory( this->data_path, err ); if ( !ok ) { // failed to create - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to create the directory" ), @@ -619,7 +596,7 @@ bool MainWindow::checkAppdataPath() if ( !std::filesystem::is_directory( this->data_path ) ) { // not a directory { - DialogBool dialog = DialogBool( + DialogBool dialog( MainWindow::tr( "Conflict" ), QString("%1:\n%2\n\n%3").arg( MainWindow::tr( "An entry with the same name already exists" ), @@ -634,7 +611,7 @@ bool MainWindow::checkAppdataPath() ok = ! std::filesystem::exists( this->data_path ); if ( !ok ) { // failed to remove - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to remove the entry" ), @@ -647,7 +624,7 @@ bool MainWindow::checkAppdataPath() ok = std::filesystem::create_directory( this->data_path, err ); if ( !ok ) { // failed to create - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to create the directory" ), @@ -660,7 +637,7 @@ bool MainWindow::checkAppdataPath() } else { // is a directory: probably an installation already exists { - DialogBool dialog = DialogBool( + DialogBool dialog( MainWindow::tr( "Conflict" ), QString("%1:\n%2\n\n%3").arg( MainWindow::tr( "A directory already exists for the application data" ), @@ -673,10 +650,10 @@ bool MainWindow::checkAppdataPath() this->ui->progressBar_Install->setValue( 40 ); // agreed on overwriting content, remove it #if defined( Q_OS_MACOS ) - const std::vector paths = { + const std::vector paths{ this->data_path / "help" }; #else - const std::vector paths = { + const std::vector paths{ this->data_path / "help", this->data_path / "licenses" }; // mac .app already contains it #endif @@ -687,11 +664,11 @@ bool MainWindow::checkAppdataPath() ok = ! std::filesystem::exists( path ); if ( !ok ) { // failed to remove - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to remove the entry" ), - QString::fromStdString( this->data_path.string() ) ), + QString::fromStdString( path.string() ) ), QString::fromStdString( err.message() ), 2, nullptr ); std::ignore = dialog.exec(); break; @@ -707,35 +684,45 @@ bool MainWindow::checkAppdataPath() bool MainWindow::copyExecutable() { - bool ok = true; + bool ok{ true }; std::error_code err; #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) - const std::string exec_name = "logdoctor"; + const std::filesystem::path src_path{ "logdoctor" }; + const std::filesystem::path dst_path{ this->exec_path / "logdoctor" }; #elif defined( Q_OS_WINDOWS ) - const std::string exec_name = "LogDoctor.exe"; + const std::filesystem::path src_path{ std::filesystem::path{"../LogDoctor"}.make_preferred() }; + const std::filesystem::path dst_path{ this->exec_path / "LogDoctor" }; #elif defined( Q_OS_MACOS ) - const std::string exec_name = "LogDoctor.app"; + const std::filesystem::path src_path{ "LogDoctor.app" }; + const std::filesystem::path dst_path{ this->exec_path / "LogDoctor.app" }; #endif - const std::filesystem::path src_path = "installation_stuff/"+exec_name; - const std::filesystem::path dst_path = this->exec_path / exec_name; - - #if defined( Q_OS_MACOS ) + #if defined( Q_OS_MACOS ) || defined( Q_OS_WINDOWS ) std::filesystem::copy( src_path, dst_path, std::filesystem::copy_options::overwrite_existing | std::filesystem::copy_options::recursive, err ); - if ( err.value() != 0 ) { + if ( err ) { ok = false; } + #if defined( Q_OS_WINDOWS ) + else { + // remove the installer + std::error_code _; + const std::filesystem::path installer_path{ dst_path / "install.exe" }; + std::ignore = std::filesystem::remove( dst_path, _ ); // no need to abort the installation in case of failure + } + #endif #else ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); #endif if ( !ok ) { // failed to copy - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), - QString("%1:\n%2").arg( + QString("%1:\n%2\n\n%3:\n%4").arg( MainWindow::tr( "Failed to copy the resource" ), + QString::fromStdString( src_path.string() ), + MainWindow::tr( "To destination path" ), QString::fromStdString( dst_path.string() ) ), QString::fromStdString( err.message() ), 2, nullptr ); std::ignore = dialog.exec(); @@ -764,7 +751,7 @@ bool MainWindow::copyExecutable() } catch (...) { ok = false; // failed set permissions - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to assign permissions to the resource" ), @@ -779,19 +766,25 @@ bool MainWindow::copyExecutable() bool MainWindow::copyConfigfile() { - bool ok = true; + bool ok{ true }; std::error_code err; - const std::filesystem::path src_path = "installation_stuff/logdoctor.conf"; - const std::filesystem::path dst_path = this->conf_path / "logdoctor.conf"; + #if defined( Q_OS_WINDOWS ) + const std::filesystem::path src_path{ std::filesystem::path{"../logdoctor.conf"}.make_preferred() }; + #else + const std::filesystem::path src_path{ "logdoctor.conf" }; + #endif + const std::filesystem::path dst_path{ this->conf_path / "logdoctor.conf" }; ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); if ( !ok ) { // failed to move - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), - QString("%1:\n%2").arg( + QString("%1:\n%2\n\n%3:\n%4").arg( MainWindow::tr( "Failed to copy the resource" ), + QString::fromStdString( src_path.string() ), + MainWindow::tr( "To destination path" ), QString::fromStdString( dst_path.string() ) ), QString::fromStdString( err.message() ), 2, nullptr ); std::ignore = dialog.exec(); @@ -802,29 +795,35 @@ bool MainWindow::copyConfigfile() bool MainWindow::copyResources() { - bool ok = true; + bool ok{ true }; std::error_code err; #if defined( Q_OS_MACOS ) - const std::vector names = { + const std::vector names{ "help" }; #else - const std::vector names = { + const std::vector names{ "help", "licenses" }; // mac .app already contains it #endif for ( const auto& name : names ) { // remove the entries - const std::filesystem::path src_path = "installation_stuff/logdocdata/"+name; - const std::filesystem::path dst_path = this->data_path / name; + #if defined( Q_OS_WINDOWS ) + const std::filesystem::path src_path{ std::filesystem::path{"../logdocdata/"+name}.make_preferred() }; + #else + const std::filesystem::path src_path{ "logdocdata/"+name }; + #endif + const std::filesystem::path dst_path{ this->data_path / name }; std::filesystem::copy( src_path, dst_path, std::filesystem::copy_options::overwrite_existing | std::filesystem::copy_options::recursive, err ); if ( err.value() != 0 ) { // failed to move ok = false; - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), - QString("%1:\n%2").arg( + QString("%1:\n%2\n\n%3:\n%4").arg( MainWindow::tr( "Failed to copy the resource" ), + QString::fromStdString( src_path.string() ), + MainWindow::tr( "To destination path" ), QString::fromStdString( dst_path.string() ) ), QString::fromStdString( err.message() ), 2, nullptr ); std::ignore = dialog.exec(); @@ -835,29 +834,24 @@ bool MainWindow::copyResources() } +#if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) bool MainWindow::copyUninstaller() { - bool ok = true; + bool ok{ true }; std::error_code err; - #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) - const std::filesystem::path src_path = "installation_stuff/uninstall"; - const std::filesystem::path dst_path = this->data_path / "uninstall"; - #elif defined( Q_OS_WINDOWS ) - const std::filesystem::path src_path = "installation_stuff/uninstall.exe"; - const std::filesystem::path dst_path = this->exec_path / "uninstall.exe"; - #else - // macOS should not run this method - throw( "LogDoctor: copyUninstaller(): Unexpected OS" ); - #endif + const std::filesystem::path src_path{ "uninstall" }; + const std::filesystem::path dst_path{ this->data_path / "uninstall" }; ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); if ( !ok ) { // failed to copy - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), - QString("%1:\n%2").arg( + QString("%1:\n%2\n\n%3:\n%4").arg( MainWindow::tr( "Failed to copy the resource" ), + QString::fromStdString( src_path.string() ), + MainWindow::tr( "To destination path" ), QString::fromStdString( dst_path.string() ) ), QString::fromStdString( err.message() ), 2, nullptr ); std::ignore = dialog.exec(); @@ -865,23 +859,19 @@ bool MainWindow::copyUninstaller() } else { // set permissions try { + // 7 5 5 std::filesystem::permissions( dst_path, std::filesystem::perms::owner_all, std::filesystem::perm_options::add ); std::filesystem::permissions( dst_path, std::filesystem::perms::group_all, std::filesystem::perm_options::remove ); std::filesystem::permissions( dst_path, std::filesystem::perms::group_read, std::filesystem::perm_options::add ); std::filesystem::permissions( dst_path, std::filesystem::perms::others_all, std::filesystem::perm_options::remove ); - #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) - // 7 5 5 - std::filesystem::permissions( dst_path, std::filesystem::perms::group_exec, std::filesystem::perm_options::add ); - std::filesystem::permissions( dst_path, std::filesystem::perms::others_read, std::filesystem::perm_options::add ); - std::filesystem::permissions( dst_path, std::filesystem::perms::others_exec, std::filesystem::perm_options::add ); - #elif defined( Q_OS_WINDOWS ) - // rw r - - #endif + std::filesystem::permissions( dst_path, std::filesystem::perms::group_exec, std::filesystem::perm_options::add ); + std::filesystem::permissions( dst_path, std::filesystem::perms::others_read, std::filesystem::perm_options::add ); + std::filesystem::permissions( dst_path, std::filesystem::perms::others_exec, std::filesystem::perm_options::add ); } catch (...) { ok = false; // failed set permissions - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to assign permissions to the resource" ), @@ -892,54 +882,60 @@ bool MainWindow::copyUninstaller() } return ok; } +#endif +#if !defined( Q_OS_MACOS ) bool MainWindow::copyIcon() { - bool ok = true; + bool ok{ true }; std::error_code err; - const std::filesystem::path src_path = "installation_stuff/LogDoctor.svg"; #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) - const std::filesystem::path dst_path = "/usr/share/LogDoctor/LogDoctor.svg"; + const std::filesystem::path src_path{ "LogDoctor.svg" }; + const std::filesystem::path dst_path{ "/usr/share/LogDoctor/LogDoctor.svg" }; #elif defined( Q_OS_WINDOWS ) - const std::filesystem::path dst_path = this->exec_path / "LogDoctor.svg"; + const std::filesystem::path src_path{ std::filesystem::path{"../LogDoctor.svg"}.make_preferred() }; + const std::filesystem::path dst_path{ this->exec_path / "LogDoctor" / "LogDoctor.svg" }; #else - // macOS should not run this method throw( "LogDoctor: copyIcon(): Unexpected OS" ); #endif ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); if ( !ok ) { // failed - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Installation failed" ), - QString("%1:\n%2").arg( + QString("%1:\n%2\n\n%3:\n%4").arg( MainWindow::tr( "Failed to copy the resource" ), + QString::fromStdString( src_path.string() ), + MainWindow::tr( "To destination path" ), QString::fromStdString( dst_path.string() ) ), QString::fromStdString( err.message() ), 2, nullptr ); std::ignore = dialog.exec(); } return ok; } +#endif +#if !defined( Q_OS_MACOS ) bool MainWindow::makeMenuEntry() { - bool ok = true; + bool ok{ true }; std::error_code err; #if defined( Q_OS_LINUX ) - const std::filesystem::path src_path = "installation_stuff/LogDoctor.desktop"; - const std::filesystem::path dst_path = "/usr/share/applications/LogDoctor.desktop"; + const std::filesystem::path src_path{ "LogDoctor.desktop" }; + const std::filesystem::path dst_path{ "/usr/share/applications/LogDoctor.desktop" }; ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); #elif defined( Q_OS_BSD4 ) - const std::filesystem::path src_path = "installation_stuff/LogDoctor.desktop"; - const std::filesystem::path dst_path = "/usr/local/share/applications/LogDoctor.desktop"; + const std::filesystem::path src_path{ "LogDoctor.desktop" }; + const std::filesystem::path dst_path{ "/usr/local/share/applications/LogDoctor.desktop" }; ok = std::filesystem::copy_file( src_path, dst_path, std::filesystem::copy_options::overwrite_existing, err ); #elif defined( Q_OS_WINDOWS ) - const std::filesystem::path src_path = this->exec_path / "LogDoctor.exe"; - const std::filesystem::path dst_path = this->home_path.substr(0,2) + "/ProgramData/Microsoft/Windows/Start Menu/Programs/LogDoctor.exe"; + const std::filesystem::path src_path{ this->exec_path / "LogDoctor" / "LogDoctor.exe" }; + const std::filesystem::path dst_path{ std::filesystem::path{this->home_path.substr(0,2) + "/ProgramData/Microsoft/Windows/Start Menu/Programs/LogDoctor.exe"}.make_preferred() }; if ( std::filesystem::exists( dst_path ) ) { // an old entry already exists, remove it std::ignore = std::filesystem::remove( dst_path, err ); @@ -953,13 +949,12 @@ bool MainWindow::makeMenuEntry() } } #else - // macOS should not run this method throw( "LogDoctor: makeMenuEntry(): Unexpected OS" ); #endif if ( !ok ) { // failed - DialogMsg dialog = DialogMsg( + DialogMsg dialog( MainWindow::tr( "Error" ), QString("%1:\n%2").arg( MainWindow::tr( "Failed to create the menu entry" ), @@ -969,3 +964,4 @@ bool MainWindow::makeMenuEntry() } return ok; } +#endif diff --git a/installer/mainwindow.h b/installer/mainwindow.h index 8018315..66c6265 100644 --- a/installer/mainwindow.h +++ b/installer/mainwindow.h @@ -64,9 +64,9 @@ private: const std::filesystem::path conf_path{ home_path + "/Lybrary/Preferences/LogDoctor" }; const std::filesystem::path data_path{ home_path + "/Lybrary/Application Support/LogDoctor" }; #elif defined( Q_OS_WINDOWS ) - const std::filesystem::path exec_path{ home_path.substr(0,2) + "/Program Files/LogDoctor" }; - const std::filesystem::path conf_path{ home_path + "/AppData/Local/LogDoctor" }; - const std::filesystem::path data_path{ home_path + "/AppData/Local/LogDoctor" }; + const std::filesystem::path exec_path{ std::filesystem::path{home_path.substr(0,2) + "/Program Files"}.make_preferred() }; + const std::filesystem::path conf_path{ std::filesystem::path{home_path + "/AppData/Local/LogDoctor"}.make_preferred() }; + const std::filesystem::path data_path{ std::filesystem::path{home_path + "/AppData/Local/LogDoctor"}.make_preferred() }; #elif defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) const std::filesystem::path exec_path{ "/usr/bin" }; const std::filesystem::path conf_path{ home_path + "/.config/LogDoctor" }; @@ -105,9 +105,13 @@ private: bool copyExecutable(); bool copyConfigfile(); bool copyResources(); - bool copyUninstaller(); - bool copyIcon(); - bool makeMenuEntry(); + #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + bool copyUninstaller(); + #endif + #if !defined( Q_OS_MACOS ) + bool copyIcon(); + bool makeMenuEntry(); + #endif }; #endif // MAINWINDOW_H -- 2.30.2 From 0ff55668011f9a82eea3f17c63274b1e1bddfbef Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sat, 23 Sep 2023 19:44:57 +0200 Subject: [PATCH 05/14] Updated translation files --- installer/translations/LogDoctorInstaller_en.ts | 12 ++++++++++++ installer/translations/LogDoctorInstaller_es.ts | 12 ++++++++++++ installer/translations/LogDoctorInstaller_fr.ts | 12 ++++++++++++ installer/translations/LogDoctorInstaller_it.ts | 14 +++++++++++++- 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/installer/translations/LogDoctorInstaller_en.ts b/installer/translations/LogDoctorInstaller_en.ts index b3bc399..4b7a8b0 100644 --- a/installer/translations/LogDoctorInstaller_en.ts +++ b/installer/translations/LogDoctorInstaller_en.ts @@ -237,5 +237,17 @@ Continue? exception made for databases, which won't be affected Continue? + + An entry with the same name already exists, but it's not a directory + An entry with the same name already exists, but it's not a directory + + + Installation path already exists + Installation path already exists + + + To destination path + To destination path + diff --git a/installer/translations/LogDoctorInstaller_es.ts b/installer/translations/LogDoctorInstaller_es.ts index e7fcd49..3978946 100644 --- a/installer/translations/LogDoctorInstaller_es.ts +++ b/installer/translations/LogDoctorInstaller_es.ts @@ -237,5 +237,17 @@ Continue? excepción hecha para databases, que no se verá afectada ¿Continuar? + + An entry with the same name already exists, but it's not a directory + Ya existe una entrada con el mismo nombre, pero no es un directorio + + + Installation path already exists + La ruta de instalación ya existe + + + To destination path + En el camino de destinación + diff --git a/installer/translations/LogDoctorInstaller_fr.ts b/installer/translations/LogDoctorInstaller_fr.ts index 22c45ce..3c1d521 100644 --- a/installer/translations/LogDoctorInstaller_fr.ts +++ b/installer/translations/LogDoctorInstaller_fr.ts @@ -237,5 +237,17 @@ Continue? exception faite pour les databases, qui ne seront pas affectées Continuer? + + An entry with the same name already exists, but it's not a directory + Une entrée avec le même nom existe déjà, mais ce n'est pas un répertoire + + + Installation path already exists + Le chemin d'installation existe déjà + + + To destination path + Vers le chemin de destination + diff --git a/installer/translations/LogDoctorInstaller_it.ts b/installer/translations/LogDoctorInstaller_it.ts index 40b5c73..6136417 100644 --- a/installer/translations/LogDoctorInstaller_it.ts +++ b/installer/translations/LogDoctorInstaller_it.ts @@ -211,7 +211,7 @@ A directory already exists for the application data - Esiste già una directory per le risorse dell'applicazione + Esiste già una cartella per le risorse dell'applicazione Failed to create the directory @@ -237,5 +237,17 @@ Continue? ad eccezione dei database, che non verranno toccati Continuare? + + An entry with the same name already exists, but it's not a directory + Esiste già un oggetto con lo stesso nome, ma non è una cartella + + + Installation path already exists + Il percorso di installazione esiste già + + + To destination path + Nella destinazione + -- 2.30.2 From 817f4df9ba1b92cbd34c805187c1b444ef743716 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sat, 23 Sep 2023 19:45:27 +0200 Subject: [PATCH 06/14] Updated translation resources --- .../translations/LogDoctorInstaller_en.qm | Bin 7074 -> 7548 bytes .../translations/LogDoctorInstaller_es.qm | Bin 7274 -> 7762 bytes .../translations/LogDoctorInstaller_fr.qm | Bin 7588 -> 8098 bytes .../translations/LogDoctorInstaller_it.qm | Bin 7502 -> 7976 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/installer/resources/translations/LogDoctorInstaller_en.qm b/installer/resources/translations/LogDoctorInstaller_en.qm index 94ca95ae54194f7c784d86d2eb5e513237165b4c..fe5e946ccfb9f935b2b02721331abf43bd9ee310 100644 GIT binary patch delta 659 zcmYjOTSyd982)BwX6LfIvlpfHk~(6!)tVSevOSoE6veg@sYyMJY3-2BYCAqylK4xj9G@+hM$};WOrykDv&-u>zF6aFHrOUgnXESel za&p?2!H0hUsUs*_hy$7Xad78Nz&?iX?K(j2!?EEuz>|xp%oF|{(`<8Qfw283Lvzy!LDL}*~(tjk^no-&T|(?FUX~MsoKjq|40eY?y2Sm ziizO=!WZ;~h%mv2dJ9Q7z?a?aC!+}8I=czjaED)vi~{MG?1zFJ8SE7*XTyN6R=9s= z4}fOj=io025)vI-D46TK7@%bkvoHPWc*ydx|teUH+`K~bPpY&mT>pnV?rgp=(YP}Um1`#ty7;mk{_5UhUv6qwn{|-RMepb zCRLs00OGVV5L-tytJIanR9I1Vo2NjnYcW;b48&C`{d&x0-!fyheM=uY(#)u}ozF}D^{xsP`KTgo74>K!CzCu4tTA;$4Z@q&cTti0 e0y~YAs+d~e5I1$>Keb#T)q0e%F`1Teh4}|N0jSjg delta 453 zcmexkwa9#e9OI6O^78e946Ht17#M_|7z{oaGcZWDGI*IyWnf^v!r(JAiGhK014Gn` z8U_Y_GlmQewON1$hO_%W^I>2Rc*njv*O7sNp^*Li(jP#J%Q?6; zfDYlAz~Q&)D^TBBj)BGcaVh z_HnILR0Yz~TnF4<039I1b#6OQobw)cjUF>Fqz-XkdkJ&^#|s|$e?`C$IL1>Y&YHrS1sZ`0|W0$K1=Pxiol>r<6jmG40`7M{QKGcfj+sze|NSW1A};CCeZo& eH-BL~#khGTOE}-=dg1@XG$Ta5M z1+42V)t*%#z25RTeG!QJWO=zF141_I?kohD9qdId3a~TmB6ptnL@v=uw{?p zPL}I0q=NMmd~T123Z{9_^*n$-#g`8BQKKZjbv_G7>EKt&M}f3T>k&6cLY8b5^Ijk^ z%XX(}FMy!!```}}q6qfQBup+7${(x%Ngsvk&Yytet8nv7?ERTA93XySTo}odBY;>g z{2JT_a4lki$N~vtVt4%%;nU*Ku~#%vt@xzzp*K->On)*%o5oZz0b0W zvIkyhlpmrB1DZLP;L4}4bq)04Ec`@gz$ehUVWp!U(!+)p2xx{ssH@GI(O`D5nbBxM zvQSlw{UkyqK>@O-iKB_?|H`T(R7K3j_+qF=8GbB7|HqwJ6;$hdVZ*Qg$Ih@x(aE$v F<_}wOugd@c delta 450 zcmca)^U7j^9OI6O@^bYoo(!x$Ul@uUB8Jl@azORAjM-}I7#LV}nZhjpF)&C@XWAwGl7WHeH`B4Nd<+ci zHq6>R#taOMrp&F0n;96GUNgUBsRNp)z#=RNq*?E?h_5kWsAmw6Vp(hq)F2+tYB@!Z zfq|ur)o#fm1_t3Ztd-AH7#PHq*?hHGfCe(N`#Dfq@~P{rl1%K#T1; zxHW(d;SJ;P+w>KvuaYCI=O@r1EF9C)K=PkBR^|ZBWxv9)Mh|EYM=HnfrG^X)%sre2 zoXqt=14B6b($4`Uo^vh>JqgrU$+@rbFav|YWzHkYi-8WP=jzaY&cGlf!PWg47&6?` zxK=8v0%>Nh18y%E7$jbBo!br+=Q_q+qsI)?SHykoCC~w!+j!*v6#+xw0#B7dACT|D z^St*z(40_SwTSx+41Do?mfA`{i-RfMXKv5>Na`ELOYd{5*4^ z`~hGNn40`sK=HikNl^-rdrhx4WI%|ro`EWWsb~9xNr3&srnrkVuZ43u2rXuA+iW%Z z;8@|ttEi!1o%fFVso@jvzu^OTgRh+!BOw>xy}A?FKF4na7J#A=^9c_}0{bnEs|`S| z%`y|M2avG*ocu*bS_JEEGA4f!0*^L;yp+&1@EgeL5=PEay+jtKBQ#%Rgjt{5N6CP& zIk^|$?ueBl3pnqJgXfk2Nf4(_zoy0?;?qknhN>rYZBv>q z-9>mvdVb_988AspkJCJF?e)>ToP*X6DKa2^v$?n8fN9azlRZfLkZtW+&0iWclU3gQ z8OS!veh&$;*X1{L^mIA5>{BP{OL)%y%+d(h{q~j7TA(nc(lzcSmziaT88UXT0WZ8z z5JeCw5|o9|Mo~irVFEhk9aKwKI-wcEvYR<<^ssvhy-I7RuBduNLeXNn5>&!!ye*{1 z;@yTr%uOz^Z|%%cqoW|tc<3xLe0*t+a!gC;!AK;it1(UK2k&iL ziW&w6flUkaF)*-3Glg0HV_=Xv&$LVWB?AL*C)2U7d<+ci zRm|Ew#taOMj?Arzn;96GIhkLw)B(-QU=bDs(rm&k;%iJ8>KO!Hu`D(QYLKX8wVa~I zz`(MA)o#fm1_qHOtd-AH7#PG&*?hHGfCjp<`#Dfq|iz{rl1%K#NN` zxHW(d;r+njx9KZTUp_}z&rb#ho)(U2X+U{t4UUyLKyx|xIM(O^?ctco@q4Ku&_QcB z4LF(Wfd;B^_NAX=VBi$xTo!r~Xb>~!zQ)5041!BJk0>t&I-sAcL;E>U-3PAj&%lu3 z;ow@SsLH^=?ay_bK}1|+m3-jGCvdO g{DYgnFy3L@e3<1d|7LN~a*oMs<)k)?$n`M-00nn*FaQ7m diff --git a/installer/resources/translations/LogDoctorInstaller_it.qm b/installer/resources/translations/LogDoctorInstaller_it.qm index ca0c43c1e8d8e67f8e0580ec51fcd0b9ab2c8518..662f5cf5579fa0046db5b69a97ae5449ecb9abab 100644 GIT binary patch delta 685 zcmYk3T}TvB6vzLwGqXE0yUwb+X1cmNVp+7?rf9+Xuo;w4*{W2Qy^Xo)(mE^d2o>Vi zLy%~eObI0feJF|&(FRrzeNY%FNFUHsWl*dd^$;c&fprXmxE$`i=bYdF{yBHLd^mXC z&AjOIxD&h|eARbgRSk+4;y~UKc5S%`Sn5%AsR6LQ#G&C1AR~rmiKl!QrpnyZpJ0v_ z-2}|JrnG7*VNa_`fPKZzbDgBOn{#B)Zl2(>$I6gE z#vpgSlz^P8yl)^tz$72I;0Jh>58k*2WPRq3r`7urDp=Q(G5NI+y1hvJxKP*g6G%HC^dF&m-W6daO8UYxVazWl0I@;% zHCO_05wTcgN${B1+cZu2FXGVt=LEhNADnsuWPTH$7G5VKQ_>mlEa0q^x)*3twvWm0WUqoHp!D)X>^&5_MyG>CETR_p{1JY1@?CXK_Is~0_1Nr-ZF8f)u=If?1!PE z4LZVz(o&NrO+JR{q>{_n#BR=o4+>hSM}dYIg@QSXc4)>qIiJ~XXzYe`pVH8-D-nHN zT+w2>q8g87cXEuqXJb>T zNSUp!O3_@rvHZSFKw7*L z45V2CYP<|oeMdv77w|RX@ZL$FB8B+#ftFcE9DbSEQuu=z9|EoA^GXiQ_VkHi2>DQiIJqVy%`!)TW2HV`&LqS|+ ze(c#A`Ht|`u|I&>&!;YJ-hbh9UBuN^`Fxn>@L~RUx)D%r=ncA(CZMU0U(N%%OP@LU zj*J`n%WH3d$`SqTt}IZ~CPwW7z56U~mZ%w%iMiU{fYByiA6f;re-!xz(v6TY7*@y^ zGCmb4fPfiXPf`OP%#>%G_$jk+YXk85UG=BF0hZ>D+94Vwk6JS)sCwmx^-49rPcaPFd=elFnJx=WoYOTtEksxQO%ULpSXPNb8|<@~&0w#6+EQ#;-fe@^UWA Qo?E$M)p4H7`0q*o0cFO3X8-^I -- 2.30.2 From 775cd48d3a48d43d97765746216716f5bf6cc1ad Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sat, 23 Sep 2023 23:02:37 +0200 Subject: [PATCH 07/14] Code improvements and fixes --- installer/mainwindow.cpp | 61 ++++++++++++++++++---------------------- installer/mainwindow.h | 11 ++++---- 2 files changed, 33 insertions(+), 39 deletions(-) diff --git a/installer/mainwindow.cpp b/installer/mainwindow.cpp index 7874413..ca6c052 100644 --- a/installer/mainwindow.cpp +++ b/installer/mainwindow.cpp @@ -66,13 +66,6 @@ MainWindow::MainWindow(QWidget *parent) } -MainWindow::~MainWindow() -{ - delete this->ui; - delete this->waiter_timer; - delete this->installer_timer; -} - void MainWindow::on_button_Close_clicked() { this->close(); @@ -208,14 +201,12 @@ void MainWindow::on_checkBox_MenuEntry_toggled(bool checked) void MainWindow::startInstalling() { this->installing = true; - delete this->waiter_timer; - this->waiter_timer = new QTimer(this); - connect(this->waiter_timer, SIGNAL(timeout()), this, SLOT(checkInstallProgress())); + this->waiter_timer.reset( new QTimer(this) ); + connect(this->waiter_timer.get(), &QTimer::timeout, this, &MainWindow::checkInstallProgress); // worker - delete this->installer_timer; - this->installer_timer = new QTimer(this); + this->installer_timer.reset( new QTimer(this) ); this->installer_timer->setSingleShot( true ); - connect(this->installer_timer, SIGNAL(timeout()), this, SLOT(Install())); + connect(this->installer_timer.get(), &QTimer::timeout, this, &MainWindow::Install); // run this->waiter_timer->start(250); this->installer_timer->start(250); @@ -474,7 +465,10 @@ bool MainWindow::checkConfigsPath() this->ui->progressBar_Install->setValue( 25 ); // path does not exists, create it ok = std::filesystem::create_directory( this->conf_path, err ); - if ( !ok ) { + if ( ok ) { + // will copy the new file + this->overwrite_conf_file = true; + } else { // failed to create DialogMsg dialog( MainWindow::tr( "Installation failed" ), @@ -636,7 +630,16 @@ bool MainWindow::checkAppdataPath() } } else { // is a directory: probably an installation already exists - { + #if defined( Q_OS_MACOS ) + const std::vector paths{ + this->data_path / "help" }; + #else + const std::vector paths{ + this->data_path / "help", + this->data_path / "licenses" }; // OSX app bundle already contains it + #endif + // check if the data path contains any of the entries + if ( std::any_of( paths.cbegin(), paths.cend(), [](const auto& p){return std::filesystem::exists(p);} ) ) { DialogBool dialog( MainWindow::tr( "Conflict" ), QString("%1:\n%2\n\n%3").arg( @@ -649,17 +652,9 @@ bool MainWindow::checkAppdataPath() if ( ok ) { this->ui->progressBar_Install->setValue( 40 ); // agreed on overwriting content, remove it - #if defined( Q_OS_MACOS ) - const std::vector paths{ - this->data_path / "help" }; - #else - const std::vector paths{ - this->data_path / "help", - this->data_path / "licenses" }; // mac .app already contains it - #endif for ( const auto& path : paths ) { // remove the entries - if ( !std::filesystem::exists( path ) ) { + if ( std::filesystem::exists( path ) ) { std::ignore = std::filesystem::remove_all( path, err ); ok = ! std::filesystem::exists( path ); if ( !ok ) { @@ -691,10 +686,10 @@ bool MainWindow::copyExecutable() const std::filesystem::path src_path{ "logdoctor" }; const std::filesystem::path dst_path{ this->exec_path / "logdoctor" }; #elif defined( Q_OS_WINDOWS ) - const std::filesystem::path src_path{ std::filesystem::path{"../LogDoctor"}.make_preferred() }; + const std::filesystem::path src_path{ std::filesystem::canonical("../LogDoctor").make_preferred() }; const std::filesystem::path dst_path{ this->exec_path / "LogDoctor" }; #elif defined( Q_OS_MACOS ) - const std::filesystem::path src_path{ "LogDoctor.app" }; + const std::filesystem::path src_path{ std::filesystem::canonical("./LogDoctor.app") }; const std::filesystem::path dst_path{ this->exec_path / "LogDoctor.app" }; #endif @@ -708,7 +703,7 @@ bool MainWindow::copyExecutable() // remove the installer std::error_code _; const std::filesystem::path installer_path{ dst_path / "install.exe" }; - std::ignore = std::filesystem::remove( dst_path, _ ); // no need to abort the installation in case of failure + std::ignore = std::filesystem::remove( installer_path, _ ); // no need to abort the installation in case of failure } #endif #else @@ -770,9 +765,9 @@ bool MainWindow::copyConfigfile() std::error_code err; #if defined( Q_OS_WINDOWS ) - const std::filesystem::path src_path{ std::filesystem::path{"../logdoctor.conf"}.make_preferred() }; + const std::filesystem::path src_path{ std::filesystem::canonical("../logdoctor.conf").make_preferred() }; #else - const std::filesystem::path src_path{ "logdoctor.conf" }; + const std::filesystem::path src_path{ std::filesystem::canonical("./logdoctor.conf") }; #endif const std::filesystem::path dst_path{ this->conf_path / "logdoctor.conf" }; @@ -809,9 +804,9 @@ bool MainWindow::copyResources() for ( const auto& name : names ) { // remove the entries #if defined( Q_OS_WINDOWS ) - const std::filesystem::path src_path{ std::filesystem::path{"../logdocdata/"+name}.make_preferred() }; + const std::filesystem::path src_path{ std::filesystem::canonical("../logdocdata").make_preferred() / name }; #else - const std::filesystem::path src_path{ "logdocdata/"+name }; + const std::filesystem::path src_path{ std::filesystem::canonical("logdocdata") / name }; #endif const std::filesystem::path dst_path{ this->data_path / name }; std::filesystem::copy( src_path, dst_path, std::filesystem::copy_options::overwrite_existing | std::filesystem::copy_options::recursive, err ); @@ -892,10 +887,10 @@ bool MainWindow::copyIcon() std::error_code err; #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) - const std::filesystem::path src_path{ "LogDoctor.svg" }; + const std::filesystem::path src_path{ std::filesystem::canonical("LogDoctor.svg") }; const std::filesystem::path dst_path{ "/usr/share/LogDoctor/LogDoctor.svg" }; #elif defined( Q_OS_WINDOWS ) - const std::filesystem::path src_path{ std::filesystem::path{"../LogDoctor.svg"}.make_preferred() }; + const std::filesystem::path src_path{ std::filesystem::canonical("../LogDoctor.svg").make_preferred() }; const std::filesystem::path dst_path{ this->exec_path / "LogDoctor" / "LogDoctor.svg" }; #else throw( "LogDoctor: copyIcon(): Unexpected OS" ); diff --git a/installer/mainwindow.h b/installer/mainwindow.h index 66c6265..f5feee7 100644 --- a/installer/mainwindow.h +++ b/installer/mainwindow.h @@ -21,7 +21,6 @@ class MainWindow : public QMainWindow public: explicit MainWindow(QWidget *parent = nullptr); - ~MainWindow(); private slots: @@ -53,7 +52,7 @@ private slots: void on_button_Close_clicked(); private: - Ui::MainWindow *ui; + QSharedPointer ui; // operating system const std::string cleanPath( const QString& path ); @@ -91,12 +90,12 @@ private: // work related int step; - bool make_menu_entry = true; + bool make_menu_entry{ true }; // install - QTimer* waiter_timer = new QTimer(); - QTimer* installer_timer = new QTimer(); + QScopedPointer waiter_timer; + QScopedPointer installer_timer; bool installing; - bool overwrite_conf_file = false; + bool overwrite_conf_file{ false }; void startInstalling(); bool checkExecutablePath(); -- 2.30.2 From 68546f73ab1fa9d0ba42542b49c2e7c00736adbf Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 24 Sep 2023 15:07:24 +0200 Subject: [PATCH 08/14] Updated CMakeLists.txt Added compiler options and flags --- installer/CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/installer/CMakeLists.txt b/installer/CMakeLists.txt index 8235f9f..f6ba1c9 100644 --- a/installer/CMakeLists.txt +++ b/installer/CMakeLists.txt @@ -11,6 +11,16 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +if(MSVC) + add_compile_options(/W2) + set(CMAKE_CXX_FLAGS_MINSIZEREL "/Os") + set(CMAKE_CXX_FLAGS_RELEASE "/O2") +else() + add_compile_options(-Wall -Wextra -Wpedantic) + set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os") + set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") +endif() + find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools) @@ -70,7 +80,8 @@ if(WIN32) endif() target_link_libraries(LogDoctorInstaller PRIVATE - Qt${QT_VERSION_MAJOR}::Widgets) + Qt${QT_VERSION_MAJOR}::Widgets +) if(WIN32) set_target_properties(LogDoctorInstaller PROPERTIES -- 2.30.2 From 33055ee899cfd286a6ddcf4f7c6606a7ce21ef55 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 24 Sep 2023 15:11:11 +0200 Subject: [PATCH 09/14] Fixes Fixed preprocessor directives for OSX. Fixed conf file not writable after installation on Unix. --- installer/mainwindow.cpp | 59 ++++++++++++++++++++++++++++------------ installer/mainwindow.h | 8 ++++-- 2 files changed, 46 insertions(+), 21 deletions(-) diff --git a/installer/mainwindow.cpp b/installer/mainwindow.cpp index ca6c052..227b3f0 100644 --- a/installer/mainwindow.cpp +++ b/installer/mainwindow.cpp @@ -7,12 +7,22 @@ #include +#if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 )// || defined( Q_OS_MACOS ) + #include + #include +#endif + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { - ui->setupUi(this); + this->ui->setupUi(this); + #if defined( Q_OS_MACOS ) + this->ui->checkBox_MenuEntry->setChecked(false); + this->ui->checkBox_MenuEntry->setCheckable(false); + this->ui->checkBox_MenuEntry->setEnabled(false); + #endif // load the font const QString font_family = QFontDatabase::applicationFontFamilies( @@ -270,7 +280,7 @@ void MainWindow::Install() } } - #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + #if !defined( Q_OS_MACOS ) && (defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 )) if ( ok ) { // OSX app bundle contains it, Windows copyed it already this->ui->progressBar_Install->setValue( 85 ); this->ui->label_Install_Info->setText( MainWindow::tr( "Copying the uninstaller ..." ) ); @@ -334,7 +344,7 @@ bool MainWindow::checkExecutablePath() } else { this->ui->progressBar_Install->setValue( 5 ); // path exists - #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + #if !defined( Q_OS_MACOS ) && (defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 )) // check if the executable already exists const std::filesystem::path path{ this->exec_path / "logdoctor" }; if ( std::filesystem::exists( path ) ) { @@ -682,15 +692,15 @@ bool MainWindow::copyExecutable() bool ok{ true }; std::error_code err; - #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) - const std::filesystem::path src_path{ "logdoctor" }; - const std::filesystem::path dst_path{ this->exec_path / "logdoctor" }; + #if defined( Q_OS_MACOS ) + const std::filesystem::path src_path{ std::filesystem::canonical("./LogDoctor.app") }; + const std::filesystem::path dst_path{ this->exec_path / "LogDoctor.app" }; #elif defined( Q_OS_WINDOWS ) const std::filesystem::path src_path{ std::filesystem::canonical("../LogDoctor").make_preferred() }; const std::filesystem::path dst_path{ this->exec_path / "LogDoctor" }; - #elif defined( Q_OS_MACOS ) - const std::filesystem::path src_path{ std::filesystem::canonical("./LogDoctor.app") }; - const std::filesystem::path dst_path{ this->exec_path / "LogDoctor.app" }; + #elif defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + const std::filesystem::path src_path{ "logdoctor" }; + const std::filesystem::path dst_path{ this->exec_path / "logdoctor" }; #endif #if defined( Q_OS_MACOS ) || defined( Q_OS_WINDOWS ) @@ -730,15 +740,15 @@ bool MainWindow::copyExecutable() std::filesystem::permissions( dst_path, std::filesystem::perms::group_all, std::filesystem::perm_options::remove ); std::filesystem::permissions( dst_path, std::filesystem::perms::group_read, std::filesystem::perm_options::add ); std::filesystem::permissions( dst_path, std::filesystem::perms::others_all, std::filesystem::perm_options::remove ); - #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + #if defined( Q_OS_MACOS ) + // 7 5 4 + std::filesystem::permissions( dst_path, std::filesystem::perms::group_exec, std::filesystem::perm_options::add ); + std::filesystem::permissions( dst_path, std::filesystem::perms::others_read, std::filesystem::perm_options::add ); + #elif defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) // 7 5 5 std::filesystem::permissions( dst_path, std::filesystem::perms::group_exec, std::filesystem::perm_options::add ); std::filesystem::permissions( dst_path, std::filesystem::perms::others_read, std::filesystem::perm_options::add ); std::filesystem::permissions( dst_path, std::filesystem::perms::others_exec, std::filesystem::perm_options::add ); - #elif defined( Q_OS_MACOS ) - // 7 5 4 - std::filesystem::permissions( dst_path, std::filesystem::perms::group_exec, std::filesystem::perm_options::add ); - std::filesystem::permissions( dst_path, std::filesystem::perms::others_read, std::filesystem::perm_options::add ); #elif defined( Q_OS_WINDOWS ) // rw r - #endif @@ -784,6 +794,21 @@ bool MainWindow::copyConfigfile() QString::fromStdString( err.message() ), 2, nullptr ); std::ignore = dialog.exec(); } + #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 )// || defined( Q_OS_MACOS ) + else { + const passwd* p{ getpwnam(this->user_name.c_str()) }; + if ( chown( dst_path.c_str(), p->pw_uid, p->pw_gid ) != 0 ) { + ok = false; + DialogMsg dialog( + MainWindow::tr( "Installation failed" ), + QString("%1:\n%2").arg( + MainWindow::tr( "Failed to change the owner of the resource" ), + QString::fromStdString( dst_path.string() ) ), + QString::fromStdString( err.message() ), 2, nullptr ); + std::ignore = dialog.exec(); + } + } + #endif return ok; } @@ -829,6 +854,7 @@ bool MainWindow::copyResources() } +#if !defined( Q_OS_MACOS ) #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) bool MainWindow::copyUninstaller() { @@ -877,10 +903,9 @@ bool MainWindow::copyUninstaller() } return ok; } -#endif +#endif // defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) -#if !defined( Q_OS_MACOS ) bool MainWindow::copyIcon() { bool ok{ true }; @@ -911,10 +936,8 @@ bool MainWindow::copyIcon() } return ok; } -#endif -#if !defined( Q_OS_MACOS ) bool MainWindow::makeMenuEntry() { bool ok{ true }; diff --git a/installer/mainwindow.h b/installer/mainwindow.h index f5feee7..b0d2642 100644 --- a/installer/mainwindow.h +++ b/installer/mainwindow.h @@ -62,6 +62,7 @@ private: const std::filesystem::path exec_path{ "/Applications" }; const std::filesystem::path conf_path{ home_path + "/Lybrary/Preferences/LogDoctor" }; const std::filesystem::path data_path{ home_path + "/Lybrary/Application Support/LogDoctor" }; + const std::string user_name{ home_path.substr(7ul) }; #elif defined( Q_OS_WINDOWS ) const std::filesystem::path exec_path{ std::filesystem::path{home_path.substr(0,2) + "/Program Files"}.make_preferred() }; const std::filesystem::path conf_path{ std::filesystem::path{home_path + "/AppData/Local/LogDoctor"}.make_preferred() }; @@ -70,6 +71,7 @@ private: const std::filesystem::path exec_path{ "/usr/bin" }; const std::filesystem::path conf_path{ home_path + "/.config/LogDoctor" }; const std::filesystem::path data_path{ "/usr/share/LogDoctor" }; + const std::string user_name{ home_path.substr(6ul) }; #else #error "System not supported" #endif @@ -104,10 +106,10 @@ private: bool copyExecutable(); bool copyConfigfile(); bool copyResources(); - #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) - bool copyUninstaller(); - #endif #if !defined( Q_OS_MACOS ) + #if defined( Q_OS_LINUX ) || defined( Q_OS_BSD4 ) + bool copyUninstaller(); + #endif bool copyIcon(); bool makeMenuEntry(); #endif -- 2.30.2 From fc997a33ba7018c8462c05731239628ddc6b82a9 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 24 Sep 2023 16:24:31 +0200 Subject: [PATCH 10/14] Version update Version 2.00 --- installer/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/CMakeLists.txt b/installer/CMakeLists.txt index f6ba1c9..53fffa3 100644 --- a/installer/CMakeLists.txt +++ b/installer/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.5) -project(LogDoctorInstaller VERSION 1.01 LANGUAGES CXX) +project(LogDoctorInstaller VERSION 2.00 LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) -- 2.30.2 From 931211527fdd4c3e67edd78aa20c62c9aa11b653 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 24 Sep 2023 16:27:27 +0200 Subject: [PATCH 11/14] Upgrade to C++20 --- installer/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installer/CMakeLists.txt b/installer/CMakeLists.txt index 53fffa3..5a961dc 100644 --- a/installer/CMakeLists.txt +++ b/installer/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) if(MSVC) -- 2.30.2 From 3e2155b691223a64ea2fb4f6ebfa3203e4d8f470 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 24 Sep 2023 17:05:19 +0200 Subject: [PATCH 12/14] Upgrade to Qt6 --- installer/CMakeLists.txt | 54 ++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/installer/CMakeLists.txt b/installer/CMakeLists.txt index 5a961dc..9c6f536 100644 --- a/installer/CMakeLists.txt +++ b/installer/CMakeLists.txt @@ -21,9 +21,15 @@ else() set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") endif() -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools) +find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets LinguistTools) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools) +if(${QT_VERSION_MAJOR} LESS 6) + message("Error: Qt6 or greater required") + return() +endif() + + set(TS_FILES translations/LogDoctorInstaller_en.ts translations/LogDoctorInstaller_es.ts @@ -48,46 +54,28 @@ set(PROJECT_SOURCES ${TS_FILES} ) -if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) - qt_add_executable(LogDoctorInstaller - MANUAL_FINALIZATION - ${PROJECT_SOURCES} - ) -# Define target properties for Android with Qt 6 as: -# set_property(TARGET LogDoctorInstaller APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR -# ${CMAKE_CURRENT_SOURCE_DIR}/android) -# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation - - qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) -else() - if(ANDROID) - add_library(LogDoctorInstaller SHARED - ${PROJECT_SOURCES} - ) -# Define properties for Android with Qt 5 after find_package() calls as: -# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") - else() - add_executable(LogDoctorInstaller - ${PROJECT_SOURCES} - ) - endif() - - qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) -endif() +qt_add_executable(LogDoctorInstaller + MANUAL_FINALIZATION + ${PROJECT_SOURCES} +) +qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES}) if(WIN32) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bstatic -lgcc -lstdc++ -lwinpthread") + target_link_libraries(LogDoctorInstaller PRIVATE + -static Qt${QT_VERSION_MAJOR}::Widgets + ) +else() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pthread") + target_link_libraries(LogDoctorInstaller PRIVATE + Qt${QT_VERSION_MAJOR}::Widgets + ) endif() -target_link_libraries(LogDoctorInstaller PRIVATE - Qt${QT_VERSION_MAJOR}::Widgets -) if(WIN32) set_target_properties(LogDoctorInstaller PROPERTIES WIN32_EXECUTABLE TRUE) endif() -if(QT_VERSION_MAJOR EQUAL 6) - qt_finalize_executable(LogDoctorInstaller) -endif() +qt_finalize_executable(LogDoctorInstaller) -- 2.30.2 From 7634023135ace9e47852218180d0fd84d77fa17c Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 24 Sep 2023 17:12:17 +0200 Subject: [PATCH 13/14] Updated translation files --- installer/translations/LogDoctorInstaller_en.ts | 4 ++++ installer/translations/LogDoctorInstaller_es.ts | 4 ++++ installer/translations/LogDoctorInstaller_fr.ts | 4 ++++ installer/translations/LogDoctorInstaller_it.ts | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/installer/translations/LogDoctorInstaller_en.ts b/installer/translations/LogDoctorInstaller_en.ts index 4b7a8b0..484cf38 100644 --- a/installer/translations/LogDoctorInstaller_en.ts +++ b/installer/translations/LogDoctorInstaller_en.ts @@ -249,5 +249,9 @@ Continue? To destination path To destination path + + Failed to change the owner of the resource + Failed to change the owner of the resource + diff --git a/installer/translations/LogDoctorInstaller_es.ts b/installer/translations/LogDoctorInstaller_es.ts index 3978946..c557626 100644 --- a/installer/translations/LogDoctorInstaller_es.ts +++ b/installer/translations/LogDoctorInstaller_es.ts @@ -249,5 +249,9 @@ excepción hecha para databases, que no se verá afectada To destination path En el camino de destinación + + Failed to change the owner of the resource + Error al cambiar el propietario del recurso + diff --git a/installer/translations/LogDoctorInstaller_fr.ts b/installer/translations/LogDoctorInstaller_fr.ts index 3c1d521..6bbbed8 100644 --- a/installer/translations/LogDoctorInstaller_fr.ts +++ b/installer/translations/LogDoctorInstaller_fr.ts @@ -249,5 +249,9 @@ Continuer? To destination path Vers le chemin de destination + + Failed to change the owner of the resource + Échec du changement du propriétaire de la ressource + diff --git a/installer/translations/LogDoctorInstaller_it.ts b/installer/translations/LogDoctorInstaller_it.ts index 6136417..3a1e304 100644 --- a/installer/translations/LogDoctorInstaller_it.ts +++ b/installer/translations/LogDoctorInstaller_it.ts @@ -249,5 +249,9 @@ Continuare? To destination path Nella destinazione + + Failed to change the owner of the resource + Errore nel modificare il proprietario della risorsa + -- 2.30.2 From 31ea80ce5c0f8ced8bc062440c1f3fcafd6b4c71 Mon Sep 17 00:00:00 2001 From: Valentino Orlandi Date: Sun, 24 Sep 2023 17:12:32 +0200 Subject: [PATCH 14/14] Updated translation resources --- .../translations/LogDoctorInstaller_en.qm | Bin 7548 -> 7713 bytes .../translations/LogDoctorInstaller_es.qm | Bin 7762 -> 7929 bytes .../translations/LogDoctorInstaller_fr.qm | Bin 8098 -> 8281 bytes .../translations/LogDoctorInstaller_it.qm | Bin 7976 -> 8159 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/installer/resources/translations/LogDoctorInstaller_en.qm b/installer/resources/translations/LogDoctorInstaller_en.qm index fe5e946ccfb9f935b2b02721331abf43bd9ee310..d9ae02e521a9acce614b43c13c2c66e9714192c9 100644 GIT binary patch delta 442 zcmexkwa{jQ9OI3N@@ib7o(u+`iy0WCpG@=@*WAaD!NtnJ!1k8mw22%8gJ=n3w%R%d z2G$)+VV3`Ziu9OvNxx)Z;9WhjU%&nn%VJ|b1_p@+R-M_F3=E9NSS_dM0TrvW+AUec zz##IPwepz?1B18~>sP-W3=C4rY`)qo3=Hf}?EcSu7#M`Uvail{WME(@WdFYO2T=YR z2e$^$GCm0ozfE6(`nPa|_55UD;MvA8Ee$9y-N~^s2WUPAJI5M5puLlA83m$*rgQeC zpJQO)i#?xXs8?4 zN<~$mI2+diw--RmtGUi?2a0o@fx6W60$HJff<}3>gfG z40#Oc45 delta 355 zcmZ2z^T%p}9OH$F@@iZnYZweZ7c($OyHE5N*HmQ4;9_N9V0+7O+C+|lLF77Pw%R%d z2G$)+VV3_G7^EgL?UH`Uz`)Blv0uMFlx49o9|MEsP-W3=EQOY`)qo3=Hf}?EcSu7#M^i*jMK|GB7X{vVULt18BG< z2e$^$GTv$qzfE6(`o%fIdVVr6@JMn@O9RQj;aHgiG@pZ=V~rlr-pRI%0zrbmIQ!Di zF)(m)a4riy2~<3Zb6?|O1_r@)&Lhf;fsSM3>d<};v}_Mo_vfh$4BRWZRw}9jX*R9{ zZZCk2y2o{HJ5ZeKBzKJ-GXsOb+R4iq<;;bC@~TDLXJFu)!e^-sG>$ot@07hU&{z)s qWx>GEVp+w%pWPqm*5mwlXWKC_NSw|D24UmoKa6X+H@orO<_7?KHeOKx diff --git a/installer/resources/translations/LogDoctorInstaller_es.qm b/installer/resources/translations/LogDoctorInstaller_es.qm index bb0ee7065e2c800e1fe6f951634ead3fbe31f7c7..2feb90a1117419eeef4126c67ab8035884ce6f6c 100644 GIT binary patch delta 469 zcmca)^V4>M9OI3N@@iaS!VCtViy0VXc1`pb(-O>K$lzjSU|{cNIBg=wz#!(rn60*s zfq_koDa`U8P!$`~F6oyH41CQK`}OM=u`D*`V_=YsW7U~$$-uyPfz@(~9s>hwJgeQ3 zMGOq0n^`NLsW31|Xt93v+rhvf^`6aFn+0h28+QL^J`4=PhuK%>Ix;XYEpOwz6A$zePd!(M_HzaX5qYle&r^Yh z%5kk!RApe`e#3RZ?FG>CaISOPf#Tfjxoh;885jhAO`gvvXD$-Ms}^yefr0-ypQSd? zSmtcLQ})I{bP1p|YPk9OH$F@@ib7B@70iiy0VXq$m1|X$hQV$lzjSU|{cNIBg=wz#zJmF4GGolH5sVfd% zeiJv2hXAc2 zE5M~RyFTRxggxdSa{ sy@r`o>{?x`KQdqh^h8YW5BsAbLr;VaJ@zGT6#hnccK*1|*!rhj+wB*nh8sg*Q7f|2Ay2Iia_dA z^miQ!4Tljq@z_0-T>k<4+u~2?Q#G(sd2aK<^i{_s4MgrIDJ_3vE~<``qMA9VQ;5v zvQYti?fk`w5Wr>m(5MFRIv@V<9;kZF-^-l`s!#FxwiTe}w>uJa5qnOE=57KNjxalL z9e^$TnK~l&H)6>JQd1v^ZHsxDH^r`J$AID%$4#pHBjQYg_{A^coTk8O=1%lf)Jrd7 z8-TPgWo~_?-sjTl!%sl@JL&VeNz%SAZS~Sco*nsdaF;am^3#Jcpmao@Ia^D3SYB`4 zBkddV#xmg^uH=DM40souw_Mvwm7C_TN;VJT+MXQ+gw?7O^DLU z-_@TJVLGwNqCK~k4!KU9OH$F^6H!c3;ll`GRO>6Z))e0dZ5_38zevMe^{V_=Y6$f`5jl7WHo6szSFJq8BWL{_^c zix?P0U$Is`Q(<6`$YlNMw}XK}+JVhin+0h4Gj{)HJ`4=PPuN%IIx;XY;|g!TMnVBihsn3e{Vmzl@0G6!fr$8nA|dVCC%Z5RcEgey4v z($6t4aK7PO7J3q>_8#ZH#={H@LLWJgC@%)ueVVI7`#A%Hh#Ob;=cx<~Jde3nDyjl$ zJFWw6FMxJV<2tt;B+kfPqsI)?$2fU8qnx=&C$Cz>eFg^pXMC30K;xLx`A*pz1Eo{= qmjwfZi{%vmes+JLydwYI*>(&JQr(#h46?eL|1du1**uBgR{#J*uwf|x -- 2.30.2