├── .github └── FUNDING.yml ├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── LICENSE ├── README.md ├── Stacer.pro ├── applications └── stacer.desktop ├── cmake └── cxxbasics │ ├── CXXBasics.cmake │ ├── DefaultSettings.cmake │ ├── InitCXXBasics.cmake │ ├── UNLICENSE │ ├── accelerators │ ├── UseCCache.cmake │ ├── UseCompilerCacheTool.cmake │ ├── UseFasterLinkers.cmake │ └── UseSCCache.cmake │ ├── compiler_detection │ └── GetTargetArch.cmake │ └── helpers │ ├── FnMktemp.cmake │ ├── MacroCustomMessages.cmake │ └── MacroOpt.cmake ├── debian ├── changelog ├── compat ├── control ├── copyright ├── install ├── postinst ├── postrm ├── rules └── source │ └── format ├── icons └── hicolor │ ├── 128x128 │ └── apps │ │ └── stacer.png │ ├── 16x16 │ └── apps │ │ └── stacer.png │ ├── 256x256 │ └── apps │ │ └── stacer.png │ ├── 32x32 │ └── apps │ │ └── stacer.png │ └── 64x64 │ └── apps │ └── stacer.png ├── release.sh ├── screenshots ├── Screenshot-1.0.9-1.png ├── Screenshot-1.0.9-10.png ├── Screenshot-1.0.9-11.png ├── Screenshot-1.0.9-12.png ├── Screenshot-1.0.9-13.png ├── Screenshot-1.0.9-14.png ├── Screenshot-1.0.9-15.png ├── Screenshot-1.0.9-16.png ├── Screenshot-1.0.9-2.png ├── Screenshot-1.0.9-3.png ├── Screenshot-1.0.9-4.png ├── Screenshot-1.0.9-5.png ├── Screenshot-1.0.9-6.png ├── Screenshot-1.0.9-7.png ├── Screenshot-1.0.9-8.png ├── Screenshot-1.0.9-9.png └── header.png ├── stacer-core ├── CMakeLists.txt ├── Info │ ├── cpu_info.cpp │ ├── cpu_info.h │ ├── disk_info.cpp │ ├── disk_info.h │ ├── memory_info.cpp │ ├── memory_info.h │ ├── network_info.cpp │ ├── network_info.h │ ├── process.cpp │ ├── process.h │ ├── process_info.cpp │ ├── process_info.h │ ├── system_info.cpp │ └── system_info.h ├── Tools │ ├── apt_source_tool.cpp │ ├── apt_source_tool.h │ ├── gnome_schema.h │ ├── gnome_settings_tool.cpp │ ├── gnome_settings_tool.h │ ├── package_tool.cpp │ ├── package_tool.h │ ├── service_tool.cpp │ └── service_tool.h ├── Utils │ ├── command_util.cpp │ ├── command_util.h │ ├── file_util.cpp │ ├── file_util.h │ ├── format_util.cpp │ └── format_util.h ├── stacer-core.pro └── stacer-core_global.h ├── stacer ├── CMakeLists.txt ├── Managers │ ├── app_manager.cpp │ ├── app_manager.h │ ├── info_manager.cpp │ ├── info_manager.h │ ├── setting_manager.cpp │ ├── setting_manager.h │ ├── tool_manager.cpp │ └── tool_manager.h ├── Pages │ ├── AptSourceManager │ │ ├── apt_source_edit.cpp │ │ ├── apt_source_edit.h │ │ ├── apt_source_edit.ui │ │ ├── apt_source_manager_page.cpp │ │ ├── apt_source_manager_page.h │ │ ├── apt_source_manager_page.ui │ │ ├── apt_source_repository_item.cpp │ │ ├── apt_source_repository_item.h │ │ └── apt_source_repository_item.ui │ ├── Dashboard │ │ ├── circlebar.cpp │ │ ├── circlebar.h │ │ ├── circlebar.ui │ │ ├── dashboard_page.cpp │ │ ├── dashboard_page.h │ │ ├── dashboard_page.ui │ │ ├── linebar.cpp │ │ ├── linebar.h │ │ └── linebar.ui │ ├── GnomeSettings │ │ ├── appearance_settings.cpp │ │ ├── appearance_settings.h │ │ ├── appearance_settings.ui │ │ ├── gnome_settings_page.cpp │ │ ├── gnome_settings_page.h │ │ ├── gnome_settings_page.ui │ │ ├── unity_settings.cpp │ │ ├── unity_settings.h │ │ ├── unity_settings.ui │ │ ├── window_manager_settings.cpp │ │ ├── window_manager_settings.h │ │ └── window_manager_settings.ui │ ├── Helpers │ │ ├── helpers_page.cpp │ │ ├── helpers_page.h │ │ ├── helpers_page.ui │ │ ├── host_manage.cpp │ │ ├── host_manage.h │ │ └── host_manage.ui │ ├── Processes │ │ ├── processes_page.cpp │ │ ├── processes_page.h │ │ └── processes_page.ui │ ├── Resources │ │ ├── history_chart.cpp │ │ ├── history_chart.h │ │ ├── history_chart.ui │ │ ├── resources_page.cpp │ │ ├── resources_page.h │ │ └── resources_page.ui │ ├── Search │ │ ├── search_page.cpp │ │ ├── search_page.h │ │ └── search_page.ui │ ├── Services │ │ ├── service_item.cpp │ │ ├── service_item.h │ │ ├── service_item.ui │ │ ├── services_page.cpp │ │ ├── services_page.h │ │ └── services_page.ui │ ├── Settings │ │ ├── settings_page.cpp │ │ ├── settings_page.h │ │ └── settings_page.ui │ ├── StartupApps │ │ ├── startup_app.cpp │ │ ├── startup_app.h │ │ ├── startup_app.ui │ │ ├── startup_app_edit.cpp │ │ ├── startup_app_edit.h │ │ ├── startup_app_edit.ui │ │ ├── startup_apps_page.cpp │ │ ├── startup_apps_page.h │ │ └── startup_apps_page.ui │ ├── SystemCleaner │ │ ├── byte_tree_widget.cpp │ │ ├── byte_tree_widget.h │ │ ├── system_cleaner_page.cpp │ │ ├── system_cleaner_page.h │ │ └── system_cleaner_page.ui │ └── Uninstaller │ │ ├── uninstaller_page.cpp │ │ ├── uninstaller_page.h │ │ └── uninstallerpage.ui ├── app.cpp ├── app.h ├── app.ui ├── feedback.cpp ├── feedback.h ├── feedback.ui ├── main.cpp ├── signal_mapper.cpp ├── signal_mapper.h ├── sliding_stacked_widget.cpp ├── sliding_stacked_widget.h ├── stacer.pro ├── static.qrc ├── static │ ├── font │ │ └── Ubuntu-R.ttf │ ├── languages.json │ ├── logo.png │ ├── splashscreen.png │ ├── themes.json │ └── themes │ │ ├── common │ │ └── img │ │ │ ├── appearance.png │ │ │ ├── check.png │ │ │ ├── checkbox.png │ │ │ ├── delete.png │ │ │ ├── donate.png │ │ │ ├── folder.png │ │ │ ├── not-found.png │ │ │ ├── package.png │ │ │ ├── spindown.png │ │ │ ├── spinup.png │ │ │ ├── trash_2.png │ │ │ ├── ubuntu.png │ │ │ ├── un-check.png │ │ │ ├── un-checkbox.png │ │ │ └── window.png │ │ ├── default │ │ ├── img │ │ │ ├── app.png │ │ │ ├── asc.png │ │ │ ├── back.png │ │ │ ├── c_cache.png │ │ │ ├── c_crash.png │ │ │ ├── c_logs.png │ │ │ ├── c_package.png │ │ │ ├── c_trash.png │ │ │ ├── clean-active.png │ │ │ ├── clean.png │ │ │ ├── collapse.png │ │ │ ├── down-arrow.png │ │ │ ├── dsc.png │ │ │ ├── edit.png │ │ │ ├── fit.png │ │ │ ├── loading.gif │ │ │ ├── loadings.gif │ │ │ ├── power.png │ │ │ ├── ppa-repository.png │ │ │ ├── refresh.png │ │ │ ├── right-arrow.png │ │ │ ├── run.png │ │ │ ├── scan-active.png │ │ │ ├── scan.png │ │ │ ├── scanLoading.gif │ │ │ ├── search.png │ │ │ ├── service.png │ │ │ ├── sidebar-icons │ │ │ │ ├── cleaner.png │ │ │ │ ├── dash.png │ │ │ │ ├── feedback.png │ │ │ │ ├── gnome.png │ │ │ │ ├── helpers.png │ │ │ │ ├── ppa-manager.png │ │ │ │ ├── process.png │ │ │ │ ├── resources.png │ │ │ │ ├── search.png │ │ │ │ ├── services.png │ │ │ │ ├── settings.png │ │ │ │ ├── startup-apps.png │ │ │ │ └── uninstaller.png │ │ │ └── trash.png │ │ └── style │ │ │ ├── style.qss │ │ │ └── values.ini │ │ └── light │ │ ├── img │ │ ├── app.png │ │ ├── clean-active.png │ │ ├── clean.png │ │ ├── collapse.png │ │ ├── down-arrow.png │ │ ├── edit.png │ │ ├── fit.png │ │ ├── loading.gif │ │ ├── ppa-repository.png │ │ ├── right-arrow.png │ │ ├── scan-active.png │ │ ├── scan.png │ │ ├── scanLoading.gif │ │ └── trash.png │ │ └── style │ │ ├── style.qss │ │ └── values.ini └── utilities.h └── translations ├── stacer_ar.ts ├── stacer_ca-es.ts ├── stacer_cs.ts ├── stacer_de.ts ├── stacer_en.ts ├── stacer_es.ts ├── stacer_fr.ts ├── stacer_gl.ts ├── stacer_hi.ts ├── stacer_hu.ts ├── stacer_it.ts ├── stacer_kn.ts ├── stacer_ko.ts ├── stacer_ml.ts ├── stacer_nl.ts ├── stacer_oc.ts ├── stacer_pl.ts ├── stacer_pt.ts ├── stacer_ro.ts ├── stacer_ru.ts ├── stacer_sv.ts ├── stacer_tr.ts ├── stacer_ua.ts ├── stacer_vn.ts ├── stacer_zh-cn.ts └── stacer_zh-tw.ts /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: oguzhaninan 5 | open_collective: stacer 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | custom: # Replace with a single custom sponsorship URL 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Stacer.pro.* 2 | dist/ 3 | build/ 4 | #*.AppImage 5 | .vscode 6 | Release/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: clang 3 | sudo: require 4 | dist: trusty 5 | before_install: 6 | - sudo add-apt-repository ppa:beineri/opt-qt591-trusty -y 7 | - sudo apt-get update -qq 8 | install: 9 | - sudo apt-get -y -qq install cmake 10 | - sudo apt-get -y -qq install libgl1-mesa-dev qt59base qt59imageformats qt59svg qt59charts-no-lgpl qt59tools 11 | - source /opt/qt*/bin/qt*-env.sh 12 | before_script: 13 | - mkdir build && cd build 14 | - cmake -DCMAKE_BUILD_TYPE=release -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_PREFIX_PATH=$QTDIR/bin .. 15 | script: 16 | - make -j $(nproc) 17 | - lupdate ../stacer/stacer.pro -no-obsolete 18 | - lrelease ../stacer/stacer.pro -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1 FATAL_ERROR) 2 | project(Stacer) 3 | 4 | # Adding features(build cache + faster linkers) and reasonable defaults(Debug build by default) 5 | include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/cxxbasics/CXXBasics.cmake") 6 | 7 | # Setting a cleaner directory structure for the generated binaries 8 | set(CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}/output") 9 | set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/") 10 | set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib") 11 | 12 | set(PROJECT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}") 13 | 14 | # Activating MOC and searching for the Qt5 dependencies 15 | set(CMAKE_AUTOMOC ON) 16 | find_package(Qt5 COMPONENTS Core Gui Widgets Charts Svg Concurrent REQUIRED) 17 | 18 | # Setting the minimum C++ standard and passing the Qt-specific define 19 | set(CMAKE_CXX_STANDARD 11) 20 | set(CMAKE_CXX_EXTENSIONS YES) 21 | set(CMAKE_CXX_STANDARD_REQUIRED YES) 22 | add_definitions(-DQT_DEPRECATED_WARNINGS) 23 | 24 | # Subprojects 25 | add_subdirectory(stacer-core) 26 | add_subdirectory(stacer) 27 | -------------------------------------------------------------------------------- /Stacer.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | stacer-core \ 5 | stacer 6 | -------------------------------------------------------------------------------- /applications/stacer.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Stacer 3 | Exec=stacer 4 | Comment=Linux System Optimizer and Monitoring 5 | Icon=stacer 6 | Type=Application 7 | Terminal=false 8 | Categories=Utility; 9 | -------------------------------------------------------------------------------- /cmake/cxxbasics/CXXBasics.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 2 | 3 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") 4 | 5 | # Variables necessary in every module 6 | include(InitCXXBasics) 7 | 8 | # Set reasonable CMake defaults 9 | include(DefaultSettings) 10 | 11 | # Activate faster linkers by default 12 | include(accelerators/UseFasterLinkers) 13 | 14 | # Activate the compiler cache tool 15 | include(accelerators/UseCompilerCacheTool) 16 | 17 | # Allow the user to extend CXXBasics 18 | if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../cxxbasics-extension.cmake") 19 | include("${CMAKE_CURRENT_LIST_DIR}/../cxxbasics-extension.cmake") 20 | endif() 21 | -------------------------------------------------------------------------------- /cmake/cxxbasics/DefaultSettings.cmake: -------------------------------------------------------------------------------- 1 | # This module sets reasonable defaults that probably every C/C++ CMake project should 2 | 3 | cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 4 | 5 | # Default build type "Debug" 6 | opt_ifndef("Build Type(Debug, Release, RelWithDebInfo, MinSizeRel)" STRING "Debug" CMAKE_BUILD_TYPE) 7 | 8 | # Generate "compile_commands.json" - tools like clang-tidy can be run on this file 9 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 10 | -------------------------------------------------------------------------------- /cmake/cxxbasics/InitCXXBasics.cmake: -------------------------------------------------------------------------------- 1 | ## This module defines common functions and variables that should be accessible in every module 2 | 3 | cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 4 | 5 | # Enable C and CXX by default. This allows to run some commands in script mode, or using "-C" 6 | enable_language(C) 7 | enable_language(CXX) 8 | 9 | # Project custom messaging macros 10 | include(helpers/MacroCustomMessages) 11 | 12 | # Widely-used macros to handle the cache variables 13 | include(helpers/MacroOpt) 14 | -------------------------------------------------------------------------------- /cmake/cxxbasics/UNLICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /cmake/cxxbasics/accelerators/UseCCache.cmake: -------------------------------------------------------------------------------- 1 | # This module activates "ccache" support on Unix 2 | # This module is supposed to be used only from "UseCompilerCacheTool.cmake" 3 | 4 | cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 5 | 6 | find_program(__cxxbasics_ccache_found ccache) 7 | if(__cxxbasics_ccache_found) 8 | if(NOT CMAKE_C_COMPILER_LAUNCHER) 9 | set(CMAKE_C_COMPILER_LAUNCHER ccache) 10 | endif() 11 | 12 | if(NOT CMAKE_CXX_COMPILER_LAUNCHER) 13 | set(CMAKE_CXX_COMPILER_LAUNCHER ccache) 14 | endif() 15 | endif() 16 | -------------------------------------------------------------------------------- /cmake/cxxbasics/accelerators/UseCompilerCacheTool.cmake: -------------------------------------------------------------------------------- 1 | # This module activates a compiler cache 2 | 3 | cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 4 | 5 | opt_ifndef("Use a compiler cache tool, if supported" BOOL ON CXXBASICS_ACTIVATE_COMPILER_CACHE) 6 | if(CXXBASICS_ACTIVATE_COMPILER_CACHE) 7 | if(CMAKE_HOST_UNIX) 8 | include(accelerators/UseCCache) 9 | endif() 10 | 11 | if(NOT CMAKE_C_COMPILER_LAUNCHER OR NOT CMAKE_CXX_COMPILER_LAUNCHER) 12 | include(accelerators/UseSCCache) 13 | endif() 14 | 15 | if(CMAKE_C_COMPILER_LAUNCHER) 16 | cbok("Compiler cache tool \"${CMAKE_C_COMPILER_LAUNCHER}\" set for the C compiler") 17 | else() 18 | cbnok("Could not set a compiler cache tool for the C compiler") 19 | endif() 20 | 21 | if(CMAKE_CXX_COMPILER_LAUNCHER) 22 | cbok("Compiler cache tool \"${CMAKE_CXX_COMPILER_LAUNCHER}\" set for the CXX compiler") 23 | else() 24 | cbnok("Could not set a compiler cache tool for the CXX compiler") 25 | endif() 26 | endif() 27 | -------------------------------------------------------------------------------- /cmake/cxxbasics/accelerators/UseSCCache.cmake: -------------------------------------------------------------------------------- 1 | # This module activates "sccache" support on Unix and Windows if 2 | # another compiler cache tool was not found. 3 | # This module is supposed to be used only from "UseCompilerCacheTool.cmake" 4 | 5 | cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 6 | 7 | find_program(__cxxbasics_sccache_found sccache) 8 | if(__cxxbasics_sccache_found) 9 | if(NOT CMAKE_C_COMPILER_LAUNCHER) 10 | set(CMAKE_C_COMPILER_LAUNCHER sccache) 11 | endif() 12 | 13 | if(NOT CMAKE_CXX_COMPILER_LAUNCHER) 14 | set(CMAKE_CXX_COMPILER_LAUNCHER sccache) 15 | endif() 16 | endif() 17 | -------------------------------------------------------------------------------- /cmake/cxxbasics/helpers/FnMktemp.cmake: -------------------------------------------------------------------------------- 1 | ## This module defines helper functions to create temporary files and folders in a system-agnostic way 2 | 3 | cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 4 | 5 | opt_ifndef("CXXBasics temporary folder(uses system folder by default)" PATH "" CXXBASICS_TMP_FOLDER) 6 | macro(__cxxbasics_mktemp_helper) 7 | # Try to catch wrong usage 8 | if(NOT "${ARGV0}" STREQUAL "file" AND NOT "${ARGV0}" STREQUAL "directory") 9 | cberror("Wrong use of the macro") 10 | endif() 11 | 12 | # If `CXXBASICS_TMP_FOLDER` is not defined or set to an empty string, than we will try to set it to the system TMP 13 | if(NOT DEFINED CXXBASICS_TMP_FOLDER OR NOT IS_DIRECTORY "${CXXBASICS_TMP_FOLDER}") 14 | if(CMAKE_HOST_WIN32) 15 | opt_overwrite(CXXBASICS_TMP_FOLDER "$ENV{TMP}") 16 | elseif(CMAKE_HOST_UNIX) 17 | opt_overwrite(CXXBASICS_TMP_FOLDER "/tmp") 18 | else() 19 | cberror("Unsupported OS. Cannot set the temporary folder, please manually modify CXXBASICS_TMP_FOLDER in the cache") 20 | endif() 21 | endif(NOT DEFINED CXXBASICS_TMP_FOLDER OR NOT IS_DIRECTORY "${CXXBASICS_TMP_FOLDER}") 22 | 23 | # Lets make sure it's actually a directory 24 | if(NOT IS_DIRECTORY "${CXXBASICS_TMP_FOLDER}") 25 | cberror("`${CXXBASICS_TMP_FOLDER}` is not a folder. Please manually modify CXXBASICS_TMP_FOLDER in the cache") 26 | endif() 27 | 28 | # We will try to generate different random names until we are sure that it is unique for the path we try to use 29 | opt_ifndef("Project prefix to be used when creating files and folders" STRING "cxxbasics" CXXBASICS_PROJECT_PREFIX) 30 | string(RANDOM LENGTH 16 random_generated_string) 31 | file(TO_NATIVE_PATH "${CXXBASICS_TMP_FOLDER}/${CXXBASICS_PROJECT_PREFIX}_${random_generated_string}" mktemp_result) 32 | while(EXISTS "${mktemp_result}") 33 | string(RANDOM LENGTH 16 random_generated_string) 34 | file(TO_NATIVE_PATH "${CXXBASICS_TMP_FOLDER}/${CXXBASICS_PROJECT_PREFIX}_${random_generated_string}" mktemp_result) 35 | endwhile(EXISTS "${mktemp_result}") 36 | 37 | # Here the behavior between `file` and `directory` splits, so we handle them separately 38 | if("${ARGV0}" STREQUAL "file") 39 | set(mktemp_result "${mktemp_result}" PARENT_SCOPE) 40 | file(WRITE "${mktemp_result}" "") 41 | 42 | # file(WRITE) should throw an error but we'll check anyway 43 | if(NOT EXISTS "${mktemp_result}" OR IS_DIRECTORY "${mktemp_result}") 44 | cbnok("Failed to create the temporary file") 45 | unset(mktemp_result PARENT_SCOPE) 46 | endif() 47 | else() 48 | set(mktemp_directory_result "${mktemp_result}") 49 | set(mktemp_directory_result "${mktemp_directory_result}" PARENT_SCOPE) 50 | file(MAKE_DIRECTORY "${mktemp_directory_result}") 51 | 52 | # file(MAKE_DIRECTORY) should throw an error but we'll check anyway 53 | if(NOT IS_DIRECTORY "${mktemp_directory_result}") 54 | cbnok("Failed to create the temporary folder") 55 | unset(mktemp_directory_result PARENT_SCOPE) 56 | endif() 57 | endif() 58 | endmacro() 59 | 60 | # @function mktemp 61 | # @return mktemp_result - stores the path to the temporary file 62 | function(mktemp) 63 | __cxxbasics_mktemp_helper("file") 64 | endfunction() 65 | 66 | # @function mktemp_directory 67 | # @return mktemp_directory_result - stores the path to the temporary folder 68 | function(mktemp_directory) 69 | __cxxbasics_mktemp_helper("directory") 70 | endfunction() 71 | -------------------------------------------------------------------------------- /cmake/cxxbasics/helpers/MacroCustomMessages.cmake: -------------------------------------------------------------------------------- 1 | ## This module contains project-wide custom CMake messagging macros. 2 | ## Does not adhere to the overall style because MacroCbmessage does not sound very well nor represent all macros... 3 | 4 | cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 5 | 6 | # This does not work in Windows CMD(usually also CI) 7 | if(CYGWIN OR NOT CMAKE_HOST_WIN32) 8 | string(ASCII 27 __cxxbasics_escape) 9 | set(__cxxbasics_prefix_color "${__cxxbasics_escape}[36m") # Cyan 10 | set(__cxxbasics_success_color "${__cxxbasics_escape}[32m") # Green 11 | set(__cxxbasics_failure_color "${__cxxbasics_escape}[31m") # Red 12 | set(__cxxbasics_no_color "${__cxxbasics_escape}[m") # Reset color 13 | 14 | unset(__cxxbasics_escape) 15 | endif() 16 | 17 | set(__cxxbasics_prefix "[${__cxxbasics_prefix_color}cxxbasics${__cxxbasics_no_color}]") 18 | set(__cxxbasics_success "[${__cxxbasics_success_color}✓${__cxxbasics_no_color}]") 19 | set(__cxxbasics_failure "[${__cxxbasics_failure_color}✗${__cxxbasics_no_color}]") 20 | 21 | unset(__cxxbasics_prefix_color) 22 | unset(__cxxbasics_success_color) 23 | unset(__cxxbasics_failure_color) 24 | unset(__cxxbasics_no_color) 25 | 26 | #======================================================== 27 | 28 | # Use `_cbp` when displaying a simple message. 29 | # `cbp` stands for [C]XX[B]asics [P]refix 30 | set(_cbp "${__cxxbasics_prefix}") 31 | 32 | # Use `_cbok` when displaying a notification of success(ex: `cxxbasics` succeded to set up ccache) 33 | # `cbok` stands for [C]XX[B]asics [OK] 34 | set(_cbok "${_cbp}${__cxxbasics_success}") 35 | 36 | # Use `_cbnok` when displaying a notification of failure(ex: the user activated `ccache` but it was not found in the system) 37 | # `cbnok` stands for [C]XX[B]asics [N]ot [OK] 38 | set(_cbnok "${_cbp}${__cxxbasics_failure}") 39 | 40 | macro(cbmessage) 41 | message(STATUS "${_cbp} " ${ARGV}) 42 | endmacro(cbmessage) 43 | 44 | macro(cbok) 45 | message(STATUS "${_cbok} " ${ARGV}) 46 | endmacro(cbok) 47 | 48 | macro(cbnok) 49 | message(STATUS "${_cbnok} " ${ARGV}) 50 | endmacro(cbnok) 51 | 52 | macro(cberror) 53 | message(FATAL_ERROR "${_cbnok} " ${ARGV}) 54 | endmacro(cberror) 55 | 56 | #======================================================== 57 | 58 | unset(__cxxbasics_prefix) 59 | unset(__cxxbasics_success) 60 | unset(__cxxbasics_failure) 61 | -------------------------------------------------------------------------------- /cmake/cxxbasics/helpers/MacroOpt.cmake: -------------------------------------------------------------------------------- 1 | ## This module defines helper macros to set options(cached variables) 2 | 3 | cmake_minimum_required(VERSION 3.0 FATAL_ERROR) 4 | 5 | # @macro opt 6 | # Macro helper to set a cache value. 7 | # Does not overwrite the value if it was already cached. 8 | # 9 | # `description` - the description that will be displayed in CMake cache editor 10 | # `var_type` - the type of the variable(BOOL, FILEPATH, PATH, STRING, INTERNAL) 11 | # `var_value` - the value `var_name` will be set to 12 | # `var_name` - variable name 13 | macro(opt description var_type var_value var_name) 14 | set(${var_name} ${var_value} CACHE ${var_type} "${description}") 15 | 16 | # Stores internally information about this variable's description and type 17 | # Will be reused in `opt_overwrite` to make the macro easy to use 18 | set(${var_name}_DESCRIPTION "${description}" CACHE INTERNAL "") 19 | set(${var_name}_TYPE "${var_type}" CACHE INTERNAL "") 20 | endmacro() 21 | 22 | # @macro opt_ifndef 23 | # Macro helper to set a cache value. 24 | # Sets the cache value only if the variable(including local variables) was not defined or it is set to an empty string. 25 | macro(opt_ifndef description var_type var_value var_name) 26 | if(NOT DEFINED ${var_name} OR "${${var_name}}" STREQUAL "") 27 | set(${var_name} ${var_value} CACHE ${var_type} "${description}" FORCE) 28 | 29 | set(${var_name}_DESCRIPTION "${description}" CACHE INTERNAL "") 30 | set(${var_name}_TYPE "${var_type}" CACHE INTERNAL "") 31 | endif() 32 | endmacro() 33 | 34 | # @macro opt_force 35 | # Macro helper to set a cache value. 36 | # Sets the cache value or overwrites the value if the variable already exists. 37 | macro(opt_force description var_type var_value var_name) 38 | set(${var_name} ${var_value} CACHE ${var_type} "${description}" FORCE) 39 | 40 | set(${var_name}_DESCRIPTION "${description}" CACHE INTERNAL "") 41 | set(${var_name}_TYPE "${var_type}" CACHE INTERNAL "") 42 | endmacro() 43 | 44 | # @macro opt_overwrite 45 | # Macro helper to set a cache value. 46 | # Overwrites the cache value only if the variable already exists in the cache(not local variables). 47 | # The variable in the cache has to be registered with one of the `opt` macros 48 | macro(opt_overwrite var_name var_value) 49 | # we do not check `if(NOT DEFINED ${var_name})` because local variables don't limit us from updating the 50 | # correct variable in the cache. We rely on _DESCRIPTION and _TYPE to find if the variable was 51 | # previously registered with `opt` 52 | if(NOT DEFINED ${var_name}_DESCRIPTION OR NOT DEFINED ${var_name}_TYPE) 53 | cberror("user-code logic error: `${var_name}` was not registered with an `opt` macro beforehand") 54 | endif() 55 | 56 | set(${var_name} ${var_value} CACHE ${${var_name}_TYPE} "${${var_name}_DESCRIPTION}" FORCE) 57 | endmacro() 58 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | stacer (1.1.0-1) stable; urgency=medium 2 | 3 | * Snap package uninstaller. 4 | * Advanced file search. 5 | * Disk chart. 6 | * Host manager. 7 | 8 | -- Oguzhan Inan Sun, 13 May 2018 00:50:10 +0300 9 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: stacer 2 | Section: utils 3 | Priority: optional 4 | Maintainer: Oguzhan INAN 5 | Build-Depends: debhelper (>=9) 6 | Standards-Version: 3.9.6 7 | Homepage: https://github.com/oguzhaninan/Stacer 8 | Vcs-Browser: https://github.com/oguzhaninan/Stacer.git 9 | 10 | Package: stacer 11 | Architecture: all 12 | Depends: ${misc:Depends} 13 | Recommends: systemd, curl 14 | Description: Linux System Optimizer and Monitoring 15 | -------------------------------------------------------------------------------- /debian/install: -------------------------------------------------------------------------------- 1 | stacer/* usr/share/stacer/ 2 | applications/* usr/share/applications/ 3 | icons/* usr/share/icons/ 4 | -------------------------------------------------------------------------------- /debian/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ln -sf "/usr/share/stacer/stacer" "/usr/bin/stacer" 4 | 5 | exit 0 -------------------------------------------------------------------------------- /debian/postrm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | unlink /usr/bin/stacer 4 | rm -rf /usr/share/stacer 5 | 6 | exit 0 7 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | 4 | # Uncomment this to turn on verbose mode. 5 | #export DH_VERBOSE=1 6 | 7 | %: 8 | dh $@ --parallel 9 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /icons/hicolor/128x128/apps/stacer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/icons/hicolor/128x128/apps/stacer.png -------------------------------------------------------------------------------- /icons/hicolor/16x16/apps/stacer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/icons/hicolor/16x16/apps/stacer.png -------------------------------------------------------------------------------- /icons/hicolor/256x256/apps/stacer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/icons/hicolor/256x256/apps/stacer.png -------------------------------------------------------------------------------- /icons/hicolor/32x32/apps/stacer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/icons/hicolor/32x32/apps/stacer.png -------------------------------------------------------------------------------- /icons/hicolor/64x64/apps/stacer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/icons/hicolor/64x64/apps/stacer.png -------------------------------------------------------------------------------- /release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | VERSION=1.1.0 3 | RELEASE=Release 4 | DIR=stacer-$VERSION 5 | 6 | mkdir $RELEASE 7 | mkdir build ; cd build 8 | cmake -DCMAKE_BUILD_TYPE=debug -DCMAKE_CXX_COMPILER=g++ -DCMAKE_PREFIX_PATH=$QTDIR/bin .. 9 | make -j `nproc` 10 | cd .. 11 | 12 | mkdir $RELEASE/$DIR/stacer -p 13 | cp -r icons applications debian $RELEASE/$DIR 14 | cp -r build/output/* $RELEASE/$DIR/stacer 15 | 16 | # translations 17 | lupdate stacer/stacer.pro -no-obsolete 18 | lrelease stacer/stacer.pro 19 | mkdir $RELEASE/$DIR/stacer/translations 20 | mv translations/*.qm $RELEASE/$DIR/stacer/translations 21 | 22 | # linuxdeployqt 23 | wget -cO lqt "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" 24 | chmod +x lqt 25 | unset QTDIR; unset QT_PLUGIN_PATH; unset LD_LIBRARY_PATH 26 | ./lqt $RELEASE/$DIR/stacer/stacer -bundle-non-qt-libs -no-translations -unsupported-allow-new-glibc 27 | rm lqt 28 | 29 | if [ $1 = "deb" ]; then 30 | cd $RELEASE/$DIR 31 | dh_make --createorig -i -c mit 32 | debuild --no-lintian -us -uc 33 | fi 34 | -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-1.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-10.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-11.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-12.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-13.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-14.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-15.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-16.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-2.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-3.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-4.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-5.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-6.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-7.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-8.png -------------------------------------------------------------------------------- /screenshots/Screenshot-1.0.9-9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/Screenshot-1.0.9-9.png -------------------------------------------------------------------------------- /screenshots/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/screenshots/header.png -------------------------------------------------------------------------------- /stacer-core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1 FATAL_ERROR) 2 | project(stacer-core) 3 | 4 | include_directories( 5 | "${CMAKE_CURRENT_SOURCE_DIR}" 6 | "${CMAKE_CURRENT_SOURCE_DIR}/Info" 7 | "${CMAKE_CURRENT_SOURCE_DIR}/Tools" 8 | "${CMAKE_CURRENT_SOURCE_DIR}/Utils" 9 | ) 10 | 11 | file(GLOB_RECURSE ${PROJECT_NAME}_srcs "${CMAKE_CURRENT_SOURCE_DIR}/**.cpp") 12 | 13 | add_definitions(-DSTACERCORE_LIBRARY) 14 | 15 | find_package(Qt5 COMPONENTS Core Network REQUIRED) 16 | 17 | add_library(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_srcs}) 18 | target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Network) 19 | -------------------------------------------------------------------------------- /stacer-core/Info/cpu_info.h: -------------------------------------------------------------------------------- 1 | #ifndef CPUINFO_H 2 | #define CPUINFO_H 3 | 4 | #include 5 | #include 6 | 7 | #include "Utils/file_util.h" 8 | 9 | #define PROC_CPUINFO "/proc/cpuinfo" 10 | #define LSCPU_COMMAND "LANG=nl_NL.UTF-8 lscpu" 11 | #define PROC_LOADAVG "/proc/loadavg" 12 | #define PROC_STAT "/proc/stat" 13 | 14 | #include "stacer-core_global.h" 15 | 16 | class STACERCORESHARED_EXPORT CpuInfo 17 | { 18 | public: 19 | int getCpuPhysicalCoreCount() const; 20 | int getCpuCoreCount() const; 21 | QList getCpuPercents() const; 22 | QList getLoadAvgs() const; 23 | double getAvgClock() const; 24 | QList getClocks() const; 25 | 26 | private: 27 | int getCpuPercent(const QList &cpuTimes, const int &processor = 0) const; 28 | }; 29 | 30 | #endif // CPUINFO_H 31 | -------------------------------------------------------------------------------- /stacer-core/Info/disk_info.cpp: -------------------------------------------------------------------------------- 1 | #include "disk_info.h" 2 | #include 3 | 4 | QList DiskInfo::getDisks() const 5 | { 6 | return disks; 7 | } 8 | 9 | void DiskInfo::updateDiskInfo() 10 | { 11 | qDeleteAll(disks); 12 | disks.clear(); 13 | 14 | QList storageInfoList = QStorageInfo::mountedVolumes(); 15 | 16 | for(const QStorageInfo &info: storageInfoList) { 17 | if (info.isValid()) { 18 | Disk *disk = new Disk(); 19 | disk->name = info.displayName(); 20 | disk->device = info.device(); 21 | disk->size = info.bytesTotal(); 22 | disk->used = info.bytesTotal() - info.bytesFree(); 23 | disk->free = info.bytesFree(); 24 | disk->fileSystemType = info.fileSystemType(); 25 | 26 | disks << disk; 27 | } 28 | } 29 | } 30 | 31 | QList DiskInfo::devices() 32 | { 33 | QSet set; 34 | for(const QStorageInfo &info: QStorageInfo::mountedVolumes()) { 35 | if (info.isValid()) set.insert(info.device()); 36 | } 37 | 38 | return set.toList(); 39 | } 40 | 41 | DiskInfo::~DiskInfo() 42 | { 43 | qDeleteAll(disks); 44 | } 45 | 46 | QList DiskInfo::fileSystemTypes() 47 | { 48 | QSet set; 49 | for(const QStorageInfo &info: QStorageInfo::mountedVolumes()) { 50 | if (info.isValid()) set.insert(info.fileSystemType()); 51 | } 52 | 53 | return set.toList(); 54 | } 55 | 56 | QList DiskInfo::getDiskIO() const 57 | { 58 | static QStringList diskNames = getDiskNames(); 59 | 60 | QList diskReadWrite; 61 | quint64 totalRead = 0; 62 | quint64 totalWrite = 0; 63 | 64 | for (const QString diskName : diskNames) { 65 | QStringList diskStat = FileUtil::readStringFromFile(QString("/sys/block/%1/stat").arg(diskName)) 66 | .trimmed() 67 | .split(QRegExp("\\s+")); 68 | 69 | if (diskStat.count() > 7) { 70 | totalRead = totalRead + (diskStat.at(2).toLongLong() * 512); 71 | totalWrite = totalWrite + (diskStat.at(6).toLongLong() * 512); 72 | } 73 | } 74 | diskReadWrite.append(totalRead); 75 | diskReadWrite.append(totalWrite); 76 | 77 | return diskReadWrite; 78 | } 79 | 80 | QStringList DiskInfo::getDiskNames() const 81 | { 82 | QDir blocks("/sys/block"); 83 | QStringList disks; 84 | for (const QFileInfo entryInfo : blocks.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot)) { 85 | if (QFile::exists(QString("%1/device").arg(entryInfo.absoluteFilePath()))) { 86 | disks.append(entryInfo.baseName()); 87 | } 88 | } 89 | return disks; 90 | } 91 | -------------------------------------------------------------------------------- /stacer-core/Info/disk_info.h: -------------------------------------------------------------------------------- 1 | #ifndef DISKINFO_H 2 | #define DISKINFO_H 3 | 4 | #include "Utils/command_util.h" 5 | #include "Utils/file_util.h" 6 | #include 7 | #include 8 | #include "stacer-core_global.h" 9 | 10 | #define PROC_MOUNTS "/proc/mounts" 11 | 12 | class Disk; 13 | 14 | class STACERCORESHARED_EXPORT DiskInfo 15 | { 16 | public: 17 | QList getDisks() const; 18 | void updateDiskInfo(); 19 | QList getDiskIO() const; 20 | QStringList getDiskNames() const; 21 | QList fileSystemTypes(); 22 | QList devices(); 23 | ~DiskInfo(); 24 | 25 | private: 26 | QList disks; 27 | }; 28 | 29 | struct Disk { 30 | QString name; 31 | QString device; 32 | QString fileSystemType; 33 | quint64 size; 34 | quint64 free; 35 | quint64 used; 36 | }; 37 | 38 | 39 | #endif // DISKINFO_H 40 | -------------------------------------------------------------------------------- /stacer-core/Info/memory_info.cpp: -------------------------------------------------------------------------------- 1 | #include "memory_info.h" 2 | #include 3 | 4 | MemoryInfo::MemoryInfo(): 5 | memTotal(0), 6 | memFree(0), 7 | memUsed(0) 8 | { } 9 | 10 | /* https://access.redhat.com/solutions/406773 11 | * 12 | * https://stackoverflow.com/questions/41224738/ 13 | * Total used memory = MemTotal - MemFree 14 | * Non cache/buffer memory (green) = Total used memory - (Buffers + Cached memory) 15 | * Buffers (blue) = Buffers 16 | * Cached memory (yellow) = Cached + SReclaimable - Shmem 17 | * Swap = SwapTotal - SwapFree 18 | */ 19 | void MemoryInfo::updateMemoryInfo() 20 | { 21 | QStringList lines = FileUtil::readListFromFile(PROC_MEMINFO) 22 | .filter(QRegExp("^MemTotal|^MemFree|^Buffers|^Cached|^SwapTotal|^SwapFree|^Shmem|^SReclaimable")); 23 | QRegExp sep("\\s+"); 24 | 25 | #define getValue(l) lines.at(l).split(sep).at(1).toLong() << 10; 26 | memTotal = getValue(0); 27 | memFree = getValue(1); 28 | buffers = getValue(2); 29 | cached = getValue(3); 30 | swapTotal = getValue(4); 31 | swapFree = getValue(5); 32 | sreclaimable = getValue(6); 33 | shmem = getValue(7); 34 | #undef getValue 35 | 36 | cached = (cached + sreclaimable - shmem); 37 | memUsed = (memTotal - (memFree + buffers + cached)); 38 | swapUsed = (swapTotal - swapFree); 39 | } 40 | 41 | quint64 MemoryInfo::getSwapUsed() const 42 | { 43 | return swapUsed; 44 | } 45 | 46 | quint64 MemoryInfo::getSwapFree() const 47 | { 48 | return swapFree; 49 | } 50 | 51 | quint64 MemoryInfo::getSwapTotal() const 52 | { 53 | return swapTotal; 54 | } 55 | 56 | quint64 MemoryInfo::getMemUsed() const 57 | { 58 | return memUsed; 59 | } 60 | 61 | quint64 MemoryInfo::getMemFree() const 62 | { 63 | return memFree; 64 | } 65 | 66 | quint64 MemoryInfo::getMemTotal() const 67 | { 68 | return memTotal; 69 | } 70 | -------------------------------------------------------------------------------- /stacer-core/Info/memory_info.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORYINFO_H 2 | #define MEMORYINFO_H 3 | 4 | #include "Utils/file_util.h" 5 | 6 | #define PROC_MEMINFO "/proc/meminfo" 7 | 8 | #include "stacer-core_global.h" 9 | 10 | class STACERCORESHARED_EXPORT MemoryInfo 11 | { 12 | public: 13 | MemoryInfo(); 14 | 15 | void updateMemoryInfo(); 16 | 17 | quint64 getMemTotal() const; 18 | quint64 getMemFree() const; 19 | quint64 getMemUsed() const; 20 | 21 | quint64 getSwapTotal() const; 22 | quint64 getSwapFree() const; 23 | quint64 getSwapUsed() const; 24 | 25 | private: 26 | // memory 27 | quint64 memTotal; 28 | quint64 memFree; 29 | quint64 memUsed; 30 | quint64 buffers; 31 | quint64 cached; 32 | quint64 sreclaimable; 33 | quint64 shmem; 34 | 35 | // swap 36 | quint64 swapTotal; 37 | quint64 swapFree; 38 | quint64 swapUsed; 39 | }; 40 | 41 | #endif // MEMORYINFO_H 42 | -------------------------------------------------------------------------------- /stacer-core/Info/network_info.cpp: -------------------------------------------------------------------------------- 1 | #include "network_info.h" 2 | #include 3 | 4 | NetworkInfo::NetworkInfo() 5 | { 6 | for (const QNetworkInterface &net: QNetworkInterface::allInterfaces()) { 7 | 8 | if ((net.flags() & QNetworkInterface::IsUp) && 9 | (net.flags() & QNetworkInterface::IsRunning) && 10 | !(net.flags() & QNetworkInterface::IsLoopBack)) 11 | { 12 | defaultNetworkInterface = net.name(); 13 | break; 14 | } 15 | } 16 | 17 | rxPath = QString("/sys/class/net/%1/statistics/rx_bytes") 18 | .arg(defaultNetworkInterface); 19 | 20 | txPath = QString("/sys/class/net/%1/statistics/tx_bytes") 21 | .arg(defaultNetworkInterface); 22 | } 23 | 24 | QList NetworkInfo::getAllInterfaces() 25 | { 26 | return QNetworkInterface::allInterfaces(); 27 | } 28 | 29 | QString NetworkInfo::getDefaultNetworkInterface() const 30 | { 31 | return defaultNetworkInterface; 32 | } 33 | 34 | quint64 NetworkInfo::getRXbytes() const 35 | { 36 | quint64 rx = FileUtil::readStringFromFile(rxPath) 37 | .trimmed() 38 | .toLong(); 39 | 40 | return rx; 41 | } 42 | 43 | quint64 NetworkInfo::getTXbytes() const 44 | { 45 | quint64 tx = FileUtil::readStringFromFile(txPath) 46 | .trimmed() 47 | .toLong(); 48 | 49 | return tx; 50 | } 51 | -------------------------------------------------------------------------------- /stacer-core/Info/network_info.h: -------------------------------------------------------------------------------- 1 | #ifndef NETWORK_INFO_H 2 | #define NETWORK_INFO_H 3 | 4 | #include 5 | #include "Utils/file_util.h" 6 | #include "Utils/command_util.h" 7 | 8 | #include "stacer-core_global.h" 9 | 10 | class STACERCORESHARED_EXPORT NetworkInfo 11 | { 12 | public: 13 | NetworkInfo(); 14 | 15 | QString getDefaultNetworkInterface() const; 16 | QList getAllInterfaces(); 17 | 18 | quint64 getRXbytes() const; 19 | quint64 getTXbytes() const; 20 | 21 | private: 22 | QString defaultNetworkInterface; 23 | 24 | QString rxPath; 25 | QString txPath; 26 | }; 27 | 28 | #endif // NETWORK_INFO_H 29 | -------------------------------------------------------------------------------- /stacer-core/Info/process.cpp: -------------------------------------------------------------------------------- 1 | #include "process.h" 2 | 3 | pid_t Process::getPid() const 4 | { 5 | return pid; 6 | } 7 | 8 | void Process::setPid(const pid_t &value) 9 | { 10 | pid = value; 11 | } 12 | 13 | quint64 Process::getRss() const 14 | { 15 | return rss; 16 | } 17 | 18 | void Process::setRss(const quint64 &value) 19 | { 20 | rss = value; 21 | } 22 | 23 | double Process::getPmem() const 24 | { 25 | return pmem; 26 | } 27 | 28 | void Process::setPmem(const double &value) 29 | { 30 | pmem = value; 31 | } 32 | 33 | quint64 Process::getVsize() const 34 | { 35 | return vsize; 36 | } 37 | 38 | void Process::setVsize(const quint64 &value) 39 | { 40 | vsize = value; 41 | } 42 | 43 | QString Process::getUname() const 44 | { 45 | return uname; 46 | } 47 | 48 | void Process::setUname(const QString &value) 49 | { 50 | uname = value; 51 | } 52 | 53 | double Process::getPcpu() const 54 | { 55 | return pcpu; 56 | } 57 | 58 | void Process::setPcpu(const double &value) 59 | { 60 | pcpu = value; 61 | } 62 | 63 | QString Process::getCmd() const 64 | { 65 | return cmd; 66 | } 67 | 68 | void Process::setCmd(const QString &value) 69 | { 70 | cmd = value; 71 | } 72 | 73 | QString Process::getStartTime() const 74 | { 75 | return startTime; 76 | } 77 | 78 | void Process::setStartTime(const QString &value) 79 | { 80 | startTime = value; 81 | } 82 | 83 | QString Process::getState() const 84 | { 85 | return state; 86 | } 87 | 88 | void Process::setState(const QString &value) 89 | { 90 | state = value; 91 | } 92 | 93 | QString Process::getGroup() const 94 | { 95 | return group; 96 | } 97 | 98 | void Process::setGroup(const QString &value) 99 | { 100 | group = value; 101 | } 102 | 103 | int Process::getNice() const 104 | { 105 | return nice; 106 | } 107 | 108 | void Process::setNice(const int &value) 109 | { 110 | nice = value; 111 | } 112 | 113 | QString Process::getCpuTime() const 114 | { 115 | return cpuTime; 116 | } 117 | 118 | void Process::setCpuTime(const QString &value) 119 | { 120 | cpuTime = value; 121 | } 122 | 123 | QString Process::getSession() const 124 | { 125 | return session; 126 | } 127 | 128 | void Process::setSession(const QString &value) 129 | { 130 | session = value; 131 | } 132 | -------------------------------------------------------------------------------- /stacer-core/Info/process.h: -------------------------------------------------------------------------------- 1 | #ifndef PROCESS_H 2 | #define PROCESS_H 3 | 4 | #include "Utils/file_util.h" 5 | 6 | #include "stacer-core_global.h" 7 | 8 | class STACERCORESHARED_EXPORT Process { 9 | 10 | public: 11 | pid_t getPid() const; 12 | void setPid(const pid_t &value); 13 | 14 | quint64 getRss() const; 15 | void setRss(const quint64 &value); 16 | 17 | double getPmem() const; 18 | void setPmem(const double &value); 19 | 20 | quint64 getVsize() const; 21 | void setVsize(const quint64 &value); 22 | 23 | QString getUname() const; 24 | void setUname(const QString &value); 25 | 26 | double getPcpu() const; 27 | void setPcpu(const double &value); 28 | 29 | QString getStartTime() const; 30 | void setStartTime(const QString &value); 31 | 32 | QString getState() const; 33 | void setState(const QString &value); 34 | 35 | QString getGroup() const; 36 | void setGroup(const QString &value); 37 | 38 | int getNice() const; 39 | void setNice(const int &value); 40 | 41 | QString getCpuTime() const; 42 | void setCpuTime(const QString &value); 43 | 44 | QString getSession() const; 45 | void setSession(const QString &value); 46 | 47 | QString getCmd() const; 48 | void setCmd(const QString &value); 49 | 50 | private: 51 | pid_t pid; 52 | quint64 rss; 53 | double pmem; 54 | quint64 vsize; 55 | QString uname; 56 | double pcpu; 57 | QString startTime; 58 | QString state; 59 | QString group; 60 | int nice; 61 | QString cpuTime; 62 | QString session; 63 | QString cmd; 64 | }; 65 | 66 | 67 | #endif // PROCESS_H 68 | -------------------------------------------------------------------------------- /stacer-core/Info/process_info.cpp: -------------------------------------------------------------------------------- 1 | #include "process_info.h" 2 | 3 | #include 4 | 5 | void ProcessInfo::updateProcesses() 6 | { 7 | processList.clear(); 8 | 9 | try { 10 | 11 | QStringList columns = { "pid", "rss", "pmem", "vsize", "uname:50", "pcpu", "start_time", 12 | "state", "group", "nice", "cputime", "session", "cmd"}; 13 | 14 | QStringList lines = CommandUtil::exec("ps", {"ax", "-weo", columns.join(","), "--no-headings"}) 15 | .trimmed() 16 | .split(QChar('\n')); 17 | 18 | if (! lines.isEmpty()) { 19 | QRegExp sep("\\s+"); 20 | for (const QString &line : lines) { 21 | QStringList procLine = line.trimmed().split(sep); 22 | 23 | if (procLine.count() >= columns.count()) { 24 | Process proc; 25 | 26 | proc.setPid(procLine.takeFirst().toLong()); 27 | proc.setRss(procLine.takeFirst().toLong() << 10); 28 | proc.setPmem(procLine.takeFirst().toDouble()); 29 | proc.setVsize(procLine.takeFirst().toLong() << 10); 30 | proc.setUname(procLine.takeFirst()); 31 | proc.setPcpu(procLine.takeFirst().toDouble()); 32 | proc.setStartTime(procLine.takeFirst()); 33 | proc.setState(procLine.takeFirst()); 34 | proc.setGroup(procLine.takeFirst()); 35 | proc.setNice(procLine.takeFirst().toInt()); 36 | proc.setCpuTime(procLine.takeFirst()); 37 | proc.setSession(procLine.takeFirst()); 38 | proc.setCmd(procLine.join(" ")); 39 | 40 | processList << proc; 41 | } 42 | } 43 | } 44 | 45 | } catch (QString &ex) { 46 | qCritical() << ex; 47 | } 48 | } 49 | 50 | QList ProcessInfo::getProcessList() const 51 | { 52 | return processList; 53 | } 54 | -------------------------------------------------------------------------------- /stacer-core/Info/process_info.h: -------------------------------------------------------------------------------- 1 | #ifndef PROCESS_INFO_H 2 | #define PROCESS_INFO_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include "process.h" 9 | 10 | #include "stacer-core_global.h" 11 | 12 | class STACERCORESHARED_EXPORT ProcessInfo : public QObject 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | QList getProcessList() const; 18 | 19 | public slots: 20 | void updateProcesses(); 21 | 22 | private: 23 | QList processList; 24 | }; 25 | 26 | #endif // PROCESS_INFO_H 27 | -------------------------------------------------------------------------------- /stacer-core/Info/system_info.cpp: -------------------------------------------------------------------------------- 1 | #include "system_info.h" 2 | 3 | #include 4 | #include 5 | 6 | SystemInfo::SystemInfo() 7 | { 8 | QString unknown(QObject::tr("Unknown")); 9 | QString model = nullptr; 10 | QString speed = nullptr; 11 | 12 | try{ 13 | QStringList lines = CommandUtil::exec("bash",{"-c", LSCPU_COMMAND}).split('\n'); //run command in English language (guaratee same behaviour across languages) 14 | 15 | QRegExp regexp("\\s+"); 16 | QString space(" "); 17 | 18 | auto filterModel = lines.filter(QRegExp("^Model name")); 19 | QString modelLine = filterModel.isEmpty() ? "error missing model:error missing model" : filterModel.first(); 20 | auto filterSpeed = lines.filter(QRegExp("^CPU max MHz")); 21 | QString speedLine = "error:0.0"; 22 | if (filterSpeed.isEmpty()) 23 | { 24 | // fallback to CPU MHz 25 | filterSpeed = lines.filter(QRegExp("^CPU MHz")); 26 | speedLine = filterSpeed.isEmpty() ? speedLine : filterSpeed.first(); 27 | } 28 | 29 | model = modelLine.split(":").last(); 30 | speed = speedLine.split(":").last(); 31 | 32 | model = model.contains('@') ? model.split("@").first() : model; // intel : AMD 33 | speed = QString::number(speed.toDouble()/1000.0) + "GHz"; 34 | 35 | this->cpuModel = model.trimmed().replace(regexp, space); 36 | this->cpuSpeed = speed.trimmed().replace(regexp, space); 37 | } catch(QString &ex) { 38 | this->cpuModel = unknown; 39 | this->cpuSpeed = unknown; 40 | } 41 | 42 | CpuInfo ci; 43 | this->cpuCore = QString::number(ci.getCpuPhysicalCoreCount()); 44 | 45 | // get username 46 | QString name = qgetenv("USER"); 47 | 48 | if (name.isEmpty()) 49 | name = qgetenv("USERNAME"); 50 | 51 | try { 52 | if (name.isEmpty()) 53 | name = CommandUtil::exec("whoami").trimmed(); 54 | } catch (const QString &ex) { 55 | qCritical() << ex; 56 | } 57 | 58 | this->username = name; 59 | } 60 | 61 | QString SystemInfo::getUsername() const 62 | { 63 | return username; 64 | } 65 | 66 | QString SystemInfo::getHostname() const 67 | { 68 | return QSysInfo::machineHostName(); 69 | } 70 | 71 | QStringList SystemInfo::getUserList() const 72 | { 73 | QStringList passwdUsers = FileUtil::readListFromFile("/etc/passwd"); 74 | QStringList users; 75 | 76 | for(QString &row: passwdUsers) { 77 | users.append(row.split(":").at(0)); 78 | } 79 | 80 | return users; 81 | } 82 | 83 | QStringList SystemInfo::getGroupList() const 84 | { 85 | QStringList groupFile = FileUtil::readListFromFile("/etc/group"); 86 | QStringList groups; 87 | 88 | for(QString &row: groupFile) { 89 | groups.append(row.split(":").at(0)); 90 | } 91 | 92 | return groups; 93 | } 94 | 95 | QString SystemInfo::getPlatform() const 96 | { 97 | return QString("%1 %2") 98 | .arg(QSysInfo::kernelType()) 99 | .arg(QSysInfo::currentCpuArchitecture()); 100 | } 101 | 102 | QString SystemInfo::getDistribution() const 103 | { 104 | return QSysInfo::prettyProductName(); 105 | } 106 | 107 | QString SystemInfo::getKernel() const 108 | { 109 | return QSysInfo::kernelVersion(); 110 | } 111 | 112 | QString SystemInfo::getCpuModel() const 113 | { 114 | return this->cpuModel; 115 | } 116 | 117 | QString SystemInfo::getCpuSpeed() const 118 | { 119 | return this->cpuSpeed; 120 | } 121 | 122 | QString SystemInfo::getCpuCore() const 123 | { 124 | return this->cpuCore; 125 | } 126 | 127 | QFileInfoList SystemInfo::getCrashReports() const 128 | { 129 | QDir reports("/var/crash"); 130 | 131 | return reports.entryInfoList(QDir::Files); 132 | } 133 | 134 | QFileInfoList SystemInfo::getAppLogs() const 135 | { 136 | QDir logs("/var/log"); 137 | 138 | //remove only files not directory ex. apache2 (log directory) 139 | return logs.entryInfoList(QDir::Files | QDir::NoDotAndDotDot); 140 | } 141 | 142 | QFileInfoList SystemInfo::getAppCaches() const 143 | { 144 | QString homePath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); 145 | 146 | QDir caches(homePath + "/.cache"); 147 | 148 | return caches.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); 149 | } 150 | -------------------------------------------------------------------------------- /stacer-core/Info/system_info.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEMINFO_H 2 | #define SYSTEMINFO_H 3 | 4 | #include "Utils/file_util.h" 5 | #include "Utils/format_util.h" 6 | #include "Utils/command_util.h" 7 | #include "Info/cpu_info.h" 8 | 9 | #define LSCPU_COMMAND "LANG=nl_NL.UTF-8 lscpu" 10 | 11 | #include "stacer-core_global.h" 12 | 13 | class STACERCORESHARED_EXPORT SystemInfo 14 | { 15 | public: 16 | SystemInfo(); 17 | 18 | QString getHostname() const; 19 | QString getPlatform() const; 20 | QString getDistribution() const; 21 | QString getKernel() const; 22 | QString getCpuModel() const; 23 | QString getCpuSpeed() const; 24 | QString getCpuCore() const; 25 | QString getUsername() const; 26 | 27 | QFileInfoList getCrashReports() const; 28 | QFileInfoList getAppLogs() const; 29 | QFileInfoList getAppCaches() const; 30 | 31 | QStringList getUserList() const; 32 | QStringList getGroupList() const; 33 | 34 | private slots: 35 | private: 36 | QString cpuCore; 37 | QString cpuModel; 38 | QString cpuSpeed; 39 | QString username; 40 | }; 41 | 42 | #endif // SYSTEMINFO_H 43 | -------------------------------------------------------------------------------- /stacer-core/Tools/apt_source_tool.cpp: -------------------------------------------------------------------------------- 1 | #include "apt_source_tool.h" 2 | #include "Utils/command_util.h" 3 | #include "Utils/file_util.h" 4 | #include 5 | 6 | bool AptSourceTool::checkSourceRepository() 7 | { 8 | QDir sourceList(APT_SOURCES_LIST_D_PATH); 9 | 10 | bool isExists = sourceList.exists(); 11 | 12 | return isExists; 13 | } 14 | 15 | void AptSourceTool::removeAPTSource(const APTSourcePtr aptSource) 16 | { 17 | changeSource(aptSource, ""); 18 | } 19 | 20 | void AptSourceTool::addRepository(const QString &repository, const bool isSource) 21 | { 22 | if (! repository.isEmpty()) { 23 | QStringList args = { "-y", repository }; 24 | if (isSource) { 25 | args << "-s"; 26 | } 27 | 28 | CommandUtil::sudoExec("add-apt-repository", args); 29 | } 30 | } 31 | 32 | void AptSourceTool::changeSource(const APTSourcePtr aptSource, const QString newSource) 33 | { 34 | QStringList sourceFileContent = FileUtil::readListFromFile(aptSource->filePath); 35 | 36 | // find line index 37 | int pos = -1; 38 | for (int i = 0; i < sourceFileContent.count(); ++i) { 39 | int _pos = sourceFileContent[i].indexOf(aptSource->source); 40 | if (_pos != -1) { 41 | pos = i; 42 | break; 43 | } 44 | } 45 | 46 | if (pos != -1) { 47 | if (newSource.isEmpty()) { 48 | sourceFileContent.removeAt(pos); 49 | } else { 50 | sourceFileContent.replace(pos, newSource); 51 | } 52 | 53 | QStringList args = { aptSource->filePath }; 54 | 55 | QByteArray data = sourceFileContent.join('\n').append('\n').toUtf8(); 56 | 57 | CommandUtil::sudoExec("tee", args, data); 58 | } 59 | } 60 | 61 | void AptSourceTool::changeStatus(const APTSourcePtr aptSource, const bool status) 62 | { 63 | QString newSource = aptSource->source; 64 | 65 | newSource.replace("#", ""); 66 | 67 | if (! status) { // if is deactive 68 | newSource = "# " + newSource.trimmed(); 69 | } 70 | 71 | changeSource(aptSource, newSource); 72 | } 73 | 74 | QList AptSourceTool::getSourceList() 75 | { 76 | QList aptSourceList; 77 | 78 | QFileInfoList infoList = QDir(APT_SOURCES_LIST_D_PATH).entryInfoList({"*.list"}, QDir::Files, QDir::Time); 79 | infoList.append(QFileInfo(APT_SOURCES_LIST_PATH)); // sources.list 80 | 81 | // example "deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main" 82 | for (const QFileInfo &info : infoList) { 83 | 84 | QStringList fileContent = FileUtil::readListFromFile(info.absoluteFilePath()).filter(QRegExp("^\\s{0,}#{0,}\\s{0,}deb")); 85 | 86 | for (const QString &line : fileContent) { 87 | QString _line = line.trimmed(); 88 | 89 | APTSourcePtr aptSource(new APTSource); 90 | aptSource->filePath = info.absoluteFilePath(); 91 | 92 | aptSource->isActive = ! _line.startsWith(QChar('#')); 93 | 94 | _line.remove('#'); // remove comment 95 | 96 | // if has options 97 | QRegExp regexOption("(\\s[\\[]+.*[\\]]+)"); 98 | regexOption.indexIn(_line); 99 | if (regexOption.matchedLength() > 0) { 100 | aptSource->options = regexOption.cap().trimmed(); 101 | } 102 | // remove options 103 | _line.remove(regexOption); 104 | 105 | QStringList sourceColumns = _line.trimmed().split(QRegExp("\\s+")); 106 | bool isBinary = sourceColumns.first() == "deb"; 107 | bool isSource = sourceColumns.first() == "deb-src"; 108 | 109 | if ((isBinary || isSource) && sourceColumns.count() > 2) { 110 | aptSource->isSource = isSource; 111 | aptSource->uri = sourceColumns.at(1); 112 | aptSource->distribution = sourceColumns.at(2); 113 | aptSource->components = sourceColumns.mid(3).join(' '); 114 | 115 | aptSource->source = line.trimmed().remove('#').trimmed(); 116 | 117 | aptSourceList.append(aptSource); 118 | } 119 | } 120 | } 121 | 122 | return aptSourceList; 123 | } 124 | 125 | 126 | -------------------------------------------------------------------------------- /stacer-core/Tools/apt_source_tool.h: -------------------------------------------------------------------------------- 1 | #ifndef AptSourceTool_H 2 | #define AptSourceTool_H 3 | 4 | #include "Utils/command_util.h" 5 | #include "Utils/file_util.h" 6 | #include 7 | 8 | #define APT_SOURCES_LIST_D_PATH "/etc/apt/sources.list.d" 9 | #define APT_SOURCES_LIST_PATH "/etc/apt/sources.list" 10 | 11 | // isSource options uri distribution componentes 12 | // example "deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main" 13 | 14 | class APTSource { 15 | public: 16 | QString filePath; 17 | bool isSource; 18 | QString options; 19 | QString uri; 20 | QString distribution; 21 | QString components; 22 | 23 | QString source; 24 | bool isActive; 25 | }; 26 | 27 | typedef QSharedPointer APTSourcePtr; 28 | 29 | class AptSourceTool 30 | { 31 | public: 32 | static bool checkSourceRepository(); 33 | static QList getSourceList(); 34 | static void removeAPTSource(const APTSourcePtr aptSource); 35 | static void changeStatus(const APTSourcePtr aptSource, const bool status); 36 | static void changeSource(const APTSourcePtr aptSource, const QString newSource); 37 | static void addRepository(const QString &repository, const bool isSource); 38 | }; 39 | 40 | #endif // AptSourceTool_H 41 | -------------------------------------------------------------------------------- /stacer-core/Tools/gnome_schema.h: -------------------------------------------------------------------------------- 1 | #ifndef GNOMESCHEMA_H 2 | #define GNOMESCHEMA_H 3 | 4 | namespace GSchemaPaths { 5 | const QString Unity = "/org/compiz/profiles/unity/plugins/unityshell/"; 6 | const QString UnityLauncher = "/com/canonical/unity/launcher/"; 7 | const QString OpenGL = "/org/compiz/profiles/unity/plugins/opengl/"; 8 | const QString Core = "/org/compiz/profiles/unity/plugins/core/"; 9 | } 10 | 11 | namespace GSchemas { 12 | namespace Unity { 13 | const QString Shell = "org.compiz.unityshell"; 14 | const QString Launcher = "com.canonical.Unity.Launcher"; 15 | const QString Lens = "com.canonical.Unity.Lenses"; 16 | const QString AppLens = "com.canonical.Unity.ApplicationsLens"; 17 | const QString FileLens = "com.canonical.Unity.FilesLens"; 18 | const QString DateTime = "com.canonical.indicator.datetime"; 19 | const QString Sound = "com.canonical.indicator.sound"; 20 | const QString Session = "com.canonical.indicator.session"; 21 | } 22 | namespace Window { 23 | const QString OpenGL = "org.compiz.opengl"; 24 | const QString Core = "org.compiz.core"; 25 | const QString Preferences = "org.gnome.desktop.wm.preferences"; 26 | } 27 | namespace Appearance { 28 | const QString Desktop = "org.gnome.nautilus.desktop"; 29 | const QString Background = "org.gnome.desktop.background"; 30 | const QString Screensaver = "org.gnome.desktop.screensaver"; 31 | const QString Applications = "org.gnome.desktop.a11y.applications"; 32 | } 33 | } 34 | 35 | namespace GSchemaKeys { 36 | namespace Unity { 37 | const QString LauncherHideMode = "launcher-hide-mode"; 38 | const QString RevealTrigger = "reveal-trigger"; 39 | const QString EdgeResponsiveness = "edge-responsiveness"; 40 | const QString LauncherMinimizeApp = "launcher-minimize-window"; 41 | const QString LauncherOpacity = "launcher-opacity"; 42 | const QString LauncherVisibility = "num-launchers"; 43 | const QString LauncherPosition = "launcher-position"; 44 | const QString LauncherIconSize = "icon-size"; 45 | const QString DashBlur = "dash-blur-experimental"; 46 | const QString SearchOnlineResource = "remote-content-search"; 47 | const QString DisplayAvailableApps = "display-available-apps"; 48 | const QString DisplayRecentApps = "display-recent-apps"; 49 | const QString EnableSearchFile = "use-locate"; 50 | const QString PanelOpacity = "panel-opacity"; 51 | const QString ShowDateTime = "show-clock"; 52 | const QString TimeFormat = "time-format"; 53 | const QString ShowSeconds = "show-seconds"; 54 | const QString ShowDate = "show-date"; 55 | const QString ShowDay = "show-day"; 56 | const QString ShowCalendar = "show-calendar"; 57 | const QString ShowVolume = "visible"; 58 | const QString ShowMyName = "show-real-name-on-panel"; 59 | } 60 | 61 | namespace Window { 62 | const QString TextureQuality = "texture-filter"; 63 | const QString HorizontalWorkSize = "hsize"; 64 | const QString VerticalWorkSize = "vsize"; 65 | const QString RaiseOnClick = "raise-on-click"; 66 | const QString FocusMode = "focus-mode"; 67 | const QString ActionDoubleClick = "action-double-click-titlebar"; 68 | const QString ActionMiddleClick = "action-middle-click-titlebar"; 69 | const QString ActionRightClick = "action-right-click-titlebar"; 70 | } 71 | 72 | namespace Appearance { 73 | const QString ShowDesktopIcons = "show-desktop-icons"; 74 | const QString ShowHomeIcon = "home-icon-visible"; 75 | const QString ShowNetworkIcon = "network-icon-visible"; 76 | const QString ShowTrashIcon = "trash-icon-visible"; 77 | const QString ShowVolumesIcon = "volumes-visible"; 78 | const QString PictureOptions = "picture-options"; 79 | const QString ScreenKeyboard = "screen-keyboard-enabled"; 80 | const QString ScreenReader = "screen-reader-enabled"; 81 | } 82 | } 83 | 84 | namespace GValues { 85 | enum RevealLocation { 86 | Left, 87 | TopLeft 88 | }; 89 | 90 | enum LauncherVisibility { 91 | AllDesktop, 92 | PrimaryDesktop 93 | }; 94 | } 95 | 96 | #endif // GNOMESCHEMA_H 97 | -------------------------------------------------------------------------------- /stacer-core/Tools/gnome_settings_tool.cpp: -------------------------------------------------------------------------------- 1 | #include "gnome_settings_tool.h" 2 | #include "Utils/command_util.h" 3 | #include 4 | 5 | bool GnomeSettingsTool::checkGSettings() 6 | { 7 | return CommandUtil::isExecutable("gsettings"); 8 | } 9 | 10 | bool GnomeSettingsTool::checkUnityAvailable() 11 | { 12 | QStringList args = { "list-relocatable-schemas" }; 13 | 14 | try { 15 | QString result = CommandUtil::exec("gsettings", args); 16 | QStringList schemas = result.split('\n'); //.filter(QRegExp(GSchemas::Unity::Shell)); 17 | 18 | QStringList keys = { 19 | GSchemas::Unity::Shell, GSchemas::Unity::Launcher, GSchemas::Unity::Lens, GSchemas::Unity::AppLens, 20 | GSchemas::Unity::FileLens, GSchemas::Unity::DateTime, GSchemas::Unity::Sound, GSchemas::Unity::Session 21 | }; 22 | for (const QString schema: schemas) { 23 | if (! keys.contains(schema.trimmed())) { 24 | return false; 25 | } 26 | } 27 | 28 | } catch(const QString &ex) { 29 | qWarning() << ex; 30 | } 31 | 32 | return true; 33 | } 34 | 35 | QVariant GnomeSettingsTool::getValue(const QString schema, const QString key, const QString schemaPath) 36 | { 37 | QStringList args = { "get" }; 38 | 39 | if (schemaPath.isEmpty()) { 40 | args << schema; 41 | } else { 42 | args << QString("%1:%2").arg(schema).arg(schemaPath); 43 | } 44 | args << key; 45 | 46 | QString result; 47 | try { 48 | result = CommandUtil::exec("gsettings", args); 49 | } catch (const QString &ex) { 50 | qDebug() << ex; 51 | } 52 | 53 | return QVariant(result.trimmed()); 54 | } 55 | 56 | QString GnomeSettingsTool::getValueS(const QString schema, const QString key, const QString schemaPath) 57 | { 58 | return getValue(schema, key, schemaPath).toString(); 59 | } 60 | 61 | bool GnomeSettingsTool::getValueB(const QString schema, const QString key, const QString schemaPath) 62 | { 63 | return getValue(schema, key, schemaPath).toBool(); 64 | } 65 | 66 | int GnomeSettingsTool::getValueI(const QString schema, const QString key, const QString schemaPath) 67 | { 68 | return getValue(schema, key, schemaPath).toInt(); 69 | } 70 | 71 | float GnomeSettingsTool::getValueF(const QString schema, const QString key, const QString schemaPath) 72 | { 73 | return getValue(schema, key, schemaPath).toFloat(); 74 | } 75 | 76 | void GnomeSettingsTool::setValue(const QString schema, const QString key, const QVariant value, const QString schemaPath) 77 | { 78 | QStringList args = { "set" }; 79 | 80 | if (schemaPath.isEmpty()) { 81 | args << schema; 82 | } else { 83 | args << QString("%1:%2").arg(schema).arg(schemaPath); 84 | } 85 | args << key << value.toString(); 86 | 87 | try { 88 | CommandUtil::exec("gsettings", args); 89 | } catch (const QString &ex) { 90 | qDebug() << ex; 91 | } 92 | } 93 | 94 | void GnomeSettingsTool::setValueS(const QString schema, const QString key, const QString value, const QString schemaPath) 95 | { 96 | setValue(schema, key, QVariant(value), schemaPath); 97 | } 98 | 99 | void GnomeSettingsTool::setValueB(const QString schema, const QString key, const bool value, const QString schemaPath) 100 | { 101 | setValue(schema, key, QVariant(value), schemaPath); 102 | } 103 | 104 | void GnomeSettingsTool::setValueI(const QString schema, const QString key, const int value, const QString schemaPath) 105 | { 106 | setValue(schema, key, QVariant(value), schemaPath); 107 | } 108 | 109 | void GnomeSettingsTool::setValueF(const QString schema, const QString key, const float value, const QString schemaPath) 110 | { 111 | setValue(schema, key, QVariant(value), schemaPath); 112 | } 113 | -------------------------------------------------------------------------------- /stacer-core/Tools/gnome_settings_tool.h: -------------------------------------------------------------------------------- 1 | #ifndef GNOME_SETTINGS_TOOL_H 2 | #define GNOME_SETTINGS_TOOL_H 3 | 4 | #include 5 | #include "gnome_schema.h" 6 | 7 | #include "stacer-core_global.h" 8 | 9 | class STACERCORESHARED_EXPORT GnomeSettingsTool 10 | { 11 | public: 12 | static GnomeSettingsTool& ins() { 13 | static GnomeSettingsTool instance; 14 | return instance; 15 | } 16 | 17 | bool checkGSettings(); 18 | bool checkUnityAvailable(); 19 | 20 | QVariant getValue(const QString schema, const QString key, const QString schemaPath = QString()); 21 | void setValue(const QString schema, const QString key, const QVariant value, const QString schemaPath = QString()); 22 | 23 | QString getValueS(const QString schema, const QString key, const QString schemaPath = QString()); 24 | bool getValueB(const QString schema, const QString key, const QString schemaPath = QString()); 25 | int getValueI(const QString schema, const QString key, const QString schemaPath = QString()); 26 | float getValueF(const QString schema, const QString key, const QString schemaPath = QString()); 27 | 28 | void setValueS(const QString schema, const QString key, const QString value, const QString schemaPath = QString()); 29 | void setValueB(const QString schema, const QString key, const bool value, const QString schemaPath = QString()); 30 | void setValueI(const QString schema, const QString key, const int value, const QString schemaPath = QString()); 31 | void setValueF(const QString schema, const QString key, const float value, const QString schemaPath = QString()); 32 | }; 33 | 34 | #endif // GNOME_SETTINGS_TOOL_H 35 | -------------------------------------------------------------------------------- /stacer-core/Tools/package_tool.h: -------------------------------------------------------------------------------- 1 | #ifndef PACKAGE_TOOL_H 2 | #define PACKAGE_TOOL_H 3 | 4 | #include 5 | 6 | #include "Utils/command_util.h" 7 | #include "Utils/file_util.h" 8 | 9 | #include "stacer-core_global.h" 10 | 11 | class STACERCORESHARED_EXPORT PackageTool 12 | { 13 | public: 14 | enum PackageTools { 15 | APT, // debian 16 | DNF, // fedora 17 | YUM, // fedora 18 | PACMAN, // arch 19 | ZYPPER, // opensuse 20 | UNKNOWN 21 | }; 22 | 23 | public: 24 | // APT 25 | static QFileInfoList getDpkgPackageCaches(); 26 | static QStringList getDpkgPackages(); 27 | static bool dpkgRemovePackages(QStringList packages); 28 | 29 | // DNF - YUM 30 | static QStringList getRpmPackages(); 31 | static bool dnfRemovePackages(QStringList packages); 32 | static bool yumRemovePackages(QStringList packages); 33 | 34 | // Arch 35 | static QFileInfoList getPacmanPackageCaches(); 36 | static QStringList getPacmanPackages(); 37 | static bool pacmanRemovePackages(QStringList packages); 38 | 39 | // Snap 40 | static QStringList getSnapPackages(); 41 | static bool snapRemovePackages(QStringList packages); 42 | 43 | static const PackageTools currentPackageTool; 44 | }; 45 | 46 | #endif // PACKAGE_TOOL_H 47 | -------------------------------------------------------------------------------- /stacer-core/Tools/service_tool.cpp: -------------------------------------------------------------------------------- 1 | #include "service_tool.h" 2 | 3 | #include 4 | 5 | Service::Service(const QString &name, const QString description, const bool status, const bool active) : 6 | name(name), 7 | description(description), 8 | status(status), 9 | active(active) 10 | { } 11 | 12 | QList ServiceTool::getServicesWithSystemctl() 13 | { 14 | QList services = {}; 15 | 16 | try { 17 | 18 | QStringList args = { "list-unit-files", "-t", "service", "-a", "--state=enabled,disabled" }; 19 | 20 | QStringList lines = CommandUtil::exec("systemctl", args) 21 | .split(QChar('\n')) 22 | .filter(QRegExp("[^@].service")); 23 | 24 | QRegExp sep("\\s+"); 25 | services.reserve(lines.size()); 26 | for (const QString &line : lines) 27 | { 28 | // e.g apache2.service [enabled|disabled] 29 | QStringList s = line.trimmed().split(sep); 30 | 31 | QString name = s.first().trimmed().replace(".service", ""); 32 | QString description = getServiceDescription(s.first().trimmed()); 33 | bool status = ! s.last().trimmed().compare("enabled"); 34 | bool active = serviceIsActive(s.first().trimmed()); 35 | 36 | services.push_back({name, description, status, active}); 37 | } 38 | 39 | } catch(QString &ex) { 40 | qCritical() << ex; 41 | } 42 | 43 | return services; 44 | } 45 | 46 | QString ServiceTool::getServiceDescription(const QString &serviceName) 47 | { 48 | QStringList args = { "cat", serviceName }; 49 | 50 | QString result("Unknown"); 51 | 52 | try { 53 | QStringList content = CommandUtil::exec("systemctl", args) 54 | .split(QChar('\n')) 55 | .filter(QRegExp("^Description")); 56 | 57 | if (content.length() > 0) { 58 | QStringList desc = content.first().split(QChar('=')); 59 | if (desc.length() > 0) 60 | result = desc.last(); 61 | } 62 | } catch (QString &ex) { 63 | qCritical() << ex; 64 | } 65 | 66 | return result; 67 | } 68 | 69 | 70 | bool ServiceTool::serviceIsActive(const QString &serviceName) 71 | { 72 | QStringList args = { "is-active", serviceName }; 73 | 74 | QString result(""); 75 | 76 | try { 77 | result = CommandUtil::exec("systemctl", args); 78 | } catch(QString &ex) { 79 | qCritical() << ex; 80 | } 81 | 82 | return ! result.trimmed().compare("active"); 83 | } 84 | 85 | bool ServiceTool::serviceIsEnabled(const QString &serviceName) 86 | { 87 | QStringList args = { "is-enabled", serviceName }; 88 | 89 | QString result(""); 90 | 91 | try { 92 | result = CommandUtil::exec("systemctl", args); 93 | } catch(QString &ex) { 94 | qCritical() << ex; 95 | } 96 | 97 | return ! result.trimmed().compare("enabled"); 98 | } 99 | 100 | bool ServiceTool::changeServiceStatus(const QString &sname, bool status) 101 | { 102 | try { 103 | 104 | QStringList args = { (status ? "enable" : "disable") , sname }; 105 | 106 | CommandUtil::sudoExec("systemctl", args); 107 | 108 | return true; 109 | 110 | } catch(QString &ex) { 111 | qCritical() << ex; 112 | } 113 | 114 | return false; 115 | } 116 | 117 | bool ServiceTool::changeServiceActive(const QString &sname, bool status) 118 | { 119 | try { 120 | 121 | QStringList args = { (status ? "start" : "stop") , sname }; 122 | 123 | CommandUtil::sudoExec("systemctl", args); 124 | 125 | return true; 126 | 127 | } catch(QString &ex) { 128 | qCritical() << ex; 129 | } 130 | 131 | return false; 132 | } 133 | -------------------------------------------------------------------------------- /stacer-core/Tools/service_tool.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVICE_TOOL_H 2 | #define SERVICE_TOOL_H 3 | 4 | #include 5 | 6 | #include "stacer-core_global.h" 7 | 8 | class STACERCORESHARED_EXPORT Service 9 | { 10 | public: 11 | Service(const QString &name, const QString description, const bool status, const bool active); 12 | 13 | QString name; 14 | QString description; 15 | bool status; 16 | bool active; 17 | }; 18 | 19 | class STACERCORESHARED_EXPORT ServiceTool 20 | { 21 | public: 22 | static QList getServicesWithSystemctl(); 23 | static bool serviceIsActive(const QString &serviceName); 24 | static bool changeServiceStatus(const QString &sname, bool status); 25 | static bool changeServiceActive(const QString &sname, bool status); 26 | static bool serviceIsEnabled(const QString &serviceName); 27 | static QString getServiceDescription(const QString &serviceName); 28 | }; 29 | 30 | #endif // SERVICE_TOOL_H 31 | -------------------------------------------------------------------------------- /stacer-core/Utils/command_util.cpp: -------------------------------------------------------------------------------- 1 | #include "command_util.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | QString CommandUtil::sudoExec(const QString &cmd, QStringList args, QByteArray data) 11 | { 12 | args.push_front(cmd); 13 | 14 | QString result(""); 15 | 16 | try { 17 | result = CommandUtil::exec("pkexec", args, data); 18 | } catch (QString &ex) { 19 | qCritical() << ex; 20 | } 21 | 22 | return result; 23 | } 24 | 25 | QString CommandUtil::exec(const QString &cmd, QStringList args, QByteArray data) 26 | { 27 | std::unique_ptr process(new QProcess()); 28 | process->start(cmd, args); 29 | 30 | if (! data.isEmpty()) { 31 | process->write(data); 32 | process->waitForBytesWritten(); 33 | process->closeWriteChannel(); 34 | } 35 | 36 | // 10 minutes 37 | process->waitForFinished(600*1000); 38 | 39 | QTextStream stdOut(process->readAllStandardOutput()); 40 | 41 | QString err = process->errorString(); 42 | 43 | process->kill(); 44 | process->close(); 45 | 46 | if (process->error() != QProcess::UnknownError) 47 | throw err; 48 | 49 | return stdOut.readAll().trimmed(); 50 | } 51 | 52 | bool CommandUtil::isExecutable(const QString &cmd) 53 | { 54 | return !QStandardPaths::findExecutable(cmd).isEmpty(); 55 | } 56 | -------------------------------------------------------------------------------- /stacer-core/Utils/command_util.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMAND_UTIL_H 2 | #define COMMAND_UTIL_H 3 | 4 | #include 5 | 6 | #include "stacer-core_global.h" 7 | 8 | class STACERCORESHARED_EXPORT CommandUtil 9 | { 10 | public: 11 | static QString sudoExec(const QString &cmd, QStringList args = QStringList(), QByteArray data = QByteArray()); 12 | static QString exec(const QString &cmd, QStringList args = QStringList(), QByteArray data = QByteArray()); 13 | static bool isExecutable(const QString &cmd); 14 | }; 15 | 16 | #endif // COMMAND_UTIL_H 17 | -------------------------------------------------------------------------------- /stacer-core/Utils/file_util.cpp: -------------------------------------------------------------------------------- 1 | #include "file_util.h" 2 | 3 | FileUtil::FileUtil() 4 | { 5 | 6 | } 7 | 8 | QString FileUtil::readStringFromFile(const QString &path, const QIODevice::OpenMode &mode) 9 | { 10 | QSharedPointer file(new QFile(path)); 11 | 12 | QString data; 13 | 14 | if(file->open(mode)) { 15 | 16 | data = file->readAll(); 17 | 18 | file->close(); 19 | } 20 | 21 | return data; 22 | } 23 | 24 | QStringList FileUtil::readListFromFile(const QString &path, const QIODevice::OpenMode &mode) 25 | { 26 | QStringList list = FileUtil::readStringFromFile(path, mode).trimmed().split("\n"); 27 | 28 | return list; 29 | } 30 | 31 | bool FileUtil::writeFile(const QString &path, const QString &content, const QIODevice::OpenMode &mode) 32 | { 33 | QFile file(path); 34 | 35 | if(file.open(mode)) 36 | { 37 | QTextStream stream(&file); 38 | stream << content.toUtf8() << endl; 39 | 40 | file.close(); 41 | 42 | return true; 43 | } 44 | 45 | return false; 46 | } 47 | 48 | QStringList FileUtil::directoryList(const QString &path) 49 | { 50 | QDir dir(path); 51 | 52 | QStringList list; 53 | 54 | for (const QFileInfo &info : dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files)) 55 | list << info.fileName(); 56 | 57 | return list; 58 | } 59 | 60 | quint64 FileUtil::getFileSize(const QString &path) 61 | { 62 | quint64 totalSize = 0; 63 | 64 | QFileInfo info(path); 65 | 66 | if (info.exists()) 67 | { 68 | if (info.isFile()) { 69 | totalSize += info.size(); 70 | } 71 | else if (info.isDir()) { 72 | 73 | QDir dir(path); 74 | 75 | for (const QFileInfo &i : dir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs)) { 76 | totalSize += getFileSize(i.absoluteFilePath()); 77 | } 78 | } 79 | } 80 | 81 | return totalSize; 82 | } 83 | 84 | 85 | -------------------------------------------------------------------------------- /stacer-core/Utils/file_util.h: -------------------------------------------------------------------------------- 1 | #ifndef FILEUTIL_H 2 | #define FILEUTIL_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include "stacer-core_global.h" 14 | 15 | class STACERCORESHARED_EXPORT FileUtil 16 | { 17 | public: 18 | static QString readStringFromFile(const QString &path, const QIODevice::OpenMode &mode = QIODevice::ReadOnly); 19 | static QStringList readListFromFile(const QString &path, const QIODevice::OpenMode &mode = QIODevice::ReadOnly); 20 | 21 | static bool writeFile(const QString &path, const QString &content, const QIODevice::OpenMode &mode = QIODevice::WriteOnly | QIODevice::Truncate); 22 | static QStringList directoryList(const QString &path); 23 | static quint64 getFileSize(const QString &path); 24 | 25 | private: 26 | FileUtil(); 27 | }; 28 | 29 | #endif // FILEUTIL_H 30 | -------------------------------------------------------------------------------- /stacer-core/Utils/format_util.cpp: -------------------------------------------------------------------------------- 1 | #include "format_util.h" 2 | 3 | #include 4 | 5 | QString FormatUtil::formatBytes(const quint64 &bytes) 6 | { 7 | #define formatUnit(v, u, t) QString().sprintf("%.1f %s", \ 8 | ((double) v / (double) u), t) 9 | 10 | if (bytes == 1L) // bytes 11 | return QString("%1 byte").arg(bytes); 12 | else if (bytes < KIBI) // bytes 13 | return QString("%1 bytes").arg(bytes); 14 | else if (bytes < MEBI) // KiB 15 | return formatUnit(bytes, KIBI, "KiB"); 16 | else if (bytes < GIBI) // MiB 17 | return formatUnit(bytes, MEBI, "MiB"); 18 | else if (bytes < TEBI) // GiB 19 | return formatUnit(bytes, GIBI, "GiB"); 20 | else // TiB 21 | return formatUnit(bytes, TEBI, "TiB"); 22 | #undef formatUnit 23 | } 24 | -------------------------------------------------------------------------------- /stacer-core/Utils/format_util.h: -------------------------------------------------------------------------------- 1 | #ifndef FORMAT_UTIL_H 2 | #define FORMAT_UTIL_H 3 | 4 | #include "stacer-core_global.h" 5 | 6 | class STACERCORESHARED_EXPORT FormatUtil 7 | { 8 | public: 9 | static QString formatBytes(const quint64 &bytes); 10 | 11 | public: 12 | static const quint64 KIBI = 1024; 13 | static const quint64 MEBI = 1048576; 14 | static const quint64 GIBI = 1073741824; 15 | static const quint64 TEBI = 1099511627776; 16 | }; 17 | 18 | #endif // FORMAT_UTIL_H 19 | -------------------------------------------------------------------------------- /stacer-core/stacer-core.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-07-02T15:48:51 4 | # 5 | #------------------------------------------------- 6 | 7 | QT -= gui 8 | 9 | QT += core network 10 | 11 | CONFIG += c++11 12 | 13 | TARGET = stacer-core 14 | TEMPLATE = lib 15 | 16 | DEFINES += STACERCORE_LIBRARY 17 | 18 | # The following define makes your compiler emit warnings if you use 19 | # any feature of Qt which as been marked as deprecated (the exact warnings 20 | # depend on your compiler). Please consult the documentation of the 21 | # deprecated API in order to know how to port your code away from it. 22 | DEFINES += QT_DEPRECATED_WARNINGS 23 | 24 | # You can also make your code fail to compile if you use deprecated APIs. 25 | # In order to do so, uncomment the following line. 26 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 27 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 28 | 29 | SOURCES += \ 30 | Utils/command_util.cpp \ 31 | Utils/file_util.cpp \ 32 | Info/network_info.cpp \ 33 | Info/cpu_info.cpp \ 34 | Info/disk_info.cpp \ 35 | Info/memory_info.cpp \ 36 | Info/system_info.cpp \ 37 | Utils/format_util.cpp \ 38 | Tools/service_tool.cpp \ 39 | Tools/package_tool.cpp \ 40 | Info/process_info.cpp \ 41 | Info/process.cpp \ 42 | Tools/apt_source_tool.cpp \ 43 | Tools/gnome_settings_tool.cpp 44 | 45 | HEADERS += \ 46 | stacer-core_global.h \ 47 | Utils/command_util.h \ 48 | Info/network_info.h \ 49 | Info/cpu_info.h \ 50 | Info/disk_info.h \ 51 | Info/memory_info.h \ 52 | Info/system_info.h \ 53 | Utils/format_util.h \ 54 | Utils/file_util.h \ 55 | Tools/service_tool.h \ 56 | Tools/package_tool.h \ 57 | Info/process_info.h \ 58 | Info/process.h \ 59 | Tools/apt_source_tool.h \ 60 | Tools/gnome_settings_tool.h \ 61 | Tools/gnome_schema.h 62 | 63 | unix { 64 | target.path = /usr/lib 65 | INSTALLS += target 66 | } 67 | -------------------------------------------------------------------------------- /stacer-core/stacer-core_global.h: -------------------------------------------------------------------------------- 1 | #ifndef STACERCORE_GLOBAL_H 2 | #define STACERCORE_GLOBAL_H 3 | 4 | #include 5 | 6 | #if defined(STACERCORE_LIBRARY) 7 | # define STACERCORESHARED_EXPORT Q_DECL_EXPORT 8 | #else 9 | # define STACERCORESHARED_EXPORT Q_DECL_IMPORT 10 | #endif 11 | 12 | #endif // STACERCORE_GLOBAL_H 13 | -------------------------------------------------------------------------------- /stacer/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.1 FATAL_ERROR) 3 | project(stacer) 4 | 5 | set(MANAGERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Managers") 6 | set(PAGES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Pages") 7 | 8 | include_directories( 9 | "${PROJECT_ROOT}/stacer-core" 10 | "${CMAKE_CURRENT_SOURCE_DIR}" 11 | "${MANAGERS_DIR}" 12 | "${PAGES_DIR}/Dashboard" 13 | "${PAGES_DIR}/Processes" 14 | "${PAGES_DIR}/Resources" 15 | "${PAGES_DIR}/Services" 16 | "${PAGES_DIR}/Settings" 17 | "${PAGES_DIR}/StartupApps" 18 | "${PAGES_DIR}/SystemCleaner" 19 | "${PAGES_DIR}/Uninstaller" 20 | "${CMAKE_CURRENT_BINARY_DIR}" # Necessary for CMake 3.7 and older 21 | ) 22 | 23 | # Sources 24 | file(GLOB_RECURSE ${PROJECT_NAME}_srcs "${CMAKE_CURRENT_SOURCE_DIR}/**.cpp") 25 | file(GLOB_RECURSE ${PROJECT_NAME}_translations "${PROJECT_ROOT}/translations/**.ts") 26 | 27 | # Translations 28 | find_package(Qt5LinguistTools) 29 | qt5_create_translation(QM_FILES ${PROJECT_NAME}_translations ${${PROJECT_NAME}_srcs}) 30 | set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${QM_FILES}") 31 | 32 | set(CMAKE_AUTOUIC ON) 33 | set(CMAKE_AUTORCC ON) 34 | 35 | add_executable(${PROJECT_NAME} 36 | ${${PROJECT_NAME}_srcs} 37 | "${CMAKE_CURRENT_SOURCE_DIR}/static.qrc" 38 | ${QM_FILES} 39 | ) 40 | 41 | target_link_libraries(${PROJECT_NAME} 42 | stacer-core Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Charts Qt5::Svg Qt5::Concurrent 43 | ) 44 | 45 | # Running LTO in Release builds, if the C++ compiler is GNU GCC 46 | if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") 47 | target_compile_options(${PROJECT_NAME} PRIVATE "-flto") 48 | list(APPEND CMAKE_EXE_LINKER_FLAGS "-flto") 49 | endif() 50 | 51 | install( 52 | TARGETS ${PROJECT_NAME} 53 | CONFIGURATIONS Release RelWithDebInfo MinSizeRel # Not allowing to install an unoptimized build 54 | RUNTIME DESTINATION bin 55 | ) 56 | 57 | install( 58 | FILES "${PROJECT_ROOT}/applications/stacer.desktop" 59 | DESTINATION share/applications 60 | CONFIGURATIONS Release RelWithDebInfo MinSizeRel 61 | ) 62 | 63 | install( 64 | FILES "${PROJECT_ROOT}/stacer/static/logo.png" 65 | DESTINATION share/icons 66 | CONFIGURATIONS Release RelWithDebInfo MinSizeRel 67 | RENAME stacer.png 68 | ) 69 | -------------------------------------------------------------------------------- /stacer/Managers/app_manager.cpp: -------------------------------------------------------------------------------- 1 | #include "app_manager.h" 2 | #include 3 | 4 | AppManager *AppManager::instance = nullptr; 5 | 6 | AppManager *AppManager::ins() 7 | { 8 | if (! instance) { 9 | instance = new AppManager; 10 | } 11 | 12 | return instance; 13 | } 14 | 15 | AppManager::AppManager() 16 | { 17 | mSettingManager = SettingManager::ins(); 18 | 19 | mTrayIcon = new QSystemTrayIcon(QIcon(":/static/themes/default/img/sidebar-icons/dash.png")); 20 | 21 | loadLanguageList(); 22 | 23 | // loadThemeList(); 24 | 25 | if (mTranslator.load(QString("stacer_%1").arg(mSettingManager->getLanguage()), qApp->applicationDirPath() + "/translations")) { 26 | qApp->installTranslator(&mTranslator); 27 | (mSettingManager->getLanguage() == "ar") ? qApp->setLayoutDirection(Qt::RightToLeft) : qApp->setLayoutDirection(Qt::LeftToRight); 28 | } 29 | } 30 | 31 | QSystemTrayIcon *AppManager::getTrayIcon() 32 | { 33 | return mTrayIcon; 34 | } 35 | 36 | QSettings *AppManager::getStyleValues() const 37 | { 38 | return mStyleValues; 39 | } 40 | 41 | void AppManager::loadLanguageList() 42 | { 43 | QByteArray lanuagesJson = FileUtil::readStringFromFile(":/static/languages.json").toUtf8(); 44 | QJsonArray lanuages = QJsonDocument::fromJson(lanuagesJson).array(); 45 | 46 | for (int i = 0; i < lanuages.count(); ++i) { 47 | 48 | QJsonObject ob = lanuages.at(i).toObject(); 49 | 50 | mLanguageList.insert(ob["value"].toString(), ob["text"].toString()); 51 | } 52 | } 53 | 54 | QMap AppManager::getLanguageList() const 55 | { 56 | return mLanguageList; 57 | } 58 | 59 | //void AppManager::loadThemeList() 60 | //{ 61 | // QByteArray themesJson = FileUtil::readStringFromFile(":/static/themes.json").toUtf8(); 62 | // QJsonArray themes = QJsonDocument::fromJson(themesJson).array(); 63 | 64 | // for (int i = 0; i < themes.count(); ++i) { 65 | 66 | // QJsonObject ob = themes.at(i).toObject(); 67 | 68 | // mThemeList.insert(ob["value"].toString(), ob["text"].toString()); 69 | // } 70 | //} 71 | 72 | //QMap AppManager::getThemeList() const 73 | //{ 74 | // return mThemeList; 75 | //} 76 | 77 | void AppManager::updateStylesheet() 78 | { 79 | QString appThemePath = QString(":/static/themes/%1/style").arg(mSettingManager->getThemeName()); 80 | mStyleValues = new QSettings(QString("%1/values.ini").arg(appThemePath), QSettings::IniFormat); 81 | 82 | mStylesheetFileContent = FileUtil::readStringFromFile(QString("%1/style.qss").arg(appThemePath)); 83 | 84 | // set values example: @color01 => #fff 85 | for (const QString &key : mStyleValues->allKeys()) { 86 | mStylesheetFileContent.replace(key, mStyleValues->value(key).toString()); 87 | } 88 | 89 | qApp->setStyleSheet(mStylesheetFileContent); 90 | 91 | emit SignalMapper::ins()->sigChangedAppTheme(); 92 | } 93 | 94 | QString AppManager::getStylesheetFileContent() const 95 | { 96 | return mStylesheetFileContent; 97 | } 98 | -------------------------------------------------------------------------------- /stacer/Managers/app_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_MANAGER_H 2 | #define APP_MANAGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "Utils/file_util.h" 14 | #include "Managers/setting_manager.h" 15 | #include "signal_mapper.h" 16 | 17 | class AppManager 18 | { 19 | 20 | public: 21 | static AppManager *ins(); 22 | 23 | QMap getLanguageList() const; 24 | void loadLanguageList(); 25 | 26 | // QMap getThemeList() const; 27 | // void loadThemeList(); 28 | 29 | void updateStylesheet(); 30 | QString getStylesheetFileContent() const; 31 | 32 | QSettings *getStyleValues() const; 33 | 34 | QSystemTrayIcon *getTrayIcon(); 35 | 36 | private: 37 | static AppManager *instance; 38 | AppManager(); 39 | 40 | private: 41 | QTranslator mTranslator; 42 | QSystemTrayIcon *mTrayIcon; 43 | 44 | QSettings *mStyleValues; 45 | 46 | QMap mLanguageList; 47 | // QMap mThemeList; 48 | QString mStylesheetFileContent; 49 | 50 | SettingManager *mSettingManager; 51 | }; 52 | 53 | #endif // APP_MANAGER_H 54 | -------------------------------------------------------------------------------- /stacer/Managers/info_manager.cpp: -------------------------------------------------------------------------------- 1 | #include "info_manager.h" 2 | 3 | InfoManager *InfoManager::instance = nullptr; 4 | 5 | InfoManager *InfoManager::ins() 6 | { 7 | if(! instance){ 8 | instance = new InfoManager; 9 | } 10 | 11 | return instance; 12 | } 13 | 14 | QString InfoManager::getUserName() const 15 | { 16 | return si.getUsername(); 17 | } 18 | 19 | QStringList InfoManager::getUserList() const 20 | { 21 | return si.getUserList(); 22 | } 23 | 24 | QStringList InfoManager::getGroupList() const 25 | { 26 | return si.getGroupList(); 27 | } 28 | 29 | /* 30 | * CPU Provider 31 | */ 32 | int InfoManager::getCpuCoreCount() const 33 | { 34 | return ci.getCpuCoreCount(); 35 | } 36 | 37 | QList InfoManager::getCpuPercents() const 38 | { 39 | return ci.getCpuPercents(); 40 | } 41 | 42 | QList InfoManager::getCpuLoadAvgs() const 43 | { 44 | return ci.getLoadAvgs(); 45 | } 46 | 47 | double InfoManager::getCpuClock() const 48 | { 49 | return ci.getAvgClock(); 50 | } 51 | 52 | /* 53 | * Memory Provider 54 | */ 55 | void InfoManager::updateMemoryInfo() 56 | { 57 | mi.updateMemoryInfo(); 58 | } 59 | 60 | quint64 InfoManager::getSwapUsed() const 61 | { 62 | return mi.getSwapUsed(); 63 | } 64 | 65 | quint64 InfoManager::getSwapTotal() const 66 | { 67 | return mi.getSwapTotal(); 68 | } 69 | 70 | quint64 InfoManager::getMemUsed() const 71 | { 72 | return mi.getMemUsed(); 73 | } 74 | 75 | quint64 InfoManager::getMemTotal() const 76 | { 77 | return mi.getMemTotal(); 78 | } 79 | 80 | /* 81 | * Disk Provider 82 | */ 83 | QList InfoManager::getDisks() const 84 | { 85 | return di.getDisks(); 86 | } 87 | 88 | void InfoManager::updateDiskInfo() 89 | { 90 | di.updateDiskInfo(); 91 | } 92 | 93 | QList InfoManager::getDiskIO() 94 | { 95 | return di.getDiskIO(); 96 | } 97 | 98 | QList InfoManager::getFileSystemTypes() 99 | { 100 | return di.fileSystemTypes(); 101 | } 102 | 103 | QList InfoManager::getDevices() 104 | { 105 | return di.devices(); 106 | } 107 | 108 | /******************** 109 | * Network Provider 110 | *******************/ 111 | quint64 InfoManager::getRXbytes() const 112 | { 113 | return ni.getRXbytes(); 114 | } 115 | 116 | quint64 InfoManager::getTXbytes() const 117 | { 118 | return ni.getTXbytes(); 119 | } 120 | 121 | /******************** 122 | * System Provider 123 | *******************/ 124 | QFileInfoList InfoManager::getCrashReports() const 125 | { 126 | return si.getCrashReports(); 127 | } 128 | 129 | QFileInfoList InfoManager::getAppLogs() const 130 | { 131 | return si.getAppLogs(); 132 | } 133 | 134 | QFileInfoList InfoManager::getAppCaches() const 135 | { 136 | return si.getAppCaches(); 137 | } 138 | 139 | /******************** 140 | * Process Provider 141 | *******************/ 142 | void InfoManager::updateProcesses() 143 | { 144 | pi.updateProcesses(); 145 | } 146 | 147 | QList InfoManager::getProcesses() const 148 | { 149 | return pi.getProcessList(); 150 | } 151 | 152 | 153 | -------------------------------------------------------------------------------- /stacer/Managers/info_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef INFO_MANAGER_H 2 | #define INFO_MANAGER_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class InfoManager 14 | { 15 | public: 16 | static InfoManager *ins(); 17 | 18 | int getCpuCoreCount() const; 19 | QList getCpuPercents() const; 20 | QList getCpuLoadAvgs() const; 21 | double getCpuClock() const; 22 | 23 | quint64 getSwapUsed() const; 24 | quint64 getSwapTotal() const; 25 | quint64 getMemUsed() const; 26 | quint64 getMemTotal() const; 27 | void updateMemoryInfo(); 28 | 29 | quint64 getRXbytes() const; 30 | quint64 getTXbytes() const; 31 | 32 | QList getDisks() const; 33 | QList getDiskIO(); 34 | void updateDiskInfo(); 35 | 36 | QFileInfoList getCrashReports() const; 37 | QFileInfoList getAppLogs() const; 38 | QFileInfoList getAppCaches() const; 39 | 40 | void updateProcesses(); 41 | QList getProcesses() const; 42 | QString getUserName() const; 43 | QStringList getUserList() const; 44 | QStringList getGroupList() const; 45 | 46 | QList getDevices(); 47 | QList getFileSystemTypes(); 48 | private: 49 | static InfoManager *instance; 50 | 51 | private: 52 | CpuInfo ci; 53 | DiskInfo di; 54 | MemoryInfo mi; 55 | NetworkInfo ni; 56 | SystemInfo si; 57 | ProcessInfo pi; 58 | }; 59 | 60 | #endif // INFO_MANAGER_H 61 | -------------------------------------------------------------------------------- /stacer/Managers/setting_manager.cpp: -------------------------------------------------------------------------------- 1 | #include "setting_manager.h" 2 | 3 | SettingManager::SettingManager() 4 | { 5 | mConfigPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); 6 | mSettings = new QSettings(QString("%1/settings.ini").arg(mConfigPath), QSettings::IniFormat); 7 | } 8 | 9 | SettingManager *SettingManager::instance = nullptr; 10 | 11 | SettingManager* SettingManager::ins() 12 | { 13 | if (! instance) { 14 | instance = new SettingManager; 15 | } 16 | return instance; 17 | } 18 | 19 | QString SettingManager::getConfigPath() const 20 | { 21 | return mConfigPath; 22 | } 23 | 24 | void SettingManager::setLanguage(const QString &value) 25 | { 26 | mSettings->setValue(SettingKeys::Language, value); 27 | } 28 | 29 | QString SettingManager::getLanguage() const 30 | { 31 | return mSettings->value(SettingKeys::Language, "en").toString(); 32 | } 33 | 34 | void SettingManager::setThemeName(const QString &value) 35 | { 36 | mSettings->setValue(SettingKeys::ThemeName, value); 37 | } 38 | 39 | QString SettingManager::getThemeName() const 40 | { 41 | return "default"; //mSettings->value(SettingKeys::ThemeName, "default").toString(); 42 | } 43 | 44 | void SettingManager::setDiskName(const QString &value) 45 | { 46 | mSettings->setValue(SettingKeys::DiskName, value); 47 | } 48 | 49 | QString SettingManager::getDiskName() const 50 | { 51 | return mSettings->value(SettingKeys::DiskName, "").toString(); 52 | } 53 | 54 | void SettingManager::setStartPage(const QString &value) 55 | { 56 | mSettings->setValue(SettingKeys::StartPage, value); 57 | } 58 | 59 | QString SettingManager::getStartPage() const 60 | { 61 | return mSettings->value(SettingKeys::StartPage, QObject::tr("Dashboard")).toString(); 62 | } 63 | 64 | void SettingManager::setCpuAlertPercent(const int value) 65 | { 66 | mSettings->setValue(SettingKeys::CPUAlertPercent, value); 67 | } 68 | 69 | int SettingManager::getCpuAlertPercent() const 70 | { 71 | return mSettings->value(SettingKeys::CPUAlertPercent, 0).toInt(); 72 | } 73 | 74 | void SettingManager::setMemoryAlertPercent(const int value) 75 | { 76 | mSettings->setValue(SettingKeys::MemoryAlertPercent, value); 77 | } 78 | 79 | int SettingManager::getMemoryAlertPercent() const 80 | { 81 | return mSettings->value(SettingKeys::MemoryAlertPercent, 0).toInt(); 82 | } 83 | 84 | void SettingManager::setDiskAlertPercent(const int value) 85 | { 86 | mSettings->setValue(SettingKeys::DiskAlertPercent, value); 87 | } 88 | 89 | int SettingManager::getDiskAlertPercent() const 90 | { 91 | return mSettings->value(SettingKeys::DiskAlertPercent, 0).toInt(); 92 | } 93 | 94 | void SettingManager::setAppQuitDialogDontAsk(const bool value) 95 | { 96 | mSettings->setValue(SettingKeys::AppQuitDialogDontAsk, value); 97 | } 98 | 99 | bool SettingManager::getAppQuitDialogDontAsk() const 100 | { 101 | return mSettings->value(SettingKeys::AppQuitDialogDontAsk, false).toBool(); 102 | } 103 | 104 | void SettingManager::setAppQuitDialogChoice(const QString &value) 105 | { 106 | mSettings->setValue(SettingKeys::AppQuitDialogChoice, value); 107 | } 108 | 109 | QString SettingManager::getAppQuitDialogChoice() const 110 | { 111 | return mSettings->value(SettingKeys::AppQuitDialogChoice, "close").toString(); 112 | } 113 | -------------------------------------------------------------------------------- /stacer/Managers/setting_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef SETTING_MANAGER_H 2 | #define SETTING_MANAGER_H 3 | 4 | #include 5 | #include 6 | 7 | namespace SettingKeys { 8 | const QString ThemeName("ThemeName"); 9 | const QString Language("Language"); 10 | const QString DiskName("DiskName"); 11 | const QString StartPage("StartPage"); 12 | const QString CPUAlertPercent("CPUAlertPercent"); 13 | const QString MemoryAlertPercent("MemoryAlertPercent"); 14 | const QString DiskAlertPercent("DiskAlertPercent"); 15 | const QString AppQuitDialogDontAsk("AppQuitDialogDontAsk"); 16 | const QString AppQuitDialogChoice("AppQuitDialogChoice"); 17 | } 18 | 19 | class SettingManager 20 | { 21 | public: 22 | static SettingManager *ins(); 23 | 24 | QString getConfigPath() const; 25 | 26 | void setLanguage(const QString &value); 27 | QString getLanguage() const; 28 | 29 | void setThemeName(const QString &value); 30 | QString getThemeName() const; 31 | 32 | void setDiskName(const QString &value); 33 | QString getDiskName() const; 34 | 35 | void setStartPage(const QString &value); 36 | QString getStartPage() const; 37 | 38 | void setCpuAlertPercent(const int value); 39 | int getCpuAlertPercent() const; 40 | 41 | void setMemoryAlertPercent(const int value); 42 | int getMemoryAlertPercent() const; 43 | 44 | void setDiskAlertPercent(const int value); 45 | int getDiskAlertPercent() const; 46 | 47 | void setAppQuitDialogDontAsk(const bool value); 48 | bool getAppQuitDialogDontAsk() const; 49 | 50 | void setAppQuitDialogChoice(const QString &value); 51 | QString getAppQuitDialogChoice() const; 52 | 53 | private: 54 | static SettingManager *instance; 55 | SettingManager(); 56 | 57 | QSettings *mSettings; 58 | QString mConfigPath; 59 | }; 60 | 61 | #endif // SETTING_MANAGER_H 62 | -------------------------------------------------------------------------------- /stacer/Managers/tool_manager.cpp: -------------------------------------------------------------------------------- 1 | #include "tool_manager.h" 2 | 3 | ToolManager *ToolManager::instance = NULL; 4 | 5 | ToolManager *ToolManager::ins() 6 | { 7 | if(! instance) { 8 | instance = new ToolManager; 9 | } 10 | 11 | return instance; 12 | } 13 | 14 | /* 15 | * Services 16 | */ 17 | QList ToolManager::getServices() const 18 | { 19 | return ServiceTool::getServicesWithSystemctl(); 20 | } 21 | 22 | bool ToolManager::changeServiceStatus(const QString &sname, bool status) const 23 | { 24 | return ServiceTool::changeServiceStatus(sname, status); 25 | } 26 | 27 | bool ToolManager::changeServiceActive(const QString &sname, bool status) const 28 | { 29 | return ServiceTool::changeServiceActive(sname, status); 30 | } 31 | 32 | bool ToolManager::serviceIsActive(const QString &sname) const 33 | { 34 | return ServiceTool::serviceIsActive(sname); 35 | } 36 | 37 | bool ToolManager::serviceIsEnabled(const QString &sname) const 38 | { 39 | return ServiceTool::serviceIsEnabled(sname); 40 | } 41 | 42 | /* 43 | * Packages 44 | */ 45 | QStringList ToolManager::getPackages() const 46 | { 47 | switch (PackageTool::currentPackageTool) { 48 | case PackageTool::PackageTools::APT: 49 | return PackageTool::getDpkgPackages(); 50 | break; 51 | case PackageTool::PackageTools::YUM: 52 | case PackageTool::PackageTools::DNF: 53 | return PackageTool::getRpmPackages(); 54 | break; 55 | case PackageTool::PackageTools::PACMAN: 56 | return PackageTool::getPacmanPackages(); 57 | break; 58 | default: 59 | return QStringList(); 60 | break; 61 | } 62 | } 63 | 64 | QStringList ToolManager::getSnapPackages() const 65 | { 66 | return PackageTool::getSnapPackages(); 67 | } 68 | 69 | bool ToolManager::uninstallSnapPackages(const QStringList packages) 70 | { 71 | return PackageTool::snapRemovePackages(packages); 72 | } 73 | 74 | QFileInfoList ToolManager::getPackageCaches() const 75 | { 76 | switch (PackageTool::currentPackageTool) { 77 | case PackageTool::PackageTools::APT: 78 | return PackageTool::getDpkgPackageCaches(); 79 | break; 80 | case PackageTool::PackageTools::YUM: 81 | case PackageTool::PackageTools::DNF: 82 | return PackageTool::getPacmanPackageCaches(); 83 | break; 84 | case PackageTool::PackageTools::PACMAN: 85 | return PackageTool::getPacmanPackageCaches(); 86 | break; 87 | default: 88 | return QFileInfoList(); 89 | break; 90 | } 91 | } 92 | 93 | void ToolManager::uninstallPackages(const QStringList &packages) 94 | { 95 | switch (PackageTool::currentPackageTool) { 96 | case PackageTool::PackageTools::APT: 97 | PackageTool::dpkgRemovePackages(packages); 98 | break; 99 | case PackageTool::PackageTools::YUM: 100 | PackageTool::yumRemovePackages(packages); 101 | break; 102 | case PackageTool::PackageTools::DNF: 103 | PackageTool::dnfRemovePackages(packages); 104 | break; 105 | case PackageTool::PackageTools::PACMAN: 106 | PackageTool::pacmanRemovePackages(packages); 107 | break; 108 | default: 109 | break; 110 | } 111 | } 112 | 113 | /* 114 | * APT Source 115 | */ 116 | bool ToolManager::checkSourceRepository() const 117 | { 118 | return AptSourceTool::checkSourceRepository(); 119 | } 120 | 121 | QList ToolManager::getSourceList() const 122 | { 123 | return AptSourceTool::getSourceList(); 124 | } 125 | 126 | void ToolManager::removeAPTSource(const APTSourcePtr source) 127 | { 128 | AptSourceTool::removeAPTSource(source); 129 | } 130 | 131 | void ToolManager::changeAPTStatus(const APTSourcePtr aptSource, const bool status) 132 | { 133 | AptSourceTool::changeStatus(aptSource, status); 134 | } 135 | 136 | void ToolManager::changeAPTSource(const APTSourcePtr aptSource, const QString newSource) 137 | { 138 | AptSourceTool::changeSource(aptSource, newSource); 139 | } 140 | 141 | void ToolManager::addAPTRepository(const QString &repository, const bool isSource) 142 | { 143 | AptSourceTool::addRepository(repository, isSource); 144 | } 145 | 146 | -------------------------------------------------------------------------------- /stacer/Managers/tool_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef TOOL_MANAGER_H 2 | #define TOOL_MANAGER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class ToolManager 9 | { 10 | public: 11 | static ToolManager *ins(); 12 | 13 | QList getServices() const; 14 | QStringList getPackages() const; 15 | QStringList getSnapPackages() const; 16 | QFileInfoList getPackageCaches() const; 17 | 18 | bool changeServiceStatus(const QString &sname, bool status) const; 19 | bool changeServiceActive(const QString &sname, bool status) const; 20 | bool serviceIsActive(const QString &sname) const; 21 | bool serviceIsEnabled(const QString &sname) const; 22 | 23 | void uninstallPackages(const QStringList &packages); 24 | bool uninstallSnapPackages(const QStringList packages); 25 | 26 | bool checkSourceRepository() const; 27 | QList getSourceList() const; 28 | void removeAPTSource(const APTSourcePtr source); 29 | void changeAPTStatus(const APTSourcePtr aptSource, const bool status); 30 | void changeAPTSource(const APTSourcePtr aptSource, const QString newSource); 31 | void addAPTRepository(const QString &repository, const bool isSource); 32 | 33 | private: 34 | static ToolManager *instance; 35 | }; 36 | 37 | #endif // TOOL_MANAGER_H 38 | -------------------------------------------------------------------------------- /stacer/Pages/AptSourceManager/apt_source_edit.cpp: -------------------------------------------------------------------------------- 1 | #include "apt_source_edit.h" 2 | #include "ui_apt_source_edit.h" 3 | 4 | #include 5 | 6 | APTSourceEdit::~APTSourceEdit() 7 | { 8 | delete ui; 9 | } 10 | 11 | APTSourcePtr APTSourceEdit::selectedAptSource = nullptr; 12 | 13 | APTSourceEdit::APTSourceEdit(QWidget *parent) : 14 | QDialog(parent), 15 | ui(new Ui::APTSourceEdit) 16 | { 17 | ui->setupUi(this); 18 | 19 | init(); 20 | } 21 | 22 | void APTSourceEdit::init() 23 | { 24 | ui->lblErrorMsg->hide(); 25 | } 26 | 27 | void APTSourceEdit::show() 28 | { 29 | clearElements(); 30 | 31 | // example 'deb [arch=amd64 lang=en] http://packages.microsoft.com/repos/vscode stable main' 32 | 33 | // set values to elements 34 | ui->radioBinary->setChecked(! selectedAptSource->isSource); 35 | ui->radioSource->setChecked(selectedAptSource->isSource); 36 | ui->txtOptions->setText(selectedAptSource->options); 37 | ui->txtUri->setText(selectedAptSource->uri); 38 | ui->txtDistribution->setText(selectedAptSource->distribution); 39 | ui->txtComponents->setText(selectedAptSource->components); 40 | 41 | QDialog::show(); 42 | } 43 | 44 | void APTSourceEdit::clearElements() 45 | { 46 | ui->lblErrorMsg->hide(); 47 | ui->txtOptions->clear(); 48 | ui->txtUri->clear(); 49 | ui->txtDistribution->clear(); 50 | ui->txtComponents->clear(); 51 | } 52 | 53 | void APTSourceEdit::on_btnSave_clicked() 54 | { 55 | if (! ui->txtUri->text().isEmpty() && 56 | ! ui->txtDistribution->text().isEmpty()) 57 | { 58 | QString sourceType = ui->radioBinary->isChecked() ? "deb" : "deb-src"; 59 | QString updatedAptSource = QString("%1 %2 %3 %4 %5") 60 | .arg(sourceType) 61 | .arg(ui->txtOptions->text()) 62 | .arg(ui->txtUri->text()) 63 | .arg(ui->txtDistribution->text()) 64 | .arg(ui->txtComponents->text()); 65 | 66 | ToolManager::ins()->changeAPTSource(selectedAptSource, updatedAptSource); 67 | 68 | emit saved(); 69 | 70 | close(); 71 | } else { 72 | ui->lblErrorMsg->show(); 73 | } 74 | } 75 | 76 | void APTSourceEdit::on_btnCancel_clicked() 77 | { 78 | close(); 79 | } 80 | -------------------------------------------------------------------------------- /stacer/Pages/AptSourceManager/apt_source_edit.h: -------------------------------------------------------------------------------- 1 | #ifndef APT_SOURCE_EDIT_H 2 | #define APT_SOURCE_EDIT_H 3 | 4 | #include 5 | #include "Managers/tool_manager.h" 6 | 7 | namespace Ui { 8 | class APTSourceEdit; 9 | } 10 | 11 | class APTSourceEdit : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit APTSourceEdit(QWidget *parent = 0); 17 | ~APTSourceEdit(); 18 | 19 | public: 20 | static APTSourcePtr selectedAptSource; 21 | void show(); 22 | 23 | signals: 24 | void saved(); 25 | 26 | private slots: 27 | void clearElements(); 28 | void on_btnSave_clicked(); 29 | void on_btnCancel_clicked(); 30 | 31 | private: 32 | void init(); 33 | 34 | private: 35 | Ui::APTSourceEdit *ui; 36 | }; 37 | 38 | #endif // APT_SOURCE_EDIT_H 39 | -------------------------------------------------------------------------------- /stacer/Pages/AptSourceManager/apt_source_manager_page.h: -------------------------------------------------------------------------------- 1 | #ifndef APTSourceManagerPage_PAGE_H 2 | #define APTSourceManagerPage_PAGE_H 3 | 4 | #include 5 | #include 6 | 7 | #include "apt_source_repository_item.h" 8 | #include "apt_source_edit.h" 9 | #include "Managers/info_manager.h" 10 | 11 | namespace Ui { 12 | class APTSourceManagerPage; 13 | } 14 | 15 | class APTSourceManagerPage : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit APTSourceManagerPage(QWidget *parent = 0); 21 | ~APTSourceManagerPage(); 22 | 23 | public: 24 | static APTSourcePtr selectedAptSource; 25 | 26 | private slots: 27 | void loadAptSources(); 28 | void changeElementsVisible(const bool checked); 29 | void on_btnAddAPTSourceRepository_clicked(bool checked); 30 | void on_listWidgetAptSources_itemClicked(QListWidgetItem *item); 31 | void on_listWidgetAptSources_itemDoubleClicked(QListWidgetItem *item); 32 | void on_txtSearchAptSource_textChanged(const QString &val); 33 | void on_btnDeleteAptSource_clicked(); 34 | void on_btnEditAptSource_clicked(); 35 | void on_btnCancel_clicked(); 36 | 37 | private: 38 | void init(); 39 | 40 | private: 41 | Ui::APTSourceManagerPage *ui; 42 | 43 | QSharedPointer mAptSourceEditDialog; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /stacer/Pages/AptSourceManager/apt_source_repository_item.cpp: -------------------------------------------------------------------------------- 1 | #include "apt_source_repository_item.h" 2 | #include "ui_apt_source_repository_item.h" 3 | #include "utilities.h" 4 | #include "Utils/command_util.h" 5 | #include 6 | 7 | APTSourceRepositoryItem::~APTSourceRepositoryItem() 8 | { 9 | delete ui; 10 | } 11 | 12 | APTSourceRepositoryItem::APTSourceRepositoryItem(APTSourcePtr aptSource, QWidget *parent) : 13 | QWidget(parent), 14 | ui(new Ui::APTSourceRepositoryItem), 15 | mAptSource(aptSource) 16 | { 17 | init(); 18 | } 19 | 20 | void APTSourceRepositoryItem::init() 21 | { 22 | ui->setupUi(this); 23 | 24 | Utilities::addDropShadow(this, 30, 10); 25 | 26 | ui->checkAptSource->setChecked(mAptSource->isActive); 27 | 28 | // example "deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main" 29 | QString source = mAptSource->source; 30 | 31 | source.remove(QRegExp("\\s[\\[]+.*[\\]]+")); 32 | 33 | if (mAptSource->isSource) { 34 | ui->lblAptSourceName->setText(tr("%1 (Source Code)").arg(source)); 35 | } else { 36 | ui->lblAptSourceName->setText(source); 37 | } 38 | 39 | ui->lblAptSourceName->setToolTip(ui->lblAptSourceName->text()); 40 | } 41 | 42 | APTSourcePtr APTSourceRepositoryItem::aptSource() const 43 | { 44 | return mAptSource; 45 | } 46 | 47 | void APTSourceRepositoryItem::on_checkAptSource_clicked(bool checked) 48 | { 49 | ToolManager::ins()->changeAPTStatus(mAptSource, checked); 50 | } 51 | -------------------------------------------------------------------------------- /stacer/Pages/AptSourceManager/apt_source_repository_item.h: -------------------------------------------------------------------------------- 1 | #ifndef APTSourceRepositoryItem_H 2 | #define APTSourceRepositoryItem_H 3 | 4 | #include 5 | #include "Managers/tool_manager.h" 6 | 7 | namespace Ui { 8 | class APTSourceRepositoryItem; 9 | } 10 | 11 | class APTSourceRepositoryItem : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit APTSourceRepositoryItem(APTSourcePtr aptSource, QWidget *parent = 0); 17 | ~APTSourceRepositoryItem(); 18 | 19 | public: 20 | APTSourcePtr aptSource() const; 21 | 22 | private slots: 23 | void on_checkAptSource_clicked(bool checked); 24 | 25 | private: 26 | void init(); 27 | 28 | private: 29 | Ui::APTSourceRepositoryItem *ui; 30 | 31 | APTSourcePtr mAptSource; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /stacer/Pages/Dashboard/circlebar.cpp: -------------------------------------------------------------------------------- 1 | #include "circlebar.h" 2 | #include "ui_circlebar.h" 3 | 4 | CircleBar::~CircleBar() 5 | { 6 | delete ui; 7 | delete mChart; 8 | } 9 | 10 | CircleBar::CircleBar(const QString &title, const QStringList &colors, QWidget *parent) : 11 | QWidget(parent), 12 | ui(new Ui::CircleBar), 13 | mColors(colors), 14 | mChart(new QChart), 15 | mChartView(new QChartView(mChart)), 16 | mSeries(new QPieSeries(this)) 17 | { 18 | ui->setupUi(this); 19 | 20 | ui->lblCircleChartTitle->setText(title); 21 | 22 | init(); 23 | } 24 | 25 | void CircleBar::init() 26 | { 27 | QColor transparent("transparent"); 28 | 29 | // series settings 30 | mSeries->setHoleSize(0.67); 31 | mSeries->setPieSize(165); 32 | mSeries->setPieStartAngle(-115); 33 | mSeries->setPieEndAngle(115); 34 | mSeries->setLabelsVisible(false); 35 | mSeries->append("Used", 0); 36 | mSeries->append("Free", 0); 37 | mSeries->slices().first()->setBorderColor(transparent); 38 | mSeries->slices().last()->setBorderColor(transparent); 39 | QConicalGradient gradient; 40 | gradient.setAngle(115); 41 | for (int i = 0; i < mColors.count(); ++i) { 42 | gradient.setColorAt(i, QColor(mColors.at(i))); 43 | } 44 | mSeries->slices().first()->setBrush(gradient); 45 | 46 | // chart settings 47 | mChart->setBackgroundBrush(QBrush(transparent)); 48 | mChart->setContentsMargins(-20, -20, -20, -65); 49 | mChart->addSeries(mSeries); 50 | mChart->legend()->hide(); 51 | 52 | // chartview settings 53 | mChartView->setRenderHint(QPainter::Antialiasing); 54 | 55 | ui->layoutCircleBar->insertWidget(1, mChartView); 56 | 57 | connect(SignalMapper::ins(), &SignalMapper::sigChangedAppTheme, [=] { 58 | QSettings *styleValues = AppManager::ins()->getStyleValues(); 59 | mChartView->setBackgroundBrush(QColor(styleValues->value("@circleChartBackgroundColor").toString())); 60 | mSeries->slices().last()->setColor(styleValues->value("@pageContent").toString()); // trail color 61 | }); 62 | } 63 | 64 | void CircleBar::setValue(const int &value, const QString &valueText) 65 | { 66 | mSeries->slices().first()->setValue(value); 67 | mSeries->slices().last()->setValue(100 - value); 68 | 69 | ui->lblCircleChartValue->setText(valueText); 70 | } 71 | 72 | -------------------------------------------------------------------------------- /stacer/Pages/Dashboard/circlebar.h: -------------------------------------------------------------------------------- 1 | #ifndef CIRCLEBAR_H 2 | #define CIRCLEBAR_H 3 | 4 | #include 5 | #include 6 | #include "Managers/app_manager.h" 7 | #include "signal_mapper.h" 8 | 9 | namespace Ui { 10 | class CircleBar; 11 | } 12 | 13 | class CircleBar : public QWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit CircleBar(const QString &title, const QStringList &colors, QWidget *parent = 0); 19 | ~CircleBar(); 20 | 21 | public slots: 22 | void setValue(const int &value, const QString &valueText); 23 | 24 | private slots: 25 | void init(); 26 | 27 | private: 28 | Ui::CircleBar *ui; 29 | 30 | private: 31 | QStringList mColors; 32 | 33 | QChart *mChart; 34 | QChartView *mChartView; 35 | QPieSeries *mSeries; 36 | }; 37 | 38 | #endif // CIRCLEBAR_H 39 | -------------------------------------------------------------------------------- /stacer/Pages/Dashboard/circlebar.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | CircleBar 4 | 5 | 6 | 7 | 0 8 | 0 9 | 383 10 | 317 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 0 28 | 29 | 30 | 0 31 | 32 | 33 | 0 34 | 35 | 36 | 0 37 | 38 | 39 | 0 40 | 41 | 42 | 43 | 44 | 45 | 0 46 | 0 47 | 48 | 49 | 50 | 51 | 2 52 | 53 | 54 | 20 55 | 56 | 57 | 10 58 | 59 | 60 | 20 61 | 62 | 63 | 10 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | Title 72 | 73 | 74 | Qt::AlignCenter 75 | 76 | 77 | 78 | 79 | 80 | 81 | Value 82 | 83 | 84 | Qt::AlignCenter 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /stacer/Pages/Dashboard/dashboard_page.h: -------------------------------------------------------------------------------- 1 | #ifndef DASHBOARDPAGE_H 2 | #define DASHBOARDPAGE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "Managers/info_manager.h" 13 | #include "circlebar.h" 14 | #include "linebar.h" 15 | 16 | #include "Managers/setting_manager.h" 17 | 18 | namespace Ui { 19 | class DashboardPage; 20 | } 21 | 22 | class DashboardPage : public QWidget 23 | { 24 | Q_OBJECT 25 | 26 | public: 27 | explicit DashboardPage(QWidget *parent = 0); 28 | ~DashboardPage(); 29 | 30 | private slots: 31 | void init(); 32 | void checkUpdate(); 33 | void systemInformationInit(); 34 | 35 | void updateCpuBar(); 36 | void updateMemoryBar(); 37 | void updateDiskBar(); 38 | void updateNetworkBar(); 39 | 40 | void on_btnDownloadUpdate_clicked(); 41 | 42 | signals: 43 | void sigShowUpdateBar(); 44 | 45 | private: 46 | Ui::DashboardPage *ui; 47 | 48 | private: 49 | CircleBar* mCpuBar; 50 | CircleBar* mMemBar; 51 | CircleBar* mDiskBar; 52 | 53 | LineBar *mDownloadBar; 54 | LineBar *mUploadBar; 55 | 56 | QTimer *mTimer; 57 | InfoManager *im; 58 | 59 | SettingManager *mSettingManager; 60 | }; 61 | 62 | #endif // DASHBOARDPAGE_H 63 | -------------------------------------------------------------------------------- /stacer/Pages/Dashboard/linebar.cpp: -------------------------------------------------------------------------------- 1 | #include "linebar.h" 2 | #include "ui_linebar.h" 3 | 4 | LineBar::~LineBar() 5 | { 6 | delete ui; 7 | } 8 | 9 | LineBar::LineBar(const QString &title, QWidget *parent) : 10 | QWidget(parent), 11 | ui(new Ui::LineBar) 12 | { 13 | ui->setupUi(this); 14 | 15 | ui->lblLineChartTitle->setText(title); 16 | } 17 | 18 | void LineBar::setValue(const int &value, const QString &text, const QString &totalText) 19 | { 20 | ui->lineChartProgress->setValue(value); 21 | ui->lblLineChartValue->setText(text); 22 | ui->lblLineChartTotal->setText(totalText); 23 | } 24 | -------------------------------------------------------------------------------- /stacer/Pages/Dashboard/linebar.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEBAR_H 2 | #define LINEBAR_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class LineBar; 8 | } 9 | 10 | class LineBar : public QWidget 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit LineBar(const QString &title, QWidget *parent = 0); 16 | ~LineBar(); 17 | 18 | public slots: 19 | void setValue(const int &value, const QString &text, const QString &totalText); 20 | 21 | private: 22 | Ui::LineBar *ui; 23 | }; 24 | 25 | #endif // LINEBAR_H 26 | -------------------------------------------------------------------------------- /stacer/Pages/Dashboard/linebar.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | LineBar 4 | 5 | 6 | 7 | 0 8 | 0 9 | 474 10 | 114 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 0 22 | 23 | 24 | 0 25 | 26 | 27 | 0 28 | 29 | 30 | 0 31 | 32 | 33 | 34 | 35 | 36 | 25 37 | 38 | 39 | 15 40 | 41 | 42 | 25 43 | 44 | 45 | 15 46 | 47 | 48 | 0 49 | 50 | 51 | 15 52 | 53 | 54 | 55 | 56 | Total 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 0 65 | 20 66 | 67 | 68 | 69 | 70 | 16777215 71 | 20 72 | 73 | 74 | 75 | 76 | 77 | 78 | 0 79 | 80 | 81 | false 82 | 83 | 84 | 85 | 86 | 87 | 88 | Value 89 | 90 | 91 | 92 | 93 | 94 | 95 | Title 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /stacer/Pages/GnomeSettings/appearance_settings.h: -------------------------------------------------------------------------------- 1 | #ifndef APPEARANCE_SETTINGS_H 2 | #define APPEARANCE_SETTINGS_H 3 | 4 | #include 5 | #include "Tools/gnome_settings_tool.h" 6 | 7 | namespace Ui { 8 | class AppearanceSettings; 9 | } 10 | 11 | class AppearanceSettings : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit AppearanceSettings(QWidget *parent = 0); 17 | ~AppearanceSettings(); 18 | 19 | private slots: 20 | void on_checkShowDesktopIcons_clicked(bool checked); 21 | void on_checkHomeIcon_clicked(bool checked); 22 | void on_checkTrashIcon_clicked(bool checked); 23 | void on_checkMountedVulmesIcon_clicked(bool checked); 24 | void on_checkNetworkIcon_clicked(bool checked); 25 | void cmbDesktopBackMode_currentIndexChanged(int index); 26 | void cmbLoginBackMode_currentIndexChanged(int index); 27 | void on_checkScreenKeyboard_clicked(bool checked); 28 | void on_checkScreenReader_clicked(bool checked); 29 | 30 | private: 31 | void init(); 32 | void initConnects(); 33 | void loadDatas(); 34 | 35 | private: 36 | Ui::AppearanceSettings *ui; 37 | 38 | GnomeSettingsTool gsettings; 39 | }; 40 | 41 | #endif // APPEARANCE_SETTINGS_H 42 | -------------------------------------------------------------------------------- /stacer/Pages/GnomeSettings/gnome_settings_page.cpp: -------------------------------------------------------------------------------- 1 | #include "gnome_settings_page.h" 2 | #include "ui_gnome_settings_page.h" 3 | #include "utilities.h" 4 | 5 | GnomeSettingsPage::~GnomeSettingsPage() 6 | { 7 | delete ui; 8 | } 9 | 10 | GnomeSettingsPage::GnomeSettingsPage(QWidget *parent) : 11 | QWidget(parent), 12 | ui(new Ui::GnomeSettingsPage), 13 | slidingStackedWidget(new SlidingStackedWidget(this)) 14 | { 15 | ui->setupUi(this); 16 | 17 | init(); 18 | } 19 | 20 | void GnomeSettingsPage::init() 21 | { 22 | ui->contentGridLayout->addWidget(slidingStackedWidget, 1, 0, 1, 1); 23 | 24 | if (GnomeSettingsTool::ins().checkUnityAvailable()) { 25 | unitySettings = new UnitySettings(slidingStackedWidget); 26 | slidingStackedWidget->addWidget(unitySettings); 27 | } else { 28 | ui->btnUnitySettings->hide(); 29 | ui->btnWindowManager->setChecked(true); 30 | } 31 | 32 | windowManagerSettings = new WindowManagerSettings(slidingStackedWidget); 33 | appearanceSettings = new AppearanceSettings(slidingStackedWidget); 34 | 35 | slidingStackedWidget->addWidget(windowManagerSettings); 36 | slidingStackedWidget->addWidget(appearanceSettings); 37 | 38 | QList widgets = { ui->btnAppearance, ui->btnUnitySettings, ui->btnWindowManager }; 39 | Utilities::addDropShadow(widgets, 40); 40 | } 41 | 42 | void GnomeSettingsPage::on_btnUnitySettings_clicked() 43 | { 44 | slidingStackedWidget->slideInIdx(slidingStackedWidget->indexOf(unitySettings)); 45 | } 46 | 47 | void GnomeSettingsPage::on_btnWindowManager_clicked() 48 | { 49 | slidingStackedWidget->slideInIdx(slidingStackedWidget->indexOf(windowManagerSettings)); 50 | } 51 | 52 | void GnomeSettingsPage::on_btnAppearance_clicked() 53 | { 54 | slidingStackedWidget->slideInIdx(slidingStackedWidget->indexOf(appearanceSettings)); 55 | } 56 | -------------------------------------------------------------------------------- /stacer/Pages/GnomeSettings/gnome_settings_page.h: -------------------------------------------------------------------------------- 1 | #ifndef GNOME_SETTINGS_PAGE_H 2 | #define GNOME_SETTINGS_PAGE_H 3 | 4 | #include 5 | #include "sliding_stacked_widget.h" 6 | 7 | #include "unity_settings.h" 8 | #include "window_manager_settings.h" 9 | #include "appearance_settings.h" 10 | 11 | namespace Ui { 12 | class GnomeSettingsPage; 13 | } 14 | 15 | class GnomeSettingsPage : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit GnomeSettingsPage(QWidget *parent = 0); 21 | ~GnomeSettingsPage(); 22 | 23 | private slots: 24 | void on_btnUnitySettings_clicked(); 25 | void on_btnWindowManager_clicked(); 26 | void on_btnAppearance_clicked(); 27 | 28 | private: 29 | void init(); 30 | 31 | private: 32 | Ui::GnomeSettingsPage *ui; 33 | 34 | SlidingStackedWidget *slidingStackedWidget; 35 | 36 | UnitySettings *unitySettings; 37 | WindowManagerSettings *windowManagerSettings; 38 | AppearanceSettings *appearanceSettings; 39 | }; 40 | 41 | #endif // GNOME_SETTINGS_PAGE_H 42 | -------------------------------------------------------------------------------- /stacer/Pages/GnomeSettings/unity_settings.h: -------------------------------------------------------------------------------- 1 | #ifndef UNITY_SETTINGS_H 2 | #define UNITY_SETTINGS_H 3 | 4 | #include 5 | #include "Tools/gnome_settings_tool.h" 6 | 7 | namespace Ui { 8 | class UnitySettings; 9 | } 10 | 11 | class UnitySettings : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit UnitySettings(QWidget *parent = 0); 17 | ~UnitySettings(); 18 | 19 | public: 20 | void init(); 21 | void initConnects(); 22 | 23 | private slots: 24 | void on_checkLauncherAutoHide_clicked(bool checked); 25 | 26 | void on_radioRevealLeft_clicked(); 27 | void on_radioRevealTopLeft_clicked(); 28 | 29 | void sliderRevealSensitivy_valueChanged(int value); 30 | void on_checkMinimizeApps_clicked(bool checked); 31 | void sliderLauncherOpacity_valueChanged(int value); 32 | 33 | void on_radioLauncherVisibleAllDesktop_clicked(); 34 | void on_radioLauncherVisiblePrimaryDesktop_clicked(); 35 | 36 | void on_radioLauncherPositionLeft_clicked(); 37 | void on_radioLauncherPositionBottom_clicked(); 38 | 39 | void spinIconSize_valueChanged(int value); 40 | void on_checkBackgroundBlur_clicked(bool checked); 41 | void on_checkSearchOnlineResource_clicked(bool checked); 42 | void on_checkMoreSuggestions_clicked(bool checked); 43 | void on_checkRecentlyUsed_clicked(bool checked); 44 | void on_checkSearchYourFiles_clicked(bool checked); 45 | void sliderPanelOpacity_valueChanged(int value); 46 | void on_checkDateTime_clicked(bool checked); 47 | void on_check24Hour_clicked(bool checked); 48 | void on_checkSeconds_clicked(bool checked); 49 | void on_checkDate_clicked(bool checked); 50 | void on_checkWeekday_clicked(bool checked); 51 | void on_checkCalendar_clicked(bool checked); 52 | void on_checkVolume_clicked(bool checked); 53 | void on_checkShowMyName_clicked(bool checked); 54 | 55 | private: 56 | Ui::UnitySettings *ui; 57 | 58 | GnomeSettingsTool gsettings; 59 | }; 60 | 61 | #endif // UNITY_SETTINGS_H 62 | -------------------------------------------------------------------------------- /stacer/Pages/GnomeSettings/window_manager_settings.h: -------------------------------------------------------------------------------- 1 | #ifndef WINDOW_MANAGER_SETTINGS_H 2 | #define WINDOW_MANAGER_SETTINGS_H 3 | 4 | #include 5 | #include "Tools/gnome_settings_tool.h" 6 | 7 | namespace Ui { 8 | class WindowManagerSettings; 9 | } 10 | 11 | class WindowManagerSettings : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit WindowManagerSettings(QWidget *parent = 0); 17 | ~WindowManagerSettings(); 18 | 19 | private slots: 20 | void cmbTextQuality_currentIndexChanged(int index); 21 | void checkWorkspaceSwitcher_clicked(bool checked); 22 | void spinHorizonWorkspace_valueChanged(int value); 23 | void spinVerticWorkspace_valueChanged(int value); 24 | void checkRaiseOnClick_clicked(bool checked); 25 | void cmbFocusMode_currentIndexChanged(int index); 26 | void cmbTitleBarDoubleClick_currentIndexChanged(int index); 27 | void cmbTitleBarMiddleClick_currentIndexChanged(int index); 28 | void cmbTitleBarRightClick_currentIndexChanged(int index); 29 | 30 | private: 31 | void init(); 32 | void loadDatas(); 33 | void initConnects(); 34 | 35 | private: 36 | Ui::WindowManagerSettings *ui; 37 | 38 | GnomeSettingsTool gsettings; 39 | }; 40 | 41 | #endif // WINDOW_MANAGER_SETTINGS_H 42 | -------------------------------------------------------------------------------- /stacer/Pages/Helpers/helpers_page.cpp: -------------------------------------------------------------------------------- 1 | #include "helpers_page.h" 2 | #include "ui_helpers_page.h" 3 | 4 | HelpersPage::~HelpersPage() 5 | { 6 | delete ui; 7 | } 8 | 9 | HelpersPage::HelpersPage(QWidget *parent) : 10 | QWidget(parent), 11 | widgetHostManage(new HostManage), 12 | ui(new Ui::HelpersPage) 13 | { 14 | ui->setupUi(this); 15 | 16 | init(); 17 | } 18 | 19 | void HelpersPage::init() 20 | { 21 | ui->stackedWidget->addWidget(widgetHostManage); 22 | //ui->stackedWidget->addWidget(); 23 | 24 | Utilities::addDropShadow({ 25 | ui->btnHostManage 26 | }, 40); 27 | } 28 | 29 | void HelpersPage::on_btnHostManage_clicked() 30 | { 31 | ui->stackedWidget->setCurrentIndex(0); 32 | } 33 | -------------------------------------------------------------------------------- /stacer/Pages/Helpers/helpers_page.h: -------------------------------------------------------------------------------- 1 | #ifndef HELPERS_PAGE_H 2 | #define HELPERS_PAGE_H 3 | 4 | #include 5 | #include "host_manage.h" 6 | #include "utilities.h" 7 | 8 | namespace Ui { 9 | class HelpersPage; 10 | } 11 | 12 | class HelpersPage : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit HelpersPage(QWidget *parent = 0); 18 | ~HelpersPage(); 19 | 20 | private slots: 21 | void on_btnHostManage_clicked(); 22 | void init(); 23 | 24 | private: 25 | Ui::HelpersPage *ui; 26 | 27 | HostManage *widgetHostManage; 28 | }; 29 | 30 | #endif // HELPERS_PAGE_H 31 | -------------------------------------------------------------------------------- /stacer/Pages/Helpers/helpers_page.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | HelpersPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 839 10 | 590 11 | 12 | 13 | 14 | Helpers 15 | 16 | 17 | 18 | 15 19 | 20 | 21 | 10 22 | 23 | 24 | 15 25 | 26 | 27 | 10 28 | 29 | 30 | 10 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 12 40 | 41 | 42 | 0 43 | 44 | 45 | 0 46 | 47 | 48 | 0 49 | 50 | 51 | 0 52 | 53 | 54 | 55 | 56 | PointingHandCursor 57 | 58 | 59 | Qt::NoFocus 60 | 61 | 62 | Host Manage 63 | 64 | 65 | true 66 | 67 | 68 | true 69 | 70 | 71 | buttonGroup 72 | 73 | 74 | 75 | 76 | 77 | 78 | Qt::Horizontal 79 | 80 | 81 | 82 | 40 83 | 20 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /stacer/Pages/Helpers/host_manage.h: -------------------------------------------------------------------------------- 1 | #ifndef HOST_MANAGE_H 2 | #define HOST_MANAGE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "Utils/file_util.h" 9 | #include "Utils/command_util.h" 10 | 11 | #include "utilities.h" 12 | 13 | namespace Ui { 14 | class HostManage; 15 | } 16 | 17 | class HostItem 18 | { 19 | public: 20 | QString ip; 21 | QString fullQualified; 22 | QString aliases; 23 | }; 24 | 25 | class HostManage : public QWidget 26 | { 27 | Q_OBJECT 28 | 29 | public: 30 | explicit HostManage(QWidget *parent = 0); 31 | ~HostManage(); 32 | 33 | private slots: 34 | void init(); 35 | 36 | void on_btnNewHost_clicked(); 37 | void on_btnSave_clicked(); 38 | void loadHostItems(); 39 | void loadTableData(); 40 | void on_btnCancel_clicked(); 41 | void loadTableRowMenu(); 42 | void on_btnSaveChanges_clicked(); 43 | QList createRow(const QPair &item); 44 | 45 | void on_tableViewHosts_customContextMenuRequested(const QPoint &pos); 46 | 47 | private: 48 | Ui::HostManage *ui; 49 | 50 | bool isAddHost; 51 | QList mHeaderList; 52 | 53 | QStandardItemModel *mItemModel; 54 | QSortFilterProxyModel *mSortFilterModel; 55 | QMenu mTableRowMenu; 56 | 57 | QStringList mHostFileContent; 58 | QMap mHostItemList; 59 | 60 | int updatedLine; 61 | }; 62 | 63 | #endif // HOST_MANAGE_H 64 | -------------------------------------------------------------------------------- /stacer/Pages/Processes/processes_page.h: -------------------------------------------------------------------------------- 1 | #ifndef PROCESSESPAGE_H 2 | #define PROCESSESPAGE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "Managers/info_manager.h" 14 | 15 | namespace Ui { 16 | class ProcessesPage; 17 | } 18 | 19 | class ProcessesPage : public QWidget 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | explicit ProcessesPage(QWidget *parent = 0); 25 | ~ProcessesPage(); 26 | 27 | private slots: 28 | void init(); 29 | void loadProcesses(); 30 | void loadHeaderMenu(); 31 | QList createRow(const Process &proc); 32 | void on_txtProcessSearch_textChanged(const QString &val); 33 | void on_sliderRefresh_valueChanged(const int &i); 34 | void on_btnEndProcess_clicked(); 35 | void on_tableProcess_customContextMenuRequested(const QPoint &pos); 36 | 37 | private: 38 | Ui::ProcessesPage *ui; 39 | 40 | QStandardItemModel *mItemModel; 41 | QSortFilterProxyModel *mSortFilterModel; 42 | QModelIndex mSeletedRowModel; 43 | QStringList mHeaders; 44 | QMenu mHeaderMenu; 45 | QTimer *mTimer; 46 | InfoManager *im; 47 | }; 48 | 49 | #endif // PROCESSESPAGE_H 50 | -------------------------------------------------------------------------------- /stacer/Pages/Resources/history_chart.cpp: -------------------------------------------------------------------------------- 1 | #include "history_chart.h" 2 | #include "ui_history_chart.h" 3 | 4 | HistoryChart::~HistoryChart() 5 | { 6 | delete ui; 7 | } 8 | 9 | HistoryChart::HistoryChart(const QString &title, const int &seriesCount, QCategoryAxis* categoriAxisY, QWidget *parent) : 10 | QWidget(parent), 11 | ui(new Ui::HistoryChart), 12 | mTitle(title), 13 | mSeriesCount(seriesCount), 14 | mChartView(new QChartView(this)), 15 | mChart(mChartView->chart()) 16 | { 17 | ui->setupUi(this); 18 | 19 | init(); 20 | 21 | if (categoriAxisY) { 22 | mAxisY = categoriAxisY; 23 | mAxisY->setLabelsPosition(QCategoryAxis::AxisLabelsPositionOnValue); 24 | for (int i = 0; i < seriesCount; ++i) { 25 | mChart->setAxisY(mAxisY, mSeriesList.at(i)); 26 | } 27 | } 28 | } 29 | 30 | void HistoryChart::init() 31 | { 32 | ui->lblHistoryTitle->setText(mTitle); 33 | 34 | // add series to chart 35 | for (int i = 0; i < mSeriesCount; i++) { 36 | mSeriesList.append(new QSplineSeries); 37 | mChart->addSeries(mSeriesList.at(i)); 38 | } 39 | 40 | mChartView->setRenderHint(QPainter::Antialiasing); 41 | 42 | QList colors = { 43 | 0x2ecc71, 0xe74c3c, 0x3498db, 0xf1c40f, 0xe67e22, 44 | 0x1abc9c, 0x9b59b6, 0x34495e, 0xd35400, 0xc0392b, 45 | 0x8e44ad, 0xFF8F00, 0xEF6C00, 0x4E342E, 0x424242, 46 | 0x5499C7, 0x58D68D, 0xCD6155, 0xF5B041, 0x566573 47 | }; 48 | // set colors 49 | for (int i = 0; i < mSeriesList.count(); ++i) { 50 | dynamic_cast(mChart->series().at(i))->setColor(QColor(colors.at(i))); 51 | } 52 | 53 | // Chart Settings 54 | mChart->createDefaultAxes(); 55 | 56 | mChart->axisX()->setRange(0, 60); 57 | mChart->axisX()->setReverse(true); 58 | 59 | mChart->setContentsMargins(-11, -11, -11, -11); 60 | mChart->setMargins(QMargins(20, 0, 10, 10)); 61 | ui->layoutHistoryChart->addWidget(mChartView, 1, 0, 1, 3); 62 | 63 | // theme changed 64 | connect(SignalMapper::ins(), &SignalMapper::sigChangedAppTheme, [=] { 65 | QString chartLabelColor = AppManager::ins()->getStyleValues()->value("@chartLabelColor").toString(); 66 | QString chartGridColor = AppManager::ins()->getStyleValues()->value("@chartGridColor").toString(); 67 | QString historyChartBackground = AppManager::ins()->getStyleValues()->value("@historyChartBackgroundColor").toString(); 68 | 69 | mChart->axisX()->setLabelsColor(chartLabelColor); 70 | mChart->axisX()->setGridLineColor(chartGridColor); 71 | 72 | mChart->axisY()->setLabelsColor(chartLabelColor); 73 | mChart->axisY()->setGridLineColor(chartGridColor); 74 | 75 | mChart->setBackgroundBrush(QColor(historyChartBackground)); 76 | mChart->legend()->setLabelColor(chartLabelColor); 77 | }); 78 | } 79 | 80 | void HistoryChart::setYMax(const int &value) 81 | { 82 | mChart->axisY()->setRange(0, value); 83 | } 84 | 85 | QCategoryAxis *HistoryChart::getAxisY() 86 | { 87 | return mAxisY; 88 | } 89 | 90 | void HistoryChart::setCategoryAxisYLabels() 91 | { 92 | if (mAxisY) { 93 | for (const QString &label : mAxisY->categoriesLabels()){ 94 | mAxisY->remove(label); 95 | } 96 | 97 | for (int i = 1; i < 5; ++i) { 98 | mAxisY->append(FormatUtil::formatBytes((mAxisY->max()/4)*i), (mAxisY->max()/4)*i); 99 | } 100 | } 101 | } 102 | 103 | QVector HistoryChart::getSeriesList() const 104 | { 105 | return mSeriesList; 106 | } 107 | 108 | void HistoryChart::setSeriesList(const QVector &seriesList) 109 | { 110 | for (int i = 0; i < seriesList.count(); ++i) { 111 | mChart->series().replace(0, seriesList.at(i)); 112 | } 113 | 114 | mChartView->repaint(); 115 | } 116 | 117 | void HistoryChart::on_checkHistoryTitle_clicked(bool checked) 118 | { 119 | QLayout *charts = topLevelWidget()->findChild("charts")->layout(); 120 | 121 | for (int i = 0; i < charts->count(); ++i) { 122 | charts->itemAt(i)->widget()->setVisible(! checked); 123 | } 124 | 125 | show(); 126 | } 127 | -------------------------------------------------------------------------------- /stacer/Pages/Resources/history_chart.h: -------------------------------------------------------------------------------- 1 | #ifndef HISTORYCHART_H 2 | #define HISTORYCHART_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "Managers/app_manager.h" 10 | #include "Utils/format_util.h" 11 | 12 | namespace Ui { 13 | class HistoryChart; 14 | } 15 | 16 | class HistoryChart : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit HistoryChart(const QString &title, const int &seriesCount, QCategoryAxis* categoriAxisY = nullptr, QWidget *parent = 0); 22 | ~HistoryChart(); 23 | 24 | QVector getSeriesList() const; 25 | QCategoryAxis *getAxisY(); 26 | void setYMax(const int &value); 27 | void setSeriesList(const QVector &seriesList); 28 | void setCategoryAxisYLabels(); 29 | 30 | private slots: 31 | void on_checkHistoryTitle_clicked(bool checked); 32 | 33 | private: 34 | void init(); 35 | 36 | private: 37 | Ui::HistoryChart *ui; 38 | 39 | QString mTitle; 40 | int mSeriesCount; 41 | QChartView *mChartView; 42 | QChart *mChart; 43 | QVector mSeriesList; 44 | 45 | QCategoryAxis *mAxisY; 46 | }; 47 | 48 | #endif // HISTORYCHART_H 49 | -------------------------------------------------------------------------------- /stacer/Pages/Resources/history_chart.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | HistoryChart 4 | 5 | 6 | 7 | 0 8 | 0 9 | 759 10 | 275 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | 21 | 0 22 | 200 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 0 31 | 32 | 33 | 0 34 | 35 | 36 | 0 37 | 38 | 39 | 0 40 | 41 | 42 | 10 43 | 44 | 45 | 0 46 | 47 | 48 | 49 | 50 | PointingHandCursor 51 | 52 | 53 | Qt::NoFocus 54 | 55 | 56 | Qt::LeftToRight 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 0 71 | 0 72 | 73 | 74 | 75 | 76 | 77 | 78 | Chart Title 79 | 80 | 81 | 82 | 83 | 84 | 85 | Qt::Horizontal 86 | 87 | 88 | 89 | 40 90 | 20 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /stacer/Pages/Resources/resources_page.h: -------------------------------------------------------------------------------- 1 | #ifndef RESOURCESPAGE_H 2 | #define RESOURCESPAGE_H 3 | 4 | #include 5 | #include 6 | 7 | #include "history_chart.h" 8 | #include "Managers/info_manager.h" 9 | #include 10 | #include 11 | 12 | namespace Ui { 13 | class ResourcesPage; 14 | } 15 | 16 | class ResourcesPage : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit ResourcesPage(QWidget *parent = 0); 22 | ~ResourcesPage(); 23 | 24 | private slots: 25 | void updateCpuChart(); 26 | void updateCpuLoadAvg(); 27 | void updateDiskReadWrite(); 28 | void updateMemoryChart(); 29 | void updateNetworkChart(); 30 | void initDiskPieChart(); 31 | void diskPieSeriesCustomize(); 32 | 33 | private: 34 | void init(); 35 | 36 | private: 37 | Ui::ResourcesPage *ui; 38 | 39 | InfoManager *im; 40 | 41 | HistoryChart *mChartCpu; 42 | HistoryChart *mChartCpuLoadAvg; 43 | HistoryChart *mChartDiskReadWrite; 44 | HistoryChart *mChartMemory; 45 | HistoryChart *mChartNetwork; 46 | 47 | QChartView *mChartViewDiskPie; 48 | QChart *mChartDiskPie; 49 | 50 | QWidget *gridWidgetDiskPie; 51 | QGridLayout *gridLayoutDiskPie; 52 | QPieSeries *mDiskPieSeries; 53 | 54 | QList chartColors; 55 | 56 | QTimer *mTimer; 57 | }; 58 | 59 | #endif // RESOURCESPAGE_H 60 | -------------------------------------------------------------------------------- /stacer/Pages/Resources/resources_page.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ResourcesPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 890 10 | 537 11 | 12 | 13 | 14 | Resources 15 | 16 | 17 | 18 | 0 19 | 20 | 21 | 10 22 | 23 | 24 | 0 25 | 26 | 27 | 10 28 | 29 | 30 | 10 31 | 32 | 33 | 34 | 35 | true 36 | 37 | 38 | 39 | 40 | 0 41 | 0 42 | 868 43 | 525 44 | 45 | 46 | 47 | 48 | 0 49 | 0 50 | 51 | 52 | 53 | 54 | 10 55 | 56 | 57 | 10 58 | 59 | 60 | 5 61 | 62 | 63 | 10 64 | 65 | 66 | 5 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /stacer/Pages/Search/search_page.h: -------------------------------------------------------------------------------- 1 | #ifndef SEARCH_PAGE_H 2 | #define SEARCH_PAGE_H 3 | 4 | #include 5 | #include 6 | #include "Managers/info_manager.h" 7 | #include "utilities.h" 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "Utils/format_util.h" 14 | #include "Managers/setting_manager.h" 15 | #include 16 | #include 17 | #include 18 | 19 | namespace Ui { 20 | class SearchPage; 21 | } 22 | 23 | class SearchPage : public QWidget 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | explicit SearchPage(QWidget *parent = 0); 29 | ~SearchPage(); 30 | 31 | private slots: 32 | void init(); 33 | 34 | void on_btnBrowseSearchDir_clicked(); 35 | void on_btnAdvancePaneToggle_clicked(); 36 | void on_btnSearchAdvance_clicked(); 37 | void initComboboxValues(); 38 | void on_tableFoundResults_customContextMenuRequested(const QPoint &pos); 39 | void tableFoundResults_header_customContextMenuRequested(const QPoint &pos); 40 | void loadTableRowMenu(); 41 | void loadHeaderMenu(); 42 | void loadDataToTable(const QList &results); 43 | void searching(); 44 | QList createRow(const QString &filepath); 45 | 46 | void on_tableFoundResults_doubleClicked(const QModelIndex &index); 47 | 48 | private: 49 | Ui::SearchPage *ui; 50 | 51 | QString mSelectedDirectory; 52 | 53 | QStringList mTableHeaders; 54 | QStandardItemModel *mItemModel; 55 | QSortFilterProxyModel *mSortFilterModel; 56 | QMenu mHeaderMenu; 57 | QMenu mTableRowMenu; 58 | QString mSearchResultDateFormat; 59 | int rowRole; 60 | }; 61 | 62 | #endif // SEARCH_PAGE_H 63 | -------------------------------------------------------------------------------- /stacer/Pages/Services/service_item.cpp: -------------------------------------------------------------------------------- 1 | #include "service_item.h" 2 | #include "ui_service_item.h" 3 | #include "utilities.h" 4 | 5 | ServiceItem::~ServiceItem() 6 | { 7 | delete ui; 8 | } 9 | 10 | ServiceItem::ServiceItem(const QString &name, 11 | const QString description, 12 | const bool status, 13 | const bool active, 14 | QWidget *parent) : 15 | QWidget(parent), 16 | ui(new Ui::ServiceItem), 17 | tm(ToolManager::ins()) 18 | { 19 | ui->setupUi(this); 20 | 21 | ui->lblServiceName->setText(name); 22 | ui->lblServiceDescription->setText("- " + description); 23 | ui->checkServiceRunning->setChecked(active); 24 | ui->checkServiceStartup->setChecked(status); 25 | 26 | ui->lblServiceName->setToolTip(name); 27 | ui->lblServiceDescription->setToolTip(description); 28 | 29 | Utilities::addDropShadow(this, 30, 10); 30 | } 31 | 32 | void ServiceItem::on_checkServiceStartup_clicked(bool status) 33 | { 34 | QString name = ui->lblServiceName->text(); 35 | 36 | tm->changeServiceStatus(name, status); 37 | 38 | ui->checkServiceStartup->setChecked(tm->serviceIsEnabled(name)); 39 | } 40 | 41 | void ServiceItem::on_checkServiceRunning_clicked(bool status) 42 | { 43 | QString name = ui->lblServiceName->text(); 44 | 45 | tm->changeServiceActive(name, status); 46 | 47 | ui->checkServiceRunning->setChecked(tm->serviceIsActive(name)); 48 | } 49 | -------------------------------------------------------------------------------- /stacer/Pages/Services/service_item.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVICE_ITEM_H 2 | #define SERVICE_ITEM_H 3 | 4 | #include 5 | #include 6 | #include "Managers/tool_manager.h" 7 | 8 | namespace Ui { 9 | class ServiceItem; 10 | } 11 | 12 | class ServiceItem : public QWidget 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | explicit ServiceItem(const QString &name, const QString description, const bool status, const bool active, QWidget *parent = 0); 18 | ~ServiceItem(); 19 | 20 | private slots: 21 | void on_checkServiceRunning_clicked(bool status); 22 | void on_checkServiceStartup_clicked(bool status); 23 | 24 | private: 25 | Ui::ServiceItem *ui; 26 | 27 | private: 28 | ToolManager *tm; 29 | }; 30 | 31 | #endif // SERVICE_ITEM_H 32 | -------------------------------------------------------------------------------- /stacer/Pages/Services/services_page.cpp: -------------------------------------------------------------------------------- 1 | #include "services_page.h" 2 | #include "ui_services_page.h" 3 | #include "service_item.h" 4 | 5 | #include "utilities.h" 6 | #include 7 | 8 | ServicesPage::~ServicesPage() 9 | { 10 | delete ui; 11 | } 12 | 13 | ServicesPage::ServicesPage(QWidget *parent) : 14 | QWidget(parent), 15 | ui(new Ui::ServicesPage) 16 | { 17 | ui->setupUi(this); 18 | 19 | init(); 20 | } 21 | 22 | void ServicesPage::init() 23 | { 24 | connect(this, &ServicesPage::loadServicesS, this, &ServicesPage::loadServices); 25 | QtConcurrent::run(this, &ServicesPage::getServices); 26 | 27 | ui->cmbRunningStatus->addItems({ tr("Running Status"), tr("Running"), tr("Not Running") }); 28 | ui->cmbStartupStatus->addItems({ tr("Startup Status"), tr("Enabled"), tr("Disabled") }); 29 | 30 | Utilities::addDropShadow(ui->cmbRunningStatus, 30); 31 | Utilities::addDropShadow(ui->cmbStartupStatus, 30); 32 | } 33 | 34 | void ServicesPage::getServices() 35 | { 36 | this->mServices = ToolManager::ins()->getServices(); 37 | emit loadServicesS(); 38 | } 39 | 40 | void ServicesPage::loadServices() 41 | { 42 | ui->listWidgetServices->clear(); 43 | 44 | int runningIndex = ui->cmbRunningStatus->currentIndex(); 45 | int startupIndex = ui->cmbStartupStatus->currentIndex(); 46 | 47 | bool runningStatus = runningIndex == 1; 48 | bool startupStatus = startupIndex == 1; 49 | 50 | for (const Service s : mServices) { 51 | bool runningFilter = runningIndex != 0 ? s.active == runningStatus : true; 52 | bool startupFilter = startupIndex != 0 ? s.status == startupStatus : true; 53 | 54 | if (runningFilter && startupFilter) { 55 | ServiceItem *service = new ServiceItem(s.name, s.description, s.status, s.active); 56 | 57 | QListWidgetItem *item = new QListWidgetItem(ui->listWidgetServices); 58 | 59 | item->setSizeHint(service->sizeHint()); 60 | 61 | ui->listWidgetServices->setItemWidget(item, service); 62 | } 63 | } 64 | 65 | setServiceCount(); 66 | 67 | bool isListEmpty = ui->listWidgetServices->count() == 0; 68 | 69 | ui->listWidgetServices->setVisible(! isListEmpty); 70 | ui->notFoundWidget->setVisible(isListEmpty); 71 | } 72 | 73 | void ServicesPage::setServiceCount() 74 | { 75 | ui->lblServicesTitle->setText(tr("System Services (%1)") 76 | .arg(ui->listWidgetServices->count())); 77 | } 78 | 79 | void ServicesPage::on_cmbRunningStatus_currentIndexChanged(int index) 80 | { 81 | Q_UNUSED(index); 82 | loadServices(); 83 | } 84 | 85 | void ServicesPage::on_cmbStartupStatus_currentIndexChanged(int index) 86 | { 87 | Q_UNUSED(index); 88 | loadServices(); 89 | } 90 | -------------------------------------------------------------------------------- /stacer/Pages/Services/services_page.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVICESPAGE_H 2 | #define SERVICESPAGE_H 3 | 4 | #include 5 | #include "Managers/tool_manager.h" 6 | 7 | namespace Ui { 8 | class ServicesPage; 9 | } 10 | 11 | class ServicesPage : public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit ServicesPage(QWidget *parent = 0); 17 | ~ServicesPage(); 18 | 19 | signals: 20 | void loadServicesS(); 21 | 22 | private slots: 23 | void init(); 24 | void getServices(); 25 | void loadServices(); 26 | 27 | void on_cmbRunningStatus_currentIndexChanged(int index); 28 | void on_cmbStartupStatus_currentIndexChanged(int index); 29 | 30 | public slots: 31 | void setServiceCount(); 32 | 33 | private: 34 | Ui::ServicesPage *ui; 35 | 36 | QList mServices; 37 | }; 38 | 39 | #endif // SERVICESPAGE_H 40 | -------------------------------------------------------------------------------- /stacer/Pages/Settings/settings_page.h: -------------------------------------------------------------------------------- 1 | #ifndef SETTINGS_PAGE_H 2 | #define SETTINGS_PAGE_H 3 | 4 | #include 5 | #include 6 | 7 | #include "Managers/app_manager.h" 8 | #include "Managers/setting_manager.h" 9 | #include "signal_mapper.h" 10 | 11 | namespace Ui { 12 | class SettingsPage; 13 | } 14 | 15 | class SettingsPage : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit SettingsPage(QWidget *parent = 0); 21 | ~SettingsPage(); 22 | 23 | private slots: 24 | void init(); 25 | 26 | // void cmbThemesChanged(const int &index); 27 | void cmbLanguagesChanged(const int &index); 28 | void cmbDiskChanged(const int &index); 29 | void on_checkAutostart_clicked(bool checked); 30 | void on_btnDonate_clicked(); 31 | void cmbStartPageChanged(const QString text); 32 | void on_spinCpuPercent_valueChanged(int value); 33 | void on_spinMemoryPercent_valueChanged(int value); 34 | void on_spinDiskPercent_valueChanged(int value); 35 | void on_checkAppQuitDontAsk_clicked(bool checked); 36 | 37 | private: 38 | Ui::SettingsPage *ui; 39 | 40 | private: 41 | AppManager *apm; 42 | 43 | QString mStartupAppPath; 44 | 45 | SettingManager *mSettingManager; 46 | }; 47 | 48 | #endif // SETTINGS_PAGE_H 49 | -------------------------------------------------------------------------------- /stacer/Pages/StartupApps/startup_app.cpp: -------------------------------------------------------------------------------- 1 | #include "startup_app.h" 2 | #include "ui_startup_app.h" 3 | #include "utilities.h" 4 | 5 | StartupApp::~StartupApp() 6 | { 7 | delete ui; 8 | } 9 | 10 | StartupApp::StartupApp(const QString &startupAppName, bool enabled, const QString &filePath, QWidget *parent) : 11 | QWidget(parent), 12 | ui(new Ui::StartupApp), 13 | mStartupAppName(startupAppName), 14 | mEnabled(enabled), 15 | mFilePath(filePath) 16 | { 17 | ui->setupUi(this); 18 | 19 | ui->lblStartupAppName->setText(startupAppName); 20 | ui->checkStartup->setChecked(enabled); 21 | 22 | Utilities::addDropShadow(this, 50); 23 | } 24 | 25 | void StartupApp::on_checkStartup_clicked(bool status) 26 | { 27 | QStringList lines = FileUtil::readListFromFile(mFilePath); 28 | 29 | // Hidden=[true|false] 30 | int pos = lines.indexOf(HIDDEN_REG); 31 | 32 | QString _status = status ? "true" : "false"; 33 | 34 | if (pos != -1) { 35 | _status = status ? "false" : "true"; 36 | lines.replace(pos, QString("Hidden=%1").arg(_status)); 37 | } else { 38 | // X-GNOME-Autostart-enabled=[true|false] 39 | pos = lines.indexOf(GNOME_ENABLED_REG); 40 | if (pos != -1) { 41 | lines.replace(pos, QString("X-GNOME-Autostart-enabled=%1").arg(_status)); 42 | } 43 | } 44 | 45 | if (pos == -1) { 46 | _status = status ? "false" : "true"; 47 | lines.append(QString("Hidden=%1").arg(_status)); 48 | } 49 | 50 | FileUtil::writeFile(mFilePath, lines.join('\n').append('\n')); 51 | } 52 | 53 | void StartupApp::on_btnDeleteStartupApp_clicked() 54 | { 55 | if (QFile::remove(mFilePath)) { 56 | emit deleteAppS(); 57 | } 58 | } 59 | 60 | void StartupApp::on_btnEditStartupApp_clicked() 61 | { 62 | emit editStartupAppS(mFilePath); 63 | } 64 | 65 | QString StartupApp::getAppName() const 66 | { 67 | return mStartupAppName; 68 | } 69 | 70 | void StartupApp::setAppName(const QString &value) 71 | { 72 | mStartupAppName = value; 73 | } 74 | 75 | bool StartupApp::getEnabled() const 76 | { 77 | return mEnabled; 78 | } 79 | 80 | void StartupApp::setEnabled(bool value) 81 | { 82 | mEnabled = value; 83 | } 84 | 85 | QString StartupApp::getFilePath() const 86 | { 87 | return mFilePath; 88 | } 89 | 90 | void StartupApp::setFilePath(const QString &value) 91 | { 92 | mFilePath = value; 93 | } 94 | 95 | -------------------------------------------------------------------------------- /stacer/Pages/StartupApps/startup_app.h: -------------------------------------------------------------------------------- 1 | #ifndef STARTUP_APP_H 2 | #define STARTUP_APP_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "startup_app_edit.h" 10 | 11 | namespace Ui { 12 | class StartupApp; 13 | } 14 | 15 | class StartupApp : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | explicit StartupApp(const QString &startupAppName, bool enabled, const QString &filePath, QWidget *parent = 0); 21 | ~StartupApp(); 22 | 23 | QString getAppName() const; 24 | void setAppName(const QString &value); 25 | 26 | bool getEnabled() const; 27 | void setEnabled(bool value); 28 | 29 | QString getFilePath() const; 30 | void setFilePath(const QString &value); 31 | 32 | private slots: 33 | void on_checkStartup_clicked(bool); 34 | void on_btnDeleteStartupApp_clicked(); 35 | void on_btnEditStartupApp_clicked(); 36 | 37 | signals: 38 | void deleteAppS(); 39 | void editStartupAppS(const QString filePath); 40 | 41 | private: 42 | Ui::StartupApp *ui; 43 | 44 | private: 45 | QString mStartupAppName; 46 | QString mAppComment; 47 | bool mEnabled; 48 | QString mFilePath; 49 | }; 50 | 51 | #endif // STARTUP_APP_H 52 | -------------------------------------------------------------------------------- /stacer/Pages/StartupApps/startup_app_edit.cpp: -------------------------------------------------------------------------------- 1 | #include "startup_app_edit.h" 2 | #include "ui_startup_app_edit.h" 3 | #include "utilities.h" 4 | #include 5 | #include 6 | 7 | StartupAppEdit::~StartupAppEdit() 8 | { 9 | delete ui; 10 | } 11 | 12 | QString StartupAppEdit::selectedFilePath = ""; 13 | 14 | StartupAppEdit::StartupAppEdit(QWidget *parent) : 15 | QDialog(parent), 16 | ui(new Ui::StartupAppEdit), 17 | mNewAppTemplate("[Desktop Entry]\n" 18 | "Name=%1\n" 19 | "Comment=%2\n" 20 | "Exec=%3\n" 21 | "Type=Application\n" 22 | "Terminal=false\n" 23 | "Hidden=false\n") 24 | { 25 | ui->setupUi(this); 26 | 27 | init(); 28 | } 29 | 30 | void StartupAppEdit::init() 31 | { 32 | setGeometry( 33 | QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, 34 | size(), qApp->desktop()->availableGeometry()) 35 | ); 36 | 37 | mAutostartPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/autostart"; 38 | 39 | ui->lblErrorMsg->hide(); 40 | 41 | setStyleSheet(AppManager::ins()->getStylesheetFileContent()); 42 | } 43 | 44 | void StartupAppEdit::show() 45 | { 46 | // clear fields 47 | ui->txtStartupAppName->clear(); 48 | ui->txtStartupAppComment->clear(); 49 | ui->txtStartupAppCommand->clear(); 50 | ui->lblErrorMsg->hide(); 51 | 52 | if(! selectedFilePath.isEmpty()) 53 | { 54 | QStringList lines = FileUtil::readListFromFile(selectedFilePath); 55 | 56 | if(! lines.isEmpty()) 57 | { 58 | ui->txtStartupAppName->setText(Utilities::getDesktopValue(NAME_REG, lines)); 59 | ui->txtStartupAppComment->setText(Utilities::getDesktopValue(COMMENT_REG, lines)); 60 | ui->txtStartupAppCommand->setText(Utilities::getDesktopValue(EXEC_REG, lines)); 61 | } 62 | } 63 | 64 | QDialog::show(); 65 | } 66 | 67 | void StartupAppEdit::changeDesktopValue(QStringList &lines, const QRegExp ®, const QString &text) 68 | { 69 | int pos = lines.indexOf(reg); 70 | 71 | if (pos != -1) { 72 | lines.replace(pos, text); 73 | } else { 74 | lines.append(text); 75 | } 76 | } 77 | 78 | void StartupAppEdit::on_btnSave_clicked() 79 | { 80 | if(isValid()) { 81 | if(! selectedFilePath.isEmpty()) { 82 | QStringList lines = FileUtil::readListFromFile(selectedFilePath); 83 | 84 | changeDesktopValue(lines, NAME_REG, QString("Name=%1").arg(ui->txtStartupAppName->text())); 85 | changeDesktopValue(lines, COMMENT_REG, QString("Comment=%1").arg(ui->txtStartupAppComment->text())); 86 | changeDesktopValue(lines, EXEC_REG, QString("Exec=%1").arg(ui->txtStartupAppCommand->text())); 87 | 88 | FileUtil::writeFile(selectedFilePath, lines.join("\n"), QIODevice::ReadWrite | QIODevice::Truncate); 89 | } 90 | else { 91 | // new file content 92 | QString appContent = mNewAppTemplate 93 | .arg(ui->txtStartupAppName->text()) 94 | .arg(ui->txtStartupAppComment->text()) 95 | .arg(ui->txtStartupAppCommand->text()); 96 | 97 | // file name 98 | QString appFileName = ui->txtStartupAppName->text() 99 | .simplified() 100 | .replace(' ', '-') 101 | .toLower(); 102 | 103 | qDebug() << appFileName; 104 | 105 | QString path = QString("%1/%2.desktop").arg(mAutostartPath).arg(appFileName); 106 | 107 | FileUtil::writeFile(path, appContent); 108 | } 109 | 110 | emit startupAppAdded(); // signal 111 | close(); 112 | } 113 | else { 114 | ui->lblErrorMsg->show(); 115 | } 116 | 117 | selectedFilePath = ""; 118 | } 119 | 120 | bool StartupAppEdit::isValid() 121 | { 122 | return ! ui->txtStartupAppName->text().isEmpty() && 123 | ! ui->txtStartupAppComment->text().isEmpty() && 124 | ! ui->txtStartupAppCommand->text().isEmpty(); 125 | } 126 | -------------------------------------------------------------------------------- /stacer/Pages/StartupApps/startup_app_edit.h: -------------------------------------------------------------------------------- 1 | #ifndef STARTUP_APP_EDIT_H 2 | #define STARTUP_APP_EDIT_H 3 | 4 | #include 5 | #include 6 | 7 | #include "Managers/app_manager.h" 8 | 9 | #define NAME_REG QRegExp("^Name=.*") 10 | #define COMMENT_REG QRegExp("^Comment=.*") 11 | #define EXEC_REG QRegExp("^Exec=.*") 12 | #define GNOME_ENABLED_REG QRegExp("^X-GNOME-Autostart-enabled=.*") 13 | #define HIDDEN_REG QRegExp("^Hidden=.*") 14 | 15 | namespace Ui { 16 | class StartupAppEdit; 17 | } 18 | 19 | class StartupAppEdit : public QDialog 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | explicit StartupAppEdit(QWidget *parent = 0); 25 | ~StartupAppEdit(); 26 | 27 | public: 28 | static QString selectedFilePath; 29 | 30 | signals: 31 | void startupAppAdded(); 32 | 33 | public slots: 34 | void show(); 35 | 36 | private slots: 37 | void init(); 38 | bool isValid(); 39 | void on_btnSave_clicked(); 40 | void changeDesktopValue(QStringList &lines, const QRegExp ®, const QString &text); 41 | 42 | private: 43 | Ui::StartupAppEdit *ui; 44 | 45 | private: 46 | QString mNewAppTemplate; 47 | QString mAutostartPath; 48 | }; 49 | 50 | #endif // STARTUP_APP_EDIT_H 51 | -------------------------------------------------------------------------------- /stacer/Pages/StartupApps/startup_app_edit.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | StartupAppEdit 4 | 5 | 6 | 7 | 0 8 | 0 9 | 380 10 | 227 11 | 12 | 13 | 14 | 15 | 380 16 | 0 17 | 18 | 19 | 20 | Startup App 21 | 22 | 23 | true 24 | 25 | 26 | 27 | 30 28 | 29 | 30 | 20 31 | 32 | 33 | 30 34 | 35 | 36 | 15 37 | 38 | 39 | 15 40 | 41 | 42 | 43 | 44 | Fields cannot be left blank. 45 | 46 | 47 | 48 | 49 | 50 | 51 | App Name 52 | 53 | 54 | 55 | 56 | 57 | 58 | App Comment 59 | 60 | 61 | 62 | 63 | 64 | 65 | PointingHandCursor 66 | 67 | 68 | Qt::NoFocus 69 | 70 | 71 | primary 72 | 73 | 74 | Save 75 | 76 | 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | dialog-title 85 | 86 | 87 | Application 88 | 89 | 90 | Qt::AlignCenter 91 | 92 | 93 | 94 | 95 | 96 | 97 | Command 98 | 99 | 100 | 101 | 102 | 103 | 104 | Qt::Vertical 105 | 106 | 107 | 108 | 20 109 | 40 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | txtStartupAppName 118 | txtStartupAppComment 119 | txtStartupAppCommand 120 | btnSave 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /stacer/Pages/StartupApps/startup_apps_page.h: -------------------------------------------------------------------------------- 1 | #ifndef STARTUPAPPSPAGE_H 2 | #define STARTUPAPPSPAGE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "startup_app.h" 11 | #include "startup_app_edit.h" 12 | 13 | #include "Utils/file_util.h" 14 | 15 | namespace Ui { 16 | class StartupAppsPage; 17 | } 18 | 19 | class StartupAppsPage : public QWidget 20 | { 21 | Q_OBJECT 22 | 23 | public: 24 | explicit StartupAppsPage(QWidget *parent = 0); 25 | ~StartupAppsPage(); 26 | 27 | public slots: 28 | void loadApps(); 29 | 30 | private slots: 31 | void init(); 32 | void openStartupAppEdit(const QString filePath = QString()); 33 | void setAppCount(); 34 | 35 | private: 36 | Ui::StartupAppsPage *ui; 37 | 38 | private: 39 | QSharedPointer mStartupAppEdit; 40 | 41 | QFileSystemWatcher mFileSystemWatcher; 42 | QString mAutostartPath; 43 | 44 | bool checkIfDisabled(const QString& as_path); 45 | }; 46 | 47 | #endif // STARTUPAPPSPAGE_H 48 | -------------------------------------------------------------------------------- /stacer/Pages/SystemCleaner/byte_tree_widget.cpp: -------------------------------------------------------------------------------- 1 | #include "byte_tree_widget.h" 2 | 3 | void ByteTreeWidget::setValues(const QString &text, const quint64 &size, const QVariant &data) { 4 | this->setText(0, text); 5 | this->setText(1, FormatUtil::formatBytes(size)); 6 | this->setData(1, 0x0100, size); 7 | this->setData(2, 0, data); 8 | this->setCheckState(0, Qt::Unchecked); 9 | } 10 | 11 | bool ByteTreeWidget::operator<(const QTreeWidgetItem &other) const 12 | { 13 | int column = treeWidget()->sortColumn(); 14 | // sort by bytes 15 | if(column == 1) { 16 | return this->data(1, 0x0100) < other.data(1, 0x0100); 17 | } 18 | // default sorting 19 | return text(column).toLower() < other.text(column).toLower(); 20 | } 21 | -------------------------------------------------------------------------------- /stacer/Pages/SystemCleaner/byte_tree_widget.h: -------------------------------------------------------------------------------- 1 | #ifndef BYTE_TREE_WIDGET_H 2 | #define BYTE_TREE_WIDGET_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | class ByteTreeWidget : public QTreeWidgetItem 10 | { 11 | public: 12 | ByteTreeWidget(QTreeWidget* parent) : QTreeWidgetItem(parent) {} 13 | ByteTreeWidget(QTreeWidgetItem* parent) : QTreeWidgetItem(parent) {} 14 | 15 | void setValues(const QString &text, const quint64 &size, const QVariant &data); 16 | 17 | virtual bool operator<(const QTreeWidgetItem &other) const; 18 | }; 19 | 20 | #endif // BYTE_TREE_WIDGET_H 21 | -------------------------------------------------------------------------------- /stacer/Pages/SystemCleaner/system_cleaner_page.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEMCLEANERPAGE_H 2 | #define SYSTEMCLEANERPAGE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "Managers/app_manager.h" 13 | 14 | #include 15 | #include 16 | 17 | namespace Ui { 18 | class SystemCleanerPage; 19 | } 20 | 21 | class SystemCleanerPage : public QWidget 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | enum CleanCategories { 27 | PACKAGE_CACHE, 28 | CRASH_REPORTS, 29 | APPLICATION_LOGS, 30 | APPLICATION_CACHES, 31 | TRASH 32 | }; 33 | 34 | public: 35 | explicit SystemCleanerPage(QWidget *parent = nullptr); 36 | ~SystemCleanerPage(); 37 | 38 | private slots: 39 | quint64 addTreeRoot(const CleanCategories &cat, const QString &title, const QFileInfoList &infos, bool noChild = false); 40 | void addTreeChild(const CleanCategories &cat, const QString &text, const quint64 &size); 41 | void addTreeChild(const QString &data, const QString &text, const quint64 &size, QTreeWidgetItem *parent); 42 | 43 | void on_treeWidgetScanResult_itemClicked(QTreeWidgetItem *item, const int &column); 44 | void on_btnClean_clicked(); 45 | void on_btnScan_clicked(); 46 | void on_btnBackToCategories_clicked(); 47 | 48 | void systemScan(); 49 | void systemClean(); 50 | bool cleanValid(); 51 | 52 | void on_checkSelectAllSystemScan_clicked(bool checked); 53 | void on_checkSelectAll_clicked(bool check); 54 | void on_cbSortBy_currentIndexChanged(int idx); 55 | 56 | private: 57 | void init(); 58 | 59 | private: 60 | Ui::SystemCleanerPage *ui; 61 | 62 | InfoManager *im; 63 | ToolManager *tmr; 64 | 65 | QIcon mDefaultIcon; 66 | QMovie *mLoadingMovie; 67 | QMovie *mLoadingMovie_2; 68 | }; 69 | 70 | #endif // SYSTEMCLEANERPAGE_H 71 | -------------------------------------------------------------------------------- /stacer/Pages/Uninstaller/uninstaller_page.h: -------------------------------------------------------------------------------- 1 | #ifndef UNINSTALLERPAGE_H 2 | #define UNINSTALLERPAGE_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "Managers/tool_manager.h" 9 | #include "Managers/app_manager.h" 10 | #include "signal_mapper.h" 11 | 12 | namespace Ui { 13 | class UninstallerPage; 14 | } 15 | 16 | class UninstallerPage : public QWidget 17 | { 18 | Q_OBJECT 19 | 20 | public: 21 | explicit UninstallerPage(QWidget *parent = 0); 22 | ~UninstallerPage(); 23 | 24 | public slots: 25 | void uninstallStarted(); 26 | 27 | private: 28 | void init(); 29 | 30 | private slots: 31 | void setAppCount(); 32 | void on_txtPackageSearch_textChanged(const QString &val); 33 | void on_btnUninstall_clicked(); 34 | QStringList getSelectedPackages(); 35 | QStringList getSelectedSnapPackages(); 36 | void loadPackages(); 37 | void loadSnapPackages(); 38 | void on_btnSystemPackages_clicked(); 39 | void on_btnSnapPackages_clicked(); 40 | 41 | void on_listWidgetSnapPackages_itemClicked(QListWidgetItem *item); 42 | void on_listWidgetPackages_itemClicked(QListWidgetItem *item); 43 | 44 | private: 45 | Ui::UninstallerPage *ui; 46 | 47 | ToolManager *tm; 48 | }; 49 | 50 | #endif // UNINSTALLERPAGE_H 51 | -------------------------------------------------------------------------------- /stacer/app.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_H 2 | #define APP_H 3 | 4 | #include 5 | 6 | #include "sliding_stacked_widget.h" 7 | #include "Managers/app_manager.h" 8 | #include "Managers/setting_manager.h" 9 | 10 | // Pages 11 | #include "Pages/Dashboard/dashboard_page.h" 12 | #include "Pages/StartupApps/startup_apps_page.h" 13 | #include "Pages/SystemCleaner/system_cleaner_page.h" 14 | #include "Pages/Services/services_page.h" 15 | #include "Pages/Processes/processes_page.h" 16 | #include "Pages/Uninstaller/uninstaller_page.h" 17 | #include "Pages/Resources/resources_page.h" 18 | #include "Pages/Settings/settings_page.h" 19 | #include "Pages/AptSourceManager/apt_source_manager_page.h" 20 | #include "Pages/GnomeSettings/gnome_settings_page.h" 21 | #include "Pages/Search/search_page.h" 22 | #include "Pages/Helpers/helpers_page.h" 23 | #include "feedback.h" 24 | 25 | namespace Ui { 26 | class App; 27 | } 28 | 29 | class App : public QMainWindow 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | explicit App(QWidget *parent = 0); 35 | ~App(); 36 | 37 | protected: 38 | void closeEvent(QCloseEvent *event) override; 39 | 40 | private slots: 41 | void init(); 42 | void pageClick(QWidget *widget, bool slide = true); 43 | void clickSidebarButton(QString pageTitle, bool isShow = false); 44 | 45 | void on_btnDash_clicked(); 46 | void on_btnSystemCleaner_clicked(); 47 | void on_btnStartupApps_clicked(); 48 | void on_btnServices_clicked(); 49 | void on_btnSearch_clicked(); 50 | void on_btnUninstaller_clicked(); 51 | void on_btnHelpers_clicked(); 52 | void on_btnResources_clicked(); 53 | void on_btnProcesses_clicked(); 54 | void on_btnSettings_clicked(); 55 | void on_btnGnomeSettings_clicked(); 56 | void on_btnAptSourceManager_clicked(); 57 | 58 | void on_btnFeedback_clicked(); 59 | 60 | private: 61 | QWidget *getPageByTitle(const QString &title); 62 | void checkSidebarButtonByTooltip(const QString &text); 63 | void createTrayActions(); 64 | void createQuitMessageBox(); 65 | 66 | private: 67 | Ui::App *ui; 68 | 69 | // Pages 70 | QList mListPages; 71 | QList mListSidebarButtons; 72 | 73 | SlidingStackedWidget *mSlidingStacked; 74 | 75 | DashboardPage *dashboardPage; 76 | StartupAppsPage *startupAppsPage; 77 | SystemCleanerPage *systemCleanerPage; 78 | SearchPage *searchPage; 79 | ServicesPage *servicesPage; 80 | ProcessesPage *processPage; 81 | UninstallerPage *uninstallerPage; 82 | ResourcesPage *resourcesPage; 83 | APTSourceManagerPage *aptSourceManagerPage; 84 | GnomeSettingsPage *gnomeSettingsPage; 85 | SettingsPage *settingsPage; 86 | HelpersPage *helpersPage; 87 | 88 | QSharedPointer feedback; 89 | 90 | QSystemTrayIcon *mTrayIcon; 91 | 92 | QMenu *mTrayMenu; 93 | 94 | QPushButton *mBtnQuit, *mBtnContinue; 95 | QMessageBox *mQuitMsgBox; 96 | }; 97 | 98 | #endif // APP_H 99 | -------------------------------------------------------------------------------- /stacer/feedback.cpp: -------------------------------------------------------------------------------- 1 | #include "feedback.h" 2 | #include "ui_feedback.h" 3 | #include "Utils/command_util.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | Feedback::~Feedback() 11 | { 12 | delete ui; 13 | } 14 | 15 | Feedback::Feedback(QWidget *parent) : 16 | QDialog(parent), 17 | ui(new Ui::Feedback), 18 | mHeader("Content-Type: application/json"), 19 | mFeedbackUrl("https://stacer-web-api.herokuapp.com/feedback"), 20 | mMailRegex("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b") 21 | { 22 | ui->setupUi(this); 23 | 24 | init(); 25 | } 26 | 27 | void Feedback::init() 28 | { 29 | mMailRegex.setCaseSensitivity(Qt::CaseInsensitive); 30 | mMailRegex.setPatternSyntax(QRegExp::RegExp); 31 | 32 | connect(this, &Feedback::clearInputsS, this, &Feedback::clearInputs); 33 | connect(this, &Feedback::setErrorMessageS, this, &Feedback::setErrorMessage); 34 | connect(this, &Feedback::disableElementsS, this, &Feedback::disableElements); 35 | } 36 | 37 | void Feedback::on_btnSend_clicked() 38 | { 39 | QString name = ui->txtName->text(); 40 | QString email = ui->txtEmail->text(); 41 | QString message = ui->txtMessage->toPlainText(); 42 | 43 | bool isEmailValid = mMailRegex.exactMatch(email); 44 | 45 | if (! isEmailValid) { 46 | emit setErrorMessageS(tr("Email address is not valid !")); 47 | return; 48 | } 49 | 50 | if (message.length() < 5) { 51 | emit setErrorMessageS(tr("Your message must be at least 5 characters !")); 52 | return; 53 | } 54 | 55 | if (! name.isEmpty() && 56 | ! email.isEmpty() && isEmailValid) 57 | { 58 | QtConcurrent::run([=] { 59 | emit disableElementsS(true); 60 | 61 | ui->btnSend->setText(tr("Sending..")); 62 | QStringList args; 63 | 64 | QJsonObject postData; 65 | postData["name"] = name; 66 | postData["email"] = email; 67 | postData["message"] = message; 68 | 69 | QJsonDocument json(postData); 70 | 71 | args << "-d" << json.toJson() << "-H" << mHeader << "-X" << "POST" << mFeedbackUrl; 72 | 73 | try { 74 | QString result = CommandUtil::exec("curl", args); 75 | QJsonObject response = QJsonDocument::fromJson(result.toUtf8()).object(); 76 | 77 | if (response.value("success").toBool()) { 78 | emit clearInputs(); 79 | emit setErrorMessageS(tr("Your Feedback has been successfully sended.")); 80 | } else { 81 | emit setErrorMessageS(tr("Something went wrong, try again !")); 82 | } 83 | 84 | } catch(QString &ex) { 85 | qCritical() << ex; 86 | emit setErrorMessageS(tr("Something went wrong, try again !")); 87 | } 88 | 89 | ui->btnSend->setText(tr("Save")); 90 | emit disableElementsS(false); 91 | }); 92 | 93 | } else { 94 | emit setErrorMessageS(tr("Fields cannot be left blank !")); 95 | } 96 | } 97 | 98 | void Feedback::setErrorMessage(const QString &msg) 99 | { 100 | ui->lblErrorMsg->setText(msg); 101 | } 102 | 103 | void Feedback::disableElements(const bool status) 104 | { 105 | ui->txtName->setDisabled(status); 106 | ui->txtEmail->setDisabled(status); 107 | ui->txtMessage->setDisabled(status); 108 | ui->btnSend->setDisabled(status); 109 | } 110 | 111 | void Feedback::clearInputs() 112 | { 113 | ui->txtName->clear(); 114 | ui->txtEmail->clear(); 115 | ui->txtMessage->clear(); 116 | ui->txtName->setFocus(); 117 | } 118 | 119 | void Feedback::on_btnClose_clicked() 120 | { 121 | this->close(); 122 | } 123 | -------------------------------------------------------------------------------- /stacer/feedback.h: -------------------------------------------------------------------------------- 1 | #ifndef FEEDBACK_H 2 | #define FEEDBACK_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class Feedback; 8 | } 9 | 10 | class Feedback : public QDialog 11 | { 12 | Q_OBJECT 13 | 14 | public: 15 | explicit Feedback(QWidget *parent = 0); 16 | ~Feedback(); 17 | 18 | signals: 19 | void setErrorMessageS(const QString &msg); 20 | void clearInputsS(); 21 | void disableElementsS(const bool status); 22 | 23 | private slots: 24 | void setErrorMessage(const QString &msg); 25 | void on_btnSend_clicked(); 26 | void clearInputs(); 27 | void disableElements(const bool status); 28 | 29 | void on_btnClose_clicked(); 30 | 31 | private: 32 | void init(); 33 | 34 | private: 35 | Ui::Feedback *ui; 36 | 37 | QString mHeader; 38 | QString mFeedbackUrl; 39 | 40 | QRegExp mMailRegex; 41 | }; 42 | 43 | #endif // FEEDBACK_H 44 | -------------------------------------------------------------------------------- /stacer/feedback.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Feedback 4 | 5 | 6 | 7 | 0 8 | 0 9 | 476 10 | 350 11 | 12 | 13 | 14 | Feedback 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 30 22 | 23 | 24 | 20 25 | 26 | 27 | 30 28 | 29 | 30 | 20 31 | 32 | 33 | 15 34 | 35 | 36 | 37 | 38 | Qt::Vertical 39 | 40 | 41 | QSizePolicy::Maximum 42 | 43 | 44 | 45 | 359 46 | 2 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Message 55 | 56 | 57 | 58 | 59 | 60 | 61 | Name 62 | 63 | 64 | 65 | 66 | 67 | 68 | Email Address 69 | 70 | 71 | 72 | 73 | 74 | 75 | dialog-title 76 | 77 | 78 | Send a Feedback 79 | 80 | 81 | Qt::AlignCenter 82 | 83 | 84 | 85 | 86 | 87 | 88 | PointingHandCursor 89 | 90 | 91 | Qt::NoFocus 92 | 93 | 94 | primary 95 | 96 | 97 | Send 98 | 99 | 100 | true 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | PointingHandCursor 115 | 116 | 117 | danger 118 | 119 | 120 | Close 121 | 122 | 123 | 124 | 125 | 126 | 127 | txtName 128 | txtEmail 129 | txtMessage 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /stacer/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "app.h" 8 | 9 | void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message) 10 | { 11 | Q_UNUSED(context) 12 | 13 | QString level; 14 | 15 | switch (type) { 16 | case QtDebugMsg: 17 | level = "DEBUG"; break; 18 | case QtInfoMsg: 19 | level = "INFO"; break; 20 | case QtWarningMsg: 21 | level = "WARNING"; break; 22 | case QtCriticalMsg: 23 | level = "CRITICAL"; break; 24 | case QtFatalMsg: 25 | level = "FATAL"; break; 26 | default: 27 | level = "UNDEFIEND"; break; 28 | } 29 | 30 | if (type != QtWarningMsg) { 31 | 32 | QString text = QString("[%1] [%2] %3") 33 | .arg(QDateTime::currentDateTime().toString("dd-MM-yyyy hh:mm:ss")) 34 | .arg(level) 35 | .arg(message); 36 | 37 | static QString logPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); 38 | 39 | QFile file(logPath + "/stacer.log"); 40 | 41 | QIODevice::OpenMode openMode = file.size() > (1L << 20) ? QIODevice::Truncate : QIODevice::Append; 42 | 43 | if (file.open(QIODevice::WriteOnly | openMode)) { 44 | QTextStream stream(&file); 45 | stream << text << endl; 46 | 47 | file.close(); 48 | } 49 | } 50 | } 51 | 52 | int main(int argc, char *argv[]) 53 | { 54 | QApplication app(argc, argv); 55 | 56 | qApp->setApplicationName("stacer"); 57 | qApp->setApplicationDisplayName("Stacer"); 58 | qApp->setApplicationVersion("1.1.0"); 59 | qApp->setWindowIcon(QIcon(":/static/logo.png")); 60 | 61 | { 62 | QCommandLineOption hideOption("hide", "Hide Stacer while launching."); 63 | QCommandLineOption noSplashOption("nosplash", "Hide splash screen while launching."); 64 | QCommandLineParser parser; 65 | parser.addVersionOption(); 66 | parser.addHelpOption(); 67 | parser.addOption(hideOption); 68 | parser.addOption(noSplashOption); 69 | parser.process(app); 70 | } 71 | 72 | bool isHide = false; 73 | bool isNoSplash = false; 74 | 75 | QLatin1String hideOption("--hide"); 76 | QLatin1String noSplashOption("--nosplash"); 77 | 78 | for (size_t i = 1; i < argc; ++i) { 79 | if (QString(argv[i]) == hideOption) 80 | isHide = true; 81 | else if (QString(argv[i]) == noSplashOption) 82 | isNoSplash = true; 83 | } 84 | 85 | QFontDatabase::addApplicationFont(":/static/font/Ubuntu-R.ttf"); 86 | 87 | QPixmap pixSplash(":/static/splashscreen.png"); 88 | 89 | QSplashScreen *splash = new QSplashScreen(pixSplash); 90 | 91 | if (!isNoSplash) splash->show(); 92 | 93 | app.processEvents(); 94 | 95 | App w; 96 | 97 | if (argc < 2 || !isHide) { 98 | w.show(); 99 | } 100 | 101 | splash->finish(&w); 102 | 103 | delete splash; 104 | 105 | return app.exec(); 106 | } 107 | -------------------------------------------------------------------------------- /stacer/signal_mapper.cpp: -------------------------------------------------------------------------------- 1 | #include "signal_mapper.h" 2 | 3 | SignalMapper *SignalMapper::instance = nullptr; 4 | 5 | SignalMapper* SignalMapper::ins() 6 | { 7 | if (! instance) { 8 | instance = new SignalMapper; 9 | } 10 | return instance; 11 | } 12 | -------------------------------------------------------------------------------- /stacer/signal_mapper.h: -------------------------------------------------------------------------------- 1 | #ifndef SIGNAL_MAPPER_H 2 | #define SIGNAL_MAPPER_H 3 | 4 | #include 5 | 6 | class SignalMapper : public QObject 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | static SignalMapper *ins(); 12 | 13 | signals: 14 | void sigChangedAppTheme(); 15 | void sigUninstallStarted(); 16 | void sigUninstallFinished(); 17 | 18 | private: 19 | static SignalMapper *instance; 20 | 21 | }; 22 | 23 | #endif // SIGNAL_MAPPER_H 24 | -------------------------------------------------------------------------------- /stacer/sliding_stacked_widget.h: -------------------------------------------------------------------------------- 1 | #ifndef SLIDINGSTACKEDWIDGET_H 2 | #define SLIDINGSTACKEDWIDGET_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class SlidingStackedWidget : public QStackedWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | // This enumeration is used to define the animation direction 17 | enum t_direction { 18 | LEFT2RIGHT, 19 | RIGHT2LEFT, 20 | TOP2BOTTOM, 21 | BOTTOM2TOP, 22 | AUTOMATIC 23 | }; 24 | 25 | SlidingStackedWidget(QWidget *parent); 26 | 27 | public slots: 28 | void setSpeed(int speed); // animation duration in milliseconds 29 | void setAnimation(const QEasingCurve::Type animationtype); // check out the QEasingCurve documentation for different styles 30 | void setVerticalMode(bool vertical = true); 31 | 32 | void slideInNext(); 33 | void slideInPrev(); 34 | void slideInIdx(int idx, t_direction direction = AUTOMATIC); 35 | 36 | signals: 37 | void animationFinished(); 38 | 39 | private slots: 40 | void animationDoneSlot(); 41 | 42 | private: 43 | void slideInWgt(QWidget *widget, t_direction direction = AUTOMATIC); 44 | 45 | enum QEasingCurve::Type animationtype; 46 | int speed; 47 | bool vertical; 48 | int now; 49 | int next; 50 | QPoint pnow; 51 | bool active; 52 | }; 53 | 54 | #endif // SLIDINGSTACKEDWIDGET_H 55 | -------------------------------------------------------------------------------- /stacer/static/font/Ubuntu-R.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/font/Ubuntu-R.ttf -------------------------------------------------------------------------------- /stacer/static/languages.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"value" : "ar", "text": "العربية"}, 3 | {"value" : "ca-es", "text": "Català"}, 4 | {"value" : "cs", "text": "Čeština"}, 5 | {"value" : "de", "text": "Deutsch"}, 6 | {"value" : "en", "text": "English"}, 7 | {"value" : "ko", "text": "한국어"}, 8 | {"value" : "es", "text": "Español"}, 9 | {"value" : "fr", "text": "Français"}, 10 | {"value" : "hi", "text": "हिंदी"}, 11 | {"value" : "hu", "text": "Magyar"}, 12 | {"value" : "it", "text": "Italiano"}, 13 | {"value" : "kn", "text": "ಕನ್ನಡ"}, 14 | {"value" : "ml", "text": "മലയാളം"}, 15 | {"value" : "nl", "text": "Nederlands"}, 16 | {"value" : "oc", "text": "Occitan"}, 17 | {"value" : "pl", "text": "Polski"}, 18 | {"value" : "pt", "text": "Português - Brasil"}, 19 | {"value" : "ru", "text": "Русский"}, 20 | {"value" : "sv", "text": "Svenska"}, 21 | {"value" : "tr", "text": "Türkçe"}, 22 | {"value" : "ua", "text": "Українська"}, 23 | {"value" : "vn", "text": "Tiếng việt"}, 24 | {"value" : "zh-cn", "text": "简体中文"}, 25 | {"value" : "zh-tw", "text": "正體中文"} 26 | ] 27 | -------------------------------------------------------------------------------- /stacer/static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/logo.png -------------------------------------------------------------------------------- /stacer/static/splashscreen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/splashscreen.png -------------------------------------------------------------------------------- /stacer/static/themes.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"value" : "default", "text": "Default"}, 3 | {"value" : "light", "text": "Light"} 4 | ] 5 | -------------------------------------------------------------------------------- /stacer/static/themes/common/img/appearance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/appearance.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/check.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/checkbox.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/delete.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/donate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/donate.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/folder.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/not-found.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/not-found.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/package.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/spindown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/spindown.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/spinup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/spinup.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/trash_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/trash_2.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/ubuntu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/ubuntu.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/un-check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/un-check.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/un-checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/un-checkbox.png -------------------------------------------------------------------------------- /stacer/static/themes/common/img/window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/common/img/window.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/app.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/asc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/asc.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/back.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/c_cache.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/c_cache.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/c_crash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/c_crash.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/c_logs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/c_logs.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/c_package.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/c_package.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/c_trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/c_trash.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/clean-active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/clean-active.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/clean.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/collapse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/collapse.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/down-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/down-arrow.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/dsc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/dsc.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/edit.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/fit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/fit.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/loading.gif -------------------------------------------------------------------------------- /stacer/static/themes/default/img/loadings.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/loadings.gif -------------------------------------------------------------------------------- /stacer/static/themes/default/img/power.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/power.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/ppa-repository.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/ppa-repository.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/refresh.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/right-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/right-arrow.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/run.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/run.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/scan-active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/scan-active.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/scan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/scan.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/scanLoading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/scanLoading.gif -------------------------------------------------------------------------------- /stacer/static/themes/default/img/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/search.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/service.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/service.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/cleaner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/cleaner.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/dash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/dash.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/feedback.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/feedback.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/gnome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/gnome.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/helpers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/helpers.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/ppa-manager.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/ppa-manager.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/process.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/process.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/resources.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/resources.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/search.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/services.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/services.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/settings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/settings.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/startup-apps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/startup-apps.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/sidebar-icons/uninstaller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/sidebar-icons/uninstaller.png -------------------------------------------------------------------------------- /stacer/static/themes/default/img/trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/default/img/trash.png -------------------------------------------------------------------------------- /stacer/static/themes/default/style/values.ini: -------------------------------------------------------------------------------- 1 | @pageContent=#1b252f 2 | @sidebar=#15191c 3 | @circleChartBackgroundColor=#212f3c 4 | @historyChartBackgroundColor=#212f3c 5 | @chartLabelColor=#7d8ea0 6 | @chartGridColor=#7d8ea0 7 | @color01=#212f3c 8 | @color02=#263848 9 | @color03=#075ffe 10 | @color04=#8394a6 11 | @color05=#eeeeee 12 | @color06=#7d8ea0 13 | @color07=#ffffff 14 | @color08=#1b252f 15 | @color09=#f44336 16 | @color10=#075fbb 17 | @color11=#dddddd 18 | @color12=#aeb5bf 19 | @color13=#293945 20 | @color14=#314452 21 | @color15=#00eb55 22 | @color16=#00d4ff 23 | -------------------------------------------------------------------------------- /stacer/static/themes/light/img/app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/app.png -------------------------------------------------------------------------------- /stacer/static/themes/light/img/clean-active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/clean-active.png -------------------------------------------------------------------------------- /stacer/static/themes/light/img/clean.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/clean.png -------------------------------------------------------------------------------- /stacer/static/themes/light/img/collapse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/collapse.png -------------------------------------------------------------------------------- /stacer/static/themes/light/img/down-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/down-arrow.png -------------------------------------------------------------------------------- /stacer/static/themes/light/img/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/edit.png -------------------------------------------------------------------------------- /stacer/static/themes/light/img/fit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/fit.png -------------------------------------------------------------------------------- /stacer/static/themes/light/img/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/loading.gif -------------------------------------------------------------------------------- /stacer/static/themes/light/img/ppa-repository.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/ppa-repository.png -------------------------------------------------------------------------------- /stacer/static/themes/light/img/right-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/right-arrow.png -------------------------------------------------------------------------------- /stacer/static/themes/light/img/scan-active.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/scan-active.png -------------------------------------------------------------------------------- /stacer/static/themes/light/img/scan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/scan.png -------------------------------------------------------------------------------- /stacer/static/themes/light/img/scanLoading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/scanLoading.gif -------------------------------------------------------------------------------- /stacer/static/themes/light/img/trash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/oguzhaninan/Stacer/a44d0565a05c996b1058f950f1d308e1964c8320/stacer/static/themes/light/img/trash.png -------------------------------------------------------------------------------- /stacer/static/themes/light/style/values.ini: -------------------------------------------------------------------------------- 1 | @pageContent=#ecf0f1 2 | @sidebar=#15191c 3 | @circleChartBackgroundColor=#ffffff 4 | @historyChartBackgroundColor=#ffffff 5 | @chartLabelColor=#7d8ea0 6 | @chartGridColor=#8394a6 7 | @color01=#fdfdfd 8 | @color02=#7d8ea0 9 | @color03=#075ffe 10 | @color04=#00eb55 11 | @color05=#eeeeee 12 | @color06=#00d4ff 13 | @color07=#f6fafd 14 | @color08=#aeb5bf 15 | @color09=#8394a6 16 | @color10=#075fbb 17 | @color11=#f44336 18 | -------------------------------------------------------------------------------- /stacer/utilities.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILITIES_H 2 | #define UTILITIES_H 3 | 4 | #include 5 | #include 6 | 7 | class Utilities 8 | { 9 | public: 10 | static void 11 | addDropShadow(QWidget *widget, const int alpha, const int blur = 15) 12 | { 13 | addDropShadow(QList() << widget, alpha, blur); 14 | } 15 | 16 | static void 17 | addDropShadow(QList widgets, const int alpha, const int blur = 15) 18 | { 19 | for (QWidget *widget: widgets) { 20 | QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(widget); 21 | effect->setBlurRadius(blur); 22 | effect->setColor(QColor(0, 0, 0, alpha)); 23 | effect->setOffset(0); 24 | widget->setGraphicsEffect(effect); 25 | } 26 | } 27 | 28 | static QString 29 | getDesktopValue(const QRegExp &val, const QStringList &lines) 30 | { 31 | QStringList filteredList = lines.filter(val); 32 | if (filteredList.count() > 0) { 33 | QStringList directive = filteredList.first().trimmed().split("="); 34 | if (directive.count() > 1) { 35 | return directive.last().trimmed(); 36 | } 37 | } 38 | return QString(""); 39 | } 40 | }; 41 | 42 | #endif // UTILITIES_H 43 | --------------------------------------------------------------------------------