86 Commits

Author SHA1 Message Date
bb7af8da40 update russian translation 2014-07-15 21:26:38 +04:00
81ff9340cc fix build 2014-07-15 21:23:03 +04:00
3d040e9bab small text update / prerelease 1.2.0 2014-07-15 20:56:46 +04:00
3542901781 added flag --config
updated translations
2014-07-15 20:40:20 +04:00
8b91f43f0b added doxygen documentation building 2014-07-15 20:01:19 +04:00
7e622ad33b added all documentation 2014-07-15 17:31:29 +04:00
48a879bd71 added documentation to wpasupinteract 2014-07-15 15:08:55 +04:00
bc8655aaeb add documentation to netctlprofile 2014-07-15 13:32:22 +04:00
05f9759d47 small edit of about.ui 2014-07-15 13:05:16 +04:00
51659c7a42 added --set-opts 2014-07-15 06:11:22 +04:00
39b8ff834f added man page 2014-07-14 22:43:17 +04:00
ea522b3864 added flags 2014-07-14 21:57:29 +04:00
79fc70efa1 rewrite errorwindow 2014-07-14 20:37:46 +04:00
5e1a4be134 add openProfile 2014-07-14 19:36:14 +04:00
63ae04cd8d edit changelog 2014-07-14 19:11:22 +04:00
4fb02058b1 added workarounds 2014-07-14 19:07:17 +04:00
e02a6a8ce1 update plasmoid translations 2014-07-14 18:35:15 +04:00
2f40ae7913 added about window 2014-07-14 18:31:35 +04:00
2e35cd356e edited cmake files 2014-07-14 14:22:04 +04:00
341a19a955 fix profile reading 2014-07-14 14:03:38 +04:00
f7e39c7834 edited profile reading 2014-07-13 15:51:44 +04:00
7660deb787 end of refactoring 2014-07-13 11:45:20 +04:00
3fb847a7b6 edited main.cpp 2014-07-13 11:26:42 +04:00
dbb9ba70c4 end of refactoring of the widgets
refactoring of settingswindow
2014-07-13 10:48:46 +04:00
ceb7f3bd0f edited configuration interface 2014-07-13 09:56:07 +04:00
8ce4b03399 end of refactoring of the library 2014-07-13 09:44:20 +04:00
44f0b6a06a refactoring of netctlprofile 2014-07-13 00:13:24 +04:00
b37272d875 refactoring of netctlinteract 2014-07-12 23:41:52 +04:00
ea91aa4ca4 refactoring of dataengine and plasmoid
update plasmoid translations
2014-07-12 23:00:59 +04:00
cc250a643a small update of documentation 2014-07-12 22:31:08 +04:00
9b01fcd4e1 refactoring of the configuration interface 2014-07-12 22:15:39 +04:00
021a870220 add support of netctl-auto to plasmoid and dataengine 2014-07-12 18:19:19 +04:00
ae001b4d7f added netctl-auto support to profiles 2014-07-12 13:36:06 +04:00
ec6834d90e edited todo list 2014-07-12 13:25:40 +04:00
de22663156 add gui for netctl-auto 2014-07-12 13:23:43 +04:00
c3f090d9a0 intermediate commit 2014-07-11 23:31:27 +04:00
d17543a075 add null translation file 2014-07-11 20:59:01 +04:00
ace3a141e4 change lineEdit to comboBox
add clear() function to profile tab
2014-07-11 11:06:01 +04:00
06bd1ce198 remove soversioned 2014-07-11 10:26:16 +04:00
9852fb8f68 detached backend from frontend 2014-07-11 09:56:48 +04:00
eccb6b6578 fix settings 2014-07-11 07:03:53 +04:00
c1457d3ef0 add language class 2014-07-11 07:00:16 +04:00
6dab355d87 added all icons 2014-07-10 14:33:04 +04:00
e81f7714f9 added icons
changes in the project architecture
2014-07-10 13:48:21 +04:00
2a3011bdef edited configuration interface of the plasmoid 2014-07-10 10:44:33 +04:00
bf799ce061 add contextual actions to wifi tab 2014-07-10 10:30:26 +04:00
a845e32960 add contextual actions to the main table 2014-07-10 10:15:11 +04:00
028546540c add debug flug 2014-07-10 09:44:23 +04:00
2bf1d0f78e update pkgbuilds 2014-06-20 02:22:44 +04:00
cce4ef4811 add support of hidden network (test) 2014-06-04 00:18:04 +04:00
4051d2f2c8 add support of macvlan
add support of profile removal
2014-06-02 00:43:13 +04:00
8a031f2183 added todo list 2014-05-28 10:17:10 +04:00
7c013310ab fix default tabnumber 2014-05-22 01:29:13 +04:00
d5f0bbc3bf release 1.1.0 2014-05-21 19:50:12 +04:00
cb033140ac added menu title 2014-05-17 08:46:55 +04:00
d582445597 release 1.1.0 2014-05-14 23:55:13 +04:00
3506bd46a9 release 1.0.6 2014-04-19 12:09:58 +04:00
727619bb85 fix rel 2014-04-14 01:23:30 +04:00
d59345c0e4 Release 1.0.5 2014-04-14 01:19:36 +04:00
4c1685164c updated translations 2014-04-12 18:58:36 +04:00
d515e4a51f added cppcheck to gui 2014-04-12 16:34:04 +04:00
2778f654ef refactoring of dataengine 2014-04-12 16:31:19 +04:00
92ec04cae1 refactoring of plasmoid
added function to start wifi menu
2014-04-12 15:27:14 +04:00
501151828d pkgbuild fixes 2014-04-10 12:14:10 +04:00
4a788aa05f edited gitignore 2014-04-10 11:39:54 +04:00
2cf91930f8 added pkgbuilds for different builds 2014-04-10 11:34:22 +04:00
4bb5d4925d F*CKING icu 2014-04-07 03:02:50 +04:00
10d44f786e removed plasmoid only =) 2014-04-07 02:32:07 +04:00
c69ff2165e removed cmakelists from root 2014-04-07 02:29:15 +04:00
4d455d93e8 added only plasmoid archive 2014-04-07 02:28:07 +04:00
046ae119a3 updated screenshots 2014-04-07 00:58:29 +04:00
b958d0b78b edited readme 2014-04-07 00:49:53 +04:00
7529cd7af0 edited changelog 2014-04-07 00:41:27 +04:00
7e85f1f933 Release 1.0.4 2014-04-07 00:39:28 +04:00
c4c407542f added notifications 2014-04-07 00:31:42 +04:00
cc2b3faf85 edited pkgbuild for the current version 2014-04-06 23:34:07 +04:00
b983f4424e commit before merging 2014-04-06 23:22:13 +04:00
72782a40c2 added qt5 build 2014-04-06 22:59:12 +04:00
9a5b61be4e updated pkgbuild 2014-04-06 19:08:21 +04:00
7d7a24c23d small changes
changed license notes since project had beed renamed to netctl-gui
2014-04-06 19:02:52 +04:00
1366852a62 refactoring of plasmoid 2014-04-06 18:45:56 +04:00
b1e455b976 changed de configuration 2014-04-06 13:08:32 +04:00
1a7d3cb50a added ui translation to plasmoid 2014-04-06 12:34:31 +04:00
762e43c0d6 fixed size 2014-03-30 19:01:02 +04:00
f02e553164 fix 2014-03-28 21:51:53 +04:00
44a5ee9083 edited readme 2014-03-28 21:51:11 +04:00
120 changed files with 14875 additions and 3681 deletions

4
.gitignore vendored
View File

@ -14,11 +14,13 @@
# Source archive
*.tar.xz
*.tar.gz
*.sig
# Build directory
build/
sources/build/
tmp/
usr/
# translations
*.qm

2
AUTHORS Normal file
View File

@ -0,0 +1,2 @@
Current developers:
Evgeniy Alekseev aka arcanis <esalexeev (at) gmail (dot) com>

60
CHANGELOG Normal file
View File

@ -0,0 +1,60 @@
Ver.1.2.0:
+ [all] added icons
+ [all] added support of netctl-auto
+ [gui] added suppoort of macvlan
+ [gui] added ability to remove profile
+ [gui] added support of hidden wifi network
+ [gui] added contextual menu to tables
+ [gui] added actions menu
+ [gui] added clear() function to profileTab
+ [gui] added about window
+ [gui] more command line options
+ [gui] added workaround for wireless-wep example
+ [lib] detached backend from frontend
+ [lib] added error checking
+ [lib] added doxygen documentation
+ [plasmoid] added dataengine configuration
+ [plasmoid] added about window
* [all] changes in the project architecture
* [all] refactoring
* [gui] more debug information
* [gui] changed lineEdit_profile to comboBox
* [gui] refactoring of configuration interface
* [gui] changed setting of the interface to profile tab
* [gui] rewrited ErrorWindow class
* [lib] more debug information
* [lib] rewrited getSettingsFromProfile() function
* [plasmoid] edited configuration interface
* [plasmoid] changed double click event to click event
Ver.1.1.0 (netctl-1.7 update):
+ [gui] added frequency
+ [plasmoid] added menu title
* [dataengine] changed definition if profile is enabled
* [gui] changed definition if profile is enabled
Ver.1.0.6:
* [gui] fix error checking
Ver.1.0.5:
+ [plasmoid] added "Start WiFi menu" function
* [plasmoid] refactoring
* [plasmoid] edited icon
Ver.1.0.4:
+ [gui] added Qt5 gui (by default)
+ [plasmoid] added notifications
* [plasmoid] fix run command with sudo from plasmoid
Ver.1.0.3:
+ [plasmoid] edited russian translation
* [all] refactoring
Ver.1.0.2:
* [plasmoid] fix layout margins
Ver.1.0.1:
- [all] removed scripts
Ver.1.0:
First release

View File

@ -631,7 +631,7 @@ 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.
netctl-plasmoid
netctl-gui
Copyright (C) 2014 Evgeniy Alekseev
This program is free software: you can redistribute it and/or modify
@ -652,7 +652,7 @@ 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:
netctl-plasmoid Copyright (C) 2014 Evgeniy Alekseev
netctl-gui Copyright (C) 2014 Evgeniy Alekseev
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.

View File

@ -1,39 +1,86 @@
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
# comment out needed line if you dont need this component
#_build_gui=0
#_build_plasmoid=0
pkgname=netctl-gui
pkgver=1.0.1
pkgbase=netctl-gui
pkgname=('netctl-gui' 'netctl-gui-qt4' 'kdeplasma-applets-netctl-gui')
pkgver=1.2.0
pkgrel=1
pkgdesc="Qt4 GUI for netctl. Provides a plasmoid for KDE4"
pkgdesc="Qt4/Qt5 GUI for netctl. Also provides a widget for KDE"
arch=('i686' 'x86_64')
url="http://arcanis.name/projects/netctl-gui"
license=('GPLv3')
depends=('netctl' 'qt4')
makedepends=('automoc4' 'cmake' 'desktop-file-utils' 'xdg-utils')
license=('GPL3')
makedepends=('automoc4' 'cmake' 'kdelibs' 'qt5-base' 'qt5-tools')
optdepends=('kdebase-runtime: sudo support'
'kdeplasma-applets-netctl-gui: KDE widget'
'sudo: sudo support'
'wpa_actiond: netctl-auto support'
'wpa_supplicant: wifi support')
source=("https://github.com/arcan1s/netctlplasmoid/releases/download/V.${pkgver}/${pkgname}-${pkgver}-src.tar.xz")
install="${pkgname}.install"
md5sums=('b2bdfabd96a436823c9d46fc0d58bbe8')
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
install="${pkgbase}.install"
md5sums=('5b3105a64bc162d30a41a2b3bcb06f0a')
# flags
_cmakekeys="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release"
[[ ${_build_gui} == 0 ]] && _cmakekeys=${_cmakekeys}" -DBUILD_GUI:BOOL=0"
[[ ${_build_plasmoid} == 0 ]] && _cmakekeys=${_cmakekeys}" -DBUILD_DATAENGINE:BOOL=0 -DBUILD_PLASMOID:BOOL=0" || depends[1]='kdebase-workspace'
prepare() {
rm -rf "${srcdir}/"{build-plasmoid,build-qt4,build-qt5}
mkdir "${srcdir}/"{build-plasmoid,build-qt4,build-qt5}
}
build() {
rm -rf "${srcdir}/build"
mkdir "${srcdir}/build"
cd "${srcdir}/build"
cmake ${_cmakekeys} "../${pkgname}"
cd "${srcdir}/build-plasmoid"
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DOCS:BOOL=0 \
-DBUILD_GUI:BOOL=0 \
-DBUILD_LIBRARY:BOOL=0 \
"../${pkgbase}"
make
cd "${srcdir}/build-qt4"
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DOCS:BOOL=0 \
-DBUILD_DATAENGINE:BOOL=0 \
-DBUILD_PLASMOID:BOOL=0 \
-DUSE_QT5:BOOL=0 \
"../${pkgbase}"
make
cd "${srcdir}/build-qt5"
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DOCS:BOOL=0 \
-DBUILD_DATAENGINE:BOOL=0 \
-DBUILD_PLASMOID:BOOL=0 \
"../${pkgbase}"
make
}
package() {
cd "${srcdir}/build"
package_kdeplasma-applets-netctl-gui() {
pkgdesc="A plasmoid, which interacts with netctl. A part of netctl-gui"
depends=('netctl' 'kdebase-workspace')
optdepends=('kdebase-runtime: sudo support'
'netctl-gui: graphical front-end'
'netctl-gui-qt4: graphical front-end'
'sudo: sudo support')
cd "${srcdir}/build-plasmoid"
make DESTDIR="${pkgdir}" install
}
package_netctl-gui() {
pkgdesc="Qt5 graphical front-end for netctl. A part of netctl-gui"
depends=('netctl' 'qt5-base' 'xdg-utils')
provides=('netctl-gui-qt4')
conflicts=('netctl-gui-qt4')
cd "${srcdir}/build-qt5"
make DESTDIR="${pkgdir}" install
}
package_netctl-gui-qt4() {
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
depends=('netctl' 'qt4')
provides=('netctl-gui')
conflicts=('netctl-gui')
cd "${srcdir}/build-qt4"
make DESTDIR="${pkgdir}" install
}

View File

@ -1,4 +1,72 @@
netctl-plasmoid
===============
Netctl GUI
==========
[Homepage](http://arcanis.name/projects/netctl-gui)
Information
-----------
Qt4/Qt5 graphical interface for netctl. It may work with profiles and may create new profiles. Also it may create a connection to WiFi. Moreover, it provides a widget and DataEngine for KDE.
**NOTE** [LOOKING FOR TRANSLATORS!](https://github.com/arcan1s/netctl-gui/issues/3)
Configuration
-------------
It is recommended to use graphical interface for widget and DataEngine configuration. All settings of GUI are stored in `$HOME/.config/netctl-gui.conf`. It is highly recommended to edit it from graphical interface.
Instruction
===========
Dependencies
------------
* netctl
* qt5-base (if Qt5 is used) or qt4 (if Qt4 is used)
Optional dependencies
---------------------
* kdebase-workspace (widget)
* sudo (sudo support)
* wpa_actiond (netctl-auto support)
* wpa_supplicant (WiFi support)
Make dependencies
-----------------
* automoc4
* cmake
* qt5-tools (if Qt5 is used)
Installation
------------
* download sources
* extract it and install the application:
cd /path/to/extracted/archive
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ../
make
sudo make install
Available cmake flags:
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
* `-DBUILD_GUI:BOOL=0` - do not build GUI
* `-DBUILD_LIBRARY:BOOL=0` - do not build library
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
Additional information
======================
TODO (wish list)
----------------
Links
-----
* [Homepage](http://arcanis.name/projects/netctl-gui)
* Page on [kde-apps](http://kde-apps.org/content/show.php?content=164490)
* Archlinux [AUR](https://aur.archlinux.org/pkgbase/netctl-gui/) package

View File

@ -2,21 +2,19 @@
ARCHIVE="netctl-gui"
SRCDIR="sources"
FILES="LICENSE README.md"
IGNORELIST="gui/resources/translations/english.qm gui/resources/translations/russian.qm"
FILES="AUTHORS CHANGELOG COPYING README.md"
IGNORELIST="build en.qm ru.qm netctl-gui.qm *.cppcheck"
VERSION=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $3}' | cut -c 1)
# create archive
[[ -e ${ARCHIVE}-${VERSION}.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
[[ -e ${ARCHIVE}-${VERSION}-src.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
cp -r "${SRCDIR}" "${ARCHIVE}"
for FILE in ${FILES[*]}; do cp "$FILE" "${ARCHIVE}"; done
for FILE in ${IGNORELIST[*]}; do rm -f "${ARCHIVE}/${FILE}"; done
tar cvJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}" > /dev/null
for FILE in ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done
for FILE in ${IGNORELIST[*]}; do find "${ARCHIVE}" -name "${FILE}" -exec rm -rf {} \;; done
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
rm -rf "${ARCHIVE}"
# update md5sum
MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 51 KiB

BIN
screenshots/gui_main.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
screenshots/gui_profile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

BIN
screenshots/gui_wifi.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@ -5,41 +5,67 @@ cmake_policy (SET CMP0002 OLD)
cmake_policy (SET CMP0011 NEW)
cmake_policy (SET CMP0015 NEW)
project (netctl-plasmoid)
project (netctl-gui)
set (PROJECT_AUTHOR "Evgeniy Alekseev")
set (PROJECT_CONTACT "esalexeev@gmail.com")
set (PROJECT_LICENSE "GPLv3")
set (PROJECT_VERSION_MAJOR 1)
set (PROJECT_VERSION_MINOR 0)
set (PROJECT_VERSION_PATCH 1)
set (PROJECT_VERSION_MINOR 2)
set (PROJECT_VERSION_PATCH 0)
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
string (TIMESTAMP CURRENT_YEAR "%Y")
message (STATUS "Project: ${PROJECT_NAME}")
message (STATUS "Version: ${PROJECT_VERSION}")
message (STATUS "Build date: ${CURRENT_DATE}")
# install options
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
# components
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_GUI)
set (BUILD_LIBRARY ON)
endif ()
if (BUILD_PLASMOID)
set (BUILD_DATAENGINE ON)
endif ()
# documentation
option (BUILD_DOCS "Build documentation and install headers" ON)
if (BUILD_DOCS)
set (BUILD_LIBRARY 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 ()
if (BUILD_PLASMOID)
set (BUILD_DATAENGINE ON)
endif ()
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
add_subdirectory (icons)
# resources
set (PROJECT_LIBRARY netctlgui)
set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
add_subdirectory (${PROJECT_RESOURCE_DIR})
# components
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 ()

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="1">
<libraries>
<library>qt</library>
</libraries>
</project>

View File

@ -3,6 +3,8 @@
## Commands
# command
CMD=/usr/bin/netctl
# netctl-auto command
NETCTLAUTOCMD=/usr/bin/netctl-auto
# ip command
IPCMD=/usr/bin/ip

View File

@ -1,26 +1,29 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "netctl.h"
#include <KGlobal>
#include <KStandardDirs>
#include <Plasma/DataContainer>
#include <QDir>
#include <QFile>
#include <QProcess>
#include <QTextCodec>
Netctl::Netctl(QObject *parent, const QVariantList &args)
@ -49,48 +52,60 @@ QStringList Netctl::sources() const
}
bool Netctl::readConfiguration()
void Netctl::readConfiguration()
{
// default configuration
checkExtIP = QString("false");
cmd = QString("/usr/bin/netctl");
extIpCmd = QString("wget -qO- http://ifconfig.me/ip");
ipCmd = QString("/usr/bin/ip");
netDir = QString("/sys/class/net/");
QMap<QString, QString> rawConfig;
rawConfig[QString("CMD")] = QString("/usr/bin/netctl");
rawConfig[QString("EXTIP")] = QString("false");
rawConfig[QString("EXTIPCMD")] = QString("wget -qO- http://ifconfig.me/ip");
rawConfig[QString("IPCMD")] = QString("/usr/bin/ip");
rawConfig[QString("NETDIR")] = QString("/sys/class/net/");
rawConfig[QString("NETCTLAUTOCMD")] = QString("/usr/bin/netctl-auto");
QString fileStr;
// FIXME: define configuration file
QFile confFile(QString(getenv("HOME")) + QString("/.kde4/share/config/netctl.conf"));
bool exists = confFile.open(QIODevice::ReadOnly);
if (!exists) {
confFile.setFileName("/usr/share/config/netctl.conf");
exists = confFile.open(QIODevice::ReadOnly);
if (!exists)
return false;
QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf");
QFile confFile(fileName);
if (!confFile.open(QIODevice::ReadOnly)) {
configuration = updateConfiguration(rawConfig);
return;
}
QString fileStr;
QStringList value;
while (true) {
fileStr = QString(confFile.readLine());
if (fileStr[0] != '#') {
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2) {
if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("EXTIP"))
checkExtIP = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("CMD"))
cmd = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("EXTIPCMD"))
extIpCmd = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("IPCMD"))
ipCmd = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
else if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("NETDIR"))
netDir = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
}
}
fileStr = QString(confFile.readLine()).trimmed();
if (fileStr[0] == QChar('#')) continue;
if (fileStr[0] == QChar(';')) continue;
if (!fileStr.contains(QChar('='))) continue;
value.clear();
for (int i=1; i<fileStr.split(QChar('=')).count(); i++)
value.append(fileStr.split(QChar('='))[i]);
rawConfig[fileStr.split(QChar('='))[0]] = value.join(QChar('='));
if (confFile.atEnd())
break;
}
confFile.close();
return true;
configuration = updateConfiguration(rawConfig);
return;
}
QMap<QString, QString> Netctl::updateConfiguration(const QMap<QString, QString> rawConfig)
{
QMap<QString, QString> config;
QString key, value;
// remove spaces and copy source map
for (int i=0; i<rawConfig.keys().count(); i++) {
key = rawConfig.keys()[i];
value = rawConfig[key];
key.remove(QChar(' '));
if ((key != QString("CMD")) &&
(key != QString("EXTIPCMD")) &&
(key != QString("IPCMD")) &&
(key != QString("NETCTLAUTOCMD")))
value.remove(QChar(' '));
config[key] = value;
}
return config;
}
@ -100,122 +115,142 @@ bool Netctl::sourceRequestEvent(const QString &name)
}
bool Netctl::updateSourceEvent(const QString &source)
QString Netctl::getCurrentProfile(const QString cmd)
{
QProcess command;
QString cmdOutput = QString("");
QString value = QString("");
if (source == QString("currentProfile")) {
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
if (!cmdOutput.isEmpty()) {
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2) {
value = profileList[i].split(QString(" "), QString::SkipEmptyParts)[1];
break;
}
QString profile = QString("");
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
if (profileList[i][0] == QChar('*')) {
profile = profileList[i];
break;
}
setData(source, QString("value"), value);
profile.remove(0, 1);
return profile;
}
QString Netctl::getExtIp(const QString cmd)
{
QProcess command;
QString extIp = QString("");
command.start(cmd);
command.waitForFinished(-1);
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
extIp = cmdOutput.trimmed();
return extIp;
}
QStringList Netctl::getInterfaceList(const QString dir)
{
QStringList interfaceList;
if (QDir(dir).exists())
interfaceList = QDir(dir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
return interfaceList;
}
QString Netctl::getIntIp(const QString cmd, const QString dir)
{
QProcess command;
QString intIp = QString("127.0.0.1/8");
QStringList interfaceList = getInterfaceList(dir);
for (int i=0; i<interfaceList.count(); i++)
if (interfaceList[i] != QString("lo")) {
command.start(cmd + QString(" addr show ") + interfaceList[i]);
command.waitForFinished(-1);
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
QStringList deviceInfo = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
for (int j=0; j<deviceInfo.count(); j++)
if (deviceInfo[j].split(QChar(' '), QString::SkipEmptyParts)[0] == QString("inet"))
intIp = deviceInfo[j].split(QChar(' '), QString::SkipEmptyParts)[1];
}
return intIp;
}
QStringList Netctl::getProfileList(const QString cmd)
{
QProcess command;
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput());
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
profileList[i].remove(0, 1);
return profileList;
}
bool Netctl::getProfileStatus(const QString cmd)
{
bool status = false;
QString cmdOutput = getCurrentProfile(cmd);
if (!cmdOutput.isEmpty())
status = true;
return status;
}
QString Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
{
QProcess command;
QString status = QString("static");
// check netctl-auto
if (!getCurrentProfile(cmdNetctlAuto).isEmpty())
status = QString("netctl-auto");
else {
// check netctl
command.start(cmdNetctl + QString(" is-enabled ") + getCurrentProfile(cmdNetctl));
command.waitForFinished(-1);
if (command.exitCode() == 0)
status = QString("enabled");
}
return status;
}
bool Netctl::updateSourceEvent(const QString &source)
{
QString key = QString("value");
QString value = QString("");
if (source == QString("currentProfile")) {
value = getCurrentProfile(configuration[QString("NETCTLAUTOCMD")]);
if (value.isEmpty())
value = getCurrentProfile(configuration[QString("CMD")]);
}
else if (source == QString("extIp")) {
if (checkExtIP == QString("true")) {
command.start(extIpCmd);
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
if (!cmdOutput.isEmpty())
value = cmdOutput.split(QString("\n"), QString::SkipEmptyParts)[0];
}
setData(source, QString("value"), value);
if (configuration[QString("EXTIP")] == QString("true"))
value = getExtIp(configuration[QString("EXTIPCMD")]);
}
else if (source == QString("interfaces")) {
if (QDir(netDir).exists())
value = QDir(netDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot).join(QString(","));
setData(source, QString("value"), value);
value = getInterfaceList(configuration[QString("NETDIR")]).join(QChar(','));
}
else if (source == QString("intIp")) {
if (QDir(netDir).exists()) {
value = QString("127.0.0.1/8");
QStringList netDevices = QDir(netDir).entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i=0; i<netDevices.count(); i++)
if (netDevices[i] != QString("lo")) {
cmdOutput = QString("");
command.start(ipCmd + QString(" addr show ") + netDevices[i]);
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
if (!cmdOutput.isEmpty()) {
QStringList deviceInfo = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int j=0; j<deviceInfo.count(); j++)
if (deviceInfo[j].split(QString(" "), QString::SkipEmptyParts)[0] == QString("inet"))
value = deviceInfo[j].split(QString(" "), QString::SkipEmptyParts)[1];
}
}
}
setData(source, QString("value"), value);
value = getIntIp(configuration[QString("IPCMD")], configuration[QString("NETDIR")]);
}
else if (source == QString("profiles")) {
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
QStringList list;
if (!cmdOutput.isEmpty()) {
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 1)
list.append(profileList[i].split(QString(" "), QString::SkipEmptyParts)[0]);
else if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2)
list.append(profileList[i].split(QString(" "), QString::SkipEmptyParts)[1]);
}
value = list.join(QString(","));
setData(source, QString("value"), value);
value = getProfileList(configuration[QString("NETCTLAUTOCMD")]).join(QChar(','));
if (value.isEmpty())
value = getProfileList(configuration[QString("CMD")]).join(QChar(','));
}
else if (source == QString("statusBool")) {
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
value = QString("false");
if (!cmdOutput.isEmpty()) {
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2) {
value = QString("true");
break;
}
}
setData(source, QString("value"), value);
if (getProfileStatus(configuration[QString("NETCTLAUTOCMD")]))
value = QString("true");
else if (getProfileStatus(configuration[QString("CMD")]))
value = QString("true");
else
value = QString("false");
}
else if (source == QString("statusString")) {
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
QString currentProfile;
if (!cmdOutput.isEmpty()) {
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int i=0; i<profileList.count(); i++)
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2) {
currentProfile = profileList[i].split(QString(" "), QString::SkipEmptyParts)[1];
break;
}
}
command.start(cmd + QString(" status ") + currentProfile);
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
if (!cmdOutput.isEmpty()) {
QStringList profile = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int i=0; i<profile.count(); i++)
if (profile[i].split(QString(" "), QString::SkipEmptyParts)[0] == QString("Loaded:")) {
if (profile[i].contains(QString("enabled")))
value = QString("enabled");
else if (profile[i].contains(QString("static")))
value = QString("static");
break;
}
}
setData(source, QString("value"), value);
value = getProfileStringStatus(configuration[QString("CMD")],
configuration[QString("NETCTLAUTOCMD")]);
}
setData(source, key, value);
return true;
}

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef NETCTL_DE_H
@ -27,25 +27,25 @@ class Netctl : public Plasma::DataEngine
public:
Netctl(QObject *parent, const QVariantList &args);
QString getCurrentProfile(const QString cmd);
QString getExtIp(const QString cmd);
QStringList getInterfaceList(const QString dir);
QString getIntIp(const QString cmd, const QString dir);
QStringList getProfileList(const QString cmd);
bool getProfileStatus(const QString cmd);
QString getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
protected:
bool readConfiguration();
bool sourceRequestEvent(const QString &name);
bool updateSourceEvent(const QString &source);
QStringList sources() const;
private:
bool isNetctlAutoRunning();
// configuration
// enable check external IP
QString checkExtIP;
// path to netctl command
QString cmd;
// command to check external IP
QString extIpCmd;
// path to ip command
QString ipCmd;
// path to directory with network device configuration
QString netDir;
QMap<QString, QString> configuration;
void readConfiguration();
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
};

