diff --git a/.clang-format-ignore b/.clang-format-ignore new file mode 100644 index 0000000..1e9ddbe --- /dev/null +++ b/.clang-format-ignore @@ -0,0 +1 @@ +src/third-party/* diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..63eba56 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,60 @@ +name: Main +on: + push: + branches-ignore: + - 'releases/**' + paths-ignore: + - '**.md' + - '.github/workflows/release.yml' + - '.gitignore' + - 'crowdin.yml' + - 'data/translations/**' + pull_request: + paths-ignore: + - '**.md' + - '.github/workflows/release.yml' + - '.gitignore' + - 'crowdin.yml' + - 'data/translations/**' +jobs: + format: + name: Format + runs-on: ubuntu-20.04 + steps: + - name: Clone repo + uses: actions/checkout@v2 + + - name: Check formatting + uses: DoozyX/clang-format-lint-action@v0.12 + with: + clangFormatVersion: 12 + + build: + name: Build + runs-on: ubuntu-20.04 + steps: + - name: Clone repo + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Install apt packages + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install extra-cmake-modules libqt5x11extras5-dev qttools5-dev libkf5notifications-dev libkf5iconthemes-dev ninja-build + + # See https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4766#note_1091927 + - name: Downgrade CMake + if: runner.os == 'Windows' + uses: lukka/get-cmake@v3.21.2 + + - name: Build without Plasma feature + run: | + cmake -B build -G Ninja -D CMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" + cmake --build build --parallel 2 + + - name: Build with Plasma feature + run: | + cmake -B build -G Ninja -D WITH_PLASMA=ON -D CMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" + cmake --build build --parallel 2 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..efc4758 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,25 @@ +name: Release +on: + release: + types: [created] +jobs: + pack: + name: Pack source tarball + runs-on: ubuntu-latest + steps: + - name: Clone repo + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Create source tarball + run: | + SOURCE_NAME=$(awk -F/ '{print $NF}' <<<"${{ github.repository }}")-$(awk -F/ '{print $NF}' <<<"${{ github.ref }}") + git ls-files --recurse-submodules | \ + tar --exclude-vcs --transform "s|^|$SOURCE_NAME/|S" -ca -T - -f ../$SOURCE_NAME-source.tar.gz + + - name: Upload source tarball + uses: AButler/upload-release-assets@v2.0 + with: + files: '../*.tar.gz' + repo-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f489d87 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "data/icons/third-party/circle-flags"] + path = data/icons/third-party/circle-flags + url = https://github.com/HatScripts/circle-flags.git +[submodule "data/icons/third-party/masalla-icon-theme"] + path = data/icons/third-party/masalla-icon-theme + url = https://github.com/masalla-art/masalla-icon-theme +[submodule "src/third-party/singleapplication"] + path = src/third-party/singleapplication + url = https://github.com/itay-grudev/SingleApplication diff --git a/CMakeLists.txt b/CMakeLists.txt index 288ce10..d08170b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.7.0) project(optimus-manager-qt - VERSION 1.6.5 + VERSION 1.6.6 LANGUAGES CXX DESCRIPTION "An interface for Optimus Manager that allows to switch GPUs on Optimus laptops." ) @@ -29,10 +29,12 @@ if(WITH_PLASMA) find_package(KF5 COMPONENTS Notifications IconThemes REQUIRED) endif() -include(ExternalLibraries) include(ECMInstallIcons) include(GNUInstallDirs) +set(QAPPLICATION_CLASS QApplication) +add_subdirectory(src/third-party/singleapplication) + qt5_add_translation(QM_FILES data/translations/${PROJECT_NAME}_de_DE.ts data/translations/${PROJECT_NAME}_es_ES.ts @@ -49,13 +51,11 @@ qt5_add_translation(QM_FILES ) configure_file(src/cmake.h.in cmake.h) -configure_file(data/icons/flags.qrc ${CircleFlags_SOURCE_DIR}/flags/flags.qrc COPYONLY) -configure_file(data/icons/masalla.qrc ${Masalla_SOURCE_DIR}/masalla/masalla.qrc COPYONLY) add_executable(${PROJECT_NAME} - ${CircleFlags_SOURCE_DIR}/flags/flags.qrc - ${Masalla_SOURCE_DIR}/masalla/masalla.qrc ${QM_FILES} + data/icons/flags.qrc + data/icons/masalla.qrc src/appsettings.cpp src/daemonclient.cpp src/main.cpp diff --git a/cmake/ExternalLibraries.cmake b/cmake/ExternalLibraries.cmake deleted file mode 100644 index a78ddf5..0000000 --- a/cmake/ExternalLibraries.cmake +++ /dev/null @@ -1,21 +0,0 @@ -include(FetchContent) - -set(QAPPLICATION_CLASS QApplication) -FetchContent_Declare(SingleApplication - GIT_REPOSITORY https://github.com/itay-grudev/SingleApplication - GIT_TAG v3.1.5 -) - -FetchContent_Declare(CircleFlags - GIT_REPOSITORY https://github.com/HatScripts/circle-flags - GIT_TAG v2.0.0 -) - -FetchContent_Declare(Masalla - GIT_REPOSITORY https://github.com/masalla-art/masalla-icon-theme - GIT_TAG d3d3e90b6f36d3641e24e39f283a672ad5462a50 -) - -FetchContent_MakeAvailable(SingleApplication CircleFlags Masalla) -FetchContent_GetProperties(CircleFlags SOURCE_DIR CircleFlags_SOURCE_DIR) -FetchContent_GetProperties(Masalla SOURCE_DIR Masalla_SOURCE_DIR) diff --git a/data/icons/flags.qrc b/data/icons/flags.qrc index 1e4cf03..7cbee52 100644 --- a/data/icons/flags.qrc +++ b/data/icons/flags.qrc @@ -1,17 +1,17 @@ - br.svg - cn.svg - de.svg - es.svg - fi.svg - hu.svg - jp.svg - nl.svg - ro.svg - ru.svg - tr.svg - ua.svg - us.svg + third-party/circle-flags/flags/br.svg + third-party/circle-flags/flags/cn.svg + third-party/circle-flags/flags/de.svg + third-party/circle-flags/flags/es.svg + third-party/circle-flags/flags/fi.svg + third-party/circle-flags/flags/hu.svg + third-party/circle-flags/flags/jp.svg + third-party/circle-flags/flags/nl.svg + third-party/circle-flags/flags/ro.svg + third-party/circle-flags/flags/ru.svg + third-party/circle-flags/flags/tr.svg + third-party/circle-flags/flags/ua.svg + third-party/circle-flags/flags/us.svg diff --git a/data/icons/masalla.qrc b/data/icons/masalla.qrc index 3169f7a..05fd0e4 100644 --- a/data/icons/masalla.qrc +++ b/data/icons/masalla.qrc @@ -1,15 +1,15 @@ - apps/16x16/preferences-system-power-management.svg - apps/16x16/qt.svg - apps/16x16/utilities-terminal.svg - places/16x16/folder.svg - apps/48x48/amd.svg - apps/48x48/intel.svg - apps/48x48/nvidia.svg - apps/48x48/preferences-system-power-management.svg - apps/48x48/preferences-system.svg - mimetypes/48x48/text-x-generic.svg - status/48x48/dialog-information.png + third-party/masalla-icon-theme/masalla/apps/16x16/preferences-system-power-management.svg + third-party/masalla-icon-theme/masalla/apps/16x16/qt.svg + third-party/masalla-icon-theme/masalla/apps/16x16/utilities-terminal.svg + third-party/masalla-icon-theme/masalla/places/16x16/folder.svg + third-party/masalla-icon-theme/masalla/apps/48x48/amd.svg + third-party/masalla-icon-theme/masalla/apps/48x48/intel.svg + third-party/masalla-icon-theme/masalla/apps/48x48/nvidia.svg + third-party/masalla-icon-theme/masalla/apps/48x48/preferences-system-power-management.svg + third-party/masalla-icon-theme/masalla/apps/48x48/preferences-system.svg + third-party/masalla-icon-theme/masalla/mimetypes/48x48/text-x-generic.svg + third-party/masalla-icon-theme/masalla/status/48x48/dialog-information.png diff --git a/data/icons/third-party/circle-flags b/data/icons/third-party/circle-flags new file mode 160000 index 0000000..2225d10 --- /dev/null +++ b/data/icons/third-party/circle-flags @@ -0,0 +1 @@ +Subproject commit 2225d1005a295649b5ddcc5c6fff209891c0bafb diff --git a/data/icons/third-party/masalla-icon-theme b/data/icons/third-party/masalla-icon-theme new file mode 160000 index 0000000..d3d3e90 --- /dev/null +++ b/data/icons/third-party/masalla-icon-theme @@ -0,0 +1 @@ +Subproject commit d3d3e90b6f36d3641e24e39f283a672ad5462a50 diff --git a/src/optimusmanager.cpp b/src/optimusmanager.cpp index 03726d9..508d425 100644 --- a/src/optimusmanager.cpp +++ b/src/optimusmanager.cpp @@ -381,7 +381,7 @@ OptimusSettings::Mode OptimusManager::detectGpu() if (jsonError.error != QJsonParseError::NoError) qFatal("Unable to parse Optimus Manager state file: %s", qPrintable(jsonError.errorString())); - QJsonValue modeValue = jsonDocument.object().value(u"current_mode"); + QJsonValue modeValue = jsonDocument.object().value("current_mode"); if (modeValue.type() != QJsonValue::String) qFatal("Unable to read current mode from Optimus Manager state file"); diff --git a/src/third-party/singleapplication b/src/third-party/singleapplication new file mode 160000 index 0000000..611e48a --- /dev/null +++ b/src/third-party/singleapplication @@ -0,0 +1 @@ +Subproject commit 611e48abbbcaea7e59352c277db0ca2c24369eb8