From 51659c7a42802b39cc5920cd4a48b5450da30963 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Tue, 15 Jul 2014 06:11:22 +0400 Subject: [PATCH] added --set-opts --- sources/CMakeLists.txt | 27 ++++++++++++++++----------- sources/gui/netctl-gui.1 | 10 +++++++--- sources/gui/src/language.cpp | 23 +++++++++++++++++++++-- sources/gui/src/language.h | 8 ++++++-- sources/gui/src/main.cpp | 22 ++++++++++++++++++++-- sources/gui/src/mainwindow.cpp | 25 +++++++++++++++++++++++++ sources/gui/src/mainwindow.h | 2 ++ sources/gui/src/netctlautowindow.cpp | 1 + sources/gui/src/settingswindow.cpp | 1 + sources/version.h.in | 1 + 10 files changed, 100 insertions(+), 20 deletions(-) diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index f0350e1..2f1949b 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.0) +cmake_minimum_required (VERSION 2.8) cmake_policy (SET CMP0003 OLD) cmake_policy (SET CMP0002 OLD) @@ -14,6 +14,7 @@ set (PROJECT_VERSION_MINOR 2) set (PROJECT_VERSION_PATCH 0) set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) string (TIMESTAMP CURRENT_DATE UTC) +string (REGEX REPLACE "T|Z" " " CURRENT_DATE ${CURRENT_DATE}) string (TIMESTAMP CURRENT_YEAR "%Y") message (STATUS "Project: ${PROJECT_NAME}") @@ -22,25 +23,29 @@ message (STATUS "Build date: ${CURRENT_DATE}") # install options option (USE_QT5 "Use Qt5 instead of Qt4" ON) +option (BUILD_DOCS "Build documentation" OFF) option (BUILD_GUI "Build GUI" ON) option (BUILD_LIBRARY "Build library" ON) option (BUILD_DATAENGINE "Build data engine" ON) option (BUILD_PLASMOID "Build plasmoid" ON) +if (BUILD_DOCS) + set (BUILD_LIBRARY ON) +endif () if (BUILD_GUI) - set (BUILD_LIBRARY ON) + set (BUILD_LIBRARY ON) endif () if (BUILD_PLASMOID) - set (BUILD_DATAENGINE ON) + set (BUILD_DATAENGINE ON) endif () # flags if (CMAKE_COMPILER_IS_GNUCXX) - set (ADD_CXX_FLAGS "-Wall") - set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}") - set (CMAKE_CXX_FLAGS_DEBUG "-g -O0") - set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") + set (ADD_CXX_FLAGS "-Wall") + set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}") + set (CMAKE_CXX_FLAGS_DEBUG "-g -O0") + set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") else () - message (STATUS "Unknown compiler") + message (STATUS "Unknown compiler") endif () configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h) @@ -55,11 +60,11 @@ if (BUILD_LIBRARY) add_subdirectory (${PROJECT_LIBRARY}) endif() if (BUILD_GUI) - add_subdirectory (gui) + add_subdirectory (gui) endif () if (BUILD_DATAENGINE) - add_subdirectory (dataengine) + add_subdirectory (dataengine) endif () if (BUILD_PLASMOID) - add_subdirectory (plasmoid) + add_subdirectory (plasmoid) endif () diff --git a/sources/gui/netctl-gui.1 b/sources/gui/netctl-gui.1 index 96f8ed3..22f60f2 100644 --- a/sources/gui/netctl-gui.1 +++ b/sources/gui/netctl-gui.1 @@ -6,7 +6,8 @@ netctl-gui is a graphical interface for netctl [ --about ] [ --netctl-auto ] [ --settings ] [ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ] [ -s PROFILE | --select PROFILE ] - [ -d | --debug ] [ --default ] [ -t NUM | --tab NUM ] + [ -d | --debug ] [ --default ] [ --set-opts OPTIONS ] + [ -t NUM | --tab NUM ] [ -v | --version ] [ -i | --info ] [ -h | --help] .SH DESCRIPTION Graphical user interface for netctl written on C++ using Qt toolkit. Provides shared library for interaction with netctl and Plasmoid and DataEngine for KDE. @@ -25,10 +26,10 @@ show settings window select ESSID ESSID. This option will set tab to 3 automatically .TP -o, --open PROFILE -open profile PROFILE. This option will set tab to 2 automatically. +open profile PROFILE. This option will set tab to 2 automatically .TP -s, --select PROFILE -select profile PROFILE. This option will set tab to 1 automatically. +select profile PROFILE. This option will set tab to 1 automatically .TP -d, --debug print debug information @@ -36,6 +37,9 @@ print debug information --default start with default settings .TP +--set-opts OPTIONS +set options OPTIONS for this run, comma separated. Example "LANGUAGE=en,NETCTL_PATH=/usr/bin/netctl" +.TP -t, --tab NUM open a tab with number NUM .TP diff --git a/sources/gui/src/language.cpp b/sources/gui/src/language.cpp index ccf943f..4a3f069 100644 --- a/sources/gui/src/language.cpp +++ b/sources/gui/src/language.cpp @@ -22,7 +22,7 @@ #include -Language::Language(const QString configPath) +Language::Language() { } @@ -41,8 +41,13 @@ QString Language::checkLanguage(const QString language, const QString defaultLan } -QString Language::defineLanguage(const QString configPath) +QString Language::defineLanguage(const QString configPath, const QString options) { + QMap optionsDict = parseOptions(options); + if (optionsDict.contains(QString("LANGUAGE"))) + if (getAvailableLanguages().contains(optionsDict[QString("LANGUAGE")])) + return optionsDict[QString("LANGUAGE")]; + QString language; language = defineLanguageFromFile(configPath); if (language.isEmpty()) @@ -92,3 +97,17 @@ QStringList Language::getAvailableLanguages() return languages; } + + +QMap Language::parseOptions(const QString options) +{ + QMap optionsDict; + for (int i=0; i