View File

@ -4,7 +4,7 @@ Name=Netctl
Comment=Data engine for netctl
ServiceTypes=Plasma/DataEngine
Type=Service
Icon=netctl-gui
Icon=netctl-gui-widget
X-KDE-ServiceTypes=Plasma/DataEngine
X-KDE-Library=plasma_engine_netctl

View File

@ -5,7 +5,7 @@ message (STATUS "Subproject ${SUBPROJECT}")
# set directories
set (SUBPROJECT_BINARY_DIR bin)
set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set (SUBPROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
set (SUBPROJECT_RESOURCE_DIR ${PROJECT_RESOURCE_DIR})
set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations)
# executable path
set (EXECUTABLE_OUTPUT_PATH ${SUBPROJECT_BINARY_DIR})
@ -15,5 +15,10 @@ set (TARGETS "")
set (HEADERS "")
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
# build man
file (GLOB SUBPROJECT_MAN_IN *.1)
file (RELATIVE_PATH SUBPROJECT_MAN ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN_IN})
configure_file (${SUBPROJECT_MAN_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN})
install (FILES ${SUBPROJECT}.desktop DESTINATION share/applications/)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN} DESTINATION share/man/man1/)

64
sources/gui/netctl-gui.1 Normal file
View File

@ -0,0 +1,64 @@
.TH netctl-gui 1 "@CURRENT_DATE@" "version @PROJECT_VERSION@" "USER COMMANDS"
.SH NAME
netctl-gui is a graphical interface for netctl
.SH SYNOPSIS
.B netctl-gui
[ --about ] [ --netctl-auto ] [ --settings ]
[ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]
[ -s PROFILE | --select PROFILE ]
[ --config FILE ] [ -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.
.SH OPTIONS
.TP
--about
show about window
.TP
--netctl-auto
show netctl-auto window
.TP
--settings
show settings window
.TP
-e, --essid ESSID
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
.TP
-s, --select PROFILE
select profile PROFILE. This option will set tab to 1 automatically
.TP
--config FILE
read configuration from file FILE
.TP
-d, --debug
print debug information
.TP
--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
-v, --version
show version and exit
.TP
-i, --info
show build information and exit
.TP
-h, --help
show this help and exit
.SH FILES
.TP
$HOME/.config/netctl-gui.conf
Configuration file
.SH AUTHOR
@PROJECT_AUTHOR@ <\fI@PROJECT_CONTACT@\fR>
.SH LICENSE
This software is licensed under @PROJECT_LICENSE@

View File

@ -1,6 +0,0 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>translations/english.qm</file>
<file>translations/russian.qm</file>
</qresource>
</RCC>

View File

@ -3,40 +3,69 @@ file (GLOB SOURCES *.cpp)
file (GLOB HEADERS *.h)
file (GLOB FORMS *.ui)
set (LANGUAGES english
russian)
file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts)
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources.qrc)
message (STATUS "${SUBPROJECT} Sources: ${SOURCES}")
message (STATUS "${SUBPROJECT} Headers: ${HEADERS}")
message (STATUS "${SUBPROJECT} Forms: ${FORMS}")
# include_path
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/include/
${CMAKE_CURRENT_BINARY_DIR}/../
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR})
link_directories (${PROJECT_LIBRARY}/src/lib)
find_package (Qt4 REQUIRED)
include (${QT_USE_FILE})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
qt4_wrap_ui (UI_HEADERS ${FORMS})
qt4_add_resources (QRC_SOURCES ${RESOURCES})
if (USE_QT5)
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5LinguistTools REQUIRED)
add_definitions(${Qt5Core_DEFINITIONS})
add_definitions(${Qt5Widgets_DEFINITIONS})
add_definitions(${Qt5LinguistTools_DEFINITIONS})
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
qt5_wrap_ui (UI_HEADERS ${FORMS})
qt5_add_resources (QRC_SOURCES ${RESOURCES})
foreach (LANGUAGE ${LANGUAGES})
set (TS ${SUBPROJECT_TRANSLATION_DIR}/${LANGUAGE}.ts)
set (QM ${SUBPROJECT_TRANSLATION_DIR}/${LANGUAGE}.qm)
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
message (STATUS "${SUBPROJECT} Translations: ${TRANSLATIONS_BINARY}")
foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS})
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES})
source_group ("Generated Files" FILES ${MOC_SOURCES})
source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES})
source_group ("Generated Files" FILES ${MOC_SOURCES})
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
target_link_libraries (${SUBPROJECT} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${Qt5Widgets_LIBRARIES} ${Qt5Core_LIBRARIES})
else ()
find_package (Qt4 REQUIRED)
include (${QT_USE_FILE})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
qt4_wrap_ui (UI_HEADERS ${FORMS})
qt4_add_resources (QRC_SOURCES ${RESOURCES})
foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS})
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES})
source_group ("Generated Files" FILES ${MOC_SOURCES})
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
endif()
# install properties
install (TARGETS ${SUBPROJECT} DESTINATION bin)

105
sources/gui/src/about.ui Normal file
View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>About</class>
<widget class="QWidget" name="About">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>390</width>
<height>290</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="label_description">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_name">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_version">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="spacer_about">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_links">
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_license">
<property name="text">
<string/>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,92 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "aboutwindow.h"
#include "ui_aboutwindow.h"
#include <QDebug>
#include <QDialogButtonBox>
#include <QPushButton>
#include "version.h"
AboutWindow::AboutWindow(QWidget *parent, const bool debugCmd)
: QMainWindow(parent),
ui(new Ui::AboutWindow),
debug(debugCmd)
{
ui->setupUi(this);
createUi();
}
AboutWindow::~AboutWindow()
{
if (debug) qDebug() << "[AboutWindow]" << "[~AboutWindow]";
delete uiAbout;
delete ui;
}
void AboutWindow::createText()
{
if (debug) qDebug() << "[AboutWindow]" << "[createText]";
uiAbout->label_name->setText(QString(NAME));
uiAbout->label_version->setText(QApplication::translate("AboutWindow", "Version %1\n(build date %2)")
.arg(QString(VERSION)).arg(QString(BUILD_DATE)));
uiAbout->label_description->setText(QApplication::translate("AboutWindow", "Qt-based graphical interface for netctl."));
uiAbout->label_links->setText(QApplication::translate("AboutWindow", "Links:") + QString("<br>") +
QString("<a href=\"%1\">%2</a><br>").arg(QString(HOMEPAGE)).arg(QApplication::translate("AboutWindow", "Homepage")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY)).arg(QApplication::translate("AboutWindow", "Repository")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER)).arg(QApplication::translate("AboutWindow", "Bugtracker")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION)).arg(QApplication::translate("AboutWindow", "Translation issue")) +\
QString("<a href=\"%1\">%2</a>").arg(QString(AUR_PACKAGES)).arg(QApplication::translate("AboutWindow", "AUR packages")));
uiAbout->label_license->setText(QString("<small>&copy; %1 <a href=\"mailto:%2\">%3</a><br>").arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) +
QApplication::translate("AboutWindow", "This software is licensed under %1").arg(QString(LICENSE)) +
QString("</small>"));
}
void AboutWindow::createUi()
{
if (debug) qDebug() << "[AboutWindow]" << "[createUi]";
QWidget *aboutWidget = new QWidget();
uiAbout = new Ui::About;
uiAbout->setupUi(aboutWidget);
ui->verticalLayout->addWidget(aboutWidget);
createText();
QDialogButtonBox *buttonBox = new QDialogButtonBox;
buttonBox->addButton(QDialogButtonBox::Close);
ui->verticalLayout->addWidget(buttonBox);
connect(buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
}
// ESC press event
void AboutWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << "[AboutWindow]" << "[keyPressEvent]";
if (pressedKey->key() == Qt::Key_Escape)
close();
}

View File

@ -1,47 +1,51 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef NETCTLPROFILE_H
#define NETCTLPROFILE_H
#ifndef ABOUTWINDOW_H
#define ABOUTWINDOW_H
#include <QDir>
#include <QMap>
#include <QObject>
#include <QKeyEvent>
#include <QMainWindow>
#include "ui_about.h"
class MainWindow;
namespace Ui {
class AboutWindow;
}
class NetctlProfile : public QObject
class AboutWindow : public QMainWindow
{
Q_OBJECT
public:
explicit NetctlProfile(MainWindow *wid = 0,
const QMap<QString, QString> settings = QMap<QString, QString>());
~NetctlProfile();
bool copyProfile(const QString oldPath);
QString createProfile(const QString profile, const QMap<QString, QString> settings);
QMap<QString, QString> getSettingsFromProfile(const QString profile);
explicit AboutWindow(QWidget *parent = 0,
const bool debugCmd = false);
~AboutWindow();
private:
MainWindow *parent;
QDir *profileDirectory;
QString sudoCommand;
Ui::AboutWindow *ui;
Ui::About *uiAbout;
bool debug;
void createText();
void createUi();
// ESC pressed event
void keyPressEvent(QKeyEvent *pressedKey);
};
#endif /* NETCTLPROFILE_H */
#endif /* ABOUTWINDOW_H */

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutWindow</class>
<widget class="QMainWindow" name="AboutWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>380</width>
<height>307</height>
</rect>
</property>
<property name="windowTitle">
<string>About</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout"/>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "bridgewidget.h"
@ -72,9 +72,10 @@ int BridgeWidget::isOk()
void BridgeWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> bridgeSettings = settings;
if (bridgeSettings.contains(QString("SkipForwardingDelay")))
if (bridgeSettings[QString("SkipForwardingDelay")].remove(QString("'")) == QString("yes"))
if (bridgeSettings[QString("SkipForwardingDelay")] == QString("yes"))
ui->checkBox_skip->setCheckState(Qt::Checked);
}

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef BRIDGEWIDGET_H

View File

@ -1,96 +1,223 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "errorwindow.h"
#include "ui_errorwindow.h"
#include <QApplication>
#include <QGridLayout>
#include <QSpacerItem>
#include <QDebug>
ErrorWindow::ErrorWindow(QWidget *parent, const int messageNumber)
: QMainWindow(parent),
ui(new Ui::ErrorWindow)
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
: debug(debugCmd)
{
ui->setupUi(this);
qDebug() << "[ErrorWindow]" << "[ErrorWindow]" << ":" << "Initializate with error code" << messageNumber;
setMessage(messageNumber);
}
ErrorWindow::~ErrorWindow()
{
delete ui;
if (debug) qDebug() << "[ErrorWindow]" << "[~ErrorWindow]";
}
void ErrorWindow::setMessage(const int mess)
QStringList ErrorWindow::getMessage(const int mess)
{
QString message;
if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]";
if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]" << ":" << "Message" << mess;
QString message, title;
switch(mess) {
case 1:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not find components");
break;
case 2:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Does not support yet");
break;
case 3:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Profile name is not set");
break;
case 4:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Bind interfaces are not set");
break;
case 5:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Description is not set");
break;
case 6:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Ip settings are not set");
break;
case 7:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Configuration file does not exist");
break;
case 8:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Key is not set");
break;
case 9:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Wireless settings are not set");
break;
case 10:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Configuration file is not set");
break;
case 11:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "ESSID is not set");
break;
case 12:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "MAC address is incorrect");
break;
case 13:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Session ID is not set");
break;
case 14:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "APN is not set");
break;
case 15:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "APN is not set");
break;
case 16:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Empty user/group name");
break;
case 17:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not find profile");
break;
case 18:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not find ESSID");
break;
default:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Unknown error");
break;
}
ui->label->setText(message);
QStringList fullMessage;
fullMessage.append(title);
fullMessage.append(message);
return fullMessage;
}
QMessageBox::Icon ErrorWindow::getIcon(const int mess)
{
if (debug) qDebug() << "[ErrorWindow]" << "[getIcon]";
if (debug) qDebug() << "[ErrorWindow]" << "[getIcon]" << ":" << "Message" << mess;
QMessageBox::Icon icon;
switch(mess) {
case 1:
icon = QMessageBox::Critical;
break;
case 2:
icon = QMessageBox::Critical;
break;
case 3:
icon = QMessageBox::Critical;
break;
case 4:
icon = QMessageBox::Critical;
break;
case 5:
icon = QMessageBox::Critical;
break;
case 6:
icon = QMessageBox::Critical;
break;
case 7:
icon = QMessageBox::Critical;
break;
case 8:
icon = QMessageBox::Critical;
break;
case 9:
icon = QMessageBox::Critical;
break;
case 10:
icon = QMessageBox::Critical;
break;
case 11:
icon = QMessageBox::Critical;
break;
case 12:
icon = QMessageBox::Critical;
break;
case 13:
icon = QMessageBox::Critical;
break;
case 14:
icon = QMessageBox::Critical;
break;
case 15:
icon = QMessageBox::Critical;
break;
case 16:
icon = QMessageBox::Critical;
break;
case 17:
icon = QMessageBox::Critical;
break;
case 18:
icon = QMessageBox::Critical;
break;
default:
icon = QMessageBox::NoIcon;
break;
}
return icon;
}
void ErrorWindow::showWindow(const int mess, const QString sender)
{
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]";
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Message" << mess;
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Sender" << sender;
QStringList message = getMessage(mess);
QMessageBox messageBox;
messageBox.setText(message[0]);
messageBox.setInformativeText(message[1]);
if (debug)
messageBox.setDetailedText(QApplication::translate("ErrorWindow", "Sender : %1").
arg(sender));
messageBox.setIcon(getIcon(mess));
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setDefaultButton(QMessageBox::Ok);
QSpacerItem *horizontalSpacer = new QSpacerItem(400, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
QGridLayout *layout = (QGridLayout *)messageBox.layout();
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
messageBox.exec();
return;
}

View File

@ -1,42 +1,45 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef ERRORWINDOW_H
#define ERRORWINDOW_H
#include <QMainWindow>
#include <QMessageBox>
#include <QObject>
namespace Ui {
class ErrorWindow;
}
class ErrorWindow : public QMainWindow
class ErrorWindow : public QObject
{
Q_OBJECT
public:
explicit ErrorWindow(QWidget *parent = 0,
const int messageNumber = 0);
const bool debugCmd = false);
~ErrorWindow();
public slots:
void showWindow(const int mess = 0,
const QString sender = QString());
private:
Ui::ErrorWindow *ui;
void setMessage(const int mess);
bool debug;
QStringList getMessage(const int mess);
QMessageBox::Icon getIcon(const int mess);
};
#endif /* ERRORWINDOW_H */

View File

