.
================================================
FILE: README.md
================================================
⚠️ This project has been abandoned. There will be no further releases ⚠️
Linux System Optimizer and Monitoring
## Reviews
### Required Packages
- curl, systemd
### PPA Repository (for ubuntu)
1. `sudo add-apt-repository ppa:oguzhaninan/stacer -y`
2. `sudo apt-get update`
3. `sudo apt-get install stacer -y`
### Arch Linux (AUR)
1. Install the stacer package with a AUR helper of your choice eg.
2. `yay -Syyu stacer`
3. `paru -S stacer`
4. `pacaur -a stacer`
### Debian x64
1. Download `stacer_1.1.0_amd64.deb` from the [Stacer releases page](https://github.com/oguzhaninan/Stacer/releases).
2. Run `sudo dpkg -i stacer*.deb` on the downloaded package.
3. Launch Stacer using the installed `stacer` command.
### Debian sid / Ubuntu 20.04+
1. Run as root `apt install stacer`
### Fedora
1. Download `stacer_1.1.0_amd64.rpm` from the [Stacer releases page](https://github.com/oguzhaninan/Stacer/releases).
2. Run `sudo rpm --install stacer*.rpm --nodeps --force` on the downloaded package.
3. Launch Stacer using the installed `stacer` command.
### Fedora (with DNF)
1. Run: `sudo dnf install stacer`
2. Launch Stacer using the installed `stacer` command.
## Build from source with CMake (Qt Version Qt 5.x)
1. `mkdir build && cd build`
2. `cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/qt/path/bin ..`
3. `make -j $(nproc)`
4. `output/bin/stacer`
## Screenshots
## Contributors
### Code Contributors
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
### Financial Contributors
Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/Stacer/contribute)]
#### Individuals
#### Organizations
Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/Stacer/contribute)]
================================================
FILE: Stacer.pro
================================================
TEMPLATE = subdirs
SUBDIRS += \
stacer-core \
stacer
================================================
FILE: applications/stacer.desktop
================================================
[Desktop Entry]
Name=Stacer
Exec=stacer
Comment=Linux System Optimizer and Monitoring
Icon=stacer
Type=Application
Terminal=false
Categories=Utility;
================================================
FILE: cmake/cxxbasics/CXXBasics.cmake
================================================
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
# Variables necessary in every module
include(InitCXXBasics)
# Set reasonable CMake defaults
include(DefaultSettings)
# Activate faster linkers by default
include(accelerators/UseFasterLinkers)
# Activate the compiler cache tool
include(accelerators/UseCompilerCacheTool)
# Allow the user to extend CXXBasics
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../cxxbasics-extension.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/../cxxbasics-extension.cmake")
endif()
================================================
FILE: cmake/cxxbasics/DefaultSettings.cmake
================================================
# This module sets reasonable defaults that probably every C/C++ CMake project should
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
# Default build type "Debug"
opt_ifndef("Build Type(Debug, Release, RelWithDebInfo, MinSizeRel)" STRING "Debug" CMAKE_BUILD_TYPE)
# Generate "compile_commands.json" - tools like clang-tidy can be run on this file
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
================================================
FILE: cmake/cxxbasics/InitCXXBasics.cmake
================================================
## This module defines common functions and variables that should be accessible in every module
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
# Enable C and CXX by default. This allows to run some commands in script mode, or using "-C"
enable_language(C)
enable_language(CXX)
# Project custom messaging macros
include(helpers/MacroCustomMessages)
# Widely-used macros to handle the cache variables
include(helpers/MacroOpt)
================================================
FILE: cmake/cxxbasics/UNLICENSE
================================================
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to
================================================
FILE: cmake/cxxbasics/accelerators/UseCCache.cmake
================================================
# This module activates "ccache" support on Unix
# This module is supposed to be used only from "UseCompilerCacheTool.cmake"
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
find_program(__cxxbasics_ccache_found ccache)
if(__cxxbasics_ccache_found)
if(NOT CMAKE_C_COMPILER_LAUNCHER)
set(CMAKE_C_COMPILER_LAUNCHER ccache)
endif()
if(NOT CMAKE_CXX_COMPILER_LAUNCHER)
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
endif()
endif()
================================================
FILE: cmake/cxxbasics/accelerators/UseCompilerCacheTool.cmake
================================================
# This module activates a compiler cache
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
opt_ifndef("Use a compiler cache tool, if supported" BOOL ON CXXBASICS_ACTIVATE_COMPILER_CACHE)
if(CXXBASICS_ACTIVATE_COMPILER_CACHE)
if(CMAKE_HOST_UNIX)
include(accelerators/UseCCache)
endif()
if(NOT CMAKE_C_COMPILER_LAUNCHER OR NOT CMAKE_CXX_COMPILER_LAUNCHER)
include(accelerators/UseSCCache)
endif()
if(CMAKE_C_COMPILER_LAUNCHER)
cbok("Compiler cache tool \"${CMAKE_C_COMPILER_LAUNCHER}\" set for the C compiler")
else()
cbnok("Could not set a compiler cache tool for the C compiler")
endif()
if(CMAKE_CXX_COMPILER_LAUNCHER)
cbok("Compiler cache tool \"${CMAKE_CXX_COMPILER_LAUNCHER}\" set for the CXX compiler")
else()
cbnok("Could not set a compiler cache tool for the CXX compiler")
endif()
endif()
================================================
FILE: cmake/cxxbasics/accelerators/UseFasterLinkers.cmake
================================================
# This module activates faster linkers, if these are available and supported.
# It prefers the fastest linker available(as of this writing LLD -> GNU gold -> ...)
# The linker is handled separately per compiler, so, you can do something like this:
# -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=clang++
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
cmake_policy(PUSH)
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif(POLICY CMP0054)
opt_ifndef("Use faster linkers(LLD, GNU gold...) if supported" BOOL ON CXXBASICS_USE_FASTER_LINKERS)
if(CXXBASICS_USE_FASTER_LINKERS)
macro(__cxxbasics_set_linker compiler)
# Lets check if the default linker is not actually LLD or GNU gold(ex: a symbolic link)
execute_process(COMMAND ${compiler} -Wl,--version
OUTPUT_VARIABLE __cxxbasics_ld_version
ERROR_QUIET)
if("${__cxxbasics_ld_version}" MATCHES "LLD")
set(__cxxbasics_using_lld_linker ON)
elseif("${__cxxbasics_ld_version}" MATCHES "GNU gold")
set(__cxxbasics_using_gold_linker ON)
else()
set(__cxxbasics_using_default_linker ON)
endif()
# We don't do anything if the system linker already is the LLD linker, or links to it
if(NOT __cxxbasics_using_lld_linker)
# We try to set LLD first because it's the fastest linker currently
if(NOT __cxxbasics_using_lld_linker)
# LLD is currently production quality only on "x86_64"
include(compiler_detection/GetTargetArch)
if("${compiler}" STREQUAL "${CMAKE_C_COMPILER}")
set(__cxxbasics_target_arch "${CXXBASICS_C_COMPILER_TARGET_ARCH}")
set(__cxxbasics_current_compiler "CMAKE_C_COMPILER")
elseif("${compiler}" STREQUAL "${CMAKE_CXX_COMPILER}")
set(__cxxbasics_target_arch "${CXXBASICS_CXX_COMPILER_TARGET_ARCH}")
set(__cxxbasics_current_compiler "CMAKE_CXX_COMPILER")
else()
cberror("Could not obtain CMAKE_C_COMPILER nor CMAKE_CXX_COMPILER")
endif()
if("${__cxxbasics_target_arch}" STREQUAL "x86_64")
# Lets check if the compiler supports the LLD linker
execute_process(COMMAND ${compiler} -fuse-ld=lld -Wl,--version
OUTPUT_VARIABLE __cxxbasics_ld_version
ERROR_QUIET)
if("${__cxxbasics_ld_version}" MATCHES "LLD")
if("${__cxxbasics_current_compiler}" STREQUAL "CMAKE_C_COMPILER")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -fuse-ld=lld")
else()
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -fuse-ld=lld")
endif()
set(__cxxbasics_using_lld_linker ON)
cbok("${__cxxbasics_current_compiler}(${compiler})'s linker set to: LLD linker")
endif()
endif("${__cxxbasics_target_arch}" STREQUAL "x86_64")
endif()
# We set the GNU gold linker if we failed to set LLD
if(NOT __cxxbasics_using_lld_linker AND NOT __cxxbasics_using_gold_linker)
execute_process(COMMAND ${compiler} -fuse-ld=gold -Wl,--version
OUTPUT_VARIABLE __cxxbasics_ld_version
ERROR_QUIET)
if("${__cxxbasics_ld_version}" MATCHES "GNU gold")
if("${__cxxbasics_current_compiler}" STREQUAL "CMAKE_C_COMPILER")
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -fuse-ld=gold")
else()
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -fuse-ld=gold")
endif()
set(__cxxbasics_using_gold_linker ON)
cbok("${__cxxbasics_current_compiler}(${compiler})'s linker is set to: GNU gold linker")
endif()
endif()
# If we failed to set LLD or the GNU gold linker, we fallback to the default linker
if(NOT __cxxbasics_using_lld_linker AND NOT __cxxbasics_using_gold_linker)
set(__cxxbasics_using_default_linker ON)
cbnok("${__cxxbasics_current_compiler}(${compiler})'s linker set to the fallback: default linker")
endif()
endif(NOT __cxxbasics_using_lld_linker)
unset(__cxxbasics_using_lld_linker)
unset(__cxxbasics_using_gold_linker)
unset(__cxxbasics_using_default_linker)
unset(__cxxbasics_ld_version)
unset(__cxxbasics_target_arch)
unset(__cxxbasics_current_compiler)
endmacro()
# Set the linker for the C compiler
__cxxbasics_set_linker("${CMAKE_C_COMPILER}")
# Set the linker for the CXX compiler
__cxxbasics_set_linker("${CMAKE_CXX_COMPILER}")
endif()
cmake_policy(POP)
================================================
FILE: cmake/cxxbasics/accelerators/UseSCCache.cmake
================================================
# This module activates "sccache" support on Unix and Windows if
# another compiler cache tool was not found.
# This module is supposed to be used only from "UseCompilerCacheTool.cmake"
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
find_program(__cxxbasics_sccache_found sccache)
if(__cxxbasics_sccache_found)
if(NOT CMAKE_C_COMPILER_LAUNCHER)
set(CMAKE_C_COMPILER_LAUNCHER sccache)
endif()
if(NOT CMAKE_CXX_COMPILER_LAUNCHER)
set(CMAKE_CXX_COMPILER_LAUNCHER sccache)
endif()
endif()
================================================
FILE: cmake/cxxbasics/compiler_detection/GetTargetArch.cmake
================================================
# This module identifies the target architecture of the C and CXX compilers
# ARM("armv8" includes AArch64, "arm" is all the old ARM processors + Cortex-M): armv8, armv7, armv6, armv5, arm
# Itanium: ia64
# Traditional PC architectures: x86, x86_64
# MIPS(RISC): mipsI, mipsII, mipsIII, mipsIV, mipsV, mips32, mips64, mips
# PowerPC: ppc64, ppc
# IBM System z: s390, s390x
# SPARC: sparcv9, sparc64, sparc
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
cmake_policy(PUSH)
if(POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif(POLICY CMP0054)
opt_ifndef("C compiler target architecture" STRING "" CXXBASICS_C_COMPILER_TARGET_ARCH)
opt_ifndef("CXX compiler target architecture" STRING "" CXXBASICS_CXX_COMPILER_TARGET_ARCH)
if("${CXXBASICS_C_COMPILER_TARGET_ARCH}" STREQUAL ""
OR "${CXXBASICS_CXX_COMPILER_TARGET_ARCH}" STREQUAL "")
include(helpers/FnMktemp)
mktemp()
if("${mktemp_result}" STREQUAL "")
opt_overwrite(CXXBASICS_TMP_FOLDER "${CMAKE_BINARY_DIR}")
mktemp()
endif()
## Based on Qt 5.9 processor detection: https://github.com/qt/qtbase/blob/dev/src/corelib/global/qprocessordetection.h
file(WRITE "${mktemp_result}"
"
// ARM
#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(__aarch64__)
# if defined(__ARM64_ARCH_8__) \\
|| defined(__aarch64__) \\
|| defined(__CORE_CORTEXAV8__) // GHS-specific for INTEGRITY
# define Q_PROCESSOR_ARM 8
# elif defined(__ARM_ARCH_7__) \\
|| defined(__ARM_ARCH_7A__) \\
|| defined(__ARM_ARCH_7R__) \\
|| defined(__ARM_ARCH_7M__) \\
|| defined(__ARM_ARCH_7S__) \\
|| defined(_ARM_ARCH_7) \\
|| defined(__CORE_CORTEXA__) // GHS-specific for INTEGRITY
# define Q_PROCESSOR_ARM 7
# elif defined(__ARM_ARCH_6__) \\
|| defined(__ARM_ARCH_6J__) \\
|| defined(__ARM_ARCH_6T2__) \\
|| defined(__ARM_ARCH_6Z__) \\
|| defined(__ARM_ARCH_6K__) \\
|| defined(__ARM_ARCH_6ZK__) \\
|| defined(__ARM_ARCH_6M__)
# define Q_PROCESSOR_ARM 6
# elif defined(__ARM_ARCH_5TEJ__) \\
|| defined(__ARM_ARCH_5TE__)
# define Q_PROCESSOR_ARM 5
# else
# define Q_PROCESSOR_ARM 0
# endif
# if Q_PROCESSOR_ARM >= 8
# error CMAKE_TARGET_ARCH armv8
# endif
# if Q_PROCESSOR_ARM >= 7
# error CMAKE_TARGET_ARCH armv7
# endif
# if Q_PROCESSOR_ARM >= 6
# error CMAKE_TARGET_ARCH armv6
# endif
# if Q_PROCESSOR_ARM >= 5
# error CMAKE_TARGET_ARCH armv5
# endif
# error CMAKE_TARGET_ARCH arm // old ARM, Cortex-M...
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) // x86
# error CMAKE_TARGET_ARCH x86
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) // x86_64
# error CMAKE_TARGET_ARCH x86_64
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) // Itanium
# error CMAKE_TARGET_ARCH ia64
#elif defined(__mips) || defined(__mips__) || defined(_M_MRX000) // MIPS(RISC)
# if defined(_MIPS_ARCH_MIPS1) || (defined(__mips) && __mips - 0 >= 1)
# error CMAKE_TARGET_ARCH mipsI
# endif
# if defined(_MIPS_ARCH_MIPS2) || (defined(__mips) && __mips - 0 >= 2)
# error CMAKE_TARGET_ARCH mipsII
# endif
# if defined(_MIPS_ARCH_MIPS3) || (defined(__mips) && __mips - 0 >= 3)
# error CMAKE_TARGET_ARCH mipsIII
# endif
# if defined(_MIPS_ARCH_MIPS4) || (defined(__mips) && __mips - 0 >= 4)
# error CMAKE_TARGET_ARCH mipsIV
# endif
# if defined(_MIPS_ARCH_MIPS5) || (defined(__mips) && __mips - 0 >= 5)
# error CMAKE_TARGET_ARCH mipsV
# endif
# if defined(_MIPS_ARCH_MIPS32) || defined(__mips32) || (defined(__mips) && __mips - 0 >= 32)
# error CMAKE_TARGET_ARCH mips32
# endif
# if defined(_MIPS_ARCH_MIPS64) || defined(__mips64)
# error CMAKE_TARGET_ARCH mips64
# endif
# error CMAKE_TARGET_ARCH mips // Unknown MIPS
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\
|| defined(_M_MPPC) || defined(_M_PPC)
# if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
# error CMAKE_TARGET_ARCH ppc64 // PowerPC 64
# endif
# error CMAKE_TARGET_ARCH ppc // PowerPC
#elif defined(__s390__) // IBM System z(s390/s390x)
# if defined(__s390x__)
# error CMAKE_TARGET_ARCH s390x
# endif
# error CMAKE_TARGET_ARCH s390
#elif defined(__sparc__) // SPARC
# if defined(__sparc_v9__)
# error CMAKE_TARGET_ARCH sparcv9
# endif
# if defined(__sparc64__)
# error CMAKE_TARGET_ARCH sparc64
# endif
# error CMAKE_TARGET_ARCH sparc
#endif
#error CMAKE_TARGET_ARCH unknown
")
macro(__cxxbasics_define_arch suffix variable)
file(RENAME "${mktemp_result}" "${mktemp_result}${suffix}")
set(mktemp_result "${mktemp_result}${suffix}")
try_compile(run_unused_result
"${CMAKE_CURRENT_BINARY_DIR}"
SOURCES "${mktemp_result}"
OUTPUT_VARIABLE TARGET_ARCH
)
if("${TARGET_ARCH}" MATCHES "CMAKE_TARGET_ARCH")
# Extracting the first "CMAKE_TARGET_ARCH [arch]"
string(REGEX MATCH "CMAKE_TARGET_ARCH ([A-Za-z0-9_]+)" TARGET_ARCH "${TARGET_ARCH}")
# Remove "CMAKE_TARGET_ARCH" and leaving only the architecture
string(REPLACE "CMAKE_TARGET_ARCH " "" TARGET_ARCH "${TARGET_ARCH}")
# Lets see if it is not unknown, otherwise we know we have the correct architecture in TARGET_ARCH
if("${TARGET_ARCH}" STREQUAL "unknown")
opt_overwrite(${variable} "unknown")
else()
opt_overwrite(${variable} "${TARGET_ARCH}")
endif()
else()
# If for some reason we didn't get the expected string, set the arch to "unknown"
opt_overwrite(${variable} "unknown")
endif()
# Catching coding errors
if("${variable}" STREQUAL "")
opt_overwrite(${variable} "unknown")
endif()
cbmessage("`${variable}` set to \"${${variable}}\"")
endmacro()
__cxxbasics_define_arch(".c" CXXBASICS_C_COMPILER_TARGET_ARCH)
__cxxbasics_define_arch(".cxx" CXXBASICS_CXX_COMPILER_TARGET_ARCH)
endif()
cmake_policy(POP)
================================================
FILE: cmake/cxxbasics/helpers/FnMktemp.cmake
================================================
## This module defines helper functions to create temporary files and folders in a system-agnostic way
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
opt_ifndef("CXXBasics temporary folder(uses system folder by default)" PATH "" CXXBASICS_TMP_FOLDER)
macro(__cxxbasics_mktemp_helper)
# Try to catch wrong usage
if(NOT "${ARGV0}" STREQUAL "file" AND NOT "${ARGV0}" STREQUAL "directory")
cberror("Wrong use of the macro")
endif()
# If `CXXBASICS_TMP_FOLDER` is not defined or set to an empty string, than we will try to set it to the system TMP
if(NOT DEFINED CXXBASICS_TMP_FOLDER OR NOT IS_DIRECTORY "${CXXBASICS_TMP_FOLDER}")
if(CMAKE_HOST_WIN32)
opt_overwrite(CXXBASICS_TMP_FOLDER "$ENV{TMP}")
elseif(CMAKE_HOST_UNIX)
opt_overwrite(CXXBASICS_TMP_FOLDER "/tmp")
else()
cberror("Unsupported OS. Cannot set the temporary folder, please manually modify CXXBASICS_TMP_FOLDER in the cache")
endif()
endif(NOT DEFINED CXXBASICS_TMP_FOLDER OR NOT IS_DIRECTORY "${CXXBASICS_TMP_FOLDER}")
# Lets make sure it's actually a directory
if(NOT IS_DIRECTORY "${CXXBASICS_TMP_FOLDER}")
cberror("`${CXXBASICS_TMP_FOLDER}` is not a folder. Please manually modify CXXBASICS_TMP_FOLDER in the cache")
endif()
# We will try to generate different random names until we are sure that it is unique for the path we try to use
opt_ifndef("Project prefix to be used when creating files and folders" STRING "cxxbasics" CXXBASICS_PROJECT_PREFIX)
string(RANDOM LENGTH 16 random_generated_string)
file(TO_NATIVE_PATH "${CXXBASICS_TMP_FOLDER}/${CXXBASICS_PROJECT_PREFIX}_${random_generated_string}" mktemp_result)
while(EXISTS "${mktemp_result}")
string(RANDOM LENGTH 16 random_generated_string)
file(TO_NATIVE_PATH "${CXXBASICS_TMP_FOLDER}/${CXXBASICS_PROJECT_PREFIX}_${random_generated_string}" mktemp_result)
endwhile(EXISTS "${mktemp_result}")
# Here the behavior between `file` and `directory` splits, so we handle them separately
if("${ARGV0}" STREQUAL "file")
set(mktemp_result "${mktemp_result}" PARENT_SCOPE)
file(WRITE "${mktemp_result}" "")
# file(WRITE) should throw an error but we'll check anyway
if(NOT EXISTS "${mktemp_result}" OR IS_DIRECTORY "${mktemp_result}")
cbnok("Failed to create the temporary file")
unset(mktemp_result PARENT_SCOPE)
endif()
else()
set(mktemp_directory_result "${mktemp_result}")
set(mktemp_directory_result "${mktemp_directory_result}" PARENT_SCOPE)
file(MAKE_DIRECTORY "${mktemp_directory_result}")
# file(MAKE_DIRECTORY) should throw an error but we'll check anyway
if(NOT IS_DIRECTORY "${mktemp_directory_result}")
cbnok("Failed to create the temporary folder")
unset(mktemp_directory_result PARENT_SCOPE)
endif()
endif()
endmacro()
# @function mktemp
# @return mktemp_result - stores the path to the temporary file
function(mktemp)
__cxxbasics_mktemp_helper("file")
endfunction()
# @function mktemp_directory
# @return mktemp_directory_result - stores the path to the temporary folder
function(mktemp_directory)
__cxxbasics_mktemp_helper("directory")
endfunction()
================================================
FILE: cmake/cxxbasics/helpers/MacroCustomMessages.cmake
================================================
## This module contains project-wide custom CMake messagging macros.
## Does not adhere to the overall style because MacroCbmessage does not sound very well nor represent all macros...
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
# This does not work in Windows CMD(usually also CI)
if(CYGWIN OR NOT CMAKE_HOST_WIN32)
string(ASCII 27 __cxxbasics_escape)
set(__cxxbasics_prefix_color "${__cxxbasics_escape}[36m") # Cyan
set(__cxxbasics_success_color "${__cxxbasics_escape}[32m") # Green
set(__cxxbasics_failure_color "${__cxxbasics_escape}[31m") # Red
set(__cxxbasics_no_color "${__cxxbasics_escape}[m") # Reset color
unset(__cxxbasics_escape)
endif()
set(__cxxbasics_prefix "[${__cxxbasics_prefix_color}cxxbasics${__cxxbasics_no_color}]")
set(__cxxbasics_success "[${__cxxbasics_success_color}✓${__cxxbasics_no_color}]")
set(__cxxbasics_failure "[${__cxxbasics_failure_color}✗${__cxxbasics_no_color}]")
unset(__cxxbasics_prefix_color)
unset(__cxxbasics_success_color)
unset(__cxxbasics_failure_color)
unset(__cxxbasics_no_color)
#========================================================
# Use `_cbp` when displaying a simple message.
# `cbp` stands for [C]XX[B]asics [P]refix
set(_cbp "${__cxxbasics_prefix}")
# Use `_cbok` when displaying a notification of success(ex: `cxxbasics` succeded to set up ccache)
# `cbok` stands for [C]XX[B]asics [OK]
set(_cbok "${_cbp}${__cxxbasics_success}")
# Use `_cbnok` when displaying a notification of failure(ex: the user activated `ccache` but it was not found in the system)
# `cbnok` stands for [C]XX[B]asics [N]ot [OK]
set(_cbnok "${_cbp}${__cxxbasics_failure}")
macro(cbmessage)
message(STATUS "${_cbp} " ${ARGV})
endmacro(cbmessage)
macro(cbok)
message(STATUS "${_cbok} " ${ARGV})
endmacro(cbok)
macro(cbnok)
message(STATUS "${_cbnok} " ${ARGV})
endmacro(cbnok)
macro(cberror)
message(FATAL_ERROR "${_cbnok} " ${ARGV})
endmacro(cberror)
#========================================================
unset(__cxxbasics_prefix)
unset(__cxxbasics_success)
unset(__cxxbasics_failure)
================================================
FILE: cmake/cxxbasics/helpers/MacroOpt.cmake
================================================
## This module defines helper macros to set options(cached variables)
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
# @macro opt
# Macro helper to set a cache value.
# Does not overwrite the value if it was already cached.
#
# `description` - the description that will be displayed in CMake cache editor
# `var_type` - the type of the variable(BOOL, FILEPATH, PATH, STRING, INTERNAL)
# `var_value` - the value `var_name` will be set to
# `var_name` - variable name
macro(opt description var_type var_value var_name)
set(${var_name} ${var_value} CACHE ${var_type} "${description}")
# Stores internally information about this variable's description and type
# Will be reused in `opt_overwrite` to make the macro easy to use
set(${var_name}_DESCRIPTION "${description}" CACHE INTERNAL "")
set(${var_name}_TYPE "${var_type}" CACHE INTERNAL "")
endmacro()
# @macro opt_ifndef
# Macro helper to set a cache value.
# Sets the cache value only if the variable(including local variables) was not defined or it is set to an empty string.
macro(opt_ifndef description var_type var_value var_name)
if(NOT DEFINED ${var_name} OR "${${var_name}}" STREQUAL "")
set(${var_name} ${var_value} CACHE ${var_type} "${description}" FORCE)
set(${var_name}_DESCRIPTION "${description}" CACHE INTERNAL "")
set(${var_name}_TYPE "${var_type}" CACHE INTERNAL "")
endif()
endmacro()
# @macro opt_force
# Macro helper to set a cache value.
# Sets the cache value or overwrites the value if the variable already exists.
macro(opt_force description var_type var_value var_name)
set(${var_name} ${var_value} CACHE ${var_type} "${description}" FORCE)
set(${var_name}_DESCRIPTION "${description}" CACHE INTERNAL "")
set(${var_name}_TYPE "${var_type}" CACHE INTERNAL "")
endmacro()
# @macro opt_overwrite
# Macro helper to set a cache value.
# Overwrites the cache value only if the variable already exists in the cache(not local variables).
# The variable in the cache has to be registered with one of the `opt` macros
macro(opt_overwrite var_name var_value)
# we do not check `if(NOT DEFINED ${var_name})` because local variables don't limit us from updating the
# correct variable in the cache. We rely on _DESCRIPTION and _TYPE to find if the variable was
# previously registered with `opt`
if(NOT DEFINED ${var_name}_DESCRIPTION OR NOT DEFINED ${var_name}_TYPE)
cberror("user-code logic error: `${var_name}` was not registered with an `opt` macro beforehand")
endif()
set(${var_name} ${var_value} CACHE ${${var_name}_TYPE} "${${var_name}_DESCRIPTION}" FORCE)
endmacro()
================================================
FILE: debian/changelog
================================================
stacer (1.1.0-1) stable; urgency=medium
* Snap package uninstaller.
* Advanced file search.
* Disk chart.
* Host manager.
-- Oguzhan Inan Sun, 13 May 2018 00:50:10 +0300
================================================
FILE: debian/compat
================================================
9
================================================
FILE: debian/control
================================================
Source: stacer
Section: utils
Priority: optional
Maintainer: Oguzhan INAN
Build-Depends: debhelper (>=9)
Standards-Version: 3.9.6
Homepage: https://github.com/oguzhaninan/Stacer
Vcs-Browser: https://github.com/oguzhaninan/Stacer.git
Package: stacer
Architecture: all
Depends: ${misc:Depends}
Recommends: systemd, curl
Description: Linux System Optimizer and Monitoring
================================================
FILE: debian/copyright
================================================
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: stacer
Source: https://github.com/oguzhaninan/Stacer/
Files: *
Copyright: 2017-2019 Oguzhan INAN
License: GPL-3.0
Files: debian/*
Copyright: 2017-2019 Oguzhan INAN
License: GPL-3.0
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
================================================
FILE: debian/install
================================================
stacer/* usr/share/stacer/
applications/* usr/share/applications/
icons/* usr/share/icons/
================================================
FILE: debian/postinst
================================================
#!/bin/sh
ln -sf "/usr/share/stacer/stacer" "/usr/bin/stacer"
exit 0
================================================
FILE: debian/postrm
================================================
#!/bin/sh
unlink /usr/bin/stacer
rm -rf /usr/share/stacer
exit 0
================================================
FILE: debian/rules
================================================
#!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
%:
dh $@ --parallel
================================================
FILE: debian/source/format
================================================
3.0 (quilt)
================================================
FILE: release.sh
================================================
#!/bin/bash
VERSION=1.1.0
RELEASE=Release
DIR=stacer-$VERSION
mkdir $RELEASE
mkdir build ; cd build
cmake -DCMAKE_BUILD_TYPE=debug -DCMAKE_CXX_COMPILER=g++ -DCMAKE_PREFIX_PATH=$QTDIR/bin ..
make -j `nproc`
cd ..
mkdir $RELEASE/$DIR/stacer -p
cp -r icons applications debian $RELEASE/$DIR
cp -r build/output/* $RELEASE/$DIR/stacer
# translations
lupdate stacer/stacer.pro -no-obsolete
lrelease stacer/stacer.pro
mkdir $RELEASE/$DIR/stacer/translations
mv translations/*.qm $RELEASE/$DIR/stacer/translations
# linuxdeployqt
wget -cO lqt "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
chmod +x lqt
unset QTDIR; unset QT_PLUGIN_PATH; unset LD_LIBRARY_PATH
./lqt $RELEASE/$DIR/stacer/stacer -bundle-non-qt-libs -no-translations -unsupported-allow-new-glibc
rm lqt
if [ $1 = "deb" ]; then
cd $RELEASE/$DIR
dh_make --createorig -i -c mit
debuild --no-lintian -us -uc
fi
================================================
FILE: stacer/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(stacer)
set(MANAGERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Managers")
set(PAGES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Pages")
include_directories(
"${PROJECT_ROOT}/stacer-core"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${MANAGERS_DIR}"
"${PAGES_DIR}/Dashboard"
"${PAGES_DIR}/Processes"
"${PAGES_DIR}/Resources"
"${PAGES_DIR}/Services"
"${PAGES_DIR}/Settings"
"${PAGES_DIR}/StartupApps"
"${PAGES_DIR}/SystemCleaner"
"${PAGES_DIR}/Uninstaller"
"${CMAKE_CURRENT_BINARY_DIR}" # Necessary for CMake 3.7 and older
)
# Sources
file(GLOB_RECURSE ${PROJECT_NAME}_srcs "${CMAKE_CURRENT_SOURCE_DIR}/**.cpp")
file(GLOB_RECURSE ${PROJECT_NAME}_translations "${PROJECT_ROOT}/translations/**.ts")
# Translations
find_package(Qt5LinguistTools)
qt5_create_translation(QM_FILES ${PROJECT_NAME}_translations ${${PROJECT_NAME}_srcs})
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${QM_FILES}")
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
add_executable(${PROJECT_NAME}
${${PROJECT_NAME}_srcs}
"${CMAKE_CURRENT_SOURCE_DIR}/static.qrc"
${QM_FILES}
)
target_link_libraries(${PROJECT_NAME}
stacer-core Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Charts Qt5::Svg Qt5::Concurrent
)
# Running LTO in Release builds, if the C++ compiler is GNU GCC
if("${CMAKE_BUILD_TYPE}" STREQUAL "Release" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(${PROJECT_NAME} PRIVATE "-flto")
list(APPEND CMAKE_EXE_LINKER_FLAGS "-flto")
endif()
install(
TARGETS ${PROJECT_NAME}
CONFIGURATIONS Release RelWithDebInfo MinSizeRel # Not allowing to install an unoptimized build
RUNTIME DESTINATION bin
)
install(
FILES "${PROJECT_ROOT}/applications/stacer.desktop"
DESTINATION share/applications
CONFIGURATIONS Release RelWithDebInfo MinSizeRel
)
install(
FILES "${PROJECT_ROOT}/stacer/static/logo.png"
DESTINATION share/icons
CONFIGURATIONS Release RelWithDebInfo MinSizeRel
RENAME stacer.png
)
================================================
FILE: stacer/Managers/app_manager.cpp
================================================
#include "app_manager.h"
#include
AppManager *AppManager::instance = nullptr;
AppManager *AppManager::ins()
{
if (! instance) {
instance = new AppManager;
}
return instance;
}
AppManager::AppManager()
{
mSettingManager = SettingManager::ins();
mTrayIcon = new QSystemTrayIcon(QIcon(":/static/themes/default/img/sidebar-icons/dash.png"));
loadLanguageList();
// loadThemeList();
if (mTranslator.load(QString("stacer_%1").arg(mSettingManager->getLanguage()), qApp->applicationDirPath() + "/translations")) {
qApp->installTranslator(&mTranslator);
(mSettingManager->getLanguage() == "ar") ? qApp->setLayoutDirection(Qt::RightToLeft) : qApp->setLayoutDirection(Qt::LeftToRight);
}
}
QSystemTrayIcon *AppManager::getTrayIcon()
{
return mTrayIcon;
}
QSettings *AppManager::getStyleValues() const
{
return mStyleValues;
}
void AppManager::loadLanguageList()
{
QByteArray lanuagesJson = FileUtil::readStringFromFile(":/static/languages.json").toUtf8();
QJsonArray lanuages = QJsonDocument::fromJson(lanuagesJson).array();
for (int i = 0; i < lanuages.count(); ++i) {
QJsonObject ob = lanuages.at(i).toObject();
mLanguageList.insert(ob["value"].toString(), ob["text"].toString());
}
}
QMap AppManager::getLanguageList() const
{
return mLanguageList;
}
//void AppManager::loadThemeList()
//{
// QByteArray themesJson = FileUtil::readStringFromFile(":/static/themes.json").toUtf8();
// QJsonArray themes = QJsonDocument::fromJson(themesJson).array();
// for (int i = 0; i < themes.count(); ++i) {
// QJsonObject ob = themes.at(i).toObject();
// mThemeList.insert(ob["value"].toString(), ob["text"].toString());
// }
//}
//QMap AppManager::getThemeList() const
//{
// return mThemeList;
//}
void AppManager::updateStylesheet()
{
QString appThemePath = QString(":/static/themes/%1/style").arg(mSettingManager->getThemeName());
mStyleValues = new QSettings(QString("%1/values.ini").arg(appThemePath), QSettings::IniFormat);
mStylesheetFileContent = FileUtil::readStringFromFile(QString("%1/style.qss").arg(appThemePath));
// set values example: @color01 => #fff
for (const QString &key : mStyleValues->allKeys()) {
mStylesheetFileContent.replace(key, mStyleValues->value(key).toString());
}
qApp->setStyleSheet(mStylesheetFileContent);
emit SignalMapper::ins()->sigChangedAppTheme();
}
QString AppManager::getStylesheetFileContent() const
{
return mStylesheetFileContent;
}
================================================
FILE: stacer/Managers/app_manager.h
================================================
#ifndef APP_MANAGER_H
#define APP_MANAGER_H
#include
#include
#include
#include
#include
#include
#include
#include
#include "Utils/file_util.h"
#include "Managers/setting_manager.h"
#include "signal_mapper.h"
class AppManager
{
public:
static AppManager *ins();
QMap getLanguageList() const;
void loadLanguageList();
// QMap getThemeList() const;
// void loadThemeList();
void updateStylesheet();
QString getStylesheetFileContent() const;
QSettings *getStyleValues() const;
QSystemTrayIcon *getTrayIcon();
private:
static AppManager *instance;
AppManager();
private:
QTranslator mTranslator;
QSystemTrayIcon *mTrayIcon;
QSettings *mStyleValues;
QMap mLanguageList;
// QMap mThemeList;
QString mStylesheetFileContent;
SettingManager *mSettingManager;
};
#endif // APP_MANAGER_H
================================================
FILE: stacer/Managers/info_manager.cpp
================================================
#include "info_manager.h"
InfoManager *InfoManager::instance = nullptr;
InfoManager *InfoManager::ins()
{
if(! instance){
instance = new InfoManager;
}
return instance;
}
QString InfoManager::getUserName() const
{
return si.getUsername();
}
QStringList InfoManager::getUserList() const
{
return si.getUserList();
}
QStringList InfoManager::getGroupList() const
{
return si.getGroupList();
}
/*
* CPU Provider
*/
int InfoManager::getCpuCoreCount() const
{
return ci.getCpuCoreCount();
}
QList InfoManager::getCpuPercents() const
{
return ci.getCpuPercents();
}
QList InfoManager::getCpuLoadAvgs() const
{
return ci.getLoadAvgs();
}
double InfoManager::getCpuClock() const
{
return ci.getAvgClock();
}
/*
* Memory Provider
*/
void InfoManager::updateMemoryInfo()
{
mi.updateMemoryInfo();
}
quint64 InfoManager::getSwapUsed() const
{
return mi.getSwapUsed();
}
quint64 InfoManager::getSwapTotal() const
{
return mi.getSwapTotal();
}
quint64 InfoManager::getMemUsed() const
{
return mi.getMemUsed();
}
quint64 InfoManager::getMemTotal() const
{
return mi.getMemTotal();
}
/*
* Disk Provider
*/
QList InfoManager::getDisks() const
{
return di.getDisks();
}
void InfoManager::updateDiskInfo()
{
di.updateDiskInfo();
}
QList InfoManager::getDiskIO()
{
return di.getDiskIO();
}
QList InfoManager::getFileSystemTypes()
{
return di.fileSystemTypes();
}
QList InfoManager::getDevices()
{
return di.devices();
}
/********************
* Network Provider
*******************/
quint64 InfoManager::getRXbytes() const
{
return ni.getRXbytes();
}
quint64 InfoManager::getTXbytes() const
{
return ni.getTXbytes();
}
/********************
* System Provider
*******************/
QFileInfoList InfoManager::getCrashReports() const
{
return si.getCrashReports();
}
QFileInfoList InfoManager::getAppLogs() const
{
return si.getAppLogs();
}
QFileInfoList InfoManager::getAppCaches() const
{
return si.getAppCaches();
}
/********************
* Process Provider
*******************/
void InfoManager::updateProcesses()
{
pi.updateProcesses();
}
QList InfoManager::getProcesses() const
{
return pi.getProcessList();
}
================================================
FILE: stacer/Managers/info_manager.h
================================================
#ifndef INFO_MANAGER_H
#define INFO_MANAGER_H
#include
#include
#include
#include
#include
#include
#include
class InfoManager
{
public:
static InfoManager *ins();
int getCpuCoreCount() const;
QList getCpuPercents() const;
QList getCpuLoadAvgs() const;
double getCpuClock() const;
quint64 getSwapUsed() const;
quint64 getSwapTotal() const;
quint64 getMemUsed() const;
quint64 getMemTotal() const;
void updateMemoryInfo();
quint64 getRXbytes() const;
quint64 getTXbytes() const;
QList getDisks() const;
QList getDiskIO();
void updateDiskInfo();
QFileInfoList getCrashReports() const;
QFileInfoList getAppLogs() const;
QFileInfoList getAppCaches() const;
void updateProcesses();
QList getProcesses() const;
QString getUserName() const;
QStringList getUserList() const;
QStringList getGroupList() const;
QList getDevices();
QList getFileSystemTypes();
private:
static InfoManager *instance;
private:
CpuInfo ci;
DiskInfo di;
MemoryInfo mi;
NetworkInfo ni;
SystemInfo si;
ProcessInfo pi;
};
#endif // INFO_MANAGER_H
================================================
FILE: stacer/Managers/setting_manager.cpp
================================================
#include "setting_manager.h"
SettingManager::SettingManager()
{
mConfigPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
mSettings = new QSettings(QString("%1/settings.ini").arg(mConfigPath), QSettings::IniFormat);
}
SettingManager *SettingManager::instance = nullptr;
SettingManager* SettingManager::ins()
{
if (! instance) {
instance = new SettingManager;
}
return instance;
}
QString SettingManager::getConfigPath() const
{
return mConfigPath;
}
void SettingManager::setLanguage(const QString &value)
{
mSettings->setValue(SettingKeys::Language, value);
}
QString SettingManager::getLanguage() const
{
return mSettings->value(SettingKeys::Language, "en").toString();
}
void SettingManager::setThemeName(const QString &value)
{
mSettings->setValue(SettingKeys::ThemeName, value);
}
QString SettingManager::getThemeName() const
{
return "default"; //mSettings->value(SettingKeys::ThemeName, "default").toString();
}
void SettingManager::setDiskName(const QString &value)
{
mSettings->setValue(SettingKeys::DiskName, value);
}
QString SettingManager::getDiskName() const
{
return mSettings->value(SettingKeys::DiskName, "").toString();
}
void SettingManager::setStartPage(const QString &value)
{
mSettings->setValue(SettingKeys::StartPage, value);
}
QString SettingManager::getStartPage() const
{
return mSettings->value(SettingKeys::StartPage, QObject::tr("Dashboard")).toString();
}
void SettingManager::setCpuAlertPercent(const int value)
{
mSettings->setValue(SettingKeys::CPUAlertPercent, value);
}
int SettingManager::getCpuAlertPercent() const
{
return mSettings->value(SettingKeys::CPUAlertPercent, 0).toInt();
}
void SettingManager::setMemoryAlertPercent(const int value)
{
mSettings->setValue(SettingKeys::MemoryAlertPercent, value);
}
int SettingManager::getMemoryAlertPercent() const
{
return mSettings->value(SettingKeys::MemoryAlertPercent, 0).toInt();
}
void SettingManager::setDiskAlertPercent(const int value)
{
mSettings->setValue(SettingKeys::DiskAlertPercent, value);
}
int SettingManager::getDiskAlertPercent() const
{
return mSettings->value(SettingKeys::DiskAlertPercent, 0).toInt();
}
void SettingManager::setAppQuitDialogDontAsk(const bool value)
{
mSettings->setValue(SettingKeys::AppQuitDialogDontAsk, value);
}
bool SettingManager::getAppQuitDialogDontAsk() const
{
return mSettings->value(SettingKeys::AppQuitDialogDontAsk, false).toBool();
}
void SettingManager::setAppQuitDialogChoice(const QString &value)
{
mSettings->setValue(SettingKeys::AppQuitDialogChoice, value);
}
QString SettingManager::getAppQuitDialogChoice() const
{
return mSettings->value(SettingKeys::AppQuitDialogChoice, "close").toString();
}
================================================
FILE: stacer/Managers/setting_manager.h
================================================
#ifndef SETTING_MANAGER_H
#define SETTING_MANAGER_H
#include
#include
namespace SettingKeys {
const QString ThemeName("ThemeName");
const QString Language("Language");
const QString DiskName("DiskName");
const QString StartPage("StartPage");
const QString CPUAlertPercent("CPUAlertPercent");
const QString MemoryAlertPercent("MemoryAlertPercent");
const QString DiskAlertPercent("DiskAlertPercent");
const QString AppQuitDialogDontAsk("AppQuitDialogDontAsk");
const QString AppQuitDialogChoice("AppQuitDialogChoice");
}
class SettingManager
{
public:
static SettingManager *ins();
QString getConfigPath() const;
void setLanguage(const QString &value);
QString getLanguage() const;
void setThemeName(const QString &value);
QString getThemeName() const;
void setDiskName(const QString &value);
QString getDiskName() const;
void setStartPage(const QString &value);
QString getStartPage() const;
void setCpuAlertPercent(const int value);
int getCpuAlertPercent() const;
void setMemoryAlertPercent(const int value);
int getMemoryAlertPercent() const;
void setDiskAlertPercent(const int value);
int getDiskAlertPercent() const;
void setAppQuitDialogDontAsk(const bool value);
bool getAppQuitDialogDontAsk() const;
void setAppQuitDialogChoice(const QString &value);
QString getAppQuitDialogChoice() const;
private:
static SettingManager *instance;
SettingManager();
QSettings *mSettings;
QString mConfigPath;
};
#endif // SETTING_MANAGER_H
================================================
FILE: stacer/Managers/tool_manager.cpp
================================================
#include "tool_manager.h"
ToolManager *ToolManager::instance = NULL;
ToolManager *ToolManager::ins()
{
if(! instance) {
instance = new ToolManager;
}
return instance;
}
/*
* Services
*/
QList ToolManager::getServices() const
{
return ServiceTool::getServicesWithSystemctl();
}
bool ToolManager::changeServiceStatus(const QString &sname, bool status) const
{
return ServiceTool::changeServiceStatus(sname, status);
}
bool ToolManager::changeServiceActive(const QString &sname, bool status) const
{
return ServiceTool::changeServiceActive(sname, status);
}
bool ToolManager::serviceIsActive(const QString &sname) const
{
return ServiceTool::serviceIsActive(sname);
}
bool ToolManager::serviceIsEnabled(const QString &sname) const
{
return ServiceTool::serviceIsEnabled(sname);
}
/*
* Packages
*/
QStringList ToolManager::getPackages() const
{
switch (PackageTool::currentPackageTool) {
case PackageTool::PackageTools::APT:
return PackageTool::getDpkgPackages();
break;
case PackageTool::PackageTools::YUM:
case PackageTool::PackageTools::DNF:
return PackageTool::getRpmPackages();
break;
case PackageTool::PackageTools::PACMAN:
return PackageTool::getPacmanPackages();
break;
default:
return QStringList();
break;
}
}
QStringList ToolManager::getSnapPackages() const
{
return PackageTool::getSnapPackages();
}
bool ToolManager::uninstallSnapPackages(const QStringList packages)
{
return PackageTool::snapRemovePackages(packages);
}
QFileInfoList ToolManager::getPackageCaches() const
{
switch (PackageTool::currentPackageTool) {
case PackageTool::PackageTools::APT:
return PackageTool::getDpkgPackageCaches();
break;
case PackageTool::PackageTools::YUM:
case PackageTool::PackageTools::DNF:
return PackageTool::getPacmanPackageCaches();
break;
case PackageTool::PackageTools::PACMAN:
return PackageTool::getPacmanPackageCaches();
break;
default:
return QFileInfoList();
break;
}
}
void ToolManager::uninstallPackages(const QStringList &packages)
{
switch (PackageTool::currentPackageTool) {
case PackageTool::PackageTools::APT:
PackageTool::dpkgRemovePackages(packages);
break;
case PackageTool::PackageTools::YUM:
PackageTool::yumRemovePackages(packages);
break;
case PackageTool::PackageTools::DNF:
PackageTool::dnfRemovePackages(packages);
break;
case PackageTool::PackageTools::PACMAN:
PackageTool::pacmanRemovePackages(packages);
break;
default:
break;
}
}
/*
* APT Source
*/
bool ToolManager::checkSourceRepository() const
{
return AptSourceTool::checkSourceRepository();
}
QList ToolManager::getSourceList() const
{
return AptSourceTool::getSourceList();
}
void ToolManager::removeAPTSource(const APTSourcePtr source)
{
AptSourceTool::removeAPTSource(source);
}
void ToolManager::changeAPTStatus(const APTSourcePtr aptSource, const bool status)
{
AptSourceTool::changeStatus(aptSource, status);
}
void ToolManager::changeAPTSource(const APTSourcePtr aptSource, const QString newSource)
{
AptSourceTool::changeSource(aptSource, newSource);
}
void ToolManager::addAPTRepository(const QString &repository, const bool isSource)
{
AptSourceTool::addRepository(repository, isSource);
}
================================================
FILE: stacer/Managers/tool_manager.h
================================================
#ifndef TOOL_MANAGER_H
#define TOOL_MANAGER_H
#include
#include
#include
class ToolManager
{
public:
static ToolManager *ins();
QList getServices() const;
QStringList getPackages() const;
QStringList getSnapPackages() const;
QFileInfoList getPackageCaches() const;
bool changeServiceStatus(const QString &sname, bool status) const;
bool changeServiceActive(const QString &sname, bool status) const;
bool serviceIsActive(const QString &sname) const;
bool serviceIsEnabled(const QString &sname) const;
void uninstallPackages(const QStringList &packages);
bool uninstallSnapPackages(const QStringList packages);
bool checkSourceRepository() const;
QList getSourceList() const;
void removeAPTSource(const APTSourcePtr source);
void changeAPTStatus(const APTSourcePtr aptSource, const bool status);
void changeAPTSource(const APTSourcePtr aptSource, const QString newSource);
void addAPTRepository(const QString &repository, const bool isSource);
private:
static ToolManager *instance;
};
#endif // TOOL_MANAGER_H
================================================
FILE: stacer/Pages/AptSourceManager/apt_source_edit.cpp
================================================
#include "apt_source_edit.h"
#include "ui_apt_source_edit.h"
#include
APTSourceEdit::~APTSourceEdit()
{
delete ui;
}
APTSourcePtr APTSourceEdit::selectedAptSource = nullptr;
APTSourceEdit::APTSourceEdit(QWidget *parent) :
QDialog(parent),
ui(new Ui::APTSourceEdit)
{
ui->setupUi(this);
init();
}
void APTSourceEdit::init()
{
ui->lblErrorMsg->hide();
}
void APTSourceEdit::show()
{
clearElements();
// example 'deb [arch=amd64 lang=en] http://packages.microsoft.com/repos/vscode stable main'
// set values to elements
ui->radioBinary->setChecked(! selectedAptSource->isSource);
ui->radioSource->setChecked(selectedAptSource->isSource);
ui->txtOptions->setText(selectedAptSource->options);
ui->txtUri->setText(selectedAptSource->uri);
ui->txtDistribution->setText(selectedAptSource->distribution);
ui->txtComponents->setText(selectedAptSource->components);
QDialog::show();
}
void APTSourceEdit::clearElements()
{
ui->lblErrorMsg->hide();
ui->txtOptions->clear();
ui->txtUri->clear();
ui->txtDistribution->clear();
ui->txtComponents->clear();
}
void APTSourceEdit::on_btnSave_clicked()
{
if (! ui->txtUri->text().isEmpty() &&
! ui->txtDistribution->text().isEmpty())
{
QString sourceType = ui->radioBinary->isChecked() ? "deb" : "deb-src";
QString updatedAptSource = QString("%1 %2 %3 %4 %5")
.arg(sourceType)
.arg(ui->txtOptions->text())
.arg(ui->txtUri->text())
.arg(ui->txtDistribution->text())
.arg(ui->txtComponents->text());
ToolManager::ins()->changeAPTSource(selectedAptSource, updatedAptSource);
emit saved();
close();
} else {
ui->lblErrorMsg->show();
}
}
void APTSourceEdit::on_btnCancel_clicked()
{
close();
}
================================================
FILE: stacer/Pages/AptSourceManager/apt_source_edit.h
================================================
#ifndef APT_SOURCE_EDIT_H
#define APT_SOURCE_EDIT_H
#include
#include "Managers/tool_manager.h"
namespace Ui {
class APTSourceEdit;
}
class APTSourceEdit : public QDialog
{
Q_OBJECT
public:
explicit APTSourceEdit(QWidget *parent = 0);
~APTSourceEdit();
public:
static APTSourcePtr selectedAptSource;
void show();
signals:
void saved();
private slots:
void clearElements();
void on_btnSave_clicked();
void on_btnCancel_clicked();
private:
void init();
private:
Ui::APTSourceEdit *ui;
};
#endif // APT_SOURCE_EDIT_H
================================================
FILE: stacer/Pages/AptSourceManager/apt_source_edit.ui
================================================
APTSourceEdit
0
0
452
295
APT Repository Edit
30
10
30
15
15
-
dialog-title
APT Repository
Qt::AlignCenter
-
Components
-
Options
-
PointingHandCursor
Qt::NoFocus
danger
Cancel
false
-
0
0
Fields cannot be left blank.
-
URI
-
PointingHandCursor
Qt::NoFocus
primary
Save
false
-
Qt::Vertical
347
4
-
Distribution
-
0
0
PointingHandCursor
Qt::NoFocus
Source
true
debTypeGroup
-
0
0
PointingHandCursor
Qt::NoFocus
Binary
debTypeGroup
-
Qt::Horizontal
40
20
txtOptions
txtUri
txtDistribution
txtComponents
================================================
FILE: stacer/Pages/AptSourceManager/apt_source_manager_page.cpp
================================================
#include "apt_source_manager_page.h"
#include "ui_apt_source_manager_page.h"
#include
#include "utilities.h"
#include "Managers/tool_manager.h"
APTSourceManagerPage::~APTSourceManagerPage()
{
delete ui;
}
APTSourcePtr APTSourceManagerPage::selectedAptSource = nullptr;
APTSourceManagerPage::APTSourceManagerPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::APTSourceManagerPage)
{
ui->setupUi(this);
init();
}
void APTSourceManagerPage::init()
{
ui->txtAptSource->setPlaceholderText(tr("example %1")
.arg("'deb http://archive.ubuntu.com/ubuntu xenial main'"));
loadAptSources();
on_btnCancel_clicked();
QList widgets = {
ui->btnAddAPTSourceRepository, ui->btnCancel, ui->btnDeleteAptSource, ui->btnEditAptSource,
ui->txtSearchAptSource, ui->txtSearchAptSource
};
Utilities::addDropShadow(widgets, 40);
}
void APTSourceManagerPage::loadAptSources()
{
ui->listWidgetAptSources->clear();
QList aptSourceList = ToolManager::ins()->getSourceList();
for (APTSourcePtr &aptSource: aptSourceList) {
QListWidgetItem *listItem = new QListWidgetItem(ui->listWidgetAptSources);
listItem->setData(5, aptSource->source); // for search
APTSourceRepositoryItem *aptSourceItem = new APTSourceRepositoryItem(aptSource, ui->listWidgetAptSources);
listItem->setSizeHint(aptSourceItem->sizeHint() + QSize(0, 1));
ui->listWidgetAptSources->setItemWidget(listItem, aptSourceItem);
}
ui->notFoundWidget->setVisible(aptSourceList.isEmpty());
ui->lblAptSourceTitle->setText(tr("APT Repositories (%1)")
.arg(aptSourceList.count()));
}
void APTSourceManagerPage::on_btnAddAPTSourceRepository_clicked(bool checked)
{
if (checked) {
ui->btnAddAPTSourceRepository->setText(tr("Save"));
changeElementsVisible(checked);
} else {
QString aptSourceRepository = ui->txtAptSource->text().trimmed();
if (! aptSourceRepository.isEmpty()) {
ToolManager::ins()->addAPTRepository(aptSourceRepository, ui->checkEnableSource->isChecked());
ui->txtAptSource->clear();
ui->checkEnableSource->setChecked(false);
on_btnCancel_clicked();
loadAptSources();
}
}
}
void APTSourceManagerPage::on_btnCancel_clicked()
{
ui->btnAddAPTSourceRepository->setChecked(false);
changeElementsVisible(false);
ui->btnAddAPTSourceRepository->setText(tr("Add Repository"));
}
void APTSourceManagerPage::changeElementsVisible(const bool checked)
{
ui->txtAptSource->setVisible(checked);
ui->checkEnableSource->setVisible(checked);
ui->btnCancel->setVisible(checked);
ui->btnEditAptSource->setVisible(!checked);
ui->btnDeleteAptSource->setVisible(!checked);
ui->bottomSectionHorizontalSpacer->changeSize(0, 0, checked ? QSizePolicy::Minimum : QSizePolicy::Expanding);
}
void APTSourceManagerPage::on_listWidgetAptSources_itemClicked(QListWidgetItem *item)
{
QWidget *widget = ui->listWidgetAptSources->itemWidget(item);
if (widget) {
APTSourceRepositoryItem *aptSourceItem = dynamic_cast(widget);
if (aptSourceItem) {
selectedAptSource = aptSourceItem->aptSource();
}
} else {
selectedAptSource.clear();
}
}
void APTSourceManagerPage::on_listWidgetAptSources_itemDoubleClicked(QListWidgetItem *item)
{
on_listWidgetAptSources_itemClicked(item);
on_btnEditAptSource_clicked();
}
void APTSourceManagerPage::on_btnDeleteAptSource_clicked()
{
if (! selectedAptSource.isNull()) {
ToolManager::ins()->removeAPTSource(selectedAptSource);
loadAptSources();
}
}
void APTSourceManagerPage::on_txtSearchAptSource_textChanged(const QString &val)
{
for (int i = 0; i < ui->listWidgetAptSources->count(); ++i) {
QListWidgetItem *item = ui->listWidgetAptSources->item(i);
if (item) {
bool isContain = item->data(5).toString().contains(val, Qt::CaseInsensitive);
ui->listWidgetAptSources->setItemHidden(item, ! isContain);
}
}
}
void APTSourceManagerPage::on_btnEditAptSource_clicked()
{
if (! selectedAptSource.isNull()) {
if (mAptSourceEditDialog.isNull()) {
mAptSourceEditDialog = QSharedPointer(new APTSourceEdit(this));
connect(mAptSourceEditDialog.data(), &APTSourceEdit::saved, this, &APTSourceManagerPage::loadAptSources);
}
APTSourceEdit::selectedAptSource = selectedAptSource;
mAptSourceEditDialog->show();
}
}
================================================
FILE: stacer/Pages/AptSourceManager/apt_source_manager_page.h
================================================
#ifndef APTSourceManagerPage_PAGE_H
#define APTSourceManagerPage_PAGE_H
#include
#include
#include "apt_source_repository_item.h"
#include "apt_source_edit.h"
#include "Managers/info_manager.h"
namespace Ui {
class APTSourceManagerPage;
}
class APTSourceManagerPage : public QWidget
{
Q_OBJECT
public:
explicit APTSourceManagerPage(QWidget *parent = 0);
~APTSourceManagerPage();
public:
static APTSourcePtr selectedAptSource;
private slots:
void loadAptSources();
void changeElementsVisible(const bool checked);
void on_btnAddAPTSourceRepository_clicked(bool checked);
void on_listWidgetAptSources_itemClicked(QListWidgetItem *item);
void on_listWidgetAptSources_itemDoubleClicked(QListWidgetItem *item);
void on_txtSearchAptSource_textChanged(const QString &val);
void on_btnDeleteAptSource_clicked();
void on_btnEditAptSource_clicked();
void on_btnCancel_clicked();
private:
void init();
private:
Ui::APTSourceManagerPage *ui;
QSharedPointer mAptSourceEditDialog;
};
#endif
================================================
FILE: stacer/Pages/AptSourceManager/apt_source_manager_page.ui
================================================
APTSourceManagerPage
0
0
836
582
APT Repository Manager
0
0
0
0
0
-
0
0
ArrowCursor
30
5
30
20
10
5
-
0
0
0
0
0
-
0
0
0
200
16777215
200
0
0
0
0
0
-
Not Found APT Repositories
-
Qt::NoFocus
QFrame::NoFrame
Qt::ScrollBarAlwaysOff
QAbstractItemView::NoEditTriggers
QAbstractItemView::SingleSelection
QAbstractItemView::SelectRows
QListView::Adjust
QListView::Batched
4
true
-
Qt::Vertical
QSizePolicy::Fixed
20
15
-
Search...
-
10
0
-
0
0
Ubuntu
PointingHandCursor
Qt::NoFocus
primary
Edit
:/static/themes/default/img/edit.png:/static/themes/default/img/edit.png
16
16
false
-
0
0
Ubuntu
PointingHandCursor
Qt::NoFocus
danger
Delete
:/static/themes/default/img/trash.png:/static/themes/default/img/trash.png
16
16
false
-
Qt::Horizontal
0
20
-
-
circle
Enable Source
-
0
0
Ubuntu
PointingHandCursor
Qt::NoFocus
primary
Add Repository
true
-
0
0
Ubuntu
PointingHandCursor
Qt::NoFocus
danger
Cancel
16
16
false
-
Qt::Horizontal
40
20
-
Ubuntu
11
false
-
Select to delete or edit.
================================================
FILE: stacer/Pages/AptSourceManager/apt_source_repository_item.cpp
================================================
#include "apt_source_repository_item.h"
#include "ui_apt_source_repository_item.h"
#include "utilities.h"
#include "Utils/command_util.h"
#include
APTSourceRepositoryItem::~APTSourceRepositoryItem()
{
delete ui;
}
APTSourceRepositoryItem::APTSourceRepositoryItem(APTSourcePtr aptSource, QWidget *parent) :
QWidget(parent),
ui(new Ui::APTSourceRepositoryItem),
mAptSource(aptSource)
{
init();
}
void APTSourceRepositoryItem::init()
{
ui->setupUi(this);
Utilities::addDropShadow(this, 30, 10);
ui->checkAptSource->setChecked(mAptSource->isActive);
// example "deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main"
QString source = mAptSource->source;
source.remove(QRegExp("\\s[\\[]+.*[\\]]+"));
if (mAptSource->isSource) {
ui->lblAptSourceName->setText(tr("%1 (Source Code)").arg(source));
} else {
ui->lblAptSourceName->setText(source);
}
ui->lblAptSourceName->setToolTip(ui->lblAptSourceName->text());
}
APTSourcePtr APTSourceRepositoryItem::aptSource() const
{
return mAptSource;
}
void APTSourceRepositoryItem::on_checkAptSource_clicked(bool checked)
{
ToolManager::ins()->changeAPTStatus(mAptSource, checked);
}
================================================
FILE: stacer/Pages/AptSourceManager/apt_source_repository_item.h
================================================
#ifndef APTSourceRepositoryItem_H
#define APTSourceRepositoryItem_H
#include
#include "Managers/tool_manager.h"
namespace Ui {
class APTSourceRepositoryItem;
}
class APTSourceRepositoryItem : public QWidget
{
Q_OBJECT
public:
explicit APTSourceRepositoryItem(APTSourcePtr aptSource, QWidget *parent = 0);
~APTSourceRepositoryItem();
public:
APTSourcePtr aptSource() const;
private slots:
void on_checkAptSource_clicked(bool checked);
private:
void init();
private:
Ui::APTSourceRepositoryItem *ui;
APTSourcePtr mAptSource;
};
#endif
================================================
FILE: stacer/Pages/AptSourceManager/apt_source_repository_item.ui
================================================
APTSourceRepositoryItem
0
0
727
45
0
0
0
45
16777215
45
0
0
0
0
0
-
0
0
PointingHandCursor
15
15
10
10
10
-
26
26
26
26
true
-
APT Source Repository
-
Qt::Horizontal
0
20
-
PointingHandCursor
Qt::NoFocus
45
23
================================================
FILE: stacer/Pages/Dashboard/circlebar.cpp
================================================
#include "circlebar.h"
#include "ui_circlebar.h"
CircleBar::~CircleBar()
{
delete ui;
delete mChart;
}
CircleBar::CircleBar(const QString &title, const QStringList &colors, QWidget *parent) :
QWidget(parent),
ui(new Ui::CircleBar),
mColors(colors),
mChart(new QChart),
mChartView(new QChartView(mChart)),
mSeries(new QPieSeries(this))
{
ui->setupUi(this);
ui->lblCircleChartTitle->setText(title);
init();
}
void CircleBar::init()
{
QColor transparent("transparent");
// series settings
mSeries->setHoleSize(0.67);
mSeries->setPieSize(165);
mSeries->setPieStartAngle(-115);
mSeries->setPieEndAngle(115);
mSeries->setLabelsVisible(false);
mSeries->append("Used", 0);
mSeries->append("Free", 0);
mSeries->slices().first()->setBorderColor(transparent);
mSeries->slices().last()->setBorderColor(transparent);
QConicalGradient gradient;
gradient.setAngle(115);
for (int i = 0; i < mColors.count(); ++i) {
gradient.setColorAt(i, QColor(mColors.at(i)));
}
mSeries->slices().first()->setBrush(gradient);
// chart settings
mChart->setBackgroundBrush(QBrush(transparent));
mChart->setContentsMargins(-20, -20, -20, -65);
mChart->addSeries(mSeries);
mChart->legend()->hide();
// chartview settings
mChartView->setRenderHint(QPainter::Antialiasing);
ui->layoutCircleBar->insertWidget(1, mChartView);
connect(SignalMapper::ins(), &SignalMapper::sigChangedAppTheme, [=] {
QSettings *styleValues = AppManager::ins()->getStyleValues();
mChartView->setBackgroundBrush(QColor(styleValues->value("@circleChartBackgroundColor").toString()));
mSeries->slices().last()->setColor(styleValues->value("@pageContent").toString()); // trail color
});
}
void CircleBar::setValue(const int &value, const QString &valueText)
{
mSeries->slices().first()->setValue(value);
mSeries->slices().last()->setValue(100 - value);
ui->lblCircleChartValue->setText(valueText);
}
================================================
FILE: stacer/Pages/Dashboard/circlebar.h
================================================
#ifndef CIRCLEBAR_H
#define CIRCLEBAR_H
#include
#include
#include "Managers/app_manager.h"
#include "signal_mapper.h"
namespace Ui {
class CircleBar;
}
class CircleBar : public QWidget
{
Q_OBJECT
public:
explicit CircleBar(const QString &title, const QStringList &colors, QWidget *parent = 0);
~CircleBar();
public slots:
void setValue(const int &value, const QString &valueText);
private slots:
void init();
private:
Ui::CircleBar *ui;
private:
QStringList mColors;
QChart *mChart;
QChartView *mChartView;
QPieSeries *mSeries;
};
#endif // CIRCLEBAR_H
================================================
FILE: stacer/Pages/Dashboard/circlebar.ui
================================================
CircleBar
0
0
383
317
0
0
0
0
0
0
0
-
0
0
2
20
10
20
10
-
Title
Qt::AlignCenter
-
Value
Qt::AlignCenter
================================================
FILE: stacer/Pages/Dashboard/dashboard_page.cpp
================================================
#include "dashboard_page.h"
#include "ui_dashboard_page.h"
#include "utilities.h"
#include
#include
#include
DashboardPage::~DashboardPage()
{
delete ui;
}
DashboardPage::DashboardPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::DashboardPage),
mCpuBar(new CircleBar(tr("CPU"), {"#A8E063", "#56AB2F"}, this)),
mMemBar(new CircleBar(tr("MEMORY"), {"#FFB75E", "#ED8F03"}, this)),
mDiskBar(new CircleBar(tr("DISK"), {"#DC2430", "#7B4397"}, this)),
mDownloadBar(new LineBar(tr("DOWNLOAD"), this)),
mUploadBar(new LineBar(tr("UPLOAD"), this)),
mTimer(new QTimer(this)),
im(InfoManager::ins()),
mSettingManager(SettingManager::ins())
{
ui->setupUi(this);
init();
systemInformationInit();
}
void DashboardPage::init()
{
// Circle bars
ui->circleBarsLayout->addWidget(mCpuBar);
ui->circleBarsLayout->addWidget(mMemBar);
ui->circleBarsLayout->addWidget(mDiskBar);
// line bars
ui->lineBarsLayout->addWidget(mDownloadBar);
ui->lineBarsLayout->addWidget(mUploadBar);
// connections
connect(mTimer, &QTimer::timeout, this, &DashboardPage::updateCpuBar);
connect(mTimer, &QTimer::timeout, this, &DashboardPage::updateMemoryBar);
connect(mTimer, &QTimer::timeout, this, &DashboardPage::updateNetworkBar);
QTimer *timerDisk = new QTimer(this);
connect(timerDisk, &QTimer::timeout, this, &DashboardPage::updateDiskBar);
timerDisk->start(5 * 1000);
mTimer->start(1 * 1000);
// initialization
updateCpuBar();
updateMemoryBar();
updateDiskBar();
updateNetworkBar();
ui->widgetUpdateBar->hide();
// check update
checkUpdate();
connect(this, &DashboardPage::sigShowUpdateBar, ui->widgetUpdateBar, &QWidget::show);
QList widgets = {
mCpuBar, mMemBar, mDiskBar, mDownloadBar, mUploadBar
};
Utilities::addDropShadow(widgets, 60);
}
void DashboardPage::checkUpdate()
{
QNetworkAccessManager * nam = new QNetworkAccessManager(this);
const QNetworkRequest updateCheckRequest(QUrl("https://api.github.com/repos/oguzhaninan/Stacer/releases/latest"));
connect(nam,&QNetworkAccessManager::finished,this,[this](QNetworkReply * reply){
if(reply->error()==QNetworkReply::NoError)
{
const QString requestResult= reply->readAll();
const QJsonDocument result = QJsonDocument::fromJson(requestResult.toUtf8());
const QRegExp ex("([0-9].[0-9].[0-9])");
ex.indexIn(result.object().value("tag_name").toString());
if (ex.matchedLength() > 0)
{
const QString version = ex.cap();
if (qApp->applicationVersion() != version) {
emit sigShowUpdateBar();
}
}
}
});
nam->get(updateCheckRequest);
}
void DashboardPage::on_btnDownloadUpdate_clicked()
{
QDesktopServices::openUrl(QUrl("https://github.com/oguzhaninan/Stacer/releases/latest"));
}
void DashboardPage::systemInformationInit()
{
// get system information
SystemInfo sysInfo;
QStringList infos;
infos
<< tr("Hostname: %1").arg(sysInfo.getHostname())
<< tr("Platform: %1").arg(sysInfo.getPlatform())
<< tr("Distribution: %1").arg(sysInfo.getDistribution())
<< tr("Kernel Release: %1").arg(sysInfo.getKernel())
<< tr("CPU Model: %1").arg(sysInfo.getCpuModel())
<< tr("CPU Core: %1").arg(sysInfo.getCpuCore())
<< tr("CPU Speed: %1").arg(sysInfo.getCpuSpeed());
QStringListModel *systemInfoModel = new QStringListModel(infos,ui->listViewSystemInfo);
const auto oldModel = ui->listViewSystemInfo->selectionModel();
delete oldModel;
ui->listViewSystemInfo->setModel(systemInfoModel);
}
void DashboardPage::updateCpuBar()
{
int cpuUsedPercent = im->getCpuPercents().at(0);
double cpuCurrentClockGHz = im->getCpuClock()/1000.0;
// alert message
int cpuAlerPercent = mSettingManager->getCpuAlertPercent();
if (cpuAlerPercent > 0) {
static bool isShow = true;
if (cpuUsedPercent > cpuAlerPercent && isShow) {
AppManager::ins()->getTrayIcon()->showMessage(tr("High CPU Usage"),
tr("The amount of CPU used is over %1%.").arg(cpuAlerPercent),
QSystemTrayIcon::Warning);
isShow = false;
} else if (cpuUsedPercent < cpuAlerPercent) {
isShow = true;
}
}
mCpuBar->setValue(cpuUsedPercent, QString("%1 GHz\n%2%").arg(cpuCurrentClockGHz, 0, 'f', 2).arg(cpuUsedPercent));
}
void DashboardPage::updateMemoryBar()
{
im->updateMemoryInfo();
int memUsedPercent = 0;
if (im->getMemTotal()) {
memUsedPercent = ((double)im->getMemUsed() / (double)im->getMemTotal()) * 100.0;
}
QString f_memUsed = FormatUtil::formatBytes(im->getMemUsed());
QString f_memTotal = FormatUtil::formatBytes(im->getMemTotal());
// alert message
int memoryAlertPercent = mSettingManager->getMemoryAlertPercent();
if (memoryAlertPercent > 0) {
static bool isShow = true;
if (memUsedPercent > memoryAlertPercent && isShow) {
AppManager::ins()->getTrayIcon()->showMessage(tr("High Memory Usage"),
tr("The amount of memory used is over %1%.").arg(memoryAlertPercent),
QSystemTrayIcon::Warning);
isShow = false;
} else if (memUsedPercent < memoryAlertPercent) {
isShow = true;
}
}
mMemBar->setValue(memUsedPercent, QString("%1 / %2")
.arg(f_memUsed)
.arg(f_memTotal));
}
void DashboardPage::updateDiskBar()
{
im->updateDiskInfo();
if(! im->getDisks().isEmpty()) {
Disk *disk = nullptr;
QString selectedDiskName = mSettingManager->getDiskName();
for (Disk *d: im->getDisks()) {
if (d->name.trimmed() == selectedDiskName.trimmed())
disk = d;
}
if (! disk) {
for (Disk *d: im->getDisks())
if (d->name.trimmed() == QStorageInfo::root().displayName().trimmed())
disk = d;
if (! disk)
disk = im->getDisks().at(0);
}
int diskPercent = 0;
if (disk->size > 0) {
diskPercent = ((double) disk->used / (double) disk->size) * 100.0;
}
// alert message
int diskAlertPercent = mSettingManager->getDiskAlertPercent();
if (diskAlertPercent > 0) {
static bool isShow = true;
if (diskPercent > diskAlertPercent && isShow) {
AppManager::ins()->getTrayIcon()->showMessage(tr("High Disk Usage"),
tr("The amount of disk used is over %1%.").arg(diskAlertPercent),
QSystemTrayIcon::Warning);
isShow = false;
} else if (diskPercent < diskAlertPercent) {
isShow = true;
}
}
QString sizeText = FormatUtil::formatBytes(disk->size);
QString usedText = FormatUtil::formatBytes(disk->used);
mDiskBar->setValue(diskPercent, QString("%1 / %2")
.arg(usedText)
.arg(sizeText));
}
}
void DashboardPage::updateNetworkBar()
{
static quint64 l_RXbytes = im->getRXbytes();
static quint64 l_TXbytes = im->getTXbytes();
static quint64 max_RXbytes = 1L << 20; // 1 MEBI
static quint64 max_TXbytes = 1L << 20; // 1 MEBI
quint64 RXbytes = im->getRXbytes();
quint64 TXbytes = im->getTXbytes();
quint64 d_RXbytes = (RXbytes - l_RXbytes);
quint64 d_TXbytes = (TXbytes - l_TXbytes);
QString downText = FormatUtil::formatBytes(d_RXbytes);
QString upText = FormatUtil::formatBytes(d_TXbytes);
int downPercent = ((double) d_RXbytes / (double) max_RXbytes) * 100.0;
int upPercent = ((double) d_TXbytes / (double) max_TXbytes) * 100.0;
mDownloadBar->setValue(downPercent,
QString("%1/s").arg(downText),
tr("Total: %1").arg(FormatUtil::formatBytes(RXbytes)));
mUploadBar->setValue(upPercent,
QString("%1/s").arg(upText),
tr("Total: %1").arg(FormatUtil::formatBytes(TXbytes)));
max_RXbytes = qMax(max_RXbytes, d_RXbytes);
max_TXbytes = qMax(max_TXbytes, d_TXbytes);
l_RXbytes = RXbytes;
l_TXbytes = TXbytes;
}
================================================
FILE: stacer/Pages/Dashboard/dashboard_page.h
================================================
#ifndef DASHBOARDPAGE_H
#define DASHBOARDPAGE_H
#include
#include
#include
#include
#include
#include
#include
#include "Managers/info_manager.h"
#include "circlebar.h"
#include "linebar.h"
#include "Managers/setting_manager.h"
namespace Ui {
class DashboardPage;
}
class DashboardPage : public QWidget
{
Q_OBJECT
public:
explicit DashboardPage(QWidget *parent = 0);
~DashboardPage();
private slots:
void init();
void checkUpdate();
void systemInformationInit();
void updateCpuBar();
void updateMemoryBar();
void updateDiskBar();
void updateNetworkBar();
void on_btnDownloadUpdate_clicked();
signals:
void sigShowUpdateBar();
private:
Ui::DashboardPage *ui;
private:
CircleBar* mCpuBar;
CircleBar* mMemBar;
CircleBar* mDiskBar;
LineBar *mDownloadBar;
LineBar *mUploadBar;
QTimer *mTimer;
InfoManager *im;
SettingManager *mSettingManager;
};
#endif // DASHBOARDPAGE_H
================================================
FILE: stacer/Pages/Dashboard/dashboard_page.ui
================================================
DashboardPage
0
0
811
583
0
0
Dashboard
5
5
5
5
0
-
0
0
0
200
20
10
5
10
5
-
0
0
150
0
20
10
10
10
10
-
0
0
200
0
Qt::WheelFocus
5
15
0
10
0
-
Qt::Vertical
QSizePolicy::Fixed
20
15
-
SYSTEM INFO
-
Qt::NoFocus
Qt::ScrollBarAlwaysOff
Qt::ScrollBarAlwaysOff
false
QAbstractItemView::NoEditTriggers
QAbstractItemView::NoSelection
QAbstractItemView::SelectRows
5
true
-
0
0
0
31
0
15
0
5
0
-
There are update currently available.
-
PointingHandCursor
Qt::NoFocus
primary
Download
================================================
FILE: stacer/Pages/Dashboard/linebar.cpp
================================================
#include "linebar.h"
#include "ui_linebar.h"
LineBar::~LineBar()
{
delete ui;
}
LineBar::LineBar(const QString &title, QWidget *parent) :
QWidget(parent),
ui(new Ui::LineBar)
{
ui->setupUi(this);
ui->lblLineChartTitle->setText(title);
}
void LineBar::setValue(const int &value, const QString &text, const QString &totalText)
{
ui->lineChartProgress->setValue(value);
ui->lblLineChartValue->setText(text);
ui->lblLineChartTotal->setText(totalText);
}
================================================
FILE: stacer/Pages/Dashboard/linebar.h
================================================
#ifndef LINEBAR_H
#define LINEBAR_H
#include
namespace Ui {
class LineBar;
}
class LineBar : public QWidget
{
Q_OBJECT
public:
explicit LineBar(const QString &title, QWidget *parent = 0);
~LineBar();
public slots:
void setValue(const int &value, const QString &text, const QString &totalText);
private:
Ui::LineBar *ui;
};
#endif // LINEBAR_H
================================================
FILE: stacer/Pages/Dashboard/linebar.ui
================================================
LineBar
0
0
474
114
0
0
0
0
0
-
25
15
25
15
0
15
-
Total
-
0
20
16777215
20
0
false
-
Value
-
Title
================================================
FILE: stacer/Pages/GnomeSettings/appearance_settings.cpp
================================================
#include "appearance_settings.h"
#include "ui_appearance_settings.h"
#include
AppearanceSettings::~AppearanceSettings()
{
delete ui;
}
AppearanceSettings::AppearanceSettings(QWidget *parent) :
QWidget(parent),
ui(new Ui::AppearanceSettings),
gsettings(GnomeSettingsTool::ins())
{
ui->setupUi(this);
loadDatas();
init();
initConnects();
}
void AppearanceSettings::init()
{
bool showDesktopIcons = gsettings.getValueB(GSchemas::Appearance::Background, GSchemaKeys::Appearance::ShowDesktopIcons);
bool showHomeIcon = gsettings.getValueB(GSchemas::Appearance::Desktop, GSchemaKeys::Appearance::ShowHomeIcon);
bool showNetworkIcon = gsettings.getValueB(GSchemas::Appearance::Desktop, GSchemaKeys::Appearance::ShowNetworkIcon);
bool showTrashIcon = gsettings.getValueB(GSchemas::Appearance::Desktop, GSchemaKeys::Appearance::ShowTrashIcon);
bool showVolumesIcon = gsettings.getValueB(GSchemas::Appearance::Desktop, GSchemaKeys::Appearance::ShowVolumesIcon);
QString desktopBackMode = gsettings.getValueS(GSchemas::Appearance::Background, GSchemaKeys::Appearance::PictureOptions).replace("'","");
QString loginBackMode = gsettings.getValueS(GSchemas::Appearance::Screensaver, GSchemaKeys::Appearance::PictureOptions).replace("'","");
bool screenKeyboardEnabled = gsettings.getValueB(GSchemas::Appearance::Applications, GSchemaKeys::Appearance::ScreenKeyboard);
bool screenReaderEnabled = gsettings.getValueB(GSchemas::Appearance::Applications, GSchemaKeys::Appearance::ScreenReader);
ui->checkShowDesktopIcons->setChecked(showDesktopIcons);
ui->checkHomeIcon->setChecked(showHomeIcon);
ui->checkNetworkIcon->setChecked(showNetworkIcon);
ui->checkTrashIcon->setChecked(showTrashIcon);
ui->checkMountedVulmesIcon->setChecked(showVolumesIcon);
ui->cmbDesktopBackMode->setCurrentIndex(ui->cmbDesktopBackMode->findData(desktopBackMode));
ui->cmbLoginBackMode->setCurrentIndex(ui->cmbLoginBackMode->findData(loginBackMode));
ui->checkScreenKeyboard->setChecked(screenKeyboardEnabled);
ui->checkScreenReader->setChecked(screenReaderEnabled);
}
void AppearanceSettings::initConnects()
{
connect(ui->cmbDesktopBackMode, SIGNAL(currentIndexChanged(int)), this, SLOT(cmbDesktopBackMode_currentIndexChanged(int)));
connect(ui->cmbLoginBackMode, SIGNAL(currentIndexChanged(int)), this, SLOT(cmbLoginBackMode_currentIndexChanged(int)));
}
void AppearanceSettings::loadDatas()
{
QList> backgroundModes = {
{tr("None"), "none"}, {tr("Wallpaper"), "wallpaper"}, {tr("Centered"), "centered"},
{tr("Scaled"), "scaled"}, {tr("Stretched"), "stretched"}, {tr("Zoom"), "zoom"}, {tr("Spanned"), "spanned"}
};
for (const QPair &mode : backgroundModes) {
ui->cmbDesktopBackMode->addItem(mode.first, mode.second);
ui->cmbLoginBackMode->addItem(mode.first, mode.second);
}
}
void AppearanceSettings::on_checkShowDesktopIcons_clicked(bool checked)
{
if (! checked) {
ui->checkHomeIcon->setChecked(checked);
ui->checkNetworkIcon->setChecked(checked);
ui->checkMountedVulmesIcon->setChecked(checked);
ui->checkTrashIcon->setChecked(checked);
}
gsettings.setValueB(GSchemas::Appearance::Background, GSchemaKeys::Appearance::ShowDesktopIcons, checked);
}
void AppearanceSettings::on_checkHomeIcon_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Appearance::Desktop, GSchemaKeys::Appearance::ShowHomeIcon, checked);
}
void AppearanceSettings::on_checkTrashIcon_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Appearance::Desktop, GSchemaKeys::Appearance::ShowTrashIcon, checked);
}
void AppearanceSettings::on_checkMountedVulmesIcon_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Appearance::Desktop, GSchemaKeys::Appearance::ShowVolumesIcon, checked);
}
void AppearanceSettings::on_checkNetworkIcon_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Appearance::Desktop, GSchemaKeys::Appearance::ShowNetworkIcon, checked);
}
void AppearanceSettings::cmbDesktopBackMode_currentIndexChanged(int index)
{
QString data = ui->cmbDesktopBackMode->itemData(index).toString();
gsettings.setValueS(GSchemas::Appearance::Background, GSchemaKeys::Appearance::PictureOptions, data);
}
void AppearanceSettings::cmbLoginBackMode_currentIndexChanged(int index)
{
QString data = ui->cmbLoginBackMode->itemData(index).toString();
gsettings.setValueS(GSchemas::Appearance::Screensaver, GSchemaKeys::Appearance::PictureOptions, data);
}
void AppearanceSettings::on_checkScreenKeyboard_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Appearance::Applications, GSchemaKeys::Appearance::ScreenKeyboard, checked);
}
void AppearanceSettings::on_checkScreenReader_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Appearance::Applications, GSchemaKeys::Appearance::ScreenReader, checked);
}
================================================
FILE: stacer/Pages/GnomeSettings/appearance_settings.h
================================================
#ifndef APPEARANCE_SETTINGS_H
#define APPEARANCE_SETTINGS_H
#include
#include "Tools/gnome_settings_tool.h"
namespace Ui {
class AppearanceSettings;
}
class AppearanceSettings : public QWidget
{
Q_OBJECT
public:
explicit AppearanceSettings(QWidget *parent = 0);
~AppearanceSettings();
private slots:
void on_checkShowDesktopIcons_clicked(bool checked);
void on_checkHomeIcon_clicked(bool checked);
void on_checkTrashIcon_clicked(bool checked);
void on_checkMountedVulmesIcon_clicked(bool checked);
void on_checkNetworkIcon_clicked(bool checked);
void cmbDesktopBackMode_currentIndexChanged(int index);
void cmbLoginBackMode_currentIndexChanged(int index);
void on_checkScreenKeyboard_clicked(bool checked);
void on_checkScreenReader_clicked(bool checked);
private:
void init();
void initConnects();
void loadDatas();
private:
Ui::AppearanceSettings *ui;
GnomeSettingsTool gsettings;
};
#endif // APPEARANCE_SETTINGS_H
================================================
FILE: stacer/Pages/GnomeSettings/appearance_settings.ui
================================================
AppearanceSettings
0
0
801
438
0
0
0
0
0
-
20
10
-
Screen Applications
5
5
5
5
30
15
-
0
0
Screen Reader
-
PointingHandCursor
Qt::NoFocus
-
0
0
Screen Keyboard
-
PointingHandCursor
Qt::NoFocus
-
Qt::Horizontal
40
20
-
Background Image Mode
5
5
5
5
30
15
-
0
0
Desktop Mode
-
0
0
200
0
300
16777215
QComboBox::AdjustToMinimumContentsLength
-
0
0
Login Mode
-
0
0
200
0
300
16777215
QComboBox::AdjustToMinimumContentsLength
-
Qt::Horizontal
40
20
-
Icons
5
5
5
5
30
15
-
0
0
Home Icon
-
PointingHandCursor
Qt::NoFocus
-
0
0
Trash Icon
-
0
0
Mounted Volumes Icon
-
PointingHandCursor
Qt::NoFocus
-
0
0
Show Desktop Icons
-
PointingHandCursor
Qt::NoFocus
-
0
0
Network Icon
-
PointingHandCursor
Qt::NoFocus
-
PointingHandCursor
Qt::NoFocus
-
Qt::Horizontal
40
20
-
Qt::Vertical
20
40
================================================
FILE: stacer/Pages/GnomeSettings/gnome_settings_page.cpp
================================================
#include "gnome_settings_page.h"
#include "ui_gnome_settings_page.h"
#include "utilities.h"
GnomeSettingsPage::~GnomeSettingsPage()
{
delete ui;
}
GnomeSettingsPage::GnomeSettingsPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::GnomeSettingsPage),
slidingStackedWidget(new SlidingStackedWidget(this))
{
ui->setupUi(this);
init();
}
void GnomeSettingsPage::init()
{
ui->contentGridLayout->addWidget(slidingStackedWidget, 1, 0, 1, 1);
if (GnomeSettingsTool::ins().checkUnityAvailable()) {
unitySettings = new UnitySettings(slidingStackedWidget);
slidingStackedWidget->addWidget(unitySettings);
} else {
ui->btnUnitySettings->hide();
ui->btnWindowManager->setChecked(true);
}
windowManagerSettings = new WindowManagerSettings(slidingStackedWidget);
appearanceSettings = new AppearanceSettings(slidingStackedWidget);
slidingStackedWidget->addWidget(windowManagerSettings);
slidingStackedWidget->addWidget(appearanceSettings);
QList widgets = { ui->btnAppearance, ui->btnUnitySettings, ui->btnWindowManager };
Utilities::addDropShadow(widgets, 40);
}
void GnomeSettingsPage::on_btnUnitySettings_clicked()
{
slidingStackedWidget->slideInIdx(slidingStackedWidget->indexOf(unitySettings));
}
void GnomeSettingsPage::on_btnWindowManager_clicked()
{
slidingStackedWidget->slideInIdx(slidingStackedWidget->indexOf(windowManagerSettings));
}
void GnomeSettingsPage::on_btnAppearance_clicked()
{
slidingStackedWidget->slideInIdx(slidingStackedWidget->indexOf(appearanceSettings));
}
================================================
FILE: stacer/Pages/GnomeSettings/gnome_settings_page.h
================================================
#ifndef GNOME_SETTINGS_PAGE_H
#define GNOME_SETTINGS_PAGE_H
#include
#include "sliding_stacked_widget.h"
#include "unity_settings.h"
#include "window_manager_settings.h"
#include "appearance_settings.h"
namespace Ui {
class GnomeSettingsPage;
}
class GnomeSettingsPage : public QWidget
{
Q_OBJECT
public:
explicit GnomeSettingsPage(QWidget *parent = 0);
~GnomeSettingsPage();
private slots:
void on_btnUnitySettings_clicked();
void on_btnWindowManager_clicked();
void on_btnAppearance_clicked();
private:
void init();
private:
Ui::GnomeSettingsPage *ui;
SlidingStackedWidget *slidingStackedWidget;
UnitySettings *unitySettings;
WindowManagerSettings *windowManagerSettings;
AppearanceSettings *appearanceSettings;
};
#endif // GNOME_SETTINGS_PAGE_H
================================================
FILE: stacer/Pages/GnomeSettings/gnome_settings_page.ui
================================================
GnomeSettingsPage
0
0
788
601
Gnome Settings
15
10
15
20
20
15
-
20
-
PointingHandCursor
Qt::NoFocus
Unity Settings
:/static/themes/common/img/ubuntu.png:/static/themes/common/img/ubuntu.png
20
20
true
true
settingsTopButtonGroup
-
PointingHandCursor
Qt::NoFocus
Window Manager
:/static/themes/common/img/window.png:/static/themes/common/img/window.png
20
20
true
settingsTopButtonGroup
-
PointingHandCursor
Qt::NoFocus
Appearance
:/static/themes/common/img/appearance.png:/static/themes/common/img/appearance.png
20
20
true
settingsTopButtonGroup
================================================
FILE: stacer/Pages/GnomeSettings/unity_settings.cpp
================================================
#include "unity_settings.h"
#include "ui_unity_settings.h"
#include
UnitySettings::~UnitySettings()
{
delete ui;
}
UnitySettings::UnitySettings(QWidget *parent) :
QWidget(parent),
ui(new Ui::UnitySettings),
gsettings(GnomeSettingsTool::ins())
{
ui->setupUi(this);
init();
initConnects();
}
void UnitySettings::init()
{
bool launcherAutoHide = gsettings.getValueB(GSchemas::Unity::Shell, GSchemaKeys::Unity::LauncherHideMode, GSchemaPaths::Unity);
GValues::RevealLocation revealLocation = (GValues::RevealLocation) gsettings.getValueI(GSchemas::Unity::Shell, GSchemaKeys::Unity::RevealTrigger, GSchemaPaths::Unity);
float revealSensitivy = gsettings.getValueF(GSchemas::Unity::Shell, GSchemaKeys::Unity::EdgeResponsiveness, GSchemaPaths::Unity);
bool launcherMinimzeApp = gsettings.getValueB(GSchemas::Unity::Shell, GSchemaKeys::Unity::LauncherMinimizeApp, GSchemaPaths::Unity);
float launcherOpacity = gsettings.getValueF(GSchemas::Unity::Shell, GSchemaKeys::Unity::LauncherOpacity, GSchemaPaths::Unity);
int launcherVisibility = gsettings.getValueI(GSchemas::Unity::Shell, GSchemaKeys::Unity::LauncherVisibility, GSchemaPaths::Unity);
QString launcherPosition = gsettings.getValueS(GSchemas::Unity::Launcher, GSchemaKeys::Unity::LauncherPosition);
int iconSize = gsettings.getValueI(GSchemas::Unity::Shell, GSchemaKeys::Unity::LauncherIconSize, GSchemaPaths::Unity);
bool dashBlur = gsettings.getValueB(GSchemas::Unity::Shell, GSchemaKeys::Unity::DashBlur, GSchemaPaths::Unity);
QString searchOnlineResource = gsettings.getValueS(GSchemas::Unity::Lens, GSchemaKeys::Unity::SearchOnlineResource);
bool displayAvailableApps = gsettings.getValueB(GSchemas::Unity::AppLens, GSchemaKeys::Unity::DisplayAvailableApps);
bool displayRecentApps = gsettings.getValueB(GSchemas::Unity::AppLens, GSchemaKeys::Unity::DisplayRecentApps);
bool enableSearchFiles = gsettings.getValueB(GSchemas::Unity::FileLens, GSchemaKeys::Unity::EnableSearchFile);
float panelOpacity = gsettings.getValueF(GSchemas::Unity::Shell, GSchemaKeys::Unity::PanelOpacity, GSchemaPaths::Unity);
bool showDateTime = gsettings.getValueB(GSchemas::Unity::DateTime, GSchemaKeys::Unity::ShowDateTime);
QString timeFormat = gsettings.getValueS(GSchemas::Unity::DateTime, GSchemaKeys::Unity::TimeFormat);
bool showSeconds = gsettings.getValueB(GSchemas::Unity::DateTime, GSchemaKeys::Unity::ShowSeconds);
bool showDate = gsettings.getValueB(GSchemas::Unity::DateTime, GSchemaKeys::Unity::ShowDate);
bool showDay = gsettings.getValueB(GSchemas::Unity::DateTime, GSchemaKeys::Unity::ShowDay);
bool showCalendar = gsettings.getValueB(GSchemas::Unity::DateTime, GSchemaKeys::Unity::ShowCalendar);
bool showVolume = gsettings.getValueB(GSchemas::Unity::Sound, GSchemaKeys::Unity::ShowVolume);
bool showShowMyName = gsettings.getValueB(GSchemas::Unity::Session, GSchemaKeys::Unity::ShowMyName);
ui->checkLauncherAutoHide->setChecked(launcherAutoHide);
if (revealLocation == GValues::RevealLocation::TopLeft) {
ui->radioRevealTopLeft->setChecked(true);
} else {
ui->radioRevealLeft->setChecked(true);
}
ui->sliderRevealSensitivy->setValue(revealSensitivy / 0.1);
ui->checkMinimizeApps->setChecked(launcherMinimzeApp);
ui->sliderLauncherOpacity->setValue(launcherOpacity / 0.1);
if (launcherVisibility == GValues::LauncherVisibility::AllDesktop) {
ui->radioLauncherVisibleAllDesktop->setChecked(true);
} else {
ui->radioLauncherVisiblePrimaryDesktop->setChecked(true);
}
if (launcherPosition.contains(QRegExp("Left", Qt::CaseInsensitive))) {
ui->radioLauncherPositionLeft->setChecked(true);
} else {
ui->radioLauncherPositionBottom->setChecked(true);
}
ui->spinIconSize->setValue(iconSize);
ui->checkBackgroundBlur->setChecked(dashBlur);
if (searchOnlineResource.contains(QRegExp("all", Qt::CaseInsensitive))) {
ui->checkSearchOnlineResource->setChecked(true);
}
ui->checkMoreSuggestions->setChecked(displayAvailableApps);
ui->checkRecentlyUsed->setChecked(displayRecentApps);
ui->checkSearchYourFiles->setChecked(enableSearchFiles);
ui->sliderPanelOpacity->setValue(panelOpacity / 0.1);
ui->checkDateTime->setChecked(showDateTime);
if (timeFormat.contains(QRegExp("24-hour", Qt::CaseInsensitive))) {
ui->check24Hour->setChecked(true);
}
ui->checkSeconds->setChecked(showSeconds);
ui->checkDate->setChecked(showDate);
ui->checkWeekday->setChecked(showDay);
ui->checkCalendar->setChecked(showCalendar);
ui->checkVolume->setChecked(showVolume);
ui->checkShowMyName->setChecked(showShowMyName);
}
void UnitySettings::initConnects()
{
connect(ui->sliderLauncherOpacity, SIGNAL(valueChanged(int)), this, SLOT(sliderLauncherOpacity_valueChanged(int)));
connect(ui->sliderPanelOpacity, SIGNAL(valueChanged(int)), this, SLOT(sliderPanelOpacity_valueChanged(int)));
connect(ui->sliderRevealSensitivy, SIGNAL(valueChanged(int)), this, SLOT(sliderRevealSensitivy_valueChanged(int)));
connect(ui->spinIconSize, SIGNAL(valueChanged(int)), this, SLOT(spinIconSize_valueChanged(int)));
}
void UnitySettings::on_checkLauncherAutoHide_clicked(bool checked)
{
gsettings.setValueI(GSchemas::Unity::Shell, GSchemaKeys::Unity::LauncherHideMode, checked, GSchemaPaths::Unity);
}
void UnitySettings::on_radioRevealLeft_clicked()
{
gsettings.setValueI(GSchemas::Unity::Shell, GSchemaKeys::Unity::RevealTrigger, GValues::RevealLocation::Left, GSchemaPaths::Unity);
}
void UnitySettings::on_radioRevealTopLeft_clicked()
{
gsettings.setValueI(GSchemas::Unity::Shell, GSchemaKeys::Unity::RevealTrigger, GValues::RevealLocation::TopLeft, GSchemaPaths::Unity);
}
void UnitySettings::sliderRevealSensitivy_valueChanged(int value)
{
gsettings.setValueF(GSchemas::Unity::Shell, GSchemaKeys::Unity::EdgeResponsiveness, (value * 0.1), GSchemaPaths::Unity);
}
void UnitySettings::on_checkMinimizeApps_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Unity::Shell, GSchemaKeys::Unity::LauncherMinimizeApp, checked, GSchemaPaths::Unity);
}
void UnitySettings::sliderLauncherOpacity_valueChanged(int value)
{
gsettings.setValueF(GSchemas::Unity::Shell, GSchemaKeys::Unity::LauncherOpacity, (value * 0.1), GSchemaPaths::Unity);
}
void UnitySettings::on_radioLauncherVisibleAllDesktop_clicked()
{
gsettings.setValueI(GSchemas::Unity::Shell, GSchemaKeys::Unity::LauncherVisibility, GValues::AllDesktop, GSchemaPaths::Unity);
}
void UnitySettings::on_radioLauncherVisiblePrimaryDesktop_clicked()
{
gsettings.setValueI(GSchemas::Unity::Shell, GSchemaKeys::Unity::LauncherVisibility, GValues::PrimaryDesktop, GSchemaPaths::Unity);
}
void UnitySettings::on_radioLauncherPositionLeft_clicked()
{
gsettings.setValueS(GSchemas::Unity::Launcher, GSchemaKeys::Unity::LauncherPosition, "Left");
}
void UnitySettings::on_radioLauncherPositionBottom_clicked()
{
gsettings.setValueS(GSchemas::Unity::Launcher, GSchemaKeys::Unity::LauncherPosition, "Bottom");
}
void UnitySettings::spinIconSize_valueChanged(int value)
{
gsettings.setValueI(GSchemas::Unity::Shell, GSchemaKeys::Unity::LauncherIconSize, value, GSchemaPaths::Unity);
}
void UnitySettings::on_checkBackgroundBlur_clicked(bool checked)
{
gsettings.setValueI(GSchemas::Unity::Shell, GSchemaKeys::Unity::DashBlur, checked, GSchemaPaths::Unity);
}
void UnitySettings::on_checkSearchOnlineResource_clicked(bool checked)
{
gsettings.setValueS(GSchemas::Unity::Lens, GSchemaKeys::Unity::SearchOnlineResource, (checked ? "all" : "none"));
}
void UnitySettings::on_checkMoreSuggestions_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Unity::AppLens, GSchemaKeys::Unity::DisplayAvailableApps, checked);
}
void UnitySettings::on_checkRecentlyUsed_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Unity::AppLens, GSchemaKeys::Unity::DisplayRecentApps, checked);
}
void UnitySettings::on_checkSearchYourFiles_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Unity::FileLens, GSchemaKeys::Unity::EnableSearchFile, checked);
}
void UnitySettings::sliderPanelOpacity_valueChanged(int value)
{
gsettings.setValueF(GSchemas::Unity::Shell, GSchemaKeys::Unity::PanelOpacity, (value * 0.1), GSchemaPaths::Unity);
}
void UnitySettings::on_checkDateTime_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Unity::DateTime, GSchemaKeys::Unity::ShowDateTime, checked);
}
void UnitySettings::on_check24Hour_clicked(bool checked)
{
gsettings.setValueS(GSchemas::Unity::DateTime, GSchemaKeys::Unity::TimeFormat, (checked ? "24-hour" : "12-hour"));
}
void UnitySettings::on_checkSeconds_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Unity::DateTime, GSchemaKeys::Unity::ShowSeconds, checked);
}
void UnitySettings::on_checkDate_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Unity::DateTime, GSchemaKeys::Unity::ShowDate, checked);
}
void UnitySettings::on_checkWeekday_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Unity::DateTime, GSchemaKeys::Unity::ShowDay, checked);
}
void UnitySettings::on_checkCalendar_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Unity::DateTime, GSchemaKeys::Unity::ShowCalendar, checked);
}
void UnitySettings::on_checkVolume_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Unity::Sound, GSchemaKeys::Unity::ShowVolume, checked);
}
void UnitySettings::on_checkShowMyName_clicked(bool checked)
{
gsettings.setValueB(GSchemas::Unity::Session, GSchemaKeys::Unity::ShowMyName, checked);
}
================================================
FILE: stacer/Pages/GnomeSettings/unity_settings.h
================================================
#ifndef UNITY_SETTINGS_H
#define UNITY_SETTINGS_H
#include
#include "Tools/gnome_settings_tool.h"
namespace Ui {
class UnitySettings;
}
class UnitySettings : public QWidget
{
Q_OBJECT
public:
explicit UnitySettings(QWidget *parent = 0);
~UnitySettings();
public:
void init();
void initConnects();
private slots:
void on_checkLauncherAutoHide_clicked(bool checked);
void on_radioRevealLeft_clicked();
void on_radioRevealTopLeft_clicked();
void sliderRevealSensitivy_valueChanged(int value);
void on_checkMinimizeApps_clicked(bool checked);
void sliderLauncherOpacity_valueChanged(int value);
void on_radioLauncherVisibleAllDesktop_clicked();
void on_radioLauncherVisiblePrimaryDesktop_clicked();
void on_radioLauncherPositionLeft_clicked();
void on_radioLauncherPositionBottom_clicked();
void spinIconSize_valueChanged(int value);
void on_checkBackgroundBlur_clicked(bool checked);
void on_checkSearchOnlineResource_clicked(bool checked);
void on_checkMoreSuggestions_clicked(bool checked);
void on_checkRecentlyUsed_clicked(bool checked);
void on_checkSearchYourFiles_clicked(bool checked);
void sliderPanelOpacity_valueChanged(int value);
void on_checkDateTime_clicked(bool checked);
void on_check24Hour_clicked(bool checked);
void on_checkSeconds_clicked(bool checked);
void on_checkDate_clicked(bool checked);
void on_checkWeekday_clicked(bool checked);
void on_checkCalendar_clicked(bool checked);
void on_checkVolume_clicked(bool checked);
void on_checkShowMyName_clicked(bool checked);
private:
Ui::UnitySettings *ui;
GnomeSettingsTool gsettings;
};
#endif // UNITY_SETTINGS_H
================================================
FILE: stacer/Pages/GnomeSettings/unity_settings.ui
================================================
UnitySettings
0
0
809
817
0
0
0
0
0
-
true
0
0
807
815
0
0
0
0
10
-
Applications
5
5
5
5
30
10
-
PointingHandCursor
Qt::NoFocus
-
0
0
Show "Recently Used" applications
-
PointingHandCursor
Qt::NoFocus
-
0
0
Enable search of your files
-
PointingHandCursor
Qt::NoFocus
-
0
0
Show "More Suggestions"
-
Qt::Horizontal
40
20
-
general-title
Search
Qt::AlignCenter
-
General
5
5
5
5
30
10
-
0
0
Transparency Level
-
PointingHandCursor
Qt::NoFocus
1
10
2
1
1
Qt::Horizontal
-
Qt::Horizontal
40
20
-
Behaviour
5
5
5
5
30
15
-
PointingHandCursor
Qt::NoFocus
-
0
0
Auto Hide
-
0
0
PointingHandCursor
Left Side
buttonGroup
-
PointingHandCursor
Qt::NoFocus
1
10
1
1
Qt::Horizontal
-
0
0
Minimize applications with clicking
-
0
0
PointingHandCursor
Top-Left Corner
buttonGroup
-
0
0
Reveal Sensitivity
-
PointingHandCursor
Qt::NoFocus
-
0
0
Reveal Location
-
Qt::Horizontal
40
20
-
general-title
Launcher
Qt::AlignCenter
-
Appearance
5
5
5
5
30
10
-
0
0
PointingHandCursor
Left
buttonGroup_3
-
0
0
PointingHandCursor
Bottom
buttonGroup_3
-
0
0
Visibility
-
0
0
PointingHandCursor
Primary Desktop
buttonGroup_2
-
8
64
2
-
PointingHandCursor
Qt::NoFocus
1
10
2
1
Qt::Horizontal
-
0
0
Icon size
-
0
0
PointingHandCursor
All Desktops
buttonGroup_2
-
0
0
Position
-
0
0
Transparency Level
-
Qt::Horizontal
40
20
-
General
5
5
5
5
30
10
-
PointingHandCursor
Qt::NoFocus
-
0
0
Search online sources
-
PointingHandCursor
Qt::NoFocus
-
0
0
Background Blur
-
Qt::Horizontal
40
20
-
general-title
Panel
Qt::AlignCenter
-
Qt::Vertical
20
46
-
Indicators
5
5
5
5
30
10
-
0
0
PointingHandCursor
Qt::NoFocus
circle
Date
-
0
0
PointingHandCursor
Qt::NoFocus
circle
Calendar
-
0
0
Date & Time
-
0
0
24-Hour Time
-
0
0
PointingHandCursor
Qt::NoFocus
circle
Weekday
-
0
0
Include
-
0
0
PointingHandCursor
Qt::NoFocus
circle
Seconds
-
0
0
Volume
-
0
0
Show my name
-
PointingHandCursor
Qt::NoFocus
-
PointingHandCursor
Qt::NoFocus
-
PointingHandCursor
Qt::NoFocus
-
PointingHandCursor
Qt::NoFocus
-
Qt::Horizontal
40
20
================================================
FILE: stacer/Pages/GnomeSettings/window_manager_settings.cpp
================================================
#include "window_manager_settings.h"
#include "ui_window_manager_settings.h"
#include
WindowManagerSettings::~WindowManagerSettings()
{
delete ui;
}
WindowManagerSettings::WindowManagerSettings(QWidget *parent) :
QWidget(parent),
ui(new Ui::WindowManagerSettings),
gsettings(GnomeSettingsTool::ins())
{
ui->setupUi(this);
loadDatas();
init();
initConnects();
}
void WindowManagerSettings::init()
{
int textureFilter = gsettings.getValueI(GSchemas::Window::OpenGL, GSchemaKeys::Window::TextureQuality, GSchemaPaths::OpenGL);
int horizontalWorkspaceSize = gsettings.getValueI(GSchemas::Window::Core, GSchemaKeys::Window::HorizontalWorkSize, GSchemaPaths::Core);
int verticalWorkspaceSize = gsettings.getValueI(GSchemas::Window::Core, GSchemaKeys::Window::VerticalWorkSize, GSchemaPaths::Core);
bool workspaceSwitcher = horizontalWorkspaceSize > 1 || verticalWorkspaceSize > 1;
bool raiseOnClick = gsettings.getValueI(GSchemas::Window::Preferences, GSchemaKeys::Window::RaiseOnClick);
QString focusMode = gsettings.getValueS(GSchemas::Window::Preferences, GSchemaKeys::Window::FocusMode).replace("'", "");
QString actionDoubleClick = gsettings.getValueS(GSchemas::Window::Preferences, GSchemaKeys::Window::ActionDoubleClick).replace("'", "");
QString actionMiddleClick = gsettings.getValueS(GSchemas::Window::Preferences, GSchemaKeys::Window::ActionMiddleClick).replace("'", "");
QString actionRightClick = gsettings.getValueS(GSchemas::Window::Preferences, GSchemaKeys::Window::ActionRightClick).replace("'", "");
ui->cmbTextQuality->setCurrentIndex(textureFilter);
ui->checkWorkspaceSwitcher->setChecked(workspaceSwitcher);
ui->spinHorizonWorkspace->setValue(horizontalWorkspaceSize);
ui->spinVerticWorkspace->setValue(verticalWorkspaceSize);
ui->checkRaiseOnClick->setChecked(raiseOnClick);
ui->cmbFocusMode->setCurrentIndex(ui->cmbFocusMode->findData(focusMode));
ui->cmbTitleBarDoubleClick->setCurrentIndex(ui->cmbTitleBarDoubleClick->findData(actionDoubleClick));
ui->cmbTitleBarMiddleClick->setCurrentIndex(ui->cmbTitleBarMiddleClick->findData(actionMiddleClick));
ui->cmbTitleBarRightClick->setCurrentIndex(ui->cmbTitleBarRightClick->findData(actionRightClick));
}
void WindowManagerSettings::loadDatas()
{
QStringList textQualities = { tr("Fast"), tr("Good"), tr("Best") };
QList> textFocusModes = {
{tr("Click"), "click"}, {tr("Sloppy") , "sloppy"}, {tr("Mouse"), "mouse"}
};
for (const QString &qual : textQualities) {
ui->cmbTextQuality->addItem(qual, qual.toLower());
}
for (const QPair &mode : textFocusModes) {
ui->cmbFocusMode->addItem(mode.first, mode.second);
}
QList> titleBarClickActions = {
{tr("Toggle Shade"), "toggle-shade"}, {tr("Maximize"), "toggle-maximize"}, {tr("Maximize Horizontally"), "toggle-maximize-horizontally"},
{tr("Maximize Vertically"), "toggle-maximize-vertically"}, {tr("Minimize"), "minimize"},
{tr("None"), "none"}, {tr("Lower"), "lower"}, {tr("Menu"), "menu"}
};
for (const QPair &action : titleBarClickActions) {
ui->cmbTitleBarDoubleClick->addItem(action.first, action.second);
ui->cmbTitleBarMiddleClick->addItem(action.first, action.second);
ui->cmbTitleBarRightClick-> addItem(action.first, action.second);
}
}
void WindowManagerSettings::initConnects()
{
connect(ui->cmbTextQuality, SIGNAL(currentIndexChanged(int)), this, SLOT(cmbTextQuality_currentIndexChanged(int)));
connect(ui->checkWorkspaceSwitcher, SIGNAL(clicked(bool)), this, SLOT(checkWorkspaceSwitcher_clicked(bool)));
connect(ui->spinHorizonWorkspace, SIGNAL(valueChanged(int)), this, SLOT(spinHorizonWorkspace_valueChanged(int)));
connect(ui->spinVerticWorkspace, SIGNAL(valueChanged(int)), this, SLOT(spinVerticWorkspace_valueChanged(int)));
connect(ui->checkRaiseOnClick, SIGNAL(clicked(bool)), this, SLOT(checkRaiseOnClick_clicked(bool)));
connect(ui->cmbFocusMode, SIGNAL(currentIndexChanged(int)), this, SLOT(cmbFocusMode_currentIndexChanged(int)));
connect(ui->cmbTitleBarDoubleClick, SIGNAL(currentIndexChanged(int)), this, SLOT(cmbTitleBarDoubleClick_currentIndexChanged(int)));
connect(ui->cmbTitleBarMiddleClick, SIGNAL(currentIndexChanged(int)), this, SLOT(cmbTitleBarMiddleClick_currentIndexChanged(int)));
connect(ui->cmbTitleBarRightClick, SIGNAL(currentIndexChanged(int)), this, SLOT(cmbTitleBarRightClick_currentIndexChanged(int)));
}
void WindowManagerSettings::cmbTextQuality_currentIndexChanged(int index)
{
gsettings.setValueI(GSchemas::Window::OpenGL, GSchemaKeys::Window::TextureQuality, index, GSchemaPaths::OpenGL);
}
void WindowManagerSettings::checkWorkspaceSwitcher_clicked(bool checked)
{
int workSize = checked ? 2 : 1;
gsettings.setValueI(GSchemas::Window::Core, GSchemaKeys::Window::HorizontalWorkSize, workSize, GSchemaPaths::Core);
gsettings.setValueI(GSchemas::Window::Core, GSchemaKeys::Window::VerticalWorkSize, workSize, GSchemaPaths::Core);
ui->spinHorizonWorkspace->setValue(workSize);
ui->spinVerticWorkspace->setValue(workSize);
}
void WindowManagerSettings::spinHorizonWorkspace_valueChanged(int value)
{
gsettings.setValueI(GSchemas::Window::Core, GSchemaKeys::Window::HorizontalWorkSize, value, GSchemaPaths::Core);
}
void WindowManagerSettings::spinVerticWorkspace_valueChanged(int value)
{
gsettings.setValueI(GSchemas::Window::Core, GSchemaKeys::Window::VerticalWorkSize, value, GSchemaPaths::Core);
}
void WindowManagerSettings::checkRaiseOnClick_clicked(bool checked)
{
gsettings.setValueI(GSchemas::Window::Preferences, GSchemaKeys::Window::RaiseOnClick, checked);
}
void WindowManagerSettings::cmbFocusMode_currentIndexChanged(int index)
{
QString data = ui->cmbFocusMode->itemData(index).toString();
gsettings.setValueS(GSchemas::Window::Preferences, GSchemaKeys::Window::FocusMode, data);
}
void WindowManagerSettings::cmbTitleBarDoubleClick_currentIndexChanged(int index)
{
QString data = ui->cmbTitleBarDoubleClick->itemData(index).toString();
gsettings.setValueS(GSchemas::Window::Preferences, GSchemaKeys::Window::ActionDoubleClick, data);
}
void WindowManagerSettings::cmbTitleBarMiddleClick_currentIndexChanged(int index)
{
QString data = ui->cmbTitleBarMiddleClick->itemData(index).toString();
gsettings.setValueS(GSchemas::Window::Preferences, GSchemaKeys::Window::ActionMiddleClick, data);
}
void WindowManagerSettings::cmbTitleBarRightClick_currentIndexChanged(int index)
{
QString data = ui->cmbTitleBarRightClick->itemData(index).toString();
gsettings.setValueS(GSchemas::Window::Preferences, GSchemaKeys::Window::ActionRightClick, data);
}
================================================
FILE: stacer/Pages/GnomeSettings/window_manager_settings.h
================================================
#ifndef WINDOW_MANAGER_SETTINGS_H
#define WINDOW_MANAGER_SETTINGS_H
#include
#include "Tools/gnome_settings_tool.h"
namespace Ui {
class WindowManagerSettings;
}
class WindowManagerSettings : public QWidget
{
Q_OBJECT
public:
explicit WindowManagerSettings(QWidget *parent = 0);
~WindowManagerSettings();
private slots:
void cmbTextQuality_currentIndexChanged(int index);
void checkWorkspaceSwitcher_clicked(bool checked);
void spinHorizonWorkspace_valueChanged(int value);
void spinVerticWorkspace_valueChanged(int value);
void checkRaiseOnClick_clicked(bool checked);
void cmbFocusMode_currentIndexChanged(int index);
void cmbTitleBarDoubleClick_currentIndexChanged(int index);
void cmbTitleBarMiddleClick_currentIndexChanged(int index);
void cmbTitleBarRightClick_currentIndexChanged(int index);
private:
void init();
void loadDatas();
void initConnects();
private:
Ui::WindowManagerSettings *ui;
GnomeSettingsTool gsettings;
};
#endif // WINDOW_MANAGER_SETTINGS_H
================================================
FILE: stacer/Pages/GnomeSettings/window_manager_settings.ui
================================================
WindowManagerSettings
0
0
933
467
0
0
0
0
0
-
0
0
true
0
0
931
465
0
0
0
0
15
10
-
Qt::Vertical
20
46
-
general-title
General
Qt::AlignCenter
-
Titlebar Actions
5
5
5
5
30
15
-
0
0
300
0
16777215
16777215
QComboBox::AdjustToMinimumContentsLength
-
0
0
Right click
-
0
0
Double click
-
0
0
Middle click
-
0
0
300
0
16777215
16777215
QComboBox::AdjustToMinimumContentsLength
-
0
0
300
0
16777215
16777215
QComboBox::AdjustToMinimumContentsLength
-
Qt::Horizontal
40
20
-
general-title
Additional
Qt::AlignCenter
-
Workspace Settings
5
5
5
5
30
15
-
PointingHandCursor
Qt::NoFocus
-
0
0
Vertical workspaces
-
1
25
-
0
0
Workspace switcher
-
1
25
-
0
0
Horizontal workspaces
-
Qt::Horizontal
40
20
-
Focus Behaviour
5
5
5
5
30
15
-
0
0
Focus mode
-
PointingHandCursor
Qt::NoFocus
-
0
0
300
0
16777215
16777215
QComboBox::AdjustToMinimumContentsLength
-
0
0
Raise on click
-
Qt::Horizontal
40
20
-
Hardware Acceleration
5
5
5
5
30
15
-
0
0
300
0
16777215
16777215
QComboBox::AdjustToMinimumContentsLength
-
0
0
Text quality
-
Qt::Horizontal
40
20
================================================
FILE: stacer/Pages/Helpers/helpers_page.cpp
================================================
#include "helpers_page.h"
#include "ui_helpers_page.h"
HelpersPage::~HelpersPage()
{
delete ui;
}
HelpersPage::HelpersPage(QWidget *parent) :
QWidget(parent),
widgetHostManage(new HostManage),
ui(new Ui::HelpersPage)
{
ui->setupUi(this);
init();
}
void HelpersPage::init()
{
ui->stackedWidget->addWidget(widgetHostManage);
//ui->stackedWidget->addWidget();
Utilities::addDropShadow({
ui->btnHostManage
}, 40);
}
void HelpersPage::on_btnHostManage_clicked()
{
ui->stackedWidget->setCurrentIndex(0);
}
================================================
FILE: stacer/Pages/Helpers/helpers_page.h
================================================
#ifndef HELPERS_PAGE_H
#define HELPERS_PAGE_H
#include
#include "host_manage.h"
#include "utilities.h"
namespace Ui {
class HelpersPage;
}
class HelpersPage : public QWidget
{
Q_OBJECT
public:
explicit HelpersPage(QWidget *parent = 0);
~HelpersPage();
private slots:
void on_btnHostManage_clicked();
void init();
private:
Ui::HelpersPage *ui;
HostManage *widgetHostManage;
};
#endif // HELPERS_PAGE_H
================================================
FILE: stacer/Pages/Helpers/helpers_page.ui
================================================
HelpersPage
0
0
839
590
Helpers
15
10
15
10
10
-
-
12
0
0
0
0
-
PointingHandCursor
Qt::NoFocus
Host Manage
true
true
buttonGroup
-
Qt::Horizontal
40
20
================================================
FILE: stacer/Pages/Helpers/host_manage.cpp
================================================
#include "host_manage.h"
#include "ui_host_manage.h"
#include
HostManage::~HostManage()
{
delete ui;
}
HostManage::HostManage(QWidget *parent):
QWidget(parent),
mItemModel(new QStandardItemModel(this)),
mSortFilterModel(new QSortFilterProxyModel(this)),
updatedLine(-1),
ui(new Ui::HostManage)
{
ui->setupUi(this);
init();
}
void HostManage::init()
{
ui->lblHostTitle->setText(tr("Hosts (%1)").arg(1));
Utilities::addDropShadow({
ui->btnCancel, ui->btnNewHost, ui->btnSave, ui->txtAliases, ui->txtFullyQualified,
ui->txtIP, ui->tableViewHosts
}, 40);
ui->widgetAddEditHost->hide();
ui->lblErrorMsg->hide();
mHeaderList = {
tr("IP Address"), tr("Full Qualified"), tr("Aliases")
};
mItemModel->setHorizontalHeaderLabels(mHeaderList);
mSortFilterModel->setSourceModel(mItemModel);
ui->tableViewHosts->setModel(mSortFilterModel);
mSortFilterModel->setSortRole(1);
mSortFilterModel->setDynamicSortFilter(true);
ui->tableViewHosts->horizontalHeader()->setSectionsMovable(true);
ui->tableViewHosts->horizontalHeader()->setFixedHeight(32);
ui->tableViewHosts->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->tableViewHosts->horizontalHeader()->setCursor(Qt::PointingHandCursor);
ui->tableViewHosts->horizontalHeader()->resizeSection(0, 195);
ui->tableViewHosts->horizontalHeader()->resizeSection(1, 195);
ui->tableViewHosts->setContextMenuPolicy(Qt::CustomContextMenu);
loadTableRowMenu();
mHostFileContent = FileUtil::readListFromFile("/etc/hosts");
loadTableData();
}
void HostManage::loadHostItems()
{
mHostItemList.clear();
int i = 0;
for (const QString &line: mHostFileContent)
{
if (! line.trimmed().startsWith("#") && ! line.trimmed().isEmpty())
{
QStringList lineItems = line.trimmed().split(QRegExp("\\s+"));
if (lineItems.count() > 1) {
HostItem hItem;
hItem.ip = lineItems.at(0).trimmed();
hItem.fullQualified = lineItems.at(1).trimmed();
hItem.aliases = lineItems.count() > 2 ? lineItems.mid(2).join(" ") : "";
mHostItemList.insert(i, hItem);
}
}
i++;
}
}
void HostManage::loadTableData()
{
loadHostItems();
mItemModel->removeRows(0, mItemModel->rowCount());
QMapIterator itemIterator(mHostItemList);
while (itemIterator.hasNext()) {
itemIterator.next();
mItemModel->appendRow(createRow(QPair(itemIterator.key(), itemIterator.value())));
}
ui->lblHostTitle->setText(tr("Hosts (%1)").arg(mHostItemList.count()));
}
QList HostManage::createRow(const QPair &item)
{
QStandardItem *i_ip = new QStandardItem(item.second.ip);
i_ip->setData(item.first, 9);
i_ip->setData(item.second.ip, 1);
i_ip->setData(item.second.ip, Qt::ToolTipRole);
QStandardItem *i_fullQualified = new QStandardItem(item.second.fullQualified);
i_fullQualified->setData(item.second.fullQualified, 1);
i_fullQualified->setData(item.second.fullQualified, Qt::ToolTipRole);
QStandardItem *i_aliases = new QStandardItem(item.second.aliases);
i_aliases->setData(item.second.aliases, 1);
i_aliases->setData(item.second.aliases, Qt::ToolTipRole);
return {
i_ip, i_fullQualified, i_aliases
};
}
void HostManage::on_btnNewHost_clicked()
{
ui->widgetAddEditHost->show();
ui->lblErrorMsg->hide();
ui->txtIP->clear();
ui->txtFullyQualified->clear();
ui->txtAliases->clear();
updatedLine = -1;
}
void HostManage::loadTableRowMenu()
{
QAction *actionOpenFolder = new QAction(QIcon(":/static/themes/common/img/folder.png"), tr("Edit"),&mTableRowMenu);
actionOpenFolder->setData("edit");
mTableRowMenu.addAction(actionOpenFolder);
QAction *actionDelete = new QAction(QIcon(":/static/themes/common/img/delete.png"), tr("Delete"),&mTableRowMenu);
actionDelete->setData("delete");
mTableRowMenu.addAction(actionDelete);
}
void HostManage::on_btnSave_clicked()
{
if (ui->txtIP->text().isEmpty() || ui->txtFullyQualified->text().isEmpty()) {
ui->lblErrorMsg->setText(tr("The IP and Fully Qualified fields are required."));
ui->lblErrorMsg->show();
}
else {
QString item = QString("%1 %2 %3")
.arg(ui->txtIP->text().trimmed())
.arg(ui->txtFullyQualified->text().trimmed())
.arg(ui->txtAliases->text());
if (updatedLine == -1) {
mHostFileContent.append(item);
} else {
mHostFileContent.replace(updatedLine, item);
}
updatedLine = -1;
loadTableData();
ui->widgetAddEditHost->hide();
}
}
void HostManage::on_btnCancel_clicked()
{
ui->widgetAddEditHost->hide();
ui->lblErrorMsg->hide();
updatedLine = -1;
}
void HostManage::on_btnSaveChanges_clicked()
{
FileUtil::writeFile("/tmp/stacer_etc_host_new_content", mHostFileContent.join("\n"));
try {
CommandUtil::sudoExec("mv", {"/tmp/stacer_etc_host_new_content", "/etc/hosts"});
loadTableData();
} catch (QString ex) {
qDebug() << ex;
}
}
void HostManage::on_tableViewHosts_customContextMenuRequested(const QPoint &pos)
{
if (mItemModel->rowCount() > 0) {
QPoint globalPos = ui->tableViewHosts->mapToGlobal(pos);
QAction *action = mTableRowMenu.exec(globalPos);
QModelIndexList selecteds = ui->tableViewHosts->selectionModel()->selectedRows();
QItemSelectionModel *selectionModel = ui->tableViewHosts->selectionModel();
if (action && ! selecteds.isEmpty()) {
if (action->data().toString() == "edit") {
QModelIndex index = selectionModel->selectedRows().first();
updatedLine = mSortFilterModel->index(index.row(), 0).data(9).toInt();
ui->txtIP->setText(mHostItemList.value(updatedLine).ip);
ui->txtFullyQualified->setText(mHostItemList.value(updatedLine).fullQualified);
ui->txtAliases->setText(mHostItemList.value(updatedLine).aliases);
ui->widgetAddEditHost->show();
selectionModel->clearSelection();
}
else if (action->data().toString() == "delete") {
while (! selectionModel->selectedRows().isEmpty()) {
QModelIndex index = selectionModel->selectedRows().first();
int lineNumber = mSortFilterModel->index(index.row(), 0).data(9).toInt();
mHostFileContent.replace(lineNumber, "");
selectionModel->select(index, QItemSelectionModel::Deselect);
}
selectionModel->clearSelection();
loadTableData();
}
}
}
}
================================================
FILE: stacer/Pages/Helpers/host_manage.h
================================================
#ifndef HOST_MANAGE_H
#define HOST_MANAGE_H
#include
#include
#include
#include
#include "Utils/file_util.h"
#include "Utils/command_util.h"
#include "utilities.h"
namespace Ui {
class HostManage;
}
class HostItem
{
public:
QString ip;
QString fullQualified;
QString aliases;
};
class HostManage : public QWidget
{
Q_OBJECT
public:
explicit HostManage(QWidget *parent = 0);
~HostManage();
private slots:
void init();
void on_btnNewHost_clicked();
void on_btnSave_clicked();
void loadHostItems();
void loadTableData();
void on_btnCancel_clicked();
void loadTableRowMenu();
void on_btnSaveChanges_clicked();
QList createRow(const QPair &item);
void on_tableViewHosts_customContextMenuRequested(const QPoint &pos);
private:
Ui::HostManage *ui;
bool isAddHost;
QList mHeaderList;
QStandardItemModel *mItemModel;
QSortFilterProxyModel *mSortFilterModel;
QMenu mTableRowMenu;
QStringList mHostFileContent;
QMap mHostItemList;
int updatedLine;
};
#endif // HOST_MANAGE_H
================================================
FILE: stacer/Pages/Helpers/host_manage.ui
================================================
HostManage
0
0
804
534
Form
5
0
5
10
10
-
10
-
-
PointingHandCursor
Qt::NoFocus
primary
Save Changes
-
10
0
0
-
-
Qt::Horizontal
40
20
-
PointingHandCursor
Qt::NoFocus
New Host
true
true
-
8
0
0
0
0
-
Qt::StrongFocus
IP Address *
-
Fully Qualified Name *
-
Aliases
-
PointingHandCursor
Qt::NoFocus
primary
Save
-
PointingHandCursor
Qt::NoFocus
danger
Cancel
-
Qt::NoFocus
QFrame::NoFrame
QAbstractItemView::NoEditTriggers
QAbstractItemView::SelectRows
Qt::ElideMiddle
true
true
true
false
================================================
FILE: stacer/Pages/Processes/processes_page.cpp
================================================
#include "processes_page.h"
#include "ui_processes_page.h"
#include "utilities.h"
ProcessesPage::~ProcessesPage()
{
delete ui;
}
ProcessesPage::ProcessesPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::ProcessesPage),
mItemModel(new QStandardItemModel(this)),
mSortFilterModel(new QSortFilterProxyModel(this)),
im(InfoManager::ins()),
mTimer(new QTimer(this))
{
ui->setupUi(this);
init();
}
void ProcessesPage::init()
{
mHeaders = QStringList {
"PID", tr("Resident Memory"), tr("%Memory"), tr("Virtual Memory"),
tr("User"), "%CPU", tr("Start Time"), tr("State"), tr("Group"),
tr("Nice"), tr("CPU Time"), tr("Session"), tr("Process")
};
// slider settings
ui->sliderRefresh->setRange(1, 10);
ui->sliderRefresh->setPageStep(1);
ui->sliderRefresh->setSingleStep(1);
// Table settings
mSortFilterModel->setSourceModel(mItemModel);
mItemModel->setHorizontalHeaderLabels(mHeaders);
ui->tableProcess->setModel(mSortFilterModel);
mSortFilterModel->setSortRole(1);
mSortFilterModel->setDynamicSortFilter(true);
mSortFilterModel->sort(5, Qt::SortOrder::DescendingOrder);
ui->tableProcess->horizontalHeader()->setSectionsMovable(true);
ui->tableProcess->horizontalHeader()->setFixedHeight(36);
ui->tableProcess->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->tableProcess->horizontalHeader()->setCursor(Qt::PointingHandCursor);
ui->tableProcess->horizontalHeader()->resizeSection(0, 70);
loadProcesses();
connect(mTimer, &QTimer::timeout, this, &ProcessesPage::loadProcesses);
mTimer->setInterval(1000);
mTimer->start();
ui->tableProcess->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->tableProcess->horizontalHeader(), SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(on_tableProcess_customContextMenuRequested(const QPoint&)));
loadHeaderMenu();
Utilities::addDropShadow(ui->btnEndProcess, 60);
Utilities::addDropShadow(ui->tableProcess, 55);
}
void ProcessesPage::loadHeaderMenu()
{
int i = 0;
QList actionList;
actionList.reserve(mHeaders.size());
for (const QString &header : mHeaders) {
QAction *action = new QAction(header,&mHeaderMenu);
action->setCheckable(true);
action->setChecked(true);
action->setData(i++);
actionList.push_back(action);
}
mHeaderMenu.addActions(actionList);
// exclude headers
QList hiddenHeaders = { 3, 6, 7, 8, 9, 10, 11 };
QList actions = mHeaderMenu.actions();
for (const int i : hiddenHeaders) {
if (i < mHeaders.count()) {
ui->tableProcess->horizontalHeader()->setSectionHidden(i, true);
actions.at(i)->setChecked(false);
}
}
}
void ProcessesPage::loadProcesses()
{
QModelIndexList selecteds = ui->tableProcess->selectionModel()->selectedRows();
mItemModel->removeRows(0, mItemModel->rowCount());
im->updateProcesses();
QList processes = im->getProcesses();
QString username = im->getUserName();
if (ui->checkAllProcesses->isChecked()) {
for (const Process &proc : processes) {
mItemModel->appendRow(createRow(proc));
}
} else {
for (const Process &proc : processes) {
if (username == proc.getUname()) {
mItemModel->appendRow(createRow(proc));
}
}
}
ui->lblProcessTitle->setText(tr("Processes (%1)").arg(mItemModel->rowCount()));
// selected item
if (! selecteds.isEmpty()) {
mSeletedRowModel = selecteds.first();
for (int i = 0; i < mSortFilterModel->rowCount(); ++i) {
if (mSortFilterModel->index(i, 0).data(1).toInt() == mSeletedRowModel.data(1).toInt()) {
ui->tableProcess->selectRow(i);
}
}
} else {
mSeletedRowModel = QModelIndex();
}
}
QList ProcessesPage::createRow(const Process &proc)
{
QList row;
int data = 1;
QStandardItem *pid_i = new QStandardItem(QString::number(proc.getPid()));
pid_i->setData(proc.getPid(), data);
pid_i->setData(proc.getPid(), Qt::ToolTipRole);
QStandardItem *rss_i = new QStandardItem(FormatUtil::formatBytes(proc.getRss()));
rss_i->setData(proc.getRss(), data);
rss_i->setData(FormatUtil::formatBytes(proc.getRss()), Qt::ToolTipRole);
QStandardItem *pmem_i = new QStandardItem(QString::number(proc.getPmem()));
pmem_i->setData(proc.getPmem(), data);
pmem_i->setData(proc.getPmem(), Qt::ToolTipRole);
QStandardItem *vsize_i = new QStandardItem(FormatUtil::formatBytes(proc.getVsize()));
vsize_i->setData(proc.getVsize(), data);
vsize_i->setData(FormatUtil::formatBytes(proc.getVsize()), Qt::ToolTipRole);
QStandardItem *uname_i = new QStandardItem(proc.getUname());
uname_i->setData(proc.getUname(), data);
uname_i->setData(proc.getUname(), Qt::ToolTipRole);
QStandardItem *pcpu_i = new QStandardItem(QString::number(proc.getPcpu()));
pcpu_i->setData(proc.getPcpu(), data);
pcpu_i->setData(proc.getPcpu(), Qt::ToolTipRole);
QStandardItem *starttime_i = new QStandardItem(proc.getStartTime());
starttime_i->setData(proc.getStartTime(), data);
starttime_i->setData(proc.getStartTime(), Qt::ToolTipRole);
QStandardItem *state_i = new QStandardItem(proc.getState());
state_i->setData(proc.getState(), data);
state_i->setData(proc.getState(), Qt::ToolTipRole);
QStandardItem *group_i = new QStandardItem(proc.getGroup());
group_i->setData(proc.getGroup(), data);
group_i->setData(proc.getGroup(), Qt::ToolTipRole);
QStandardItem *nice_i = new QStandardItem(QString::number(proc.getNice()));
nice_i->setData(proc.getNice(), data);
nice_i->setData(proc.getNice(), Qt::ToolTipRole);
QStandardItem *cpuTime_i = new QStandardItem(proc.getCpuTime());
cpuTime_i->setData(proc.getCpuTime(), data);
cpuTime_i->setData(proc.getCpuTime(), Qt::ToolTipRole);
QStandardItem *session_i = new QStandardItem(proc.getSession());
session_i->setData(proc.getSession(), data);
session_i->setData(proc.getSession(), Qt::ToolTipRole);
QStandardItem *cmd_i = new QStandardItem(proc.getCmd());
cmd_i->setData(proc.getCmd(), data);
cmd_i->setData(QString("%1
").arg(proc.getCmd()), Qt::ToolTipRole);
row << pid_i << rss_i << pmem_i << vsize_i << uname_i << pcpu_i
<< starttime_i << state_i << group_i << nice_i << cpuTime_i
<< session_i << cmd_i;
return row;
}
void ProcessesPage::on_txtProcessSearch_textChanged(const QString &val)
{
QRegExp query(val, Qt::CaseInsensitive, QRegExp::Wildcard);
mSortFilterModel->setFilterKeyColumn(mHeaders.count() - 1); // process name
mSortFilterModel->setFilterRegExp(query);
}
void ProcessesPage::on_sliderRefresh_valueChanged(const int &i)
{
ui->lblRefresh->setText(tr("Refresh (%1)").arg(i));
mTimer->setInterval(i * 1000);
}
void ProcessesPage::on_btnEndProcess_clicked()
{
pid_t pid = mSeletedRowModel.data(1).toInt();
if (pid) {
QString selectedUname = mSortFilterModel->index(mSeletedRowModel.row(), 4).data(1).toString();
try {
if (selectedUname == im->getUserName()) {
CommandUtil::exec("kill", { QString::number(pid) });
} else {
CommandUtil::sudoExec("kill", { QString::number(pid) });
}
} catch (QString &ex) {
qCritical() << ex;
}
}
}
void ProcessesPage::on_tableProcess_customContextMenuRequested(const QPoint &pos)
{
QPoint globalPos = ui->tableProcess->mapToGlobal(pos);
QAction *action = mHeaderMenu.exec(globalPos);
if (action) {
ui->tableProcess->horizontalHeader()->setSectionHidden(action->data().toInt(), ! action->isChecked());
}
}
================================================
FILE: stacer/Pages/Processes/processes_page.h
================================================
#ifndef PROCESSESPAGE_H
#define PROCESSESPAGE_H
#include
#include
#include
#include
#include
#include
#include
#include
#include "Managers/info_manager.h"
namespace Ui {
class ProcessesPage;
}
class ProcessesPage : public QWidget
{
Q_OBJECT
public:
explicit ProcessesPage(QWidget *parent = 0);
~ProcessesPage();
private slots:
void init();
void loadProcesses();
void loadHeaderMenu();
QList createRow(const Process &proc);
void on_txtProcessSearch_textChanged(const QString &val);
void on_sliderRefresh_valueChanged(const int &i);
void on_btnEndProcess_clicked();
void on_tableProcess_customContextMenuRequested(const QPoint &pos);
private:
Ui::ProcessesPage *ui;
QStandardItemModel *mItemModel;
QSortFilterProxyModel *mSortFilterModel;
QModelIndex mSeletedRowModel;
QStringList mHeaders;
QMenu mHeaderMenu;
QTimer *mTimer;
InfoManager *im;
};
#endif // PROCESSESPAGE_H
================================================
FILE: stacer/Pages/Processes/processes_page.ui
================================================
ProcessesPage
0
0
835
612
Processes
20
5
20
20
0
5
-
10
5
0
10
-
Processes
-
PointingHandCursor
Qt::NoFocus
circle
All Processes
-
Qt::Horizontal
40
20
-
10
Search...
-
Qt::NoFocus
QFrame::NoFrame
QFrame::Sunken
QAbstractScrollArea::AdjustToContents
QAbstractItemView::NoEditTriggers
QAbstractItemView::SingleSelection
QAbstractItemView::SelectRows
Qt::ElideMiddle
Qt::SolidLine
true
true
true
false
true
false
-
10
0
5
0
0
-
Refresh (1)
-
PointingHandCursor
Qt::NoFocus
Qt::Horizontal
-
Qt::Horizontal
40
20
-
PointingHandCursor
Qt::NoFocus
primary
End Process
================================================
FILE: stacer/Pages/Resources/history_chart.cpp
================================================
#include "history_chart.h"
#include "ui_history_chart.h"
HistoryChart::~HistoryChart()
{
delete ui;
}
HistoryChart::HistoryChart(const QString &title, const int &seriesCount, QCategoryAxis* categoriAxisY, QWidget *parent) :
QWidget(parent),
ui(new Ui::HistoryChart),
mTitle(title),
mSeriesCount(seriesCount),
mChartView(new QChartView(this)),
mChart(mChartView->chart())
{
ui->setupUi(this);
init();
if (categoriAxisY) {
mAxisY = categoriAxisY;
mAxisY->setLabelsPosition(QCategoryAxis::AxisLabelsPositionOnValue);
for (int i = 0; i < seriesCount; ++i) {
mChart->setAxisY(mAxisY, mSeriesList.at(i));
}
}
}
void HistoryChart::init()
{
ui->lblHistoryTitle->setText(mTitle);
// add series to chart
for (int i = 0; i < mSeriesCount; i++) {
mSeriesList.append(new QSplineSeries);
mChart->addSeries(mSeriesList.at(i));
}
mChartView->setRenderHint(QPainter::Antialiasing);
QList colors = {
0x2ecc71, 0xe74c3c, 0x3498db, 0xf1c40f, 0xe67e22,
0x1abc9c, 0x9b59b6, 0x34495e, 0xd35400, 0xc0392b,
0x8e44ad, 0xFF8F00, 0xEF6C00, 0x4E342E, 0x424242,
0x5499C7, 0x58D68D, 0xCD6155, 0xF5B041, 0x566573
};
// set colors
for (int i = 0; i < mSeriesList.count(); ++i) {
dynamic_cast(mChart->series().at(i))->setColor(QColor(colors.at(i)));
}
// Chart Settings
mChart->createDefaultAxes();
mChart->axisX()->setRange(0, 60);
mChart->axisX()->setReverse(true);
mChart->setContentsMargins(-11, -11, -11, -11);
mChart->setMargins(QMargins(20, 0, 10, 10));
ui->layoutHistoryChart->addWidget(mChartView, 1, 0, 1, 3);
// theme changed
connect(SignalMapper::ins(), &SignalMapper::sigChangedAppTheme, [=] {
QString chartLabelColor = AppManager::ins()->getStyleValues()->value("@chartLabelColor").toString();
QString chartGridColor = AppManager::ins()->getStyleValues()->value("@chartGridColor").toString();
QString historyChartBackground = AppManager::ins()->getStyleValues()->value("@historyChartBackgroundColor").toString();
mChart->axisX()->setLabelsColor(chartLabelColor);
mChart->axisX()->setGridLineColor(chartGridColor);
mChart->axisY()->setLabelsColor(chartLabelColor);
mChart->axisY()->setGridLineColor(chartGridColor);
mChart->setBackgroundBrush(QColor(historyChartBackground));
mChart->legend()->setLabelColor(chartLabelColor);
});
}
void HistoryChart::setYMax(const int &value)
{
mChart->axisY()->setRange(0, value);
}
QCategoryAxis *HistoryChart::getAxisY()
{
return mAxisY;
}
void HistoryChart::setCategoryAxisYLabels()
{
if (mAxisY) {
for (const QString &label : mAxisY->categoriesLabels()){
mAxisY->remove(label);
}
for (int i = 1; i < 5; ++i) {
mAxisY->append(FormatUtil::formatBytes((mAxisY->max()/4)*i), (mAxisY->max()/4)*i);
}
}
}
QVector HistoryChart::getSeriesList() const
{
return mSeriesList;
}
void HistoryChart::setSeriesList(const QVector &seriesList)
{
for (int i = 0; i < seriesList.count(); ++i) {
mChart->series().replace(0, seriesList.at(i));
}
mChartView->repaint();
}
void HistoryChart::on_checkHistoryTitle_clicked(bool checked)
{
QLayout *charts = topLevelWidget()->findChild("charts")->layout();
for (int i = 0; i < charts->count(); ++i) {
charts->itemAt(i)->widget()->setVisible(! checked);
}
show();
}
================================================
FILE: stacer/Pages/Resources/history_chart.h
================================================
#ifndef HISTORYCHART_H
#define HISTORYCHART_H
#include
#include
#include
#include
#include "Managers/app_manager.h"
#include "Utils/format_util.h"
namespace Ui {
class HistoryChart;
}
class HistoryChart : public QWidget
{
Q_OBJECT
public:
explicit HistoryChart(const QString &title, const int &seriesCount, QCategoryAxis* categoriAxisY = nullptr, QWidget *parent = 0);
~HistoryChart();
QVector getSeriesList() const;
QCategoryAxis *getAxisY();
void setYMax(const int &value);
void setSeriesList(const QVector &seriesList);
void setCategoryAxisYLabels();
private slots:
void on_checkHistoryTitle_clicked(bool checked);
private:
void init();
private:
Ui::HistoryChart *ui;
QString mTitle;
int mSeriesCount;
QChartView *mChartView;
QChart *mChart;
QVector mSeriesList;
QCategoryAxis *mAxisY;
};
#endif // HISTORYCHART_H
================================================
FILE: stacer/Pages/Resources/history_chart.ui
================================================
HistoryChart
0
0
759
275
0
0
0
200
0
0
0
0
10
0
-
PointingHandCursor
Qt::NoFocus
Qt::LeftToRight
-
0
0
Chart Title
-
Qt::Horizontal
40
20
================================================
FILE: stacer/Pages/Resources/resources_page.cpp
================================================
#include "resources_page.h"
#include "ui_resources_page.h"
#include "utilities.h"
ResourcesPage::~ResourcesPage()
{
delete ui;
}
ResourcesPage::ResourcesPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::ResourcesPage),
im(InfoManager::ins()),
mChartCpu(new HistoryChart(tr("History of CPU"), im->getCpuCoreCount(), nullptr, this)),
mChartCpuLoadAvg(new HistoryChart(tr("History of CPU Load Averages"), 3, nullptr, this)),
mChartDiskReadWrite(new HistoryChart(tr("History of Disk Read Write"), 2, new QCategoryAxis, this)),
mChartMemory(new HistoryChart(tr("History of Memory"), 2, nullptr, this)),
mChartNetwork(new HistoryChart(tr("History of Network"), 2, new QCategoryAxis, this)),
mChartDiskPie(new QChart),
mTimer(new QTimer(this))
{
ui->setupUi(this);
init();
}
void ResourcesPage::init()
{
chartColors = {
0x2ecc71, 0xe74c3c, 0x3498db, 0xf1c40f, 0xe67e22,
0x1abc9c, 0x9b59b6, 0x34495e, 0xd35400, 0xc0392b,
0x8e44ad, 0xFF8F00, 0xEF6C00, 0x4E342E, 0x424242,
0x5499C7, 0x58D68D, 0xCD6155, 0xF5B041, 0x566573
};
mChartCpu->setYMax(100);
mChartMemory->setYMax(100);
QList widgets = { mChartCpu, mChartCpuLoadAvg, mChartDiskReadWrite, mChartMemory, mChartNetwork };
for (QWidget *widget : widgets) {
ui->chartsLayout->addWidget(widget);
}
Utilities::addDropShadow(widgets, 40);
connect(mTimer, &QTimer::timeout, this, &ResourcesPage::updateCpuChart);
connect(mTimer, &QTimer::timeout, this, &ResourcesPage::updateCpuLoadAvg);
connect(mTimer, &QTimer::timeout, this, &ResourcesPage::updateDiskReadWrite);
connect(mTimer, &QTimer::timeout, this, &ResourcesPage::updateMemoryChart);
connect(mTimer, &QTimer::timeout, this, &ResourcesPage::updateNetworkChart);
mTimer->start(1000);
initDiskPieChart();
}
void ResourcesPage::diskPieSeriesCustomize()
{
for (int i = 0; i < mDiskPieSeries->count(); ++i) {
QPieSlice *slice = mDiskPieSeries->slices().at(i);
slice->setBrush(QColor((i < chartColors.count() ? chartColors.at(i) : i - chartColors.count())));
slice->setBorderColor(QColor(Qt::lightGray));
connect(slice, &QPieSlice::hovered, this, [=](bool show) {
slice->setExploded(show);
mChartDiskPie->setTitle(QString("%1 (%2) (%3)")
.arg(slice->label())
.arg(FormatUtil::formatBytes(slice->value()))
.arg(QString().sprintf("%1.2f%%", slice->percentage() * 100)));
});
}
}
void ResourcesPage::initDiskPieChart()
{
mDiskPieSeries = new QPieSeries();
for (const Disk *disk : InfoManager::ins()->getDisks()) {
mDiskPieSeries->append(disk->name, disk->size);
}
diskPieSeriesCustomize();
mChartDiskPie->legend()->hide();
mChartDiskPie->setAnimationOptions(QChart::AllAnimations);
mChartDiskPie->addSeries(mDiskPieSeries);
mChartDiskPie->setMinimumHeight(500);
QChartView *mChartViewDiskPie = new QChartView(mChartDiskPie);
mChartViewDiskPie->setRenderHint(QPainter::Antialiasing);
mChartDiskPie->setContentsMargins(-11, -11, -11, -11);
mChartDiskPie->setMargins(QMargins(20, 10, 10, 10));
gridWidgetDiskPie = new QWidget(this);
gridLayoutDiskPie = new QGridLayout(gridWidgetDiskPie);
gridWidgetDiskPie->setLayout(gridLayoutDiskPie);
gridLayoutDiskPie->setContentsMargins(0,0,0,0);
gridLayoutDiskPie->setHorizontalSpacing(10);
gridLayoutDiskPie->setVerticalSpacing(5);
QLabel *lblChartTitle = new QLabel(gridWidgetDiskPie);
lblChartTitle->setObjectName("lblHistoryTitle");
lblChartTitle->setText(tr("File System"));
QCheckBox *checkHistoryTitle = new QCheckBox(gridWidgetDiskPie);
checkHistoryTitle->setObjectName("checkHistoryTitle");
checkHistoryTitle->setCursor(QCursor(Qt::CursorShape::PointingHandCursor));
connect(checkHistoryTitle, &QCheckBox::clicked, this, [=](bool checked) {
QLayout *charts = topLevelWidget()->findChild("charts")->layout();
for (int i = 0; i < charts->count(); ++i) {
charts->itemAt(i)->widget()->setVisible(! checked);
}
gridWidgetDiskPie->show();
});
QComboBox *cmbFileSystemType = new QComboBox(gridWidgetDiskPie);
cmbFileSystemType->addItem(tr("File System Type"), -1);
cmbFileSystemType->addItems(InfoManager::ins()->getFileSystemTypes());
connect(cmbFileSystemType, &QComboBox::currentTextChanged, this, [=](const QString text) {
mChartDiskPie->removeSeries(mDiskPieSeries);
mDiskPieSeries = new QPieSeries();
for (const Disk *disk : InfoManager::ins()->getDisks()) {
if (cmbFileSystemType->currentIndex() != 0 && disk->fileSystemType == text) {
mDiskPieSeries->append(disk->name, disk->size);
} else if(cmbFileSystemType->currentIndex() == 0) {
mDiskPieSeries->append(disk->name, disk->size);
}
}
diskPieSeriesCustomize();
emit SignalMapper::ins()->sigChangedAppTheme();
mChartDiskPie->addSeries(mDiskPieSeries);
});
QComboBox *cmbDevice = new QComboBox(gridWidgetDiskPie);
cmbDevice->addItem(tr("Device"));
cmbDevice->addItems(InfoManager::ins()->getDevices());
connect(cmbDevice, &QComboBox::currentTextChanged, this, [=](const QString text) {
mChartDiskPie->removeSeries(mDiskPieSeries);
mDiskPieSeries = new QPieSeries();
for (const Disk *disk : InfoManager::ins()->getDisks()) {
if (cmbDevice->currentIndex() != 0 && disk->device == text) {
mDiskPieSeries->append(disk->name, disk->size);
} else if(cmbDevice->currentIndex() == 0) {
mDiskPieSeries->append(disk->name, disk->size);
}
}
diskPieSeriesCustomize();
emit SignalMapper::ins()->sigChangedAppTheme();
mChartDiskPie->addSeries(mDiskPieSeries);
});
QSpacerItem *horizontalSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
gridLayoutDiskPie->addWidget(lblChartTitle, 0, 0);
gridLayoutDiskPie->addWidget(checkHistoryTitle, 0, 1);
gridLayoutDiskPie->addItem(horizontalSpacer, 0, 2);
gridLayoutDiskPie->addWidget(cmbDevice, 0, 3);
gridLayoutDiskPie->addWidget(cmbFileSystemType, 0, 4);
gridLayoutDiskPie->addWidget(mChartViewDiskPie, 1, 0, 1, 5);
ui->chartsLayout->addWidget(gridWidgetDiskPie);
// theme changed
connect(SignalMapper::ins(), &SignalMapper::sigChangedAppTheme, [=] {
QString chartLabelColor = AppManager::ins()->getStyleValues()->value("@chartLabelColor").toString();
QString chartGridColor = AppManager::ins()->getStyleValues()->value("@chartGridColor").toString();
QString historyChartBackground = AppManager::ins()->getStyleValues()->value("@historyChartBackgroundColor").toString();
for (int i = 0; i < mDiskPieSeries->count(); ++i) {
mDiskPieSeries->slices().at(i)->setLabelBrush(QColor(chartGridColor));
}
mChartDiskPie->setBackgroundBrush(QColor(historyChartBackground));
mChartDiskPie->legend()->setLabelColor(chartLabelColor);
mChartDiskPie->setTitleBrush(QColor(chartGridColor));
});
}
void ResourcesPage::updateDiskReadWrite()
{
static int second = 0;
QList diskReadWrite = im->getDiskIO();
QVector seriesList = mChartDiskReadWrite->getSeriesList();
for (int j = 0; j < seriesList.count(); ++j) {
for (int i = 0; i < (second < 61 ? second : 61); ++i) {
seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());
}
if(second > 61) seriesList.at(j)->removePoints(61, 1);
}
static quint64 l_readBytes = diskReadWrite.at(0); // last
static quint64 l_writeBytes = diskReadWrite.at(1); // last
static quint64 maxY = (1L << 10) * 100; // 100 KIBI
quint64 readBytes = diskReadWrite.at(0);
quint64 writeBytes = diskReadWrite.at(1);
quint64 d_readByte = (readBytes - l_readBytes);
quint64 d_writeByte = (writeBytes - l_writeBytes);
seriesList.at(0)->insert(0, QPointF(0, d_readByte));
seriesList.at(0)->setName(tr("Read: %1/s Total: %2")
.arg(FormatUtil::formatBytes(d_readByte))
.arg(FormatUtil::formatBytes(readBytes)));
seriesList.at(1)->insert(0, QPointF(0, d_writeByte));
seriesList.at(1)->setName(tr("Write: %1/s Total: %2")
.arg(FormatUtil::formatBytes(d_writeByte))
.arg(FormatUtil::formatBytes(writeBytes)));
maxY = qMax(qMax(maxY, d_readByte), d_writeByte);
l_readBytes = readBytes;
l_writeBytes = writeBytes;
mChartDiskReadWrite->setYMax(maxY);
mChartDiskReadWrite->setSeriesList(seriesList);
mChartDiskReadWrite->setCategoryAxisYLabels();
second++;
}
void ResourcesPage::updateCpuLoadAvg()
{
static int second, maxAvg = im->getCpuCoreCount();
static int minutes[] = {1, 5, 15};
QList cpuLoadAvgs = im->getCpuLoadAvgs();
QVector seriesList = mChartCpuLoadAvg->getSeriesList();
for (int j = 0; j < seriesList.count(); ++j) {
double avg = cpuLoadAvgs.at(j);
for (int i = 0; i < (second < 61 ? second : 61); ++i) {
seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());
}
seriesList.at(j)->insert(0, QPointF(0, avg));
seriesList.at(j)->setName(tr("%1 Minute Average: %2")
.arg(minutes[j])
.arg(avg));
if (second > 61) seriesList.at(j)->removePoints(61, 1);
maxAvg = qMax((int)ceil(avg), maxAvg);
}
mChartCpuLoadAvg->setYMax(maxAvg);
mChartCpuLoadAvg->setSeriesList(seriesList);
second++;
}
void ResourcesPage::updateNetworkChart()
{
static int second = 0;
QVector seriesList = mChartNetwork->getSeriesList();
// points swap
for (int j = 0; j < seriesList.count(); j++) {
for (int i = 0; i < (second < 61 ? second : 61); i++)
seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());
if(second > 61) seriesList.at(j)->removePoints(61, 1);
}
quint64 RXbytes = im->getRXbytes();
quint64 TXbytes = im->getTXbytes();
static quint64 l_RXbytes = RXbytes;
static quint64 l_TXbytes = TXbytes;
static quint64 max_RXbytes = 1L << 20; // 1 MEBI
static quint64 max_TXbytes = 1L << 20; // 1 MEBI
quint64 d_RXbytes = (RXbytes - l_RXbytes);
quint64 d_TXbytes = (TXbytes - l_TXbytes);
QString downText = FormatUtil::formatBytes(d_RXbytes);
QString upText = FormatUtil::formatBytes(d_TXbytes);
// Download
seriesList.at(0)->insert(0, QPointF(0, d_RXbytes));
seriesList.at(0)->setName(tr("Download: %1/s Total: %2")
.arg(downText)
.arg(FormatUtil::formatBytes(RXbytes)));
seriesList.at(1)->insert(0, QPointF(0, d_TXbytes));
seriesList.at(1)->setName(tr("Upload: %1/s Total: %2")
.arg(upText)
.arg(FormatUtil::formatBytes(TXbytes)));
max_RXbytes = qMax(max_RXbytes, d_RXbytes);
max_TXbytes = qMax(max_TXbytes, d_TXbytes);
int max = qMax(max_RXbytes, max_TXbytes);
l_RXbytes = RXbytes;
l_TXbytes = TXbytes;
mChartNetwork->setYMax(max);
mChartNetwork->setSeriesList(seriesList);
mChartNetwork->setCategoryAxisYLabels();
second++;
}
void ResourcesPage::updateMemoryChart()
{
static int second = 0;
QVector seriesList = mChartMemory->getSeriesList();
im->updateMemoryInfo();
// points swap
for (int j = 0; j < seriesList.count(); j++) {
for (int i = 0; i < (second < 61 ? second : 61); i++)
seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());
if(second > 61)
seriesList.at(j)->removePoints(61, 1);
}
// Swap
double percent = 0;
if (im->getSwapTotal()) // arithmetic exception control
percent = ((double) im->getSwapUsed() / (double) im->getSwapTotal()) * 100.0;
seriesList.at(0)->insert(0, QPointF(0, percent));
seriesList.at(0)->setName(tr("Swap: %1 (%2%) %3")
.arg(FormatUtil::formatBytes(im->getSwapUsed()))
.arg(QString().sprintf("%.1f",percent))
.arg(FormatUtil::formatBytes(im->getSwapTotal())));
// Memory
double percent2 = ((double) im->getMemUsed() / (double) im->getMemTotal()) * 100.0;
seriesList.at(1)->insert(0, QPointF(0, percent2));
seriesList.at(1)->setName(tr("Memory: %1 (%2%) %3")
.arg(FormatUtil::formatBytes(im->getMemUsed()))
.arg(QString().sprintf("%.1f",percent2))
.arg(FormatUtil::formatBytes(im->getMemTotal())));
mChartMemory->setSeriesList(seriesList);
second++;
}
void ResourcesPage::updateCpuChart()
{
static int second = 0;
QList cpuPercents = im->getCpuPercents();
QVector seriesList = mChartCpu->getSeriesList();
for (int j = 0; j < seriesList.count(); j++){
int p = cpuPercents.at(j+1);
for (int i = 0; i < (second < 61 ? second : 61); i++)
seriesList.at(j)->replace(i, (i+1), seriesList.at(j)->at(i).y());
seriesList.at(j)->insert(0, QPointF(0, p));
seriesList.at(j)->setName(QString("CPU%1: %2%").arg(j+1).arg(p));
if(second > 61) seriesList.at(j)->removePoints(61, 1);
}
mChartCpu->setSeriesList(seriesList);
second++;
}
================================================
FILE: stacer/Pages/Resources/resources_page.h
================================================
#ifndef RESOURCESPAGE_H
#define RESOURCESPAGE_H
#include
#include
#include "history_chart.h"
#include "Managers/info_manager.h"
#include
#include
namespace Ui {
class ResourcesPage;
}
class ResourcesPage : public QWidget
{
Q_OBJECT
public:
explicit ResourcesPage(QWidget *parent = 0);
~ResourcesPage();
private slots:
void updateCpuChart();
void updateCpuLoadAvg();
void updateDiskReadWrite();
void updateMemoryChart();
void updateNetworkChart();
void initDiskPieChart();
void diskPieSeriesCustomize();
private:
void init();
private:
Ui::ResourcesPage *ui;
InfoManager *im;
HistoryChart *mChartCpu;
HistoryChart *mChartCpuLoadAvg;
HistoryChart *mChartDiskReadWrite;
HistoryChart *mChartMemory;
HistoryChart *mChartNetwork;
QChartView *mChartViewDiskPie;
QChart *mChartDiskPie;
QWidget *gridWidgetDiskPie;
QGridLayout *gridLayoutDiskPie;
QPieSeries *mDiskPieSeries;
QList chartColors;
QTimer *mTimer;
};
#endif // RESOURCESPAGE_H
================================================
FILE: stacer/Pages/Resources/resources_page.ui
================================================
ResourcesPage
0
0
890
537
Resources
0
10
0
10
10
-
true
0
0
868
525
0
0
10
10
5
10
5
================================================
FILE: stacer/Pages/Search/search_page.cpp
================================================
#include "search_page.h"
#include "ui_search_page.h"
#include
#include
SearchPage::SearchPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::SearchPage),
mItemModel(new QStandardItemModel(this)),
mSortFilterModel(new QSortFilterProxyModel(this))
{
ui->setupUi(this);
init();
}
SearchPage::~SearchPage()
{
delete ui;
}
void SearchPage::init()
{
mTableHeaders = QStringList {
tr("Name"), tr("Path"), tr("Size"), tr("User"), tr("Group"),
tr("Creation Time"), tr("Last Access"), tr("Last Modification"), tr("Last Change"),
};
// Table settings
mItemModel->setHorizontalHeaderLabels(mTableHeaders);
mSortFilterModel->setSourceModel(mItemModel);
ui->tableFoundResults->setModel(mSortFilterModel);
mSortFilterModel->setSortRole(1);
mSortFilterModel->setDynamicSortFilter(true);
mSortFilterModel->sort(1, Qt::SortOrder::DescendingOrder);
ui->tableFoundResults->horizontalHeader()->setSectionsMovable(true);
ui->tableFoundResults->horizontalHeader()->setFixedHeight(32);
ui->tableFoundResults->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
ui->tableFoundResults->horizontalHeader()->setCursor(Qt::PointingHandCursor);
ui->tableFoundResults->horizontalHeader()->resizeSection(0, 150);
ui->tableFoundResults->horizontalHeader()->resizeSection(1, 150);
ui->tableFoundResults->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
ui->tableFoundResults->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->tableFoundResults->horizontalHeader(), &QHeaderView::customContextMenuRequested,
this, &SearchPage::tableFoundResults_header_customContextMenuRequested);
loadHeaderMenu();
loadTableRowMenu();
rowRole = 1;
mSearchResultDateFormat = "dd.MM.yyyy hh:mm:ss";
ui->advanceSearchPane->setHidden(false);
on_btnAdvancePaneToggle_clicked();
ui->lblErrorMsg->hide();
QString iconLoading = QString(":/static/themes/%1/img/loading.gif").arg(SettingManager::ins()->getThemeName());
QMovie *loadingMovie = new QMovie(iconLoading, QByteArray(), this);
ui->lblLoadingSearching->setMovie(loadingMovie);
loadingMovie->start();
ui->lblLoadingSearching->hide();
initComboboxValues();
QList widgets = {
ui->btnBrowseSearchDir, ui->btnSearchAdvance, ui->txtSearchInput, ui->cmbGroups,
ui->cmbSizeCriteria, ui->cmbSizeUnits, ui->cmbTimeCriteria, ui->cmbTimeType,
ui->cmbSearchTypes, ui->tableFoundResults, ui->cmbUsers
};
Utilities::addDropShadow(widgets, 30);
}
void SearchPage::loadTableRowMenu()
{
QAction *actionOpenFolder = new QAction(QIcon(":/static/themes/common/img/folder.png"), tr("Open Folder"));
actionOpenFolder->setData("open-folder");
mTableRowMenu.addAction(actionOpenFolder);
QAction *actionMoveTrash = new QAction(QIcon(":/static/themes/common/img/trash_2.png"), tr("Move Trash"));
actionMoveTrash->setData("move-trash");
mTableRowMenu.addAction(actionMoveTrash);
QAction *actionDelete = new QAction(QIcon(":/static/themes/common/img/delete.png"), tr("Delete"));
actionDelete->setData("delete");
mTableRowMenu.addAction(actionDelete);
}
void SearchPage::loadHeaderMenu()
{
int i = 0;
QList actionList;
actionList.reserve(mTableHeaders.size());
for (const QString &header : mTableHeaders) {
QAction *action = new QAction(header,&mHeaderMenu);
action->setCheckable(true);
action->setChecked(true);
action->setData(i++);
actionList.push_back(action);
}
mHeaderMenu.addActions(actionList);
// exclude headers
QList hiddenHeaders = { 4, 6, 7, 8 };
QList actions = mHeaderMenu.actions();
for (const int i : hiddenHeaders) {
if (i < mTableHeaders.count()) {
ui->tableFoundResults->horizontalHeader()->setSectionHidden(i, true);
actions.at(i)->setChecked(false);
}
}
}
void SearchPage::initComboboxValues()
{
ui->cmbUsers->addItem(tr("Choose"), "-1");
ui->cmbUsers->addItems(InfoManager::ins()->getUserList());
ui->cmbGroups->addItem(tr("Choose"), "-1");
ui->cmbGroups->addItems(InfoManager::ins()->getGroupList());
ui->cmbSearchTypes->addItem(tr("All"), "all");
ui->cmbSearchTypes->addItem(tr("File"), "f");
ui->cmbSearchTypes->addItem(tr("Directory"), "d");
ui->cmbSearchTypes->addItem(tr("Symbolic Link"), "l");
ui->cmbTimeType->addItem(tr("Choose"), "-1");
ui->cmbTimeType->addItem(tr("Access"), "-amin");
ui->cmbTimeType->addItem(tr("Modify"), "-mmin");
ui->cmbTimeType->addItem(tr("Change"), "-cmin");
ui->cmbTimeCriteria->addItem(tr("Smaller (<)"), "-");
ui->cmbTimeCriteria->addItem(tr("Equal (=)"), "");
ui->cmbTimeCriteria->addItem(tr("Greater (>)"), "+");
ui->cmbSizeCriteria->addItem(tr("Choose"), "-1");
ui->cmbSizeCriteria->addItem(tr("Smaller (<)"), "-");
ui->cmbSizeCriteria->addItem(tr("Equal (=)"), "");
ui->cmbSizeCriteria->addItem(tr("Greater (>)"), "+");
ui->cmbSizeUnits->addItem("Bytes", "c");
ui->cmbSizeUnits->addItem("Kibibytes", "k");
ui->cmbSizeUnits->addItem("Mebibytes", "M");
ui->cmbSizeUnits->addItem("Gibibytes", "G");
}
void SearchPage::on_btnBrowseSearchDir_clicked()
{
QString selectedDirPath = QFileDialog::getExistingDirectory(this, tr("Select Directory"), "/",
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
QDir selectedDir(selectedDirPath);
if (! selectedDirPath.isEmpty() && selectedDir.exists()) {
ui->lblSearchDir->setText(tr("Directory: %1").arg(selectedDirPath));
mSelectedDirectory = selectedDirPath;
}
}
void SearchPage::on_btnAdvancePaneToggle_clicked()
{
ui->advanceSearchPane->setHidden(! ui->advanceSearchPane->isHidden());
QString icon = ui->advanceSearchPane->isHidden() ? "▼" : "▲";
ui->btnAdvancePaneToggle->setText(tr("Advanced Search %1").arg(icon));
}
void SearchPage::on_btnSearchAdvance_clicked()
{
QtConcurrent::run(this, &SearchPage::searching);
ui->advanceSearchPane->hide();
}
void SearchPage::searching()
{
if (mSelectedDirectory.isEmpty()) {
ui->lblErrorMsg->show();
ui->lblErrorMsg->setText(tr("Select the search directory."));
} else {
ui->lblErrorMsg->hide();
ui->lblLoadingSearching->show();
ui->btnSearchAdvance->setEnabled(false);
QStringList findQuery(mSelectedDirectory);
if (! ui->txtSearchInput->text().isEmpty()) {
if (ui->checkCaseInsensitive->isChecked()) {
if (ui->checkRegEx->isChecked()) {
findQuery.append("-iregex");
} else {
findQuery.append("-iname");
}
} else {
if (ui->checkRegEx->isChecked()) {
findQuery.append("-regex");
} else {
findQuery.append("-name");
}
}
findQuery.append(QString("%1").arg(ui->txtSearchInput->text()));
}
if (ui->checkInvert->isChecked()) {
findQuery.append("-invert");
}
if (ui->checkEmpty->isChecked()) {
findQuery.append("-empty");
}
if (ui->cmbSearchTypes->currentData().toString() != "all") {
findQuery.append("-type");
findQuery.append(ui->cmbSearchTypes->currentData().toString());
}
// TIME
if (ui->cmbTimeType->currentData().toString() != "-1") {
findQuery.append(ui->cmbTimeType->currentData().toString());
findQuery.append(QString("%1%2").arg(ui->cmbTimeCriteria->currentData().toString()).arg(ui->spinTime->value()));
}
// PERMISSIONS
if (ui->checkPermReadable->isChecked()) {
findQuery.append("-readable");
}
if (ui->checkPermWritable->isChecked()) {
findQuery.append("-writable");
}
if (ui->checkPermExecutable->isChecked()) {
findQuery.append("-executable");
}
// SIZE
if (ui->cmbSizeCriteria->currentData().toString() != "-1") {
QString size = QString("%1%2%3")
.arg(ui->cmbSizeCriteria->currentData().toString())
.arg(ui->spinSize->value())
.arg(ui->cmbSizeUnits->currentData().toString());
findQuery.append("-size");
findQuery.append(size);
}
// OWNER
if (ui->cmbUsers->currentData().toString() != "-1") {
findQuery.append("-user");
findQuery.append(ui->cmbUsers->currentText());
}
if (ui->cmbGroups->currentData().toString() != "-1") {
findQuery.append("-group");
findQuery.append(ui->cmbGroups->currentText());
}
// searching
QString result;
try {
if (ui->checkSearchAsRoot->isChecked()) {
result = CommandUtil::sudoExec("find", findQuery);
} else {
result = CommandUtil::exec("find", findQuery);
}
if (result.trimmed().isEmpty()) {
mItemModel->removeRows(0, mItemModel->rowCount()); // clear table
} else {
loadDataToTable(result.split("\n"));
}
} catch (QString ex) {
ui->lblErrorMsg->show();
ui->lblErrorMsg->setText(tr("Somethings went wrong, try again."));
}
ui->lblLoadingSearching->hide();
ui->btnSearchAdvance->setEnabled(true);
}
}
void SearchPage::loadDataToTable(const QList &foundFiles)
{
mItemModel->removeRows(0, mItemModel->rowCount());
for (const QString &file : foundFiles.mid(1, 2000)) {
mItemModel->appendRow(createRow(file));
}
ui->lblFoundFilesInfo->setText(tr("%1 files found. Showing %2 of them.")
.arg(foundFiles.count()-1)
.arg(mItemModel->rowCount()));
}
QList SearchPage::createRow(const QString &filepath)
{
QFileInfo *fileInfo = new QFileInfo(filepath);
QStandardItem *i_name = new QStandardItem(fileInfo->fileName());
i_name->setData(fileInfo->fileName(), rowRole);
i_name->setData(fileInfo->fileName(), Qt::ToolTipRole);
QStandardItem *i_path = new QStandardItem(fileInfo->path());
i_path->setData(fileInfo->path(), rowRole);
i_path->setData(fileInfo->path(), Qt::ToolTipRole);
QStandardItem *i_size = new QStandardItem(FormatUtil::formatBytes(fileInfo->size()));
i_size->setData(fileInfo->size(), rowRole);
i_size->setData(fileInfo->size(), Qt::ToolTipRole);
QStandardItem *i_user = new QStandardItem(fileInfo->owner());
i_user->setData(fileInfo->owner(), rowRole);
i_user->setData(fileInfo->owner(), Qt::ToolTipRole);
QStandardItem *i_group = new QStandardItem(fileInfo->group());
i_group->setData(fileInfo->group(), rowRole);
i_group->setData(fileInfo->group(), Qt::ToolTipRole);
QStandardItem *i_creationTime = new QStandardItem(fileInfo->created().toString(mSearchResultDateFormat));
i_creationTime->setData(fileInfo->created().toString(mSearchResultDateFormat), rowRole);
i_creationTime->setData(fileInfo->created().toString(mSearchResultDateFormat), Qt::ToolTipRole);
QStandardItem *i_lastAccess = new QStandardItem(fileInfo->lastRead().toString(mSearchResultDateFormat));
i_lastAccess->setData(fileInfo->lastRead().toString(mSearchResultDateFormat), rowRole);
i_lastAccess->setData(fileInfo->lastRead().toString(mSearchResultDateFormat), Qt::ToolTipRole);
QStandardItem *i_lastModify = new QStandardItem(fileInfo->lastModified().toString(mSearchResultDateFormat));
i_lastModify->setData(fileInfo->lastModified().toString(mSearchResultDateFormat), rowRole);
i_lastModify->setData(fileInfo->lastModified().toString(mSearchResultDateFormat), Qt::ToolTipRole);
QStandardItem *i_lastChange = new QStandardItem(fileInfo->metadataChangeTime().toString(mSearchResultDateFormat));
i_lastChange->setData(fileInfo->metadataChangeTime().toString(mSearchResultDateFormat), rowRole);
i_lastChange->setData(fileInfo->metadataChangeTime().toString(mSearchResultDateFormat), Qt::ToolTipRole);
delete fileInfo;
return {
i_name, i_path, i_size, i_user, i_group,
i_creationTime, i_lastAccess, i_lastModify, i_lastChange
};
}
void SearchPage::tableFoundResults_header_customContextMenuRequested(const QPoint &pos)
{
QPoint globalPos = ui->tableFoundResults->mapToGlobal(pos);
QAction *action = mHeaderMenu.exec(globalPos);
if (action) {
ui->tableFoundResults->horizontalHeader()->setSectionHidden(action->data().toInt(), ! action->isChecked());
}
}
void SearchPage::on_tableFoundResults_customContextMenuRequested(const QPoint &pos)
{
if (mItemModel->rowCount() > 0) {
QPoint globalPos = ui->tableFoundResults->mapToGlobal(pos);
QAction *action = mTableRowMenu.exec(globalPos);
QModelIndexList selecteds = ui->tableFoundResults->selectionModel()->selectedRows();
QItemSelectionModel *selectionModel = ui->tableFoundResults->selectionModel();
if (action && ! selecteds.isEmpty()) {
if (action->data().toString() == "open-folder") {
for (QModelIndex &index : selecteds) {
QUrl folderPath = mSortFilterModel->index(index.row(), 1).data(rowRole).toUrl();
QDesktopServices::openUrl(folderPath);
}
}
else if (action->data().toString() == "move-trash") {
QString trashPath(QDir::homePath() + "/.local/share/Trash");
while (! selectionModel->selectedRows().isEmpty()) {
QModelIndex index = selectionModel->selectedRows().first();
QString fileName = mSortFilterModel->index(index.row(), 0).data(rowRole).toString();
QString folderPath = mSortFilterModel->index(index.row(), 1).data(rowRole).toString();
QString filePath = folderPath + "/" + fileName;
bool isAnotherUser = QFileInfo(filePath).owner() != InfoManager::ins()->getUserName();
if (isAnotherUser) {
CommandUtil::sudoExec("mv", {filePath, trashPath + "/files"});
} else {
CommandUtil::exec("mv", {filePath, trashPath + "/files"});
}
if (QFile(filePath).exists()) {
selectionModel->select(index, QItemSelectionModel::Deselect);
} else {
QString infoContent = QString("[Trash Info]\n"
"Path=%1\n"
"DeletionDate=%2")
.arg(filePath)
.arg(QDateTime::currentDateTime().toString("yyyy-MM-ddThh:mm:ss"));
FileUtil::writeFile(trashPath + "/info/" + fileName + ".trashinfo", infoContent);
mSortFilterModel->removeRow(index.row());
}
}
selectionModel->clearSelection();
}
else if (action->data().toString() == "delete") {
while (! selectionModel->selectedRows().isEmpty()) {
QModelIndex index = selectionModel->selectedRows().first();
QString fileName = mSortFilterModel->index(index.row(), 0).data(rowRole).toString();
QString folderPath = mSortFilterModel->index(index.row(), 1).data(rowRole).toString();
QString filePath = folderPath + "/" + fileName;
bool isAnotherUser = QFileInfo(filePath).owner() != InfoManager::ins()->getUserName();
if (isAnotherUser) {
CommandUtil::sudoExec("rm", {"-rf", filePath });
} else {
CommandUtil::exec("rm", {"-rf", filePath });
}
if (QFile(filePath).exists()) {
selectionModel->select(index, QItemSelectionModel::Deselect);
} else {
mSortFilterModel->removeRow(index.row());
}
}
selectionModel->clearSelection();
}
}
}
}
void SearchPage::on_tableFoundResults_doubleClicked(const QModelIndex &index)
{
QUrl folderPath = mSortFilterModel->index(index.row(), 1).data(rowRole).toUrl();
QDesktopServices::openUrl(folderPath);
}
================================================
FILE: stacer/Pages/Search/search_page.h
================================================
#ifndef SEARCH_PAGE_H
#define SEARCH_PAGE_H
#include
#include
#include "Managers/info_manager.h"
#include "utilities.h"
#include
#include
#include
#include
#include
#include "Utils/format_util.h"
#include "Managers/setting_manager.h"
#include
#include
#include
namespace Ui {
class SearchPage;
}
class SearchPage : public QWidget
{
Q_OBJECT
public:
explicit SearchPage(QWidget *parent = 0);
~SearchPage();
private slots:
void init();
void on_btnBrowseSearchDir_clicked();
void on_btnAdvancePaneToggle_clicked();
void on_btnSearchAdvance_clicked();
void initComboboxValues();
void on_tableFoundResults_customContextMenuRequested(const QPoint &pos);
void tableFoundResults_header_customContextMenuRequested(const QPoint &pos);
void loadTableRowMenu();
void loadHeaderMenu();
void loadDataToTable(const QList &results);
void searching();
QList createRow(const QString &filepath);
void on_tableFoundResults_doubleClicked(const QModelIndex &index);
private:
Ui::SearchPage *ui;
QString mSelectedDirectory;
QStringList mTableHeaders;
QStandardItemModel *mItemModel;
QSortFilterProxyModel *mSortFilterModel;
QMenu mHeaderMenu;
QMenu mTableRowMenu;
QString mSearchResultDateFormat;
int rowRole;
};
#endif // SEARCH_PAGE_H
================================================
FILE: stacer/Pages/Search/search_page.ui
================================================
SearchPage
0
0
764
596
Search
15
15
15
15
10
-
Qt::NoFocus
QFrame::NoFrame
QFrame::Sunken
QAbstractScrollArea::AdjustToContents
QAbstractItemView::NoEditTriggers
QAbstractItemView::ExtendedSelection
QAbstractItemView::SelectRows
Qt::ElideMiddle
Qt::SolidLine
true
true
true
false
true
false
-
10
0
-
PointingHandCursor
Qt::NoFocus
Browse...
-
10
Search...
-
0
30
16777215
25
false
-
PointingHandCursor
Qt::NoFocus
primary
:/static/themes/default/img/sidebar-icons/search.png:/static/themes/default/img/sidebar-icons/search.png
24
24
-
Qt::AlignCenter
-
-
0
5
0
2
12
-
PointingHandCursor
Qt::NoFocus
circle
Case Insensitive
-
Qt::Horizontal
40
20
-
10
0
4
-
0
28
16777215
28
false
-
0
28
16777215
28
false
-
100
28
50
16777215
true
QAbstractSpinBox::NoButtons
minute
9999999
-
10
-
0
28
16777215
28
false
-
0
28
16777215
28
false
-
PointingHandCursor
Qt::NoFocus
circle
Search as Root
-
Owner
-
Qt::Horizontal
40
20
-
PointingHandCursor
Qt::NoFocus
circle
RegEx
-
10
0
-
0
28
16777215
28
false
-
15
28
68
16777215
QAbstractSpinBox::NoButtons
9999999
-
0
28
16777215
28
false
-
Permissions
-
Size
-
5
4
-
PointingHandCursor
Qt::NoFocus
circle
Readable
-
PointingHandCursor
Qt::NoFocus
circle
Writable
-
PointingHandCursor
Qt::NoFocus
circle
Executable
-
Time
-
Qt::Horizontal
40
20
-
PointingHandCursor
Qt::NoFocus
circle
Empty
-
File or Folder:
-
PointingHandCursor
Qt::NoFocus
circle
Invert
-
10
0
-
0
Qt::PlainText
true
false
-
PointingHandCursor
Advanced Search
false
false
-
0
Qt::PlainText
true
false
-
color: rgb(252, 175, 62);
0
BETA version
Qt::PlainText
true
false
================================================
FILE: stacer/Pages/Services/service_item.cpp
================================================
#include "service_item.h"
#include "ui_service_item.h"
#include "utilities.h"
ServiceItem::~ServiceItem()
{
delete ui;
}
ServiceItem::ServiceItem(const QString &name,
const QString description,
const bool status,
const bool active,
QWidget *parent) :
QWidget(parent),
ui(new Ui::ServiceItem),
tm(ToolManager::ins())
{
ui->setupUi(this);
ui->lblServiceName->setText(name);
ui->lblServiceDescription->setText("- " + description);
ui->checkServiceRunning->setChecked(active);
ui->checkServiceStartup->setChecked(status);
ui->lblServiceName->setToolTip(name);
ui->lblServiceDescription->setToolTip(description);
Utilities::addDropShadow(this, 30, 10);
}
void ServiceItem::on_checkServiceStartup_clicked(bool status)
{
QString name = ui->lblServiceName->text();
tm->changeServiceStatus(name, status);
ui->checkServiceStartup->setChecked(tm->serviceIsEnabled(name));
}
void ServiceItem::on_checkServiceRunning_clicked(bool status)
{
QString name = ui->lblServiceName->text();
tm->changeServiceActive(name, status);
ui->checkServiceRunning->setChecked(tm->serviceIsActive(name));
}
================================================
FILE: stacer/Pages/Services/service_item.h
================================================
#ifndef SERVICE_ITEM_H
#define SERVICE_ITEM_H
#include
#include
#include "Managers/tool_manager.h"
namespace Ui {
class ServiceItem;
}
class ServiceItem : public QWidget
{
Q_OBJECT
public:
explicit ServiceItem(const QString &name, const QString description, const bool status, const bool active, QWidget *parent = 0);
~ServiceItem();
private slots:
void on_checkServiceRunning_clicked(bool status);
void on_checkServiceStartup_clicked(bool status);
private:
Ui::ServiceItem *ui;
private:
ToolManager *tm;
};
#endif // SERVICE_ITEM_H
================================================
FILE: stacer/Pages/Services/service_item.ui
================================================
ServiceItem
0
0
713
45
0
0
0
45
16777215
45
0
0
0
0
0
-
0
45
16777215
45
15
10
10
0
-
25
25
25
25
true
-
Service Name
-
Qt::Horizontal
QSizePolicy::Fixed
20
0
-
Qt::Horizontal
0
20
-
PointingHandCursor
Qt::NoFocus
-
PointingHandCursor
Qt::NoFocus
-
Description
================================================
FILE: stacer/Pages/Services/services_page.cpp
================================================
#include "services_page.h"
#include "ui_services_page.h"
#include "service_item.h"
#include "utilities.h"
#include
ServicesPage::~ServicesPage()
{
delete ui;
}
ServicesPage::ServicesPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::ServicesPage)
{
ui->setupUi(this);
init();
}
void ServicesPage::init()
{
connect(this, &ServicesPage::loadServicesS, this, &ServicesPage::loadServices);
QtConcurrent::run(this, &ServicesPage::getServices);
ui->cmbRunningStatus->addItems({ tr("Running Status"), tr("Running"), tr("Not Running") });
ui->cmbStartupStatus->addItems({ tr("Startup Status"), tr("Enabled"), tr("Disabled") });
Utilities::addDropShadow(ui->cmbRunningStatus, 30);
Utilities::addDropShadow(ui->cmbStartupStatus, 30);
}
void ServicesPage::getServices()
{
this->mServices = ToolManager::ins()->getServices();
emit loadServicesS();
}
void ServicesPage::loadServices()
{
ui->listWidgetServices->clear();
int runningIndex = ui->cmbRunningStatus->currentIndex();
int startupIndex = ui->cmbStartupStatus->currentIndex();
bool runningStatus = runningIndex == 1;
bool startupStatus = startupIndex == 1;
for (const Service s : mServices) {
bool runningFilter = runningIndex != 0 ? s.active == runningStatus : true;
bool startupFilter = startupIndex != 0 ? s.status == startupStatus : true;
if (runningFilter && startupFilter) {
ServiceItem *service = new ServiceItem(s.name, s.description, s.status, s.active);
QListWidgetItem *item = new QListWidgetItem(ui->listWidgetServices);
item->setSizeHint(service->sizeHint());
ui->listWidgetServices->setItemWidget(item, service);
}
}
setServiceCount();
bool isListEmpty = ui->listWidgetServices->count() == 0;
ui->listWidgetServices->setVisible(! isListEmpty);
ui->notFoundWidget->setVisible(isListEmpty);
}
void ServicesPage::setServiceCount()
{
ui->lblServicesTitle->setText(tr("System Services (%1)")
.arg(ui->listWidgetServices->count()));
}
void ServicesPage::on_cmbRunningStatus_currentIndexChanged(int index)
{
Q_UNUSED(index);
loadServices();
}
void ServicesPage::on_cmbStartupStatus_currentIndexChanged(int index)
{
Q_UNUSED(index);
loadServices();
}
================================================
FILE: stacer/Pages/Services/services_page.h
================================================
#ifndef SERVICESPAGE_H
#define SERVICESPAGE_H
#include
#include "Managers/tool_manager.h"
namespace Ui {
class ServicesPage;
}
class ServicesPage : public QWidget
{
Q_OBJECT
public:
explicit ServicesPage(QWidget *parent = 0);
~ServicesPage();
signals:
void loadServicesS();
private slots:
void init();
void getServices();
void loadServices();
void on_cmbRunningStatus_currentIndexChanged(int index);
void on_cmbStartupStatus_currentIndexChanged(int index);
public slots:
void setServiceCount();
private:
Ui::ServicesPage *ui;
QList mServices;
};
#endif // SERVICESPAGE_H
================================================
FILE: stacer/Pages/Services/services_page.ui
================================================
ServicesPage
0
0
882
549
Services
30
0
30
25
0
-
20
15
5
45
5
-
Ubuntu
11
System Services
-
120
0
QComboBox::AdjustToMinimumContentsLength
false
-
120
0
QComboBox::AdjustToMinimumContentsLength
false
-
Qt::Horizontal
40
20
-
0
0
20
20
80
16777215
Ubuntu
10
Startup at boot ?
-
Qt::Horizontal
QSizePolicy::Fixed
40
20
-
0
0
20
20
100
16777215
Ubuntu
10
Running Now ?
-
0
0
0
200
16777215
9999999
0
0
0
0
0
-
Not Found System Service
-
Qt::NoFocus
QFrame::NoFrame
Qt::ScrollBarAlwaysOff
QAbstractItemView::NoEditTriggers
QAbstractItemView::NoSelection
QAbstractItemView::SelectRows
QListView::Adjust
QListView::Batched
4
true
================================================
FILE: stacer/Pages/Settings/settings_page.cpp
================================================
#include "settings_page.h"
#include "ui_settings_page.h"
#include "Managers/info_manager.h"
#include "utilities.h"
#include
#include
SettingsPage::~SettingsPage()
{
delete ui;
}
SettingsPage::SettingsPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::SettingsPage),
apm(AppManager::ins()),
mSettingManager(SettingManager::ins())
{
ui->setupUi(this);
init();
}
void SettingsPage::init()
{
// load languages
QMapIterator lang(apm->getLanguageList());
while (lang.hasNext()) {
lang.next();
ui->cmbLanguages->addItem(lang.value(), lang.key());
}
QString lc = mSettingManager->getLanguage();
ui->cmbLanguages->setCurrentText(apm->getLanguageList().value(lc));
// load themes
// QMapIterator theme(apm->getThemeList());
// while (theme.hasNext()) {
// theme.next();
// ui->cmbThemes->addItem(theme.value(), theme.key());
// }
// QString tn = mSettingManager->getThemeName();
// ui->cmbThemes->setCurrentText(apm->getThemeList().value(tn));
// load disks
InfoManager::ins()->updateDiskInfo();
QList disks = InfoManager::ins()->getDisks();
for (const Disk *disk : disks) {
ui->cmbDisks->addItem(QString("%1 (%2)").arg(disk->device).arg(disk->name), disk->name);
}
QString dk = mSettingManager->getDiskName().isEmpty() ? QStorageInfo::root().displayName() : mSettingManager->getDiskName();
if (! dk.isEmpty()) {
ui->cmbDisks->setCurrentIndex(ui->cmbDisks->findData(dk));
}
// start on boot
mStartupAppPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation).append("/autostart");
if (! QDir(mStartupAppPath).exists()) {
QDir().mkdir(mStartupAppPath);
}
mStartupAppPath.append("/stacer.desktop");
QFile startupAppFile(mStartupAppPath);
if (startupAppFile.exists()) {
QStringList appContent = FileUtil::readListFromFile(mStartupAppPath);
QString isHidden = Utilities::getDesktopValue(QRegExp("^Hidden=.*"), appContent).toLower();
ui->checkAutostart->setChecked(isHidden == "false");
} else {
ui->checkAutostart->setChecked(false);
}
// app quit dont ask
ui->checkAppQuitDontAsk->setChecked(mSettingManager->getAppQuitDialogDontAsk());
// load pages
ui->cmbStartPage->addItems({
tr("Dashboard"), tr("Startup Apps"), tr("System Cleaner"), tr("Search"),
tr("Services"), tr("Processes"), tr("Helpers"), tr("Uninstaller"), tr("Resources")
});
ui->cmbStartPage->setCurrentText(mSettingManager->getStartPage());
// load resource percents
ui->spinCpuPercent->setValue(mSettingManager->getCpuAlertPercent());
ui->spinMemoryPercent->setValue(mSettingManager->getMemoryAlertPercent());
ui->spinDiskPercent->setValue(mSettingManager->getDiskAlertPercent());
// effects
QList widgets = {
ui->cmbLanguages, /*ui->cmbThemes,*/ ui->cmbDisks, ui->cmbStartPage, ui->btnDonate,
ui->spinCpuPercent, ui->spinMemoryPercent, ui->spinDiskPercent
};
Utilities::addDropShadow(widgets, 50);
// connects
connect(ui->cmbLanguages, SIGNAL(currentIndexChanged(int)), this, SLOT(cmbLanguagesChanged(int)));
// connect(ui->cmbThemes, SIGNAL(currentIndexChanged(int)), this, SLOT(cmbThemesChanged(int)));
connect(ui->cmbDisks, SIGNAL(currentIndexChanged(int)), this, SLOT(cmbDiskChanged(int)));
connect(ui->cmbStartPage, SIGNAL(currentIndexChanged(QString)), this, SLOT(cmbStartPageChanged(QString)));
}
void SettingsPage::cmbLanguagesChanged(const int &index)
{
QString langCode = ui->cmbLanguages->itemData(index).toString();
mSettingManager->setLanguage(langCode);
}
//void SettingsPage::cmbThemesChanged(const int &index)
//{
// QString themeName = ui->cmbThemes->itemData(index).toString();
// mSettingManager->setThemeName(themeName);
// apm->updateStylesheet();
//}
void SettingsPage::cmbDiskChanged(const int &index)
{
QString diskName = ui->cmbDisks->itemData(index).toString();
mSettingManager->setDiskName(diskName);
}
void SettingsPage::on_checkAutostart_clicked(bool checked)
{
if (checked) {
QString appTemplate = QString("[Desktop Entry]\n"
"Name=Stacer\n"
"Comment=Linux System Optimizer and Monitoring\n"
"Exec=stacer --hide \n"
"Type=Application\n"
"Terminal=false\n"
"Hidden=false\n");
FileUtil::writeFile(mStartupAppPath, appTemplate);
} else {
QFile::remove(mStartupAppPath);
}
}
void SettingsPage::on_btnDonate_clicked()
{
QDesktopServices::openUrl(QUrl("https://www.patreon.com/oguzhaninan"));
}
void SettingsPage::cmbStartPageChanged(const QString text)
{
mSettingManager->setStartPage(text);
}
void SettingsPage::on_spinCpuPercent_valueChanged(int value)
{
mSettingManager->setCpuAlertPercent(value);
}
void SettingsPage::on_spinMemoryPercent_valueChanged(int value)
{
mSettingManager->setMemoryAlertPercent(value);
}
void SettingsPage::on_spinDiskPercent_valueChanged(int value)
{
mSettingManager->setDiskAlertPercent(value);
}
void SettingsPage::on_checkAppQuitDontAsk_clicked(bool checked)
{
mSettingManager->setAppQuitDialogDontAsk(checked);
}
================================================
FILE: stacer/Pages/Settings/settings_page.h
================================================
#ifndef SETTINGS_PAGE_H
#define SETTINGS_PAGE_H
#include
#include
#include "Managers/app_manager.h"
#include "Managers/setting_manager.h"
#include "signal_mapper.h"
namespace Ui {
class SettingsPage;
}
class SettingsPage : public QWidget
{
Q_OBJECT
public:
explicit SettingsPage(QWidget *parent = 0);
~SettingsPage();
private slots:
void init();
// void cmbThemesChanged(const int &index);
void cmbLanguagesChanged(const int &index);
void cmbDiskChanged(const int &index);
void on_checkAutostart_clicked(bool checked);
void on_btnDonate_clicked();
void cmbStartPageChanged(const QString text);
void on_spinCpuPercent_valueChanged(int value);
void on_spinMemoryPercent_valueChanged(int value);
void on_spinDiskPercent_valueChanged(int value);
void on_checkAppQuitDontAsk_clicked(bool checked);
private:
Ui::SettingsPage *ui;
private:
AppManager *apm;
QString mStartupAppPath;
SettingManager *mSettingManager;
};
#endif // SETTINGS_PAGE_H
================================================
FILE: stacer/Pages/Settings/settings_page.ui
================================================
SettingsPage
0
0
811
479
0
0
Settings
15
15
15
15
20
10
-
0
0
150
0
200
16777215
PointingHandCursor
Qt::NoFocus
QComboBox::AdjustToMinimumContentsLength
-
PointingHandCursor
Qt::NoFocus
-
0
0
Memory Percent
-
Qt::ClickFocus
false
%
0
100
-
0
0
Disk Percent
-
Qt::ClickFocus
%
0
100
-
0
0
Language
-
0
0
Autostart Stacer
-
Qt::Vertical
10
40
-
Qt::ClickFocus
%
0
100
-
0
0
CPU Percent
-
0
0
title
Alert messages (Show a warning after the specified percentage)
-
<html><head/><body><p>Stacer v1.1.0 <a href="https://github.com/oguzhaninan"><span style=" text-decoration: underline; color:#007af4;">Oğuzhan İNAN</span></a></p></body></html>
Qt::RichText
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
true
-
0
0
PointingHandCursor
Qt::NoFocus
primary
Donate
:/static/themes/common/img/donate.png:/static/themes/common/img/donate.png
18
18
-
Qt::Horizontal
0
20
-
Qt::Vertical
QSizePolicy::Fixed
20
10
-
Qt::Vertical
QSizePolicy::Fixed
20
10
-
App Quit Don't Ask
-
PointingHandCursor
Qt::NoFocus
-
0
0
150
0
200
16777215
PointingHandCursor
Qt::NoFocus
QComboBox::AdjustToMinimumContentsLength
-
0
0
Disks
-
0
0
Start Page
-
0
0
150
0
200
16777215
PointingHandCursor
Qt::NoFocus
QComboBox::AdjustToMinimumContentsLength
spinCpuPercent
spinMemoryPercent
spinDiskPercent
================================================
FILE: stacer/Pages/StartupApps/startup_app.cpp
================================================
#include "startup_app.h"
#include "ui_startup_app.h"
#include "utilities.h"
StartupApp::~StartupApp()
{
delete ui;
}
StartupApp::StartupApp(const QString &startupAppName, bool enabled, const QString &filePath, QWidget *parent) :
QWidget(parent),
ui(new Ui::StartupApp),
mStartupAppName(startupAppName),
mEnabled(enabled),
mFilePath(filePath)
{
ui->setupUi(this);
ui->lblStartupAppName->setText(startupAppName);
ui->checkStartup->setChecked(enabled);
Utilities::addDropShadow(this, 50);
}
void StartupApp::on_checkStartup_clicked(bool status)
{
QStringList lines = FileUtil::readListFromFile(mFilePath);
// Hidden=[true|false]
int pos = lines.indexOf(HIDDEN_REG);
QString _status = status ? "true" : "false";
if (pos != -1) {
_status = status ? "false" : "true";
lines.replace(pos, QString("Hidden=%1").arg(_status));
} else {
// X-GNOME-Autostart-enabled=[true|false]
pos = lines.indexOf(GNOME_ENABLED_REG);
if (pos != -1) {
lines.replace(pos, QString("X-GNOME-Autostart-enabled=%1").arg(_status));
}
}
if (pos == -1) {
_status = status ? "false" : "true";
lines.append(QString("Hidden=%1").arg(_status));
}
FileUtil::writeFile(mFilePath, lines.join('\n').append('\n'));
}
void StartupApp::on_btnDeleteStartupApp_clicked()
{
if (QFile::remove(mFilePath)) {
emit deleteAppS();
}
}
void StartupApp::on_btnEditStartupApp_clicked()
{
emit editStartupAppS(mFilePath);
}
QString StartupApp::getAppName() const
{
return mStartupAppName;
}
void StartupApp::setAppName(const QString &value)
{
mStartupAppName = value;
}
bool StartupApp::getEnabled() const
{
return mEnabled;
}
void StartupApp::setEnabled(bool value)
{
mEnabled = value;
}
QString StartupApp::getFilePath() const
{
return mFilePath;
}
void StartupApp::setFilePath(const QString &value)
{
mFilePath = value;
}
================================================
FILE: stacer/Pages/StartupApps/startup_app.h
================================================
#ifndef STARTUP_APP_H
#define STARTUP_APP_H
#include
#include
#include
#include
#include "startup_app_edit.h"
namespace Ui {
class StartupApp;
}
class StartupApp : public QWidget
{
Q_OBJECT
public:
explicit StartupApp(const QString &startupAppName, bool enabled, const QString &filePath, QWidget *parent = 0);
~StartupApp();
QString getAppName() const;
void setAppName(const QString &value);
bool getEnabled() const;
void setEnabled(bool value);
QString getFilePath() const;
void setFilePath(const QString &value);
private slots:
void on_checkStartup_clicked(bool);
void on_btnDeleteStartupApp_clicked();
void on_btnEditStartupApp_clicked();
signals:
void deleteAppS();
void editStartupAppS(const QString filePath);
private:
Ui::StartupApp *ui;
private:
QString mStartupAppName;
QString mAppComment;
bool mEnabled;
QString mFilePath;
};
#endif // STARTUP_APP_H
================================================
FILE: stacer/Pages/StartupApps/startup_app.ui
================================================
StartupApp
0
0
661
45
0
0
0
45
16777215
45
0
0
0
0
0
-
0
0
ArrowCursor
15
15
10
10
10
-
22
24
22
24
true
-
App Name
-
Qt::Horizontal
0
0
-
PointingHandCursor
Qt::NoFocus
Edit App
18
20
-
PointingHandCursor
Qt::NoFocus
Delete App
22
22
-
PointingHandCursor
Qt::NoFocus
45
23
================================================
FILE: stacer/Pages/StartupApps/startup_app_edit.cpp
================================================
#include "startup_app_edit.h"
#include "ui_startup_app_edit.h"
#include "utilities.h"
#include
#include
StartupAppEdit::~StartupAppEdit()
{
delete ui;
}
QString StartupAppEdit::selectedFilePath = "";
StartupAppEdit::StartupAppEdit(QWidget *parent) :
QDialog(parent),
ui(new Ui::StartupAppEdit),
mNewAppTemplate("[Desktop Entry]\n"
"Name=%1\n"
"Comment=%2\n"
"Exec=%3\n"
"Type=Application\n"
"Terminal=false\n"
"Hidden=false\n")
{
ui->setupUi(this);
init();
}
void StartupAppEdit::init()
{
setGeometry(
QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter,
size(), qApp->desktop()->availableGeometry())
);
mAutostartPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/autostart";
ui->lblErrorMsg->hide();
setStyleSheet(AppManager::ins()->getStylesheetFileContent());
}
void StartupAppEdit::show()
{
// clear fields
ui->txtStartupAppName->clear();
ui->txtStartupAppComment->clear();
ui->txtStartupAppCommand->clear();
ui->lblErrorMsg->hide();
if(! selectedFilePath.isEmpty())
{
QStringList lines = FileUtil::readListFromFile(selectedFilePath);
if(! lines.isEmpty())
{
ui->txtStartupAppName->setText(Utilities::getDesktopValue(NAME_REG, lines));
ui->txtStartupAppComment->setText(Utilities::getDesktopValue(COMMENT_REG, lines));
ui->txtStartupAppCommand->setText(Utilities::getDesktopValue(EXEC_REG, lines));
}
}
QDialog::show();
}
void StartupAppEdit::changeDesktopValue(QStringList &lines, const QRegExp ®, const QString &text)
{
int pos = lines.indexOf(reg);
if (pos != -1) {
lines.replace(pos, text);
} else {
lines.append(text);
}
}
void StartupAppEdit::on_btnSave_clicked()
{
if(isValid()) {
if(! selectedFilePath.isEmpty()) {
QStringList lines = FileUtil::readListFromFile(selectedFilePath);
changeDesktopValue(lines, NAME_REG, QString("Name=%1").arg(ui->txtStartupAppName->text()));
changeDesktopValue(lines, COMMENT_REG, QString("Comment=%1").arg(ui->txtStartupAppComment->text()));
changeDesktopValue(lines, EXEC_REG, QString("Exec=%1").arg(ui->txtStartupAppCommand->text()));
FileUtil::writeFile(selectedFilePath, lines.join("\n"), QIODevice::ReadWrite | QIODevice::Truncate);
}
else {
// new file content
QString appContent = mNewAppTemplate
.arg(ui->txtStartupAppName->text())
.arg(ui->txtStartupAppComment->text())
.arg(ui->txtStartupAppCommand->text());
// file name
QString appFileName = ui->txtStartupAppName->text()
.simplified()
.replace(' ', '-')
.toLower();
qDebug() << appFileName;
QString path = QString("%1/%2.desktop").arg(mAutostartPath).arg(appFileName);
FileUtil::writeFile(path, appContent);
}
emit startupAppAdded(); // signal
close();
}
else {
ui->lblErrorMsg->show();
}
selectedFilePath = "";
}
bool StartupAppEdit::isValid()
{
return ! ui->txtStartupAppName->text().isEmpty() &&
! ui->txtStartupAppComment->text().isEmpty() &&
! ui->txtStartupAppCommand->text().isEmpty();
}
================================================
FILE: stacer/Pages/StartupApps/startup_app_edit.h
================================================
#ifndef STARTUP_APP_EDIT_H
#define STARTUP_APP_EDIT_H
#include
#include
#include "Managers/app_manager.h"
#define NAME_REG QRegExp("^Name=.*")
#define COMMENT_REG QRegExp("^Comment=.*")
#define EXEC_REG QRegExp("^Exec=.*")
#define GNOME_ENABLED_REG QRegExp("^X-GNOME-Autostart-enabled=.*")
#define HIDDEN_REG QRegExp("^Hidden=.*")
namespace Ui {
class StartupAppEdit;
}
class StartupAppEdit : public QDialog
{
Q_OBJECT
public:
explicit StartupAppEdit(QWidget *parent = 0);
~StartupAppEdit();
public:
static QString selectedFilePath;
signals:
void startupAppAdded();
public slots:
void show();
private slots:
void init();
bool isValid();
void on_btnSave_clicked();
void changeDesktopValue(QStringList &lines, const QRegExp ®, const QString &text);
private:
Ui::StartupAppEdit *ui;
private:
QString mNewAppTemplate;
QString mAutostartPath;
};
#endif // STARTUP_APP_EDIT_H
================================================
FILE: stacer/Pages/StartupApps/startup_app_edit.ui
================================================
StartupAppEdit
0
0
380
227
380
0
Startup App
true
30
20
30
15
15
-
Fields cannot be left blank.
-
App Name
-
App Comment
-
PointingHandCursor
Qt::NoFocus
primary
Save
true
-
dialog-title
Application
Qt::AlignCenter
-
Command
-
Qt::Vertical
20
40
txtStartupAppName
txtStartupAppComment
txtStartupAppCommand
btnSave
================================================
FILE: stacer/Pages/StartupApps/startup_apps_page.cpp
================================================
#include "startup_apps_page.h"
#include "ui_startup_apps_page.h"
#include "utilities.h"
StartupAppsPage::~StartupAppsPage()
{
delete ui;
}
StartupAppsPage::StartupAppsPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::StartupAppsPage),
mFileSystemWatcher(this)
{
ui->setupUi(this);
init();
}
bool StartupAppsPage::checkIfDisabled(const QString& as_path)
{
const QString disabled_str("X-GNOME-Autostart-enabled=false");
QFile autostart_file(as_path);
autostart_file.open(QIODevice::ReadOnly | QIODevice::Text);
return autostart_file.readAll().indexOf(disabled_str, 0) != -1;
}
void StartupAppsPage::init()
{
mAutostartPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation).append("/autostart");
QFileInfo asfi(mAutostartPath);
bool startups_disabled = false;
/* original behavior, autostart is a dir and not...
* * a pre-exisiting file as is case on my machine.
*/
if (asfi.isDir() == true) {
mAutostartPath.append("/");
}
else {
/* altered behavior for if a file is at this location instead
* * check for disabled string
* * * if found, don't add watcher
*/
startups_disabled = checkIfDisabled(mAutostartPath);
}
if (!startups_disabled) {
if (! QDir(mAutostartPath).exists()) {
QDir().mkdir(mAutostartPath);
}
mFileSystemWatcher.addPath(mAutostartPath);
loadApps();
connect(&mFileSystemWatcher, &QFileSystemWatcher::directoryChanged, this, &StartupAppsPage::loadApps);
}
else {
ui->lblNotFound->setText(tr("Startup Apps are disabled."));
ui->btnAddStartupApp->setEnabled(false);
}
connect(ui->btnAddStartupApp, SIGNAL(clicked()), this, SLOT(openStartupAppEdit()));
Utilities::addDropShadow(ui->btnAddStartupApp, 60);
}
void StartupAppsPage::loadApps()
{
// clear
ui->listWidgetStartup->clear();
QDir autostartFiles(mAutostartPath, "*.desktop");
QLatin1String enabledStr("true");
for (const QFileInfo &f : autostartFiles.entryInfoList())
{
QStringList lines = FileUtil::readListFromFile(f.absoluteFilePath());
QString appName = Utilities::getDesktopValue(NAME_REG, lines); // get name
if(! appName.isEmpty()) // has a name
{
bool enabled = false;
// Hidden=[true|false]
QString hidden = Utilities::getDesktopValue(HIDDEN_REG, lines).toLower();
// X-GNOME-Autostart-enabled=[true|false]
QString gnomeEnabled = Utilities::getDesktopValue(GNOME_ENABLED_REG, lines).toLower();
if (! hidden.isEmpty()) {
enabled = (hidden != enabledStr);
} else {
enabled = (gnomeEnabled == enabledStr);
}
QListWidgetItem *item = new QListWidgetItem(ui->listWidgetStartup);
// new app
StartupApp *app = new StartupApp(appName, enabled, f.absoluteFilePath(), this);
connect(app, &StartupApp::deleteAppS, this, &StartupAppsPage::loadApps);
connect(app, &StartupApp::editStartupAppS, this, &StartupAppsPage::openStartupAppEdit);
item->setSizeHint(app->sizeHint());
ui->listWidgetStartup->setItemWidget(item, app);
}
}
setAppCount();
}
void StartupAppsPage::setAppCount()
{
int count = ui->listWidgetStartup->count();
ui->lblStartupAppsTitle->setText(
tr("Startup Applications (%1)")
.arg(QString::number(count)));
ui->notFoundWidget->setVisible(! count);
ui->listWidgetStartup->setVisible(count);
}
void StartupAppsPage::openStartupAppEdit(const QString filePath)
{
StartupAppEdit::selectedFilePath = filePath;
if (mStartupAppEdit.isNull()) {
mStartupAppEdit = QSharedPointer(new StartupAppEdit(this));
connect(mStartupAppEdit.data(), &StartupAppEdit::startupAppAdded, this, &StartupAppsPage::loadApps);
}
mStartupAppEdit->show();
}
================================================
FILE: stacer/Pages/StartupApps/startup_apps_page.h
================================================
#ifndef STARTUPAPPSPAGE_H
#define STARTUPAPPSPAGE_H
#include
#include
#include
#include
#include
#include "startup_app.h"
#include "startup_app_edit.h"
#include "Utils/file_util.h"
namespace Ui {
class StartupAppsPage;
}
class StartupAppsPage : public QWidget
{
Q_OBJECT
public:
explicit StartupAppsPage(QWidget *parent = 0);
~StartupAppsPage();
public slots:
void loadApps();
private slots:
void init();
void openStartupAppEdit(const QString filePath = QString());
void setAppCount();
private:
Ui::StartupAppsPage *ui;
private:
QSharedPointer mStartupAppEdit;
QFileSystemWatcher mFileSystemWatcher;
QString mAutostartPath;
bool checkIfDisabled(const QString& as_path);
};
#endif // STARTUPAPPSPAGE_H
================================================
FILE: stacer/Pages/StartupApps/startup_apps_page.ui
================================================
StartupAppsPage
0
0
892
591
Startup Apps
0
0
0
0
0
-
0
0
ArrowCursor
60
10
60
20
5
-
Qt::Horizontal
40
20
-
0
0
Ubuntu
PointingHandCursor
Qt::NoFocus
primary
Add Startup App
-
Ubuntu
11
false
System Startup Applications
-
Qt::Vertical
QSizePolicy::Fixed
20
10
-
0
0
0
0
0
-
0
0
0
200
16777215
200
0
0
0
0
0
-
Not Found Startup Apps
-
Qt::NoFocus
QFrame::NoFrame
Qt::ScrollBarAlwaysOff
QAbstractItemView::EditKeyPressed
QAbstractItemView::NoSelection
QAbstractItemView::SelectRows
QListView::Adjust
QListView::Batched
5
true
================================================
FILE: stacer/Pages/SystemCleaner/byte_tree_widget.cpp
================================================
#include "byte_tree_widget.h"
void ByteTreeWidget::setValues(const QString &text, const quint64 &size, const QVariant &data) {
this->setText(0, text);
this->setText(1, FormatUtil::formatBytes(size));
this->setData(1, 0x0100, size);
this->setData(2, 0, data);
this->setCheckState(0, Qt::Unchecked);
}
bool ByteTreeWidget::operator<(const QTreeWidgetItem &other) const
{
int column = treeWidget()->sortColumn();
// sort by bytes
if(column == 1) {
return this->data(1, 0x0100) < other.data(1, 0x0100);
}
// default sorting
return text(column).toLower() < other.text(column).toLower();
}
================================================
FILE: stacer/Pages/SystemCleaner/byte_tree_widget.h
================================================
#ifndef BYTE_TREE_WIDGET_H
#define BYTE_TREE_WIDGET_H
#include
#include
#include
class ByteTreeWidget : public QTreeWidgetItem
{
public:
ByteTreeWidget(QTreeWidget* parent) : QTreeWidgetItem(parent) {}
ByteTreeWidget(QTreeWidgetItem* parent) : QTreeWidgetItem(parent) {}
void setValues(const QString &text, const quint64 &size, const QVariant &data);
virtual bool operator<(const QTreeWidgetItem &other) const;
};
#endif // BYTE_TREE_WIDGET_H
================================================
FILE: stacer/Pages/SystemCleaner/system_cleaner_page.cpp
================================================
#include "system_cleaner_page.h"
#include "ui_system_cleaner_page.h"
#include "byte_tree_widget.h"
SystemCleanerPage::~SystemCleanerPage()
{
delete ui;
}
SystemCleanerPage::SystemCleanerPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::SystemCleanerPage),
im(InfoManager::ins()),
tmr(ToolManager::ins()),
mDefaultIcon(QIcon::fromTheme("application-x-executable")),
mLoadingMovie(nullptr),
mLoadingMovie_2(nullptr)
{
ui->setupUi(this);
init();
ui->stackedWidget->setCurrentIndex(0);
}
void SystemCleanerPage::init()
{
// treview settings
ui->treeWidgetScanResult->setColumnCount(2);
ui->treeWidgetScanResult->setColumnWidth(0, 600);
ui->treeWidgetScanResult->header()->setFixedHeight(30);
ui->treeWidgetScanResult->setHeaderLabels({ tr("File Name"), tr("Size") });
// loaders
connect(SignalMapper::ins(), &SignalMapper::sigChangedAppTheme, [=] {
QString themeName = SettingManager::ins()->getThemeName();
mLoadingMovie = new QMovie(QString(":/static/themes/%1/img/scanLoading.gif").arg(themeName),{},this);
ui->lblLoadingScanner->setMovie(mLoadingMovie);
mLoadingMovie->start();
ui->lblLoadingScanner->hide();
mLoadingMovie_2 = new QMovie(QString(":/static/themes/%1/img/loading.gif").arg(themeName),{},this);
ui->lblLoadingCleaner->setMovie(mLoadingMovie_2);
mLoadingMovie_2->start();
ui->lblLoadingCleaner->hide();
});
// needed to suppress qt warnings (signal/slot <> threads)
qRegisterMetaType>();
qRegisterMetaType();
qRegisterMetaType();
}
quint64 SystemCleanerPage::addTreeRoot(const CleanCategories &cat, const QString &title, const QFileInfoList &infos, bool noChild)
{
QTreeWidgetItem *root = new QTreeWidgetItem(ui->treeWidgetScanResult);
root->setData(2, 0, cat);
root->setData(2, 1, title);
if (! infos.isEmpty())
root->setData(3, 0, infos.at(0).absoluteDir().path());
root->setCheckState(0, Qt::Unchecked);
// add children
quint64 totalSize = 0;
if(! noChild) {
for (const QFileInfo &i : infos) {
QString path = i.absoluteFilePath();
quint64 size = FileUtil::getFileSize(path);
addTreeChild(path, i.fileName(), size, root);
totalSize += size;
}
root->setText(0, QString("%1 (%2)")
.arg(title)
.arg(infos.count()));
} else {
if (! infos.isEmpty())
totalSize += FileUtil::getFileSize(infos.first().absoluteFilePath());
root->setText(0, QString("%1")
.arg(title));
}
root->setText(1, QString("%1").arg(FormatUtil::formatBytes(totalSize)));
return totalSize;
}
void SystemCleanerPage::addTreeChild(const QString &data, const QString &text, const quint64 &size, QTreeWidgetItem *parent)
{
ByteTreeWidget *item = new ByteTreeWidget(parent);
item->setValues(text, size, data);
item->setIcon(0, QIcon::fromTheme(text, mDefaultIcon));
}
void SystemCleanerPage::addTreeChild(const CleanCategories &cat, const QString &text, const quint64 &size)
{
ByteTreeWidget *item = new ByteTreeWidget(ui->treeWidgetScanResult);
item->setValues(text, size, cat);
}
void SystemCleanerPage::on_treeWidgetScanResult_itemClicked(QTreeWidgetItem *item, const int &column)
{
if(column == 0) {
// new check state
Qt::CheckState cs = (item->checkState(column) == Qt::Checked ? Qt::Checked : Qt::Unchecked);
// update check state
//item->setCheckState(column, cs);
// change check state if has children
for (int i = 0; i < item->childCount(); ++i)
item->child(i)->setCheckState(column, cs);
}
}
void SystemCleanerPage::systemScan()
{
if (ui->checkPackageCache->isChecked() ||
ui->checkCrashReports->isChecked() ||
ui->checkAppLog->isChecked() ||
ui->checkAppCache->isChecked() ||
ui->checkTrash->isChecked()
){
ui->btnScan->hide();
ui->lblLoadingScanner->show();
ui->checkPackageCache->setEnabled(false);
ui->checkCrashReports->setEnabled(false);
ui->checkAppLog->setEnabled(false);
ui->checkAppCache->setEnabled(false);
ui->checkTrash->setEnabled(false);
ui->checkSelectAllSystemScan->setEnabled(false);
ui->treeWidgetScanResult->setSortingEnabled(false);
ui->treeWidgetScanResult->clear();
quint64 totalSize = 0;
// Package Caches
if (ui->checkPackageCache->isChecked()) {
totalSize += addTreeRoot(PACKAGE_CACHE,
ui->lblPackageCache->text(),
tmr->getPackageCaches());
}
// Crash Reports
if (ui->checkCrashReports->isChecked()) {
totalSize += addTreeRoot(CRASH_REPORTS,
ui->lblCrashReports->text(),
im->getCrashReports());
}
// Application Logs
if (ui->checkAppLog->isChecked()) {
totalSize += addTreeRoot(APPLICATION_LOGS,
ui->lblAppLog->text(),
im->getAppLogs());
}
// Application Cache
if (ui->checkAppCache->isChecked()) {
totalSize += addTreeRoot(APPLICATION_CACHES,
ui->lblAppCache->text(),
im->getAppCaches());
}
// Trash
if(ui->checkTrash->isChecked()) {
totalSize += addTreeRoot(TRASH,
ui->lblTrash->text(),
{ QFileInfo(QDir::homePath() + "/.local/share/Trash/") },
true);
}
ui->lblTotalBytes->setText(tr("Total size: %1").arg(FormatUtil::formatBytes(totalSize)));
ui->treeWidgetScanResult->setSortingEnabled(true);
on_cbSortBy_currentIndexChanged(ui->cbSortBy->currentIndex());
// scan results page
ui->stackedWidget->setCurrentIndex(1);
ui->checkPackageCache->setChecked(false);
ui->checkCrashReports->setChecked(false);
ui->checkAppLog->setChecked(false);
ui->checkAppCache->setChecked(false);
ui->checkTrash->setChecked(false);
}
}
bool SystemCleanerPage::cleanValid()
{
for (int i = 0; i < ui->treeWidgetScanResult->topLevelItemCount(); ++i) {
QTreeWidgetItem *it = ui->treeWidgetScanResult->topLevelItem(i);
if (it->checkState(0) == Qt::Checked)
return true;
for (int j = 0; j < it->childCount(); ++j)
if (it->child(j)->checkState(0) == Qt::Checked)
return true;
}
return false;
}
void SystemCleanerPage::systemClean()
{
if (cleanValid()) {
ui->btnClean->hide();
ui->lblLoadingCleaner->show();
ui->treeWidgetScanResult->setEnabled(false);
quint64 totalCleanedSize = 0;
QTreeWidget *tree = ui->treeWidgetScanResult;
QStringList filesToDelete;
QList children;
for (int i = 0; i < tree->topLevelItemCount(); ++i) {
QTreeWidgetItem *it = tree->topLevelItem(i);
CleanCategories cat = (CleanCategories) it->data(2, 0).toInt();
// Package Caches | Crash Reports | Application Logs | Application Caches
if (cat != CleanCategories::TRASH) {
for (int j = 0; j < it->childCount(); ++j) { // files
if(it->child(j)->checkState(0) == Qt::Checked) { // if checked
QString filePath = it->child(j)->data(2, 0).toString();
filesToDelete << filePath;
children.append(it->child(j));
}
}
}
// Trash
else if (cat == CleanCategories::TRASH) {
if (it->checkState(0) == Qt::Checked) {
QString trashPath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation).append("/.local/share/Trash");
QDir(trashPath + "/files").removeRecursively();
QDir(trashPath + "/info").removeRecursively();
}
}
}
// get removed files total size
for (const QString &file : filesToDelete) {
totalCleanedSize += FileUtil::getFileSize(file);
}
// remove selected files
if(! filesToDelete.isEmpty()) {
CommandUtil::sudoExec("rm", QStringList() << "-rf" << filesToDelete);
}
for (int i = 0; i < tree->topLevelItemCount(); ++i) {
// clear removed childs
for (QTreeWidgetItem *item : children) {
tree->topLevelItem(i)->removeChild(item);
}
}
// update titles
for (int i = 0; i < tree->topLevelItemCount(); ++i) {
QTreeWidgetItem *it = tree->topLevelItem(i);
it->setText(0, QString("%1 (%2)")
.arg(it->data(2, 1).toString())
.arg(it->childCount()));
it->setText(1, QString("%1")
.arg(FormatUtil::formatBytes(FileUtil::getFileSize(it->data(3, 0).toString()))));
}
ui->lblRemovedTotalSize->setText(tr("%1 size files cleaned.")
.arg(FormatUtil::formatBytes(totalCleanedSize)));
ui->btnClean->show();
ui->lblLoadingCleaner->hide();
ui->treeWidgetScanResult->setEnabled(true);
}
}
void SystemCleanerPage::on_btnScan_clicked()
{
QtConcurrent::run(this, &SystemCleanerPage::systemScan);
}
void SystemCleanerPage::on_btnClean_clicked()
{
QtConcurrent::run(this, &SystemCleanerPage::systemClean);
}
void SystemCleanerPage::on_btnBackToCategories_clicked()
{
ui->btnScan->show();
ui->lblRemovedTotalSize->clear();
ui->lblLoadingScanner->hide();
ui->checkPackageCache->setEnabled(true);
ui->checkCrashReports->setEnabled(true);
ui->checkAppLog->setEnabled(true);
ui->checkAppCache->setEnabled(true);
ui->checkTrash->setEnabled(true);
ui->treeWidgetScanResult->clear();
ui->stackedWidget->setCurrentIndex(0);
ui->checkSelectAllSystemScan->setEnabled(true);
ui->checkSelectAllSystemScan->setChecked(false);
}
void SystemCleanerPage::on_checkSelectAllSystemScan_clicked(bool checked)
{
ui->checkAppCache->setChecked(checked);
ui->checkAppLog->setChecked(checked);
ui->checkCrashReports->setChecked(checked);
ui->checkPackageCache->setChecked(checked);
ui->checkTrash->setChecked(checked);
}
void SystemCleanerPage::on_checkSelectAll_clicked(bool checked)
{
for (int i = 0; i < ui->treeWidgetScanResult->topLevelItemCount(); ++i)
{
QTreeWidgetItem *it = ui->treeWidgetScanResult->topLevelItem(i);
it->setCheckState(0, (checked ? Qt::Checked : Qt::Unchecked));
for (int j = 0; j < it->childCount(); ++j)
it->child(j)->setCheckState(0, (checked ? Qt::Checked : Qt::Unchecked));
}
}
void SystemCleanerPage::on_cbSortBy_currentIndexChanged(int idx)
{
switch (idx) {
case 0: ui->treeWidgetScanResult->sortItems(0, Qt::AscendingOrder); break;
case 1: ui->treeWidgetScanResult->sortItems(0, Qt::DescendingOrder); break;
case 2: ui->treeWidgetScanResult->sortItems(1, Qt::AscendingOrder); break;
case 3: ui->treeWidgetScanResult->sortItems(1, Qt::DescendingOrder); break;
}
}
================================================
FILE: stacer/Pages/SystemCleaner/system_cleaner_page.h
================================================
#ifndef SYSTEMCLEANERPAGE_H
#define SYSTEMCLEANERPAGE_H
#include
#include
#include
#include
#include
#include
#include
#include
#include "Managers/app_manager.h"
#include
#include
namespace Ui {
class SystemCleanerPage;
}
class SystemCleanerPage : public QWidget
{
Q_OBJECT
public:
enum CleanCategories {
PACKAGE_CACHE,
CRASH_REPORTS,
APPLICATION_LOGS,
APPLICATION_CACHES,
TRASH
};
public:
explicit SystemCleanerPage(QWidget *parent = nullptr);
~SystemCleanerPage();
private slots:
quint64 addTreeRoot(const CleanCategories &cat, const QString &title, const QFileInfoList &infos, bool noChild = false);
void addTreeChild(const CleanCategories &cat, const QString &text, const quint64 &size);
void addTreeChild(const QString &data, const QString &text, const quint64 &size, QTreeWidgetItem *parent);
void on_treeWidgetScanResult_itemClicked(QTreeWidgetItem *item, const int &column);
void on_btnClean_clicked();
void on_btnScan_clicked();
void on_btnBackToCategories_clicked();
void systemScan();
void systemClean();
bool cleanValid();
void on_checkSelectAllSystemScan_clicked(bool checked);
void on_checkSelectAll_clicked(bool check);
void on_cbSortBy_currentIndexChanged(int idx);
private:
void init();
private:
Ui::SystemCleanerPage *ui;
InfoManager *im;
ToolManager *tmr;
QIcon mDefaultIcon;
QMovie *mLoadingMovie;
QMovie *mLoadingMovie_2;
};
#endif // SYSTEMCLEANERPAGE_H
================================================
FILE: stacer/Pages/SystemCleaner/system_cleaner_page.ui
================================================
SystemCleanerPage
0
0
1025
736
System Cleaner
0
15
0
15
15
-
1
0
0
0
0
40
20
-
Crash Reports
Qt::AlignCenter
true
-
90
90
90
90
:/static/themes/default/img/c_crash.png
false
Qt::AlignCenter
-
0
0
PointingHandCursor
Qt::NoFocus
circle
-
Qt::Vertical
20
0
-
Qt::Horizontal
40
20
-
90
90
90
90
:/static/themes/default/img/c_cache.png
Qt::AlignCenter
-
Application Logs
Qt::AlignCenter
true
-
90
90
90
90
:/static/themes/default/img/c_trash.png
Qt::AlignCenter
-
Application Caches
Qt::AlignCenter
true
-
90
90
90
90
Qt::AutoText
:/static/themes/default/img/c_package.png
false
Qt::AlignCenter
-
0
0
PointingHandCursor
Qt::NoFocus
circle
-
0
0
PointingHandCursor
Qt::NoFocus
circle
-
100
100
PointingHandCursor
Qt::NoFocus
100
100
-
Qt::Vertical
QSizePolicy::Fixed
20
30
-
0
0
PointingHandCursor
Qt::NoFocus
circle
-
Trash
Qt::AlignCenter
true
-
90
90
90
90
:/static/themes/default/img/c_logs.png
Qt::AlignCenter
-
Package Caches
Qt::AlignCenter
true
-
0
0
PointingHandCursor
Qt::NoFocus
circle
-
Qt::Horizontal
40
20
-
Qt::Vertical
20
100
-
100
100
-
0
0
PointingHandCursor
Qt::NoFocus
circle
Select All
30
30
0
0
5
0
0
-
0
0
0
0
0
10
-
20
0
-
100
20
16777215
20
circle
-
0
0
100
100
100
100
PointingHandCursor
Qt::NoFocus
-
16777215
16777215
10
PointingHandCursor
Qt::NoFocus
circle
Select All
-
PointingHandCursor
Qt::NoFocus
Back
:/static/themes/default/img/back.png:/static/themes/default/img/back.png
20
20
-
Qt::Horizontal
40
20
-
0
0
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
Qt::Horizontal
40
20
-
PreferAntialias
ArrowCursor
Qt::NoFocus
QAbstractItemView::NoEditTriggers
QAbstractItemView::NoSelection
Qt::ElideMiddle
QAbstractItemView::ScrollPerItem
true
true
true
true
1
-
-
Sort by:
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
-
3
-
Name
:/static/themes/default/img/asc.png:/static/themes/default/img/asc.png
-
Name
:/static/themes/default/img/dsc.png:/static/themes/default/img/dsc.png
-
Size
:/static/themes/default/img/asc.png:/static/themes/default/img/asc.png
-
Size
:/static/themes/default/img/dsc.png:/static/themes/default/img/dsc.png
================================================
FILE: stacer/Pages/Uninstaller/uninstaller_page.cpp
================================================
#include "uninstaller_page.h"
#include "ui_uninstallerpage.h"
#include
#include "utilities.h"
UninstallerPage::~UninstallerPage()
{
delete ui;
}
UninstallerPage::UninstallerPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::UninstallerPage),
tm(ToolManager::ins())
{
ui->setupUi(this);
init();
}
void UninstallerPage::init()
{
QString iconLoading = QString(":/static/themes/%1/img/loading.gif").arg(SettingManager::ins()->getThemeName());
QMovie *loadingMovie = new QMovie(iconLoading, QByteArray(), this);
ui->lblLoadingUninstaller->setMovie(loadingMovie);
loadingMovie->start();
ui->lblLoadingUninstaller->hide();
ui->stackedWidget->setCurrentIndex(0);
QList widgets = { ui->txtPackageSearch, ui->btnUninstall, ui->btnSystemPackages, ui->btnSnapPackages };
Utilities::addDropShadow(widgets, 40);
QtConcurrent::run(this, &UninstallerPage::loadPackages);
QtConcurrent::run(this, &UninstallerPage::loadSnapPackages);
connect(SignalMapper::ins(), &SignalMapper::sigUninstallStarted, this, &UninstallerPage::uninstallStarted);
connect(SignalMapper::ins(), &SignalMapper::sigUninstallFinished, this, &UninstallerPage::loadPackages);
connect(SignalMapper::ins(), &SignalMapper::sigUninstallFinished, this, &UninstallerPage::loadSnapPackages);
}
void UninstallerPage::loadPackages()
{
emit uninstallStarted();
// clear items
ui->listWidgetPackages->clear();
QIcon icon(":/static/themes/common/img/package.png");
QStringList packages = tm->getPackages();
for (const QString &package : packages) {
QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme(package, icon), QString(" %1").arg(package));
item->setCheckState(Qt::Unchecked);
ui->listWidgetPackages->addItem(item);
}
setAppCount();
ui->listWidgetPackages->setEnabled(true);
ui->txtPackageSearch->setEnabled(true);
ui->txtPackageSearch->clear();
ui->lblLoadingUninstaller->hide();
}
void UninstallerPage::loadSnapPackages()
{
// clear items
ui->listWidgetSnapPackages->clear();
QIcon icon(":/static/themes/common/img/package.png");
QStringList packages = tm->getSnapPackages();
for (const QString &package : packages) {
QListWidgetItem *item = new QListWidgetItem(QIcon::fromTheme(package, icon), QString(" %1").arg(package));
item->setCheckState(Qt::Unchecked);
ui->listWidgetSnapPackages->addItem(item);
}
setAppCount();
ui->listWidgetSnapPackages->setEnabled(true);
ui->txtPackageSearch->setEnabled(true);
ui->txtPackageSearch->clear();
ui->lblLoadingUninstaller->hide();
}
void UninstallerPage::setAppCount()
{
int count = ui->listWidgetPackages->count();
ui->btnSystemPackages->setText(tr("Packages (%1)").arg(count));
ui->notFoundWidget->setVisible(! count);
ui->listWidgetPackages->setVisible(count);
int snapCount = ui->listWidgetSnapPackages->count();
ui->btnSnapPackages->setText(tr("Snap Packages (%1)").arg(snapCount));
ui->notFoundWidget_2->setVisible(! snapCount);
ui->listWidgetSnapPackages->setVisible(snapCount);
ui->btnSnapPackages->setVisible(CommandUtil::isExecutable("snap"));
ui->btnUninstall->setVisible(count || snapCount);
}
QStringList UninstallerPage::getSelectedPackages()
{
QStringList selectedPackages = {};
for (int i = 0; i < ui->listWidgetPackages->count(); ++i)
{
QListWidgetItem *item = ui->listWidgetPackages->item(i);
if(item->checkState() == Qt::Checked)
selectedPackages << item->text().trimmed();
}
return selectedPackages;
}
QStringList UninstallerPage::getSelectedSnapPackages()
{
QStringList selectedPackages = {};
for (int i = 0; i < ui->listWidgetSnapPackages->count(); ++i)
{
QListWidgetItem *item = ui->listWidgetSnapPackages->item(i);
if(item->checkState() == Qt::Checked)
selectedPackages << item->text().trimmed();
}
return selectedPackages;
}
void UninstallerPage::on_btnUninstall_clicked()
{
QStringList selectedPackages = getSelectedPackages();
QStringList selectedSnapPackages = getSelectedSnapPackages();
if (!selectedPackages.isEmpty() || !selectedSnapPackages.isEmpty()) {
QtConcurrent::run([=]
{
emit SignalMapper::ins()->sigUninstallStarted();
ToolManager::ins()->uninstallPackages(selectedPackages);
ToolManager::ins()->uninstallSnapPackages(selectedSnapPackages);
emit SignalMapper::ins()->sigUninstallFinished();
});
}
}
void UninstallerPage::uninstallStarted()
{
ui->listWidgetPackages->setEnabled(false);
ui->listWidgetSnapPackages->setEnabled(false);
ui->txtPackageSearch->setEnabled(false);
ui->btnUninstall->hide();
ui->lblLoadingUninstaller->show();
}
void UninstallerPage::on_txtPackageSearch_textChanged(const QString &val)
{
QListWidget *listWidgetPackages = nullptr;
switch (ui->stackedWidget->currentIndex()) {
case 0: listWidgetPackages = ui->listWidgetPackages; break;
case 1: listWidgetPackages = ui->listWidgetSnapPackages; break;
}
// Get matches items
QList matches = listWidgetPackages->findItems(val, Qt::MatchFlag::MatchContains);
// All items hide
for (int i = 0; i < listWidgetPackages->count(); ++i)
listWidgetPackages->item(i)->setHidden(true);
// Matches items show
for (QListWidgetItem* item : matches)
item->setHidden(false);
}
void UninstallerPage::on_btnSystemPackages_clicked()
{
ui->stackedWidget->setCurrentIndex(0);
}
void UninstallerPage::on_btnSnapPackages_clicked()
{
ui->stackedWidget->setCurrentIndex(1);
}
void UninstallerPage::on_listWidgetSnapPackages_itemClicked(QListWidgetItem *item)
{
//item->setCheckState(item->checkState() == Qt::Checked ? Qt::Unchecked : Qt::Checked);
ui->btnUninstall->setText(tr("Uninstall Selected (%1)")
.arg(getSelectedSnapPackages().count() + getSelectedPackages().count()));
}
void UninstallerPage::on_listWidgetPackages_itemClicked(QListWidgetItem *item)
{
//item->setCheckState(item->checkState() == Qt::Checked ? Qt::Unchecked : Qt::Checked);
ui->btnUninstall->setText(tr("Uninstall Selected (%1)")
.arg(getSelectedSnapPackages().count() + getSelectedPackages().count()));
}
================================================
FILE: stacer/Pages/Uninstaller/uninstaller_page.h
================================================
#ifndef UNINSTALLERPAGE_H
#define UNINSTALLERPAGE_H
#include
#include
#include
#include "Managers/tool_manager.h"
#include "Managers/app_manager.h"
#include "signal_mapper.h"
namespace Ui {
class UninstallerPage;
}
class UninstallerPage : public QWidget
{
Q_OBJECT
public:
explicit UninstallerPage(QWidget *parent = 0);
~UninstallerPage();
public slots:
void uninstallStarted();
private:
void init();
private slots:
void setAppCount();
void on_txtPackageSearch_textChanged(const QString &val);
void on_btnUninstall_clicked();
QStringList getSelectedPackages();
QStringList getSelectedSnapPackages();
void loadPackages();
void loadSnapPackages();
void on_btnSystemPackages_clicked();
void on_btnSnapPackages_clicked();
void on_listWidgetSnapPackages_itemClicked(QListWidgetItem *item);
void on_listWidgetPackages_itemClicked(QListWidgetItem *item);
private:
Ui::UninstallerPage *ui;
ToolManager *tm;
};
#endif // UNINSTALLERPAGE_H
================================================
FILE: stacer/Pages/Uninstaller/uninstallerpage.ui
================================================
UninstallerPage
0
0
844
635
Uninstaller
30
5
30
20
0
2
-
0
0
0
0
0
0
-
0
0
0
200
16777215
200
notFoundWidget
0
0
0
0
0
-
0
0
Not Found Installed Packages
Qt::AlignBottom|Qt::AlignHCenter
-
Ubuntu
10
Qt::NoFocus
10
QAbstractItemView::NoEditTriggers
QAbstractItemView::NoSelection
QAbstractItemView::SelectRows
20
20
Qt::ElideMiddle
4
false
0
0
0
0
0
-
0
0
0
200
16777215
200
notFoundWidget
0
0
0
0
0
-
0
0
Not Found Installed Packages
Qt::AlignBottom|Qt::AlignHCenter
-
Ubuntu
10
Qt::NoFocus
10
QAbstractItemView::NoEditTriggers
QAbstractItemView::NoSelection
QAbstractItemView::SelectRows
20
20
Qt::ElideMiddle
4
false
-
0
0
-
Qt::Vertical
QSizePolicy::Fixed
0
10
-
true
Ubuntu
PointingHandCursor
Qt::NoFocus
primary
Uninstall Selected
-
10
4
5
4
5
-
PointingHandCursor
Qt::NoFocus
System Packages
true
true
navBtnGroup
-
PointingHandCursor
Qt::NoFocus
Snap Packages
true
navBtnGroup
-
Qt::Horizontal
40
20
-
170
0
170
16777215
10
Qt::StrongFocus
Search...
================================================
FILE: stacer/app.cpp
================================================
#include "app.h"
#include "ui_app.h"
#include "utilities.h"
#include
#include
App::~App()
{
delete ui;
}
App::App(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::App),
mSlidingStacked(new SlidingStackedWidget(this)),
mTrayIcon(AppManager::ins()->getTrayIcon()),
mTrayMenu(new QMenu(this))
{
ui->setupUi(this);
init();
}
void App::init()
{
setGeometry(
QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter,
size(), qApp->desktop()->availableGeometry())
);
// form settings
ui->horizontalLayout->setContentsMargins(0,0,0,0);
ui->horizontalLayout->setSpacing(0);
dashboardPage = new DashboardPage(mSlidingStacked);
startupAppsPage = new StartupAppsPage(mSlidingStacked);
searchPage = new SearchPage(mSlidingStacked);
systemCleanerPage = new SystemCleanerPage(mSlidingStacked);
servicesPage = new ServicesPage(mSlidingStacked);
processPage = new ProcessesPage(mSlidingStacked);
helpersPage = new HelpersPage(mSlidingStacked);
uninstallerPage = new UninstallerPage(mSlidingStacked);
resourcesPage = new ResourcesPage(mSlidingStacked);
settingsPage = new SettingsPage(mSlidingStacked);
ui->pageContentLayout->addWidget(mSlidingStacked);
mListPages = {
dashboardPage, startupAppsPage, systemCleanerPage, searchPage, servicesPage,
processPage, uninstallerPage, resourcesPage, helpersPage, settingsPage
};
mListSidebarButtons = {
ui->btnDash, ui->btnStartupApps, ui->btnSystemCleaner, ui->btnSearch, ui->btnServices,
ui->btnProcesses, ui->btnHelpers, ui->btnUninstaller, ui->btnResources, ui->btnSettings
};
// APT SOURCE MANAGER
if (ToolManager::ins()->checkSourceRepository()) {
aptSourceManagerPage = new APTSourceManagerPage(mSlidingStacked);
mListPages.insert(7, aptSourceManagerPage);
mListSidebarButtons.insert(7, ui->btnAptSourceManager);
} else {
ui->btnAptSourceManager->hide();
}
// GNOME SETTINGS
bool checkDesktopSession = QString(qgetenv("DESKTOP_SESSION")).contains(QRegExp("ubuntu", Qt::CaseInsensitive));
bool checkDistribution = SystemInfo().getDistribution().contains(QRegExp("ubuntu", Qt::CaseInsensitive));;
if (checkDesktopSession || checkDistribution) {
gnomeSettingsPage = new GnomeSettingsPage(mSlidingStacked);
mListPages.insert(8, gnomeSettingsPage);
mListSidebarButtons.insert(8, ui->btnGnomeSettings);
} else {
ui->btnGnomeSettings->hide();
}
// add pages
for (QWidget *page: mListPages) {
mSlidingStacked->addWidget(page);
}
AppManager::ins()->updateStylesheet();
Utilities::addDropShadow(ui->sidebar, 60);
// set start page
clickSidebarButton(SettingManager::ins()->getStartPage());
createTrayActions();
mTrayIcon->show();
createQuitMessageBox();
}
void App::createQuitMessageBox()
{
mBtnQuit = new QPushButton(tr("Quit"), this);
mBtnQuit->setAccessibleName("danger");
mBtnContinue = new QPushButton(tr("Continue"), this);
mBtnContinue->setAccessibleName("primary");
mQuitMsgBox = new QMessageBox(this);
QCheckBox *check = new QCheckBox("Don't ask again.");
check->setAccessibleName("circle");
mQuitMsgBox->setWindowTitle(tr("Quit"));
mQuitMsgBox->setText(tr("Will the program continue to work in the system tray?"));
mQuitMsgBox->addButton(mBtnQuit, QMessageBox::YesRole);
mQuitMsgBox->addButton(mBtnContinue, QMessageBox::NoRole);
mQuitMsgBox->setCheckBox(check);
connect(check, &QCheckBox::toggled, [this](bool checked) {
SettingManager::ins()->setAppQuitDialogDontAsk(checked);
});
}
void App::closeEvent(QCloseEvent *event)
{
if (SettingManager::ins()->getAppQuitDialogDontAsk()) {
if (SettingManager::ins()->getAppQuitDialogChoice() == "close") {
event->accept();
} else {
event->ignore();
hide();
}
} else {
mQuitMsgBox->exec();
if (mQuitMsgBox->clickedButton() == mBtnContinue) {
SettingManager::ins()->setAppQuitDialogChoice("hide");
event->ignore();
hide();
} else if (mQuitMsgBox->clickedButton() == mBtnQuit) {
SettingManager::ins()->setAppQuitDialogChoice("close");
event->accept();
} else {
event->ignore();
}
}
}
void App::createTrayActions()
{
for (QPushButton *button: mListSidebarButtons) {
QString toolTip = button->toolTip();
QAction *action = new QAction(toolTip, this);
connect(action, &QAction::triggered, [=] {
clickSidebarButton(toolTip, true);
});
connect(mTrayIcon, &QSystemTrayIcon::activated, this, [=](QSystemTrayIcon::ActivationReason){
setVisible(true);
activateWindow();
});
mTrayMenu->addAction(action);
}
mTrayMenu->addSeparator();
QAction *quitAction = new QAction(tr("Quit"), this);
connect(quitAction, &QAction::triggered, [=] {qApp->quit();});
mTrayMenu->addAction(quitAction);
mTrayIcon->setContextMenu(mTrayMenu);
}
void App::clickSidebarButton(QString pageTitle, bool isShow)
{
QWidget *selectedWidget = getPageByTitle(pageTitle);
if (selectedWidget) {
pageClick(selectedWidget, !isShow);
checkSidebarButtonByTooltip(pageTitle);
} else {
pageClick(mListPages.first());
}
setVisible(isShow);
if (isShow) activateWindow();
}
void App::checkSidebarButtonByTooltip(const QString &text)
{
for (QPushButton *button: mListSidebarButtons) {
if (button->toolTip() == text) {
button->setChecked(true);
}
}
}
QWidget* App::getPageByTitle(const QString &title)
{
for (QWidget *page: mListPages) {
if (page->windowTitle() == title) {
return page;
}
}
return nullptr;
}
void App::pageClick(QWidget *widget, bool slide)
{
if (widget) {
ui->pageTitle->setText(widget->windowTitle());
if (slide) {
mSlidingStacked->slideInIdx(mSlidingStacked->indexOf(widget));
} else {
mSlidingStacked->setCurrentWidget(widget);
}
}
}
void App::on_btnDash_clicked()
{
pageClick(dashboardPage);
}
void App::on_btnStartupApps_clicked()
{
pageClick(startupAppsPage);
}
void App::on_btnSystemCleaner_clicked()
{
pageClick(systemCleanerPage);
}
void App::on_btnSearch_clicked()
{
pageClick(searchPage);
}
void App::on_btnServices_clicked()
{
pageClick(servicesPage);
}
void App::on_btnUninstaller_clicked()
{
pageClick(uninstallerPage);
}
void App::on_btnProcesses_clicked()
{
pageClick(processPage);
}
void App::on_btnResources_clicked()
{
pageClick(resourcesPage);
}
void App::on_btnHelpers_clicked()
{
pageClick(helpersPage);
}
void App::on_btnAptSourceManager_clicked()
{
pageClick(aptSourceManagerPage);
}
void App::on_btnGnomeSettings_clicked()
{
pageClick(gnomeSettingsPage);
}
void App::on_btnSettings_clicked()
{
pageClick(settingsPage);
}
void App::on_btnFeedback_clicked()
{
if (feedback.isNull()) {
feedback = QSharedPointer(new Feedback(this));
}
feedback->show();
}
================================================
FILE: stacer/app.h
================================================
#ifndef APP_H
#define APP_H
#include
#include "sliding_stacked_widget.h"
#include "Managers/app_manager.h"
#include "Managers/setting_manager.h"
// Pages
#include "Pages/Dashboard/dashboard_page.h"
#include "Pages/StartupApps/startup_apps_page.h"
#include "Pages/SystemCleaner/system_cleaner_page.h"
#include "Pages/Services/services_page.h"
#include "Pages/Processes/processes_page.h"
#include "Pages/Uninstaller/uninstaller_page.h"
#include "Pages/Resources/resources_page.h"
#include "Pages/Settings/settings_page.h"
#include "Pages/AptSourceManager/apt_source_manager_page.h"
#include "Pages/GnomeSettings/gnome_settings_page.h"
#include "Pages/Search/search_page.h"
#include "Pages/Helpers/helpers_page.h"
#include "feedback.h"
namespace Ui {
class App;
}
class App : public QMainWindow
{
Q_OBJECT
public:
explicit App(QWidget *parent = 0);
~App();
protected:
void closeEvent(QCloseEvent *event) override;
private slots:
void init();
void pageClick(QWidget *widget, bool slide = true);
void clickSidebarButton(QString pageTitle, bool isShow = false);
void on_btnDash_clicked();
void on_btnSystemCleaner_clicked();
void on_btnStartupApps_clicked();
void on_btnServices_clicked();
void on_btnSearch_clicked();
void on_btnUninstaller_clicked();
void on_btnHelpers_clicked();
void on_btnResources_clicked();
void on_btnProcesses_clicked();
void on_btnSettings_clicked();
void on_btnGnomeSettings_clicked();
void on_btnAptSourceManager_clicked();
void on_btnFeedback_clicked();
private:
QWidget *getPageByTitle(const QString &title);
void checkSidebarButtonByTooltip(const QString &text);
void createTrayActions();
void createQuitMessageBox();
private:
Ui::App *ui;
// Pages
QList mListPages;
QList mListSidebarButtons;
SlidingStackedWidget *mSlidingStacked;
DashboardPage *dashboardPage;
StartupAppsPage *startupAppsPage;
SystemCleanerPage *systemCleanerPage;
SearchPage *searchPage;
ServicesPage *servicesPage;
ProcessesPage *processPage;
UninstallerPage *uninstallerPage;
ResourcesPage *resourcesPage;
APTSourceManagerPage *aptSourceManagerPage;
GnomeSettingsPage *gnomeSettingsPage;
SettingsPage *settingsPage;
HelpersPage *helpersPage;
QSharedPointer feedback;
QSystemTrayIcon *mTrayIcon;
QMenu *mTrayMenu;
QPushButton *mBtnQuit, *mBtnContinue;
QMessageBox *mQuitMsgBox;
};
#endif // APP_H
================================================
FILE: stacer/app.ui
================================================
App
Qt::NonModal
0
0
850
570
Stacer
:/static/icons/icon256x256.png:/static/icons/icon256x256.png
0
0
0
0
0
-
0
0
60
0
60
16777215
0
0
5
0
5
-
Qt::Vertical
20
40
-
PointingHandCursor
Qt::NoFocus
Dashboard
28
28
true
true
sidebarBtnGroup
-
PointingHandCursor
Qt::NoFocus
Startup Apps
28
28
true
sidebarBtnGroup
-
PointingHandCursor
Qt::NoFocus
System Cleaner
28
28
true
sidebarBtnGroup
-
PointingHandCursor
Qt::NoFocus
Search
28
28
true
sidebarBtnGroup
-
PointingHandCursor
Qt::NoFocus
Services
28
28
true
sidebarBtnGroup
-
PointingHandCursor
Qt::NoFocus
Processes
28
28
true
sidebarBtnGroup
-
PointingHandCursor
Qt::NoFocus
Uninstaller
28
28
true
sidebarBtnGroup
-
PointingHandCursor
Qt::NoFocus
Resources
28
28
true
sidebarBtnGroup
-
PointingHandCursor
Qt::NoFocus
Helpers
28
28
true
sidebarBtnGroup
-
PointingHandCursor
Qt::NoFocus
APT Repository Manager
28
28
true
sidebarBtnGroup
-
PointingHandCursor
Qt::NoFocus
Gnome Settings
28
28
true
sidebarBtnGroup
-
PointingHandCursor
Qt::NoFocus
Settings
28
28
true
sidebarBtnGroup
-
Qt::Vertical
20
40
-
PointingHandCursor
Qt::NoFocus
Feedback
28
28
false
btnDash
btnServices
btnUninstaller
btnStartupApps
btnResources
verticalSpacer_2
btnSystemCleaner
btnProcesses
btnSettings
btnFeedback
btnGnomeSettings
btnAptSourceManager
btnSearch
btnHelpers
-
0
0
0
0
0
0
0
-
0
0
Ubuntu
12
Title
Qt::AlignCenter
pageContent
sidebar
================================================
FILE: stacer/feedback.cpp
================================================
#include "feedback.h"
#include "ui_feedback.h"
#include "Utils/command_util.h"
#include
#include
#include
#include
Feedback::~Feedback()
{
delete ui;
}
Feedback::Feedback(QWidget *parent) :
QDialog(parent),
ui(new Ui::Feedback),
mHeader("Content-Type: application/json"),
mFeedbackUrl("https://stacer-web-api.herokuapp.com/feedback"),
mMailRegex("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b")
{
ui->setupUi(this);
init();
}
void Feedback::init()
{
mMailRegex.setCaseSensitivity(Qt::CaseInsensitive);
mMailRegex.setPatternSyntax(QRegExp::RegExp);
connect(this, &Feedback::clearInputsS, this, &Feedback::clearInputs);
connect(this, &Feedback::setErrorMessageS, this, &Feedback::setErrorMessage);
connect(this, &Feedback::disableElementsS, this, &Feedback::disableElements);
}
void Feedback::on_btnSend_clicked()
{
QString name = ui->txtName->text();
QString email = ui->txtEmail->text();
QString message = ui->txtMessage->toPlainText();
bool isEmailValid = mMailRegex.exactMatch(email);
if (! isEmailValid) {
emit setErrorMessageS(tr("Email address is not valid !"));
return;
}
if (message.length() < 5) {
emit setErrorMessageS(tr("Your message must be at least 5 characters !"));
return;
}
if (! name.isEmpty() &&
! email.isEmpty() && isEmailValid)
{
QtConcurrent::run([=] {
emit disableElementsS(true);
ui->btnSend->setText(tr("Sending.."));
QStringList args;
QJsonObject postData;
postData["name"] = name;
postData["email"] = email;
postData["message"] = message;
QJsonDocument json(postData);
args << "-d" << json.toJson() << "-H" << mHeader << "-X" << "POST" << mFeedbackUrl;
try {
QString result = CommandUtil::exec("curl", args);
QJsonObject response = QJsonDocument::fromJson(result.toUtf8()).object();
if (response.value("success").toBool()) {
emit clearInputs();
emit setErrorMessageS(tr("Your Feedback has been successfully sended."));
} else {
emit setErrorMessageS(tr("Something went wrong, try again !"));
}
} catch(QString &ex) {
qCritical() << ex;
emit setErrorMessageS(tr("Something went wrong, try again !"));
}
ui->btnSend->setText(tr("Save"));
emit disableElementsS(false);
});
} else {
emit setErrorMessageS(tr("Fields cannot be left blank !"));
}
}
void Feedback::setErrorMessage(const QString &msg)
{
ui->lblErrorMsg->setText(msg);
}
void Feedback::disableElements(const bool status)
{
ui->txtName->setDisabled(status);
ui->txtEmail->setDisabled(status);
ui->txtMessage->setDisabled(status);
ui->btnSend->setDisabled(status);
}
void Feedback::clearInputs()
{
ui->txtName->clear();
ui->txtEmail->clear();
ui->txtMessage->clear();
ui->txtName->setFocus();
}
void Feedback::on_btnClose_clicked()
{
this->close();
}
================================================
FILE: stacer/feedback.h
================================================
#ifndef FEEDBACK_H
#define FEEDBACK_H
#include
namespace Ui {
class Feedback;
}
class Feedback : public QDialog
{
Q_OBJECT
public:
explicit Feedback(QWidget *parent = 0);
~Feedback();
signals:
void setErrorMessageS(const QString &msg);
void clearInputsS();
void disableElementsS(const bool status);
private slots:
void setErrorMessage(const QString &msg);
void on_btnSend_clicked();
void clearInputs();
void disableElements(const bool status);
void on_btnClose_clicked();
private:
void init();
private:
Ui::Feedback *ui;
QString mHeader;
QString mFeedbackUrl;
QRegExp mMailRegex;
};
#endif // FEEDBACK_H
================================================
FILE: stacer/feedback.ui
================================================
Feedback
0
0
476
350
Feedback
true
30
20
30
20
15
-
Qt::Vertical
QSizePolicy::Maximum
359
2
-
Message
-
Name
-
Email Address
-
dialog-title
Send a Feedback
Qt::AlignCenter
-
PointingHandCursor
Qt::NoFocus
primary
Send
true
-
-
PointingHandCursor
danger
Close
txtName
txtEmail
txtMessage
================================================
FILE: stacer/main.cpp
================================================
#include
#include
#include
#include
#include "app.h"
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message)
{
Q_UNUSED(context)
QString level;
switch (type) {
case QtDebugMsg:
level = "DEBUG"; break;
case QtInfoMsg:
level = "INFO"; break;
case QtWarningMsg:
level = "WARNING"; break;
case QtCriticalMsg:
level = "CRITICAL"; break;
case QtFatalMsg:
level = "FATAL"; break;
default:
level = "UNDEFIEND"; break;
}
if (type != QtWarningMsg) {
QString text = QString("[%1] [%2] %3")
.arg(QDateTime::currentDateTime().toString("dd-MM-yyyy hh:mm:ss"))
.arg(level)
.arg(message);
static QString logPath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
QFile file(logPath + "/stacer.log");
QIODevice::OpenMode openMode = file.size() > (1L << 20) ? QIODevice::Truncate : QIODevice::Append;
if (file.open(QIODevice::WriteOnly | openMode)) {
QTextStream stream(&file);
stream << text << endl;
file.close();
}
}
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
qApp->setApplicationName("stacer");
qApp->setApplicationDisplayName("Stacer");
qApp->setApplicationVersion("1.1.0");
qApp->setWindowIcon(QIcon(":/static/logo.png"));
{
QCommandLineOption hideOption("hide", "Hide Stacer while launching.");
QCommandLineOption noSplashOption("nosplash", "Hide splash screen while launching.");
QCommandLineParser parser;
parser.addVersionOption();
parser.addHelpOption();
parser.addOption(hideOption);
parser.addOption(noSplashOption);
parser.process(app);
}
bool isHide = false;
bool isNoSplash = false;
QLatin1String hideOption("--hide");
QLatin1String noSplashOption("--nosplash");
for (size_t i = 1; i < argc; ++i) {
if (QString(argv[i]) == hideOption)
isHide = true;
else if (QString(argv[i]) == noSplashOption)
isNoSplash = true;
}
QFontDatabase::addApplicationFont(":/static/font/Ubuntu-R.ttf");
QPixmap pixSplash(":/static/splashscreen.png");
QSplashScreen *splash = new QSplashScreen(pixSplash);
if (!isNoSplash) splash->show();
app.processEvents();
App w;
if (argc < 2 || !isHide) {
w.show();
}
splash->finish(&w);
delete splash;
return app.exec();
}
================================================
FILE: stacer/signal_mapper.cpp
================================================
#include "signal_mapper.h"
SignalMapper *SignalMapper::instance = nullptr;
SignalMapper* SignalMapper::ins()
{
if (! instance) {
instance = new SignalMapper;
}
return instance;
}
================================================
FILE: stacer/signal_mapper.h
================================================
#ifndef SIGNAL_MAPPER_H
#define SIGNAL_MAPPER_H
#include
class SignalMapper : public QObject
{
Q_OBJECT
public:
static SignalMapper *ins();
signals:
void sigChangedAppTheme();
void sigUninstallStarted();
void sigUninstallFinished();
private:
static SignalMapper *instance;
};
#endif // SIGNAL_MAPPER_H
================================================
FILE: stacer/sliding_stacked_widget.cpp
================================================
#include "sliding_stacked_widget.h"
SlidingStackedWidget::SlidingStackedWidget(QWidget *parent)
: QStackedWidget(parent)
{
vertical = false;
speed = 150;
animationtype = QEasingCurve::Type::Linear;
now = 0;
next = 0;
pnow = QPoint(0,0);
active = false;
}
void SlidingStackedWidget::setVerticalMode(bool vertical)
{
this->vertical = vertical;
}
void SlidingStackedWidget::setSpeed(int speed)
{
this->speed = speed;
}
void SlidingStackedWidget::setAnimation(const QEasingCurve::Type animationtype)
{
this->animationtype = animationtype;
}
void SlidingStackedWidget::slideInNext()
{
int now = currentIndex();
if (now < count() - 1)
slideInIdx(now + 1);
}
void SlidingStackedWidget::slideInPrev()
{
int now = currentIndex();
if (now > 0)
slideInIdx(now - 1);
}
void SlidingStackedWidget::slideInIdx(int idx, t_direction direction)
{
// int idx, t_direction direction=AUTOMATIC
if (idx > count() - 1) {
direction = vertical ? TOP2BOTTOM : RIGHT2LEFT;
idx = (idx) % count();
}
else if (idx < 0) {
direction = vertical ? BOTTOM2TOP : LEFT2RIGHT;
idx = (idx + count()) % count();
}
slideInWgt(widget(idx), direction);
}
void SlidingStackedWidget::slideInWgt(QWidget * newwidget, t_direction direction)
{
// do not allow re-entrance before an animation is completed.
if (active)
return ;
else
active = true;
enum t_direction directionhint;
int now = currentIndex();
int next = indexOf(newwidget);
if (now == next) {
active = false;
return;
}
else if (now < next) {
directionhint = vertical ? TOP2BOTTOM : RIGHT2LEFT;
}
else {
directionhint = vertical ? BOTTOM2TOP : LEFT2RIGHT;
}
if (direction == AUTOMATIC) {
direction = directionhint;
}
// calculate the shifts
int offsetx = frameRect().width();
int offsety = frameRect().height();
widget(next)->setGeometry(0, 0, offsetx, offsety);
if (direction == BOTTOM2TOP) {
offsetx = 0;
offsety = -offsety;
}
else if (direction == TOP2BOTTOM) {
offsetx = 0;
}
else if (direction == RIGHT2LEFT) {
offsetx = -offsetx;
offsety = 0;
}
else if (direction == LEFT2RIGHT) {
offsety = 0;
}
// re-position the next widget outside/aside of the display area
QPoint pnext = widget(next)->pos();
QPoint pnow = widget(now)->pos();
this->pnow = pnow;
widget(next)->move(pnext.x() - offsetx, pnext.y() - offsety);
// make it visible/show
widget(next)->show();
widget(next)->raise();
// animate both, the now and next widget to the side, using animation framework
QPropertyAnimation *animnow = new QPropertyAnimation(widget(now), "pos");
animnow->setDuration(speed);
animnow->setEasingCurve(animationtype);
animnow->setStartValue(QPoint(pnow.x(), pnow.y()));
animnow->setEndValue(QPoint(offsetx + pnow.x(), offsety + pnow.y()));
QPropertyAnimation *animnext = new QPropertyAnimation(widget(next), "pos");
animnext->setDuration(speed);
animnext->setEasingCurve(animationtype);
animnext->setStartValue(QPoint(-offsetx + pnext.x(), offsety + pnext.y()));
animnext->setEndValue(QPoint(pnext.x(), pnext.y()));
QParallelAnimationGroup *animgroup = new QParallelAnimationGroup(this);
animgroup->addAnimation(animnow);
animgroup->addAnimation(animnext);
connect(animgroup, &QParallelAnimationGroup::finished, this, &SlidingStackedWidget::animationDoneSlot);
this->next = next;
this->now = now;
active = true;
animgroup->start();
}
void SlidingStackedWidget::animationDoneSlot()
{
setCurrentIndex(next); // this function is inherited from QStackedWidget
widget(now)->hide();
widget(now)->move(pnow);
active = false;
emit animationFinished();
}
================================================
FILE: stacer/sliding_stacked_widget.h
================================================
#ifndef SLIDINGSTACKEDWIDGET_H
#define SLIDINGSTACKEDWIDGET_H
#include
#include
#include
#include
#include
class SlidingStackedWidget : public QStackedWidget
{
Q_OBJECT
public:
// This enumeration is used to define the animation direction
enum t_direction {
LEFT2RIGHT,
RIGHT2LEFT,
TOP2BOTTOM,
BOTTOM2TOP,
AUTOMATIC
};
SlidingStackedWidget(QWidget *parent);
public slots:
void setSpeed(int speed); // animation duration in milliseconds
void setAnimation(const QEasingCurve::Type animationtype); // check out the QEasingCurve documentation for different styles
void setVerticalMode(bool vertical = true);
void slideInNext();
void slideInPrev();
void slideInIdx(int idx, t_direction direction = AUTOMATIC);
signals:
void animationFinished();
private slots:
void animationDoneSlot();
private:
void slideInWgt(QWidget *widget, t_direction direction = AUTOMATIC);
enum QEasingCurve::Type animationtype;
int speed;
bool vertical;
int now;
int next;
QPoint pnow;
bool active;
};
#endif // SLIDINGSTACKEDWIDGET_H
================================================
FILE: stacer/stacer.pro
================================================
QT += core gui charts svg concurrent
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = stacer
TEMPLATE = app
CONFIG += c++11
QMAKE_CXXFLAGS += -O2
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
app.cpp \
Pages/Dashboard/circlebar.cpp \
Pages/Dashboard/linebar.cpp \
Pages/StartupApps/startup_app.cpp \
Pages/StartupApps/startup_app_edit.cpp \
Pages/StartupApps/startup_apps_page.cpp \
Pages/Services/service_item.cpp \
Managers/app_manager.cpp \
Managers/tool_manager.cpp \
Managers/info_manager.cpp \
Pages/Resources/history_chart.cpp \
Pages/SystemCleaner/system_cleaner_page.cpp \
Pages/SystemCleaner/byte_tree_widget.cpp \
Pages/Uninstaller/uninstaller_page.cpp \
Pages/Services/services_page.cpp \
Pages/Resources/resources_page.cpp \
Pages/Dashboard/dashboard_page.cpp \
Pages/Processes/processes_page.cpp \
Pages/Settings/settings_page.cpp \
Pages/AptSourceManager/apt_source_manager_page.cpp \
Pages/AptSourceManager/apt_source_repository_item.cpp \
Pages/GnomeSettings/gnome_settings_page.cpp \
Pages/GnomeSettings/unity_settings.cpp \
Pages/GnomeSettings/window_manager_settings.cpp \
Pages/GnomeSettings/appearance_settings.cpp \
feedback.cpp \
Pages/AptSourceManager/apt_source_edit.cpp \
Managers/setting_manager.cpp \
sliding_stacked_widget.cpp \
signal_mapper.cpp \
Pages/Search/search_page.cpp \
Pages/Helpers/helpers_page.cpp \
Pages/Helpers/host_manage.cpp
HEADERS += \
app.h \
Pages/Dashboard/circlebar.h \
Pages/Dashboard/linebar.h \
Pages/StartupApps/startup_app.h \
Pages/StartupApps/startup_app_edit.h \
Pages/StartupApps/startup_apps_page.h \
Pages/Services/service_item.h \
Managers/app_manager.h \
Managers/tool_manager.h \
Managers/info_manager.h \
Pages/Resources/history_chart.h \
Pages/SystemCleaner/system_cleaner_page.h \
Pages/SystemCleaner/byte_tree_widget.h \
Pages/Uninstaller/uninstaller_page.h \
Pages/Resources/resources_page.h \
Pages/Processes/processes_page.h \
Pages/Dashboard/dashboard_page.h \
Pages/Services/services_page.h \
Pages/Settings/settings_page.h \
Pages/AptSourceManager/apt_source_manager_page.h \
Pages/AptSourceManager/apt_source_repository_item.h \
Pages/GnomeSettings/gnome_settings_page.h \
Pages/GnomeSettings/unity_settings.h \
Pages/GnomeSettings/window_manager_settings.h \
Pages/GnomeSettings/appearance_settings.h \
sliding_stacked_widget.h \
utilities.h \
feedback.h \
Pages/AptSourceManager/apt_source_edit.h \
Managers/setting_manager.h \
signal_mapper.h \
Pages/Search/search_page.h \
Pages/Helpers/helpers_page.h \
Pages/Helpers/host_manage.h
FORMS += \
app.ui \
Pages/Uninstaller/uninstallerpage.ui \
Pages/Dashboard/circlebar.ui \
Pages/Dashboard/linebar.ui \
Pages/StartupApps/startup_app.ui \
Pages/StartupApps/startup_app_edit.ui \
Pages/StartupApps/startup_apps_page.ui \
Pages/Services/service_item.ui \
Pages/Resources/history_chart.ui \
Pages/SystemCleaner/system_cleaner_page.ui \
Pages/Dashboard/dashboard_page.ui \
Pages/Processes/processes_page.ui \
Pages/Resources/resources_page.ui \
Pages/Services/services_page.ui \
Pages/Settings/settings_page.ui \
Pages/AptSourceManager/apt_source_manager_page.ui \
Pages/AptSourceManager/apt_source_repository_item.ui \
Pages/GnomeSettings/gnome_settings_page.ui \
Pages/GnomeSettings/unity_settings.ui \
Pages/GnomeSettings/window_manager_settings.ui \
Pages/GnomeSettings/appearance_settings.ui \
Pages/AptSourceManager/apt_source_edit.ui \
Pages/Search/search_page.ui \
Pages/Helpers/helpers_page.ui \
feedback.ui \
Pages/Helpers/host_manage.ui
TRANSLATIONS += \
../translations/stacer_ar.ts \
../translations/stacer_ca-es.ts \
../translations/stacer_de.ts \
../translations/stacer_en.ts \
../translations/stacer_es.ts \
../translations/stacer_fr.ts \
../translations/stacer_hi.ts \
../translations/stacer_it.ts \
../translations/stacer_kn.ts \
../translations/stacer_ko.ts \
../translations/stacer_ml.ts \
../translations/stacer_nl.ts \
../translations/stacer_oc.ts \
../translations/stacer_pl.ts \
../translations/stacer_pt.ts \
../translations/stacer_ru.ts \
../translations/stacer_sv.ts \
../translations/stacer_tr.ts \
../translations/stacer_ua.ts \
../translations/stacer_vn.ts \
../translations/stacer_zh-cn.ts \
../translations/stacer_zh-tw.ts
RESOURCES += \
static.qrc
unix:!macx: LIBS += -L$$OUT_PWD/../stacer-core/ -lstacer-core
INCLUDEPATH += $$PWD/../stacer-core
DEPENDPATH += $$PWD/../stacer-core
================================================
FILE: stacer/static/languages.json
================================================
[
{"value" : "ar", "text": "العربية"},
{"value" : "ca-es", "text": "Català"},
{"value" : "cs", "text": "Čeština"},
{"value" : "de", "text": "Deutsch"},
{"value" : "en", "text": "English"},
{"value" : "ko", "text": "한국어"},
{"value" : "es", "text": "Español"},
{"value" : "fr", "text": "Français"},
{"value" : "hi", "text": "हिंदी"},
{"value" : "hu", "text": "Magyar"},
{"value" : "it", "text": "Italiano"},
{"value" : "kn", "text": "ಕನ್ನಡ"},
{"value" : "ml", "text": "മലയാളം"},
{"value" : "nl", "text": "Nederlands"},
{"value" : "oc", "text": "Occitan"},
{"value" : "pl", "text": "Polski"},
{"value" : "pt", "text": "Português - Brasil"},
{"value" : "ru", "text": "Русский"},
{"value" : "sv", "text": "Svenska"},
{"value" : "tr", "text": "Türkçe"},
{"value" : "ua", "text": "Українська"},
{"value" : "vn", "text": "Tiếng việt"},
{"value" : "zh-cn", "text": "简体中文"},
{"value" : "zh-tw", "text": "正體中文"}
]
================================================
FILE: stacer/static/themes/default/style/style.qss
================================================
/****** DEFAULT THEME ******/
/*****************
QScrollArea
******************/
QScrollArea {
border: 0;
}
QScrollBar:vertical {
width: 12;
margin: 0 0 0 2;
border-radius: 2;
background-color: transparent;
}
QScrollBar::handle:vertical {
background-color: @color01;
min-height: 20px;
border-radius: 2;
}
QScrollBar::add-line:vertical,
QScrollBar::sub-line:vertical {
height: 0;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
border-bottom-right-radius: 2;
border-bottom-left-radius: 2;
background-color: transparent;
}
QScrollBar:horizontal {
height: 12;
margin: 2 0 0 0;
border-radius: 2;
background-color: transparent;
}
QScrollBar::handle:horizontal {
background-color: @color01;
min-width: 20px;
border-radius: 2;
}
QScrollBar::add-line:horizontal,
QScrollBar::sub-line:horizontal {
height: 0;
}
QScrollBar::add-page:horizontal,
QScrollBar::sub-page:horizontal {
border-bottom-right-radius: 2;
border-bottom-left-radius: 2;
background-color: transparent;
}
QAbstractScrollArea::corner {
background: transparent;
}
/*************
QMessageBox
**************/
QMessageBox {
background-color: #212f3c;
}
QMessageBox QLabel {
color: #fefefe;
}
/*************
QMenu
**************/
QMenu {
background-color: @color02;
border-radius: 2;
margin: 3px 5px;
}
QMenu::item {
padding: 2px 30px;
color: @color05;
font-size: 10pt;
}
QMenu::item:selected {
background-color: @color03;
}
QMenu::indicator {
width: 14px;
height: 14px;
}
QMenu::indicator:non-exclusive:unchecked {
image: url(:/static/themes/common/img/un-check.png);
}
QMenu::indicator:non-exclusive:checked {
image: url(:/static/themes/common/img/check.png);
}
/*****************
QRadioButton
******************/
QRadioButton {
color: @color12;
font-size: 11pt;
}
QRadioButton::indicator {
width: 16;
height: 16;
}
QRadioButton::indicator:unchecked {
image: url(:/static/themes/common/img/un-check.png);
}
QRadioButton::indicator:checked {
image: url(:/static/themes/common/img/check.png);
}
/*****************
QCheckBox
******************/
QCheckBox::indicator {
width: 44px;
height: 24px;
}
QCheckBox::indicator:checked {
image: url(:/static/themes/common/img/checkbox.png);
}
QCheckBox::indicator:unchecked {
image: url(:/static/themes/common/img/un-checkbox.png);
}
QCheckBox[accessibleName="circle"] {
font-size: 10pt;
color: @color06;
}
QCheckBox[accessibleName="circle"]::indicator {
width: 18px;
height: 18px;
}
QCheckBox[accessibleName="circle"]::indicator:unchecked {
image: url(:/static/themes/common/img/un-check.png);
}
QCheckBox[accessibleName="circle"]::indicator:checked {
image: url(:/static/themes/common/img/check.png);
}
/*****************
QToolTip
******************/
QToolTip {
color: @color05;
padding: 2;
background-color: @sidebar;
border-radius: 3;
}
/***************
Not Found
***************/
#notFoundWidget, QWidget[accessibleName="notFoundWidget"] {
background: url(:/static/themes/common/img/not-found.png) no-repeat top center;
}
#notFoundWidget QLabel, QWidget[accessibleName="notFoundWidget"] {
color: @color06;
font-size: 13pt;
}
/***************
QSpinBox
***************/
QSpinBox::up-button {
subcontrol-origin: border;
subcontrol-position: top right;
width: 16px;
border-image: url(:/static/themes/common/img/spinup.png) 1;
border-width: 1px;
}
QSpinBox::down-button {
subcontrol-origin: border;
subcontrol-position: bottom right;
width: 16px;
border-image: url(:/static/themes/common/img/spindown.png) 1;
border-width: 1px;
border-top-width: 0;
}
/***************
QSlider
***************/
QSlider::groove:horizontal {
height: 2px;
background: @color12;
margin: 2px 0;
}
QSlider::handle:horizontal {
background-color: @color03;
width: 14px;
height: 14px;
margin: -6px 0;
border-radius: 7px;
}
/***************
QComboBox
***************/
QComboBox {
border: 0;
border-radius: 2;
background-color: @color01;
padding: 4 0 4 10;
font-size: 11pt;
color: @color05;
min-width: 100;
}
QComboBox::drop-down {
background-color: @color01;
subcontrol-position: top right;
width: 14;
padding: 0 5;
color: @color05;
border-left-width: 1px;
border-left-color: @color01;
border-left-style: solid;
image: url(:/static/themes/default/img/down-arrow.png);
border-top-right-radius: 2;
border-bottom-right-radius: 2;
}
QComboBox::down-arrow:on {
background-color: @color01;
color: @color05;
}
QComboBox QAbstractItemView {
background-color: @color01;
border: 0;
}
/***************
QGroupBox
***************/
QGroupBox::title {
font-size: 11pt;
font-weight: bold;
color: @color06;
}
/***************
QTableView
***************/
QTableView {
background-color: transparent;
selection-color: @color05;
color: @color05;
font-size: 10pt;
gridline-color: @color08;
border-radius: 2;
}
QTableView::item {
font-size: 11pt;
color: @color05;
padding: 6 0 6 -10;
background-color: @color01;
}
QTableView::item:selected {
background-color: @color02;
}
QHeaderView::section {
background-color: @color02;
border-width: 1 1 1 0;
border-style: solid;
border-color: @color08;
font-size: 11pt;
color: @color16;
padding-left:10;
}
QHeaderView::up-arrow {
image: url(:/static/themes/default/img/asc.png);
}
QHeaderView::down-arrow {
image: url(:/static/themes/default/img/dsc.png);
}
/******************
QMainWindow
*******************/
QMainWindow * {
font-family: "Ubuntu";
}
QLineEdit,
QPlainTextEdit,
QSpinBox {
border-radius: 2;
padding: 6;
background-color: @color01;
font-size: 10pt;
color: @color05;
}
QPushButton {
border-radius: 2;
font-size: 11pt;
}
QPushButton[accessibleName="danger"] {
padding: 6 16;
background-color: @color09;
color: @color07;
}
QPushButton[accessibleName="danger"]:hover {
background-color: #c0392b;
}
QPushButton[accessibleName="primary"] {
padding: 6 16;
background-color: @color03;
color: @color07;
}
QPushButton[accessibleName="primary"]:hover {
background-color: @color10;
}
QLabel[accessibleName="dialog-title"] {
color: @color06;
font-size: 11pt;
padding-bottom: 8;
border: 0;
border-bottom: 1 solid @color06;
}
#lblErrorMsg {
color: @color09;
}
/**************
Sidebar
***************/
#sidebar {
background-color: @sidebar;
min-width: 60;
}
#sidebar QPushButton {
border: 0px;
height: 42;
border-style: solid;
color: @color07;
margin: 0 0;
border-radius: 0;
}
#sidebar QPushButton:checked,
#sidebar QPushButton:hover {
background-color: @color03;
}
#pageTitle {
color: @color04;
padding: 5 0 8 0;
margin: 5 10;
border: 0;
border-bottom: 1 solid @color04;
}
#pageContent {
background-color: @color08;
}
#btnDash {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/dash.png);
}
#btnSystemCleaner {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/cleaner.png);
}
#btnStartupApps {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/startup-apps.png);
}
#btnSearch {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/search.png);
}
#btnServices {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/services.png);
}
#btnProcesses {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/process.png);
}
#btnUninstaller {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/uninstaller.png);
}
#btnResources {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/resources.png);
}
#btnHelpers {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/helpers.png);
}
#btnAptSourceManager {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/ppa-manager.png);
}
#btnGnomeSettings {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/gnome.png);
}
#btnSettings {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/settings.png);
}
#btnFirewall {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/firewall.png);
}
#btnFeedback {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/feedback.png);
}
/********************
DASHBOARD PAGE
*********************/
/* - Circle Bar - */
#widgetCircleBar {
background-color: @color01;
border-radius: 1;
}
#lblCircleChartTitle,
#lblCircleChartValue {
color: @color05;
font-size: 13pt;
margin: 0;
}
/* - Line Bar - */
#lineChartWidget {
background-color: @color01;
border-radius: 1;
}
#lblLineChartTitle {
color: @color05;
font-size: 13pt;
}
#lblLineChartValue {
color: @color05;
font-size: 13pt;
}
#lblLineChartTotal {
color: @color06;
font-size: 11pt;
}
#lineChartProgress {
background-color: @color08;
border: 0;
border-radius: 0;
}
#lineChartProgress::chunk {
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #3498db, stop:1 #2980b9);
}
/* - System Info - */
#lblSystemInfoTitle {
color: @color05;
font-size: 13pt;
padding-left: 5;
}
#listViewSystemInfo {
border: 0;
background-color: transparent;
font-size: 12pt;
color: @color06;
}
/**************************
SYSTEM CLEANER PAGE
***************************/
#cleanerCategories QCheckBox[accessibleName=circle]::indicator {
width: 26;
height: 26;
}
#cleanerCategories QLabel,
#checkSelectAllSystemScan {
font-size: 11pt;
color: @color05;
}
/* - System Scan Button - */
#SystemCleanerPage #btnScan {
border: 0;
background: url(:/static/themes/default/img/scan.png) no-repeat center;
}
#SystemCleanerPage #btnScan:hover {
background: url(:/static/themes/default/img/scan-active.png) no-repeat center;
}
/* - System Clean Button - */
#SystemCleanerPage #btnClean {
border: 0;
background: url(:/static/themes/default/img/clean.png) no-repeat center;
}
#SystemCleanerPage #btnClean:hover {
background: url(:/static/themes/default/img/clean-active.png) no-repeat center;
}
/* - System Scan Results - */
#btnBackToCategories {
border: 0;
font-size: 11pt;
color: @color03;
}
#treeWidgetScanResult {
border: 1 solid @color13;
background-color: transparent;
border-radius: 2;
}
#treeWidgetScanResult QHeaderView::section {
border-top: 1;
}
#treeWidgetScanResult::item {
border-bottom: 1 solid @color14;
padding: 7 3;
font-size: 11pt;
color: @color11;
}
#treeWidgetScanResult::indicator {
width: 14;
height: 14;
}
#treeWidgetScanResult::indicator:checked {
image: url(:/static/themes/common/img/check.png);
}
#treeWidgetScanResult::indicator:unchecked {
image: url(:/static/themes/common/img/un-check.png);
}
#treeWidgetScanResult::branch:has-children:!has-siblings:closed,
#treeWidgetScanResult::branch:closed:has-children:has-siblings {
image: url(:/static/themes/default/img/right-arrow.png);
border-image: none;
padding: 4;
}
#treeWidgetScanResult::branch:open:has-children:!has-siblings,
#treeWidgetScanResult::branch:open:has-children:has-siblings {
image: url(:/static/themes/default/img/down-arrow.png);
border-image: none;
padding: 4;
}
#treeWidgetScanResult::branch {
border-bottom: 1 solid @color14;
}
#lblRemovedTotalSize {
font-size: 11pt;
color: @color15;
}
/************************
STARTUP APPS PAGE
*************************/
#listWidgetStartup {
background-color: transparent;
}
#lblStartupAppsTitle {
color: @color11;
padding: 10 0 10 20;
}
/* - Startup App - */
#widgetStartupApp {
border-radius: 2;
background-color: @color01;
}
#lblStartupAppIcon {
image: url(:/static/themes/default/img/app.png);
}
#widgetStartupApp:hover {
background-color: @color02;
}
#widgetStartupApp #lblStartupAppName {
font-size: 11pt;
color: @color05;
}
#checkStartup {
margin-top: 3;
}
#widgetStartupApp #btnDeleteStartupApp {
qproperty-icon: url(:/static/themes/default/img/trash.png);
border: 0;
}
#widgetStartupApp #btnEditStartupApp {
qproperty-icon: url(:/static/themes/default/img/edit.png);
border: 0;
margin-bottom: 2;
}
/* - Startup App Edit - */
#StartupAppEdit {
background-color: @color08;
}
/**************************
SERVICES PAGE
***************************/
#ServicesPage QListWidget {
background-color: transparent;
}
#lblServicesTitle {
font-size: 11pt;
color: @color11;
padding: 10 0;
}
/* - Service Item - */
#serviceItemWidget {
border-radius: 2;
background-color: @color01;
}
#serviceItemWidget:hover {
background-color: @color02;
}
#lblServiceIcon {
image: url(:/static/themes/default/img/service.png);
}
#ServiceItem #lblServiceName {
font-size: 11pt;
color: @color05;
}
#ServiceItem #lblServiceDescription {
font-size: 10pt;
color: @color06;
}
#lblServiceStartupImg {
image: url(:/static/themes/default/img/power.png);
}
#lblSystemRunningImg {
image: url(:/static/themes/default/img/run.png);
}
/**********************
PROCESSES PAGE
***********************/
#lblProcessTitle {
color: @color11;
padding: 10 0;
font-size: 11pt;
}
#checkAllProcesses {
margin-top: 2;
color: @color12;
font-size: 10pt;
}
#checkAllProcesses::indicator {
width: 14;
height: 14;
}
#txtProcessSearch {
width: 150;
padding: 4 12;
border-radius: 12;
background: @color01 url(:/static/themes/default/img/search.png) no-repeat right center;
border: 1px solid @color02;
color: @color12;
}
#lblRefresh {
color: @color12;
font-size: 10pt;
}
#sliderRefresh {
margin-top: 3;
}
/************************
UNINSTALLER PAGE
*************************/
#nav QPushButton {
border-radius: 3;
padding: 5 10;
font-size: 10pt;
background-color: @circleChartBackgroundColor;
color: @color07;
}
#nav QPushButton:hover,
#nav QPushButton:checked {
background-color: @color03;
}
#lblPackagesTitle {
color: @color11;
padding: 10 0;
font-size: 11pt;
}
#txtPackageSearch,
#txtSearchAptSource {
padding: 4 12;
border-radius: 12;
background: @color01 url(:/static/themes/default/img/search.png) no-repeat right center;
border: 1px solid @color02;
color: @color12;
}
#listWidgetPackages, #listWidgetSnapPackages {
border: 0;
background-color: transparent;
font-size: 11pt;
}
#listWidgetPackages::indicator, #listWidgetSnapPackages::indicator {
width: 16;
height: 16;
}
#listWidgetPackages::indicator:unchecked, #listWidgetSnapPackages::indicator:unchecked {
image: url(:/static/themes/common/img/un-check.png);
}
#listWidgetPackages::indicator:checked, #listWidgetSnapPackages::indicator:checked {
image: url(:/static/themes/common/img/check.png);
}
#listWidgetPackages::item, #listWidgetSnapPackages::item {
border-radius: 2;
min-height: 45;
background-color: @color01;
}
#listWidgetPackages::item:text, #listWidgetSnapPackages::item:text {
color: @color05;
padding-left: 15;
}
#listWidgetPackages::item:selected, #listWidgetSnapPackages::item:selected {
background-color: @color02;
border: 0;
}
#listWidgetPackages::item:hover, #listWidgetSnapPackages::item:hover {
background-color: @color02;
}
/****************
HISTORIES
*****************/
#charts {
background-color: @pageContent;
}
#lblHistoryTitle {
font-size: 11pt;
margin: 6 0 10 0;
color: @color12;
}
#checkHistoryTitle::indicator {
width: 16;
height: 16;
}
#checkHistoryTitle::indicator:unchecked {
image: url(:/static/themes/default/img/fit.png);
}
#checkHistoryTitle::indicator:checked {
image: url(:/static/themes/default/img/collapse.png);
}
/***************
SETTINGS
****************/
#SettingsPage QLabel {
font-size: 11pt;
color: @color12;
}
#lblCreatedBy {
font-size: 9pt;
color: @color06;
}
/*****************
UPDATE BAR
******************/
#widgetUpdateBar {
background-color: @color03;
border-radius: 2;
}
#lblUpdateBarText {
font-size: 10pt;
color: @color05;
}
#btnDownloadUpdate {
background-color: @color01;
padding: 4 10;
}
/****************
FEEDBACK
*****************/
#Feedback {
background-color: @pageContent;
}
/**************************
APT SOURCE MANAGER PAGE
***************************/
#listWidgetAptSources {
background-color: transparent;
}
#lblAptSourceTitle {
color: @color11;
padding: 10 0 5 20;
}
#txtAptSource {
padding: 7;
}
#lblAptSourceSelectInfo {
margin-top: 5;
font-size: 10pt;
color: @color05;
}
#listWidgetAptSources {
selection-background-color: @color03;
}
/* - APT Source Repository Item - */
#aptSourceRepositoryItemWidget {
border-radius: 2;
background-color: @color01;
}
#lblAptSourceIcon {
image: url(:/static/themes/default/img/ppa-repository.png);
}
#aptSourceRepositoryItemWidget:hover {
background-color: @color02;
}
#lblAptSourceName {
font-size: 11pt;
color: @color05;
}
#checkAptSource {
margin-top: 3;
}
/* - APT Source Repository Item Edit - */
#APTSourceEdit {
background-color: @pageContent;
}
/**************************
GNOME SETTINGS PAGE
***************************/
#GnomeSettingsPage QLabel {
font-size: 11pt;
color: @color12;
}
#GnomeSettingsPage QMenu {
background-color: @color01;
}
#GnomeSettingsPage QLabel[accessibleName="general-title"] {
font-size: 12pt;
font-weight: bold;
color: @color03;
border: 0;
border-bottom: 1 solid @color03;
padding-bottom: 5;
}
#GnomeSettingsPage QLabel[accessibleName="title"] {
font-size: 11pt;
font-weight: bold;
color: @color06;
border: 0;
border-bottom: 1 dashed @color06;
padding-bottom: 10;
}
#GnomeSettingsPage QPushButton {
border-radius: 3;
padding: 7 25;
font-size: 11pt;
background-color: @circleChartBackgroundColor;
color: @color07;
}
#GnomeSettingsPage QPushButton:hover,
#GnomeSettingsPage QPushButton:checked {
background-color: @color03;
}
/* --- Unity Settings --- */
#scrollAreaUnityContents {
background-color: @pageContent;
}
/*******************************
SEARCH
*******************************/
#txtSearchInput {
padding: 5 12 5 24;
border-radius: 12;
background: @color01 url(:/static/themes/default/img/search.png) no-repeat left center;
border: 1px solid @color02;
color: @color12;
}
#btnSearchAdvance {
padding: 3;
background-color: @color03;
color: @color07;
}
#lblFoundFilesInfo {
color: @color15;
}
#lblSearchDir {
font-size: 10pt;
color: @color06;
}
#btnBrowseSearchDir {
background-color: @color01;
padding: 6 8;
color: @color05;
}
#advanceSearchPane QSpinBox {
padding: 4 6;
}
#advanceSearchPane QCheckBox[accessibleName="circle"]::indicator {
width: 15px;
height: 15px;
}
#advanceSearchPane QLabel {
color: @color06;
}
#advanceSearchPane QLineEdit {
padding: 4 6;
}
#btnAdvancePaneToggle,
#btnNewHost {
font-size: 10pt;
text-decoration: underline;
color: @color03;
}
#lblHostTitle {
font-size: 11pt;
color: @color12;
}
================================================
FILE: stacer/static/themes/default/style/values.ini
================================================
@pageContent=#1b252f
@sidebar=#15191c
@circleChartBackgroundColor=#212f3c
@historyChartBackgroundColor=#212f3c
@chartLabelColor=#7d8ea0
@chartGridColor=#7d8ea0
@color01=#212f3c
@color02=#263848
@color03=#075ffe
@color04=#8394a6
@color05=#eeeeee
@color06=#7d8ea0
@color07=#ffffff
@color08=#1b252f
@color09=#f44336
@color10=#075fbb
@color11=#dddddd
@color12=#aeb5bf
@color13=#293945
@color14=#314452
@color15=#00eb55
@color16=#00d4ff
================================================
FILE: stacer/static/themes/light/style/style.qss
================================================
/****** LIGHT THEME ******/
/****************
SCROLL BAR
*****************/
QScrollArea {
border: 0;
}
QScrollBar:vertical {
width: 12;
margin: 0 0 0 2;
border-radius: 2;
background-color: transparent;
}
QScrollBar::handle:vertical {
background-color: @color01;
min-height: 20px;
border-radius: 2;
}
QScrollBar::add-line:vertical,
QScrollBar::sub-line:vertical {
height: 0;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical {
border-bottom-right-radius: 2;
border-bottom-left-radius: 2;
background-color: transparent;
}
QScrollBar:horizontal {
height: 12;
margin: 2 0 0 0;
border-radius: 2;
background-color: transparent;
}
QScrollBar::handle:horizontal {
background-color: @color01;
min-width: 20px;
border-radius: 2;
}
QScrollBar::add-line:horizontal,
QScrollBar::sub-line:horizontal {
height: 0;
}
QScrollBar::add-page:horizontal,
QScrollBar::sub-page:horizontal {
border-bottom-right-radius: 2;
border-bottom-left-radius: 2;
background-color: transparent;
}
QAbstractScrollArea::corner {
background: transparent;
}
/*************
QMessageBox
**************/
QMessageBox {
background-color: #212f3c;
}
QMessageBox QLabel {
color: #fefefe;
}
/*************
QMenu
**************/
QMenu {
background-color: @color07;
border-radius: 2;
margin: 3px 5px;
}
QMenu::item {
padding: 2px 30px;
color: @color02;
font-size: 10pt;
}
QMenu::item:selected {
background-color: @color01;
}
QMenu::indicator {
width: 14px;
height: 14px;
}
QMenu::indicator:non-exclusive:unchecked {
image: url(:/static/themes/common/img/un-check.png);
}
QMenu::indicator:non-exclusive:checked {
image: url(:/static/themes/common/img/check.png);
}
/*****************
QRadioButton
******************/
QRadioButton {
color: @color02;
font-size: 11pt;
}
QRadioButton::indicator {
width: 16;
height: 16;
}
QRadioButton::indicator:unchecked {
image: url(:/static/themes/common/img/un-check.png);
}
QRadioButton::indicator:checked {
image: url(:/static/themes/common/img/check.png);
}
/***************
QCheckBox
****************/
QCheckBox::indicator {
width: 44px;
height: 24px;
}
QCheckBox::indicator:checked {
image: url(:/static/themes/common/img/checkbox.png);
}
QCheckBox::indicator:unchecked {
image: url(:/static/themes/common/img/un-checkbox.png);
}
QCheckBox[accessibleName="circle"] {
font-size: 10pt;
color: @color02;
}
QCheckBox[accessibleName="circle"]::indicator {
width: 18px;
height: 18px;
}
QCheckBox[accessibleName="circle"]::indicator:unchecked {
image: url(:/static/themes/common/img/un-check.png);
}
QCheckBox[accessibleName="circle"]::indicator:checked {
image: url(:/static/themes/common/img/check.png);
}
/*****************
QToolTip
******************/
QToolTip {
color: @color01;
background-color: #8394a6;
border: 1px solid #8394a6;
border-radius: 2;
}
/***************
Not Found
***************/
#notFoundWidget, QWidget[accessibleName="notFoundWidget"] {
background: url(:/static/themes/common/img/not-found.png) no-repeat top center;
}
#notFoundWidget QLabel, QWidget[accessibleName="notFoundWidget"] {
color: @color02;
font-size: 13pt;
}
/***************
QSpinBox
***************/
QSpinBox::up-button {
subcontrol-origin: border;
subcontrol-position: top right;
width: 16px;
border-image: url(:/static/themes/common/img/spinup.png) 1;
border-width: 1px;
}
QSpinBox::down-button {
subcontrol-origin: border;
subcontrol-position: bottom right;
width: 16px;
border-image: url(:/static/themes/common/img/spindown.png) 1;
border-width: 1px;
border-top-width: 0;
}
/***************
QSlider
***************/
QSlider::groove:horizontal {
height: 2px;
background: @color08;
margin: 2px 0;
}
QSlider::handle:horizontal {
background-color: @color03;
width: 14px;
height: 14px;
margin: -6px 0;
border-radius: 7px;
}
/***************
QComboBox
***************/
QComboBox {
border: 0;
border-radius: 2;
background-color: @color01;
padding: 4 0 4 10;
font-size: 11pt;
color: @color02;
min-width: 100;
}
QComboBox::drop-down {
background-color: @color01;
subcontrol-position: top right;
width: 14;
padding: 0 5;
color: @color02;
border-left-width: 1px;
border-left-color: @color01;
border-left-style: solid;
image: url(:/static/themes/light/img/down-arrow.png);
border-top-right-radius: 2;
border-bottom-right-radius: 2;
}
QComboBox::down-arrow:on {
background-color: @color01;
color: @color05;
}
QComboBox QAbstractItemView {
background-color: @color01;
border: 0;
}
/***************
QGroupBox
***************/
QGroupBox::title {
font-size: 11pt;
font-weight: bold;
color: @color02;
}
/***************
QTableView
***************/
QTableView {
background-color: transparent;
selection-color: @color02;
color: @color02;
font-size: 10pt;
gridline-color: @pageContent;
border-radius: 2;
}
QTableView::item {
font-size: 11pt;
color: @color02;
padding: 6 0 6 -10;
background-color: @color01;
}
QTableView::item:selected {
background-color: @color07;
}
QHeaderView::section {
background-color: @color07;
border-width: 1 1 1 0;
border-style: solid;
border-color: @pageContent;
font-size: 11pt;
color: @color06;
padding-left:10;
}
QHeaderView::up-arrow {
image: url(:/static/themes/default/img/asc.png);
}
QHeaderView::down-arrow {
image: url(:/static/themes/default/img/dsc.png);
}
/******************
QMainWindow
*******************/
QMainWindow * {
font-family: "Ubuntu";
}
QLineEdit,
QPlainTextEdit,
QSpinBox {
border-radius: 2;
padding: 6;
background-color: @color01;
font-size: 10pt;
color: @color02;
}
QPushButton {
border-radius: 2;
font-size: 11pt;
}
QPushButton[accessibleName="danger"] {
padding: 6 16;
background-color: @color11;
color: @color05;
}
QPushButton[accessibleName="danger"]:hover {
background-color: #c0392b;
}
QPushButton[accessibleName="primary"] {
padding: 6 16;
background-color: @color03;
color: @color05;
}
QPushButton[accessibleName="primary"]:hover {
background-color: @color10;
}
QLabel[accessibleName="dialog-title"] {
color: @color02;
font-size: 11pt;
padding-bottom: 8;
border: 0;
border-bottom: 1 solid @color02;
}
#lblErrorMsg {
color: @color11;
}
/**************
Sidebar
***************/
#sidebar {
background-color: @sidebar;
min-width: 60;
}
#sidebar QPushButton {
border: 0px;
height: 42;
border-style: solid;
color: @color01;
margin: 0 0;
border-radius: 0;
}
#sidebar QPushButton:checked,
#sidebar QPushButton:hover {
background-color: @color03;
}
#pageTitle {
color: @color02;
padding: 5 0 8 0;
margin: 5 10;
border: 0;
border-bottom: 1 solid @color09;
}
#pageContent {
background-color: @pageContent;
}
#btnDash {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/dash.png);
}
#btnSystemCleaner {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/cleaner.png);
}
#btnStartupApps {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/startup-apps.png);
}
#btnSearch {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/search.png);
}
#btnServices {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/services.png);
}
#btnProcesses {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/process.png);
}
#btnUninstaller {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/uninstaller.png);
}
#btnResources {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/resources.png);
}
#btnHelpers {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/helpers.png);
}
#btnAptSourceManager {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/ppa-manager.png);
}
#btnGnomeSettings {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/gnome.png);
}
#btnSettings {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/settings.png);
}
#btnFirewall {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/firewall.png);
}
#btnFeedback {
qproperty-icon: url(:/static/themes/default/img/sidebar-icons/feedback.png);
}
/*********************
DASHBOARD PAGE
**********************/
/* - Circle Bar - */
#widgetCircleBar {
background-color: @color01;
border-radius: 1;
}
#lblCircleChartTitle,
#lblCircleChartValue {
color: @color02;
font-size: 13pt;
margin: 0;
}
/* - Line Bar - */
#lineChartWidget {
background-color: @color01;
border-radius: 1;
}
#lblLineChartTitle {
color: @color02;
font-size: 13pt;
}
#lblLineChartValue {
color: @color02;
font-size: 13pt;
}
#lblLineChartTotal {
color: @color02;
font-size: 11pt;
}
#lineChartProgress {
background-color: @pageContent;
border: 0;
border-radius: 0;
}
#lineChartProgress::chunk {
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 #3498db, stop:1 #2980b9);
}
/* - System Info - */
#lblSystemInfoTitle {
color: @color02;
font-size: 13pt;
padding-left: 5;
}
#listViewSystemInfo {
border: 0;
background-color: transparent;
font-size: 12pt;
color: @color02;
}
/**************************
SYSTEM CLEANER PAGE
***************************/
#SystemCleanerPage QCheckBox[accessibleName=circle]::indicator {
width: 26;
height: 26;
}
#cleanerCategories QLabel,
#checkSelectAllSystemScan {
font-size: 11pt;
color: @color02;
}
/* - System Scan Button - */
#SystemCleanerPage #btnScan {
border: 0;
background: url(:/static/themes/light/img/scan.png) no-repeat center;
}
#SystemCleanerPage #btnScan:hover {
background: url(:/static/themes/light/img/scan-active.png) no-repeat center;
}
/* - System Clean Button - */
#SystemCleanerPage #btnClean {
border: 0;
background: url(:/static/themes/light/img/clean.png) no-repeat center;
}
#SystemCleanerPage #btnClean:hover {
background: url(:/static/themes/light/img/clean-active.png) no-repeat center;
}
/* - System Scan Results - */
#btnBackToCategories {
border: 0;
font-size: 11pt;
color: @color03;
}
#treeWidgetScanResult {
border: 1 solid @color01;
background-color: @color01;
border-radius: 2;
}
#treeWidgetScanResult QHeaderView::section {
border-top: 1;
}
#treeWidgetScanResult::item {
border-bottom: 1 solid @pageContent;
padding: 7 3;
font-size: 11pt;
color: @color02;
}
#treeWidgetScanResult::indicator {
width: 14;
height: 14;
}
#treeWidgetScanResult::indicator:checked {
image: url(:/static/themes/common/img/check.png);
}
#treeWidgetScanResult::indicator:unchecked {
image: url(:/static/themes/common/img/un-check.png);
}
#treeWidgetScanResult::branch:has-children:!has-siblings:closed,
#treeWidgetScanResult::branch:closed:has-children:has-siblings {
border-image: none;
image: url(:/static/themes/light/img/right-arrow.png);
padding: 4;
}
#treeWidgetScanResult::branch:open:has-ch ildren:!has-siblings,
#treeWidgetScanResult::branch:open:has-children:has-siblings {
border-image: none;
image: url(:/static/themes/light/img/down-arrow.png);
padding: 4;
}
#treeWidgetScanResult::branch {
border-bottom: 1 solid @pageContent;
}
#lblRemovedTotalSize {
font-size: 11pt;
color: @color04;
}
/**************************
STARTUP APPS PAGE
***************************/
#listWidgetStartup {
background-color: transparent;
}
#lblStartupAppsTitle {
color: @color03;
padding: 10 0 10 20;
}
/* - Startup App - */
#widgetStartupApp {
border-radius: 2;
background-color: @color01;
}
#lblStartupAppIcon {
image: url(:/static/themes/light/img/app.png);
}
#widgetStartupApp:hover {
background-color: @color07;
}
#widgetStartupApp #lblStartupAppName {
font-size: 11pt;
color: @color02;
}
#checkStartup {
margin-top: 3;
}
#widgetStartupApp #btnDeleteStartupApp {
qproperty-icon: url(:/static/themes/light/img/trash.png);
border: 0;
}
#widgetStartupApp #btnEditStartupApp {
qproperty-icon: url(:/static/themes/light/img/edit.png);
border: 0;
margin-bottom: 2;
}
/* - Startup App Edit - */
#StartupAppEdit {
background-color: @pageContent;
}
/*********************
SERVICES PAGE
**********************/
#ServicesPage QListWidget {
background-color: transparent;
}
#lblServicesTitle {
font-size: 11pt;
color: @color03;
padding: 10 0;
}
/* - Service Item - */
#serviceItemWidget {
border-radius: 2;
background-color: @color01;
}
#serviceItemWidget:hover {
background-color: @color07;
}
#lblServiceIcon {
image: url(:/static/themes/default/img/service.png);
}
#ServiceItem #lblServiceName {
font-size: 11pt;
color: @color02;
}
#ServiceItem #lblServiceDescription {
font-size: 10pt;
color: @color06;
}
#lblServiceStartupImg {
image: url(:/static/themes/default/img/power.png);
}
#lblSystemRunningImg {
image: url(:/static/themes/default/img/run.png);
}
/*********************
PROCESSES PAGE
**********************/
#lblProcessTitle {
color: @color03;
padding: 10 0;
font-size: 11pt;
}
#checkAllProcesses {
margin-top: 2;
color: @color02;
font-size: 10pt;
}
#checkAllProcesses::indicator {
width: 14;
height: 14;
}
#txtProcessSearch {
width: 150;
padding: 4 12;
border-radius: 12;
background: @color01 url(:/static/themes/default/img/search.png) no-repeat right center;
border: 1px solid @color07;
color: @color02;
}
#lblRefresh {
color: @color02;
font-size: 10pt;
}
#sliderRefresh {
margin-top: 3;
}
/***********************
UNINSTALLER PAGE
************************/
#UninstallerPage #nav QPushButton {
border-radius: 3;
padding: 5 12;
font-size: 10pt;
background-color: @color02;
color: @color07;
}
#UninstallerPage #nav QPushButton:hover,
#UninstallerPage #nav QPushButton:checked {
background-color: @color03;
}
#lblPackagesTitle {
color: @color03;
padding: 10 0;
font-size: 11pt;
}
#txtPackageSearch,
#txtSearchAptSource {
padding: 4 12;
border-radius: 12;
background: @color01 url(:/static/themes/default/img/search.png) no-repeat right center;
border: 1px solid @color07;
color: @color08;
}
#listWidgetPackages, #listWidgetSnapPackages
border:0;
background-color: transparent;
font-size:11pt;
}
#listWidgetPackages::indicator, #listWidgetSnapPackages::indicator {
min-width: 16;
min-height: 16;
}
#listWidgetPackages::indicator:unchecked, #listWidgetSnapPackages::indicator:unchecked {
image: url(:/static/themes/common/img/un-check.png);
}
#listWidgetPackages::indicator:checked, #listWidgetSnapPackages::indicator:checked {
image: url(:/static/themes/default/img/check.png);
}
#listWidgetPackages::item, #listWidgetSnapPackages::item {
border-radius: 2;
min-height: 40;
max-height: 40;
background-color: @color01;
}
#listWidgetPackages::item:text, #listWidgetSnapPackages::item:text {
color: @color02;
padding-left: 15;
}
#listWidgetPackages::item:selected, #listWidgetSnapPackages::item:selected {
background-color: @color07;
border: 0;
}
#listWidgetPackages::item:hover, #listWidgetSnapPackages::item:hover {
background-color: @color07;
}
/***************
HISTORIES
****************/
#charts {
background-color: @pageContent;
}
#lblHistoryTitle {
font-size: 11pt;
margin: 6 0 10 0;
color: @color02;
}
#checkHistoryTitle::indicator {
width: 16;
height: 16;
}
#checkHistoryTitle::indicator:unchecked {
image: url(:/static/themes/light/img/fit.png);
}
#checkHistoryTitle::indicator:checked {
image: url(:/static/themes/light/img/collapse.png);
}
/****************
SETTINGS
*****************/
#SettingsPage QLabel {
font-size: 11pt;
color: @color02;
}
#lblCreatedBy {
font-size: 9pt;
color: @color06;
}
/*****************
UPDATE BAR
******************/
#widgetUpdateBar {
background-color: @color03;
border-radius: 2;
}
#lblUpdateBarText {
font-size: 10pt;
color: @color05;
}
#btnDownloadUpdate {
background-color: @sidebar;
padding: 4 10;
}
/**************************
FEEDBACK
***************************/
#Feedback {
background-color: @pageContent;
}
/**************************
APT SOURCE MANAGER PAGE
***************************/
#listWidgetAptSources {
background-color: transparent;
}
#lblAptSourceTitle {
font-size: 11pt;
color: @color03;
padding: 10 0 5 20;
}
#txtAptSource {
padding: 7;
}
#lblAptSourceSelectInfo {
margin-top: 5;
font-size: 10pt;
color: @color05;
}
#listWidgetAptSources {
selection-background-color: @color03;
}
/* - APT Source Repository Item - */
#aptSourceRepositoryItemWidget {
border-radius: 2;
background-color: @color01;
}
#aptSourceRepositoryItemWidget:hover {
background-color: @color07;
}
#lblAptSourceIcon {
image: url(:/static/themes/light/img/ppa-repository.png);
}
#lblAptSourceName {
font-size: 11pt;
color: @color02;
}
#checkAptSource {
margin-top: 3;
}
/* - APT Source Repository Item Edit - */
#APTSourceEdit {
background-color: @pageContent;
}
/**************************
GNOME SETTINGS PAGE
***************************/
#GnomeSettingsPage QLabel {
font-size: 11pt;
color: @color02;
}
#GnomeSettingsPage QMenu {
background-color: @color01;
}
#GnomeSettingsPage QLabel[accessibleName="general-title"] {
font-size: 12pt;
font-weight: bold;
color: @color03;
border: 0;
border-bottom: 1 solid @color03;
padding-bottom: 5;
}
#GnomeSettingsPage QLabel[accessibleName="title"] {
font-size: 11pt;
font-weight: bold;
color: @color02;
border: 0;
border-bottom: 1 dashed @color02;
padding-bottom: 10;
}
#GnomeSettingsPage QPushButton {
border-radius: 3;
padding: 7 25;
font-size: 11pt;
background-color: @color02;
color: @color07;
}
#GnomeSettingsPage QPushButton:hover,
#GnomeSettingsPage QPushButton:checked {
background-color: @color03;
}
/* --- Unity Settings --- */
#scrollAreaUnityContents {
background-color: @pageContent;
}
/*******************************
SEARCH
*******************************/
#txtSearchInput {
padding: 5 12 5 24;
border-radius: 12;
background: @color01 url(:/static/themes/default/img/search.png) no-repeat left center;
border: 1px solid @color02;
color: @color12;
}
#btnSearchAdvance {
padding: 3;
background-color: @color03;
color: @color07;
}
================================================
FILE: stacer/static/themes/light/style/values.ini
================================================
@pageContent=#ecf0f1
@sidebar=#15191c
@circleChartBackgroundColor=#ffffff
@historyChartBackgroundColor=#ffffff
@chartLabelColor=#7d8ea0
@chartGridColor=#8394a6
@color01=#fdfdfd
@color02=#7d8ea0
@color03=#075ffe
@color04=#00eb55
@color05=#eeeeee
@color06=#00d4ff
@color07=#f6fafd
@color08=#aeb5bf
@color09=#8394a6
@color10=#075fbb
@color11=#f44336
================================================
FILE: stacer/static/themes.json
================================================
[
{"value" : "default", "text": "Default"},
{"value" : "light", "text": "Light"}
]
================================================
FILE: stacer/static.qrc
================================================