Skip to content

Commit

Permalink
Allow disable the auto updater
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoquang2708 committed Nov 6, 2024
1 parent 204bba9 commit 265f1ce
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
arch: amd64

- name: Configure CMake
run: cmake --fresh -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_QT_GUI=ON -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
run: cmake --fresh -G Ninja -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_C_COMPILER=clang-cl -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel
Expand Down Expand Up @@ -265,7 +265,7 @@ jobs:
variant: sccache

- name: Configure CMake
run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DENABLE_QT_GUI=ON -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_OSX_ARCHITECTURES=x86_64 -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel $(sysctl -n hw.ncpu)
Expand Down Expand Up @@ -368,7 +368,7 @@ jobs:
key: ${{ env.cache-name }}-${{ hashFiles('**/CMakeLists.txt', 'cmake/**') }}

- name: Configure CMake
run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_QT_GUI=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
run: cmake --fresh -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_QT_GUI=ON -DENABLE_UPDATER=ON -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache

- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --parallel3
Expand Down
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -732,15 +732,19 @@ set(EMULATOR src/emulator.cpp
if(ENABLE_QT_GUI)
qt_add_resources(RESOURCE_FILES src/shadps4.qrc)

if (ENABLE_UPDATER)
set(UPDATER src/qt_gui/check_update.cpp
src/qt_gui/check_update.h
)
endif()

set(QT_GUI src/qt_gui/about_dialog.cpp
src/qt_gui/about_dialog.h
src/qt_gui/about_dialog.ui
src/qt_gui/background_music_player.cpp
src/qt_gui/background_music_player.h
src/qt_gui/cheats_patches.cpp
src/qt_gui/cheats_patches.h
src/qt_gui/check_update.cpp
src/qt_gui/check_update.h
src/qt_gui/main_window_ui.h
src/qt_gui/main_window.cpp
src/qt_gui/main_window.h
Expand Down Expand Up @@ -771,6 +775,7 @@ set(QT_GUI src/qt_gui/about_dialog.cpp
${EMULATOR}
${RESOURCE_FILES}
${TRANSLATIONS}
${UPDATER}
)
endif()

Expand Down Expand Up @@ -843,8 +848,11 @@ else()
endif()

if (ENABLE_QT_GUI)
target_link_libraries(shadps4 PRIVATE Qt6::Widgets Qt6::Concurrent Qt6::Network Qt6::Multimedia)
add_definitions(-DENABLE_QT_GUI)
target_link_libraries(shadps4 PRIVATE Qt6::Widgets Qt6::Concurrent Qt6::Network Qt6::Multimedia)
add_definitions(-DENABLE_QT_GUI)
if (ENABLE_UPDATER)
add_definitions(-DENABLE_UPDATER)
endif()
endif()

if (WIN32)
Expand Down
10 changes: 10 additions & 0 deletions src/qt_gui/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

#include "about_dialog.h"
#include "cheats_patches.h"
#ifdef ENABLE_UPDATER
#include "check_update.h"
#endif
#include "common/io_file.h"
#include "common/path_util.h"
#include "common/scm_rev.h"
Expand Down Expand Up @@ -59,8 +61,10 @@ bool MainWindow::Init() {
this->show();
// load game list
LoadGameLists();
#ifdef ENABLE_UPDATER
// Check for update
CheckUpdateMain(true);
#endif

auto end = std::chrono::steady_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start);
Expand Down Expand Up @@ -183,6 +187,7 @@ void MainWindow::LoadGameLists() {
}
}

#ifdef ENABLE_UPDATER
void MainWindow::CheckUpdateMain(bool checkSave) {
if (checkSave) {
if (!Config::autoUpdate()) {
Expand All @@ -192,6 +197,7 @@ void MainWindow::CheckUpdateMain(bool checkSave) {
auto checkUpdate = new CheckUpdate(false);
checkUpdate->exec();
}
#endif

void MainWindow::GetPhysicalDevices() {
Vulkan::Instance instance(false, false);
Expand Down Expand Up @@ -254,10 +260,12 @@ void MainWindow::CreateConnects() {
settingsDialog->exec();
});

#ifdef ENABLE_UPDATER
connect(ui->updaterAct, &QAction::triggered, this, [this]() {
auto checkUpdate = new CheckUpdate(true);
checkUpdate->exec();
});
#endif

connect(ui->aboutAct, &QAction::triggered, this, [this]() {
auto aboutDialog = new AboutDialog(this);
Expand Down Expand Up @@ -933,7 +941,9 @@ void MainWindow::SetUiIcons(bool isWhite) {
ui->bootInstallPkgAct->setIcon(RecolorIcon(ui->bootInstallPkgAct->icon(), isWhite));
ui->bootGameAct->setIcon(RecolorIcon(ui->bootGameAct->icon(), isWhite));
ui->exitAct->setIcon(RecolorIcon(ui->exitAct->icon(), isWhite));
#ifdef ENABLE_UPDATER
ui->updaterAct->setIcon(RecolorIcon(ui->updaterAct->icon(), isWhite));
#endif
ui->downloadCheatsPatchesAct->setIcon(
RecolorIcon(ui->downloadCheatsPatchesAct->icon(), isWhite));
ui->dumpGameListAct->setIcon(RecolorIcon(ui->dumpGameListAct->icon(), isWhite));
Expand Down
2 changes: 2 additions & 0 deletions src/qt_gui/main_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ private Q_SLOTS:
void CreateDockWindows();
void GetPhysicalDevices();
void LoadGameLists();
#ifdef ENABLE_UPDATER
void CheckUpdateMain(bool checkSave);
#endif
void CreateConnects();
void SetLastUsedTheme();
void SetLastIconSizeBullet();
Expand Down
8 changes: 8 additions & 0 deletions src/qt_gui/main_window_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class Ui_MainWindow {
QAction* downloadCheatsPatchesAct;
QAction* dumpGameListAct;
QAction* pkgViewerAct;
#ifdef ENABLE_UPDATER
QAction* updaterAct;
#endif
QAction* aboutAct;
QAction* configureAct;
QAction* setThemeDark;
Expand Down Expand Up @@ -130,9 +132,11 @@ class Ui_MainWindow {
pkgViewerAct = new QAction(MainWindow);
pkgViewerAct->setObjectName("pkgViewer");
pkgViewerAct->setIcon(QIcon(":images/file_icon.png"));
#ifdef ENABLE_UPDATER
updaterAct = new QAction(MainWindow);
updaterAct->setObjectName("updaterAct");
updaterAct->setIcon(QIcon(":images/update_icon.png"));
#endif
aboutAct = new QAction(MainWindow);
aboutAct->setObjectName("aboutAct");
aboutAct->setIcon(QIcon(":images/about_icon.png"));
Expand Down Expand Up @@ -291,7 +295,9 @@ class Ui_MainWindow {
menuUtils->addAction(downloadCheatsPatchesAct);
menuUtils->addAction(dumpGameListAct);
menuUtils->addAction(pkgViewerAct);
#ifdef ENABLE_UPDATER
menuHelp->addAction(updaterAct);
#endif
menuHelp->addAction(aboutAct);

retranslateUi(MainWindow);
Expand All @@ -306,8 +312,10 @@ class Ui_MainWindow {
bootInstallPkgAct->setText(
QCoreApplication::translate("MainWindow", "Install Packages (PKG)", nullptr));
bootGameAct->setText(QCoreApplication::translate("MainWindow", "Boot Game", nullptr));
#ifdef ENABLE_UPDATER
updaterAct->setText(
QCoreApplication::translate("MainWindow", "Check for Updates", nullptr));
#endif
aboutAct->setText(QCoreApplication::translate("MainWindow", "About shadPS4", nullptr));
configureAct->setText(QCoreApplication::translate("MainWindow", "Configure...", nullptr));
#if QT_CONFIG(tooltip)
Expand Down
9 changes: 9 additions & 0 deletions src/qt_gui/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#include <QHoverEvent>

#include <common/version.h>
#ifdef ENABLE_UPDATER
#include "check_update.h"
#endif
#include "common/logging/backend.h"
#include "common/logging/filter.h"
#include "main_window.h"
Expand Down Expand Up @@ -143,6 +145,7 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
connect(ui->logFilterLineEdit, &QLineEdit::textChanged, this,
[](const QString& text) { Config::setLogFilter(text.toStdString()); });

#ifdef ENABLE_UPDATER
connect(ui->updateCheckBox, &QCheckBox::stateChanged, this,
[](int state) { Config::setAutoUpdate(state == Qt::Checked); });

Expand All @@ -153,6 +156,12 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices, QWidge
auto checkUpdate = new CheckUpdate(true);
checkUpdate->exec();
});
#else
// FIXME Can we do better than this?
ui->updateCheckBox->setEnabled(false);
ui->updateComboBox->setEnabled(false);
ui->checkUpdateButton->setEnabled(false);
#endif

connect(ui->playBGMCheckBox, &QCheckBox::stateChanged, this, [](int val) {
Config::setPlayBGM(val);
Expand Down

0 comments on commit 265f1ce

Please sign in to comment.