@ -1,123 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ErrorWindow</class>
<widget class="QMainWindow" name="ErrorWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>101</height>
</rect>
</property>
<property name="windowTitle">
<string>Error</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="spacer2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="layout_main">
<item>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="text">
<string>Error text</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="layout_button">
<item>
<spacer name="spacer_button1">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Ok</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer_button2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked(bool)</signal>
<receiver>ErrorWindow</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>143</x>
<y>83</y>
</hint>
<hint type="destinationlabel">
<x>252</x>
<y>80</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "ethernetwidget.h"
@ -44,7 +44,7 @@ void EthernetWidget::clear()
ui->checkBox_skip->setCheckState(Qt::Unchecked);
ui->checkBox_8021x->setCheckState(Qt::Unchecked);
showWpa(ui->checkBox_8021x->checkState());
ui->lineEdit_wpaConfig->setText(QString("/etc/wpa_supplicant.conf"));
ui->lineEdit_wpaConfig->clear();
ui->comboBox_driver->setCurrentIndex(0);
ui->spinBox_timeoutCarrier->setValue(5);
ui->spinBox_timeoutWpa->setValue(15);
@ -86,7 +86,7 @@ void EthernetWidget::selectWpaConfig()
void EthernetWidget::showAdvanced()
{
if (ui->pushButton_ethernetAdvanced->isChecked()) {
ui->widget_ethernetAdvanced->setShown(true);
ui->widget_ethernetAdvanced->setHidden(false);
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
}
else {
@ -101,7 +101,7 @@ void EthernetWidget::showWpa(const int state)
if (state == 0)
ui->widget_wpa->setHidden(true);
else
ui->widget_wpa->setShown(true);
ui->widget_wpa->setHidden(false);
}
@ -141,19 +141,20 @@ int EthernetWidget::isOk()
void EthernetWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> ethernetSettings = settings;
if (ethernetSettings.contains(QString("SkipNoCarrier")))
if (ethernetSettings[QString("SkipNoCarrier")].remove(QString("'")) == QString("yes"))
if (ethernetSettings[QString("SkipNoCarrier")] == QString("yes"))
ui->checkBox_skip->setCheckState(Qt::Checked);
if (ethernetSettings.contains(QString("Auth8021X")))
if (ethernetSettings[QString("Auth8021X")].remove(QString("'")) == QString("yes"))
if (ethernetSettings[QString("Auth8021X")] == QString("yes"))
ui->checkBox_8021x->setCheckState(Qt::Checked);
if (ethernetSettings.contains(QString("WPAConfigFile")))
ui->lineEdit_wpaConfig->setText(ethernetSettings[QString("WPAConfigFile")].remove(QString("'")));
ui->lineEdit_wpaConfig->setText(ethernetSettings[QString("WPAConfigFile")]);
if (ethernetSettings.contains(QString("WPADriver")))
for (int i=0; i<ui->comboBox_driver->count(); i++)
if (ethernetSettings[QString("WPADriver")].remove(QString("'")) == ui->comboBox_driver->itemText(i))
if (ethernetSettings[QString("WPADriver")] == ui->comboBox_driver->itemText(i))
ui->comboBox_driver->setCurrentIndex(i);
if (ethernetSettings.contains(QString("TimeoutCarrier")))
ui->spinBox_timeoutCarrier->setValue(ethernetSettings[QString("TimeoutCarrier")].toInt());

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef ETHERNETWIDGET_H

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "generalwidget.h"
@ -112,7 +112,7 @@ void GeneralWidget::keyPressEvent(QKeyEvent *pressedKey)
void GeneralWidget::showAdvanced()
{
if (ui->pushButton_generalAdvanced->isChecked()) {
ui->widget_generalAdvanced->setShown(true);
ui->widget_generalAdvanced->setHidden(false);
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
}
else {
@ -136,13 +136,13 @@ QMap<QString, QString> GeneralWidget::getSettings()
QStringList interfaces;
for (int i=0; i<ui->listWidget_bindto->count(); i++)
interfaces.append(ui->listWidget_bindto->item(i)->text());
generalSettings[QString("BindsToInterfaces")] = interfaces.join(QString(" "));
generalSettings[QString("BindsToInterfaces")] = interfaces.join(QChar(' '));
}
if (ui->listWidget_after->count() != 0) {
QStringList profiles;
for (int i=0; i<ui->listWidget_after->count(); i++)
profiles.append(ui->listWidget_after->item(i)->text());
generalSettings[QString("After")] = profiles.join(QString(" "));
generalSettings[QString("After")] = profiles.join(QChar(' '));
}
if (!ui->lineEdit_execUpPost->text().isEmpty())
generalSettings[QString("ExecUpPost")] = QString("'") + ui->lineEdit_execUpPost->text() + QString("'");
@ -175,30 +175,31 @@ int GeneralWidget::isOk()
void GeneralWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> generalSettings = settings;
if (generalSettings.contains(QString("Description")))
ui->lineEdit_description->setText(generalSettings[QString("Description")].remove(QString("'")));
ui->lineEdit_description->setText(generalSettings[QString("Description")]);
if (generalSettings.contains(QString("Connection")))
for (int i=0; i<ui->comboBox_connection->count(); i++)
if (generalSettings[QString("Connection")].remove(QString("'")) == ui->comboBox_connection->itemText(i))
if (generalSettings[QString("Connection")] == ui->comboBox_connection->itemText(i))
ui->comboBox_connection->setCurrentIndex(i);
if (generalSettings.contains(QString("Interface")))
for (int i=0; i<ui->comboBox_interface->count(); i++)
if (generalSettings[QString("Interface")].remove(QString("'")) == ui->comboBox_interface->itemText(i))
ui->comboBox_interface->setCurrentIndex(i);
if (generalSettings.contains(QString("Interface"))) {
ui->comboBox_interface->addItem(generalSettings[QString("Interface")]);
ui->comboBox_interface->setCurrentIndex(ui->comboBox_interface->count()-1);
}
if (generalSettings.contains(QString("BindsToInterfaces")))
ui->listWidget_bindto->addItems(generalSettings[QString("BindsToInterfaces")].split(QString(" ")));
ui->listWidget_bindto->addItems(generalSettings[QString("BindsToInterfaces")].split(QChar('\n')));
if (generalSettings.contains(QString("After")))
ui->listWidget_after->addItems(generalSettings[QString("After")].split(QString(" ")));
ui->listWidget_after->addItems(generalSettings[QString("After")].split(QChar('\n')));
if (generalSettings.contains(QString("ExecUpPost")))
ui->lineEdit_execUpPost->setText(generalSettings[QString("ExecUpPost")].remove(QString("'")));
ui->lineEdit_execUpPost->setText(generalSettings[QString("ExecUpPost")]);
if (generalSettings.contains(QString("ExecDownPre")))
ui->lineEdit_execDownPre->setText(generalSettings[QString("ExecDownPre")].remove(QString("'")));
ui->lineEdit_execDownPre->setText(generalSettings[QString("ExecDownPre")]);
if (generalSettings.contains(QString("ForceConnect")))
if (generalSettings[QString("ForceConnect")].remove(QString("'")) == QString("yes"))
if (generalSettings[QString("ForceConnect")] == QString("yes"))
ui->checkBox_forceConnect->setCheckState(Qt::Checked);
if (generalSettings.contains(QString("NETCTL_DEBUG")))
if (generalSettings[QString("NETCTL_DEBUG")].remove(QString("'")) == QString("yes"))
if (generalSettings[QString("NETCTL_DEBUG")] == QString("yes"))
ui->checkBox_debug->setCheckState(Qt::Checked);
}

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef GENERALWIDGET_H

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>431</width>
<height>537</height>
<width>429</width>
<height>535</height>
</rect>
</property>
<property name="windowTitle">
@ -118,6 +118,11 @@
<string notr="true">vlan</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">macvlan</string>
</property>
</item>
</widget>
</item>
</layout>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="1">
<libraries>
<library>qt</library>
</libraries>
</project>

View File

@ -1,24 +1,23 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "ipwidget.h"
#include "ui_ipwidget.h"
#include <QDebug>
#include <QKeyEvent>
@ -171,7 +170,7 @@ void IpWidget::keyPressEvent(QKeyEvent *pressedKey)
QString IpWidget::getIp(const QString rawIp)
{
QStringList ip = rawIp.split(QString("."));
QStringList ip = rawIp.split(QChar('.'));
// fix empty fields
if (ip[0].isEmpty())
@ -187,7 +186,7 @@ QString IpWidget::getIp(const QString rawIp)
if (ip[i].toInt() > 255)
ip[i] = QString("255");
return ip.join(QString("."));
return ip.join(QChar('.'));
}
@ -234,8 +233,8 @@ QString IpWidget::getPrefix6(const QString rawPrefix)
void IpWidget::addIp()
{
QString ip = getIp(ui->lineEdit_ipAddress->text().remove(" ").split(QString("/"))[0]);
QString prefix = getPrefix(ui->lineEdit_ipAddress->text().remove(" ").split(QString("/"))[1]);
QString ip = getIp(ui->lineEdit_ipAddress->text().remove(QChar(' ')).split(QChar('/'))[0]);
QString prefix = getPrefix(ui->lineEdit_ipAddress->text().remove(QChar(' ')).split(QChar('/'))[1]);
ui->listWidget_ipAddress->addItem(ip + QString("/") + prefix);
ui->lineEdit_ipAddress->clear();
@ -244,9 +243,9 @@ void IpWidget::addIp()
void IpWidget::addIpRoutes()
{
QString ip = getIp(ui->lineEdit_ipRoutes->text().remove(" ").split(QString("/"))[0]);
QString prefix = getPrefix(ui->lineEdit_ipRoutes->text().remove(" ").split(QString("/"))[1]);
QString ipVia = getIp(ui->lineEdit_ipRoutes2->text().remove(" "));
QString ip = getIp(ui->lineEdit_ipRoutes->text().remove(QChar(' ')).split(QChar('/'))[0]);
QString prefix = getPrefix(ui->lineEdit_ipRoutes->text().remove(QChar(' ')).split(QChar('/'))[1]);
QString ipVia = getIp(ui->lineEdit_ipRoutes2->text().remove(QChar(' ')));
ui->listWidget_ipRoutes->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
ui->lineEdit_ipRoutes->clear();
@ -256,8 +255,8 @@ void IpWidget::addIpRoutes()
void IpWidget::addIp6()
{
QString ip = getIp6(ui->lineEdit_ipAddress6->text().remove(" ").split(QString("/"))[0]);
QString prefix = getPrefix6(ui->lineEdit_ipAddress6->text().remove(" ").split(QString("/"))[1]);
QString ip = getIp6(ui->lineEdit_ipAddress6->text().remove(QChar(' ')).split(QChar('/'))[0]);
QString prefix = getPrefix6(ui->lineEdit_ipAddress6->text().remove(QChar(' ')).split(QChar('/'))[1]);
ui->listWidget_ipAddress6->addItem(ip + QString("/") + prefix);
ui->lineEdit_ipAddress6->clear();
@ -266,9 +265,9 @@ void IpWidget::addIp6()
void IpWidget::addIpRoutes6()
{
QString ip = getIp6(ui->lineEdit_ipRoutes6->text().remove(" ").split(QString("/"))[0]);
QString prefix = getPrefix6(ui->lineEdit_ipRoutes6->text().remove(" ").split(QString("/"))[1]);
QString ipVia = getIp6(ui->lineEdit_ipRoutes62->text().remove(" "));
QString ip = getIp6(ui->lineEdit_ipRoutes6->text().remove(QChar(' ')).split(QChar('/'))[0]);
QString prefix = getPrefix6(ui->lineEdit_ipRoutes6->text().remove(QChar(' ')).split(QChar('/'))[1]);
QString ipVia = getIp6(ui->lineEdit_ipRoutes62->text().remove(QChar(' ')));
ui->listWidget_ipRoutes6->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
ui->lineEdit_ipRoutes6->clear();
@ -286,7 +285,7 @@ void IpWidget::addCustom()
void IpWidget::addDns()
{
QString ip = getIp(ui->lineEdit_dns->text().remove(" "));
QString ip = getIp(ui->lineEdit_dns->text().remove(QChar(' ')));
ui->listWidget_dns->addItem(ip);
ui->lineEdit_dns->clear();
@ -306,7 +305,7 @@ void IpWidget::changeIpMode(const QString currentText)
if (currentText == QString("dhcp"))
ui->widget_ip->setHidden(true);
else if (currentText == QString("static"))
ui->widget_ip->setShown(true);
ui->widget_ip->setHidden(false);
}
@ -332,7 +331,7 @@ void IpWidget::changeIp6Mode(const QString currentText)
ui->widget_ip6->setHidden(true);
else if ((currentText == QString("static")) ||
(currentText == QString("stateless")))
ui->widget_ip6->setShown(true);
ui->widget_ip6->setHidden(false);
}
@ -354,12 +353,12 @@ void IpWidget::ip6Enable(const int state)
void IpWidget::changeDhcpClient(const QString currentText)
{
if (currentText == QString("dhcpcd")) {
ui->widget_dhcpcdOpt->setShown(true);
ui->widget_dhcpcdOpt->setHidden(false);
ui->widget_dhclientOpt->setHidden(true);
}
else if (currentText == QString("dhclient")) {
ui->widget_dhcpcdOpt->setHidden(true);
ui->widget_dhclientOpt->setShown(true);
ui->widget_dhclientOpt->setHidden(false);
}
}
@ -367,7 +366,7 @@ void IpWidget::changeDhcpClient(const QString currentText)
void IpWidget::showAdvanced()
{
if (ui->pushButton_ipAdvanced->isChecked()) {
ui->widget_ipAdvanced->setShown(true);
ui->widget_ipAdvanced->setHidden(false);
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
}
else {
@ -390,14 +389,14 @@ QMap<QString, QString> IpWidget::getSettings()
QStringList addresses;
for (int i=0; i<ui->listWidget_ipAddress->count(); i++)
addresses.append(QString("'") + ui->listWidget_ipAddress->item(i)->text() + QString("'"));
ipSettings[QString("Address")] = addresses.join(QString(" "));
ipSettings[QString("Address")] = addresses.join(QChar(' '));
ipSettings[QString("Gateway")] = QString("'") + ui->lineEdit_gateway->text() + QString("'");
}
if (ui->listWidget_ipRoutes->count() > 0) {
QStringList routes;
for (int i=0; i<ui->listWidget_ipRoutes->count(); i++)
routes.append(QString("'") + ui->listWidget_ipRoutes->item(i)->text() + QString("'"));
ipSettings[QString("Routes")] = routes.join(QString(" "));
ipSettings[QString("Routes")] = routes.join(QChar(' '));
}
}
else
@ -409,14 +408,14 @@ QMap<QString, QString> IpWidget::getSettings()
QStringList addresses;
for (int i=0; i<ui->listWidget_ipAddress6->count(); i++)
addresses.append(QString("'") + ui->listWidget_ipAddress6->item(i)->text() + QString("'"));
ipSettings[QString("Address6")] = addresses.join(QString(" "));
ipSettings[QString("Address6")] = addresses.join(QChar(' '));
ipSettings[QString("Gateway6")] = QString("'") + ui->lineEdit_gateway6->text() + QString("'");
}
if (ui->listWidget_ipRoutes6->count() > 0) {
QStringList routes;
for (int i=0; i<ui->listWidget_ipRoutes6->count(); i++)
routes.append(QString("'") + ui->listWidget_ipRoutes6->item(i)->text() + QString("'"));
ipSettings[QString("Routes6")] = routes.join(QString(" "));
ipSettings[QString("Routes6")] = routes.join(QChar(' '));
}
}
else
@ -425,7 +424,7 @@ QMap<QString, QString> IpWidget::getSettings()
QStringList custom;
for (int i=0; i<ui->listWidget_custom->count(); i++)
custom.append(QString("'") + ui->listWidget_custom->item(i)->text() + QString("'"));
ipSettings[QString("IPCustom")] = custom.join(QString(" "));
ipSettings[QString("IPCustom")] = custom.join(QChar(' '));
}
if (!ui->lineEdit_hostname->text().isEmpty())
ipSettings[QString("Hostname")] = QString("'") + ui->lineEdit_hostname->text() + QString("'");
@ -450,7 +449,7 @@ QMap<QString, QString> IpWidget::getSettings()
QStringList dns;
for (int i=0; i<ui->listWidget_dns->count(); i++)
dns.append(QString("'") + ui->listWidget_dns->item(i)->text() + QString("'"));
ipSettings[QString("DNS")] = dns.join(QString(" "));
ipSettings[QString("DNS")] = dns.join(QChar(' '));
}
if (!ui->lineEdit_dnsDomain->text().isEmpty())
ipSettings[QString("DNSDomain")] = QString("'") + ui->lineEdit_dnsDomain->text() + QString("'");
@ -460,7 +459,7 @@ QMap<QString, QString> IpWidget::getSettings()
QStringList dnsOpt;
for (int i=0; i<ui->listWidget_dnsOptions->count(); i++)
dnsOpt.append(QString("'") + ui->listWidget_dnsOptions->item(i)->text() + QString("'"));
ipSettings[QString("DNSOptions")] = dnsOpt.join(QString(" "));
ipSettings[QString("DNSOptions")] = dnsOpt.join(QChar(' '));
}
return ipSettings;
@ -489,76 +488,71 @@ int IpWidget::isOk()
void IpWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> ipSettings = settings;
if (ipSettings.contains(QString("IP"))) {
if (ipSettings[QString("IP")].remove(QString("'")) == QString("no"))
if (ipSettings[QString("IP")] == QString("no"))
ui->checkBox_ip->setCheckState(Qt::Unchecked);
else {
ui->checkBox_ip->setCheckState(Qt::Checked);
for (int i=0; i<ui->comboBox_ip->count(); i++)
if (ipSettings[QString("IP")].remove(QString("'")) == ui->comboBox_ip->itemText(i))
if (ipSettings[QString("IP")] == ui->comboBox_ip->itemText(i))
ui->comboBox_ip->setCurrentIndex(i);
}
}
if (ipSettings.contains(QString("Address")))
ui->listWidget_ipAddress->addItems(ipSettings[QString("Address")].remove(QString("'")).split(QString(" ")));
ui->listWidget_ipAddress->addItems(ipSettings[QString("Address")].split(QChar('\n')));
if (ipSettings.contains(QString("Gateway")))
ui->lineEdit_gateway->setText(ipSettings[QString("Gateway")].remove(QString("'")));
ui->lineEdit_gateway->setText(ipSettings[QString("Gateway")]);
if (ipSettings.contains(QString("Routes")))
ui->listWidget_ipRoutes->addItems(ipSettings[QString("Routes")].remove(QString("'")).split(QString(" ")));
ui->listWidget_ipRoutes->addItems(ipSettings[QString("Routes")].split(QChar('\n')));
if (ipSettings.contains(QString("IP6"))) {
if (ipSettings[QString("IP6")].remove(QString("'")) == QString("no"))
if (ipSettings[QString("IP6")] == QString("no"))
ui->checkBox_ip6->setCheckState(Qt::Unchecked);
else {
ui->checkBox_ip6->setCheckState(Qt::Checked);
for (int i=0; i<ui->comboBox_ip6->count(); i++)
if (ipSettings[QString("IP6")].remove(QString("'")) == ui->comboBox_ip6->itemText(i))
if (ipSettings[QString("IP6")] == ui->comboBox_ip6->itemText(i))
ui->comboBox_ip6->setCurrentIndex(i);
}
}
if (ipSettings.contains(QString("Address6")))
ui->listWidget_ipAddress6->addItems(ipSettings[QString("Address6")].remove(QString("'")).split(QString(" ")));
ui->listWidget_ipAddress6->addItems(ipSettings[QString("Address6")].split(QChar('\n')));
if (ipSettings.contains(QString("Gateway6")))
ui->lineEdit_gateway6->setText(ipSettings[QString("Gateway6")].remove(QString("'")));
ui->lineEdit_gateway6->setText(ipSettings[QString("Gateway6")]);
if (ipSettings.contains(QString("Routes6")))
ui->listWidget_ipRoutes6->addItems(ipSettings[QString("Routes6")].remove(QString("'")).split(QString(" ")));
if (ipSettings.contains(QString("IPCustom"))) {
QStringList custom;
if (ipSettings[QString("IPCustom")].contains(QString("\n")))
custom = ipSettings[QString("IPCustom")].split(QString("'\n'"));
else
custom = ipSettings[QString("IPCustom")].split(QString("' '"));
for (int i=0; i<custom.count(); i++)
ui->listWidget_custom->addItem(custom[i].remove(QString("'")));
}
ui->listWidget_ipRoutes6->addItems(ipSettings[QString("Routes6")].split(QChar('\n')));
if (ipSettings.contains(QString("IPCustom")))
ui->listWidget_custom->addItems(ipSettings[QString("IPCustom")].split(QChar('\n')));
if (ipSettings.contains(QString("Hostname")))
ui->lineEdit_hostname->setText(ipSettings[QString("Hostname")].remove(QString("'")));
ui->lineEdit_hostname->setText(ipSettings[QString("Hostname")]);
if (ipSettings.contains(QString("TimeoutDAD")))
ui->spinBox_timeoutDad->setValue(ipSettings[QString("TimeoutDAD")].toInt());
if (ipSettings.contains(QString("DHCPClient")))
for (int i=0; i<ui->comboBox_dhcp->count(); i++)
if (ipSettings[QString("DHCPClient")].remove(QString("'")) == ui->comboBox_dhcp->itemText(i))
if (ipSettings[QString("DHCPClient")] == ui->comboBox_dhcp->itemText(i))
ui->comboBox_dhcp->setCurrentIndex(i);
if (ipSettings.contains(QString("DhcpcdOptions")))
ui->lineEdit_dhcpcdOpt->setText(ipSettings[QString("DhcpcdOptions")].remove(QString("'")));
ui->lineEdit_dhcpcdOpt->setText(ipSettings[QString("DhcpcdOptions")]
.remove(QChar('\'')).remove(QChar('"')));
if (ipSettings.contains(QString("DhclientOptions")))
ui->lineEdit_dhclientOpt->setText(ipSettings[QString("DhclientOptions")].remove(QString("'")));
ui->lineEdit_dhclientOpt->setText(ipSettings[QString("DhclientOptions")]);
if (ipSettings.contains(QString("DhclientOptions6")))
ui->lineEdit_dhclientOpt6->setText(ipSettings[QString("DhclientOptions6")].remove(QString("'")));
ui->lineEdit_dhclientOpt6->setText(ipSettings[QString("DhclientOptions6")]);
if (ipSettings.contains(QString("TimeoutDHCP")))
ui->spinBox_timeoutDhcp->setValue(ipSettings[QString("TimeoutDHCP")].toInt());
if (ipSettings.contains(QString("DHCPReleaseOnStop")))
if (ipSettings[QString("DHCPReleaseOnStop")].remove(QString("'")) == QString("yes"))
if (ipSettings[QString("DHCPReleaseOnStop")] == QString("yes"))
ui->checkBox_dhcp->setCheckState(Qt::Checked);
if (ipSettings.contains(QString("DNS")))
ui->listWidget_dns->addItems(ipSettings[QString("DNS")].remove(QString("'")).split(QString(" ")));
ui->listWidget_dns->addItems(ipSettings[QString("DNS")].split(QChar('\n')));
if (ipSettings.contains(QString("DNSDomain")))
ui->lineEdit_dnsDomain->setText(ipSettings[QString("DNSDomain")].remove(QString("'")));
ui->lineEdit_dnsDomain->setText(ipSettings[QString("DNSDomain")]);
if (ipSettings.contains(QString("DNSSearch")))
ui->lineEdit_dnsSearch->setText(ipSettings[QString("DNSSearch")].remove(QString("'")));
ui->lineEdit_dnsSearch->setText(ipSettings[QString("DNSSearch")]);
if (ipSettings.contains(QString("DNSOptions")))
ui->listWidget_dnsOptions->addItems(ipSettings[QString("DNSOptions")].remove(QString("'")).split(QString(" ")));
ui->listWidget_dnsOptions->addItems(ipSettings[QString("DNSOptions")].split(QChar('\n')));
ipEnable(ui->checkBox_ip->checkState());
changeIpMode(ui->comboBox_ip->currentText());

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef IPWIDGET_H

View File

@ -0,0 +1,113 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "language.h"
#include <QFile>
#include <QLocale>
Language::Language()
{
}
QString Language::checkLanguage(const QString language, const QString defaultLanguage)
{
QStringList availableLanguages = getAvailableLanguages();
for (int i=0; i<availableLanguages.count(); i++)
if (language == availableLanguages[i])
return availableLanguages[i];
for (int i=0; i<availableLanguages.count(); i++)
if (language.contains(availableLanguages[i] + QChar('_')))
return availableLanguages[i];
return defaultLanguage;
}
QString Language::defineLanguage(const QString configPath, const QString options)
{
QMap<QString, QString> 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())
language = defineLanguageFromLocale();
language = checkLanguage(language, QString("en"));
return language;
}
QString Language::defineLanguageFromFile(const QString configPath)
{
QString language;
if (configPath.isEmpty())
return language;
QFile configFile(configPath);
QString fileStr;
if (!configFile.open(QIODevice::ReadOnly))
return language;
while (true) {
fileStr = QString(configFile.readLine());
if (fileStr[0] == QChar('#')) continue;
if (fileStr.contains(QString("LANGUAGE=")))
language = fileStr.split(QChar('='))[1]
.remove(QChar(' '))
.trimmed();
if (configFile.atEnd())
break;
}
configFile.close();
return language;
}
QString Language::defineLanguageFromLocale()
{
return QLocale::system().name();
}
QStringList Language::getAvailableLanguages()
{
QStringList languages;
languages.append(QString("en"));
languages.append(QString("ru"));
return languages;
}
QMap<QString, QString> Language::parseOptions(const QString options)
{
QMap<QString, QString> optionsDict;
for (int i=0; i<options.split(QChar(',')).count(); i++) {
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2)
continue;
optionsDict[options.split(QChar(','))[i].split(QChar('='))[0]] =
options.split(QChar(','))[i].split(QChar('='))[1];
}
return optionsDict;
}

View File

@ -0,0 +1,43 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef LANGUAGE_H
#define LANGUAGE_H
#include <QStringList>
class Language : public QObject
{
Q_OBJECT
public:
explicit Language();
static QString checkLanguage(const QString language,
const QString defaultLanguage = QString("en"));
static QString defineLanguage(const QString configPath,
const QString options = QString("OPTIONS"));
static QString defineLanguageFromFile(const QString configPath);
static QString defineLanguageFromLocale();
static QStringList getAvailableLanguages();
private:
static QMap<QString, QString> parseOptions(const QString options);
};
#endif /* LANGUAGE_H */

View File

@ -0,0 +1,94 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "macvlanwidget.h"
#include "ui_macvlanwidget.h"
MacvlanWidget::MacvlanWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::MacvlanWidget)
{
ui->setupUi(this);
createFilter();
}
MacvlanWidget::~MacvlanWidget()
{
delete ui;
}
void MacvlanWidget::clear()
{
ui->comboBox_mode->setCurrentIndex(0);
ui->lineEdit_mac->clear();
}
void MacvlanWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void MacvlanWidget::createFilter()
{
// mac
ui->lineEdit_mac->setInputMask(QString(">HH:HH:HH:HH:HH:HH"));
}
QMap<QString, QString> MacvlanWidget::getSettings()
{
QMap<QString, QString> macvlanSettings;
if (isOk() != 0)
return macvlanSettings;
macvlanSettings[QString("Mode")] = ui->comboBox_mode->currentText();
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
macvlanSettings[QString("MACAddress")] = ui->lineEdit_mac->text();
return macvlanSettings;
}
int MacvlanWidget::isOk()
{
// all fine
return 0;
}
void MacvlanWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> macvlanSettings = settings;
if (macvlanSettings.contains(QString("Mode")))
for (int i=0; i<ui->comboBox_mode->count(); i++)
if (macvlanSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
ui->comboBox_mode->setCurrentIndex(i);
if (macvlanSettings.contains(QString("MACAddress")))
ui->lineEdit_mac->setText(macvlanSettings[QString("MACAddress")]);
}

View File

