// SPDX-License-Identifier: MIT #pragma once #include "ui_queue.hpp" #include "openpu/api_client.hpp" #include "openpu/app_update.hpp" #include "openpu/job.hpp" #include "openpu/storage.hpp" #include "openpu/usb.hpp" #include #include #include #include namespace openpu::gtk { class MainWindow : public Gtk::ApplicationWindow { public: MainWindow(); ~MainWindow() override; MainWindow(const MainWindow&) = delete; MainWindow& operator=(const MainWindow&) = delete; private: // pages void buildVehiclesPage(); void buildAddPage(); void buildUpdatesPage(); void buildDownloadPage(); void buildUsbPage(); void buildWritePage(); void buildDonePage(); void show(const char* page); // vehicles void refreshVehicles(); std::optional selectedVehicle() const; void onAddVehicle(); void onRemoveVehicle(); void onCheckUpdates(); // updates / download void showUpdates(const AvailableUpdates& updates); void onChooseFolder(); void onStartDownload(); void startDownload(const DownloadPlan& plan); void onDownloadProgress(const JobProgress& p); void onDownloaded(const DownloadedFiles& files); // usb void enterUsbPage(); void refreshDrives(); void onPrepareUsb(); void startWrite(const UsbDrive& drive); void onWriteProgress(const UsbProgress& p); void onWritten(); // helpers template void runAsync(F&& work); void joinWorker(); void showError(const Glib::ustring& title, const Glib::ustring& detail); void showAbout(); void showPreferences(); void checkAppUpdate(bool manual); void offerAppUpdate(const AppRelease& release); void saveVehicles(); void updateDownloadDirLabel(); std::string language() const; UiQueue ui_; std::unique_ptr transport_; std::unique_ptr api_; std::unique_ptr usb_; VehicleStore store_; Settings settings_; std::filesystem::path settingsFile_; std::thread worker_; std::thread updateThread_; // OpenPU new-version check, independent of the main flow bool updateCheckRunning_ = false; CancelToken cancel_; // flow state std::optional current_; AvailableUpdates updates_; DownloadedFiles files_; std::vector drives_; std::uint64_t payload_ = 0; // widgets Gtk::HeaderBar header_; Gtk::Button back_; Gtk::MenuButton menu_; Gtk::Label* prefsDirLabel_ = nullptr; // download folder shown in the open preferences window Gtk::Stack stack_; Gtk::Box vehiclesPage_{Gtk::Orientation::VERTICAL, 12}; Gtk::ListBox vehicleList_; Gtk::Label vehiclesEmpty_; Gtk::Button addButton_, removeButton_, checkButton_; Gtk::Box addPage_{Gtk::Orientation::VERTICAL, 12}; Gtk::Entry vinEntry_, nameEntry_; Gtk::Label addStatus_; Gtk::Spinner addSpinner_; Gtk::Button addConfirm_; Gtk::Box updatesPage_{Gtk::Orientation::VERTICAL, 12}; Gtk::Label updatesTitle_, updatesStatus_; Gtk::Spinner updatesSpinner_; Gtk::CheckButton firmwareCheck_, mapCheck_; Gtk::Label downloadDirLabel_; Gtk::Button chooseDir_, downloadButton_, guideButton_; Gtk::Box downloadPage_{Gtk::Orientation::VERTICAL, 12}; Gtk::Label downloadTitle_; Gtk::Label licenseLabel_, firmwareLabel_, mapLabel_; Gtk::ProgressBar firmwareBar_, mapBar_; Gtk::Label etaLabel_; Gtk::Button cancelDownload_; Gtk::Box usbPage_{Gtk::Orientation::VERTICAL, 12}; Gtk::Label usbInfo_; Gtk::DropDown driveDrop_; Glib::RefPtr driveModel_; Gtk::Button refreshDrives_, prepareButton_; Gtk::Label usbStatus_; Gtk::Box writePage_{Gtk::Orientation::VERTICAL, 12}; Gtk::Label writeStep_, writeDetail_; Gtk::ProgressBar writeBar_; Gtk::Button cancelWrite_; Gtk::Box donePage_{Gtk::Orientation::VERTICAL, 12}; Gtk::Label doneText_; Gtk::Button doneGuide_, doneButton_; }; } // namespace openpu::gtk