@ -0,0 +1,49 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef MACVLANWIDGET_H
#define MACVLANWIDGET_H
#include <QWidget>
namespace Ui {
class MacvlanWidget;
}
class MacvlanWidget : public QWidget
{
Q_OBJECT
public:
explicit MacvlanWidget(QWidget *parent = 0);
~MacvlanWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private:
Ui::MacvlanWidget *ui;
void createFilter();
};
#endif /* MACVLANWIDGET_H */

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MacvlanWidget</class>
<widget class="QWidget" name="MacvlanWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>396</width>
<height>101</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_macvlan">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>macvlan settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_macvlan">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QHBoxLayout" name="layout_mode">
<item>
<widget class="QLabel" name="label_mode">
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_mode">
<item>
<property name="text">
<string notr="true">bridge</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">vepa</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">private</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">passthru</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="layout_mac">
<item>
<widget class="QLabel" name="label_mac">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>MAC address</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_mac">
<property name="toolTip">
<string>Optional static MAC address</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,28 +1,28 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include <QApplication>
#include <QDir>
#include <QTextStream>
#include <QTranslator>
#include <iostream>
#include "language.h"
#include "mainwindow.h"
#include "version.h"
@ -30,6 +30,15 @@
using namespace std;
QChar isParametrEnable(const bool parametr)
{
if (parametr)
return QChar('*');
else
return QChar(' ');
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
@ -37,59 +46,82 @@ int main(int argc, char *argv[])
// translation
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
QDir::separator() + QString("netctl-gui.conf");
QFile configFile(configPath);
QString fileStr;
QString language = QString("english");
if (configFile.open(QIODevice::ReadOnly))
while (true) {
fileStr = QString(configFile.readLine());
if (fileStr[0] != '#') {
if (fileStr.contains(QString("LANGUAGE=")))
language = fileStr.split(QString("="))[1]
.remove(QString(" "))
.trimmed();
}
if (configFile.atEnd())
break;
}
configFile.close();
QString language = Language::defineLanguage(configPath);
QTranslator translator;
translator.load(QString(":/translations/") + language);
a.installTranslator(&translator);
QString helpMessage = QString("");
helpMessage += QApplication::translate("MainWindow", " Netctl GUI\n");
helpMessage += QApplication::translate("MainWindow", "Version : %1 License : GPLv3\n")
.arg(QString(VERSION));
helpMessage += QApplication::translate("MainWindow", " Evgeniy Alekseev aka arcanis\n");
helpMessage += QApplication::translate("MainWindow", " E-mail : esalexeev@gmail.com\n\n");
helpMessage += QApplication::translate("MainWindow", "Usage:\n");
helpMessage += QApplication::translate("MainWindow", "netctl-gui [ --default ] [ -t NUM | --tab NUM ] [ -h | --help]\n\n");
helpMessage += QApplication::translate("MainWindow", "Parametrs:\n");
helpMessage += QApplication::translate("MainWindow", " --default - start with default settings\n");
helpMessage += QApplication::translate("MainWindow", " -t NUM --tab NUM - open a tab with number NUM\n");
helpMessage += QApplication::translate("MainWindow", " -h --help - show this help and exit\n");
// reading command line flags
bool error = false;
// windows
bool showAbout = false;
bool showNetctlAuto = false;
bool showSettings = false;
// main functions
QString selectEssid = QString("ESSID");
QString openProfile = QString("PROFILE");
QString selectProfile = QString("PROFILE");
// additional functions
bool debug = false;
bool defaultSettings = false;
int tabNumber = 0;
QString options = QString("OPTIONS");
int tabNumber = 1;
// messages
bool showVersion = false;
bool showInfo = false;
bool showHelp = false;
// reading
for (int i=1; i<argc; i++) {
// help message
if (((argv[i][0] == '-') && (argv[i][1] == 'h') && (argv[i][2] == '\0')) ||
((argv[i][0] == '-') && (argv[i][1] == '-') && (argv[i][2] == 'h') && (argv[i][3] == 'e') &&
(argv[i][4] == 'l') && (argv[i][5] == 'p') && (argv[i][6] == '\0'))) {
cout << helpMessage.toUtf8().data();
return 0;
// windows
// about
if (QString(argv[i]) == QString("--about")) {
showAbout = true;
}
// netctl-auto
else if (QString(argv[i]) == QString("--netctl-auto")) {
showNetctlAuto = true;
}
// settings
else if (QString(argv[i]) == QString("--settings")) {
showSettings = true;
}
// main functions
// select ESSID
else if ((QString(argv[i]) == QString("-e")) || (QString(argv[i]) == QString("--essid"))) {
selectEssid = QString(argv[i+1]);
i++;
}
// open profile
else if ((QString(argv[i]) == QString("-o")) || (QString(argv[i]) == QString("--open"))) {
openProfile = QString(argv[i+1]);
i++;
}
// select profile
else if ((QString(argv[i]) == QString("-s")) || (QString(argv[i]) == QString("--select"))) {
selectProfile = QString(argv[i+1]);
i++;
}
// additional functions
// config path
else if (QString(argv[i]) == QString("--config")) {
configPath = QString(argv[i+1]);
i++;
}
// debug
else if ((QString(argv[i]) == QString("-d")) || (QString(argv[i]) == QString("--debug"))) {
debug = true;
}
// default settings
else if ((argv[i][0] == '-') && (argv[i][1] == '-') && (argv[i][2] == 'd') && (argv[i][3] == 'e') &&
(argv[i][4] == 'f') && (argv[i][5] == 'a') && (argv[i][6] == 'u') && (argv[i][7] == 'l') &&
(argv[i][8] == 't') && (argv[i][9] == '\0')) {
else if (QString(argv[i]) == QString("--default")) {
defaultSettings = true;
}
// options
else if (QString(argv[i]) == QString("--set-opts")) {
options = QString(argv[i+1]);
i++;
}
// tab number
else if (((argv[i][0] == '-') && (argv[i][1] == 't') && (argv[i][2] == '\0')) ||
((argv[i][0] == '-') && (argv[i][1] == '-') && (argv[i][2] == 't') &&
(argv[i][3] == 'a') && (argv[i][4] == 'b') && (argv[i][5] == '\0'))) {
else if ((QString(argv[i]) == QString("-t")) || (QString(argv[i]) == QString("--tab"))) {
if (atoi(argv[i+1]) > 3)
tabNumber = 3;
else if (atoi(argv[i+1]) < 1)
@ -98,9 +130,146 @@ int main(int argc, char *argv[])
tabNumber = atoi(argv[i+1]);
i++;
}
// messages
// version message
else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
showVersion = true;
}
// info message
else if ((QString(argv[i]) == QString("-i")) || (QString(argv[i]) == QString("--info"))) {
showInfo = true;
}
// help message
else if ((QString(argv[i]) == QString("-h")) || (QString(argv[i]) == QString("--help"))) {
showHelp = true;
}
else {
error = true;
}
}
if (selectEssid != QString("ESSID"))
tabNumber = 3;
if (openProfile != QString("PROFILE"))
tabNumber = 2;
if (selectProfile != QString("PROFILE"))
tabNumber = 1;
MainWindow w(0, defaultSettings, tabNumber);
// messages
QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n");
QString helpMessage = QString("");
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Usage:"));
helpMessage += QString("netctl-gui [ --about ] [ --netctl-auto ] [ --settings ]\n");
helpMessage += QString(" [ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]\n");
helpMessage += QString(" [ -s PROFILE | --select PROFILE ]\n");
helpMessage += QString(" [ --config FILE ] [ -d | --debug ] [ --default ]\n");
helpMessage += QString(" [ --set-opts OPTIONS ] [ -t NUM | --tab NUM ]\n");
helpMessage += QString(" [ -v | --version ] [ -i | --info ] [ -h | --help]\n\n");
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Parametrs:"));
// windows
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Open window:"));
helpMessage += QString("%1 --about - %2\n")
.arg(isParametrEnable(showAbout))
.arg(QApplication::translate("MainWindow", "show about window"));
helpMessage += QString("%1 --netctl-auto - %2\n")
.arg(isParametrEnable(showNetctlAuto))
.arg(QApplication::translate("MainWindow", "show netctl-auto window"));
helpMessage += QString("%1 --settings - %2\n")
.arg(isParametrEnable(showSettings))
.arg(QApplication::translate("MainWindow", "show settings window"));
// main functions
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Functions:"));
helpMessage += QString(" -e %1 --essid %1 - %2\n")
.arg(selectEssid, -10)
.arg(QApplication::translate("MainWindow", "select ESSID %1").arg(selectEssid));
helpMessage += QString(" -o %1 --open %1 - %2\n")
.arg(openProfile, -10)
.arg(QApplication::translate("MainWindow", "open profile %1").arg(openProfile));
helpMessage += QString(" -s %1 --select %1 - %2\n")
.arg(selectProfile, -10)
.arg(QApplication::translate("MainWindow", "select profile %1").arg(selectProfile));
// additional functions
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Additional flags:"));
helpMessage += QString(" --config %1\n")
.arg(configPath, -10);
helpMessage += QString(" - %1\n")
.arg(QApplication::translate("MainWindow", "read configuration from this file"));
helpMessage += QString("%1 -d --debug - %2\n")
.arg(isParametrEnable(debug))
.arg(QApplication::translate("MainWindow", "print debug information"));
helpMessage += QString("%1 --default - %2\n")
.arg(isParametrEnable(defaultSettings))
.arg(QApplication::translate("MainWindow", "start with default settings"));
helpMessage += QString(" --set-opts %1\n")
.arg(options, -10);
helpMessage += QString(" - %1\n")
.arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
helpMessage += QString(" -t %1 --tab %1 - %2\n")
.arg(QString::number(tabNumber), -3)
.arg(QApplication::translate("MainWindow", "open a tab with number %1").arg(QString::number(tabNumber)));
// messages
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Show messages:"));
helpMessage += QString(" -v --version - %1\n")
.arg(QApplication::translate("MainWindow", "show version and exit"));
helpMessage += QString(" -i --info - %1\n")
.arg(QApplication::translate("MainWindow", "show build information and exit"));
helpMessage += QString(" -h --help - %1\n")
.arg(QApplication::translate("MainWindow", "show this help and exit"));
QString infoMessage = QString("");
infoMessage += QApplication::translate("MainWindow", "Build date: %1").
arg(QString(BUILD_DATE));
infoMessage += QString("\n%1\n").arg(QApplication::translate("MainWindow", "cmake flags:"));
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1 \\\n").arg(QString(CMAKE_BUILD_TYPE));
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1 \\\n").arg(QString(CMAKE_INSTALL_PREFIX));
infoMessage += QString("\t-DBUILD_DOCS=%1 \\\n").arg(QString(PROJECT_BUILD_DOCS));
infoMessage += QString("\t-DBUILD_LIBRARY=%1 \\\n").arg(QString(PROJECT_BUILD_LIBRARY));
infoMessage += QString("\t-DBUILD_GUI=%1 \\\n").arg(QString(PROJECT_BUILD_GUI));
infoMessage += QString("\t-DUSE_QT5=%1 \\\n").arg(QString(PROJECT_USE_QT5));
infoMessage += QString("\t-DBUILD_DATAENGINE=%1 \\\n").arg(QString(PROJECT_BUILD_DATAENGINE));
infoMessage += QString("\t-DBUILD_PLASMOID=%1\n").arg(QString(PROJECT_BUILD_PLASMOID));
QString versionMessage = QString("");
versionMessage += QString("%1\n").arg(QString(NAME));
versionMessage += QString("%1 : %2\n")
.arg(QApplication::translate("MainWindow", "Version"))
.arg(QString(VERSION));
versionMessage += QString("%1 : %2\n")
.arg(QApplication::translate("MainWindow", "Author"))
.arg(QString(AUTHOR));
versionMessage += QString("%1 : %2\n")
.arg(QApplication::translate("MainWindow", "License"))
.arg(QString(LICENSE));
// reread translations
a.removeTranslator(&translator);
language = Language::defineLanguage(configPath, options);
translator.load(QString(":/translations/") + language);
a.installTranslator(&translator);
// running
if (error) {
cout << errorMessage.toUtf8().data() << endl;
cout << helpMessage.toUtf8().data();
return 127;
}
if (showInfo) {
cout << versionMessage.toUtf8().data() << endl;
cout << infoMessage.toUtf8().data();
return 0;
}
if (showHelp) {
cout << helpMessage.toUtf8().data();
return 0;
}
if (showVersion) {
cout << versionMessage.toUtf8().data();
return 0;
}
MainWindow w(0,
showAbout, showNetctlAuto, showSettings,
selectEssid, openProfile, selectProfile,
configPath, debug, defaultSettings, options, tabNumber);
w.show();
return a.exec();
}

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef MAINWINDOW_H
@ -23,13 +23,16 @@
#include <QTableWidgetItem>
class AboutWindow;
class BridgeWidget;
class ErrorWindow;
class EthernetWidget;
class GeneralWidget;
class IpWidget;
class MacvlanWidget;
class MobileWidget;
class Netctl;
class NetctlAutoWindow;
class NetctlProfile;
class PasswdWidget;
class PppoeWidget;
@ -47,37 +50,55 @@ class MainWindow;
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0,
const bool showAbout = false,
const bool showNetctlAuto = false,
const bool showSettings = false,
const QString selectEssid = QString("ESSID"),
const QString openProfile = QString("PROFILE"),
const QString selectProfile = QString("PROFILE"),
const QString configPath = QString(""),
const bool debugCmd = false,
const bool defaultSettings = false,
const QString options = QString("OPTIONS"),
const int tabNum = 1);
~MainWindow();
Netctl *netctlCommand;
NetctlProfile *netctlProfile;
WpaSup *wpaCommand;
public slots:
void updateTabs(const int tab);
void updateMenu(const int tab);
// wifi tab slots
void connectToUnknownEssid(const QString passwd);
void setHiddenName(const QString name);
private slots:
// menu update slots
void setMenuActionsShown(const bool state = true);
void updateMenuMain();
void updateMenuProfile();
void updateMenuWifi();
// tab update slots
void updateMainTab();
void updateProfileTab();
void updateWifiTab();
// main tab slots
void mainTabContextualMenu(const QPoint &pos);
void mainTabEditProfile();
void mainTabRemoveProfile();
void mainTabEnableProfile();
void mainTabRestartProfile();
void mainTabStartProfile();
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
// profile tab slots
void profileTabBrowseProfile();
void profileTabChangeState(const QString current);
void profileTabClear();
void profileTabCreateProfile();
void profileTabLoadProfile();
void profileTabRemoveProfile();
// wifi tab slots
void wifiTabContextualMenu(const QPoint &pos);
void wifiTabSetEnabled(const bool state);
void wifiTabStart();
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
@ -85,10 +106,16 @@ private slots:
private:
// ui
Ui::MainWindow *ui;
AboutWindow *aboutWin;
ErrorWindow *errorWin;
NetctlAutoWindow *netctlAutoWin;
PasswdWidget *passwdWid;
SettingsWindow *settingsWin;
BridgeWidget *bridgeWid;
EthernetWidget *ethernetWid;
GeneralWidget *generalWid;
IpWidget *ipWid;
MacvlanWidget *macvlanWid;
MobileWidget *mobileWid;
PppoeWidget *pppoeWid;
TunnelWidget *tunnelWid;
@ -96,14 +123,19 @@ private:
VlanWidget *vlanWid;
WirelessWidget *wirelessWid;
// backend
ErrorWindow *errorWin;
PasswdWidget *passwdWid;
SettingsWindow *settingsWin;
Netctl *netctlCommand;
NetctlProfile *netctlProfile;
WpaSup *wpaCommand;
bool checkExternalApps(const QString apps);
bool checkState(const QString state, const QString item);
void createActions();
void keyPressEvent(QKeyEvent *pressedKey);
void setIconsToButtons();
bool debug;
bool hiddenNetwork;
// configuration
QMap<QString, QString> configuration;
QMap<QString, QString> parseOptions(const QString options);
};

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>491</width>
<height>519</height>
<width>479</width>
<height>507</height>
</rect>
</property>
<property name="windowTitle">
@ -25,8 +25,37 @@
<string>Connect to profile</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget_netctlAuto" native="true">
<layout class="QHBoxLayout" name="layout_netctlAuto">
<item>
<widget class="QLabel" name="label_netctlAuto">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>netctl-auto is running</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_netctlAuto">
<property name="text">
<string>Show</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget_main">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
@ -99,19 +128,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_mainEnable">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Enable</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_mainRestart">
<property name="enabled">
@ -169,12 +185,12 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_profile"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_profile">
<property name="text">
<string>Browse</string>
<widget class="QComboBox" name="comboBox_profile">
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
@ -190,8 +206,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
<width>96</width>
<height>26</height>
</rect>
</property>
<property name="sizePolicy">
@ -213,13 +229,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_profileLoad">
<property name="text">
<string>Load</string>
</property>
</widget>
</item>
<item>
<spacer name="spacer_newProfileButtons">
<property name="orientation">
@ -261,6 +270,9 @@
</item>
<item>
<widget class="QTableWidget" name="tableWidget_wifi">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
@ -355,21 +367,54 @@
<rect>
<x>0</x>
<y>0</y>
<width>491</width>
<height>20</height>
<width>479</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuMenu">
<property name="title">
<string>Menu</string>
</property>
<addaction name="actionNetctlAuto"/>
<addaction name="actionSettings"/>
<addaction name="actionQuit"/>
</widget>
<widget class="QMenu" name="menuActions">
<property name="title">
<string>Actions</string>
</property>
<addaction name="actionMainRefresh"/>
<addaction name="actionWifiRefresh"/>
<addaction name="actionProfileClear"/>
<addaction name="separator"/>
<addaction name="actionMainStart"/>
<addaction name="actionMainRestart"/>
<addaction name="actionMainEnable"/>
<addaction name="actionProfileLoad"/>
<addaction name="actionProfileSave"/>
<addaction name="actionWifiStart"/>
<addaction name="separator"/>
<addaction name="actionMainEdit"/>
<addaction name="actionMainRemove"/>
<addaction name="actionProfileRemove"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Help</string>
</property>
<addaction name="actionAbout"/>
</widget>
<addaction name="menuMenu"/>
<addaction name="menuActions"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionSettings">
<property name="icon">
<iconset theme="configure">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Settings</string>
</property>
@ -378,6 +423,11 @@
</property>
</action>
<action name="actionQuit">
<property name="icon">
<iconset theme="exit">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Quit</string>
</property>
@ -385,19 +435,148 @@
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionMainRefresh">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Refresh</string>
</property>
</action>
<action name="actionMainStart">
<property name="icon">
<iconset theme="dialog-apply">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Start profile</string>
</property>
</action>
<action name="actionMainRestart">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Restart profile</string>
</property>
</action>
<action name="actionMainEnable">
<property name="icon">
<iconset theme="edit-add">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Enable profile</string>
</property>
</action>
<action name="actionMainEdit">
<property name="icon">
<iconset theme="edit">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Edit profile</string>
</property>
</action>
<action name="actionMainRemove">
<property name="icon">
<iconset theme="edit-delete">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Remove profile</string>
</property>
</action>
<action name="actionProfileClear">
<property name="icon">
<iconset theme="edit-clear">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Clear</string>
</property>
</action>
<action name="actionWifiRefresh">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Refresh</string>
</property>
</action>
<action name="actionProfileLoad">
<property name="icon">
<iconset theme="document-open">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Load profile</string>
</property>
</action>
<action name="actionProfileSave">
<property name="icon">
<iconset theme="document-save">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Save profile</string>
</property>
</action>
<action name="actionWifiStart">
<property name="icon">
<iconset theme="dialog-apply">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Start Wi-Fi</string>
</property>
</action>
<action name="actionProfileRemove">
<property name="icon">
<iconset theme="edit-delete">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Remove profile</string>
</property>
</action>
<action name="actionNetctlAuto">
<property name="text">
<string>netctl-auto</string>
</property>
</action>
<action name="actionAbout">
<property name="icon">
<iconset theme="help-about"/>
</property>
<property name="text">
<string>About</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>tableWidget_main</tabstop>
<tabstop>pushButton_mainRefresh</tabstop>
<tabstop>pushButton_mainEnable</tabstop>
<tabstop>pushButton_mainRestart</tabstop>
<tabstop>pushButton_mainStart</tabstop>
<tabstop>lineEdit_profile</tabstop>
<tabstop>pushButton_profile</tabstop>
<tabstop>scrollArea</tabstop>
<tabstop>pushButton_profileClear</tabstop>
<tabstop>pushButton_profileLoad</tabstop>
<tabstop>pushButton_profileSave</tabstop>
<tabstop>tableWidget_wifi</tabstop>
<tabstop>pushButton_wifiRefresh</tabstop>

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "mobilewidget.h"
@ -87,7 +87,7 @@ void MobileWidget::selectOptionsFile()
void MobileWidget::showAdvanced()
{
if (ui->pushButton_mobileAdvanced->isChecked()) {
ui->widget_mobileAdvanced->setShown(true);
ui->widget_mobileAdvanced->setHidden(false);
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
}
else {
@ -143,28 +143,29 @@ int MobileWidget::isOk()
void MobileWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> mobileSettings = settings;
if (mobileSettings.contains(QString("User")))
ui->lineEdit_username->setText(mobileSettings[QString("User")].remove(QString("'")));
ui->lineEdit_username->setText(mobileSettings[QString("User")]);
if (mobileSettings.contains(QString("Password")))
ui->lineEdit_password->setText(mobileSettings[QString("Password")].remove(QString("'")));
ui->lineEdit_password->setText(mobileSettings[QString("Password")]);
if (mobileSettings.contains(QString("AccessPointName")))
ui->lineEdit_apn->setText(mobileSettings[QString("AccessPointName")].remove(QString("'")));
ui->lineEdit_apn->setText(mobileSettings[QString("AccessPointName")]);
if (mobileSettings.contains(QString("PIN")))
ui->lineEdit_pin->setText(mobileSettings[QString("PIN")].remove(QString("'")));
ui->lineEdit_pin->setText(mobileSettings[QString("PIN")]);
if (mobileSettings.contains(QString("Mode")))
for (int i=0; i<ui->comboBox_mode->count(); i++)
if (mobileSettings[QString("Mode")].remove(QString("'")) == ui->comboBox_mode->itemText(i))
if (mobileSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
ui->comboBox_mode->setCurrentIndex(i);
if (mobileSettings.contains(QString("MaxFail")))
ui->spinBox_fail->setValue(mobileSettings[QString("MaxFail")].toInt());
if (mobileSettings.contains(QString("DefaultRoute")))
if (mobileSettings[QString("DefaultRoute")].remove(QString("'")) == QString("false"))
if (mobileSettings[QString("DefaultRoute")] == QString("false"))
ui->checkBox_route->setCheckState(Qt::Unchecked);
if (mobileSettings.contains(QString("UsePeerDNS")))
if (mobileSettings[QString("UsePeerDNS")].remove(QString("'")) == QString("false"))
if (mobileSettings[QString("UsePeerDNS")] == QString("false"))
ui->checkBox_dns->setCheckState(Qt::Unchecked);
if (mobileSettings.contains(QString("OptionsFile")))
ui->lineEdit_options->setText(mobileSettings[QString("OptionsFile")].remove(QString("'")));
ui->lineEdit_options->setText(mobileSettings[QString("OptionsFile")]);
}

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef MOBILEWIDGET_H

View File

@ -0,0 +1,377 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "netctlautowindow.h"
#include "ui_netctlautowindow.h"
#include <QDebug>
#include <netctlgui/netctlinteract.h>
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const QMap<QString, QString> settings)
: QMainWindow(parent),
ui(new Ui::NetctlAutoWindow),
debug(debugCmd)
{
ui->setupUi(this);
netctlCommand = new Netctl(debug, settings);
createActions();
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Ready"));
}
NetctlAutoWindow::~NetctlAutoWindow()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[~NetctlAutoWindow]";
delete ui;
delete netctlCommand;
}
void NetctlAutoWindow::createActions()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[createActions]";
// menu actions
connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close()));
connect(ui->actionDisableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoDisableAllProfiles()));
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableProfile()));
connect(ui->actionEnableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableAllProfiles()));\
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(netctlAutoUpdateTable()));
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartProfile()));
// service
connect(ui->actionEnableService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableService()));
connect(ui->actionRestartService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoRestartService()));
connect(ui->actionStartService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartService()));
// table actions
connect(ui->tableWidget, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(netctlAutoStartProfile()));
connect(ui->tableWidget, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(netctlAutoRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(netctlAutoContextualMenu(QPoint)));
// buttons
connect(ui->pushButton_enable, SIGNAL(clicked(bool)), this, SLOT(netctlAutoEnableProfile()));
connect(ui->pushButton_refresh, SIGNAL(clicked(bool)), this, SLOT(netctlAutoUpdateTable()));
connect(ui->pushButton_switch, SIGNAL(clicked(bool)), this, SLOT(netctlAutoStartProfile()));
}
void NetctlAutoWindow::showWindow()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[showWindow]";
netctlAutoUpdateTable();
show();
}
void NetctlAutoWindow::netctlAutoUpdateTable()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoUpdateTable]";
ui->tableWidget->setDisabled(true);
QList<QStringList> profiles = netctlCommand->getProfileListFromNetctlAuto();
// actions
if (netctlCommand->isNetctlAutoEnabled())
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
else
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
ui->actionEnableService->setVisible(true);
if (netctlCommand->isNetctlAutoRunning()) {
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
ui->actionRestartService->setVisible(true);
}
else {
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
ui->actionRestartService->setVisible(false);
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running"));
netctlAutoRefreshButtons(0, 0);
return;
}
ui->tableWidget->setSortingEnabled(false);
ui->tableWidget->selectRow(-1);
ui->tableWidget->sortByColumn(0, Qt::AscendingOrder);
ui->tableWidget->clear();
ui->tableWidget->setRowCount(profiles.count());
// create header
QStringList headerList;
headerList.append(QApplication::translate("NetctlAutoWindow", "Name"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Description"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Active"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Disabled"));
ui->tableWidget->setHorizontalHeaderLabels(headerList);
// create items
for (int i=0; i<profiles.count(); i++) {
// name
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(profiles[i][0]));
ui->tableWidget->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
if (profiles[i][2] == QString("*")) {
QFont font;
font.setBold(true);
ui->tableWidget->item(i, 0)->setFont(font);
}
else if (profiles[i][2] == QString("!")) {
QFont font;
font.setItalic(true);
ui->tableWidget->item(i, 0)->setFont(font);
}
// description
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i][1]));
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
if (profiles[i][2] == QString("*")) {
// active
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QApplication::translate("NetctlAutoWindow", "yes")));
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
else
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QString("")));
if (profiles[i][2] == QString("!")) {
// disabled
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(QApplication::translate("NetctlAutoWindow", "yes")));
ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
else
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(QString("")));
}
ui->tableWidget->setSortingEnabled(true);
ui->tableWidget->resizeRowsToContents();
#if QT_VERSION >= 0x050000
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
#else
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
#endif
ui->tableWidget->setEnabled(true);
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated"));
netctlAutoRefreshButtons(0, 0);
update();
}
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]";
if (ui->tableWidget->currentItem() == 0)
return;
// create menu
QMenu menu(this);
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
startProfile->setIcon(QIcon::fromTheme("dialog-apply"));
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
menu.addSeparator();
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
enableAllProfiles->setIcon(QIcon::fromTheme("edit-add"));
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
// set text
if (ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text() == QString("yes")) {
enableProfile->setVisible(false);
startProfile->setVisible(false);
}
else {
enableProfile->setVisible(true);
startProfile->setVisible(true);
if (ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text() == QString("yes")) {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
}
else {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
}
}
// actions
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
if (action == startProfile) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Switch to profile";
netctlAutoStartProfile();
}
else if (action == enableProfile) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable profile";
netctlAutoEnableProfile();
}
else if (action == enableAllProfiles) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable all profiles";
netctlAutoEnableAllProfiles();
}
else if (action == disableAllProfiles) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Disable all profiles";
netctlAutoDisableAllProfiles();
}
}
void NetctlAutoWindow::netctlAutoDisableAllProfiles()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoDisableAllProfiles]";
ui->tableWidget->setDisabled(true);
if (netctlCommand->autoDisableAllProfiles())
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoEnableProfile()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableProfile]";
if (ui->tableWidget->currentItem() == 0)
return;
ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
if (netctlCommand->autoEnableProfile(profile))
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoEnableAllProfiles()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableAllProfiles]";
ui->tableWidget->setDisabled(true);
if (netctlCommand->autoEnableAllProfiles())
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoStartProfile()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoStartProfile]";
if (ui->tableWidget->currentItem() == 0)
return;
ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
if (netctlCommand->autoStartProfile(profile))
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoEnableService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableService]";
if (netctlCommand->autoEnableService())
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoRestartService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoRestartService]";
if (netctlCommand->autoRestartService())
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoStartService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoStartService]";
if (netctlCommand->autoStartService())
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
{
Q_UNUSED(previous);
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoRefreshButtons]";
if (current == 0) {
// buttons
ui->pushButton_enable->setDisabled(true);
ui->pushButton_switch->setDisabled(true);
// menu
ui->actionEnable->setVisible(false);
ui->actionSwitch->setVisible(false);
return;
}
if (ui->tableWidget->item(current->row(), 2)->text() == QString("yes")) {
// buttons
ui->pushButton_enable->setDisabled(true);
ui->pushButton_switch->setDisabled(true);
// menu
ui->actionEnable->setVisible(false);
ui->actionSwitch->setVisible(false);
}
else {
// buttons
ui->pushButton_enable->setEnabled(true);
ui->pushButton_switch->setEnabled(true);
// menu
ui->actionEnable->setVisible(true);
ui->actionSwitch->setVisible(true);
if (ui->tableWidget->item(current->row(), 3)->text() == QString("yes")) {
// buttons
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-add"));
// menu
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
ui->actionEnable->setIcon(QIcon::fromTheme("edit-add"));
}
else {
// buttons
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-delete"));
// menu
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable profile"));
ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete"));
}
}
}

View File

@ -0,0 +1,68 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef NETCTLAUTOWINDOW_H
#define NETCTLAUTOWINDOW_H
#include <QKeyEvent>
#include <QMainWindow>
#include <QTableWidgetItem>
class Netctl;
namespace Ui {
class NetctlAutoWindow;
}
class NetctlAutoWindow : public QMainWindow
{
Q_OBJECT
public:
explicit NetctlAutoWindow(QWidget *parent = 0,
const bool debugCmd = false,
const QMap<QString, QString> settings = QMap<QString, QString>());
~NetctlAutoWindow();
public slots:
void showWindow();
private slots:
// table
void netctlAutoContextualMenu(const QPoint &pos);
void netctlAutoUpdateTable();
// netctl-auto
void netctlAutoDisableAllProfiles();
void netctlAutoEnableProfile();
void netctlAutoEnableAllProfiles();
void netctlAutoStartProfile();
void netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
// service
void netctlAutoEnableService();
void netctlAutoRestartService();
void netctlAutoStartService();
private:
Netctl *netctlCommand;
Ui::NetctlAutoWindow *ui;
bool debug;
void createActions();
};
#endif /* NETCTLAUTOWINDOW_H */

View File

@ -0,0 +1,240 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NetctlAutoWindow</class>
<widget class="QMainWindow" name="NetctlAutoWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>343</height>
</rect>
</property>
<property name="windowTitle">
<string>netctl-auto</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_info">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Description</string>
</property>
</column>
<column>
<property name="text">
<string>Active</string>
</property>
</column>
<column>
<property name="text">
<string>Disabled</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_buttons">
<item>
<widget class="QPushButton" name="pushButton_refresh">
<property name="text">
<string>Refresh</string>
</property>
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
</widget>
</item>
<item>
<spacer name="spacer_buttons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_enable">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Enable</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_switch">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Switch</string>
</property>
<property name="icon">
<iconset theme="dialog-apply">
<normaloff/>
</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>432</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuMenu">
<property name="title">
<string>Menu</string>
</property>
<addaction name="actionRefresh"/>
<addaction name="separator"/>
<addaction name="actionSwitch"/>
<addaction name="actionEnable"/>
<addaction name="separator"/>
<addaction name="actionEnableAll"/>
<addaction name="actionDisableAll"/>
<addaction name="separator"/>
<addaction name="actionStartService"/>
<addaction name="actionRestartService"/>
<addaction name="actionEnableService"/>
<addaction name="separator"/>
<addaction name="actionClose"/>
</widget>
<addaction name="menuMenu"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionEnable">
<property name="icon">
<iconset theme="edit-add">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Enable profile</string>
</property>
</action>
<action name="actionSwitch">
<property name="icon">
<iconset theme="dialog-apply">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Switch to profile</string>
</property>
</action>
<action name="actionClose">
<property name="icon">
<iconset theme="exit">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Close</string>
</property>
<property name="shortcut">
<string>Esc</string>
</property>
</action>
<action name="actionEnableAll">
<property name="icon">
<iconset theme="edit-add">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Enable all profiles</string>
</property>
</action>
<action name="actionDisableAll">
<property name="icon">
<iconset theme="edit-delete">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Disable all profiles</string>
</property>
</action>
<action name="actionStartService">
<property name="text">
<string>Start service</string>
</property>
</action>
<action name="actionRestartService">
<property name="text">
<string>Restart service</string>
</property>
</action>
<action name="actionEnableService">
<property name="text">
<string>Enable service</string>
</property>
</action>
<action name="actionRefresh">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Refresh</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,228 +0,0 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* *
* netctl-plasmoid 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. *
* *
* netctl-plasmoid 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "netctlinteract.h"
#include <QDebug>
#include <QFile>
#include <QProcess>
#include "mainwindow.h"
Netctl::Netctl(MainWindow *wid, const QMap<QString, QString> settings)
: parent(wid)
{
netctlCommand = settings[QString("NETCTL_PATH")];
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
sudoCommand = settings[QString("SUDO_PATH")];
}
Netctl::~Netctl()
{
delete profileDirectory;
}
// functions
QString Netctl::getNetctlOutput(const bool sudo, const QString commandLine, const QString profile)
{
QProcess command;
QString commandText;
if (sudo)
commandText = sudoCommand + QString(" ") + netctlCommand + QString(" ") + commandLine +
QString(" ") + profile;
else
commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile;
qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
return command.readAllStandardOutput();
}
bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QString profile)
{
QProcess command;
QString commandText;
if (sudo)
commandText = sudoCommand + QString(" ") + netctlCommand + QString(" ") + commandLine +
QString(" ") + profile;
else
commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile;
qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() == 0)
return true;
else
return false;
}
// general information
QList<QStringList> Netctl::getProfileList()
{
QList<QStringList> fullProfilesInfo;
QStringList profiles = profileDirectory->entryList(QDir::Files);
QStringList descriptions = getProfileDescriptions(profiles);
QStringList statuses = getProfileStatuses(profiles);
for (int i=0; i<profiles.count(); i++) {
QStringList profileInfo;
profileInfo.append(profiles[i]);
profileInfo.append(descriptions[i]);
profileInfo.append(statuses[i]);
fullProfilesInfo.append(profileInfo);
}
return fullProfilesInfo;
}
QStringList Netctl::getProfileDescriptions(const QStringList profileList)
{
QStringList descriptions;
for (int i=0; i<profileList.count(); i++) {
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profileList[i];
qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Check" << profileUrl;
QFile profile(profileUrl);
QString fileStr;
if (profile.open(QIODevice::ReadOnly))
while (true) {
fileStr = QString(profile.readLine());
if (fileStr[0] != '#')
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2)
if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("Description"))
descriptions.append(fileStr.split(QString("="), QString::SkipEmptyParts)[1].trimmed());
if (profile.atEnd())
break;
}
else
descriptions.append(QString("<unknown>"));
}
for (int i=0; i<profileList.count(); i++) {
descriptions[i].remove(QChar('\''));
descriptions[i].remove(QChar('"'));
}
return descriptions;
}
QStringList Netctl::getProfileStatuses(const QStringList profileList)
{
QStringList statuses;
for (int i=0; i<profileList.count(); i++) {
QString status;
if (isProfileActive(profileList[i]))
status = QString("active");
else
status = QString("inactive");
if (isProfileEnabled(profileList[i]))
status = status + QString(" (enabled)");
else
status = status + QString(" (static)");
statuses.append(status);
}
return statuses;
}
QString Netctl::getSsidFromProfile(const QString profile)
{
QString ssidName = QString("");
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Check" << profileUrl;
QFile profileFile(profileUrl);
QString fileStr;
if (!profileFile.open(QIODevice::ReadOnly))
return ssidName;
while (true) {
fileStr = QString(profileFile.readLine());
if (fileStr[0] != '#') {
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2)
if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("ESSID"))
ssidName = fileStr.split(QString("="), QString::SkipEmptyParts)[1].trimmed();
}
if (profileFile.atEnd())
break;
}
profileFile.close();
ssidName.remove(QChar('\''));
ssidName.remove(QChar('"'));
return ssidName;
}
bool Netctl::isProfileActive(const QString profile)
{
bool status = false;
QString cmdOutput = getNetctlOutput(false, QString("status"), profile);
if (!cmdOutput.isEmpty())
if (cmdOutput.contains(QString("Active: active")))
status = true;
return status;
}
bool Netctl::isProfileEnabled(const QString profile)
{
bool status = false;
QString cmdOutput = getNetctlOutput(false, QString("status"), profile);
if (!cmdOutput.isEmpty()) {
QStringList profileStatus = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int i=0; i<profileStatus.count(); i++)
if (profileStatus[i].split(QString(" "), QString::SkipEmptyParts)[0] == QString("Loaded:"))
if (profileStatus[i].contains(QString("enabled")))
status = true;
}
return status;
}
// functions
bool Netctl::enableProfile(const QString profile)
{
if (isProfileEnabled(profile))
return netctlCall(true, QString("disable"), profile);
else
return netctlCall(true, QString("enable"), profile);
}
bool Netctl::restartProfile(const QString profile)
{
return netctlCall(true, QString("restart"), profile);
}
bool Netctl::startProfile(const QString profile)
{
if (isProfileActive(profile))
return netctlCall(true, QString("stop"), profile);
else
return netctlCall(true, QString("start"), profile);
}

View File

@ -1,61 +0,0 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* *
* netctl-plasmoid 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. *
* *
* netctl-plasmoid 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef NETCTLINTERACT_H
#define NETCTLINTERACT_H
#include <QDir>
#include <QMap>
#include <QObject>
class MainWindow;
class Netctl : public QObject
{
Q_OBJECT
public:
explicit Netctl(MainWindow *wid = 0,
const QMap<QString, QString> settings = QMap<QString, QString>());
~Netctl();
// general information
QList<QStringList> getProfileList();
QStringList getProfileDescriptions(const QStringList profileList);
QStringList getProfileStatuses(const QStringList profileList);
QString getSsidFromProfile(const QString profile);
bool isProfileActive(const QString profile);
bool isProfileEnabled(const QString profile);
public slots:
// functions
bool enableProfile(const QString profile);
bool restartProfile(const QString profile);
bool startProfile(const QString profile);
private:
MainWindow *parent;
QString netctlCommand;
QDir *profileDirectory;
QString sudoCommand;
// functions
QString getNetctlOutput(const bool sudo, const QString commandLine, const QString profile);
bool netctlCall(const bool sudo, const QString commandLine, const QString profile);
};
#endif /* NETCTLINTERACT_H */

View File

@ -1,156 +0,0 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* *
* netctl-plasmoid 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. *
* *
* netctl-plasmoid 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "netctlprofile.h"
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QProcess>
#include <QTextStream>
#include "mainwindow.h"
NetctlProfile::NetctlProfile(MainWindow *wid, const QMap<QString, QString> settings)
: parent(wid)
{
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
sudoCommand = settings[QString("SUDO_PATH")];
}
NetctlProfile::~NetctlProfile()
{
delete profileDirectory;
}
bool NetctlProfile::copyProfile(const QString oldPath)
{
QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
QProcess command;
QString commandText = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath;
qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (command.exitCode() == 0)
return true;
else
return false;
}
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings)
{
QString profileTempName = QDir::homePath() + QDir::separator() +
QString(".cache") + QDir::separator() + QFileInfo(profile).fileName();
QFile profileFile(profileTempName);
qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Save to" << profileTempName;
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
return profileTempName;
QTextStream out(&profileFile);
for (int i=0; i<settings.keys().count(); i++) {
out << settings.keys()[i] << QString("=");
if ((settings.keys()[i] == QString("BindsToInterfaces")) ||
(settings.keys()[i] == QString("After")) ||
(settings.keys()[i] == QString("Address")) ||
(settings.keys()[i] == QString("Routes")) ||
(settings.keys()[i] == QString("Address6")) ||
(settings.keys()[i] == QString("Routes6")) ||
(settings.keys()[i] == QString("IPCustom")) ||
(settings.keys()[i] == QString("DNS")) ||
(settings.keys()[i] == QString("DNSOptions")) ||
(settings.keys()[i] == QString("WPAConfigSection")) ||
(settings.keys()[i] == QString("WPAConfigSection")))
out << QString("(") + settings[settings.keys()[i]] << QString(")\n");
else
out << settings[settings.keys()[i]] << QString("\n");
}
profileFile.close();
return profileTempName;
}
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile)
{
QMap<QString, QString> settings;
QString fileStr, profileUrl;
if (profile[0] == QDir::separator())
profileUrl = profile;
else
profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
QFile profileFile(profileUrl);
qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Read from" << profileUrl;
if (!profileFile.open(QIODevice::ReadOnly))
return settings;
while (true) {
fileStr = QString(profileFile.readLine());
if (fileStr[0] != '#') {
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2) {
if ((fileStr.split(QString("="))[1][0] == QChar('(')) &&
(fileStr.split(QString("="))[1][fileStr.split(QString("="))[1].size()-2] == QChar(')')))
settings[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
.remove(QString("("))
.remove(QString(")"))
.trimmed();
else if (fileStr.split(QString("="))[1][0] == QChar('(')) {
QString parameterName = fileStr.split(QString("="))[0];
QStringList parameter;
if (!fileStr.split(QString("="))[1]
.remove(QString("("))
.remove(QString(")"))
.trimmed()
.isEmpty())
parameter.append(fileStr.split(QString("="))[1]
.remove(QString("("))
.remove(QString(")"))
.trimmed());
while(true) {
fileStr = QString(profileFile.readLine());
if (fileStr[fileStr.size()-2] == QChar(')'))
break;
if (!fileStr.remove(QString("("))
.remove(QString(")"))
.trimmed()
.isEmpty())
parameter.append(fileStr.remove(QString("("))
.remove(QString(")"))
.trimmed());
if (profileFile.atEnd())
break;
}
settings[parameterName] = parameter.join(QString("\n"));
}
else
settings[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
.trimmed();
}
}
if (profileFile.atEnd())
break;
}
profileFile.close();
return settings;
}

View File

@ -1,23 +1,25 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "passwdwidget.h"
#include "ui_passwdwidget.h"
#include <QLineEdit>
#include "mainwindow.h"
@ -59,6 +61,19 @@ void PasswdWidget::setFocusToLineEdit()
}
void PasswdWidget::setPassword(const bool mode)
{
if (mode) {
ui->lineEdit->setEchoMode(QLineEdit::Password);
ui->label->setText(QApplication::translate("PasswdWidget", "Password"));
}
else {
ui->lineEdit->setEchoMode(QLineEdit::Normal);
ui->label->setText(QApplication::translate("PasswdWidget", "ESSID"));
}
}
void PasswdWidget::cancel()
{
hide();
@ -70,5 +85,8 @@ void PasswdWidget::cancel()
void PasswdWidget::passwdApply()
{
hide();
return parent->connectToUnknownEssid(ui->lineEdit->text());
if (ui->lineEdit->echoMode() == QLineEdit::Normal)
return parent->setHiddenName(ui->lineEdit->text());
else
return parent->connectToUnknownEssid(ui->lineEdit->text());
}

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef PASSWDWIDGET_H
@ -39,6 +39,7 @@ public:
public slots:
void setFocusToLineEdit();
void setPassword(const bool mode = true);
private slots:
void cancel();

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "pppoewidget.h"
@ -96,7 +96,7 @@ void PppoeWidget::changeMode(const QString currentText)
if (currentText == QString("persist"))
ui->widget_timeout->setHidden(true);
else if (currentText == QString("demand"))
ui->widget_timeout->setShown(true);
ui->widget_timeout->setHidden(false);
}
@ -115,7 +115,7 @@ void PppoeWidget::selectOptionsFile()
void PppoeWidget::showAdvanced()
{
if (ui->pushButton_pppoeAdvanced->isChecked()) {
ui->widget_pppoeAdvanced->setShown(true);
ui->widget_pppoeAdvanced->setHidden(false);
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Hide advanced"));
}
else {
@ -157,9 +157,10 @@ QMap<QString, QString> PppoeWidget::getSettings()
pppoeSettings[QString("PPPoEService")] = QString("'") + ui->lineEdit_service->text() + QString("'");
if (!ui->lineEdit_ac->text().isEmpty())
pppoeSettings[QString("PPPoEAC")] = QString("'") + ui->lineEdit_ac->text() + QString("'");
if (!ui->lineEdit_session->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty())
pppoeSettings[QString("PPPoESession")] = QString("'") + ui->lineEdit_session->text().remove(QString(" ")) + QString("'");
if (!ui->lineEdit_mac->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty())
if (!ui->lineEdit_session->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
pppoeSettings[QString("PPPoESession")] = QString("'") + ui->lineEdit_session->text()
.remove(QChar('\'')).remove(QChar('"')) + QString("'");
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
pppoeSettings[QString("PPPoEMAC")] = QString("'") + ui->lineEdit_mac->text() + QString("'");
if (ui->checkBox_ipv6->checkState() == Qt::Checked)
pppoeSettings[QString("PPPoEIP6")] = QString("yes");
@ -175,18 +176,18 @@ int PppoeWidget::isOk()
if (!QFile(ui->lineEdit_options->text()).exists())
return 1;
// mac address
if (!ui->lineEdit_mac->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty())
if (ui->lineEdit_mac->text().contains(QString(" ")))
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
if (ui->lineEdit_mac->text().contains(QChar(' ')))
return 2;
// session id is not set
if (!ui->lineEdit_session->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty())
if (ui->lineEdit_session->text().split(QString(":"))[0].remove(QString(" ")).isEmpty())
if (!ui->lineEdit_session->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
if (ui->lineEdit_session->text().split(QChar(':'))[0].remove(QChar(' ')).isEmpty())
return 3;
// session mac address
if (!ui->lineEdit_session->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty()) {
QStringList item = ui->lineEdit_session->text().split(QString(":"));
if (!ui->lineEdit_session->text().remove(QChar(':')).remove(QChar(' ')).isEmpty()) {
QStringList item = ui->lineEdit_session->text().split(QChar(':'));
for (int i=1; i<7; i++)
if (item[i].contains(QString(" ")))
if (item[i].contains(QChar(' ')))
return 4;
}
// all fine
@ -196,25 +197,26 @@ int PppoeWidget::isOk()
void PppoeWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> pppoeSettings = settings;
if (pppoeSettings.contains(QString("User")))
ui->lineEdit_username->setText(pppoeSettings[QString("User")].remove(QString("'")));
ui->lineEdit_username->setText(pppoeSettings[QString("User")]);
if (pppoeSettings.contains(QString("Password")))
ui->lineEdit_password->setText(pppoeSettings[QString("Password")].remove(QString("'")));
ui->lineEdit_password->setText(pppoeSettings[QString("Password")]);
if (pppoeSettings.contains(QString("ConnectionMode")))
for (int i=0; i<ui->comboBox_connection->count(); i++)
if (pppoeSettings[QString("ConnectionMode")].remove(QString("'")) == ui->comboBox_connection->itemText(i))
if (pppoeSettings[QString("ConnectionMode")] == ui->comboBox_connection->itemText(i))
ui->comboBox_connection->setCurrentIndex(i);
if (pppoeSettings.contains(QString("IdleTimeout")))
ui->spinBox_timeout->setValue(pppoeSettings[QString("IdleTimeout")].toInt());
if (pppoeSettings.contains(QString("MaxFail")))
ui->spinBox_fail->setValue(pppoeSettings[QString("MaxFail")].toInt());
if (pppoeSettings.contains(QString("DefaultRoute")))
if (pppoeSettings[QString("DefaultRoute")].remove(QString("'")) == QString("false"))
if (pppoeSettings[QString("DefaultRoute")] == QString("false"))
ui->checkBox_route->setCheckState(Qt::Unchecked);
if (pppoeSettings.contains(QString("UsePeerDNS")))
if (pppoeSettings[QString("UsePeerDNS")].remove(QString("'")) == QString("false"))
if (pppoeSettings[QString("UsePeerDNS")] == QString("false"))
ui->checkBox_dns->setCheckState(Qt::Unchecked);
if (pppoeSettings.contains(QString("PPPUnit")))
ui->lineEdit_unit->setText(pppoeSettings[QString("PPPUnit")]);
@ -223,15 +225,15 @@ void PppoeWidget::setSettings(const QMap<QString, QString> settings)
if (pppoeSettings.contains(QString("LCPEchoFailure")))
ui->spinBox_lcpFailure->setValue(pppoeSettings[QString("LCPEchoFailure")].toInt());
if (pppoeSettings.contains(QString("OptionsFile")))
ui->lineEdit_options->setText(pppoeSettings[QString("OptionsFile")].remove(QString("'")));
ui->lineEdit_options->setText(pppoeSettings[QString("OptionsFile")]);
if (pppoeSettings.contains(QString("PPPoEService")))
ui->lineEdit_service->setText(pppoeSettings[QString("PPPoEService")].remove(QString("'")));
ui->lineEdit_service->setText(pppoeSettings[QString("PPPoEService")]);
if (pppoeSettings.contains(QString("PPPoEAC")))
ui->lineEdit_ac->setText(pppoeSettings[QString("PPPoEAC")].remove(QString("'")));
ui->lineEdit_ac->setText(pppoeSettings[QString("PPPoEAC")]);
if (pppoeSettings.contains(QString("PPPoESession")))
ui->lineEdit_session->setText(pppoeSettings[QString("PPPoESession")].remove(QString("'")));
ui->lineEdit_session->setText(pppoeSettings[QString("PPPoESession")]);
if (pppoeSettings.contains(QString("PPPoEMAC")))
ui->lineEdit_mac->setText(pppoeSettings[QString("PPPoEMAC")].remove(QString("'")));
ui->lineEdit_mac->setText(pppoeSettings[QString("PPPoEMAC")]);
if (pppoeSettings.contains(QString("PPPoEIP6")))
if (pppoeSettings[QString("PPPoEIP6")] == QString("yes"))
ui->checkBox_dns->setCheckState(Qt::Checked);

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef PPPOEWIDGET_H

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "settingswindow.h"
@ -23,12 +23,12 @@
#include <QFileDialog>
#include <QTextStream>
#include "mainwindow.h"
#include "language.h"
SettingsWindow::SettingsWindow(MainWindow *wid, const QString configFile)
: QMainWindow(wid),
parent(wid),
SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QString configFile)
: QMainWindow(parent),
debug(debugCmd),
file(configFile),
ui(new Ui::SettingsWindow)
{
@ -40,23 +40,32 @@ SettingsWindow::SettingsWindow(MainWindow *wid, const QString configFile)
SettingsWindow::~SettingsWindow()
{
if (debug) qDebug() << "[SettingsWindow]" << "[~SettingsWindow]";
delete ui;
}
void SettingsWindow::createActions()
{
connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
if (debug) qDebug() << "[SettingsWindow]" << "[createActions]";
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(close()));
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(saveSettings()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(close()));
connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
// buttons
connect(ui->pushButton_interfaceDir, SIGNAL(clicked(bool)), SLOT(selectIfaceDir()));
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), SLOT(selectNetctlPath()));
connect(ui->pushButton_netctlAutoPath, SIGNAL(clicked(bool)), SLOT(selectNetctlAutoPath()));
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), SLOT(selectProfileDir()));
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), SLOT(selectRfkillDir()));
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), SLOT(selectSudoPath()));
connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), SLOT(selectSystemctlPath()));
connect(ui->pushButton_wpaActiondPath, SIGNAL(clicked(bool)), SLOT(selectWpaActiondPath()));
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), SLOT(selectWpaCliPath()));
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), SLOT(selectWpaSupPath()));
}
@ -65,6 +74,8 @@ void SettingsWindow::createActions()
// ESC press event
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << "[SettingsWindow]" << "[keyPressEvent]";
if (pressedKey->key() == Qt::Key_Escape)
close();
}
@ -72,27 +83,45 @@ void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
void SettingsWindow::addLanguages()
{
ui->comboBox_language->addItem(QString("english"));
ui->comboBox_language->addItem(QString("russian"));
if (debug) qDebug() << "[SettingsWindow]" << "[addLanguages]";
ui->comboBox_language->clear();
ui->comboBox_language->addItems(Language::getAvailableLanguages());
}
void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
Q_UNUSED(previous)
if (debug) qDebug() << "[SettingsWindow]" << "[changePage]";
for (int i=0; i<ui->treeWidget->topLevelItemCount(); i++)
if (current == ui->treeWidget->topLevelItem(i)) {
ui->stackedWidget->setCurrentIndex(i);
break;
}
}
void SettingsWindow::saveSettings()
{
if (debug) qDebug() << "[SettingsWindow]" << "[saveSettings]";
QMap<QString, QString> settings = readSettings();
QFile configFile(file);
if (!configFile.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream out(&configFile);
for (int i=0; i<settings.keys().count(); i++)
out << settings.keys()[i] << QString("=") << settings[settings.keys()[i]] << QString("\n");
out << settings.keys()[i] << QString("=") << settings[settings.keys()[i]] << endl;
configFile.close();
}
void SettingsWindow::setDefault()
{
if (debug) qDebug() << "[SettingsWindow]" << "[setDefault]";
setSettings(getDefault());
saveSettings();
}
@ -100,6 +129,8 @@ void SettingsWindow::setDefault()
void SettingsWindow::selectIfaceDir()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectIfaceDir]";
QString directory = QFileDialog::getExistingDirectory(
this,
QApplication::translate("SettingsWindow", "Select path to directory with interfaces"),
@ -111,6 +142,8 @@ void SettingsWindow::selectIfaceDir()
void SettingsWindow::selectNetctlPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectNetctlPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select netctl command"),
@ -121,8 +154,24 @@ void SettingsWindow::selectNetctlPath()
}
void SettingsWindow::selectNetctlAutoPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectNetctlAutoPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select netctl-auto command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_netctlAutoPath->setText(filename);
}
void SettingsWindow::selectProfileDir()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectProfileDir]";
QString directory = QFileDialog::getExistingDirectory(
this,
QApplication::translate("SettingsWindow", "Select path to profile directory"),
@ -134,6 +183,8 @@ void SettingsWindow::selectProfileDir()
void SettingsWindow::selectRfkillDir()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectRfkillDir]";
QString directory = QFileDialog::getExistingDirectory(
this,
QApplication::translate("SettingsWindow", "Select path to directory with rfkill devices"),
@ -145,6 +196,8 @@ void SettingsWindow::selectRfkillDir()
void SettingsWindow::selectSudoPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectSudoPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select sudo command"),
@ -155,8 +208,38 @@ void SettingsWindow::selectSudoPath()
}
void SettingsWindow::selectSystemctlPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectSystemctlPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select systemctl command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_systemctlPath->setText(filename);
}
void SettingsWindow::selectWpaActiondPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaActiondPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select wpa_actiond command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_wpaActiondPath->setText(filename);
}
void SettingsWindow::selectWpaCliPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaCliPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select wpa_cli command"),
@ -169,6 +252,8 @@ void SettingsWindow::selectWpaCliPath()
void SettingsWindow::selectWpaSupPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaSupPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select wpa_supplicant command"),
@ -181,32 +266,39 @@ void SettingsWindow::selectWpaSupPath()
void SettingsWindow::showWindow()
{
if (debug) qDebug() << "[SettingsWindow]" << "[showWindow]";
setSettings(getSettings());
ui->label_info->hide();
show();
}
QMap<QString, QString> SettingsWindow::readSettings()
{
QMap<QString, QString> settings;
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]";
QMap<QString, QString> settings;
settings[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
settings[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->text();
settings[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
settings[QString("LANGUAGE")] = ui->comboBox_language->currentText();
settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
settings[QString("NETCTLAUTO_PATH")] = ui->lineEdit_netctlAutoPath->text();
settings[QString("NETCTLAUTO_SERVICE")] = ui->lineEdit_netctlAutoService->text();
settings[QString("PID_FILE")] = ui->lineEdit_pid->text();
settings[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
settings[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
settings[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
settings[QString("SUDO_PATH")] = ui->lineEdit_sudo->text();
settings[QString("SYSTEMCTL_PATH")] = ui->lineEdit_systemctlPath->text();
settings[QString("WPAACTIOND_PATH")] = ui->lineEdit_wpaActiondPath->text();
settings[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
for (int i=0; i<settings.keys().count(); i++)
qDebug() << "[SettingsWindow]" << "[readSettings]" << ":" <<
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
@ -215,6 +307,8 @@ QMap<QString, QString> SettingsWindow::readSettings()
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
{
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]";
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
@ -223,41 +317,48 @@ void SettingsWindow::setSettings(const QMap<QString, QString> settings)
if (ui->comboBox_language->itemText(i) == settings[QString("LANGUAGE")])
ui->comboBox_language->setCurrentIndex(i);
ui->lineEdit_netctlPath->setText(settings[QString("NETCTL_PATH")]);
ui->lineEdit_netctlAutoPath->setText(settings[QString("NETCTLAUTO_PATH")]);
ui->lineEdit_netctlAutoService->setText(settings[QString("NETCTLAUTO_SERVICE")]);
ui->lineEdit_pid->setText(settings[QString("PID_FILE")]);
ui->lineEdit_interface->setText(settings[QString("PREFERED_IFACE")]);
ui->lineEdit_profilePath->setText(settings[QString("PROFILE_DIR")]);
ui->lineEdit_rfkill->setText(settings[QString("RFKILL_DIR")]);
ui->lineEdit_sudo->setText(settings[QString("SUDO_PATH")]);
ui->lineEdit_systemctlPath->setText(settings[QString("SYSTEMCTL_PATH")]);
ui->lineEdit_wpaActiondPath->setText(settings[QString("WPAACTIOND_PATH")]);
ui->lineEdit_wpaCliPath->setText(settings[QString("WPACLI_PATH")]);
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
for (int i=0; i<settings.keys().count(); i++)
qDebug() << "[SettingsWindow]" << "[setSettings]" << ":" <<
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
}
QMap<QString, QString> SettingsWindow::getDefault()
{
QMap<QString, QString> settings;
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]";
QMap<QString, QString> settings;
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
settings[QString("CTRL_GROUP")] = QString("users");
settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
settings[QString("LANGUAGE")] = QString("english");
settings[QString("LANGUAGE")] = QString("en");
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");
settings[QString("NETCTLAUTO_PATH")] = QString("/usr/bin/netctl-auto");
settings[QString("NETCTLAUTO_SERVICE")] = QString("netctl-auto");
settings[QString("PID_FILE")] = QString("/run/wpa_supplicant_netctl-gui.pid");
settings[QString("PREFERED_IFACE")] = QString("");
settings[QString("PROFILE_DIR")] = QString("/etc/netctl/");
settings[QString("RFKILL_DIR")] = QString("/sys/class/rfkill/");
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl");
settings[QString("WPAACTIOND_PATH")] = QString("/usr/bin/wpa_actiond");
settings[QString("WPACLI_PATH")] = QString("/usr/bin/wpa_cli");
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
for (int i=0; i<settings.keys().count(); i++)
qDebug() << "[SettingsWindow]" << "[getDefault]" << ":" <<
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
@ -266,28 +367,25 @@ QMap<QString, QString> SettingsWindow::getDefault()
QMap<QString, QString> SettingsWindow::getSettings()
{
QMap<QString, QString> settings;
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]";
QMap<QString, QString> settings = getDefault();
QFile configFile(file);
QString fileStr;
if (!configFile.open(QIODevice::ReadOnly))
return getDefault();
return settings;
while (true) {
fileStr = QString(configFile.readLine());
if (fileStr[0] != '#') {
if (fileStr.contains(QString("=")))
settings[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
.remove(QString(" "))
.trimmed();
}
fileStr = QString(configFile.readLine()).trimmed();
if (fileStr[0] == QChar('#')) continue;
if (fileStr[0] == QChar(';')) continue;
if (!fileStr.contains(QChar('='))) continue;
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
if (configFile.atEnd())
break;
}
configFile.close();
for (int i=0; i<settings.keys().count(); i++)
qDebug() << "[SettingsWindow]" << "[getSettings]" << ":" <<
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef SETTINGSWINDOW_H
@ -20,6 +20,7 @@
#include <QKeyEvent>
#include <QMainWindow>
#include <QTreeWidgetItem>
class MainWindow;
@ -33,7 +34,8 @@ class SettingsWindow : public QMainWindow
Q_OBJECT
public:
explicit SettingsWindow(MainWindow *wid = 0,
explicit SettingsWindow(QWidget *parent = 0,
const bool debugCmd = false,
const QString configFile = QString(""));
~SettingsWindow();
QMap<QString, QString> getDefault();
@ -45,18 +47,22 @@ public slots:
private slots:
void addLanguages();
void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void saveSettings();
// buttons
void selectIfaceDir();
void selectNetctlPath();
void selectNetctlAutoPath();
void selectProfileDir();
void selectRfkillDir();
void selectSudoPath();
void selectSystemctlPath();
void selectWpaActiondPath();
void selectWpaCliPath();
void selectWpaSupPath();
private:
MainWindow *parent;
bool debug;
QString file;
Ui::SettingsWindow *ui;
void createActions();

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "tunnelwidget.h"
@ -63,7 +63,7 @@ void TunnelWidget::createFilter()
QString TunnelWidget::getIp(const QString rawIp)
{
QStringList ip = rawIp.split(QString("."));
QStringList ip = rawIp.split(QChar('.'));
// fix empty fields
if (ip[0].isEmpty())
@ -79,7 +79,7 @@ QString TunnelWidget::getIp(const QString rawIp)
if (ip[i].toInt() > 255)
ip[i] = QString("255");
return ip.join(QString("."));
return ip.join(QChar('.'));
}
@ -91,10 +91,10 @@ QMap<QString, QString> TunnelWidget::getSettings()
return tunnelSettings;
tunnelSettings[QString("Mode")] = QString("'") + ui->comboBox_mode->currentText() + QString("'");
if (!ui->lineEdit_local->text().split(QString(".")).join(QString("")).remove(QString(" ")).isEmpty())
tunnelSettings[QString("Local")] = QString("'") + getIp(ui->lineEdit_local->text().remove(QString(" "))) + QString("'");
if (!ui->lineEdit_remote->text().split(QString(".")).join(QString("")).remove(QString(" ")).isEmpty())
tunnelSettings[QString("Remote")] = QString("'") + getIp(ui->lineEdit_remote->text().remove(QString(" "))) + QString("'");
if (!ui->lineEdit_local->text().remove(QChar('.')).remove(QChar(' ')).isEmpty())
tunnelSettings[QString("Local")] = QString("'") + getIp(ui->lineEdit_local->text().remove(QChar(' '))) + QString("'");
if (!ui->lineEdit_remote->text().remove(QChar('.')).remove(QChar(' ')).isEmpty())
tunnelSettings[QString("Remote")] = QString("'") + getIp(ui->lineEdit_remote->text().remove(QChar(' '))) + QString("'");
return tunnelSettings;
}
@ -109,14 +109,15 @@ int TunnelWidget::isOk()
void TunnelWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> tunnelSettings = settings;
if (tunnelSettings.contains(QString("Mode")))
for (int i=0; i<ui->comboBox_mode->count(); i++)
if (tunnelSettings[QString("Mode")].remove(QString("'")) == ui->comboBox_mode->itemText(i))
if (tunnelSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
ui->comboBox_mode->setCurrentIndex(i);
if (tunnelSettings.contains(QString("Local")))
ui->lineEdit_local->setText(tunnelSettings[QString("Local")].remove(QString("'")));
ui->lineEdit_local->setText(tunnelSettings[QString("Local")]);
if (tunnelSettings.contains(QString("Remote")))
ui->lineEdit_remote->setText(tunnelSettings[QString("Remote")].remove(QString("'")));
ui->lineEdit_remote->setText(tunnelSettings[QString("Remote")]);
}

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TUNNELWIDGET_H

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "tuntapwidget.h"
@ -81,14 +81,15 @@ int TuntapWidget::isOk()
void TuntapWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> tuntapSettings = settings;
if (tuntapSettings.contains(QString("Mode")))
for (int i=0; i<ui->comboBox_mode->count(); i++)
if (tuntapSettings[QString("Mode")].remove(QString("'")) == ui->comboBox_mode->itemText(i))
if (tuntapSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
ui->comboBox_mode->setCurrentIndex(i);
if (tuntapSettings.contains(QString("User")))
ui->lineEdit_user->setText(tuntapSettings[QString("User")].remove(QString("'")));
ui->lineEdit_user->setText(tuntapSettings[QString("User")]);
if (tuntapSettings.contains(QString("Group")))
ui->lineEdit_group->setText(tuntapSettings[QString("Group")].remove(QString("'")));
ui->lineEdit_group->setText(tuntapSettings[QString("Group")]);
}

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef TUNTAPWIDGET_H

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "vlanwidget.h"
@ -71,6 +71,7 @@ int VlanWidget::isOk()
void VlanWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> vlanSettings = settings;
if (vlanSettings.contains(QString("VLANID")))

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef VLANWIDGET_H

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "wirelesswidget.h"
@ -56,6 +56,7 @@ void WirelessWidget::clear()
ui->spinBox_freq->setValue(2412);
ui->listWidget_freq->setCurrentRow(-1);
ui->listWidget_freq->clear();
ui->spinBox_frequency->setValue(2000);
ui->spinBox_priority->setValue(0);
ui->lineEdit_country->clear();
ui->lineEdit_wpaGroup->setText(QString("wheel"));
@ -70,7 +71,7 @@ void WirelessWidget::clear()
QDir::separator() + QString("name"));
QString deviceName;
if (device.open(QIODevice::ReadOnly))
deviceName = QString(device.readLine()).remove(QString("\n"));
deviceName = QString(device.readLine()).trimmed();
ui->comboBox_rfkill->addItem(deviceName);
}
}
@ -153,28 +154,28 @@ void WirelessWidget::addOption()
void WirelessWidget::changeSecurity(const QString currentText)
{
if (currentText == QString("none")) {
ui->widget_essid->setShown(true);
ui->widget_essid->setHidden(false);
ui->widget_wpaConfigSection->setHidden(true);
ui->widget_wpaConfig->setHidden(true);
ui->widget_key->setHidden(true);
}
else if ((currentText == QString("wep")) ||
(currentText == QString("wpa"))) {
ui->widget_essid->setShown(true);
ui->widget_essid->setHidden(false);
ui->widget_wpaConfigSection->setHidden(true);
ui->widget_wpaConfig->setHidden(true);
ui->widget_key->setShown(true);
ui->widget_key->setHidden(false);
}
else if (currentText == QString("wpa-configsection")) {
ui->widget_essid->setHidden(true);
ui->widget_wpaConfigSection->setShown(true);
ui->widget_wpaConfigSection->setHidden(false);
ui->widget_wpaConfig->setHidden(true);
ui->widget_key->setHidden(true);
}
else if (currentText == QString("wpa-config")) {
ui->widget_essid->setHidden(true);
ui->widget_wpaConfigSection->setHidden(true);
ui->widget_wpaConfig->setShown(true);
ui->widget_wpaConfig->setHidden(false);
ui->widget_key->setHidden(true);
}
}
@ -195,7 +196,7 @@ void WirelessWidget::selectWpaConfig()
void WirelessWidget::showAdvanced()
{
if (ui->pushButton_wirelessAdvanced->isChecked()) {
ui->widget_wirelessAdvanced->setShown(true);
ui->widget_wirelessAdvanced->setHidden(false);
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Hide advanced"));
}
else {
@ -226,7 +227,7 @@ QMap<QString, QString> WirelessWidget::getSettings()
QStringList section;
for (int i=0; i<ui->listWidget_wpaConfigSection->count(); i++)
section.append(QString("'") + ui->listWidget_wpaConfigSection->item(i)->text() + QString("'"));
wirelessSettings[QString("WPAConfigSection")] = QString("\n") + section.join(QString("\n")) + QString("\n");
wirelessSettings[QString("WPAConfigSection")] = QString("\n") + section.join(QChar('\n')) + QString("\n");
}
if (ui->comboBox_security->currentText() == QString("wpa-config"))
wirelessSettings[QString("WPAConfigFile")] = QString("'") + ui->lineEdit_wpaConfig->text() + QString("'");
@ -238,8 +239,10 @@ QMap<QString, QString> WirelessWidget::getSettings()
QStringList freqs;
for (int i=0; i<ui->listWidget_freq->count(); i++)
freqs.append(ui->listWidget_freq->item(i)->text());
wirelessSettings[QString("ScanFrequencies")] = freqs.join(QString(" "));
wirelessSettings[QString("ScanFrequencies")] = freqs.join(QChar(' '));
}
if (ui->spinBox_frequency->value() != 2000)
wirelessSettings[QString("Frequency")] = QString::number(ui->spinBox_frequency->value());
if (ui->spinBox_priority->value() != 0)
wirelessSettings[QString("Priority")] = QString::number(ui->spinBox_priority->value());
if (!ui->lineEdit_country->text().isEmpty())
@ -250,7 +253,7 @@ QMap<QString, QString> WirelessWidget::getSettings()
QStringList drivers;
for (int i=0; i<ui->listWidget_drivers->count(); i++)
drivers.append(ui->listWidget_drivers->item(i)->text());
wirelessSettings[QString("WPADriver")] = QString("'") + drivers.join(QString(",")) + QString("'");
wirelessSettings[QString("WPADriver")] = QString("'") + drivers.join(QChar(',')) + QString("'");
}
if (ui->comboBox_rfkill->currentText() != QString("auto"))
wirelessSettings[QString("RFKill")] = ui->comboBox_rfkill->currentText();
@ -280,9 +283,8 @@ int WirelessWidget::isOk()
return 3;
// file wpa_supplicant doesn't exists
if (ui->comboBox_security->currentText() == QString("wpa-config"))
if (!ui->lineEdit_wpaConfig->text().isEmpty())
if (!QFile(ui->lineEdit_wpaConfig->text()).exists())
return 4;
if (!QFile(ui->lineEdit_wpaConfig->text()).exists())
return 4;
// essid is not set
if ((ui->comboBox_security->currentText() == QString("none")) ||
(ui->comboBox_security->currentText() == QString("wep")) ||
@ -296,51 +298,53 @@ int WirelessWidget::isOk()
void WirelessWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> wirelessSettings = settings;
if (wirelessSettings.contains(QString("Security")))
for (int i=0; i<ui->comboBox_security->count(); i++)
if (wirelessSettings[QString("Security")].remove(QString("'")) == ui->comboBox_security->itemText(i))
if (wirelessSettings[QString("Security")] == ui->comboBox_security->itemText(i))
ui->comboBox_security->setCurrentIndex(i);
if (wirelessSettings.contains(QString("ESSID")))
ui->lineEdit_essid->setText(wirelessSettings[QString("ESSID")].remove(QString("'")));
if (wirelessSettings.contains(QString("Key")))
ui->lineEdit_key->setText(wirelessSettings[QString("Key")].remove(QString("'")));
if (wirelessSettings.contains(QString("WPAConfigSection"))) {
QStringList custom;
if (wirelessSettings[QString("WPAConfigSection")].contains(QString("\n")))
custom = wirelessSettings[QString("WPAConfigSection")].split(QString("'\n'"));
else
custom = wirelessSettings[QString("WPAConfigSection")].split(QString("' '"));
for (int i=0; i<custom.count(); i++)
ui->listWidget_wpaConfigSection->addItem(custom[i].remove(QString("'")));
ui->lineEdit_essid->setText(wirelessSettings[QString("ESSID")]);
if (wirelessSettings.contains(QString("Key"))) {
// workaround for wireless-wep example
if (wirelessSettings.contains(QString("Security")))
if ((wirelessSettings[QString("Security")] == QString("wep")) &&
(wirelessSettings[QString("Key")][0] == QChar('"')))
wirelessSettings[QString("Key")] = QChar('\\') + wirelessSettings[QString("Key")];
ui->lineEdit_key->setText(wirelessSettings[QString("Key")]);
}
if (wirelessSettings.contains(QString("WPAConfigSection")))
ui->listWidget_wpaConfigSection->addItems(wirelessSettings[QString("WPAConfigSection")].split(QChar('\n')));
if (wirelessSettings.contains(QString("WPAConfigFile")))
ui->lineEdit_wpaConfig->setText(wirelessSettings[QString("WPAConfigFile")].remove(QString("'")));
ui->lineEdit_wpaConfig->setText(wirelessSettings[QString("WPAConfigFile")]);
if (wirelessSettings.contains(QString("Hidden")))
if (wirelessSettings[QString("Hidden")].remove(QString("'")) == QString("yes"))
if (wirelessSettings[QString("Hidden")] == QString("yes"))
ui->checkBox_hidden->setCheckState(Qt::Checked);
if (wirelessSettings.contains(QString("AdHoc")))
if (wirelessSettings[QString("AdHoc")].remove(QString("'")) == QString("yes"))
if (wirelessSettings[QString("AdHoc")] == QString("yes"))
ui->checkBox_adhoc->setCheckState(Qt::Checked);
if (wirelessSettings.contains(QString("ScanFrequencies")))
ui->listWidget_freq->addItems(wirelessSettings[QString("ScanFrequencies")].split(QString("\n")));
ui->listWidget_freq->addItems(wirelessSettings[QString("ScanFrequencies")].split(QChar('\n')));
if (wirelessSettings.contains(QString("Frequency")))
ui->spinBox_frequency->setValue(wirelessSettings[QString("Frequency")].toInt());
if (wirelessSettings.contains(QString("Priority")))
ui->spinBox_priority->setValue(wirelessSettings[QString("Priority")].toInt());
if (wirelessSettings.contains(QString("Country")))
ui->lineEdit_country->setText(wirelessSettings[QString("Country")].remove(QString("'")));
ui->lineEdit_country->setText(wirelessSettings[QString("Country")]);
if (wirelessSettings.contains(QString("WPAGroup")))
ui->lineEdit_wpaGroup->setText(wirelessSettings[QString("WPAGroup")].remove(QString("'")));
ui->lineEdit_wpaGroup->setText(wirelessSettings[QString("WPAGroup")]);
if (wirelessSettings.contains(QString("WPADriver")))
ui->listWidget_drivers->addItems(wirelessSettings[QString("WPADriver")].split(QString(",")));
ui->listWidget_drivers->addItems(wirelessSettings[QString("WPADriver")].split(QChar(',')));
if (wirelessSettings.contains(QString("RFKill")))
for (int i=0; i<ui->comboBox_rfkill->count(); i++)
if (wirelessSettings[QString("RFKill")].remove(QString("'")) == ui->comboBox_rfkill->itemText(i))
if (wirelessSettings[QString("RFKill")] == ui->comboBox_rfkill->itemText(i))
ui->comboBox_rfkill->setCurrentIndex(i);
if (wirelessSettings.contains(QString("TimeoutWPA")))
ui->spinBox_timeoutWpa->setValue(wirelessSettings[QString("TimeoutWPA")].toInt());
if (wirelessSettings.contains(QString("ExcludeAuto")))
if (wirelessSettings[QString("ExcludeAuto")].remove(QString("'")) == QString("yes"))
if (wirelessSettings[QString("ExcludeAuto")] == QString("yes"))
ui->checkBox_exclude->setCheckState(Qt::Checked);
changeSecurity(ui->comboBox_security->currentText());

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef WIRELESSWIDGET_H

View File

@ -305,6 +305,36 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_frequency">
<item>
<widget class="QLabel" name="label_frequency">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Frequency</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_frequency">
<property name="toolTip">
<string>Priority group for the network</string>
</property>
<property name="minimum">
<number>2000</number>
</property>
<property name="maximum">
<number>6000</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_priority">
<item>
@ -525,6 +555,7 @@
<tabstop>spinBox_freq</tabstop>
<tabstop>pushButton_freq</tabstop>
<tabstop>listWidget_freq</tabstop>
<tabstop>spinBox_frequency</tabstop>
<tabstop>spinBox_priority</tabstop>
<tabstop>lineEdit_country</tabstop>
<tabstop>lineEdit_wpaGroup</tabstop>

View File

@ -1,231 +0,0 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* *
* netctl-plasmoid 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. *
* *
* netctl-plasmoid 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "wpasupinteract.h"
#include <QDebug>
#include <QProcess>
#include "mainwindow.h"
#include "netctlinteract.h"
#include "sleepthread.h"
WpaSup::WpaSup(MainWindow *wid, const QMap<QString, QString> settings)
: parent(wid)
{
ctrlDir = settings[QString("CTRL_DIR")];
ctrlGroup = settings[QString("CTRL_GROUP")];
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
mainInterface = settings[QString("PREFERED_IFACE")];
pidFile = settings[QString("PID_FILE")];
sudoCommand = settings[QString("SUDO_PATH")];
wpaCliPath = settings[QString("WPACLI_PATH")];
wpaDrivers = settings[QString("WPA_DRIVERS")];
wpaSupPath = settings[QString("WPASUP_PATH")];
// terminate old loaded profile
if (QFile(pidFile).exists() || QDir(ctrlDir).exists())
stopWpaSupplicant();
}
WpaSup::~WpaSup()
{
delete ifaceDirectory;
}
// general information
QString WpaSup::existentProfile(const QString profile)
{
QString profileFile = QString("");
QList<QStringList> profileList = parent->netctlCommand->getProfileList();
for (int i=0; i<profileList.count(); i++)
if (profile == parent->netctlCommand->getSsidFromProfile(profileList[i][0]))
profileFile = profileList[i][0];
return profileFile;
}
QStringList WpaSup::getInterfaceList()
{
QStringList interfaces;
if (!mainInterface.isEmpty())
interfaces.append(mainInterface);
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i=0; i<allInterfaces.count(); i++) {
qDebug() << "[WpaSup]" << "[getInterfaceList]" << ":" << "Check directory"
<< ifaceDirectory->path() + QDir::separator() + allInterfaces[i] + QDir::separator() + QString("wireless");
if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] +
QDir::separator() + QString("wireless")).exists())
interfaces.append(allInterfaces[i]);
}
return interfaces;
}
bool WpaSup::isProfileActive(const QString profile)
{
QString profileFile;
QList<QStringList> profileList = parent->netctlCommand->getProfileList();
for (int i=0; i<profileList.count(); i++)
if (profile == parent->netctlCommand->getSsidFromProfile(profileList[i][0]))
profileFile = profileList[i][0];
return parent->netctlCommand->isProfileActive(profileFile);
}
bool WpaSup::isProfileExists(const QString profile)
{
bool exists = false;
QList<QStringList> profileList = parent->netctlCommand->getProfileList();
for (int i=0; i<profileList.count(); i++)
if (profile == parent->netctlCommand->getSsidFromProfile(profileList[i][0]))
exists = true;
return exists;
}
// functions
bool WpaSup::wpaCliCall(const QString commandLine)
{
QString interface = getInterfaceList()[0];
QProcess command;
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
QString(" -P ") + pidFile + QString(" ") + commandLine;
qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
SleepThread::sleep(1);
qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() == 0)
return true;
else
return false;
}
QString WpaSup::getWpaCliOutput(const QString commandLine)
{
QString interface = getInterfaceList()[0];
QProcess command;
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
QString(" -P ") + pidFile + QString(" ") + commandLine;
qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
return command.readAllStandardOutput();
}
QList<QStringList> WpaSup::scanWifi()
{
QList<QStringList> scanResults;
if (!startWpaSupplicant()) {
stopWpaSupplicant();
return scanResults;
}
if (!wpaCliCall(QString("scan")))
return scanResults;
SleepThread::sleep(3);
QStringList rawOutput = getWpaCliOutput(QString("scan_results")).split(QString("\n"), QString::SkipEmptyParts);
// remove table header
rawOutput.removeFirst();
// remove duplicates
QStringList rawList;
for (int i=0; i<rawOutput.count(); i++) {
bool exist = false;
if (rawOutput[i].split(QString("\t"), QString::SkipEmptyParts).count() > 4)
for (int j=0; j<rawList.count(); j++)
if (rawList[j].split(QString("\t"), QString::SkipEmptyParts).count() > 4)
if (rawOutput[i].split(QString("\t"), QString::SkipEmptyParts)[4] ==
rawList[j].split(QString("\t"), QString::SkipEmptyParts)[4])
exist = true;
if (!exist)
rawList.append(rawOutput[i]);
}
for (int i=0; i<rawList.count(); i++) {
QStringList wifiPoint;
// point name
if (rawList[i].split(QString("\t"), QString::SkipEmptyParts).count() > 4)
wifiPoint.append(rawList[i].split(QString("\t"), QString::SkipEmptyParts)[4]);
else
wifiPoint.append(QString("<hidden>"));
// profile status
QString status;
if (isProfileExists(wifiPoint[0])) {
status = QString("exists");
if (isProfileActive(wifiPoint[0]))
status = status + QString(" (active)");
else
status = status + QString(" (inactive)");
}
else
status = QString("new");
wifiPoint.append(status);
// point signal
wifiPoint.append(rawList[i].split(QString("\t"), QString::SkipEmptyParts)[2]);
// point security
QString security = rawList[i].split(QString("\t"), QString::SkipEmptyParts)[3];
if (security.contains(QString("WPA2")))
security = QString("WPA2");
else if (security.contains(QString("WPA")))
security = QString("WPA");
else if (security.contains(QString("WEP")))
security = QString("WEP");
else
security = QString("none");
wifiPoint.append(security);
scanResults.append(wifiPoint);
}
stopWpaSupplicant();
return scanResults;
}
bool WpaSup::startWpaSupplicant()
{
if (!QFile(pidFile).exists()) {
QString interface = getInterfaceList()[0];
QProcess command;
QString commandText = sudoCommand + QString(" ") + wpaSupPath + QString(" -B -P ") + pidFile +
QString(" -i ") + interface + QString(" -D ") + wpaDrivers +
QString(" -C \"DIR=") + ctrlDir + QString(" GROUP=") + ctrlGroup + QString("\"");
qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
SleepThread::sleep(1);
qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() != 0)
return false;
}
return true;
}
bool WpaSup::stopWpaSupplicant()
{
return wpaCliCall(QString("terminate"));
}

View File

@ -1,65 +0,0 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* *
* netctl-plasmoid 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. *
* *
* netctl-plasmoid 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef WPASUPINTERACT_H
#define WPASUPINTERACT_H
#include <QDir>
#include <QMap>
#include <QObject>
class MainWindow;
class WpaSup : public QObject
{
Q_OBJECT
public:
explicit WpaSup(MainWindow *wid = 0,
const QMap<QString, QString> settings = QMap<QString, QString>());
~WpaSup();
// general information
QString existentProfile(const QString profile);
QStringList getInterfaceList();
bool isProfileActive(const QString profile);
bool isProfileExists(const QString profile);
public slots:
// functions
QList<QStringList> scanWifi();
bool startWpaSupplicant();
bool stopWpaSupplicant();
private:
MainWindow *parent;
QString ctrlDir;
QString ctrlGroup;
QDir *ifaceDirectory;
QString mainInterface;
QString pidFile;
QString sudoCommand;
QString wpaCliPath;
QString wpaDrivers;
QString wpaSupPath;
// functions
bool wpaCliCall(const QString commandLine);
QString getWpaCliOutput(const QString commandLine);
};
#endif /* WPASUPINTERACT_H */

View File

@ -1,7 +0,0 @@
# set project name
set (SUBPROJECT netctl-gui-icons)
message (STATUS "Subproject ${SUBPROJECT}")
install (FILES network-idle-64x64.png DESTINATION share/icons/hicolor/64x64/apps RENAME netctl-idle.png)
install (FILES network-offline-64x64.png DESTINATION share/icons/hicolor/64x64/apps RENAME netctl-offline.png)
install (FILES network-idle-128-128.png DESTINATION share/pixmaps RENAME netctl-gui.png)

View File

@ -0,0 +1,19 @@
# set project name
set (SUBPROJECT ${PROJECT_LIBRARY})
message (STATUS "Subproject ${SUBPROJECT}")
# set directories
set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set (SUBPROJECT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
# additional targets
set (TARGETS "")
set (HEADERS "")
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
# headers
install (DIRECTORY ${SUBPROJECT_INCLUDE_DIR}/ DESTINATION include/)
# documentation
if (BUILD_DOCS)
include (docs.cmake)
endif ()

View File

@ -0,0 +1,19 @@
# doxygen documentation
find_package (Doxygen)
if (NOT DOXYGEN_FOUND)
message (STATUS "WARNING: Doxygen not found - Reference manual will not be created")
return ()
endif ()
configure_file (doxygen.conf.in ${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf)
add_custom_target (oxygen-docs ALL COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.conf)
# man pages
# workaround for man pages
set (MAN_DIR ${CMAKE_CURRENT_BINARY_DIR}/docs/man/man3)
install (FILES ${MAN_DIR}/Netctl.3 DESTINATION share/man/man3 RENAME ${SUBPROJECT}_Netctl.3)
install (FILES ${MAN_DIR}/NetctlProfile.3 DESTINATION share/man/man3 RENAME ${SUBPROJECT}_NetctlProfile.3)
install (FILES ${MAN_DIR}/SleepThread.3 DESTINATION share/man/man3 RENAME ${SUBPROJECT}_SleepThread.3)
install (FILES ${MAN_DIR}/WpaSup.3 DESTINATION share/man/man3 RENAME ${SUBPROJECT}_WpaSup.3)
# html docs
install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs/html DESTINATION share/doc/${SUBPROJECT})

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,302 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file netctlinteract.h
* Header of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#ifndef NETCTLINTERACT_H
#define NETCTLINTERACT_H
#include <QDir>
#include <QMap>
#include <QObject>
/**
* @brief The Netctl class interacts with netctl
*/
class Netctl : public QObject
{
Q_OBJECT
public:
/**
* @brief Netctl class constructor
* @param debugCmd show debug messages
* @param settings default settings. Needed keys are
* IFACE_DIR (path to directory with interfaces),
* PREFERED_IFACE (prefered interface for WiFi),
* NETCTL_PATH (path to netctl command),
* NETCTLAUTO_PATH (path to netctl-auto command),
* NETCTLAUTO_SERVICE (netctl-auto service name),
* PROFILE_DIR (path to directory which contains profiles),
* SUDO_PATH (path to sudo command),
* SYSTEMCTL_PATH (path to systemctl command)
*/
explicit Netctl(const bool debugCmd = false,
const QMap<QString, QString> settings = QMap<QString, QString>());
/**
* @brief Netctl class destructor
*/
~Netctl();
// general information
/**
* @brief method which returns profile informations from netctl
* @return list of profiles. Available information is [NAME, DESCRIPTION, STATUS]:
* NAME is a profile name,
* DESCRIPTION is a profile description (see more details below),
* STATUS is a profile status (see more details below)
*/
QList<QStringList> getProfileList();
/**
* @brief method which returns profile informations from netctl-auto
* @return list of profiles. Available information is [NAME, DESCRIPTION, STATUS]:
* NAME is a profile name,
* DESCRIPTION is a profile description (see more details below),
* STATUS is a profile status (see more details below)
*/
QList<QStringList> getProfileListFromNetctlAuto();
/**
* @brief method which gets description from profile
* @param profile profile name
* @return profile description or "<unknown>"
*/
QString getProfileDescription(const QString profile);
/**
* @brief method which gets descriptions from profile list
* @param profileList profile names
* @return list of profile descriptions (if description is not available return "<unknown>")
*/
QStringList getProfileDescriptions(const QStringList profileList);
/**
* @brief method which gets profile status
* @param profile profile name
* @return profile status. It may be "active (enabled)", "active (static)",
* "inactive (enabled)", "inactive (static)"
*/
QString getProfileStatus(const QString profile);
/**
* @brief method which gets statuses of profile list
* @param profileList profile names
* @return list of profile statuses. It may be "active (enabled)", "active (static)",
* "inactive (enabled)", "inactive (static)"
*/
QStringList getProfileStatuses(const QStringList profileList);
/**
* @brief method which gets ESSID from profile
* @param profile profile name
* @return ESSID name or null string
*/
QString getSsidFromProfile(const QString profile);
/**
* @brief method which checks if profile is active
* @param profile profile name
* @return false if profile is inactive
* @return true if profile is active
*/
bool isProfileActive(const QString profile);
/**
* @brief method which checks if profile is enabled
* @param profile profile name
* @return false if profile is disabled
* @return true if profile is enabled
*/
bool isProfileEnabled(const QString profile);
/**
* @brief method which checks if profile is active (netctl-auto)
* @param profile profile name
* @return false if profile is inactive
* @return true if profile is active
*/
bool autoIsProfileActive(const QString profile);
/**
* @brief method which checks if profile is enabled (netctl-auto)
* @param profile profile name
* @return false if profile is disabled
* @return true if profile is enabled
*/
bool autoIsProfileEnabled(const QString profile);
/**
* @brief method which checks netctl-auto autoload status
* @return false if netctl-auto is disabled
* @return true if netctl-auto is enabled
*/
bool isNetctlAutoEnabled();
/**
* @brief method which checks netctl-auto status
* @return false if netctl-auto is inactive
* @return true if netctl-auto is active
*/
bool isNetctlAutoRunning();
public slots:
// functions
// netctl
/**
* @brief method which sets profile disabled or enabled
* @param profile profile name
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool enableProfile(const QString profile);
/**
* @brief method which restarts profile
* @param profile profile name
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool restartProfile(const QString profile);
/**
* @brief method which starts or stops profile
* @param profile profile name
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool startProfile(const QString profile);
// netctl-auto
/**
* @brief method which sets all profiles disabled (netctl-auto)
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool autoDisableAllProfiles();
/**
* @brief method which sets profile disabled or enabled (netctl-auto)
* @param profile profile name
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool autoEnableProfile(const QString profile);
/**
* @brief method which sets all profiles enabled (netctl-auto)
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool autoEnableAllProfiles();
/**
* @brief method which switchs to profile (netctl-auto)
* @param profile profile name
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool autoStartProfile(const QString profile);
// netctl-auto service
/**
* @brief method which sets netctl-auto service enabled or disabled
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool autoEnableService();
/**
* @brief method which restarted netctl-auto service
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool autoRestartService();
/**
* @brief method which starts or stops netctl-auto service
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool autoStartService();
private:
/**
* @brief show debug messages
*/
bool debug;
/**
* @brief directory with interfaces. Default is "/sys/class/net/"
*/
QDir *ifaceDirectory;
/**
* @brief prefered interface for WiFi. Default is ""
*/
QString mainInterface;
/**
* @brief path to netctl command. Default is "/usr/bin/netctl"
*/
QString netctlCommand;
/**
* @brief path to netctl-auto command. Default is "/usr/bin/netctl-auto"
*/
QString netctlAutoCommand;
/**
* @brief netctl-auto service name. Default is "netctl-auto"
*/
QString netctlAutoService;
/**
* @brief directory which contains profiles. Default is "/etc/netctl"
*/
QDir *profileDirectory;
/**
* @brief path to sudo command. Default is "/usr/bin/kdesu"
*/
QString sudoCommand;
/**
* @brief path to systemctl command. Default is "/usr/bin/systemctl"
*/
QString systemctlCommand;
// functions
/**
* @brief method which calls netctl and returns its output
* @param sudo set true if sudo is needed
* @param commandLine command which will be passed to netctl
* @param profile profile name
* @return netctl output
*/
QString getNetctlOutput(const bool sudo, const QString commandLine, const QString profile = 0);
/**
* @brief method which gets interface list from PREFERED_IFACE and IFACE_DIR
* @return first element from interface list. If PREFERED_IFACE is not empty it will be first element
*/
QString getWifiInterface();
/**
* @brief method which calls netctl
* @param sudo set true if sudo is needed
* @param commandLine command which will be passed to netctl
* @param profile profile name
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool netctlCall(const bool sudo, const QString commandLine, const QString profile = 0);
/**
* @brief method which calls netctl-auto
* @param sudo set true if sudo is needed
* @param commandLine command which will be passed to netctl-auto
* @param profile profile name
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool netctlAutoCall(const bool sudo, const QString commandLine, const QString profile = 0);
/**
* @brief method which calls systemctl associated with netctl-auto
* @param sudo set true if sudo is needed
* @param commandLine command which will be passed to systemctl
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool systemctlCall(const bool sudo, const QString commandLine);
};
#endif /* NETCTLINTERACT_H */

View File

@ -0,0 +1,99 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file netctlprofile.h
* Header of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#ifndef NETCTLPROFILE_H
#define NETCTLPROFILE_H
#include <QDir>
#include <QMap>
#include <QObject>
/**
* @brief The NetctlProfile class interacts with netctl profiles
*/
class NetctlProfile : public QObject
{
Q_OBJECT
public:
/**
* @brief NetctlProfile class constructor
* @param debugCmd show debug messages
* @param settings default settings. Needed keys are
* PROFILE_DIR (path to directory which contains profiles),
* SUDO_PATH (path to sudo command)
*/
explicit NetctlProfile(const bool debugCmd = false,
const QMap<QString, QString> settings = QMap<QString, QString>());
/**
* @brief Netctl class destructor
*/
~NetctlProfile();
/**
* @brief method which copies temporary profile to PROFILE_DIR
* @param oldPath path to temprorary profile
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool copyProfile(const QString oldPath);
/**
* @brief method which creates temporary profile
* @param profile profile name
* @param settings profile configuration. All available keys will be printed to the profile
* @return temporary profile name
*/
QString createProfile(const QString profile, const QMap<QString, QString> settings);
/**
* @brief method which reads settings from profile
* @param profile profile name
* @return settings from profile
*/
QMap<QString, QString> getSettingsFromProfile(const QString profile);
/**
* @brief method which removes profile
* @param profile profile name
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool removeProfile(const QString profile);
private:
/**
* @brief show debug messages
*/
bool debug;
/**
* @brief directory which contains profiles. Default is "/etc/netctl"
*/
QDir *profileDirectory;
/**
* @brief path to sudo command. Default is "/usr/bin/kdesu"
*/
QString sudoCommand;
};
#endif /* NETCTLPROFILE_H */

View File

@ -1,19 +1,27 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file sleepthread.h
* Header of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#ifndef SLEEPTHREAD_H
#define SLEEPTHREAD_H
@ -21,21 +29,34 @@
#include <QThread>
/**
* @brief The SleepThread class is used for sleep current thread in WpaSup class
*/
class SleepThread : public QThread
{
Q_OBJECT
public:
/**
* @brief method which forces the current thread to sleep for usecs microseconds
* @param iSleepTime time in microseconds
*/
static void usleep(long iSleepTime)
{
QThread::usleep(iSleepTime);
}
/**
* @brief method which forces the current thread to sleep for usecs seconds
* @param iSleepTime time in seconds
*/
static void sleep(long iSleepTime)
{
QThread::sleep(iSleepTime);
}
/**
* @brief method which forces the current thread to sleep for usecs milliseconds
* @param iSleepTime time in milliseconds
*/
static void msleep(long iSleepTime)
{
QThread::msleep(iSleepTime);

View File

@ -0,0 +1,177 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file wpasupinteract.h
* Header of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#ifndef WPASUPINTERACT_H
#define WPASUPINTERACT_H
#include <QDir>
#include <QMap>
#include <QObject>
class Netctl;
/**
* @brief The WpaSup class interacts with wpa_supplicant
*/
class WpaSup : public QObject
{
Q_OBJECT
public:
/**
* @brief WpaSup class constructor
* @param debugCmd show debug messages
* @param settings default settings. Needed keys are
* CTRL_DIR (path to ctrl_directory),
* CTRL_GROUP (group which is owner of CTRL_DIR),
* IFACE_DIR (path to directory with interfaces),
* PREFERED_IFACE (prefered interface for WiFi),
* PID_FILE (wpa_supplicant PID file),
* SUDO_PATH (path to sudo command),
* WPACLI_PATH (path to wpa_cli command),
* WPA_DRIVERS (wpa_supplicant drivers comma separated),
* WPASUP_PATH (path to wpa_supplicant command)
*/
explicit WpaSup(const bool debugCmd = false,
const QMap<QString, QString> settings = QMap<QString, QString>());
/**
* @brief WpaSup class destructor
*/
~WpaSup();
// general information
/**
* @brief method which gets profile name by ESSID
* @param essid ESSID name
* @return profile name
*/
QString existentProfile(const QString essid);
/**
* @brief method which gets interface list from PREFERED_IFACE and IFACE_DIR
* @return interface list. If PREFERED_IFACE is not empty it will be first element
*/
QStringList getInterfaceList();
/**
* @brief method which checks profile status by ESSID
* @param essid ESSID name
* @return false if profile is inactive
* @return true if profile is active
*/
bool isProfileActive(const QString essid);
/**
* @brief method which checks profile existence by ESSID
* @param essid ESSID name
* @return false if profile does not exist
* @return true if profile exists
*/
bool isProfileExists(const QString essid);
public slots:
// functions
/**
* @brief method which scans WiFi networks
* @return list of essids. Available information is [NAME, NETCTL_STATUS, SIGNAL, SECUITY]:
* NAME is WiFi point name or "<hidden>",
* NETCTL_STATUS may be "new", "exist (active)", "exist (inactive)",
* SIGNAL is Wifi point signal,
* SECURITY may be "WPA2", "WEP", "WEP", "none"
*/
QList<QStringList> scanWifi();
/**
* @brief method which calls wpa_supplicant
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool startWpaSupplicant();
/**
* @brief method which send TERMINATE signal to wpa_supplicant
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool stopWpaSupplicant();
private:
/**
* @brief Netctl class
*/
Netctl *netctlCommand;
/**
* @brief show debug messages
*/
bool debug;
/**
* @brief path to ctrl_directory. Defaults is "/run/wpa_supplicant_netctl-gui"
*/
QString ctrlDir;
/**
* @brief group which is owner of CTRL_DIR. Default is "users"
*/
QString ctrlGroup;
/**
* @brief directory with interfaces. Default is "/sys/class/net/"
*/
QDir *ifaceDirectory;
/**
* @brief prefered interface for WiFi. Default is ""
*/
QString mainInterface;
/**
* @brief wpa_supplicant PID file. Default is "/run/wpa_supplicant_netctl-gui.pid"
*/
QString pidFile;
/**
* @brief path to sudo command. Default is "/usr/bin/kdesu"
*/
QString sudoCommand;
/**
* @brief path to wpa_cli command. Default is "/usr/bin/wpa_cli"
*/
QString wpaCliPath;
/**
* @brief wpa_supplicant drivers comma separated. Default is "nl80211,wext"
*/
QString wpaDrivers;
/**
* @brief path to wpa_supplicant command. Default is "/usr/bin/wpa_supplicant"
*/
QString wpaSupPath;
// functions
/**
* @brief method which calls wpa_cli and returns its output
* @param commandLine command which will be passed to wpa_cli
* @return wpa_cli output
*/
QString getWpaCliOutput(const QString commandLine);
/**
* @brief method which calls wpa_cli
* @param commandLine command which will be passed to wpa_cli
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool wpaCliCall(const QString commandLine);
};
#endif /* WPASUPINTERACT_H */

View File

@ -0,0 +1,40 @@
# set files
file (GLOB SOURCES *.cpp)
file (GLOB HEADERS ${SUBPROJECT_INCLUDE_DIR}/${SUBPROJECT}/*.h)
# include_path
include_directories (${SUBPROJECT_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR})
if (USE_QT5)
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
add_definitions(${Qt5Core_DEFINITIONS})
add_definitions(${Qt5Widgets_DEFINITIONS})
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES})
source_group ("Generated Files" FILES ${MOC_SOURCES})
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
add_library (${SUBPROJECT} SHARED ${SOURCES} ${HEADERS} ${MOC_SOURCES})
target_link_libraries (${SUBPROJECT} ${Qt5Widgets_LIBRARIES} ${Qt5Core_LIBRARIES})
else ()
find_package (Qt4 REQUIRED)
include (${QT_USE_FILE})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES})
source_group ("Generated Files" FILES ${MOC_SOURCES})
add_library (${SUBPROJECT} SHARED ${SOURCES} ${HEADERS} ${MOC_SOURCES})
target_link_libraries (${SUBPROJECT} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
endif()
# install properties
install (TARGETS ${SUBPROJECT} DESTINATION lib)

View File

@ -0,0 +1,41 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file main.cpp
* Source code of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#include <netctlgui/netctlinteract.h>
#include <netctlgui/netctlprofile.h>
#include <netctlgui/sleepthread.h>
#include <netctlgui/wpasupinteract.h>
/**
* @fn main
*/
int main(int argc, char *argv[])
/**
* @return 0 - exit without errors
*/
{
return 0;
}

View File

@ -0,0 +1,747 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file netctlinteract.cpp
* Source code of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#include <QDebug>
#include <QFile>
#include <QProcess>
#include <netctlgui/netctlinteract.h>
/**
* @class Netctl
*/
/**
* @fn Netctl
*/
Netctl::Netctl(const bool debugCmd, const QMap<QString, QString> settings)
: debug(debugCmd)
{
if (settings.contains(QString("IFACE_DIR")))
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
else
ifaceDirectory = new QDir(QString("/sys/class/net/"));
if (settings.contains(QString("PREFERED_IFACE")))
mainInterface = settings[QString("PREFERED_IFACE")];
else
mainInterface = QString("");
if (settings.contains(QString("NETCTL_PATH")))
netctlCommand = settings[QString("NETCTL_PATH")];
else
netctlCommand = QString("/usr/bin/netctl");
if (settings.contains(QString("NETCTLAUTO_PATH")))
netctlAutoCommand = settings[QString("NETCTLAUTO_PATH")];
else
netctlAutoCommand = QString("/usr/bin/netctl-auto");
if (settings.contains(QString("NETCTLAUTO_SERVICE")))
netctlAutoService = settings[QString("NETCTLAUTO_SERVICE")];
else
netctlAutoService = QString("netctl-auto");
if (settings.contains(QString("PROFILE_DIR")))
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
else
profileDirectory = new QDir(QString("/etc/netctl/"));
if (settings.contains(QString("SUDO_PATH")))
sudoCommand = settings[QString("SUDO_PATH")];
else
sudoCommand = QString("/usr/bin/kdesu");
if (settings.contains(QString("SYSTEMCTL_PATH")))
systemctlCommand = settings[QString("SYSTEMCTL_PATH")];
else
systemctlCommand = QString("/usr/bin/systemctl");
}
/**
* @fn ~Netctl
*/
Netctl::~Netctl()
{
if (debug) qDebug() << "[Netctl]" << "[~Netctl]";
if (ifaceDirectory != 0)
delete ifaceDirectory;
if (profileDirectory != 0)
delete profileDirectory;
}
// functions
/**
* @fn getNetctlOutput
*/
QString Netctl::getNetctlOutput(const bool sudo, const QString commandLine, const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]";
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Command" << commandLine;
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Profile" << profile;
if (netctlCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Could not find netctl";
return QString();
}
if ((sudo) && (sudoCommand == 0)) {
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Could not find sudo";
return QString();
}
QProcess command;
QString commandText;
if (sudo)
commandText = sudoCommand + QString(" ") + netctlCommand + QString(" ") + commandLine +
QString(" ") + profile;
else
commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile;
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
return command.readAllStandardOutput();
}
/**
* @fn getWifiInterface
*/
QString Netctl::getWifiInterface()
{
if (debug) qDebug() << "[Netctl]" << "[getInterfaceList]";
if (ifaceDirectory == 0) {
if (debug) qDebug() << "[Netctl]" << "[getInterfaceList]" << ":" << "Could not find directory";
return QString();
}
QStringList interfaces;
if (!mainInterface.isEmpty())
interfaces.append(mainInterface);
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i=0; i<allInterfaces.count(); i++) {
if (debug) qDebug() << "[Netctl]" << "[getInterfaceList]" << ":" << "Check directory"
<< ifaceDirectory->path() + QDir::separator() + allInterfaces[i] + QDir::separator() + QString("wireless");
if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] +
QDir::separator() + QString("wireless")).exists())
interfaces.append(allInterfaces[i]);
}
return interfaces[0];
}
/**
* @fn netctlCall
*/
bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[netctlCall]";
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Command" << commandLine;
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Profile" << profile;
if (netctlCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Could not find netctl";
return false;
}
if ((sudo) && (sudoCommand == 0)) {
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Could not find sudo";
return false;
}
QProcess command;
QString commandText;
if (sudo)
commandText = sudoCommand + QString(" ") + netctlCommand + QString(" ") + commandLine +
QString(" ") + profile;
else
commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile;
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() == 0)
return true;
else
return false;
}
/**
* @fn netctlAutoCall
*/
bool Netctl::netctlAutoCall(const bool sudo, const QString commandLine, const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]";
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Command" << commandLine;
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Profile" << profile;
if (netctlAutoCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Could not find netctl-auto";
return false;
}
if ((sudo) && (sudoCommand == 0)) {
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Could not find sudo";
return false;
}
QProcess command;
QString commandText;
if (sudo)
commandText = sudoCommand + QString(" ") + netctlAutoCommand + QString(" ") + commandLine;
else
commandText = netctlAutoCommand + QString(" ") + commandLine;
if (profile != 0)
commandText = commandText + QString(" ") + profile;
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() == 0)
return true;
else
return false;
}
/**
* @fn systemctlCall
*/
bool Netctl::systemctlCall(const bool sudo, const QString commandLine)
{
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]";
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Command" << commandLine;
if (netctlAutoService == 0) {
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Could not find service";
return false;
}
if ((sudo) && (sudoCommand == 0)) {
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Could not find sudo";
return false;
}
if (systemctlCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Could not find systemctl";
return false;
}
QProcess command;
QString commandText;
QString interface = getWifiInterface();
if (sudo)
commandText = sudoCommand + QString(" ") + systemctlCommand + QString(" ") + commandLine +
QString(" ") + netctlAutoService + QString("@") + interface + QString(".service");
else
commandText = systemctlCommand + QString(" ") + commandLine + QString(" ") + netctlAutoService +
QString("@") + interface + QString(".service");
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() == 0)
return true;
else
return false;
}
// general information
/**
* @fn getProfileList
*/
QList<QStringList> Netctl::getProfileList()
{
if (debug) qDebug() << "[Netctl]" << "[getProfileList]";
if (profileDirectory == 0) {
if (debug) qDebug() << "[Netctl]" << "[getProfileList]" << ":" << "Could not find directory";
return QList<QStringList>();
}
QList<QStringList> fullProfilesInfo;
QStringList profiles = profileDirectory->entryList(QDir::Files);
QStringList descriptions = getProfileDescriptions(profiles);
QStringList statuses = getProfileStatuses(profiles);
for (int i=0; i<profiles.count(); i++) {
QStringList profileInfo;
profileInfo.append(profiles[i]);
profileInfo.append(descriptions[i]);
profileInfo.append(statuses[i]);
fullProfilesInfo.append(profileInfo);
}
return fullProfilesInfo;
}
/**
* @fn getProfileListFromNetctlAuto
*/
QList<QStringList> Netctl::getProfileListFromNetctlAuto()
{
if (debug) qDebug() << "[Netctl]" << "[getProfileListFromNetctlAuto]";
if (netctlAutoCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[getProfileListFromNetctlAuto]" << ":" << "Could not find netctl-auto";
return QList<QStringList>();
}
QProcess command;
QString commandText = netctlAutoCommand + QString(" list");
if (debug) qDebug() << "[Netctl]" << "[getProfileListFromNetctlAuto]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
QStringList output = QString(command.readAllStandardOutput()).split(QChar('\n'), QString::SkipEmptyParts);
QList<QStringList> fullProfilesInfo;
for (int i=0; i<output.count(); i++) {
QStringList profileInfo;
profileInfo.append(output[i].mid(2, -1));
profileInfo.append(getProfileDescription(profileInfo[0]));
profileInfo.append(output[i].left(1));
fullProfilesInfo.append(profileInfo);
}
return fullProfilesInfo;
}
/**
* @fn getProfileDescription
*/
QString Netctl::getProfileDescription(const QString profileName)
{
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]";
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Profile" << profileName;
if (profileDirectory == 0) {
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Could not find directory";
return QString();
}
QString description = QString("<unknown>");
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profileName;
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Check" << profileUrl;
QFile profile(profileUrl);
QString fileStr;
if (!profile.open(QIODevice::ReadOnly))
return description;
while (true) {
fileStr = QString(profile.readLine());
if (fileStr[0] == QChar('#')) continue;
if (fileStr.split(QChar('='), QString::SkipEmptyParts).count() == 2)
if (fileStr.split(QChar('='), QString::SkipEmptyParts)[0] == QString("Description"))
description = fileStr.split(QChar('='), QString::SkipEmptyParts)[1].trimmed();
if (profile.atEnd())
break;
}
description.remove(QChar('\'')).remove(QChar('"'));
return description;
}
/**
* @fn getProfileDescriptions
*/
QStringList Netctl::getProfileDescriptions(const QStringList profileList)
{
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]";
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Profile list" << profileList;
if (profileDirectory == 0) {
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Could not find directory";
return QStringList();
}
QStringList descriptions;
for (int i=0; i<profileList.count(); i++) {
QString description = QString("<unknown>");
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profileList[i];
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Check" << profileUrl;
QFile profile(profileUrl);
QString fileStr;
if (!profile.open(QIODevice::ReadOnly)) {
descriptions.append(description);
continue;
}
while (true) {
fileStr = QString(profile.readLine());
if (fileStr[0] == QChar('#')) continue;
if (fileStr.split(QChar('='), QString::SkipEmptyParts).count() == 2)
if (fileStr.split(QChar('='), QString::SkipEmptyParts)[0] == QString("Description"))
description = fileStr.split(QChar('='), QString::SkipEmptyParts)[1].trimmed();
if (profile.atEnd())
break;
}
description.remove(QChar('\'')).remove(QChar('"'));
descriptions.append(description);
}
return descriptions;
}
/**
* @fn getProfileStatus
*/
QString Netctl::getProfileStatus(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[getProfileStatus]";
if (debug) qDebug() << "[Netctl]" << "[getProfileStatus]" << ":" << "Profile" << profile;
QString status;
if (isProfileActive(profile))
status = QString("active");
else
status = QString("inactive");
if (isProfileEnabled(profile))
status = status + QString(" (enabled)");
else
status = status + QString(" (static)");
return status;
}
/**
* @fn getProfileStatuses
*/
QStringList Netctl::getProfileStatuses(const QStringList profileList)
{
if (debug) qDebug() << "[Netctl]" << "[getProfileStatuses]";
if (debug) qDebug() << "[Netctl]" << "[getProfileStatuses]" << ":" << "Profile list" << profileList;
QStringList statuses;
for (int i=0; i<profileList.count(); i++) {
QString status;
if (isProfileActive(profileList[i]))
status = QString("active");
else
status = QString("inactive");
if (isProfileEnabled(profileList[i]))
status = status + QString(" (enabled)");
else
status = status + QString(" (static)");
statuses.append(status);
}
return statuses;
}
/**
* @fn getSsidFromProfile
*/
QString Netctl::getSsidFromProfile(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]";
if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Profile" << profile;
if (profileDirectory == 0) {
if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Could not find directory";
return QString();
}
QString ssidName;
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Check" << profileUrl;
QFile profileFile(profileUrl);
QString fileStr;
if (!profileFile.open(QIODevice::ReadOnly))
return ssidName;
while (true) {
fileStr = QString(profileFile.readLine());
if (fileStr[0] == QChar('#')) continue;
if (fileStr.split(QChar('='), QString::SkipEmptyParts).count() == 2)
if (fileStr.split(QChar('='), QString::SkipEmptyParts)[0] == QString("ESSID"))
ssidName = fileStr.split(QChar('='), QString::SkipEmptyParts)[1].trimmed();
if (profileFile.atEnd())
break;
}
profileFile.close();
ssidName.remove(QChar('\'')).remove(QChar('"'));
return ssidName;
}
/**
* @fn isProfileActive
*/
bool Netctl::isProfileActive(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[isProfileActive]";
if (debug) qDebug() << "[Netctl]" << "[isProfileActive]" << ":" << "Profile" << profile;
bool status = false;
QString cmdOutput = getNetctlOutput(false, QString("status"), profile);
if (cmdOutput.contains(QString("Active: active")))
status = true;
return status;
}
/**
* @fn isProfileEnabled
*/
bool Netctl::isProfileEnabled(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[isProfileEnabled]";
if (debug) qDebug() << "[Netctl]" << "[isProfileEnabled]" << ":" << "Profile" << profile;
return netctlCall(false, QString("is-enabled"), profile);
}
/**
* @fn autoIsProfileActive
*/
bool Netctl::autoIsProfileActive(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[autoIsProfileActive]";
if (debug) qDebug() << "[Netctl]" << "[autoIsProfileActive]" << ":" << "Profile" << profile;
bool status = false;
QList<QStringList> profiles = getProfileListFromNetctlAuto();
for (int i=0; i<profiles.count(); i++)
if ((profiles[i][0] == profile) && (profiles[i][2] == QString("*"))) {
status = true;
break;
}
return status;
}
/**
* @fn autoIsProfileEnabled
*/
bool Netctl::autoIsProfileEnabled(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[autoIsProfileEnabled]";
if (debug) qDebug() << "[Netctl]" << "[autoIsProfileEnabled]" << ":" << "Profile" << profile;
bool status = true;
QList<QStringList> profiles = getProfileListFromNetctlAuto();
for (int i=0; i<profiles.count(); i++)
if ((profiles[i][0] == profile) && (profiles[i][2] == QString("!"))) {
status = false;
break;
}
return status;
}
/**
* @fn isNetctlAutoEnabled
*/
bool Netctl::isNetctlAutoEnabled()
{
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]";
if (netctlAutoService == 0) {
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]" << ":" << "Could not find service";
return false;
}
if (systemctlCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]" << ":" << "Could not find systemctl";
return false;
}
QProcess command;
QString interface = getWifiInterface();
QString commandText = systemctlCommand + QString(" is-enabled ") + netctlAutoService + QString("@") +
interface + QString(".service");
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]" << ":" << "Cmd returns" << command.exitCode();
QString output = command.readAllStandardOutput().trimmed();
if (output == QString("enabled"))
return true;
else
return false;
}
/**
* @fn isNetctlAutoRunning
*/
bool Netctl::isNetctlAutoRunning()
{
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]";
if (netctlAutoService == 0) {
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Could not find service";
return false;
}
if (systemctlCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Could not find systemctl";
return false;
}
QString interface = getWifiInterface();
QProcess command;
QString commandText = systemctlCommand + QString(" is-active ") + netctlAutoService + QString("@") +
interface + QString(".service");
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Cmd returns" << command.exitCode();
QString output = command.readAllStandardOutput().trimmed();
if (output == QString("active"))
return true;
else
return false;
}
// functions
/**
* @fn enableProfile
*/
bool Netctl::enableProfile(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[enableProfile]";
if (debug) qDebug() << "[Netctl]" << "[enableProfile]" << ":" << "Profile" << profile;
if (isProfileEnabled(profile))
return netctlCall(true, QString("disable"), profile);
else
return netctlCall(true, QString("enable"), profile);
}
/**
* @fn restartProfile
*/
bool Netctl::restartProfile(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[restartProfile]";
if (debug) qDebug() << "[Netctl]" << "[restartProfile]" << ":" << "Profile" << profile;
return netctlCall(true, QString("restart"), profile);
}
/**
* @fn startProfile
*/
bool Netctl::startProfile(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[startProfile]";
if (debug) qDebug() << "[Netctl]" << "[startProfile]" << ":" << "Profile" << profile;
if (isProfileActive(profile))
return netctlCall(true, QString("stop"), profile);
else
return netctlCall(true, QString("start"), profile);
}
/**
* @fn autoDisableAllProfiles
*/
bool Netctl::autoDisableAllProfiles()
{
if (debug) qDebug() << "[Netctl]" << "[autoDisableAllProfiles]";
return netctlAutoCall(false, QString("disable-all"));
}
/**
* @fn autoEnableProfile
*/
bool Netctl::autoEnableProfile(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[autoEnableProfile]";
if (debug) qDebug() << "[Netctl]" << "[autoEnableProfile]" << ":" << "Profile" << profile;
if (autoIsProfileEnabled(profile))
return netctlAutoCall(false, QString("disable"), profile);
else
return netctlAutoCall(false, QString("enable"), profile);
}
/**
* @fn autoEnableAllProfiles
*/
bool Netctl::autoEnableAllProfiles()
{
if (debug) qDebug() << "[Netctl]" << "[autoEnableAllProfiles]";
return netctlAutoCall(false, QString("enable-all"));
}
/**
* @fn autoStartProfile
*/
bool Netctl::autoStartProfile(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[autoStartProfile]";
if (debug) qDebug() << "[Netctl]" << "[autoStartProfile]" << ":" << "Profile" << profile;
if (autoIsProfileActive(profile))
return true;
else
return netctlAutoCall(false, QString("switch-to"), profile);
}
/**
* @fn autoEnableService
*/
bool Netctl::autoEnableService()
{
if (debug) qDebug() << "[Netctl]" << "[autoEnableService]";
if (isNetctlAutoEnabled())
return systemctlCall(true, QString("disable"));
else
return systemctlCall(true, QString("enable"));
}
/**
* @fn autoRestartService
*/
bool Netctl::autoRestartService()
{
if (debug) qDebug() << "[Netctl]" << "[autoRestartService]";
if (isNetctlAutoRunning())
return systemctlCall(true, QString("restart"));
else
return true;
}
/**
* @fn autoStartService
*/
bool Netctl::autoStartService()
{
if (debug) qDebug() << "[Netctl]" << "[autoStartService]";
if (isNetctlAutoRunning())
return systemctlCall(true, QString("stop"));
else
return systemctlCall(true, QString("start"));
}

View File

@ -0,0 +1,216 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file netctlprofile.cpp
* Source code of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QProcess>
#include <QTextStream>
#include <netctlgui/netctlprofile.h>
/**
* @class NetctlProfile
*/
/**
* @fn NetctlProfile
*/
NetctlProfile::NetctlProfile(const bool debugCmd, const QMap<QString, QString> settings)
: debug(debugCmd)
{
if (settings.contains(QString("PROFILE_DIR")))
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
else
profileDirectory = new QDir(QString("/etc/netctl/"));
if (settings.contains(QString("SUDO_PATH")))
sudoCommand = settings[QString("SUDO_PATH")];
else
sudoCommand = QString("/usr/bin/kdesu");
}
/**
* @fn ~NetctlProfile
*/
NetctlProfile::~NetctlProfile()
{
if (debug) qDebug() << "[NetctlProfile]" << "[~NetctlProfile]";
if (profileDirectory != 0)
delete profileDirectory;
}
/**
* @fn copyProfile
*/
bool NetctlProfile::copyProfile(const QString oldPath)
{
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]";
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Path" << oldPath;
if (profileDirectory == 0) {
if (debug) qDebug() << "[NetctlProfile]" << "[profileDirectory]" << ":" << "Could not find directory";
return false;
}
if (sudoCommand == 0) {
if (debug) qDebug() << "[NetctlProfile]" << "[profileDirectory]" << ":" << "Could not find sudo";
return false;
}
QProcess command;
QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
QString commandText = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath;
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (command.exitCode() == 0)
return true;
else
return false;
}
/**
* @fn createProfile
*/
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings)
{
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]";
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Profile" << profile;
QString profileTempName = QDir::homePath() + QDir::separator() +
QString(".cache") + QDir::separator() + QFileInfo(profile).fileName();
QFile profileFile(profileTempName);
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Save to" << profileTempName;
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
return profileTempName;
QTextStream out(&profileFile);
for (int i=0; i<settings.keys().count(); i++) {
out << settings.keys()[i] << QString("=");
if ((settings.keys()[i] == QString("BindsToInterfaces")) ||
(settings.keys()[i] == QString("After")) ||
(settings.keys()[i] == QString("Address")) ||
(settings.keys()[i] == QString("Routes")) ||
(settings.keys()[i] == QString("Address6")) ||
(settings.keys()[i] == QString("Routes6")) ||
(settings.keys()[i] == QString("IPCustom")) ||
(settings.keys()[i] == QString("DNS")) ||
(settings.keys()[i] == QString("DNSOptions")) ||
(settings.keys()[i] == QString("ScanFrequencies")) ||
(settings.keys()[i] == QString("WPAConfigSection")))
out << QString("(") + settings[settings.keys()[i]] << QString(")") << endl;
else
out << settings[settings.keys()[i]] << endl;
}
profileFile.close();
return profileTempName;
}
/**
* @fn getSettingsFromProfile
*/
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile)
{
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]";
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Profile" << profile;
if (profileDirectory == 0) {
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Could not find directory";
return QMap<QString, QString>();
}
// getting variables list
// system variables
QProcess shell;
QString cmd = QString("env -i bash -c \"set\"");
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Run cmd" << cmd;
shell.start(cmd);
shell.waitForFinished(-1);
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Cmd returns" << shell.exitCode();
QStringList output = QString(shell.readAllStandardOutput()).trimmed().split(QChar('\n'));
QStringList systemVariables;
systemVariables.append(QString("PIPESTATUS"));
for (int i=0; i<output.count(); i++)
systemVariables.append(output[i].split(QChar('='))[0]);
// profile variables
QMap<QString, QString> settings;
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
cmd = QString("env -i bash -c \"source ") + profileUrl + QString("; set\"");
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Run cmd" << cmd;
shell.start(cmd);
shell.waitForFinished(-1);
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Cmd returns" << shell.exitCode();
output = QString(shell.readAllStandardOutput()).trimmed().split(QChar('\n'));
// gettings variables
QStringList keys;
for (int i=0; i<output.count(); i++)
if (!systemVariables.contains(output[i].split(QChar('='))[0]))
keys.append(output[i].split(QChar('='))[0]);
for (int i=0; i<keys.count(); i++){
cmd = QString("env -i bash -c \"source ") + profileUrl +
QString("; for i in ${!") + keys[i] + QString("[@]}; do echo ${") +
keys[i] + QString("[$i]}; done\"");
shell.start(cmd);
shell.waitForFinished(-1);
settings[keys[i]] = shell.readAllStandardOutput().trimmed();
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << keys[i] << "=" << settings[keys[i]];
}
return settings;
}
/**
* @fn removeProfile
*/
bool NetctlProfile::removeProfile(const QString profile)
{
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]";
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Profile" << profile;
if (profileDirectory == 0) {
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Could not find directory";
return false;
}
if (sudoCommand == 0) {
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Could not find sudo";
return false;
}
QProcess command;
QString profilePath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
QString commandText = sudoCommand + QString(" /usr/bin/rm ") + profilePath;
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (command.exitCode() == 0)
return true;
else
return false;
}

View File

@ -0,0 +1,389 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui 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. *
* *
* netctl-gui 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 netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file wpasupinteract.cpp
* Source code of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#include <QDebug>
#include <QProcess>
#include <netctlgui/netctlinteract.h>
#include <netctlgui/sleepthread.h>
#include <netctlgui/wpasupinteract.h>
/**
* @class WpaSup
*/
/**
* @fn WpaSup
*/
WpaSup::WpaSup(const bool debugCmd, const QMap<QString, QString> settings)
: debug(debugCmd)
{
netctlCommand = new Netctl(debug, settings);
if (settings.contains(QString("CTRL_DIR")))
ctrlDir = settings[QString("CTRL_DIR")];
else
ctrlDir = QString("/run/wpa_supplicant_netctl-gui");
if (settings.contains(QString("CTRL_GROUP")))
ctrlGroup = settings[QString("CTRL_GROUP")];
else
ctrlGroup = QString("users");
if (settings.contains(QString("IFACE_DIR")))
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
else
ifaceDirectory = new QDir(QString("/sys/class/net/"));
if (settings.contains(QString("PREFERED_IFACE")))
mainInterface = settings[QString("PREFERED_IFACE")];
else
mainInterface = QString("");
if (settings.contains(QString("PID_FILE")))
pidFile = settings[QString("PID_FILE")];
else
pidFile = QString("/run/wpa_supplicant_netctl-gui.pid");
if (settings.contains(QString("SUDO_PATH")))
sudoCommand = settings[QString("SUDO_PATH")];
else
sudoCommand = QString("/usr/bin/kdesu");
if (settings.contains(QString("WPACLI_PATH")))
wpaCliPath = settings[QString("WPACLI_PATH")];
else
wpaCliPath = QString("/usr/bin/wpa_cli");
if (settings.contains(QString("WPA_DRIVERS")))
wpaDrivers = settings[QString("WPA_DRIVERS")];
else
wpaDrivers = QString("nl80211,wext");
if (settings.contains(QString("WPASUP_PATH")))
wpaSupPath = settings[QString("WPASUP_PATH")];
else
wpaSupPath = QString("/usr/bin/wpa_supplicant");
// terminate old loaded profile
if (QFile(pidFile).exists() || QDir(ctrlDir).exists())
stopWpaSupplicant();
}
/**
* @fn ~WpaSup
*/
WpaSup::~WpaSup()
{
if (debug) qDebug() << "[WpaSup]" << "[~WpaSup]";
delete netctlCommand;
if (ifaceDirectory != 0)
delete ifaceDirectory;
}
// general information
/**
* @fn existentProfile
*/
QString WpaSup::existentProfile(const QString essid)
{
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]";
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]" << ":" << "ESSID" << essid;
QString profileFile = QString("");
QList<QStringList> profileList = netctlCommand->getProfileList();
for (int i=0; i<profileList.count(); i++)
if (essid == netctlCommand->getSsidFromProfile(profileList[i][0]))
profileFile = profileList[i][0];
return profileFile;
}
/**
* @fn getInterfaceList
*/
QStringList WpaSup::getInterfaceList()
{
if (debug) qDebug() << "[WpaSup]" << "[getInterfaceList]";
if (ifaceDirectory == 0) {
if (debug) qDebug() << "[WpaSup]" << "[getInterfaceList]" << ":" << "Could not find directory";
return QStringList();
}
QStringList interfaces;
if (!mainInterface.isEmpty())
interfaces.append(mainInterface);
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i=0; i<allInterfaces.count(); i++) {
if (debug) qDebug() << "[WpaSup]" << "[getInterfaceList]" << ":" << "Check directory"
<< ifaceDirectory->path() + QDir::separator() + allInterfaces[i] + QDir::separator() + QString("wireless");
if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] +
QDir::separator() + QString("wireless")).exists())
interfaces.append(allInterfaces[i]);
}
return interfaces;
}
/**
* @fn isProfileActive
*/
bool WpaSup::isProfileActive(const QString essid)
{
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]";
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]" << ":" << "ESSID" << essid;
QString profileFile;
QList<QStringList> profileList = netctlCommand->getProfileList();
for (int i=0; i<profileList.count(); i++)
if (essid == netctlCommand->getSsidFromProfile(profileList[i][0])) {
profileFile = profileList[i][0];
break;
}
return netctlCommand->isProfileActive(profileFile);
}
/**
* @fn isProfileExists
*/
bool WpaSup::isProfileExists(const QString essid)
{
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]";
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]" << ":" << "ESSID" << essid;
bool exists = false;
QList<QStringList> profileList = netctlCommand->getProfileList();
for (int i=0; i<profileList.count(); i++)
if (essid == netctlCommand->getSsidFromProfile(profileList[i][0])) {
exists = true;
break;
}
return exists;
}
/**
* @fn scanWifi
*/
QList<QStringList> WpaSup::scanWifi()
{
if (debug) qDebug() << "[WpaSup]" << "[scanWifi]";
QList<QStringList> scanResults;
if (!startWpaSupplicant()) {
stopWpaSupplicant();
return scanResults;
}
if (!wpaCliCall(QString("scan")))
return scanResults;
SleepThread::sleep(3);
QStringList rawOutput = getWpaCliOutput(QString("scan_results")).split(QChar('\n'), QString::SkipEmptyParts);
// remove table header
rawOutput.removeFirst();
// remove duplicates
QStringList rawList;
for (int i=0; i<rawOutput.count(); i++) {
bool exist = false;
if (rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts).count() > 4)
for (int j=0; j<rawList.count(); j++)
if (rawList[j].split(QChar('\t'), QString::SkipEmptyParts).count() > 4)
if (rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts)[4] ==
rawList[j].split(QChar('\t'), QString::SkipEmptyParts)[4])
exist = true;
if (!exist)
rawList.append(rawOutput[i]);
}
for (int i=0; i<rawList.count(); i++) {
QStringList wifiPoint;
// point name
if (rawList[i].split(QChar('\t'), QString::SkipEmptyParts).count() > 4)
wifiPoint.append(rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[4]);
else
wifiPoint.append(QString("<hidden>"));
// profile status
QString status;
if (isProfileExists(wifiPoint[0])) {
status = QString("exists");
if (isProfileActive(wifiPoint[0]))
status = status + QString(" (active)");
else
status = status + QString(" (inactive)");
}
else
status = QString("new");
wifiPoint.append(status);
// point signal
wifiPoint.append(rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[2]);
// point security
QString security = rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[3];
if (security.contains(QString("WPA2")))
security = QString("WPA2");
else if (security.contains(QString("WPA")))
security = QString("WPA");
else if (security.contains(QString("WEP")))
security = QString("WEP");
else
security = QString("none");
wifiPoint.append(security);
scanResults.append(wifiPoint);
}
stopWpaSupplicant();
return scanResults;
}
/**
* @fn startWpaSupplicant
*/
bool WpaSup::startWpaSupplicant()
{
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]";
if (ctrlDir == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find directory";
return false;
}
if (ctrlGroup == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find group";
return false;
}
if (pidFile == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find PID file";
return false;
}
if (sudoCommand == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find sudo";
return false;
}
if (wpaDrivers == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find drivers";
return false;
}
if (wpaSupPath == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find wpa_supplicant";
return false;
}
if (QFile(pidFile).exists())
return true;
QProcess command;
QString interface = getInterfaceList()[0];
QString commandText = sudoCommand + QString(" ") + wpaSupPath + QString(" -B -P ") + pidFile +
QString(" -i ") + interface + QString(" -D ") + wpaDrivers +
QString(" -C \"DIR=") + ctrlDir + QString(" GROUP=") + ctrlGroup + QString("\"");
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
SleepThread::sleep(1);
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() == 0)
return true;
else
return false;
}
/**
* @fn stopWpaSupplicant
*/
bool WpaSup::stopWpaSupplicant()
{
if (debug) qDebug() << "[WpaSup]" << "[stopWpaSupplicant]";
return wpaCliCall(QString("terminate"));
}
// functions
/**
* @fn getWpaCliOutput
*/
QString WpaSup::getWpaCliOutput(const QString commandLine)
{
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]";
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Command" << commandLine;
if (ctrlDir == 0) {
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find directory";
return QString();
}
if (pidFile == 0) {
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find PID file";
return QString();
}
if (wpaCliPath == 0) {
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find wpa_cli";
return QString();
}
QProcess command;
QString interface = getInterfaceList()[0];
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
QString(" -P ") + pidFile + QString(" ") + commandLine;
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
return command.readAllStandardOutput();
}
/**
* @fn wpaCliCall
*/
bool WpaSup::wpaCliCall(const QString commandLine)
{
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]";
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Command" << commandLine;
if (ctrlDir == 0) {
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find directory";
return false;
}
if (pidFile == 0) {
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find PID file";
return false;
}
if (wpaCliPath == 0) {
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find wpa_cli";
return false;
}
QProcess command;
QString interface = getInterfaceList()[0];
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
QString(" -P ") + pidFile + QString(" ") + commandLine;
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
SleepThread::sleep(1);
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() == 0)
return true;
else
return false;
}

View File

@ -1,6 +1,8 @@
# set project name
set (SUBPROJECT plasma_applet_netctl)
message (STATUS "Subproject ${SUBPROJECT}")
# find resources
set (RESOURCES ${PROJECT_RESOURCE_DIR}/resources-plasmoid.qrc)
# find required libaries
find_package (KDE4 REQUIRED)
@ -23,8 +25,9 @@ file (GLOB SUBPROJECT_UI *.ui)
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
# make
qt4_add_resources (QRC_SOURCES ${RESOURCES})
kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI})
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE})
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${QRC_SOURCES})
target_link_libraries (${PLUGIN_NAME} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS})
# install

1
sources/plasmoid/about.ui Symbolic link
View File

@ -0,0 +1 @@
../gui/src/about.ui

View File

@ -0,0 +1,419 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AppearanceWindow</class>
<widget class="QWidget" name="AppearanceWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>341</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>480</width>
<height>320</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Configuration Window</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="8" column="0">
<spacer name="verticalSpacer_appearance">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_inactiveIcon">
<item>
<widget class="QLabel" name="label_inactiveIcon">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Inactive icon</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_inactiveIcon"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_inactiveIcon">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<layout class="QHBoxLayout" name="layout_fontColor">
<item>
<widget class="QLabel" name="label_fontColor">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font color</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_fontColor">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_fontColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font color</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<widget class="Line" name="line_appearance">
<property name="lineWidth">
<number>5</number>
</property>
<property name="midLineWidth">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="layout_fontSize">
<item>
<widget class="QLabel" name="label_fontSize">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font size</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_fontSize">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fontSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font size</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>7</number>
</property>
<property name="maximum">
<number>48</number>
</property>
<property name="value">
<number>12</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="layout_fontWeight">
<item>
<widget class="QLabel" name="label_fontWeight">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font weight</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_fontWeight">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fontWeight">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font weight</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>300</number>
</property>
<property name="maximum">
<number>600</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="value">
<number>400</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="layout_fontStyle">
<item>
<widget class="QLabel" name="label_fontStyle">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font style</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_fontStyle">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="comboBox_fontStyle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font style</string>
</property>
<item>
<property name="text">
<string>normal</string>
</property>
</item>
<item>
<property name="text">
<string>italic</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="layout_font">
<item>
<widget class="QLabel" name="label_font">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_font">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QFontComboBox" name="fontComboBox_font">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font family</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="0">
<layout class="QHBoxLayout" name="layout_activeIcon">
<item>
<widget class="QLabel" name="label_activeIcon">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Active icon</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_activeIcon"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_activeIcon">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorCombo</class>
<extends>QComboBox</extends>
<header>kcolorcombo.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>fontComboBox_font</tabstop>
<tabstop>spinBox_fontSize</tabstop>
<tabstop>kcolorcombo_fontColor</tabstop>
<tabstop>spinBox_fontWeight</tabstop>
<tabstop>comboBox_fontStyle</tabstop>
<tabstop>lineEdit_activeIcon</tabstop>
<tabstop>pushButton_activeIcon</tabstop>
<tabstop>lineEdit_inactiveIcon</tabstop>
<tabstop>pushButton_inactiveIcon</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -1,674 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConfigWindow</class>
<widget class="QWidget" name="ConfigWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>320</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>480</width>
<height>320</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Configuration Window</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabConfiguration">
<attribute name="title">
<string>Configuration</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_info">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_autoUpdate">
<item>
<widget class="QLabel" name="label_autoUpdate">
<property name="minimumSize">
<size>
<width>150</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Auto update interval, msec</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_autoUpdate">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBox_autoUpdate">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>333</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>500</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_gui">
<item>
<widget class="QLabel" name="label_gui">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Path to GUI</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_gui"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_gui">
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_netctl">
<item>
<widget class="QLabel" name="label_netctl">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Path to netctl</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_netctl"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_netctl">
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_sudo">
<item>
<widget class="QCheckBox" name="checkBox_sudo">
<property name="minimumSize">
<size>
<width>150</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Use sudo for netctl</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_sudo"/>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_showBigInterface">
<property name="text">
<string>Show more detailed interface</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_showNetDev">
<property name="text">
<string>Show network devices</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_showExtIp">
<property name="text">
<string>Show external IP</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_showIntIp">
<property name="text">
<string>Show internal IP</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_configuration">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabAppearance">
<attribute name="title">
<string>Appearance</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layout_font">
<item>
<widget class="QLabel" name="label_font">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_font">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QFontComboBox" name="fontComboBox_font">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>180</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font family</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fontSize">
<item>
<widget class="QLabel" name="label_fontSize">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font size</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_fontSize">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fontSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font size</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>7</number>
</property>
<property name="maximum">
<number>48</number>
</property>
<property name="value">
<number>12</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fontColor">
<item>
<widget class="QLabel" name="label_fontColor">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font color</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_fontColor">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="KColorCombo" name="kcolorcombo_fontColor">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font color</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fontWeight">
<item>
<widget class="QLabel" name="label_fontWeight">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font weight</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_fontWeight">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fontWeight">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font weight</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="minimum">
<number>300</number>
</property>
<property name="maximum">
<number>600</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="value">
<number>400</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_fontStyle">
<item>
<widget class="QLabel" name="label_fontStyle">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Font style</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_fontStyle">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QComboBox" name="comboBox_fontStyle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="toolTip">
<string>Set font style</string>
</property>
<item>
<property name="text">
<string>normal</string>
</property>
</item>
<item>
<property name="text">
<string>italic</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_appearance">
<property name="lineWidth">
<number>5</number>
</property>
<property name="midLineWidth">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_activeIcon">
<item>
<widget class="QLabel" name="label_activeIcon">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Active icon</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_activeIcon"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_activeIcon">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_inactiveIcon">
<item>
<widget class="QLabel" name="label_inactiveIcon">
<property name="minimumSize">
<size>
<width>80</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Inactive icon</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_inactiveIcon"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_inactiveIcon">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_appearance">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KColorCombo</class>
<extends>QComboBox</extends>
<header>kcolorcombo.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>spinBox_autoUpdate</tabstop>
<tabstop>lineEdit_gui</tabstop>
<tabstop>pushButton_gui</tabstop>
<tabstop>lineEdit_netctl</tabstop>
<tabstop>pushButton_netctl</tabstop>
<tabstop>checkBox_sudo</tabstop>
<tabstop>lineEdit_sudo</tabstop>
<tabstop>checkBox_showBigInterface</tabstop>
<tabstop>checkBox_showNetDev</tabstop>
<tabstop>checkBox_showExtIp</tabstop>
<tabstop>checkBox_showIntIp</tabstop>
<tabstop>fontComboBox_font</tabstop>
<tabstop>spinBox_fontSize</tabstop>
<tabstop>kcolorcombo_fontColor</tabstop>
<tabstop>spinBox_fontWeight</tabstop>
<tabstop>comboBox_fontStyle</tabstop>
<tabstop>lineEdit_activeIcon</tabstop>
<tabstop>pushButton_activeIcon</tabstop>
<tabstop>lineEdit_inactiveIcon</tabstop>
<tabstop>pushButton_inactiveIcon</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,216 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DataEngineWindow</class>
<widget class="QWidget" name="DataEngineWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>337</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>480</width>
<height>320</height>
</size>
</property>
<property name="windowTitle">
<string notr="true">Configuration Window</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layout_netctl">
<item>
<widget class="QLabel" name="label_netctl">
<property name="minimumSize">
<size>
<width>150</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Path to netctl</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_netctl"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_netctl">
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_netctlAuto">
<item>
<widget class="QLabel" name="label_netctlAuto">
<property name="minimumSize">
<size>
<width>150</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Path to netctl-auto</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_netctlAuto"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_netctlAuto">
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_ip">
<item>
<widget class="QLabel" name="label_ip">
<property name="minimumSize">
<size>
<width>150</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Path to ip</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ip"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_ip">
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_interface">
<item>
<widget class="QLabel" name="label_interface">
<property name="minimumSize">
<size>
<width>150</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Path to interface list</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_interface"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_interface">
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_extIp">
<item>
<widget class="QCheckBox" name="checkBox_extIp">
<property name="minimumSize">
<size>
<width>150</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Check external IP</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_extIp"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_extIp">
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_dataengine">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<tabstops>
<tabstop>lineEdit_ip</tabstop>
<tabstop>lineEdit_netctl</tabstop>
<tabstop>pushButton_netctl</tabstop>
<tabstop>checkBox_extIp</tabstop>
<tabstop>lineEdit_extIp</tabstop>
<tabstop>pushButton_extIp</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

File diff suppressed because it is too large Load Diff

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui 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. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui 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 netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef NETCTL_PLASMOID_H
@ -25,7 +25,10 @@
#include <Plasma/Label>
#include <QProcess>
#include <ui_configwindow.h>
#include <ui_about.h>
#include <ui_appearance.h>
#include <ui_dataengine.h>
#include <ui_widget.h>
class QGraphicsLinearLayout;
@ -38,32 +41,48 @@ public:
Netctl(QObject *parent, const QVariantList &args);
~Netctl();
void init();
QMap<QString, QString> readDataEngineConfiguration();
void writeDataEngineConfiguration(const QMap<QString, QString> settings);
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
public slots:
// events
void showGui();
void sendNotification(const QString eventId, const QString message);
void showGui();
void showWifi();
// dataengine
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
// configuration interface
void configAccepted();
void configChanged();
void setBigInterface();
void setDataEngineExternalIp();
void setSudo();
void setWifi();
private slots:
// ui
void updateInterface(bool setHidden);
// configuration interface
void selectGuiExe();
void selectNetctlExe();
void selectActiveIcon();
void selectGuiExe();
void selectInactiveIcon();
void selectNetctlExe();
void selectNetctlAutoExe();
void selectSudoExe();
void selectWifiExe();
// dataengine
void selectDataEngineExternalIpExe();
void selectDataEngineInterfacesDirectory();
void selectDataEngineIpExe();
void selectDataEngineNetctlExe();
void selectDataEngineNetctlAutoExe();
// context menu
void enableProfileSlot();
void startProfileSlot(QAction *profile);
void stopProfileSlot();
void switchToProfileSlot(QAction *profile);
void restartProfileSlot();
void enableProfileAutoloadSlot();
protected:
void createConfigurationInterface(KConfigDialog *parent);
@ -77,46 +96,29 @@ private:
// text
Plasma::Label *textLabel;
bool status;
QString profileName;
QString profileStatus;
QString intIp;
QString extIp;
QString interfaces;
QMap<QString, QString> info;
QStringList profileList;
QStringList formatLine;
// context menu
void createActions();
QList<QAction*> menuActions;
QAction *startProfile;
QMenu *startProfileMenu;
QAction *stopProfile;
QAction *restartProfile;
QAction *enableProfileAutoload;
QMenu *switchToProfileMenu;
QMap<QString, QAction*> contextMenu;
// data engine
Plasma::DataEngine *netctlEngine;
void connectToEngine();
void disconnectFromEngine();
// notification
//
// configuration interface
Ui::ConfigWindow uiConfig;
Ui::AppearanceWindow uiAppConfig;
Ui::DataEngineWindow uiDEConfig;
Ui::ConfigWindow uiWidConfig;
Ui::About uiAboutConfig;
// configuration
int autoUpdateInterval;
QString guiPath;
QString netctlPath;
bool useSudo;
QString sudoPath;
bool showBigInterface;
bool showNetDev;
bool showExtIp;
bool showIntIp;
QString fontFamily;
int fontSize;
QString fontColor;
int fontWeight;
QString fontStyle;
QString activeIconPath;
QString inactiveIconPath;
QMap<QString, bool> bigInterface;
QStringList formatLine;
QMap<QString, QString> paths;
bool useSudo, useWifi;
};
K_EXPORT_PLASMA_APPLET(netctl, Netctl)

View File

@ -3,7 +3,7 @@ Encoding=UTF-8
Name=Netctl
Comment=Plasmoid for netctl
Type=Service
Icon=netctl-gui
Icon=netctl-gui-widget
X-KDE-ServiceTypes=Plasma/Applet
X-KDE-Library=plasma_applet_netctl

Some files were not shown because too many files have changed in this diff Show More