95 Commits

Author SHA1 Message Date
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
e576ff3b51 release 1.0.1 2014-03-25 12:06:18 +04:00
20e744d3cd removed install scripts 2014-03-25 12:00:34 +04:00
6132de0951 release 1.0.0 2014-03-25 11:00:50 +04:00
80e4b3e3d3 small changes before work on plasmoid 2014-03-21 19:11:47 +04:00
028b636d22 changes before renaming 2014-03-06 22:10:27 +04:00
682b6c5b4f small fixes before editing plasmoid 2014-03-02 18:45:07 +04:00
996d2d5bee more refactoring and tests profile tab 2014-03-02 17:56:19 +04:00
d0a39b6770 edited vlan before testing 2014-03-02 16:47:04 +04:00
8c9904ac4b added screenshot
edited buttons
2014-03-02 04:41:08 +04:00
e969be6b89 fix 2014-03-02 04:21:37 +04:00
9e854d8893 edited pkgbuild 2014-03-02 04:20:29 +04:00
ecea3f2cf8 small fix 2014-03-02 04:18:40 +04:00
e24b908015 more refactoring
+ added debug output
2014-03-02 04:11:55 +04:00
2abe09473a small fixes 2014-03-01 17:39:23 +04:00
f258f18e8c added translations 2014-03-01 16:32:33 +04:00
c66891ee60 added translations 2014-02-28 20:45:02 +04:00
3f02c047c2 more refactoring 2014-02-28 20:07:04 +04:00
2cade97786 added settings functions
added const type
2014-02-28 18:46:04 +04:00
fbad5a6c7d added settings window 2014-02-27 03:53:09 +04:00
710941c259 edited pkgbuild 2014-02-26 04:21:07 +04:00
32fb8ceb54 edited pkgbuild 2014-02-26 04:14:11 +04:00
9b3902e971 settings type has been changed from QHash to QMap 2014-02-26 04:07:50 +04:00
9184aa78f4 fix work wit arrays 2014-02-26 03:48:29 +04:00
0c219544b2 small fixes 2014-02-26 02:21:42 +04:00
946b470d11 looks working... 2014-02-25 16:09:37 +04:00
76877f737e added several function to profile tab 2014-02-25 02:06:33 +04:00
4dd6a8276d added setSettings() to ipwidget 2014-02-24 20:17:29 +04:00
4da239e41f added update functions 2014-02-24 19:59:12 +04:00
d98b3694a4 small edit of
added setSettings() to wireless
2014-02-24 19:55:04 +04:00
ac1a135844 added setSettings() to tunnel, tuntap and vlan 2014-02-24 19:32:34 +04:00
806cc02075 added setSettings() to pppoe 2014-02-24 19:27:58 +04:00
887cc013a7 function setSettings() has been added to mobile widget 2014-02-22 13:52:52 +04:00
3cb4e1dfee starting work on setSettings() functions 2014-02-22 13:35:05 +04:00
03b4744097 wireless widget has been completed
small fix
2014-02-22 03:34:04 +04:00
23df40960c intermediate commit 2014-02-22 02:35:07 +04:00
026f08d0cf tuntap, tunnel and vlan widgets have been completed 2014-02-22 00:38:17 +04:00
13c63163b1 pppoe widget has been completed 2014-02-22 00:06:53 +04:00
a56119d0de added command line arguments 2014-02-21 22:18:08 +04:00
f3b6457a9b now mobile ppp widget has been completed 2014-02-21 21:26:44 +04:00
d85e5560fa now ip widget has been completed 2014-02-20 02:39:27 +04:00
9cad2e2c29 small fix 2014-02-18 00:43:45 +04:00
49fcfafc9e now general widget has been completed 2014-02-18 00:38:57 +04:00
a20cac49aa now ethernet widget has been completed 2014-02-17 23:43:09 +04:00
4e53eaa1ea edited ethernet widget 2014-02-17 22:11:37 +04:00
6b9f9beabc added all widgets 2014-02-17 21:33:49 +04:00
6e427519af added pppoe widget 2014-02-17 20:21:00 +04:00
61bf2627cc added wirelesswidget 2014-02-11 16:40:26 +04:00
ec27411b1d added ethernet widget 2014-02-10 10:58:29 +04:00
b81bd78327 starting work on new profile tab... 2014-02-10 02:13:59 +04:00
8d3a3d29d2 added profile file 2014-02-09 21:09:36 +04:00
da7f1488c8 added errorwin and passwdwin
added function to read password
small changes
2014-02-08 17:40:29 +04:00
b439906be4 small changes in the architecture 2014-02-08 12:35:52 +04:00
65086a9aa3 almost working wifi module 2014-02-07 12:04:49 +04:00
95a3e0d544 try to get it work 2014-02-07 01:34:43 +04:00
d9571b76cf edited wpa functions, added scripts 2014-02-06 16:32:01 +04:00
4a2a27176f small commit 2014-02-06 11:06:36 +04:00
fc43861ba6 started work on wifi-menu 2014-02-05 00:28:02 +04:00
121ba0e54f small fixes 2014-02-04 22:05:35 +04:00
7a6930ce2c added main functions 2014-02-04 21:59:06 +04:00
e4c2402530 yet another edit of pkgbuild 2014-02-02 11:34:25 +04:00
c6902c6c6b edited pkgbuild 2014-02-02 11:15:45 +04:00
af414bb720 Small edit of cmakefiles 2014-02-02 04:57:59 +04:00
101 changed files with 14588 additions and 510 deletions

6
.gitignore vendored
View File

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

2
AUTHORS Normal file
View File

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

31
CHANGELOG Normal file
View File

@ -0,0 +1,31 @@
Ver.1.1.0 (netctl-1.7 update):
+ [gui] added frequency
+ [plasmoid] added menu title
* [gui] changed definition if profile is enabled]
* [dataengine] 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,37 +0,0 @@
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
pkgname=kdeplasma-applets-netctl
_pkgname=netctl-plasmoid
pkgver=1.0.0
pkgrel=1
pkgdesc="Plasmoid written on C++ which interacts with netctl"
arch=('i686' 'x86_64')
url="http://arcan1s.github.io/projects/netctlplasmoid"
license=('GPLv3')
depends=('kdebase-workspace')
makedepends=('cmake' 'automoc4')
source=(https://github.com/arcan1s/netctlplasmoid/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
install=${pkgname}.install
md5sums=('5ac750e391936a6f3494a819b7b4d0b2')
_cmakekeys="-DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix)
-DBUILD_GUI:BOOL=1
-DBUILD_PLASMOID:BOOL=1
-DCMAKE_BUILD_TYPE=Release"
prepare() {
if [[ -d ${srcdir}/build ]]; then
rm -rf "${srcdir}/build"
fi
mkdir "${srcdir}/build"
}
build () {
cd "${srcdir}/build"
cmake ${_cmakekeys} ../${_pkgname}
make
}
package() {
cd "${srcdir}/build"
make DESTDIR="${pkgdir}" install
}

39
PKGBUILD-qt4 Normal file
View File

@ -0,0 +1,39 @@
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
pkgname=netctl-gui-qt4
_pkgname=netctl-gui
pkgver=1.1.0
pkgrel=1
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
arch=('i686' 'x86_64')
url="http://arcanis.name/projects/netctl-gui"
license=('GPLv3')
depends=('netctl' 'qt4')
makedepends=('automoc4' 'cmake' 'desktop-file-utils')
optdepends=('kdebase-runtime: sudo support'
'kdeplasma-applets-netctl-gui: KDE widget'
'sudo: sudo support'
'wpa_supplicant: wifi support')
provides=('netctl-gui')
conflicts=('netctl-gui')
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz")
install="${_pkgname}.install"
md5sums=('229e11efda0a94bed44ea79b3deabf7c')
_cmakekeys="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DUSE_QT5:BOOL=0 -DBUILD_DATAENGINE:BOOL=0 -DBUILD_PLASMOID:BOOL=0"
prepare() {
rm -rf "${srcdir}/build"
mkdir "${srcdir}/build"
}
build() {
cd "${srcdir}/build"
cmake ${_cmakekeys} "../${_pkgname}"
make
}
package() {
cd "${srcdir}/build"
make DESTDIR="${pkgdir}" install
}

36
PKGBUILD-qt5 Normal file
View File

@ -0,0 +1,36 @@
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
pkgname=netctl-gui
pkgver=1.1.0
pkgrel=1
pkgdesc="Qt5 graphical front-end for netctl. A part of netctl-gui"
arch=('i686' 'x86_64')
url="http://arcanis.name/projects/netctl-gui"
license=('GPLv3')
depends=('netctl' 'qt5-base' 'xdg-utils')
makedepends=('automoc4' 'cmake' 'qt5-tools')
optdepends=('kdebase-runtime: sudo support'
'kdeplasma-applets-netctl-gui: KDE widget'
'sudo: sudo support'
'wpa_supplicant: wifi support')
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgname}-${pkgver}-src.tar.xz")
install="${pkgname}.install"
md5sums=('229e11efda0a94bed44ea79b3deabf7c')
_cmakekeys="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_DATAENGINE:BOOL=0 -DBUILD_PLASMOID:BOOL=0"
prepare() {
rm -rf "${srcdir}/build"
mkdir "${srcdir}/build"
}
build() {
cd "${srcdir}/build"
cmake ${_cmakekeys} "../${pkgname}"
make
}
package() {
cd "${srcdir}/build"
make DESTDIR="${pkgdir}" install
}

37
PKGBUILD-widget Normal file
View File

@ -0,0 +1,37 @@
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
pkgname=kdeplasma-applets-netctl-gui
_pkgname=netctl-gui
pkgver=1.1.0
pkgrel=1
pkgdesc="A plasmoid, which interacts with netctl. A part of netctl-gui"
arch=('i686' 'x86_64')
url="http://arcanis.name/projects/netctl-gui"
license=('GPLv3')
depends=('netctl' 'kdebase-workspace')
makedepends=('automoc4' 'cmake')
optdepends=('kdebase-runtime: sudo support'
'netctl-gui: graphical front-end'
'netctl-gui-qt4: graphical front-end'
'sudo: sudo support')
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz")
install="${_pkgname}.install"
md5sums=('229e11efda0a94bed44ea79b3deabf7c')
_cmakekeys="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI:BOOL=0"
prepare() {
rm -rf "${srcdir}/build"
mkdir "${srcdir}/build"
}
build() {
cd "${srcdir}/build"
cmake ${_cmakekeys} "../${_pkgname}"
make
}
package() {
cd "${srcdir}/build"
make DESTDIR="${pkgdir}" install
}

View File

@ -1,4 +1,67 @@
netctl-plasmoid
===============
Netctl GUI
==========
Plasmoid written on C++ which interacts with netctl
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!
Configuration
-------------
It is recommended to use graphical interface for widget configuration. DataEngine settings are stored in `/usr/share/config/netctl.conf`:
* `CMD` - netctl command. Default value is `/usr/bin/netctl`.
* `IPCMD` - ip command. `/usr/bin/ip` by default.
* `NETDIR` - a directory, which contains subdirectories with names of network interfaces. Default is `/sys/class/net/`.
* `EXTIPCMD` - a command, which returns external IP address. Default value is `wget -qO- http://ifconfig.me/ip`.
* `EXTIP` - `true` will enable external IP definition. Default is `false`.
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_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_GUI:BOOL=0` - do not build GUI
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
Additional information
======================
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/packages/netctl-gui) package

View File

@ -1,23 +1,25 @@
#!/bin/bash
ARCHIVE="netctl-plasmoid"
ARCHIVE="netctl-gui"
SRCDIR="sources"
FILES="LICENSE README.md"
IGNORELIST="CMakeLists.txt.user"
FILES="AUTHORS CHANGELOG COPYING README.md"
IGNORELIST="build gui/resources/translations/english.qm gui/resources/translations/russian.qm dataengine/dataengine.cppcheck gui/src/gui.cppcheck plasmoid/plasmoid.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 rm -rf "${ARCHIVE}/${FILE}"; 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
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" PKGBUILD
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD-qt4
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" PKGBUILD-qt4
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD-qt5
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" PKGBUILD-qt5
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD-widget
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" PKGBUILD-widget

View File

@ -1,5 +1,4 @@
post_install() {
kbuildsycoca4 > /dev/null 2>&1
xdg-icon-resource forceupdate --theme hicolor 2> /dev/null
update-desktop-database -q
}

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

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,9 +5,9 @@ cmake_policy (SET CMP0002 OLD)
cmake_policy (SET CMP0011 NEW)
cmake_policy (SET CMP0015 NEW)
project (netctl-plasmoid)
project (netctl-gui)
set (PROJECT_VERSION_MAJOR 1)
set (PROJECT_VERSION_MINOR 0)
set (PROJECT_VERSION_MINOR 1)
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)
@ -15,32 +15,27 @@ configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/ver
message (STATUS "Version: ${PROJECT_VERSION}")
# install options
option (WITH_DEBUG_MODE "Build with debug mode" OFF)
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
option (BUILD_GUI "Build GUI" ON)
option (BUILD_DATAENGINE "Build data engine" ON)
option (BUILD_PLASMOID "Build plasmoid" ON)
# verbose
set (CMAKE_VERBOSE_MAKEFILE ON)
# flags
if (WITH_DEBUG_MODE)
add_definitions (-DDEBUG_MODE=1)
endif ()
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 "-O3 -DNDEBUG")
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
else ()
message (STATUS "Unknown compiler")
endif ()
add_subdirectory (icons)
if (BUILD_PLASMOID)
set (BUILD_DATAENGINE ON)
endif ()
add_subdirectory (icons)
if (BUILD_GUI)
add_subdirectory (gui)
endif ()

View File

@ -6,12 +6,8 @@ message (STATUS "Subproject ${SUBPROJECT}")
find_package (KDE4 REQUIRED)
include (KDE4Defaults)
add_definitions (${QT_DEFINITIONS}
${KDE4_DEFINITIONS})
include_directories (${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${KDE4_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}/../)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
set (PLUGIN_NAME ${SUBPROJECT})
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)

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,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 Foobar. If not, see <http://www.gnu.org/licenses/>. *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "netctl.h"
#include <Plasma/DataContainer>
#include <KDE/KGlobal>
#include <KDE/KStandardDirs>
#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/");
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);
bool ok = confFile.open(QIODevice::ReadOnly);
if (!ok) {
configuration = updateConfiguration(rawConfig);
return;
}
QString fileStr;
QStringList value;
while (true) {
fileStr = QString(confFile.readLine());
fileStr = QString(confFile.readLine()).trimmed();
if (fileStr[0] == QChar('#')) continue;
if (fileStr[0] == QChar(';')) continue;
if (fileStr.contains(QChar('='))) {
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;
else 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];
}
}
}
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")))
value.remove(QChar(' '));
config[key] = value;
}
return config;
}
@ -100,125 +115,130 @@ 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 != QString("")) {
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 cmd)
{
QProcess command;
QString status = QString("static");
QString profile = getCurrentProfile(cmd);
command.start(cmd + QString(" is-enabled ") + profile);
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("CMD")]);
}
else if (source == QString("extIp")) {
if (checkExtIP == QString("true")) {
command.start(extIpCmd);
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
if (cmdOutput != QString(""))
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 != QString("")) {
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 != QString("")) {
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("CMD")]).join(QChar(','));
}
else if (source == QString("statusBool")) {
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
value = QString("false");
if (cmdOutput != QString("")) {
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("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 != QString("")) {
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 != QString("")) {
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].indexOf(QString("enabled")) > -1) {
value = QString("enabled");
break;
}
else if (profile[i].indexOf(QString("static")) > -1) {
value = QString("static");
break;
}
}
}
setData(source, QString("value"), value);
value = getProfileStringStatus(configuration[QString("CMD")]);
}
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 Foobar. If not, see <http://www.gnu.org/licenses/>. *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef NETCTL_DE_H
@ -20,30 +20,32 @@
#include <Plasma/DataEngine>
class Netctl : public Plasma::DataEngine
{
Q_OBJECT
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 cmd);
protected:
bool readConfiguration();
bool sourceRequestEvent(const QString &name);
bool updateSourceEvent(const QString &source);
QStringList sources() const;
private:
// 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);
};
#endif /* NETCTL_DE_H */

View File

@ -1,10 +1,10 @@
[Desktop Entry]
Encoding=UTF-8
Name=Netctl DataEngine
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,6 +5,8 @@ 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_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations)
# executable path
set (EXECUTABLE_OUTPUT_PATH ${SUBPROJECT_BINARY_DIR})
@ -15,5 +17,3 @@ set (HEADERS "")
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
install (FILES ${SUBPROJECT}.desktop DESTINATION share/applications/)
install (FILES ${SUBPROJECT}-logo.png DESTINATION share/pixmaps/)
install (FILES ${SUBPROJECT}.png DESTINATION share/icons/hicolor/32x32/apps/)

View File

@ -0,0 +1,10 @@
#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Netctl GUI
Comment=GUI written on Qt4 for netctl
Exec=netctl-gui
Icon=netctl-gui.png
Terminal=false
Encoding=UTF-8
Type=Application
Categories=Network

144
sources/gui/netctl.profile Normal file
View File

@ -0,0 +1,144 @@
! - обязательное поле
[ddsg] - условие для этой опции
в массиве первая опция - дефолт
yes - бинарная опция, по дефолту стоит no (и наоборот)
GENERAL
=======
Description=
! Connection=ethernet|wireless|bond|bridge|dummy|pppoe|mobile_ppp|tunnel|tuntap|vlan
! Interface=
BindsToInterfaces=(массив интерфейсов, которые будет ожидать этот профиль)
After=(список профилей, которые будут запущены перед этим)
ExecUpPost=команда, которая будет запущена после
ExecDownPre=команда, которая будет запущена перед
ForceConnect=yes - включить, даже если интерфейс уже поднят
IP
==
! IP=static|dhcp|no
! IP6=static|stateless|dhcp-noaddr|dhcp|no
[IP=static] Address=('192.168.1.23/24' '192.168.1.87/24')
[IP=static] Gateway='192.168.1.1'
Routes=('192.168.0.0/24 via 192.168.1.2')
[IP6=static]|[IP6=stateless] Address6=('1234:5678:9abc:def::1/64' '1234:3456::123/96')
[IP6=static]|[IP6=stateless] Gateway6='1234:0:123::abcd'
Routes6=('192.168.0.0/24 via 192.168.1.2')
[IP=dhcp] DHCPClient=dhcpcd|dhclient
[IP=dhcp] DHCPReleaseOnStop=yes - release the DHCP lease when the profile is stopped.
[IP=dhcp][DHCPClient=dhcpcd] DhcpcdOptions=опции
[IP=dhcp][DHCPClient=dhclient] DhclientOptions=опции
[IP=dhcp][DHCPClient=dhclient] DhclientOptions6=опции
IPCustom=('addr add dev eth0 192.168.1.23/24 brd +' 'route add default via 192.168.1.1') - команда для ip напрямую
Hostname=
DNS=('192.168.1.1')
DNSDomain= domain для /etc/resolv.conf
DNSSearch= search для /etc/resolv.conf
DNSOptions=() массив options для /etc/resolv.conf
TimeoutDHCP=30 - время в секундах
TimeoutDAD=3 - время в секундах для ipv6 удаление дубликата
ETHERNET
========
SkipNoCarrier=yes
Auth8021X=yes
WPAConfigFile=/etc/wpa_supplicant.conf
WPADriver=wired|nl80211|wext
TimeoutCarrier=5
TimeoutWPA=15
+ IP
WIRELESS
========
Security=none|wep|wpa|wpa-configsection|wpa-config
! ESSID=
AP=MAC address
[Security=wep]|[Security=wpa] ! Key='superpass'
Hidden=yes
AdHoc=yes
ScanFrequencies=A space-separated list of frequencies in MHz to scan when searching for the network.
Priority=0
[Security=wpa-configsection] ! WPAConfigSection=(
'ssid="University"'
'key_mgmt=WPA-EAP'
'eap=TTLS'
'group=TKIP'
'pairwise=TKIP CCMP'
'anonymous_identity="anonymous"'
'identity="myusername"'
'password="mypassword"'
'priority=1'
'phase2="auth=PAP"'
)
WPAConfigFile=/etc/wpa_supplicant.conf
Country=страна
WPAGroup=wheel (группа)
WPADriver=nl80211,wext
TimeoutWPA=15
RFKill=for X in 0..2 $(cat /sys/class/rfkill/rfkillX/name)|auto
ExcludeAuto=yes
+ IP
BOND
====
! BindsToInterfaces=
+ IP
BRIDGE
======
! BindsToInterfaces=
+ IP
DUMMY
=====
+ IP
PPPOE
=====
-User='example@yourprovider.com'
-Password='very secret'
ConnectionMode=persist|demand
[ConnectionMode=demand] IdleTimeout=0
MaxFail=5
DefaultRoute=false
UsePeerDNS=false
PPPUnit=ppp0|ppp1|...
-LCPEchoInterval=30
-LCPEchoFailure=4
OptionsFile=доп файл
PPPoEService=имя
PPPoEAC=имя
PPPoESession='sessid:macaddr'
PPPoEMAC=мак
PPPoEIP6=yes
MOBILE_PPP
==========
MaxFail=5
DefaultRoute=false
UsePeerDNS=false
-User='example@yourprovider.com'
-Password='very secret'
AccessPointName=имя
Pin=код
Mode=None|3Gpref|3Gonly|GPRSpref|GPRSonly
OptionsFile=доп файл
TUNNEL
======
Mode=ipip|gre|sit|isatap|ip6ip6|ipip6|ip6gre|any
Local='172.16.0.1'
Remote='216.66.80.26'
+ ip
TUNTAP
======
Mode=tun|tap
User='nobody'
Group='nobody'
+ ip
VLAN
====
! BindsToInterfaces=
VLANID=55

View File

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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,26 +3,71 @@ file (GLOB SOURCES *.cpp)
file (GLOB HEADERS *.h)
file (GLOB FORMS *.ui)
set (LANGUAGES english
russian)
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 (${SUBPROJECT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../)
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
find_package (Qt4 REQUIRED)
include (${QT_USE_FILE})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
qt4_wrap_ui (UI_HEADERS ${FORMS})
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})
source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES})
source_group ("Generated Files" FILES ${MOC_SOURCES})
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 ${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})
message (STATUS "${SUBPROJECT} Translations: ${TRANSLATIONS_BINARY}")
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES})
target_link_libraries (${SUBPROJECT} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
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_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
target_link_libraries (${SUBPROJECT} ${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 ${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}")
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})
endif()
# install properties
install (TARGETS ${SUBPROJECT} DESTINATION bin)

View File

@ -0,0 +1,80 @@
/***************************************************************************
* 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 "bridgewidget.h"
#include "ui_bridgewidget.h"
BridgeWidget::BridgeWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::BridgeWidget)
{
ui->setupUi(this);
clear();
}
BridgeWidget::~BridgeWidget()
{
delete ui;
}
void BridgeWidget::clear()
{
ui->checkBox_skip->setCheckState(Qt::Unchecked);
}
void BridgeWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
QMap<QString, QString> BridgeWidget::getSettings()
{
QMap<QString, QString> bridgeSettings;
if (isOk() != 0)
return bridgeSettings;
if (ui->checkBox_skip->checkState() == Qt::Checked)
bridgeSettings[QString("SkipForwardingDelay")] = QString("yes");
return bridgeSettings;
}
int BridgeWidget::isOk()
{
// all fine
return 0;
}
void BridgeWidget::setSettings(const QMap<QString, QString> settings)
{
QMap<QString, QString> bridgeSettings = settings;
if (bridgeSettings.contains(QString("SkipForwardingDelay")))
if (bridgeSettings[QString("SkipForwardingDelay")].remove(QString("'")) == QString("yes"))
ui->checkBox_skip->setCheckState(Qt::Checked);
}

View File

@ -0,0 +1,48 @@
/***************************************************************************
* 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 BRIDGEWIDGET_H
#define BRIDGEWIDGET_H
#include <QWidget>
namespace Ui {
class BridgeWidget;
}
class BridgeWidget : public QWidget
{
Q_OBJECT
public:
explicit BridgeWidget(QWidget *parent = 0);
~BridgeWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private:
Ui::BridgeWidget *ui;
};
#endif /* BRIDGEWIDGET_H */

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BridgeWidget</class>
<widget class="QWidget" name="BridgeWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>424</width>
<height>76</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_bridge">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Bridge settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_bridge">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="checkBox_skip">
<property name="toolTip">
<string>Skip (R)STP and immediately activate all bridge members</string>
</property>
<property name="text">
<string>Skip forwarding delay</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,96 @@
/***************************************************************************
* 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 "errorwindow.h"
#include "ui_errorwindow.h"
#include <QDebug>
ErrorWindow::ErrorWindow(QWidget *parent, const int messageNumber)
: QMainWindow(parent),
ui(new Ui::ErrorWindow)
{
ui->setupUi(this);
qDebug() << "[ErrorWindow]" << "[ErrorWindow]" << ":" << "Initializate with error code" << messageNumber;
setMessage(messageNumber);
}
ErrorWindow::~ErrorWindow()
{
delete ui;
}
void ErrorWindow::setMessage(const int mess)
{
QString message;
switch(mess) {
case 1:
message = QApplication::translate("ErrorWindow", "Could not find components");
break;
case 2:
message = QApplication::translate("ErrorWindow", "Does not support yet");
break;
case 3:
message = QApplication::translate("ErrorWindow", "Profile name is not set");
break;
case 4:
message = QApplication::translate("ErrorWindow", "Bind interfaces are not set");
break;
case 5:
message = QApplication::translate("ErrorWindow", "Description is not set");
break;
case 6:
message = QApplication::translate("ErrorWindow", "Ip settings are not set");
break;
case 7:
message = QApplication::translate("ErrorWindow", "Configuration file does not exist");
break;
case 8:
message = QApplication::translate("ErrorWindow", "Key is not set");
break;
case 9:
message = QApplication::translate("ErrorWindow", "Wireless settings are not set");
break;
case 10:
message = QApplication::translate("ErrorWindow", "Configuration file is not set");
break;
case 11:
message = QApplication::translate("ErrorWindow", "ESSID is not set");
break;
case 12:
message = QApplication::translate("ErrorWindow", "MAC address is incorrect");
break;
case 13:
message = QApplication::translate("ErrorWindow", "Session ID is not set");
break;
case 14:
message = QApplication::translate("ErrorWindow", "APN is not set");
break;
case 15:
message = QApplication::translate("ErrorWindow", "APN is not set");
break;
case 16:
message = QApplication::translate("ErrorWindow", "Empty user/group name");
break;
default:
message = QApplication::translate("ErrorWindow", "Unknown error");
break;
}
ui->label->setText(message);
}

View File

@ -0,0 +1,42 @@
/***************************************************************************
* 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 ERRORWINDOW_H
#define ERRORWINDOW_H
#include <QMainWindow>
namespace Ui {
class ErrorWindow;
}
class ErrorWindow : public QMainWindow
{
Q_OBJECT
public:
explicit ErrorWindow(QWidget *parent = 0,
const int messageNumber = 0);
~ErrorWindow();
private:
Ui::ErrorWindow *ui;
void setMessage(const int mess);
};
#endif /* ERRORWINDOW_H */

View File

@ -0,0 +1,123 @@
<?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

@ -0,0 +1,164 @@
/***************************************************************************
* 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 "ethernetwidget.h"
#include "ui_ethernetwidget.h"
#include <QDir>
#include <QFileDialog>
#include <QFile>
EthernetWidget::EthernetWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::EthernetWidget)
{
ui->setupUi(this);
createActions();
clear();
}
EthernetWidget::~EthernetWidget()
{
delete ui;
}
void EthernetWidget::clear()
{
ui->checkBox_skip->setCheckState(Qt::Unchecked);
ui->checkBox_8021x->setCheckState(Qt::Unchecked);
showWpa(ui->checkBox_8021x->checkState());
ui->lineEdit_wpaConfig->clear();
ui->comboBox_driver->setCurrentIndex(0);
ui->spinBox_timeoutCarrier->setValue(5);
ui->spinBox_timeoutWpa->setValue(15);
ui->pushButton_ethernetAdvanced->setChecked(false);
showAdvanced();
}
void EthernetWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void EthernetWidget::createActions()
{
connect(ui->pushButton_ethernetAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->pushButton_wpaConfig, SIGNAL(clicked(bool)), this, SLOT(selectWpaConfig()));
connect(ui->checkBox_8021x, SIGNAL(stateChanged(int)), this, SLOT(showWpa(int)));
}
void EthernetWidget::selectWpaConfig()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("EthernetWidget", "Select wpa configuration file"),
QDir::currentPath(),
QApplication::translate("EthernetWidget", "Configuration files (*.conf)"));
if (!filename.isEmpty())
ui->lineEdit_wpaConfig->setText(filename);
}
void EthernetWidget::showAdvanced()
{
if (ui->pushButton_ethernetAdvanced->isChecked()) {
ui->widget_ethernetAdvanced->setHidden(false);
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
}
else {
ui->widget_ethernetAdvanced->setHidden(true);
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Show advanced"));
}
}
void EthernetWidget::showWpa(const int state)
{
if (state == 0)
ui->widget_wpa->setHidden(true);
else
ui->widget_wpa->setHidden(false);
}
QMap<QString, QString> EthernetWidget::getSettings()
{
QMap<QString, QString> ethernetSettings;
if (isOk() != 0)
return ethernetSettings;
if (ui->checkBox_skip->checkState() == Qt::Checked)
ethernetSettings[QString("SkipNoCarrier")] = QString("yes");
if (ui->checkBox_8021x->checkState() == Qt::Checked) {
ethernetSettings[QString("Auth8021X")] = QString("yes");
ethernetSettings[QString("WPAConfigFile")] = QString("'") + ui->lineEdit_wpaConfig->text() + QString("'");
ethernetSettings[QString("WPADriver")] = ui->comboBox_driver->currentText();
}
if (ui->spinBox_timeoutCarrier->value() != 5)
ethernetSettings[QString("TimeoutCarrier")] = QString::number(ui->spinBox_timeoutCarrier->value());
if (ui->spinBox_timeoutWpa->value() != 15)
ethernetSettings[QString("TimeoutWPA")] = QString::number(ui->spinBox_timeoutWpa->value());
return ethernetSettings;
}
int EthernetWidget::isOk()
{
// file wpa_supplicant doesn't exists
if (!ui->lineEdit_wpaConfig->text().isEmpty())
if (!QFile(ui->lineEdit_wpaConfig->text()).exists())
return 1;
// all fine
return 0;
}
void EthernetWidget::setSettings(const QMap<QString, QString> settings)
{
QMap<QString, QString> ethernetSettings = settings;
if (ethernetSettings.contains(QString("SkipNoCarrier")))
if (ethernetSettings[QString("SkipNoCarrier")].remove(QString("'")) == QString("yes"))
ui->checkBox_skip->setCheckState(Qt::Checked);
if (ethernetSettings.contains(QString("Auth8021X")))
if (ethernetSettings[QString("Auth8021X")].remove(QString("'")) == QString("yes"))
ui->checkBox_8021x->setCheckState(Qt::Checked);
if (ethernetSettings.contains(QString("WPAConfigFile")))
ui->lineEdit_wpaConfig->setText(ethernetSettings[QString("WPAConfigFile")].remove(QString("'")));
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))
ui->comboBox_driver->setCurrentIndex(i);
if (ethernetSettings.contains(QString("TimeoutCarrier")))
ui->spinBox_timeoutCarrier->setValue(ethernetSettings[QString("TimeoutCarrier")].toInt());
if (ethernetSettings.contains(QString("TimeoutWPA")))
ui->spinBox_timeoutWpa->setValue(ethernetSettings[QString("TimeoutWPA")].toInt());
showWpa(ui->checkBox_8021x->checkState());
}

View File

@ -0,0 +1,55 @@
/***************************************************************************
* 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 ETHERNETWIDGET_H
#define ETHERNETWIDGET_H
#include <QMap>
#include <QWidget>
namespace Ui {
class EthernetWidget;
}
class EthernetWidget : public QWidget
{
Q_OBJECT
public:
explicit EthernetWidget(QWidget *parent = 0);
~EthernetWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private slots:
void selectWpaConfig();
void showAdvanced();
void showWpa(const int state);
private:
Ui::EthernetWidget *ui;
void createActions();
};
#endif /* ETHERNETWIDGET_H */

View File

@ -0,0 +1,237 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EthernetWidget</class>
<widget class="QWidget" name="EthernetWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>431</width>
<height>296</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_ethernet">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Ethernet options</string>
</property>
<widget class="QWidget" name="dockWidgetContents_ethernet">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="layout_ethernetAdvanced">
<item>
<spacer name="spacer_ethernetAdvanced">
<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_ethernetAdvanced">
<property name="text">
<string>Hide advanced</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_ethernetAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QCheckBox" name="checkBox_skip">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Whether or not the absence of a carrier is acceptable&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Skip no carrier</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_8021x">
<property name="toolTip">
<string>Set to yes to use 802.1x authentication</string>
</property>
<property name="text">
<string>802.1x authentication</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_wpa" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_wpaConfig">
<item>
<widget class="QLabel" name="label_wpaConfig">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>WPA config file</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaConfig">
<property name="toolTip">
<string>Path to a wpa_supplicant configuration file</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_wpaConfig">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_driver">
<item>
<widget class="QLabel" name="label_driver">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>WPA driver</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_driver">
<property name="toolTip">
<string>The wpa_supplicant driver to use for 802.1x authentication</string>
</property>
<item>
<property name="text">
<string>wired</string>
</property>
</item>
<item>
<property name="text">
<string>nl80211</string>
</property>
</item>
<item>
<property name="text">
<string>wext</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_timeoutCarrier">
<item>
<widget class="QLabel" name="label_timeoutCarrier">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Timeout carrier</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timeoutCarrier">
<property name="toolTip">
<string>Maximum time, in seconds, to wait for a carrier</string>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_timeoutWpa">
<item>
<widget class="QLabel" name="label_timeoutWpa">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Timeout WPA</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timeoutWpa">
<property name="toolTip">
<string>Maximum time, in seconds, to wait for 802.1x authentication to succeed</string>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>15</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>pushButton_ethernetAdvanced</tabstop>
<tabstop>checkBox_skip</tabstop>
<tabstop>checkBox_8021x</tabstop>
<tabstop>lineEdit_wpaConfig</tabstop>
<tabstop>pushButton_wpaConfig</tabstop>
<tabstop>comboBox_driver</tabstop>
<tabstop>spinBox_timeoutCarrier</tabstop>
<tabstop>spinBox_timeoutWpa</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,204 @@
/***************************************************************************
* 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 "generalwidget.h"
#include "ui_generalwidget.h"
#include <QKeyEvent>
GeneralWidget::GeneralWidget(QWidget *parent, const QMap<QString, QString> settings)
: QWidget(parent),
ui(new Ui::GeneralWidget)
{
ui->setupUi(this);
connectionType = ui->comboBox_connection;
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
createActions();
clear();
}
GeneralWidget::~GeneralWidget()
{
delete connectionType;
delete ifaceDirectory;
delete profileDirectory;
delete ui;
}
void GeneralWidget::clear()
{
ui->lineEdit_description->setText(QString("Generated by Netctl GUI"));
ui->comboBox_connection->setCurrentIndex(0);
ui->comboBox_interface->clear();
ui->comboBox_interface->addItems(ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot));
ui->comboBox_bindto->clear();
ui->comboBox_bindto->addItems(ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot));
ui->listWidget_bindto->setCurrentRow(-1);
ui->listWidget_bindto->clear();
ui->comboBox_after->clear();
ui->comboBox_after->addItems(profileDirectory->entryList(QDir::Files));
ui->listWidget_after->setCurrentRow(-1);
ui->listWidget_after->clear();
ui->lineEdit_execUpPost->clear();
ui->lineEdit_execDownPre->clear();
ui->checkBox_forceConnect->setCheckState(Qt::Unchecked);
ui->checkBox_debug->setCheckState(Qt::Unchecked);
ui->pushButton_generalAdvanced->setChecked(false);
showAdvanced();
}
void GeneralWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void GeneralWidget::createActions()
{
connect(ui->pushButton_generalAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->pushButton_after, SIGNAL(clicked(bool)), this, SLOT(addAfter()));
connect(ui->pushButton_bindto, SIGNAL(clicked(bool)), this, SLOT(addBindTo()));
}
void GeneralWidget::addAfter()
{
ui->listWidget_after->addItem(ui->comboBox_after->currentText());
}
void GeneralWidget::addBindTo()
{
ui->listWidget_bindto->addItem(ui->comboBox_bindto->currentText());
}
void GeneralWidget::keyPressEvent(QKeyEvent *pressedKey)
{
if (pressedKey->key() == Qt::Key_Delete) {
if (ui->listWidget_bindto->hasFocus() &&
(ui->listWidget_bindto->currentItem() != 0))
delete ui->listWidget_bindto->currentItem();
else if (ui->listWidget_after->hasFocus() &&
(ui->listWidget_after->currentItem() != 0))
delete ui->listWidget_after->currentItem();
}
}
void GeneralWidget::showAdvanced()
{
if (ui->pushButton_generalAdvanced->isChecked()) {
ui->widget_generalAdvanced->setHidden(false);
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
}
else {
ui->widget_generalAdvanced->setHidden(true);
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Show advanced"));
}
}
QMap<QString, QString> GeneralWidget::getSettings()
{
QMap<QString, QString> generalSettings;
if (isOk() != 0)
return generalSettings;
generalSettings[QString("Description")] = QString("'") + ui->lineEdit_description->text() + QString("'");
generalSettings[QString("Connection")] = ui->comboBox_connection->currentText();
generalSettings[QString("Interface")] = ui->comboBox_interface->currentText();
if (ui->listWidget_bindto->count() != 0) {
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(" "));
}
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(" "));
}
if (!ui->lineEdit_execUpPost->text().isEmpty())
generalSettings[QString("ExecUpPost")] = QString("'") + ui->lineEdit_execUpPost->text() + QString("'");
if (!ui->lineEdit_execDownPre->text().isEmpty())
generalSettings[QString("ExecDownPre")] = QString("'") + ui->lineEdit_execDownPre->text() + QString("'");
if (ui->checkBox_forceConnect->checkState() == Qt::Checked)
generalSettings[QString("ForceConnect")] = QString("yes");
if (ui->checkBox_debug->checkState() == Qt::Checked)
generalSettings[QString("NETCTL_DEBUG")] = QString("yes");
return generalSettings;
}
int GeneralWidget::isOk()
{
// bind interfaces is not set
if ((ui->comboBox_connection->currentText() == QString("bond")) ||
(ui->comboBox_connection->currentText() == QString("bridge")) ||
(ui->comboBox_connection->currentText() == QString("vlan")))
if (ui->listWidget_bindto->count() == 0)
return 1;
// empty description
if (ui->lineEdit_description->text().isEmpty())
return 2;
// all fine
return 0;
}
void GeneralWidget::setSettings(const QMap<QString, QString> settings)
{
QMap<QString, QString> generalSettings = settings;
if (generalSettings.contains(QString("Description")))
ui->lineEdit_description->setText(generalSettings[QString("Description")].remove(QString("'")));
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))
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("BindsToInterfaces")))
ui->listWidget_bindto->addItems(generalSettings[QString("BindsToInterfaces")].split(QString(" ")));
if (generalSettings.contains(QString("After")))
ui->listWidget_after->addItems(generalSettings[QString("After")].split(QString(" ")));
if (generalSettings.contains(QString("ExecUpPost")))
ui->lineEdit_execUpPost->setText(generalSettings[QString("ExecUpPost")].remove(QString("'")));
if (generalSettings.contains(QString("ExecDownPre")))
ui->lineEdit_execDownPre->setText(generalSettings[QString("ExecDownPre")].remove(QString("'")));
if (generalSettings.contains(QString("ForceConnect")))
if (generalSettings[QString("ForceConnect")].remove(QString("'")) == QString("yes"))
ui->checkBox_forceConnect->setCheckState(Qt::Checked);
if (generalSettings.contains(QString("NETCTL_DEBUG")))
if (generalSettings[QString("NETCTL_DEBUG")].remove(QString("'")) == QString("yes"))
ui->checkBox_debug->setCheckState(Qt::Checked);
}

View File

@ -0,0 +1,62 @@
/***************************************************************************
* 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 GENERALWIDGET_H
#define GENERALWIDGET_H
#include <QComboBox>
#include <QDir>
#include <QMap>
#include <QWidget>
namespace Ui {
class GeneralWidget;
}
class GeneralWidget : public QWidget
{
Q_OBJECT
public:
explicit GeneralWidget(QWidget *parent = 0,
const QMap<QString, QString> settings = QMap<QString, QString>());
~GeneralWidget();
QComboBox *connectionType;
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private slots:
void addAfter();
void addBindTo();
void showAdvanced();
private:
QDir *ifaceDirectory;
QDir *profileDirectory;
Ui::GeneralWidget *ui;
void createActions();
void keyPressEvent(QKeyEvent *pressedKey);
};
#endif /* GENERALWIDGET_H */

View File

@ -0,0 +1,354 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GeneralWidget</class>
<widget class="QWidget" name="GeneralWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>431</width>
<height>537</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QDockWidget" name="dockWidget_general">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>General</string>
</property>
<widget class="QWidget" name="dockWidgetContents_general">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="layout_description">
<item>
<widget class="QLabel" name="label_description">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Description</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_description">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;A description of the profile&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_connection">
<item>
<widget class="QLabel" name="label_connection">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Connection</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_connection">
<property name="toolTip">
<string>The connection type used by the profile</string>
</property>
<item>
<property name="text">
<string notr="true">ethernet</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">wireless</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">bond</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">bridge</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">dummy</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">pppoe</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">mobile_ppp</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">tunnel</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">tuntap</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">vlan</string>
</property>
</item>
</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>0</height>
</size>
</property>
<property name="text">
<string>Interface</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_interface">
<property name="toolTip">
<string>The name of the associated network interface</string>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="layout_bindto">
<item>
<layout class="QHBoxLayout" name="layout_bindtoButton">
<item>
<widget class="QLabel" name="label_bindto">
<property name="text">
<string>Binds to interfaces</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_bindto">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_bindto">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_bindto">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="toolTip">
<string>An array of physical network interfaces that this profile needs before it can be started</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_generalAdvanced">
<item>
<spacer name="spacer_generalAdvanced">
<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_generalAdvanced">
<property name="text">
<string>Hide advanced</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_generalAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="layout_after">
<item>
<layout class="QHBoxLayout" name="layout_afterButton">
<item>
<widget class="QLabel" name="label_after">
<property name="text">
<string>After</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_after">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_after">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_after">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="toolTip">
<string>An array of profile names that should be started before this profile is started</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_execUpPost">
<item>
<widget class="QLabel" name="label_execUpPost">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Command after starting</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_execUpPost">
<property name="toolTip">
<string>A command that is executed after a connection is established</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_execDownPre">
<item>
<widget class="QLabel" name="label_execDownPre">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Command before stoping</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_execDownPre">
<property name="toolTip">
<string>A command that is executed before a connection is brought down</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_forceConnect">
<property name="toolTip">
<string>Set to yes to force connecting even if the interface is up</string>
</property>
<property name="text">
<string>Force connect</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_debug">
<property name="text">
<string>Debug mode</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

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

View File

@ -0,0 +1,568 @@
/***************************************************************************
* 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 "ipwidget.h"
#include "ui_ipwidget.h"
#include <QDebug>
#include <QKeyEvent>
IpWidget::IpWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::IpWidget)
{
ui->setupUi(this);
createActions();
createFilter();
clear();
}
IpWidget::~IpWidget()
{
delete ui;
}
void IpWidget::clear()
{
ui->checkBox_ip->setCheckState(Qt::Checked);
ui->comboBox_ip->setCurrentIndex(0);
ipEnable(ui->checkBox_ip->checkState());
changeIpMode(ui->comboBox_ip->currentText());
ui->lineEdit_ipAddress->clear();
ui->listWidget_ipAddress->setCurrentRow(-1);
ui->listWidget_ipAddress->clear();
ui->lineEdit_gateway->clear();
ui->lineEdit_ipRoutes->clear();
ui->lineEdit_ipRoutes2->clear();
ui->listWidget_ipRoutes->setCurrentRow(-1);
ui->listWidget_ipRoutes->clear();
ui->checkBox_ip6->setCheckState(Qt::Unchecked);
ui->comboBox_ip6->setCurrentIndex(0);
ip6Enable(ui->checkBox_ip6->checkState());
changeIp6Mode(ui->comboBox_ip6->currentText());
ui->lineEdit_ipAddress6->clear();
ui->listWidget_ipAddress6->setCurrentRow(-1);
ui->listWidget_ipAddress6->clear();
ui->lineEdit_gateway6->clear();
ui->lineEdit_ipRoutes6->clear();
ui->lineEdit_ipRoutes62->clear();
ui->listWidget_ipRoutes6->setCurrentRow(-1);
ui->listWidget_ipRoutes6->clear();
ui->lineEdit_custom->clear();
ui->listWidget_custom->clear();
ui->lineEdit_hostname->clear();
ui->spinBox_timeoutDad->setValue(3);
ui->comboBox_dhcp->setCurrentIndex(0);
changeDhcpClient(ui->comboBox_dhcp->currentText());
ui->lineEdit_dhcpcdOpt->clear();
ui->lineEdit_dhclientOpt->clear();
ui->lineEdit_dhclientOpt6->clear();
ui->spinBox_timeoutDhcp->setValue(30);
ui->checkBox_dhcp->setCheckState(Qt::Unchecked);
ui->lineEdit_dns->clear();
ui->listWidget_dns->setCurrentRow(-1);
ui->listWidget_dns->clear();
ui->lineEdit_dnsDomain->clear();
ui->lineEdit_dnsSearch->clear();
ui->lineEdit_dnsOptions->clear();
ui->listWidget_dnsOptions->setCurrentRow(-1);
ui->listWidget_dnsOptions->clear();
ui->pushButton_ipAdvanced->setChecked(false);;
showAdvanced();
}
void IpWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void IpWidget::createActions()
{
connect(ui->pushButton_ipAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
// ip mode
connect(ui->checkBox_ip, SIGNAL(stateChanged(int)), this, SLOT(ipEnable(int)));
connect(ui->comboBox_ip, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeIpMode(QString)));
// ipv6 mode
connect(ui->checkBox_ip6, SIGNAL(stateChanged(int)), this, SLOT(ip6Enable(int)));
connect(ui->comboBox_ip6, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeIp6Mode(QString)));
// dhcp client
connect(ui->comboBox_dhcp, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeDhcpClient(QString)));
// buttons
connect(ui->pushButton_ipAddress, SIGNAL(clicked(bool)), this, SLOT(addIp()));
connect(ui->pushButton_ipRoutes, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes()));
connect(ui->pushButton_ipAddress6, SIGNAL(clicked(bool)), this, SLOT(addIp6()));
connect(ui->pushButton_ipRoutes6, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes6()));
connect(ui->pushButton_custom, SIGNAL(clicked(bool)), this, SLOT(addCustom()));
connect(ui->pushButton_dns, SIGNAL(clicked(bool)), this, SLOT(addDns()));
connect(ui->pushButton_dnsOptions, SIGNAL(clicked(bool)), this, SLOT(addDnsOpt()));
}
void IpWidget::createFilter()
{
// using input mask because validators is not comfortable
// ipv4
ui->lineEdit_ipAddress->setInputMask(QString("999.999.999.999/99"));
ui->lineEdit_gateway->setInputMask(QString("999.999.999.999"));
ui->lineEdit_ipRoutes->setInputMask(QString("999.999.999.999/99"));
ui->lineEdit_ipRoutes2->setInputMask(QString("999.999.999.999"));
// ipv6
ui->lineEdit_ipAddress6->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh/999"));
ui->lineEdit_gateway6->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh"));
ui->lineEdit_ipRoutes6->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh/999"));
ui->lineEdit_ipRoutes62->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh"));
// dns
ui->lineEdit_dns->setInputMask(QString("999.999.999.999"));
}
void IpWidget::keyPressEvent(QKeyEvent *pressedKey)
{
if (pressedKey->key() == Qt::Key_Delete) {
if (ui->listWidget_ipAddress->hasFocus() &&
(ui->listWidget_ipAddress->currentItem() != 0))
delete ui->listWidget_ipAddress->currentItem();
else if (ui->listWidget_ipRoutes->hasFocus() &&
(ui->listWidget_ipRoutes->currentItem() != 0))
delete ui->listWidget_ipRoutes->currentItem();
else if (ui->listWidget_ipAddress6->hasFocus() &&
(ui->listWidget_ipAddress6->currentItem() != 0))
delete ui->listWidget_ipAddress6->currentItem();
else if (ui->listWidget_ipRoutes6->hasFocus() &&
(ui->listWidget_ipRoutes6->currentItem() != 0))
delete ui->listWidget_ipRoutes6->currentItem();
else if (ui->listWidget_custom->hasFocus() &&
(ui->listWidget_custom->currentItem() != 0))
delete ui->listWidget_custom->currentItem();
else if (ui->listWidget_dns->hasFocus() &&
(ui->listWidget_dns->currentItem() != 0))
delete ui->listWidget_dns->currentItem();
else if (ui->listWidget_dnsOptions->hasFocus() &&
(ui->listWidget_dnsOptions->currentItem() != 0))
delete ui->listWidget_dnsOptions->currentItem();
}
}
QString IpWidget::getIp(const QString rawIp)
{
QStringList ip = rawIp.split(QString("."));
// fix empty fields
if (ip[0].isEmpty())
ip[0] = QString("127");
if (ip[1].isEmpty())
ip[1] = QString("0");
if (ip[2].isEmpty())
ip[2] = QString("0");
if (ip[3].isEmpty())
ip[3] = QString("1");
// fix numbers
for (int i=0; i<4; i++)
if (ip[i].toInt() > 255)
ip[i] = QString("255");
return ip.join(QString("."));
}
QString IpWidget::getPrefix(const QString rawPrefix)
{
QString prefix;
if (rawPrefix.isEmpty())
prefix = QString("24");
else if (rawPrefix.toInt() > 32)
prefix = QString("32");
else
prefix = rawPrefix;
return prefix;
}
QString IpWidget::getIp6(const QString rawIp)
{
QString ip = rawIp;
for (int i=0; i<5; i++)
ip.replace(QString(":::"), QString("::"));
return ip;
}
QString IpWidget::getPrefix6(const QString rawPrefix)
{
QString prefix;
if (rawPrefix.isEmpty())
prefix = QString("64");
else if (rawPrefix.toInt() > 128)
prefix = QString("128");
else
prefix = rawPrefix;
return prefix;
}
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]);
ui->listWidget_ipAddress->addItem(ip + QString("/") + prefix);
ui->lineEdit_ipAddress->clear();
}
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(" "));
ui->listWidget_ipRoutes->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
ui->lineEdit_ipRoutes->clear();
ui->lineEdit_ipRoutes2->clear();
}
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]);
ui->listWidget_ipAddress6->addItem(ip + QString("/") + prefix);
ui->lineEdit_ipAddress6->clear();
}
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(" "));
ui->listWidget_ipRoutes6->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
ui->lineEdit_ipRoutes6->clear();
ui->lineEdit_ipRoutes62->clear();
}
void IpWidget::addCustom()
{
if (!ui->lineEdit_custom->text().isEmpty())
ui->listWidget_custom->addItem(ui->lineEdit_custom->text());
ui->lineEdit_custom->clear();
}
void IpWidget::addDns()
{
QString ip = getIp(ui->lineEdit_dns->text().remove(" "));
ui->listWidget_dns->addItem(ip);
ui->lineEdit_dns->clear();
}
void IpWidget::addDnsOpt()
{
if (!ui->lineEdit_dnsOptions->text().isEmpty())
ui->listWidget_dnsOptions->addItem(ui->lineEdit_dnsOptions->text());
ui->lineEdit_dnsOptions->clear();
}
void IpWidget::changeIpMode(const QString currentText)
{
if (currentText == QString("dhcp"))
ui->widget_ip->setHidden(true);
else if (currentText == QString("static"))
ui->widget_ip->setHidden(false);
}
void IpWidget::ipEnable(const int state)
{
if (state == 0) {
ui->comboBox_ip->setDisabled(true);
ui->widget_ip->setDisabled(true);
ui->widget_ipRoutes->setDisabled(true);
}
else {
ui->comboBox_ip->setEnabled(true);
ui->widget_ip->setEnabled(true);
ui->widget_ipRoutes->setEnabled(true);
}
}
void IpWidget::changeIp6Mode(const QString currentText)
{
if ((currentText == QString("dhcp")) ||
(currentText == QString("dhcp-noaddr")))
ui->widget_ip6->setHidden(true);
else if ((currentText == QString("static")) ||
(currentText == QString("stateless")))
ui->widget_ip6->setHidden(false);
}
void IpWidget::ip6Enable(const int state)
{
if (state == 0) {
ui->comboBox_ip6->setDisabled(true);
ui->widget_ip6->setDisabled(true);
ui->widget_ipRoutes6->setDisabled(true);
}
else {
ui->comboBox_ip6->setEnabled(true);
ui->widget_ip6->setEnabled(true);
ui->widget_ipRoutes6->setEnabled(true);
}
}
void IpWidget::changeDhcpClient(const QString currentText)
{
if (currentText == QString("dhcpcd")) {
ui->widget_dhcpcdOpt->setHidden(false);
ui->widget_dhclientOpt->setHidden(true);
}
else if (currentText == QString("dhclient")) {
ui->widget_dhcpcdOpt->setHidden(true);
ui->widget_dhclientOpt->setHidden(false);
}
}
void IpWidget::showAdvanced()
{
if (ui->pushButton_ipAdvanced->isChecked()) {
ui->widget_ipAdvanced->setHidden(false);
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
}
else {
ui->widget_ipAdvanced->setHidden(true);
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Show advanced"));
}
}
QMap<QString, QString> IpWidget::getSettings()
{
QMap<QString, QString> ipSettings;
if (isOk() != 0)
return ipSettings;
if (ui->checkBox_ip->checkState() == Qt::Checked) {
ipSettings[QString("IP")] = ui->comboBox_ip->currentText();
if (ui->comboBox_ip->currentText() == QString("static")) {
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("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(" "));
}
}
else
ipSettings[QString("IP")] = QString("no");
if (ui->checkBox_ip6->checkState() == Qt::Checked) {
ipSettings[QString("IP6")] = ui->comboBox_ip6->currentText();
if ((ui->comboBox_ip6->currentText() == QString("static")) ||
(ui->comboBox_ip6->currentText() == QString("stateless"))) {
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("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(" "));
}
}
else
ipSettings[QString("IP6")] = QString("no");
if (ui->listWidget_custom->count() > 0) {
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(" "));
}
if (!ui->lineEdit_hostname->text().isEmpty())
ipSettings[QString("Hostname")] = QString("'") + ui->lineEdit_hostname->text() + QString("'");
if (ui->spinBox_timeoutDad->value() != 3)
ipSettings[QString("TimeoutDAD")] = QString::number(ui->spinBox_timeoutDad->value());
if (ui->comboBox_dhcp->currentText() == QString("dhcpcd")) {
if (!ui->lineEdit_dhcpcdOpt->text().isEmpty())
ipSettings[QString("DhcpcdOptions")] = QString("'") + ui->lineEdit_dhcpcdOpt->text() + QString("'");
}
else if (ui->comboBox_dhcp->currentText() == QString("dhclient")) {
ipSettings[QString("DHCPClient")] = ui->comboBox_dhcp->currentText();
if (!ui->lineEdit_dhclientOpt->text().isEmpty())
ipSettings[QString("DhclientOptions")] = QString("'") + ui->lineEdit_dhclientOpt->text() + QString("'");
if (!ui->lineEdit_dhclientOpt6->text().isEmpty())
ipSettings[QString("DhclientOptions6")] = QString("'") + ui->lineEdit_dhclientOpt6->text() + QString("'");
}
if (ui->spinBox_timeoutDhcp->value() != 30)
ipSettings[QString("TimeoutDHCP")] = QString::number(ui->spinBox_timeoutDhcp->value());
if (ui->checkBox_dhcp->checkState() == Qt::Checked)
ipSettings[QString("DHCPReleaseOnStop")] = QString("yes");
if (ui->listWidget_dns->count() > 0) {
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(" "));
}
if (!ui->lineEdit_dnsDomain->text().isEmpty())
ipSettings[QString("DNSDomain")] = QString("'") + ui->lineEdit_dnsDomain->text() + QString("'");
if (!ui->lineEdit_dnsSearch->text().isEmpty())
ipSettings[QString("DNSSearch")] = QString("'") + ui->lineEdit_dnsSearch->text() + QString("'");
if (ui->listWidget_dnsOptions->count() > 0) {
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(" "));
}
return ipSettings;
}
int IpWidget::isOk()
{
// ip settings is not set
if (ui->checkBox_ip->checkState() == Qt::Checked)
if (ui->comboBox_ip->currentText() == QString("static"))
if ((ui->listWidget_ipAddress->count() == 0) ||
(ui->lineEdit_gateway->text().isEmpty()))
return 1;
// ipv6 settings is not set
if (ui->checkBox_ip6->checkState() == Qt::Checked)
if ((ui->comboBox_ip6->currentText() == QString("static")) ||
(ui->comboBox_ip6->currentText() == QString("stateless")))
if ((ui->listWidget_ipAddress6->count() == 0) ||
(ui->lineEdit_gateway6->text().isEmpty()))
return 2;
// all fine
return 0;
}
void IpWidget::setSettings(const QMap<QString, QString> settings)
{
QMap<QString, QString> ipSettings = settings;
if (ipSettings.contains(QString("IP"))) {
if (ipSettings[QString("IP")].remove(QString("'")) == 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))
ui->comboBox_ip->setCurrentIndex(i);
}
}
if (ipSettings.contains(QString("Address")))
ui->listWidget_ipAddress->addItems(ipSettings[QString("Address")].remove(QString("'")).split(QString(" ")));
if (ipSettings.contains(QString("Gateway")))
ui->lineEdit_gateway->setText(ipSettings[QString("Gateway")].remove(QString("'")));
if (ipSettings.contains(QString("Routes")))
ui->listWidget_ipRoutes->addItems(ipSettings[QString("Routes")].remove(QString("'")).split(QString(" ")));
if (ipSettings.contains(QString("IP6"))) {
if (ipSettings[QString("IP6")].remove(QString("'")) == 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))
ui->comboBox_ip6->setCurrentIndex(i);
}
}
if (ipSettings.contains(QString("Address6")))
ui->listWidget_ipAddress6->addItems(ipSettings[QString("Address6")].remove(QString("'")).split(QString(" ")));
if (ipSettings.contains(QString("Gateway6")))
ui->lineEdit_gateway6->setText(ipSettings[QString("Gateway6")].remove(QString("'")));
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("'")));
}
if (ipSettings.contains(QString("Hostname")))
ui->lineEdit_hostname->setText(ipSettings[QString("Hostname")].remove(QString("'")));
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))
ui->comboBox_dhcp->setCurrentIndex(i);
if (ipSettings.contains(QString("DhcpcdOptions")))
ui->lineEdit_dhcpcdOpt->setText(ipSettings[QString("DhcpcdOptions")].remove(QString("'")));
if (ipSettings.contains(QString("DhclientOptions")))
ui->lineEdit_dhclientOpt->setText(ipSettings[QString("DhclientOptions")].remove(QString("'")));
if (ipSettings.contains(QString("DhclientOptions6")))
ui->lineEdit_dhclientOpt6->setText(ipSettings[QString("DhclientOptions6")].remove(QString("'")));
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"))
ui->checkBox_dhcp->setCheckState(Qt::Checked);
if (ipSettings.contains(QString("DNS")))
ui->listWidget_dns->addItems(ipSettings[QString("DNS")].remove(QString("'")).split(QString(" ")));
if (ipSettings.contains(QString("DNSDomain")))
ui->lineEdit_dnsDomain->setText(ipSettings[QString("DNSDomain")].remove(QString("'")));
if (ipSettings.contains(QString("DNSSearch")))
ui->lineEdit_dnsSearch->setText(ipSettings[QString("DNSSearch")].remove(QString("'")));
if (ipSettings.contains(QString("DNSOptions")))
ui->listWidget_dnsOptions->addItems(ipSettings[QString("DNSOptions")].remove(QString("'")).split(QString(" ")));
ipEnable(ui->checkBox_ip->checkState());
changeIpMode(ui->comboBox_ip->currentText());
ip6Enable(ui->checkBox_ip6->checkState());
changeIp6Mode(ui->comboBox_ip6->currentText());
changeDhcpClient(ui->comboBox_dhcp->currentText());
}

View File

@ -0,0 +1,74 @@
/***************************************************************************
* 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 IPWIDGET_H
#define IPWIDGET_H
#include <QWidget>
namespace Ui {
class IpWidget;
}
class IpWidget : public QWidget
{
Q_OBJECT
public:
explicit IpWidget(QWidget *parent = 0);
~IpWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private slots:
// buttons
void addIp();
void addIpRoutes();
void addIp6();
void addIpRoutes6();
void addCustom();
void addDns();
void addDnsOpt();
// ip mode
void changeIpMode(const QString currentText);
void ipEnable(const int state);
// ipv6 mode
void changeIp6Mode(const QString currentText);
void ip6Enable(int state);
// dhcp client
void changeDhcpClient(const QString currentText);
void showAdvanced();
private:
Ui::IpWidget *ui;
void createActions();
void createFilter();
void keyPressEvent(QKeyEvent *pressedKey);
QString getIp(const QString rawIp);
QString getPrefix(const QString rawPrefix);
QString getIp6(const QString rawIp);
QString getPrefix6(const QString rawPrefix);
};
#endif /* IPWIDGET_H */

900
sources/gui/src/ipwidget.ui Normal file
View File

@ -0,0 +1,900 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>IpWidget</class>
<widget class="QWidget" name="IpWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>430</width>
<height>1353</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QDockWidget" name="dockWidget_ip">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>IP options</string>
</property>
<widget class="QWidget" name="dockWidgetContents_ip">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="layout_ip">
<item>
<widget class="QCheckBox" name="checkBox_ip">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>IP</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_ip">
<item>
<property name="text">
<string>dhcp</string>
</property>
</item>
<item>
<property name="text">
<string>static</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_ip" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="layout_ipAddress">
<item>
<layout class="QHBoxLayout" name="layout_ipAddressLine">
<item>
<widget class="QLabel" name="label_ipAddress">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Address</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ipAddress"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_ipAddress">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_ipAddress">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of IP addresses suffixed with /&lt;netmask&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_gateway">
<item>
<widget class="QLabel" name="label_gateway">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Gateway</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_gateway">
<property name="toolTip">
<string>An IP routing gateway address</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_ip6">
<item>
<widget class="QCheckBox" name="checkBox_ip6">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>IP6</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_ip6">
<item>
<property name="text">
<string>dhcp</string>
</property>
</item>
<item>
<property name="text">
<string>dhcp-noaddr</string>
</property>
</item>
<item>
<property name="text">
<string>static</string>
</property>
</item>
<item>
<property name="text">
<string>stateless</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_ip6" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="layout_ipAddress6">
<item>
<layout class="QHBoxLayout" name="layout_ipAddress6Line">
<item>
<widget class="QLabel" name="label_ipAddress6">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Address6</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ipAddress6"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_ipAddress6">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_ipAddress6">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of IPv6 addresses</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_gateway6">
<item>
<widget class="QLabel" name="label_gateway6">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Gateway6</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_gateway6">
<property name="toolTip">
<string>An IPv6 routing gateway address</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_ipAdvanced">
<item>
<spacer name="spacer_ipAdvanced">
<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_ipAdvanced">
<property name="text">
<string>Hide advanced</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_ipAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QWidget" name="widget_ipRoutes" native="true">
<layout class="QVBoxLayout" name="layout_ipRoutes">
<item>
<layout class="QHBoxLayout" name="layout_ipRoutesLine">
<item>
<widget class="QLabel" name="label_ipRoutes">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Routes</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ipRoutes"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_ipRoutesLine2">
<item>
<spacer name="spacer_ipRoutes">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>68</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_ipRoutes2">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>via</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ipRoutes2"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_ipRoutes">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_ipRoutes">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of custom routes</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_ipRoutes6" native="true">
<layout class="QVBoxLayout" name="layout_ipRoutes6">
<item>
<layout class="QHBoxLayout" name="layout_ipRoutes6Line">
<item>
<widget class="QLabel" name="label_ipRoutes6">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Routes6</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ipRoutes6"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_ipRoutes62">
<item>
<spacer name="spacer_ipRoutes6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>68</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_ipRoutes62">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>via</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ipRoutes62"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_ipRoutes6">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_ipRoutes6">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of custom routes</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="layout_custom">
<item>
<layout class="QHBoxLayout" name="layout_customLine">
<item>
<widget class="QLabel" name="label_custom">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Custom</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_custom"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_custom">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_custom">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of argument lines to pass to ip</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_hostmane">
<item>
<widget class="QLabel" name="label_hostname">
<property name="text">
<string>Hostname</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_hostname">
<property name="toolTip">
<string>A system hostname</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_timeoutDad">
<item>
<widget class="QLabel" name="label_timeoutDad">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Timeout DAD</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timeoutDad">
<property name="toolTip">
<string>Maximum time, in seconds, to wait for IPv6s Duplicate Address Detection to succeed</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>3</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_dhcp" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layout_dhcp">
<item>
<widget class="QLabel" name="label_dhcp">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>DHCP client</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_dhcp">
<property name="toolTip">
<string>The name of the preferred DHCP client</string>
</property>
<item>
<property name="text">
<string>dhcpcd</string>
</property>
</item>
<item>
<property name="text">
<string>dhclient</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_dhcpcdOpt" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_dhcpcdOpt">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>dhcpcd options</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dhcpcdOpt">
<property name="toolTip">
<string>Additional options to be passed to the DHCP client</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_dhclientOpt" native="true">
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QHBoxLayout" name="layout_dhclientOpt">
<item>
<widget class="QLabel" name="label_dhclientOpt">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>dhclient options</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dhclientOpt">
<property name="toolTip">
<string>Additional options to be passed to the DHCP client</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_dhclientOpt6">
<item>
<widget class="QLabel" name="label_dhclientOpt6">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>dhclient options (6)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dhclientOpt6">
<property name="toolTip">
<string>Additional options to be passed to the DHCP client</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_timeoutDhcp">
<item>
<widget class="QLabel" name="label_timeoutDhcp">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Timeout DHCP</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timeoutDhcp">
<property name="toolTip">
<string>Maximum time, in seconds, to wait for DHCP to be successful</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>30</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_dhcp">
<property name="toolTip">
<string>Set to yes to release the DHCP lease when the profile is stopped</string>
</property>
<property name="text">
<string>DHCP release on stop</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_dns" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QVBoxLayout" name="layout_dns">
<item>
<layout class="QHBoxLayout" name="layout_dnsLine">
<item>
<widget class="QLabel" name="label_dns">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>DNS</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dns"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_dns">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_dns">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of DNS nameservers</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_dnsDomain">
<item>
<widget class="QLabel" name="label_dnsDomain">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>DNS domain</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dnsDomain">
<property name="toolTip">
<string>A domain line for /etc/resolv.conf</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_dnsSearch">
<item>
<widget class="QLabel" name="label_dnsSearch">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>DNS search</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dnsSearch">
<property name="toolTip">
<string>A search line for /etc/resolv.conf</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="layout_dnsOptions">
<item>
<layout class="QHBoxLayout" name="layout_dnsOptionsLine">
<item>
<widget class="QLabel" name="label_dnsOptions">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>DNS options</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_dnsOptions"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_dnsOptions">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_dnsOptions">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>An array of options lines for /etc/resolv.conf</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>checkBox_ip</tabstop>
<tabstop>comboBox_ip</tabstop>
<tabstop>lineEdit_ipAddress</tabstop>
<tabstop>pushButton_ipAddress</tabstop>
<tabstop>listWidget_ipAddress</tabstop>
<tabstop>lineEdit_gateway</tabstop>
<tabstop>checkBox_ip6</tabstop>
<tabstop>comboBox_ip6</tabstop>
<tabstop>lineEdit_ipAddress6</tabstop>
<tabstop>pushButton_ipAddress6</tabstop>
<tabstop>listWidget_ipAddress6</tabstop>
<tabstop>lineEdit_gateway6</tabstop>
<tabstop>pushButton_ipAdvanced</tabstop>
<tabstop>lineEdit_ipRoutes</tabstop>
<tabstop>lineEdit_ipRoutes2</tabstop>
<tabstop>pushButton_ipRoutes</tabstop>
<tabstop>listWidget_ipRoutes</tabstop>
<tabstop>lineEdit_ipRoutes6</tabstop>
<tabstop>lineEdit_ipRoutes62</tabstop>
<tabstop>pushButton_ipRoutes6</tabstop>
<tabstop>listWidget_ipRoutes6</tabstop>
<tabstop>lineEdit_custom</tabstop>
<tabstop>pushButton_custom</tabstop>
<tabstop>listWidget_custom</tabstop>
<tabstop>lineEdit_hostname</tabstop>
<tabstop>spinBox_timeoutDad</tabstop>
<tabstop>comboBox_dhcp</tabstop>
<tabstop>lineEdit_dhcpcdOpt</tabstop>
<tabstop>lineEdit_dhclientOpt</tabstop>
<tabstop>lineEdit_dhclientOpt6</tabstop>
<tabstop>spinBox_timeoutDhcp</tabstop>
<tabstop>checkBox_dhcp</tabstop>
<tabstop>lineEdit_dns</tabstop>
<tabstop>pushButton_dns</tabstop>
<tabstop>listWidget_dns</tabstop>
<tabstop>lineEdit_dnsDomain</tabstop>
<tabstop>lineEdit_dnsSearch</tabstop>
<tabstop>lineEdit_dnsOptions</tabstop>
<tabstop>pushButton_dnsOptions</tabstop>
<tabstop>listWidget_dnsOptions</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

106
sources/gui/src/main.cpp Normal file
View File

@ -0,0 +1,106 @@
/***************************************************************************
* 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 <QApplication>
#include <QDir>
#include <QTextStream>
#include <QTranslator>
#include <iostream>
#include "mainwindow.h"
#include "version.h"
using namespace std;
int main(int argc, char *argv[])
{
QApplication a(argc, 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();
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");
bool defaultSettings = false;
int tabNumber = 0;
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;
}
// 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')) {
defaultSettings = true;
}
// 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'))) {
if (atoi(argv[i+1]) > 3)
tabNumber = 3;
else if (atoi(argv[i+1]) < 1)
tabNumber = 1;
else
tabNumber = atoi(argv[i+1]);
i++;
}
}
MainWindow w(0, defaultSettings, tabNumber);
w.show();
return a.exec();
}

View File

@ -0,0 +1,970 @@
/***************************************************************************
* 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 "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QFileDialog>
#include <QFileInfo>
#include <QProcess>
#include "bridgewidget.h"
#include "errorwindow.h"
#include "ethernetwidget.h"
#include "generalwidget.h"
#include "ipwidget.h"
#include "mobilewidget.h"
#include "netctlinteract.h"
#include "netctlprofile.h"
#include "passwdwidget.h"
#include "pppoewidget.h"
#include "settingswindow.h"
#include "tunnelwidget.h"
#include "tuntapwidget.h"
#include "vlanwidget.h"
#include "wpasupinteract.h"
#include "wirelesswidget.h"
MainWindow::MainWindow(QWidget *parent, const bool defaultSettings, const int tabNum)
: QMainWindow(parent),
ui(new Ui::MainWindow)
{
qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << QString("defaultSettings") << defaultSettings;
qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << QString("tabNum") << tabNum;
ui->setupUi(this);
ui->tabWidget->setCurrentIndex(tabNum-1);
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
QDir::separator() + QString("netctl-gui.conf");
settingsWin = new SettingsWindow(this, configPath);
if (defaultSettings)
settingsWin->setDefault();
configuration = settingsWin->getSettings();
// gui
generalWid = new GeneralWidget(this, configuration);
ui->scrollAreaWidgetContents->layout()->addWidget(generalWid);
ipWid = new IpWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(ipWid);
bridgeWid = new BridgeWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid);
ethernetWid = new EthernetWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid);
mobileWid = new MobileWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
pppoeWid = new PppoeWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);
tunnelWid = new TunnelWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(tunnelWid);
tuntapWid = new TuntapWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(tuntapWid);
vlanWid = new VlanWidget(this);
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
wirelessWid = new WirelessWidget(this, configuration);
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
// backend
netctlCommand = new Netctl(this, configuration);
netctlProfile = new NetctlProfile(this, configuration);
wpaCommand = new WpaSup(this, configuration);
createActions();
updateTabs(ui->tabWidget->currentIndex());
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready"));
}
MainWindow::~MainWindow()
{
delete netctlCommand;
delete netctlProfile;
delete wpaCommand;
delete bridgeWid;
delete ethernetWid;
delete generalWid;
delete ipWid;
delete mobileWid;
delete pppoeWid;
delete tunnelWid;
delete tuntapWid;
delete vlanWid;
delete wirelessWid;
delete settingsWin;
delete ui;
}
bool MainWindow::checkExternalApps(const QString apps = QString("all"))
{
QStringList commandLine;
commandLine.append("which");
commandLine.append(configuration[QString("SUDO_PATH")]);
if ((apps == QString("netctl")) || (apps == QString("all"))) {
commandLine.append(configuration[QString("NETCTL_PATH")]);
}
if ((apps == QString("wpasup")) || (apps == QString("all"))) {
commandLine.append(configuration[QString("WPACLI_PATH")]);
commandLine.append(configuration[QString("WPASUP_PATH")]);
}
QProcess command;
qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Run cmd" << commandLine.join(QString(" "));
command.start(commandLine.join(QString(" ")));
command.waitForFinished(-1);
qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() != 0)
return false;
else
return true;
}
bool MainWindow::checkState(const QString state, const QString item)
{
if (item.contains(state))
return true;
else
return false;
}
// window signals
void MainWindow::createActions()
{
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
connect(ui->actionSettings, SIGNAL(triggered(bool)), settingsWin, SLOT(showWindow()));
connect(ui->actionQuit, SIGNAL(triggered(bool)), this, SLOT(close()));
// main page events
connect(ui->pushButton_mainRefresh, SIGNAL(clicked(bool)), this, SLOT(updateMainTab()));
connect(ui->pushButton_mainEnable, SIGNAL(clicked(bool)), this, SLOT(mainTabEnableProfile()));
connect(ui->pushButton_mainRestart, SIGNAL(clicked(bool)), this, SLOT(mainTabRestartProfile()));
connect(ui->pushButton_mainStart, SIGNAL(clicked(bool)), this, SLOT(mainTabStartProfile()));
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
connect(ui->tableWidget_main, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(mainTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
// profile tab events
connect(ui->lineEdit_profile, SIGNAL(returnPressed()), this, SLOT(profileTabLoadProfile()));
connect(ui->pushButton_profile, SIGNAL(clicked(bool)), this, SLOT(profileTabBrowseProfile()));
connect(ui->pushButton_profileClear, SIGNAL(clicked(bool)), this, SLOT(profileTabClear()));
connect(ui->pushButton_profileSave, SIGNAL(clicked(bool)), this, SLOT(profileTabCreateProfile()));
connect(ui->pushButton_profileLoad, SIGNAL(clicked(bool)), this, SLOT(profileTabLoadProfile()));
connect(generalWid->connectionType, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabChangeState(QString)));
// wifi page events
connect(ui->pushButton_wifiRefresh, SIGNAL(clicked(bool)), this, SLOT(updateWifiTab()));
connect(ui->pushButton_wifiStart, SIGNAL(clicked(bool)), this, SLOT(wifiTabStart()));
connect(ui->tableWidget_wifi, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(wifiTabStart()));
connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(wifiTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
}
// window slots
void MainWindow::updateTabs(const int tab)
{
if (tab == 0)
updateMainTab();
else if (tab == 1)
updateProfileTab();
else if (tab == 2)
updateWifiTab();
}
void MainWindow::updateMainTab()
{
if (!checkExternalApps(QString("netctl"))) {
errorWin = new ErrorWindow(this, 1);
errorWin->show();
return;
}
qDebug() << "[MainWindow]" << "[updateMainTab]";
ui->tabWidget->setDisabled(true);
QList<QStringList> profiles = netctlCommand->getProfileList();;
ui->tableWidget_main->setSortingEnabled(false);
ui->tableWidget_main->selectRow(-1);
ui->tableWidget_main->sortByColumn(0, Qt::AscendingOrder);
ui->tableWidget_main->clear();
ui->tableWidget_main->setRowCount(profiles.count());
// create header
ui->tableWidget_main->setHorizontalHeaderLabels(QApplication::translate("MainWindow", "Name Description Status")
.split(QString(" ")));
// create items
for (int i=0; i<profiles.count(); i++) {
// name
ui->tableWidget_main->setItem(i, 0, new QTableWidgetItem(profiles[i][0]));
ui->tableWidget_main->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
// description
ui->tableWidget_main->setItem(i, 1, new QTableWidgetItem(profiles[i][1]));
ui->tableWidget_main->item(i, 1)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
// status
ui->tableWidget_main->setItem(i, 2, new QTableWidgetItem(profiles[i][2]));
ui->tableWidget_main->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
ui->tableWidget_main->setSortingEnabled(true);
ui->tableWidget_main->resizeRowsToContents();
#if QT_VERSION >= 0x050000
ui->tableWidget_main->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
#else
ui->tableWidget_main->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
#endif
ui->tabWidget->setEnabled(true);
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated"));
update();
}
void MainWindow::updateProfileTab()
{
qDebug() << "[MainWindow]" << "[updateProfileTab]";
ui->tabWidget->setDisabled(true);
profileTabClear();
ui->tabWidget->setEnabled(true);
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated"));
update();
}
void MainWindow::updateWifiTab()
{
wifiTabSetEnabled(checkExternalApps(QString("wpasup")));
if (!checkExternalApps(QString("wpasup"))) {
errorWin = new ErrorWindow(this, 1);
errorWin->show();
return;
}
QList<QStringList> scanResults = wpaCommand->scanWifi();
qDebug() << "[MainWindow]" << "[updateWifiTab]";
ui->tabWidget->setDisabled(true);
ui->tableWidget_wifi->setSortingEnabled(false);
ui->tableWidget_wifi->selectRow(-1);
ui->tableWidget_wifi->sortByColumn(0, Qt::AscendingOrder);
ui->tableWidget_wifi->clear();
ui->tableWidget_wifi->setRowCount(scanResults.count());
// create header
ui->tableWidget_wifi->setHorizontalHeaderLabels(QApplication::translate("MainWindow", "Name Status Signal Security")
.split(QString(" ")));
// create items
for (int i=0; i<scanResults.count(); i++) {
// name
ui->tableWidget_wifi->setItem(i, 0, new QTableWidgetItem(scanResults[i][0]));
ui->tableWidget_wifi->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
// status
ui->tableWidget_wifi->setItem(i, 1, new QTableWidgetItem(scanResults[i][1]));
ui->tableWidget_wifi->item(i, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
// signal
ui->tableWidget_wifi->setItem(i, 2, new QTableWidgetItem(scanResults[i][2]));
ui->tableWidget_wifi->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
// security
ui->tableWidget_wifi->setItem(i, 3, new QTableWidgetItem(scanResults[i][3]));
ui->tableWidget_wifi->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
ui->tableWidget_wifi->setSortingEnabled(true);
ui->tableWidget_wifi->resizeRowsToContents();
#if QT_VERSION >= 0x050000
ui->tableWidget_wifi->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
#else
ui->tableWidget_wifi->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
#endif
ui->tabWidget->setEnabled(true);
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated"));
update();
}
// main tab slots
void MainWindow::mainTabEnableProfile()
{
if (!checkExternalApps(QString("netctl"))) {
errorWin = new ErrorWindow(this, 1);
errorWin->show();
return;
}
if (ui->tableWidget_main->currentItem() == 0)
return;
qDebug() << "[MainWindow]" << "[mainTabEnableProfile]";
ui->tabWidget->setDisabled(true);
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
netctlCommand->enableProfile(profile);
QString item = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text();
if (checkState(QString("enabled"), item)) {
if (netctlCommand->isProfileEnabled(profile))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
}
else {
if (netctlCommand->isProfileEnabled(profile))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
}
updateMainTab();
}
void MainWindow::mainTabRestartProfile()
{
if (!checkExternalApps(QString("netctl"))) {
errorWin = new ErrorWindow(this, 1);
errorWin->show();
return;
}
if (ui->tableWidget_main->currentItem() == 0)
return;
qDebug() << "[MainWindow]" << "[mainTabRestartProfile]";
ui->tabWidget->setDisabled(true);
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
netctlCommand->restartProfile(profile);
if (netctlCommand->isProfileActive(profile))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
updateMainTab();
}
void MainWindow::mainTabStartProfile()
{
if (!checkExternalApps(QString("netctl"))) {
errorWin = new ErrorWindow(this, 1);
errorWin->show();
return;
}
if (ui->tableWidget_main->currentItem() == 0)
return;
qDebug() << "[MainWindow]" << "[mainTabStartProfile]";
ui->tabWidget->setDisabled(true);
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
netctlCommand->startProfile(profile);
QString item = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text();
if (checkState(QString("inactive"), item)) {
if (netctlCommand->isProfileActive(profile))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
}
else {
if (netctlCommand->isProfileActive(profile))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
}
updateMainTab();
}
void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
{
Q_UNUSED(previous);
if (!checkExternalApps(QString("netctl"))) {
errorWin = new ErrorWindow(this, 1);
errorWin->show();
return;
}
if (current == 0) {
ui->pushButton_mainEnable->setDisabled(true);
ui->pushButton_mainRestart->setDisabled(true);
ui->pushButton_mainStart->setDisabled(true);
return;
}
qDebug() << "[MainWindow]" << "[mainTabRefreshButtons]";
ui->pushButton_mainEnable->setEnabled(true);
ui->pushButton_mainStart->setEnabled(true);
QString item = ui->tableWidget_main->item(current->row(), 2)->text();
if (!checkState(QString("inactive"), item)) {
ui->pushButton_mainRestart->setEnabled(true);
ui->pushButton_mainStart->setText(QApplication::translate("MainWindow", "Stop"));
}
else {
ui->pushButton_mainRestart->setDisabled(true);
ui->pushButton_mainStart->setText(QApplication::translate("MainWindow", "Start"));
}
if (checkState(QString("enabled"), item))
ui->pushButton_mainEnable->setText(QApplication::translate("MainWindow", "Disable"));
else
ui->pushButton_mainEnable->setText(QApplication::translate("MainWindow", "Enable"));
}
// profile tab slots
void MainWindow::profileTabBrowseProfile()
{
qDebug() << "[MainWindow]" << "[profileTabBrowseProfile]";
QString filename = QFileDialog::getSaveFileName(
this,
QApplication::translate("MainWindow", "Save profile as..."),
QString("/etc/netctl/"),
QApplication::translate("MainWindow", "Profile (*)"));
if (!filename.isEmpty())
ui->lineEdit_profile->setText(filename);
}
void MainWindow::profileTabChangeState(const QString current)
{
qDebug() << "[MainWindow]" << "[profileTabChangeState]";
if (current == QString("ethernet")) {
generalWid->setShown(true);
ipWid->setShown(true);
bridgeWid->setShown(false);
ethernetWid->setShown(true);
mobileWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
vlanWid->setShown(false);
wirelessWid->setShown(false);
}
else if (current == QString("wireless")) {
generalWid->setShown(true);
ipWid->setShown(true);
bridgeWid->setShown(false);
ethernetWid->setShown(false);
mobileWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
vlanWid->setShown(false);
wirelessWid->setShown(true);
}
else if ((current == QString("bond")) ||
(current == QString("dummy"))) {
generalWid->setShown(true);
ipWid->setShown(true);
bridgeWid->setShown(false);
ethernetWid->setShown(false);
mobileWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
vlanWid->setShown(false);
wirelessWid->setShown(false);
}
else if (current == QString("bridge")) {
generalWid->setShown(true);
ipWid->setShown(true);
bridgeWid->setShown(true);
ethernetWid->setShown(false);
mobileWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
vlanWid->setShown(false);
wirelessWid->setShown(false);
}
else if (current == QString("pppoe")) {
generalWid->setShown(true);
ipWid->setShown(false);
bridgeWid->setShown(false);
ethernetWid->setShown(false);
mobileWid->setShown(false);
pppoeWid->setShown(true);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
vlanWid->setShown(false);
wirelessWid->setShown(false);
}
else if (current == QString("mobile_ppp")) {
generalWid->setShown(true);
ipWid->setShown(false);
bridgeWid->setShown(false);
ethernetWid->setShown(false);
mobileWid->setShown(true);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
vlanWid->setShown(false);
wirelessWid->setShown(false);
}
else if (current == QString("tunnel")) {
generalWid->setShown(true);
ipWid->setShown(true);
bridgeWid->setShown(false);
ethernetWid->setShown(false);
mobileWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(true);
tuntapWid->setShown(false);
vlanWid->setShown(false);
wirelessWid->setShown(false);
}
else if (current == QString("tuntap")) {
generalWid->setShown(true);
ipWid->setShown(true);
bridgeWid->setShown(false);
ethernetWid->setShown(false);
mobileWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(true);
vlanWid->setShown(false);
wirelessWid->setShown(false);
}
else if (current == QString("vlan")) {
generalWid->setShown(true);
ipWid->setShown(true);
bridgeWid->setShown(false);
ethernetWid->setShown(true);
mobileWid->setShown(false);
pppoeWid->setShown(false);
tunnelWid->setShown(false);
tuntapWid->setShown(false);
vlanWid->setShown(true);
wirelessWid->setShown(false);
}
}
void MainWindow::profileTabClear()
{
qDebug() << "[MainWindow]" << "[profileTabClear]";
ui->lineEdit_profile->clear();
generalWid->clear();
ipWid->clear();
bridgeWid->clear();
ethernetWid->clear();
mobileWid->clear();
pppoeWid->clear();
tunnelWid->clear();
tuntapWid->clear();
vlanWid->clear();
wirelessWid->clear();
profileTabChangeState(generalWid->connectionType->currentText());
}
void MainWindow::profileTabCreateProfile()
{
// error checking
if (ui->lineEdit_profile->text().isEmpty()) {
errorWin = new ErrorWindow(this, 3);
errorWin->show();
return;
}
if (generalWid->isOk() == 1) {
errorWin = new ErrorWindow(this, 4);
errorWin->show();
return;
}
else if (generalWid->isOk() == 2) {
errorWin = new ErrorWindow(this, 5);
errorWin->show();
return;
}
if ((generalWid->connectionType->currentText() == QString("ethernet")) ||
(generalWid->connectionType->currentText() == QString("wireless")) ||
(generalWid->connectionType->currentText() == QString("bond")) ||
(generalWid->connectionType->currentText() == QString("dummy")) ||
(generalWid->connectionType->currentText() == QString("bridge")) ||
(generalWid->connectionType->currentText() == QString("tunnel")) ||
(generalWid->connectionType->currentText() == QString("tuntap")) ||
(generalWid->connectionType->currentText() == QString("vlan"))) {
if (ipWid->isOk() == 1) {
errorWin = new ErrorWindow(this, 6);
errorWin->show();
return;
}
else if (ipWid->isOk() == 2) {
errorWin = new ErrorWindow(this, 6);
errorWin->show();
return;
}
}
if (generalWid->connectionType->currentText() == QString("ethernet")) {
if (ethernetWid->isOk() == 1) {
errorWin = new ErrorWindow(this, 7);
errorWin->show();
return;
}
}
else if (generalWid->connectionType->currentText() == QString("wireless")) {
if (wirelessWid->isOk() == 1) {
errorWin = new ErrorWindow(this, 8);
errorWin->show();
return;
}
else if (wirelessWid->isOk() == 2) {
errorWin = new ErrorWindow(this, 9);
errorWin->show();
return;
}
else if (wirelessWid->isOk() == 3) {
errorWin = new ErrorWindow(this, 10);
errorWin->show();
return;
}
else if (wirelessWid->isOk() == 4) {
errorWin = new ErrorWindow(this, 7);
errorWin->show();
return;
}
else if (wirelessWid->isOk() == 5) {
errorWin = new ErrorWindow(this, 11);
errorWin->show();
return;
}
}
else if (generalWid->connectionType->currentText() == QString("bridge")) {
}
else if (generalWid->connectionType->currentText() == QString("pppoe")) {
if (pppoeWid->isOk() == 1) {
errorWin = new ErrorWindow(this, 7);
errorWin->show();
return;
}
else if (pppoeWid->isOk() == 2) {
errorWin = new ErrorWindow(this, 12);
errorWin->show();
return;
}
else if (pppoeWid->isOk() == 3) {
errorWin = new ErrorWindow(this, 13);
errorWin->show();
return;
}
else if (pppoeWid->isOk() == 4) {
errorWin = new ErrorWindow(this, 12);
errorWin->show();
return;
}
}
else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
if (mobileWid->isOk() == 1) {
errorWin = new ErrorWindow(this, 14);
errorWin->show();
return;
}
if (mobileWid->isOk() == 2) {
errorWin = new ErrorWindow(this, 7);
errorWin->show();
return;
}
}
else if (generalWid->connectionType->currentText() == QString("tunnel")) {
}
else if (generalWid->connectionType->currentText() == QString("tuntap")) {
if (tuntapWid->isOk() == 1) {
errorWin = new ErrorWindow(this, 15);
errorWin->show();
return;
}
if (tuntapWid->isOk() == 2) {
errorWin = new ErrorWindow(this, 15);
errorWin->show();
return;
}
}
else if (generalWid->connectionType->currentText() == QString("vlan")) {
if (ethernetWid->isOk() == 1) {
errorWin = new ErrorWindow(this, 7);
errorWin->show();
return;
}
}
qDebug() << "[MainWindow]" << "[profileTabCreateProfile]";
ui->tabWidget->setDisabled(true);
// read settings
QString profile = ui->lineEdit_profile->text();
QMap<QString, QString> settings;
settings = generalWid->getSettings();
if (generalWid->connectionType->currentText() == QString("ethernet")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = ethernetWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
}
else if (generalWid->connectionType->currentText() == QString("wireless")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = wirelessWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
}
else if ((generalWid->connectionType->currentText() == QString("bond")) ||
(generalWid->connectionType->currentText() == QString("dummy"))) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
}
else if (generalWid->connectionType->currentText() == QString("bridge")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = bridgeWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
}
else if (generalWid->connectionType->currentText() == QString("pppoe")) {
QMap<QString, QString> addSettings = pppoeWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
}
else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
QMap<QString, QString> addSettings = mobileWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
}
else if (generalWid->connectionType->currentText() == QString("tunnel")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = tunnelWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
}
else if (generalWid->connectionType->currentText() == QString("tuntap")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = tuntapWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
}
else if (generalWid->connectionType->currentText() == QString("vlan")) {
QMap<QString, QString> addSettings = ipWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = ethernetWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
addSettings = vlanWid->getSettings();
for (int i=0; i<addSettings.keys().count(); i++)
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
}
// call netctlprofile
QString profileTempName = netctlProfile->createProfile(profile, settings);
if (netctlProfile->copyProfile(profileTempName))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
updateProfileTab();
}
void MainWindow::profileTabLoadProfile()
{
qDebug() << "[MainWindow]" << "[profileTabLoadProfile]";
QString profile = ui->lineEdit_profile->text();
QMap<QString, QString> settings = netctlProfile->getSettingsFromProfile(profile);
generalWid->setSettings(settings);
if (generalWid->connectionType->currentText() == QString("ethernet")) {
ipWid->setSettings(settings);
ethernetWid->setSettings(settings);
}
else if (generalWid->connectionType->currentText() == QString("wireless")) {
ipWid->setSettings(settings);
wirelessWid->setSettings(settings);
}
else if ((generalWid->connectionType->currentText() == QString("bond")) ||
(generalWid->connectionType->currentText() == QString("dummy"))) {
ipWid->setSettings(settings);
}
else if (generalWid->connectionType->currentText() == QString("bridge")) {
ipWid->setSettings(settings);
bridgeWid->setSettings(settings);
}
else if (generalWid->connectionType->currentText() == QString("pppoe")) {
pppoeWid->setSettings(settings);
}
else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
mobileWid->setSettings(settings);
}
else if (generalWid->connectionType->currentText() == QString("tunnel")) {
ipWid->setSettings(settings);
tunnelWid->setSettings(settings);
}
else if (generalWid->connectionType->currentText() == QString("tuntap")) {
ipWid->setSettings(settings);
tuntapWid->setSettings(settings);
}
else if (generalWid->connectionType->currentText() == QString("vlan")) {
ipWid->setSettings(settings);
ethernetWid->setSettings(settings);
vlanWid->setSettings(settings);
}
}
// wifi tab slots
void MainWindow::wifiTabSetEnabled(const bool state)
{
if (state) {
ui->tableWidget_wifi->show();
ui->pushButton_wifiRefresh->setEnabled(true);
ui->label_wifi->hide();
}
else {
ui->tableWidget_wifi->hide();
ui->pushButton_wifiRefresh->setDisabled(true);
ui->pushButton_wifiStart->setDisabled(true);
ui->label_wifi->show();
}
}
void MainWindow::connectToUnknownEssid(const QString passwd)
{
if (!passwd.isEmpty())
delete passwdWid;
qDebug() << "[MainWindow]" << "[connectToUnknownEssid]";
QMap<QString, QString> settings;
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
settings[QString("Interface")] = wpaCommand->getInterfaceList()[0];
settings[QString("Connection")] = QString("wireless");
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text();
if (checkState(QString("WPA"), security))
settings[QString("Security")] = QString("wpa");
else if (checkState(QString("wep"), security))
settings[QString("Security")] = QString("wep");
else
settings[QString("Security")] = QString("none");
settings[QString("ESSID")] = QString("'") +
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() +
QString("'");
if (!passwd.isEmpty())
settings[QString("Key")] = QString("'") + passwd + QString("'");
settings[QString("IP")] = QString("dhcp");
QString profile = QString("netctl-gui-") + settings[QString("ESSID")];
profile.remove(QString("'"));
QString profileTempName = netctlProfile->createProfile(profile, settings);
if (netctlProfile->copyProfile(profileTempName))
netctlCommand->startProfile(profile);
if (netctlCommand->isProfileActive(profile))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
updateWifiTab();
}
void MainWindow::wifiTabStart()
{
if (!checkExternalApps(QString("wpasup"))) {
errorWin = new ErrorWindow(this, 1);
errorWin->show();
return;
}
if (ui->tableWidget_wifi->currentItem() == 0)
return;
if (ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() == QString("<hidden>")) {
ui->pushButton_wifiStart->setDisabled(true);
errorWin = new ErrorWindow(this, 2);
errorWin->show();
return;
}
qDebug() << "[MainWindow]" << "[wifiTabStart]";
ui->tabWidget->setDisabled(true);
QString profile = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text();
QString item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text();
if (checkState(QString("exists"), item)) {
QString profileName = wpaCommand->existentProfile(profile);
netctlCommand->startProfile(profileName);
item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text();
if (checkState(QString("inactive"), item)) {
if (netctlCommand->isProfileActive(profileName))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
}
else {
if (netctlCommand->isProfileActive(profileName))
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
}
}
else {
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text();
if (checkState(QString("none"), security))
return connectToUnknownEssid(QString(""));
else {
passwdWid = new PasswdWidget(this);
int widgetWidth = 270;
int widgetHeight = 86;
int x = (width() - widgetWidth) / 2;
int y = (height() - widgetHeight) / 2;
passwdWid->setGeometry(x, y, widgetWidth, widgetHeight);
passwdWid->show();
passwdWid->setFocusToLineEdit();
return;
}
}
updateWifiTab();
}
void MainWindow::wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
{
Q_UNUSED(previous);
if (!checkExternalApps(QString("wpasup"))) {
errorWin = new ErrorWindow(this, 1);
errorWin->show();
return;
}
if (current == 0) {
ui->pushButton_wifiStart->setDisabled(true);
return;
}
if (ui->tableWidget_wifi->item(current->row(), 0)->text() == QString("<hidden>")) {
ui->pushButton_wifiStart->setDisabled(true);
return;
}
qDebug() << "[MainWindow]" << "[wifiTabRefreshButtons]";
ui->pushButton_wifiStart->setEnabled(true);
QString item = ui->tableWidget_wifi->item(current->row(), 1)->text();
if (checkState(QString("exists"), item)) {
if (!checkState(QString("inactive"), item))
ui->pushButton_wifiStart->setText(QApplication::translate("MainWindow", "Stop"));
else
ui->pushButton_wifiStart->setText(QApplication::translate("MainWindow", "Start"));
}
else
ui->pushButton_wifiStart->setText(QApplication::translate("MainWindow", "Start"));
}

View File

@ -0,0 +1,110 @@
/***************************************************************************
* 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 MAINWINDOW_H
#define MAINWINDOW_H
#include <QApplication>
#include <QMainWindow>
#include <QTableWidgetItem>
class BridgeWidget;
class ErrorWindow;
class EthernetWidget;
class GeneralWidget;
class IpWidget;
class MobileWidget;
class Netctl;
class NetctlProfile;
class PasswdWidget;
class PppoeWidget;
class SettingsWindow;
class TunnelWidget;
class TuntapWidget;
class VlanWidget;
class WirelessWidget;
class WpaSup;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0,
const bool defaultSettings = false,
const int tabNum = 1);
~MainWindow();
Netctl *netctlCommand;
NetctlProfile *netctlProfile;
WpaSup *wpaCommand;
public slots:
void updateTabs(const int tab);
// wifi tab slots
void connectToUnknownEssid(const QString passwd);
private slots:
void updateMainTab();
void updateProfileTab();
void updateWifiTab();
// main tab slots
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();
// wifi tab slots
void wifiTabSetEnabled(const bool state);
void wifiTabStart();
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
private:
// ui
Ui::MainWindow *ui;
BridgeWidget *bridgeWid;
EthernetWidget *ethernetWid;
GeneralWidget *generalWid;
IpWidget *ipWid;
MobileWidget *mobileWid;
PppoeWidget *pppoeWid;
TunnelWidget *tunnelWid;
TuntapWidget *tuntapWid;
VlanWidget *vlanWid;
WirelessWidget *wirelessWid;
// backend
ErrorWindow *errorWin;
PasswdWidget *passwdWid;
SettingsWindow *settingsWin;
bool checkExternalApps(const QString apps);
bool checkState(const QString state, const QString item);
void createActions();
// configuration
QMap<QString, QString> configuration;
};
#endif /* MAINWINDOW_H */

View File

@ -0,0 +1,408 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>491</width>
<height>519</height>
</rect>
</property>
<property name="windowTitle">
<string>Netctl GUI</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_main">
<attribute name="title">
<string>Connect to profile</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTableWidget" name="tableWidget_main">
<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>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Description</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
<column>
<property name="text">
<string>Status</string>
</property>
<property name="textAlignment">
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_mainButtons">
<item>
<widget class="QPushButton" name="pushButton_mainRefresh">
<property name="text">
<string>Refresh</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="spacer_mainButtons">
<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_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">
<bool>false</bool>
</property>
<property name="text">
<string>Restart</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_mainStart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_new">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title">
<string>Create a new profile</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QHBoxLayout" name="layout_profile">
<item>
<widget class="QLabel" name="label_profile">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Profile</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_profile"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_profile">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>98</width>
<height>28</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="scrollArea_layout"/>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_newProfileButtons">
<item>
<widget class="QPushButton" name="pushButton_profileClear">
<property name="text">
<string>Clear</string>
</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">
<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_profileSave">
<property name="text">
<string>Save</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_wifi">
<attribute name="title">
<string>Connect to Wi-Fi</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_wifi">
<property name="text">
<string>Please install 'wpa_supplicant' before using it</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget_wifi">
<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>Status</string>
</property>
</column>
<column>
<property name="text">
<string>Signal</string>
</property>
</column>
<column>
<property name="text">
<string>Security</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_wifiButtons">
<item>
<widget class="QPushButton" name="pushButton_wifiRefresh">
<property name="text">
<string>Refresh</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="spacer_wifiButtons">
<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_wifiStart">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Start</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>491</width>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuMenu">
<property name="title">
<string>Menu</string>
</property>
<addaction name="actionSettings"/>
<addaction name="actionQuit"/>
</widget>
<addaction name="menuMenu"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionSettings">
<property name="text">
<string>Settings</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action>
<action name="actionQuit">
<property name="text">
<string>Quit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</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>
<tabstop>pushButton_wifiStart</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,170 @@
/***************************************************************************
* 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 "mobilewidget.h"
#include "ui_mobilewidget.h"
#include <QDir>
#include <QFileDialog>
#include <QFile>
MobileWidget::MobileWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::MobileWidget)
{
ui->setupUi(this);
createActions();
clear();
}
MobileWidget::~MobileWidget()
{
delete ui;
}
void MobileWidget::clear()
{
ui->lineEdit_username->clear();
ui->lineEdit_password->clear();
ui->lineEdit_apn->clear();
ui->lineEdit_pin->clear();
ui->comboBox_mode->setCurrentIndex(0);
ui->spinBox_fail->setValue(5);
ui->checkBox_route->setCheckState(Qt::Checked);
ui->checkBox_dns->setCheckState(Qt::Checked);
ui->lineEdit_options->clear();
ui->pushButton_mobileAdvanced->setChecked(false);;
showAdvanced();
}
void MobileWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void MobileWidget::createActions()
{
connect(ui->pushButton_mobileAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->pushButton_options, SIGNAL(clicked(bool)), this, SLOT(selectOptionsFile()));
}
void MobileWidget::selectOptionsFile()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("MobileWidget", "Select options file"),
QDir::currentPath(),
QApplication::translate("MobileWidget", "Configuration files (*.conf)"));
if (!filename.isEmpty())
ui->lineEdit_options->setText(filename);
}
void MobileWidget::showAdvanced()
{
if (ui->pushButton_mobileAdvanced->isChecked()) {
ui->widget_mobileAdvanced->setHidden(false);
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
}
else {
ui->widget_mobileAdvanced->setHidden(true);
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Show advanced"));
}
}
QMap<QString, QString> MobileWidget::getSettings()
{
QMap<QString, QString> mobileSettings;
if (isOk() != 0)
return mobileSettings;
if (!ui->lineEdit_username->text().isEmpty())
mobileSettings[QString("User")] = QString("'") + ui->lineEdit_username->text() + QString("'");
if (!ui->lineEdit_password->text().isEmpty())
mobileSettings[QString("Password")] = QString("'") + ui->lineEdit_password->text() + QString("'");
mobileSettings[QString("AccessPointName")] = ui->lineEdit_apn->text();
if (!ui->lineEdit_pin->text().isEmpty())
mobileSettings[QString("PIN")] = QString("'") + ui->lineEdit_pin->text() + QString("'");
else
mobileSettings[QString("PIN")] = QString("None");
mobileSettings[QString("Mode")] = ui->comboBox_mode->currentText();
if (ui->spinBox_fail->value() != 5)
mobileSettings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
if (ui->checkBox_route->checkState() == Qt::Unchecked)
mobileSettings[QString("DefaultRoute")] = QString("false");
if (ui->checkBox_dns->checkState() == Qt::Unchecked)
mobileSettings[QString("UsePeerDNS")] = QString("false");
if (!ui->lineEdit_options->text().isEmpty())
mobileSettings[QString("OptionsFile")] = QString("'") + ui->lineEdit_options->text() + QString("'");
return mobileSettings;
}
int MobileWidget::isOk()
{
// APN is not set
if (ui->lineEdit_apn->text().isEmpty())
return 1;
// config file doesn't exist
if (!ui->lineEdit_options->text().isEmpty())
if (!QFile(ui->lineEdit_options->text()).exists())
return 2;
// all fine
return 0;
}
void MobileWidget::setSettings(const QMap<QString, QString> settings)
{
QMap<QString, QString> mobileSettings = settings;
if (mobileSettings.contains(QString("User")))
ui->lineEdit_username->setText(mobileSettings[QString("User")].remove(QString("'")));
if (mobileSettings.contains(QString("Password")))
ui->lineEdit_password->setText(mobileSettings[QString("Password")].remove(QString("'")));
if (mobileSettings.contains(QString("AccessPointName")))
ui->lineEdit_apn->setText(mobileSettings[QString("AccessPointName")].remove(QString("'")));
if (mobileSettings.contains(QString("PIN")))
ui->lineEdit_pin->setText(mobileSettings[QString("PIN")].remove(QString("'")));
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))
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"))
ui->checkBox_route->setCheckState(Qt::Unchecked);
if (mobileSettings.contains(QString("UsePeerDNS")))
if (mobileSettings[QString("UsePeerDNS")].remove(QString("'")) == QString("false"))
ui->checkBox_dns->setCheckState(Qt::Unchecked);
if (mobileSettings.contains(QString("OptionsFile")))
ui->lineEdit_options->setText(mobileSettings[QString("OptionsFile")].remove(QString("'")));
}

View File

@ -0,0 +1,53 @@
/***************************************************************************
* 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 MOBILEWIDGET_H
#define MOBILEWIDGET_H
#include <QWidget>
namespace Ui {
class MobileWidget;
}
class MobileWidget : public QWidget
{
Q_OBJECT
public:
explicit MobileWidget(QWidget *parent = 0);
~MobileWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private slots:
void selectOptionsFile();
void showAdvanced();
private:
Ui::MobileWidget *ui;
void createActions();
};
#endif /* MOBILEWIDGET_H */

View File

@ -0,0 +1,313 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MobileWidget</class>
<widget class="QWidget" name="MobileWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>445</width>
<height>370</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_mobile">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Mobile PPP settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_mobile">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="layout_username">
<item>
<widget class="QLabel" name="label_username">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Username</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_username">
<property name="toolTip">
<string>The username and password to connect with</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_password">
<item>
<widget class="QLabel" name="label_password">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_password">
<property name="toolTip">
<string>The username and password to connect with</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_apn">
<item>
<widget class="QLabel" name="label_apn">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Access point name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_apn">
<property name="toolTip">
<string>The access point (apn) to connect on</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_pin">
<item>
<widget class="QLabel" name="label_pin">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>PIN</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_pin">
<property name="toolTip">
<string>If your modem requires a PIN to unlock, use this option</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_mode">
<item>
<widget class="QLabel" name="label_mode">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_mode">
<property name="toolTip">
<string>This option is used to specify the connection mode</string>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>3Gpref</string>
</property>
</item>
<item>
<property name="text">
<string>3Gonly</string>
</property>
</item>
<item>
<property name="text">
<string>GPRSpref</string>
</property>
</item>
<item>
<property name="text">
<string>GPRSonly</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_mobileAdvanced">
<item>
<spacer name="spacer_mobileAdvanced">
<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_mobileAdvanced">
<property name="text">
<string>Show advanced</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_mobileAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_fail">
<item>
<widget class="QLabel" name="label_fail">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Max fail</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fail">
<property name="toolTip">
<string>The number of consecutive failed connection attempts to tolerate</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_route">
<property name="toolTip">
<string>Use the default route provided by the peer</string>
</property>
<property name="text">
<string>Default route</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_dns">
<property name="toolTip">
<string>Use the DNS provided by the peer</string>
</property>
<property name="text">
<string>Use peer DNS</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_options">
<item>
<widget class="QLabel" name="label_options">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Options file</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_options">
<property name="toolTip">
<string>A file to read additional pppd options from</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_options">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>lineEdit_username</tabstop>
<tabstop>lineEdit_password</tabstop>
<tabstop>lineEdit_apn</tabstop>
<tabstop>lineEdit_pin</tabstop>
<tabstop>comboBox_mode</tabstop>
<tabstop>pushButton_mobileAdvanced</tabstop>
<tabstop>spinBox_fail</tabstop>
<tabstop>checkBox_route</tabstop>
<tabstop>checkBox_dns</tabstop>
<tabstop>lineEdit_options</tabstop>
<tabstop>pushButton_options</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,219 @@
/***************************************************************************
* 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 "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)
{
return netctlCall(false, QString("is-enabled"), profile);
}
// 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

@ -0,0 +1,61 @@
/***************************************************************************
* 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 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

@ -0,0 +1,156 @@
/***************************************************************************
* 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 "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

@ -0,0 +1,47 @@
/***************************************************************************
* 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 NETCTLPROFILE_H
#define NETCTLPROFILE_H
#include <QDir>
#include <QMap>
#include <QObject>
class MainWindow;
class NetctlProfile : public QObject
{
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);
private:
MainWindow *parent;
QDir *profileDirectory;
QString sudoCommand;
};
#endif /* NETCTLPROFILE_H */

View File

@ -0,0 +1,74 @@
/***************************************************************************
* 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 "passwdwidget.h"
#include "ui_passwdwidget.h"
#include "mainwindow.h"
PasswdWidget::PasswdWidget(MainWindow *wid)
: QWidget(wid),
parent(wid),
ui(new Ui::PasswdWidget)
{
ui->setupUi(this);
createActions();
}
PasswdWidget::~PasswdWidget()
{
delete ui;
}
// ESC press event
void PasswdWidget::keyPressEvent(QKeyEvent *pressedKey)
{
if (pressedKey->key() == Qt::Key_Escape)
cancel();
}
void PasswdWidget::createActions()
{
connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(passwdApply()));
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(cancel()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(passwdApply()));
}
void PasswdWidget::setFocusToLineEdit()
{
ui->lineEdit->setFocus(Qt::ActiveWindowFocusReason);
}
void PasswdWidget::cancel()
{
hide();
parent->updateTabs(2);
this->~PasswdWidget();
}
void PasswdWidget::passwdApply()
{
hide();
return parent->connectToUnknownEssid(ui->lineEdit->text());
}

View File

@ -0,0 +1,56 @@
/***************************************************************************
* 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 PASSWDWIDGET_H
#define PASSWDWIDGET_H
#include <QKeyEvent>
#include <QPushButton>
#include <QWidget>
class MainWindow;
namespace Ui {
class PasswdWidget;
}
class PasswdWidget : public QWidget
{
Q_OBJECT
public:
explicit PasswdWidget(MainWindow *wid = 0);
~PasswdWidget();
public slots:
void setFocusToLineEdit();
private slots:
void cancel();
void passwdApply();
private:
MainWindow *parent;
Ui::PasswdWidget *ui;
// ESC pressed event
void keyPressEvent(QKeyEvent *pressedKey);
void createActions();
};
#endif /* PASSWDWIDGET_H */

View File

@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PasswdWidget</class>
<widget class="QWidget" name="PasswdWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>264</width>
<height>86</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<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>0</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="layout_passwd">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit">
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</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>0</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="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</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>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,240 @@
/***************************************************************************
* 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 "pppoewidget.h"
#include "ui_pppoewidget.h"
#include <QDir>
#include <QFileDialog>
#include <QFile>
PppoeWidget::PppoeWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::PppoeWidget)
{
ui->setupUi(this);
createActions();
createFilter();
clear();
}
PppoeWidget::~PppoeWidget()
{
delete ui;
}
void PppoeWidget::clear()
{
ui->lineEdit_username->clear();
ui->lineEdit_password->clear();
ui->comboBox_connection->setCurrentIndex(0);
changeMode(ui->comboBox_connection->currentText());
ui->spinBox_timeout->setValue(300);
ui->spinBox_fail->setValue(5);
ui->checkBox_route->setCheckState(Qt::Checked);
ui->checkBox_dns->setCheckState(Qt::Checked);
ui->lineEdit_unit->clear();
ui->spinBox_lcpInterval->setValue(30);
ui->spinBox_lcpFailure->setValue(4);
ui->lineEdit_options->clear();
ui->lineEdit_service->clear();
ui->lineEdit_ac->clear();
ui->lineEdit_session->clear();
ui->lineEdit_mac->clear();
ui->checkBox_ipv6->setCheckState(Qt::Unchecked);
ui->pushButton_pppoeAdvanced->setChecked(false);;
showAdvanced();
}
void PppoeWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void PppoeWidget::createFilter()
{
// session mac
ui->lineEdit_session->setInputMask(QString(">99999:HH:HH:HH:HH:HH:HH"));
// mac
ui->lineEdit_mac->setInputMask(QString(">HH:HH:HH:HH:HH:HH"));
}
void PppoeWidget::createActions()
{
connect(ui->pushButton_pppoeAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->comboBox_connection, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeMode(QString)));
connect(ui->pushButton_options, SIGNAL(clicked(bool)), this, SLOT(selectOptionsFile()));
}
void PppoeWidget::changeMode(const QString currentText)
{
if (currentText == QString("persist"))
ui->widget_timeout->setHidden(true);
else if (currentText == QString("demand"))
ui->widget_timeout->setHidden(false);
}
void PppoeWidget::selectOptionsFile()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("PppoeWidget", "Select options file"),
QDir::currentPath(),
QApplication::translate("PppoeWidget", "Configuration files (*.conf)"));
if (!filename.isEmpty())
ui->lineEdit_options->setText(filename);
}
void PppoeWidget::showAdvanced()
{
if (ui->pushButton_pppoeAdvanced->isChecked()) {
ui->widget_pppoeAdvanced->setHidden(false);
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Hide advanced"));
}
else {
ui->widget_pppoeAdvanced->setHidden(true);
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Show advanced"));
}
}
QMap<QString, QString> PppoeWidget::getSettings()
{
QMap<QString, QString> pppoeSettings;
if (isOk() != 0)
return pppoeSettings;
if (!ui->lineEdit_username->text().isEmpty())
pppoeSettings[QString("User")] = QString("'") + ui->lineEdit_username->text() + QString("'");
if (!ui->lineEdit_password->text().isEmpty())
pppoeSettings[QString("Password")] = QString("'") + ui->lineEdit_password->text() + QString("'");
pppoeSettings[QString("ConnectionMode")] = QString("'") + ui->comboBox_connection->currentText() + QString("'");
if (ui->comboBox_connection->currentText() == QString("demand"))
pppoeSettings[QString("IdleTimeout")] = QString::number(ui->spinBox_timeout->value());
if (ui->spinBox_fail->value() != 5)
pppoeSettings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
if (ui->checkBox_route->checkState() == Qt::Unchecked)
pppoeSettings[QString("DefaultRoute")] = QString("false");
if (ui->checkBox_dns->checkState() == Qt::Unchecked)
pppoeSettings[QString("UsePeerDNS")] = QString("false");
if (!ui->lineEdit_unit->text().isEmpty())
pppoeSettings[QString("PPPUnit")] = ui->lineEdit_unit->text();
if (ui->spinBox_lcpInterval->value() != 30)
pppoeSettings[QString("LCPEchoInterval")] = QString::number(ui->spinBox_lcpInterval->value());
if (ui->spinBox_lcpFailure->value() != 4)
pppoeSettings[QString("LCPEchoFailure")] = QString::number(ui->spinBox_lcpFailure->value());
if (!ui->lineEdit_options->text().isEmpty())
pppoeSettings[QString("OptionsFile")] = QString("'") + ui->lineEdit_options->text() + QString("'");
if (!ui->lineEdit_service->text().isEmpty())
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())
pppoeSettings[QString("PPPoEMAC")] = QString("'") + ui->lineEdit_mac->text() + QString("'");
if (ui->checkBox_ipv6->checkState() == Qt::Checked)
pppoeSettings[QString("PPPoEIP6")] = QString("yes");
return pppoeSettings;
}
int PppoeWidget::isOk()
{
// config file doesn't exist
if (!ui->lineEdit_options->text().isEmpty())
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(" ")))
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())
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(":"));
for (int i=1; i<7; i++)
if (item[i].contains(QString(" ")))
return 4;
}
// all fine
return 0;
}
void PppoeWidget::setSettings(const QMap<QString, QString> settings)
{
QMap<QString, QString> pppoeSettings = settings;
if (pppoeSettings.contains(QString("User")))
ui->lineEdit_username->setText(pppoeSettings[QString("User")].remove(QString("'")));
if (pppoeSettings.contains(QString("Password")))
ui->lineEdit_password->setText(pppoeSettings[QString("Password")].remove(QString("'")));
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))
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"))
ui->checkBox_route->setCheckState(Qt::Unchecked);
if (pppoeSettings.contains(QString("UsePeerDNS")))
if (pppoeSettings[QString("UsePeerDNS")].remove(QString("'")) == QString("false"))
ui->checkBox_dns->setCheckState(Qt::Unchecked);
if (pppoeSettings.contains(QString("PPPUnit")))
ui->lineEdit_unit->setText(pppoeSettings[QString("PPPUnit")]);
if (pppoeSettings.contains(QString("LCPEchoInterval")))
ui->spinBox_lcpInterval->setValue(pppoeSettings[QString("LCPEchoInterval")].toInt());
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("'")));
if (pppoeSettings.contains(QString("PPPoEService")))
ui->lineEdit_service->setText(pppoeSettings[QString("PPPoEService")].remove(QString("'")));
if (pppoeSettings.contains(QString("PPPoEAC")))
ui->lineEdit_ac->setText(pppoeSettings[QString("PPPoEAC")].remove(QString("'")));
if (pppoeSettings.contains(QString("PPPoESession")))
ui->lineEdit_session->setText(pppoeSettings[QString("PPPoESession")].remove(QString("'")));
if (pppoeSettings.contains(QString("PPPoEMAC")))
ui->lineEdit_mac->setText(pppoeSettings[QString("PPPoEMAC")].remove(QString("'")));
if (pppoeSettings.contains(QString("PPPoEIP6")))
if (pppoeSettings[QString("PPPoEIP6")] == QString("yes"))
ui->checkBox_dns->setCheckState(Qt::Checked);
changeMode(ui->comboBox_connection->currentText());
}

View File

@ -0,0 +1,55 @@
/***************************************************************************
* 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 PPPOEWIDGET_H
#define PPPOEWIDGET_H
#include <QWidget>
namespace Ui {
class PppoeWidget;
}
class PppoeWidget : public QWidget
{
Q_OBJECT
public:
explicit PppoeWidget(QWidget *parent = 0);
~PppoeWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private slots:
void changeMode(const QString currentText);
void selectOptionsFile();
void showAdvanced();
private:
Ui::PppoeWidget *ui;
void createActions();
void createFilter();
};
#endif /* PPPOEWIDGET_H */

View File

@ -0,0 +1,465 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PppoeWidget</class>
<widget class="QWidget" name="PppoeWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>431</width>
<height>602</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_pppoe">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>PPPoE settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_pppoe">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="layout_username">
<item>
<widget class="QLabel" name="label_username">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Username</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_username">
<property name="toolTip">
<string>The username and password to connect with</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_password">
<item>
<widget class="QLabel" name="label_password">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_password">
<property name="toolTip">
<string>The username and password to connect with</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_connection">
<item>
<widget class="QLabel" name="label_connection">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Connection mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_connection">
<property name="toolTip">
<string>This option specifies how a connection should be established</string>
</property>
<item>
<property name="text">
<string>persist</string>
</property>
</item>
<item>
<property name="text">
<string>demand</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_timeout" native="true">
<layout class="QHBoxLayout" name="layout_timeout">
<item>
<widget class="QLabel" name="label_timeout">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Idle timeout</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timeout">
<property name="toolTip">
<string>This option specifies the idle time (in seconds) after which pppd should disconnect</string>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
<property name="value">
<number>300</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_pppoeAdvanced">
<item>
<spacer name="spacer_pppoeAdvanced">
<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_pppoeAdvanced">
<property name="text">
<string>Show advanced</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_pppoeAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_fail">
<item>
<widget class="QLabel" name="label_fail">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Max fail</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fail">
<property name="toolTip">
<string>The number of consecutive failed connection attempts to tolerate</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_route">
<property name="toolTip">
<string>Use the default route provided by the peer</string>
</property>
<property name="text">
<string>Default route</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_dns">
<property name="toolTip">
<string>Use the DNS provided by the peer</string>
</property>
<property name="text">
<string>Use peer DNS</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_unit">
<item>
<widget class="QLabel" name="label_unit">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>PPP unit</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_unit">
<property name="toolTip">
<string>Set the ppp unit number in the interface name (ppp0, ppp1, etc.)</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_lcpInterval">
<item>
<widget class="QLabel" name="label_lcpInterval">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>LCP echo interval</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_lcpInterval">
<property name="toolTip">
<string>These options override default LCP parameters from /etc/ppp/options</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>499</number>
</property>
<property name="value">
<number>30</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_lcpFailure">
<item>
<widget class="QLabel" name="label_lcpFailure">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>LCP echo failure</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_lcpFailure">
<property name="toolTip">
<string>These options override default LCP parameters from /etc/ppp/options</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>4</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_options">
<item>
<widget class="QLabel" name="label_options">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Options file</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_options">
<property name="toolTip">
<string>A file to read additional pppd options from</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_options">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_service">
<item>
<widget class="QLabel" name="label_service">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>PPPoE service</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_service">
<property name="toolTip">
<string>This option specifies the PPPoE service name</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_ac">
<item>
<widget class="QLabel" name="label_ac">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>PPPoE AC</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_ac">
<property name="toolTip">
<string>This option specifies the PPPoE access concentrator name</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_session">
<item>
<widget class="QLabel" name="label_session">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>PPPoE session</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_session">
<property name="toolTip">
<string>This option specifies an existing session to attach to, MAC address</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<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>PPPoE MAC</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_mac">
<property name="toolTip">
<string>Only connect to specified MAC address</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_ipv6">
<property name="toolTip">
<string>Enable IPv6 support</string>
</property>
<property name="text">
<string>PPPoE IPv6</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,294 @@
/***************************************************************************
* 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 "settingswindow.h"
#include "ui_settingswindow.h"
#include <QDebug>
#include <QFile>
#include <QFileDialog>
#include <QTextStream>
#include "mainwindow.h"
SettingsWindow::SettingsWindow(MainWindow *wid, const QString configFile)
: QMainWindow(wid),
parent(wid),
file(configFile),
ui(new Ui::SettingsWindow)
{
ui->setupUi(this);
addLanguages();
createActions();
}
SettingsWindow::~SettingsWindow()
{
delete ui;
}
void SettingsWindow::createActions()
{
connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
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()));
// buttons
connect(ui->pushButton_interfaceDir, SIGNAL(clicked(bool)), SLOT(selectIfaceDir()));
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), SLOT(selectNetctlPath()));
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_wpaCliPath, SIGNAL(clicked(bool)), SLOT(selectWpaCliPath()));
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), SLOT(selectWpaSupPath()));
}
// ESC press event
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (pressedKey->key() == Qt::Key_Escape)
close();
}
void SettingsWindow::addLanguages()
{
ui->comboBox_language->addItem(QString("english"));
ui->comboBox_language->addItem(QString("russian"));
}
void 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");
configFile.close();
}
void SettingsWindow::setDefault()
{
setSettings(getDefault());
saveSettings();
}
void SettingsWindow::selectIfaceDir()
{
QString directory = QFileDialog::getExistingDirectory(
this,
QApplication::translate("SettingsWindow", "Select path to directory with interfaces"),
QString("/sys/"));
if (!directory.isEmpty())
ui->lineEdit_interfacesDir->setText(directory);
}
void SettingsWindow::selectNetctlPath()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select netctl command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_netctlPath->setText(filename);
}
void SettingsWindow::selectProfileDir()
{
QString directory = QFileDialog::getExistingDirectory(
this,
QApplication::translate("SettingsWindow", "Select path to profile directory"),
QString("/etc/"));
if (!directory.isEmpty())
ui->lineEdit_profilePath->setText(directory);
}
void SettingsWindow::selectRfkillDir()
{
QString directory = QFileDialog::getExistingDirectory(
this,
QApplication::translate("SettingsWindow", "Select path to directory with rfkill devices"),
QString("/sys/"));
if (!directory.isEmpty())
ui->lineEdit_rfkill->setText(directory);
}
void SettingsWindow::selectSudoPath()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select sudo command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_sudo->setText(filename);
}
void SettingsWindow::selectWpaCliPath()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select wpa_cli command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_wpaCliPath->setText(filename);
}
void SettingsWindow::selectWpaSupPath()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select wpa_supplicant command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_wpaSupPath->setText(filename);
}
void SettingsWindow::showWindow()
{
setSettings(getSettings());
ui->label_info->hide();
show();
}
QMap<QString, QString> 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("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("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]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
{
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
ui->comboBox_language->setCurrentIndex(0);
for (int i=0; i<ui->comboBox_language->count(); i++)
if (ui->comboBox_language->itemText(i) == settings[QString("LANGUAGE")])
ui->comboBox_language->setCurrentIndex(i);
ui->lineEdit_netctlPath->setText(settings[QString("NETCTL_PATH")]);
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_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]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
}
QMap<QString, QString> 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("NETCTL_PATH")] = QString("/usr/bin/netctl");
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("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]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}
QMap<QString, QString> SettingsWindow::getSettings()
{
QMap<QString, QString> settings;
QFile configFile(file);
QString fileStr;
if (!configFile.open(QIODevice::ReadOnly))
return getDefault();
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();
}
if (configFile.atEnd())
break;
}
configFile.close();
for (int i=0; i<settings.keys().count(); i++)
qDebug() << "[SettingsWindow]" << "[getSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}

View File

@ -0,0 +1,70 @@
/***************************************************************************
* 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 SETTINGSWINDOW_H
#define SETTINGSWINDOW_H
#include <QKeyEvent>
#include <QMainWindow>
class MainWindow;
namespace Ui {
class SettingsWindow;
}
class SettingsWindow : public QMainWindow
{
Q_OBJECT
public:
explicit SettingsWindow(MainWindow *wid = 0,
const QString configFile = QString(""));
~SettingsWindow();
QMap<QString, QString> getDefault();
QMap<QString, QString> getSettings();
public slots:
void setDefault();
void showWindow();
private slots:
void addLanguages();
void saveSettings();
// buttons
void selectIfaceDir();
void selectNetctlPath();
void selectProfileDir();
void selectRfkillDir();
void selectSudoPath();
void selectWpaCliPath();
void selectWpaSupPath();
private:
MainWindow *parent;
QString file;
Ui::SettingsWindow *ui;
void createActions();
// ESC pressed event
void keyPressEvent(QKeyEvent *pressedKey);
QMap<QString, QString> readSettings();
void setSettings(const QMap<QString, QString> settings);
};
#endif /* SETTINGSWINDOW_H */

View File

@ -0,0 +1,502 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsWindow</class>
<widget class="QMainWindow" name="SettingsWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>461</width>
<height>287</height>
</rect>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_general">
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_language">
<item>
<widget class="QLabel" name="label_language">
<property name="text">
<string>Language</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_language">
<property name="toolTip">
<string>Select a language</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_info">
<property name="text">
<string>You will need to restart the application</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="spacer_general">
<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="tab_netctl">
<attribute name="title">
<string>netctl</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="layout_netctlPath">
<item>
<widget class="QLabel" name="label_netctlPath">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>netctl path</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_netctlPath">
<property name="toolTip">
<string>Path to netctl</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_netctlPath">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_profilePath">
<item>
<widget class="QLabel" name="label_profilePath">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Profile path</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_profilePath">
<property name="toolTip">
<string>Path to profile directory</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_profilePath">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer_netctl">
<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="tab_sudo">
<attribute name="title">
<string>sudo</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="layout_sudo">
<item>
<widget class="QLabel" name="label_sudo">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>sudo path</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_sudo">
<property name="toolTip">
<string>Path to sudo</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_sudo">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer_sudo">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>192</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_wpaSup">
<attribute name="title">
<string>wpa_supplicant</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="layout_wpaSupPath">
<item>
<widget class="QLabel" name="label_wpaSupPath">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>wpa_supplicant path</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaSupPath">
<property name="toolTip">
<string>Path to wpa_supplicant</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_wpaSupPath">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_wpaCliPath">
<item>
<widget class="QLabel" name="label_wpaCliPath">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>wpa_cli path</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaCliPath">
<property name="toolTip">
<string>Path to wpa_cli</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_wpaCliPath">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_pid">
<item>
<widget class="QLabel" name="label_pid">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>PID file</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_pid">
<property name="toolTip">
<string>wpa_supplicant PID file</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_wpaSupDrivers">
<item>
<widget class="QLabel" name="label_wpaSupDrivers">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>wpa_supplicant drivers</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaSupDrivers">
<property name="toolTip">
<string>wpa_supplicant drivers comma separated</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_wpaDir">
<item>
<widget class="QLabel" name="label_wpaDir">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>ctrl_interface directory</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaDir">
<property name="toolTip">
<string>Path to control directory</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_wpaGroup">
<item>
<widget class="QLabel" name="label_wpaGroup">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>ctrl_interface group</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaGroup">
<property name="toolTip">
<string>Group of control directory</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer_wpaSup">
<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="tab_other">
<attribute name="title">
<string>Other</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="layout_interfacesDir">
<item>
<widget class="QLabel" name="label_interfacesDir">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Path to interface list</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_interfacesDir">
<property name="toolTip">
<string>Path to directory which contains network devices</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_interfaceDir">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_rfkill">
<item>
<widget class="QLabel" name="label_rfkill">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Path to rfkill device list</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_rfkill">
<property name="toolTip">
<string>Path to directory which contains rfkill devices</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_rfkill">
<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>0</height>
</size>
</property>
<property name="text">
<string>Prefered wireless interface</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_interface">
<property name="toolTip">
<string>Prefered wireless interface</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="spacer_other">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>130</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,46 @@
/***************************************************************************
* 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 SLEEPTHREAD_H
#define SLEEPTHREAD_H
#include <QThread>
class SleepThread : public QThread
{
Q_OBJECT
public:
static void usleep(long iSleepTime)
{
QThread::usleep(iSleepTime);
}
static void sleep(long iSleepTime)
{
QThread::sleep(iSleepTime);
}
static void msleep(long iSleepTime)
{
QThread::msleep(iSleepTime);
}
};
#endif /* SLEEPTHREAD_H */

View File

@ -0,0 +1,122 @@
/***************************************************************************
* 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 "tunnelwidget.h"
#include "ui_tunnelwidget.h"
TunnelWidget::TunnelWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::TunnelWidget)
{
ui->setupUi(this);
createFilter();
clear();
}
TunnelWidget::~TunnelWidget()
{
delete ui;
}
void TunnelWidget::clear()
{
ui->comboBox_mode->setCurrentIndex(0);
ui->lineEdit_local->clear();
ui->lineEdit_remote->clear();
}
void TunnelWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void TunnelWidget::createFilter()
{
// using input mask because validators is not comfortable
// ipv4
ui->lineEdit_local->setInputMask(QString("999.999.999.999"));
ui->lineEdit_remote->setInputMask(QString("999.999.999.999"));
}
QString TunnelWidget::getIp(const QString rawIp)
{
QStringList ip = rawIp.split(QString("."));
// fix empty fields
if (ip[0].isEmpty())
ip[0] = QString("127");
if (ip[1].isEmpty())
ip[1] = QString("0");
if (ip[2].isEmpty())
ip[2] = QString("0");
if (ip[3].isEmpty())
ip[3] = QString("1");
// fix numbers
for (int i=0; i<4; i++)
if (ip[i].toInt() > 255)
ip[i] = QString("255");
return ip.join(QString("."));
}
QMap<QString, QString> TunnelWidget::getSettings()
{
QMap<QString, QString> tunnelSettings;
if (isOk() != 0)
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("'");
return tunnelSettings;
}
int TunnelWidget::isOk()
{
// all fine
return 0;
}
void TunnelWidget::setSettings(const QMap<QString, QString> settings)
{
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))
ui->comboBox_mode->setCurrentIndex(i);
if (tunnelSettings.contains(QString("Local")))
ui->lineEdit_local->setText(tunnelSettings[QString("Local")].remove(QString("'")));
if (tunnelSettings.contains(QString("Remote")))
ui->lineEdit_remote->setText(tunnelSettings[QString("Remote")].remove(QString("'")));
}

View File

@ -0,0 +1,50 @@
/***************************************************************************
* 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 TUNNELWIDGET_H
#define TUNNELWIDGET_H
#include <QWidget>
namespace Ui {
class TunnelWidget;
}
class TunnelWidget : public QWidget
{
Q_OBJECT
public:
explicit TunnelWidget(QWidget *parent = 0);
~TunnelWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private:
Ui::TunnelWidget *ui;
void createFilter();
QString getIp(const QString rawIp);
};
#endif /* TUNNELWIDGET_H */

View File

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TunnelWidget</class>
<widget class="QWidget" name="TunnelWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>411</width>
<height>146</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_tunnel">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Tunnel settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_tunnel">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_mode">
<item>
<widget class="QLabel" name="label_mode">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_mode">
<property name="toolTip">
<string>The tunnel type</string>
</property>
<item>
<property name="text">
<string>ipip</string>
</property>
</item>
<item>
<property name="text">
<string>gre</string>
</property>
</item>
<item>
<property name="text">
<string>sit</string>
</property>
</item>
<item>
<property name="text">
<string>isatap</string>
</property>
</item>
<item>
<property name="text">
<string>ip6ip6</string>
</property>
</item>
<item>
<property name="text">
<string>ipip6</string>
</property>
</item>
<item>
<property name="text">
<string>ip6gre</string>
</property>
</item>
<item>
<property name="text">
<string>any</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_local">
<item>
<widget class="QLabel" name="label_local">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Local</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_local">
<property name="toolTip">
<string>The address of the local end of the tunnel</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_remote">
<item>
<widget class="QLabel" name="label_remote">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Remote</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_remote">
<property name="toolTip">
<string>The address of the remote end of the tunnel</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>comboBox_mode</tabstop>
<tabstop>lineEdit_local</tabstop>
<tabstop>lineEdit_remote</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

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 "tuntapwidget.h"
#include "ui_tuntapwidget.h"
TuntapWidget::TuntapWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::TuntapWidget)
{
ui->setupUi(this);
clear();
}
TuntapWidget::~TuntapWidget()
{
delete ui;
}
void TuntapWidget::clear()
{
ui->comboBox_mode->setCurrentIndex(0);
ui->lineEdit_user->setText(QString("nobody"));
ui->lineEdit_group->setText(QString("nobody"));
}
void TuntapWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
QMap<QString, QString> TuntapWidget::getSettings()
{
QMap<QString, QString> tuntapSettings;
if (isOk() != 0)
return tuntapSettings;
tuntapSettings[QString("Mode")] = QString("'") + ui->comboBox_mode->currentText() + QString("'");
tuntapSettings[QString("User")] = QString("'") + ui->lineEdit_user->text() + QString("'");
tuntapSettings[QString("Group")] = QString("'") + ui->lineEdit_group->text() + QString("'");
return tuntapSettings;
}
int TuntapWidget::isOk()
{
// empty username
if (ui->lineEdit_user->text().isEmpty())
return 1;
// empty group name
if (ui->lineEdit_group->text().isEmpty())
return 2;
// all fine
return 0;
}
void TuntapWidget::setSettings(const QMap<QString, QString> settings)
{
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))
ui->comboBox_mode->setCurrentIndex(i);
if (tuntapSettings.contains(QString("User")))
ui->lineEdit_user->setText(tuntapSettings[QString("User")].remove(QString("'")));
if (tuntapSettings.contains(QString("Group")))
ui->lineEdit_group->setText(tuntapSettings[QString("Group")].remove(QString("'")));
}

View File

@ -0,0 +1,48 @@
/***************************************************************************
* 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 TUNTAPWIDGET_H
#define TUNTAPWIDGET_H
#include <QWidget>
namespace Ui {
class TuntapWidget;
}
class TuntapWidget : public QWidget
{
Q_OBJECT
public:
explicit TuntapWidget(QWidget *parent = 0);
~TuntapWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private:
Ui::TuntapWidget *ui;
};
#endif /* TUNTAPWIDGET_H */

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TuntapWidget</class>
<widget class="QWidget" name="TuntapWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>424</width>
<height>146</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_tuntap">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Tuntap settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_tuntap">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_mode">
<item>
<widget class="QLabel" name="label_mode">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Mode</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_mode">
<property name="toolTip">
<string>Either tun, or tap</string>
</property>
<item>
<property name="text">
<string>tun</string>
</property>
</item>
<item>
<property name="text">
<string>tap</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_user">
<item>
<widget class="QLabel" name="label_user">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>User</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_user">
<property name="toolTip">
<string>The owning user of the tun/tap interface</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_group">
<item>
<widget class="QLabel" name="label_group">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Group</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_group">
<property name="toolTip">
<string>The owning group of the tun/tap interface</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,78 @@
/***************************************************************************
* 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 "vlanwidget.h"
#include "ui_vlanwidget.h"
VlanWidget::VlanWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::VlanWidget)
{
ui->setupUi(this);
clear();
}
VlanWidget::~VlanWidget()
{
delete ui;
}
void VlanWidget::clear()
{
ui->spinBox_vlan->setValue(55);
}
void VlanWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
QMap<QString, QString> VlanWidget::getSettings()
{
QMap<QString, QString> vlanSettings;
if (isOk() != 0)
return vlanSettings;
vlanSettings[QString("VLANID")] = QString::number(ui->spinBox_vlan->value());
return vlanSettings;
}
int VlanWidget::isOk()
{
// all fine
return 0;
}
void VlanWidget::setSettings(const QMap<QString, QString> settings)
{
QMap<QString, QString> vlanSettings = settings;
if (vlanSettings.contains(QString("VLANID")))
ui->spinBox_vlan->setValue(vlanSettings[QString("VLANID")].toInt());
}

View File

@ -0,0 +1,48 @@
/***************************************************************************
* 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 VLANWIDGET_H
#define VLANWIDGET_H
#include <QWidget>
namespace Ui {
class VlanWidget;
}
class VlanWidget : public QWidget
{
Q_OBJECT
public:
explicit VlanWidget(QWidget *parent = 0);
~VlanWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private:
Ui::VlanWidget *ui;
};
#endif /* VLANWIDGET_H */

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>VlanWidget</class>
<widget class="QWidget" name="VlanWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>393</width>
<height>81</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_vlan">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>vlan settings</string>
</property>
<widget class="QWidget" name="dockWidgetContents_vlan">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_vlan">
<item>
<widget class="QLabel" name="label_vlan">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>vlan ID</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_vlan">
<property name="toolTip">
<string>vlan identifier</string>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>55</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,351 @@
/***************************************************************************
* 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 "wirelesswidget.h"
#include "ui_wirelesswidget.h"
#include <QFileDialog>
#include <QFile>
#include <QKeyEvent>
WirelessWidget::WirelessWidget(QWidget *parent, const QMap<QString, QString> settings)
: QWidget(parent),
ui(new Ui::WirelessWidget)
{
ui->setupUi(this);
rfkillDirectory = new QDir(settings[QString("RFKILL_DIR")]);
createActions();
clear();
}
WirelessWidget::~WirelessWidget()
{
delete rfkillDirectory;
delete ui;
}
void WirelessWidget::clear()
{
ui->comboBox_security->setCurrentIndex(0);
changeSecurity(ui->comboBox_security->currentText());
ui->lineEdit_essid->clear();
ui->lineEdit_wpaConfigSection->clear();
ui->listWidget_wpaConfigSection->setCurrentRow(-1);
ui->listWidget_wpaConfigSection->clear();
ui->lineEdit_wpaConfig->setText(QString("/etc/wpa_supplicant.conf"));
ui->lineEdit_key->clear();
ui->checkBox_hidden->setCheckState(Qt::Unchecked);
ui->checkBox_adhoc->setCheckState(Qt::Unchecked);
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"));
ui->comboBox_drivers->setCurrentIndex(0);
ui->listWidget_drivers->setCurrentRow(-1);
ui->listWidget_drivers->clear();
ui->comboBox_rfkill->addItem(QString("auto"));
if (rfkillDirectory->exists()) {
QStringList rfkillDevices = rfkillDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i=0; i<rfkillDevices.count(); i++) {
QFile device(rfkillDirectory->absolutePath() + QDir::separator() + rfkillDevices[i] +
QDir::separator() + QString("name"));
QString deviceName;
if (device.open(QIODevice::ReadOnly))
deviceName = QString(device.readLine()).remove(QString("\n"));
ui->comboBox_rfkill->addItem(deviceName);
}
}
ui->comboBox_rfkill->setCurrentIndex(0);
ui->spinBox_timeoutWpa->setValue(15);
ui->checkBox_exclude->setCheckState(Qt::Unchecked);
ui->pushButton_wirelessAdvanced->setChecked(false);
showAdvanced();
}
void WirelessWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void WirelessWidget::createActions()
{
connect(ui->pushButton_wirelessAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
connect(ui->pushButton_drivers, SIGNAL(clicked(bool)), this, SLOT(addDriver()));
connect(ui->pushButton_freq, SIGNAL(clicked(bool)), this, SLOT(addFreq()));
connect(ui->pushButton_wpaConfigSection, SIGNAL(clicked(bool)), this, SLOT(addOption()));
connect(ui->pushButton_wpaConfig, SIGNAL(clicked(bool)), this, SLOT(selectWpaConfig()));
connect(ui->comboBox_security, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeSecurity(QString)));
}
void WirelessWidget::keyPressEvent(QKeyEvent *pressedKey)
{
if (pressedKey->key() == Qt::Key_Delete) {
if (ui->listWidget_wpaConfigSection->hasFocus() &&
(ui->listWidget_wpaConfigSection->currentItem() != 0))
delete ui->listWidget_wpaConfigSection->currentItem();
else if (ui->listWidget_freq->hasFocus() &&
(ui->listWidget_freq->currentItem() != 0))
delete ui->listWidget_freq->currentItem();
else if (ui->listWidget_drivers->hasFocus() &&
(ui->listWidget_drivers->currentItem() != 0))
delete ui->listWidget_drivers->currentItem();
}
}
void WirelessWidget::addDriver()
{
QString driver = ui->comboBox_drivers->currentText();
bool exists = false;
for (int i=0; i<ui->listWidget_drivers->count(); i++)
if (ui->listWidget_drivers->item(i)->text() == driver)
exists = true;
if (!exists)
ui->listWidget_drivers->addItem(driver);
}
void WirelessWidget::addFreq()
{
QString freq = QString::number(ui->spinBox_freq->value());
bool exists = false;
for (int i=0; i<ui->listWidget_freq->count(); i++)
if (ui->listWidget_freq->item(i)->text() == freq)
exists = true;
if (!exists)
ui->listWidget_freq->addItem(freq);
}
void WirelessWidget::addOption()
{
if (!ui->lineEdit_wpaConfigSection->text().isEmpty())
ui->listWidget_wpaConfigSection->addItem(ui->lineEdit_wpaConfigSection->text());
}
void WirelessWidget::changeSecurity(const QString currentText)
{
if (currentText == QString("none")) {
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->setHidden(false);
ui->widget_wpaConfigSection->setHidden(true);
ui->widget_wpaConfig->setHidden(true);
ui->widget_key->setHidden(false);
}
else if (currentText == QString("wpa-configsection")) {
ui->widget_essid->setHidden(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->setHidden(false);
ui->widget_key->setHidden(true);
}
}
void WirelessWidget::selectWpaConfig()
{
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("EthernetWidget", "Select wpa configuration file"),
QDir::currentPath(),
QApplication::translate("EthernetWidget", "Configuration files (*.conf)"));
if (!filename.isEmpty())
ui->lineEdit_wpaConfig->setText(filename);
}
void WirelessWidget::showAdvanced()
{
if (ui->pushButton_wirelessAdvanced->isChecked()) {
ui->widget_wirelessAdvanced->setHidden(false);
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Hide advanced"));
}
else {
ui->widget_wirelessAdvanced->setHidden(true);
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Show advanced"));
}
}
QMap<QString, QString> WirelessWidget::getSettings()
{
QMap<QString, QString> wirelessSettings;
if (isOk() != 0)
return wirelessSettings;
wirelessSettings[QString("Security")] = ui->comboBox_security->currentText();
wirelessSettings[QString("ESSID")] = QString("'") + ui->lineEdit_essid->text() + QString("'");
if (ui->comboBox_security->currentText() == QString("wep")) {
if (ui->lineEdit_key->text().indexOf(QString("\\\"")) == 0)
wirelessSettings[QString("Key")] = ui->lineEdit_key->text();
else
wirelessSettings[QString("Key")] = QString("'") + ui->lineEdit_key->text() + QString("'");
}
else if (ui->comboBox_security->currentText() == QString("wpa"))
wirelessSettings[QString("Key")] = QString("'") + ui->lineEdit_key->text() + QString("'");
if (ui->comboBox_security->currentText() == QString("wpa-configsection")) {
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");
}
if (ui->comboBox_security->currentText() == QString("wpa-config"))
wirelessSettings[QString("WPAConfigFile")] = QString("'") + ui->lineEdit_wpaConfig->text() + QString("'");
if (ui->checkBox_hidden->checkState() == Qt::Checked)
wirelessSettings[QString("Hidden")] = QString("yes");
if (ui->checkBox_adhoc->checkState() == Qt::Checked)
wirelessSettings[QString("AdHoc")] = QString("yes");
if (ui->listWidget_freq->count() != 0) {
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(" "));
}
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())
wirelessSettings[QString("Country")] = QString("'") + ui->lineEdit_country->text() + QString("'");
if (ui->lineEdit_wpaGroup->text() != QString("wheel"))
wirelessSettings[QString("WPAGroup")] = QString("'") + ui->lineEdit_wpaGroup->text() + QString("'");
if (ui->listWidget_drivers->count() != 0) {
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("'");
}
if (ui->comboBox_rfkill->currentText() != QString("auto"))
wirelessSettings[QString("RFKill")] = ui->comboBox_rfkill->currentText();
if (ui->spinBox_timeoutWpa->value() != 15)
wirelessSettings[QString("TimeoutWPA")] = QString::number(ui->spinBox_timeoutWpa->value());
if (ui->checkBox_exclude->checkState() == Qt::Checked)
wirelessSettings[QString("ExcludeAuto")] = QString("yes");
return wirelessSettings;
}
int WirelessWidget::isOk()
{
// empty key
if ((ui->comboBox_security->currentText() == QString("wep")) ||
(ui->comboBox_security->currentText() == QString("wpa")))
if (ui->lineEdit_key->text().isEmpty())
return 1;
// empty settings
if (ui->comboBox_security->currentText() == QString("wpa-configsection"))
if (ui->listWidget_wpaConfigSection->count() == 0)
return 2;
// file is not set
if (ui->comboBox_security->currentText() == QString("wpa-config"))
if (ui->lineEdit_wpaConfig->text().isEmpty())
return 3;
// file wpa_supplicant doesn't exists
if (ui->comboBox_security->currentText() == QString("wpa-config"))
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")) ||
(ui->comboBox_security->currentText() == QString("wpa")))
if (ui->lineEdit_essid->text().isEmpty())
return 5;
// all fine
return 0;
}
void WirelessWidget::setSettings(const QMap<QString, QString> settings)
{
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))
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("'")));
}
if (wirelessSettings.contains(QString("WPAConfigFile")))
ui->lineEdit_wpaConfig->setText(wirelessSettings[QString("WPAConfigFile")].remove(QString("'")));
if (wirelessSettings.contains(QString("Hidden")))
if (wirelessSettings[QString("Hidden")].remove(QString("'")) == QString("yes"))
ui->checkBox_hidden->setCheckState(Qt::Checked);
if (wirelessSettings.contains(QString("AdHoc")))
if (wirelessSettings[QString("AdHoc")].remove(QString("'")) == QString("yes"))
ui->checkBox_adhoc->setCheckState(Qt::Checked);
if (wirelessSettings.contains(QString("ScanFrequencies")))
ui->listWidget_freq->addItems(wirelessSettings[QString("ScanFrequencies")].split(QString("\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("'")));
if (wirelessSettings.contains(QString("WPAGroup")))
ui->lineEdit_wpaGroup->setText(wirelessSettings[QString("WPAGroup")].remove(QString("'")));
if (wirelessSettings.contains(QString("WPADriver")))
ui->listWidget_drivers->addItems(wirelessSettings[QString("WPADriver")].split(QString(",")));
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))
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"))
ui->checkBox_exclude->setCheckState(Qt::Checked);
changeSecurity(ui->comboBox_security->currentText());
}

View File

@ -0,0 +1,62 @@
/***************************************************************************
* 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 WIRELESSWIDGET_H
#define WIRELESSWIDGET_H
#include <QDir>
#include <QMap>
#include <QWidget>
namespace Ui {
class WirelessWidget;
}
class WirelessWidget : public QWidget
{
Q_OBJECT
public:
explicit WirelessWidget(QWidget *parent = 0,
const QMap<QString, QString> settings = QMap<QString, QString>());
~WirelessWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private slots:
void addDriver();
void addFreq();
void addOption();
void changeSecurity(const QString currentText);
void showAdvanced();
void selectWpaConfig();
private:
QDir *rfkillDirectory;
Ui::WirelessWidget *ui;
void createActions();
void keyPressEvent(QKeyEvent *pressedKey);
};
#endif /* WIRELESSWIDGET_H */

View File

@ -0,0 +1,571 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WirelessWidget</class>
<widget class="QWidget" name="WirelessWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>431</width>
<height>776</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QDockWidget" name="dockWidget_wireless">
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="windowTitle">
<string>Wireless options</string>
</property>
<widget class="QWidget" name="dockWidgetContents_wireless">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="layout_security">
<item>
<widget class="QLabel" name="label_security">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Security</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_security">
<item>
<property name="text">
<string>none</string>
</property>
</item>
<item>
<property name="text">
<string>wep</string>
</property>
</item>
<item>
<property name="text">
<string>wpa</string>
</property>
</item>
<item>
<property name="text">
<string>wpa-configsection</string>
</property>
</item>
<item>
<property name="text">
<string>wpa-config</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_essid" native="true">
<layout class="QHBoxLayout" name="layout_essid">
<item>
<widget class="QLabel" name="label_essid">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>ESSID</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_essid">
<property name="toolTip">
<string>The name of the network to connect to</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_wpaConfigSection" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_wpaConfigSection">
<item>
<widget class="QLabel" name="label_wpaConfigSection">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Wpa config section</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaConfigSection"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_wpaConfigSection">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_wpaConfigSection">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>Array of lines that form a network block for wpa_supplicant</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_wpaConfig" native="true">
<layout class="QHBoxLayout" name="layout_wpaConfigFile">
<item>
<widget class="QLabel" name="label_wpaConfig">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Wpa config file</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaConfig">
<property name="toolTip">
<string>Path to a wpa_supplicant configuration file</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_wpaConfig">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_key" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_key">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Key</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_key">
<property name="toolTip">
<string>The secret key to a WEP, or WPA encrypted network</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_hidden">
<property name="toolTip">
<string>Whether or not the specified network is a hidden network</string>
</property>
<property name="text">
<string>Hidden</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_adhoc">
<property name="toolTip">
<string>Whether or not to use ad-hoc mode</string>
</property>
<property name="text">
<string>Ad-hoc</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="layout_wirelessAdvanced">
<item>
<spacer name="spacer_wirelessAdvanced">
<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_wirelessAdvanced">
<property name="text">
<string>Show advanced</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QWidget" name="widget_wirelessAdvanced" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="layout_freq">
<item>
<layout class="QHBoxLayout" name="layout_freqLine">
<item>
<widget class="QLabel" name="label_freq">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Scan frequencies</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_freq">
<property name="minimum">
<number>2000</number>
</property>
<property name="maximum">
<number>6000</number>
</property>
<property name="value">
<number>2412</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_freq">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_freq">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>A space-separated list of frequencies in MHz to scan when searching for the network</string>
</property>
</widget>
</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>
<widget class="QLabel" name="label_priority">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Priority</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_priority">
<property name="toolTip">
<string>Priority group for the network</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_country">
<item>
<widget class="QLabel" name="label_country">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Country</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_country">
<property name="toolTip">
<string>The country for which frequency regulations will be enforced</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layourt_wpaGroup">
<item>
<widget class="QLabel" name="label_wpaGroup">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>WPA group</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaGroup">
<property name="toolTip">
<string>Group that has the authority to configure wpa_supplicant via its control interface</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="layout_drivers">
<item>
<layout class="QHBoxLayout" name="layout_driversLine">
<item>
<widget class="QLabel" name="label_drivers">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Drivers</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_drivers">
<item>
<property name="text">
<string>west</string>
</property>
</item>
<item>
<property name="text">
<string>nl80211</string>
</property>
</item>
<item>
<property name="text">
<string>wired</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_drivers">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget_drivers">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="toolTip">
<string>The wpa_supplicant driver to use</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_rfkill">
<item>
<widget class="QLabel" name="label_rfkill">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>RFkill device</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_rfkill">
<property name="toolTip">
<string>The name of an rfkill device</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_timeoutWpa">
<item>
<widget class="QLabel" name="label_timeoutWpa">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Timeout WPA</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_timeoutWpa">
<property name="toolTip">
<string>Maximum time, in seconds, to wait for steps in the association and authentication to succeed</string>
</property>
<property name="maximum">
<number>999</number>
</property>
<property name="value">
<number>15</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_exclude">
<property name="toolTip">
<string>Whether or not to exclude this profile from automatic profile selection</string>
</property>
<property name="text">
<string>Exclude auto</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>comboBox_security</tabstop>
<tabstop>lineEdit_essid</tabstop>
<tabstop>lineEdit_wpaConfigSection</tabstop>
<tabstop>pushButton_wpaConfigSection</tabstop>
<tabstop>listWidget_wpaConfigSection</tabstop>
<tabstop>lineEdit_wpaConfig</tabstop>
<tabstop>pushButton_wpaConfig</tabstop>
<tabstop>lineEdit_key</tabstop>
<tabstop>checkBox_hidden</tabstop>
<tabstop>checkBox_adhoc</tabstop>
<tabstop>pushButton_wirelessAdvanced</tabstop>
<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>
<tabstop>comboBox_drivers</tabstop>
<tabstop>pushButton_drivers</tabstop>
<tabstop>listWidget_drivers</tabstop>
<tabstop>comboBox_rfkill</tabstop>
<tabstop>spinBox_timeoutWpa</tabstop>
<tabstop>checkBox_exclude</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,231 @@
/***************************************************************************
* 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 "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

@ -0,0 +1,65 @@
/***************************************************************************
* 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 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

@ -2,6 +2,11 @@
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)
if (BUILD_GUI)
install (FILES icon.png DESTINATION share/pixmaps RENAME netctl-gui.png)
endif ()
if (BUILD_DATAENGINE OR BUILD_PLASMOID)
install (FILES icon-plasmoid.png DESTINATION share/pixmaps RENAME netctl-gui-widget.png)
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)
endif ()

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -6,12 +6,10 @@ message (STATUS "Subproject ${SUBPROJECT}")
find_package (KDE4 REQUIRED)
include (KDE4Defaults)
add_definitions (${QT_DEFINITIONS}
${KDE4_DEFINITIONS})
include_directories (${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${KDE4_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}/../)
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
add_subdirectory (po)
# set sources
set (PLUGIN_NAME ${SUBPROJECT})

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>480</width>
<height>320</height>
<height>343</height>
</rect>
</property>
<property name="minimumSize">
@ -23,7 +23,7 @@
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabConfiguration">
<attribute name="title">
@ -127,9 +127,6 @@
<property name="text">
<string>Browse</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
@ -163,9 +160,6 @@
<property name="text">
<string>Browse</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
@ -191,6 +185,55 @@
<item>
<widget class="QLineEdit" name="lineEdit_sudo"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_sudo">
<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_wifi">
<item>
<widget class="QCheckBox" name="checkBox_wifi">
<property name="minimumSize">
<size>
<width>150</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Show 'Start WiFi menu'</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wifi"/>
</item>
<item>
<widget class="QPushButton" name="pushButton_wifi">
<property name="minimumSize">
<size>
<width>100</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -577,9 +620,6 @@
<property name="text">
<string>Browse</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
@ -613,9 +653,6 @@
<property name="text">
<string>Browse</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
@ -655,6 +692,10 @@
<tabstop>pushButton_netctl</tabstop>
<tabstop>checkBox_sudo</tabstop>
<tabstop>lineEdit_sudo</tabstop>
<tabstop>pushButton_sudo</tabstop>
<tabstop>checkBox_wifi</tabstop>
<tabstop>lineEdit_wifi</tabstop>
<tabstop>pushButton_wifi</tabstop>
<tabstop>checkBox_showBigInterface</tabstop>
<tabstop>checkBox_showNetDev</tabstop>
<tabstop>checkBox_showExtIp</tabstop>

View File

@ -1,23 +1,22 @@
/***************************************************************************
* 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 Foobar. If not, see <http://www.gnu.org/licenses/>. *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "netctl.h"
#include "ui_configwindow.h"
#include <version.h>
#include <KConfigDialog>
#include <KFileDialog>
@ -27,11 +26,12 @@
#include <QGraphicsLinearLayout>
#include <QMenu>
#include <cstdio>
#include <version.h>
Netctl::Netctl(QObject *parent, const QVariantList &args) :
Plasma::Applet(parent, args)
Netctl::Netctl(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args)
{
setBackgroundHints(DefaultBackground);
setHasConfigurationInterface(true);
@ -43,66 +43,103 @@ Netctl::Netctl(QObject *parent, const QVariantList &args) :
Netctl::~Netctl()
{
delete startProfileMenu;
delete startProfile;
delete stopProfile;
delete restartProfile;
delete enableProfileAutoload;
// delete startProfileMenu;
// delete startProfile;
// delete stopProfile;
// delete restartProfile;
// delete enableProfile;
delete iconWidget;
delete iconFrame;
delete textFrame;
// delete iconWidget;
delete netctlEngine;
// delete netctlEngine;
}
void Netctl::init()
{
info[QString("name")] = QString("N\\A");
info[QString("status")] = QString("N\\A");
info[QString("intIp")] = QString("N\\A");
info[QString("extIp")] = QString("N\\A");
info[QString("interfaces")] = QString("lo");
netctlEngine = dataEngine(QString("netctl"));
createActions();
// generate ui
// main layout
fullSpaceLayout = new QGraphicsLinearLayout();
fullSpaceLayout->setContentsMargins(1, 1, 1, 1);
setLayout(fullSpaceLayout);
// frames
// icon
iconFrame = new Plasma::Frame();
QGraphicsLinearLayout *iconLayout = new QGraphicsLinearLayout();
iconWidget = new Plasma::IconWidget(KIcon(""), QString(), this);
iconWidget->setPreferredSize(30, 30);
connect(iconWidget, SIGNAL(doubleClicked()), this, SLOT(showGui()));
iconFrame->setLayout(iconLayout);
iconLayout->addItem(iconWidget);
fullSpaceLayout->addItem(iconFrame);
fullSpaceLayout->addItem(iconWidget);
// text
textFrame = new Plasma::Frame();
QGraphicsLinearLayout *textLayout = new QGraphicsLinearLayout();
textLabel = new Plasma::Label();
textLayout->addItem(textLabel);
textFrame->setLayout(textLayout);
fullSpaceLayout->addItem(textFrame);
textFrame->hide();
// stretch
fullSpaceLayout->addStretch(1);
textLabel->setPreferredHeight(30);
fullSpaceLayout->addItem(textLabel);
// read variables
configChanged();
}
void Netctl::updateInterface(bool setShown)
{
if (setShown) {
textLabel->show();
fullSpaceLayout->updateGeometry();
updateGeometry();
}
else {
textLabel->hide();
fullSpaceLayout->updateGeometry();
updateGeometry();
}
}
// context menu
void Netctl::enableProfileSlot()
{
QProcess command;
QString commandLine, enableStatus;
if (info[QString("status")].contains(QString("enabled"))) {
enableStatus = QString(" disable ");
sendNotification(QString("Info"), i18n("Set profile %1 disabled", info[QString("name")]));
}
else {
enableStatus = QString(" enable ");
sendNotification(QString("Info"), i18n("Set profile %1 enabled", info[QString("name")]));
}
if (useSudo)
commandLine = paths[QString("sudo")] + QString(" ") + paths[QString("netctl")] +
enableStatus + info[QString("name")];
else
commandLine = paths[QString("netctl")] + enableStatus + info[QString("name")];
command.startDetached(commandLine);
}
void Netctl::startProfileSlot(QAction *profile)
{
QProcess command;
QString commandLine;
commandLine = QString("");
sendNotification(QString("Info"), i18n("Start profile %1", profile->text().remove(QString("&"))));
if (status)
commandLine = netctlPath + QString(" stop ") + profileName + QString(" && ");
commandLine = paths[QString("netctl")] + QString(" stop ") +
info[QString("name")] + QString(" && ");
if (useSudo)
commandLine = sudoPath + QString(" \"") + commandLine + netctlPath + QString(" start ") + profile->text().mid(1) + QString("\"");
commandLine = paths[QString("sudo")] + QString(" ") + commandLine +
paths[QString("netctl")] + QString(" start ") +
profile->text().remove(QString("&"));
else
commandLine = commandLine + netctlPath + QString(" start ") + profile->text().mid(1);
commandLine = commandLine + paths[QString("netctl")] + QString(" start ") +
profile->text().remove(QString("&"));
command.startDetached(commandLine);
}
@ -111,10 +148,12 @@ void Netctl::stopProfileSlot()
{
QProcess command;
QString commandLine;
sendNotification(QString("Info"), i18n("Stop profile %1", info[QString("name")]));
if (useSudo)
commandLine = sudoPath + QString(" \"") + netctlPath + QString(" stop ") + profileName + QString("\"");
commandLine = paths[QString("sudo")] + QString(" ") + paths[QString("netctl")] +
QString(" stop ") + info[QString("name")];
else
commandLine = netctlPath + QString(" stop ") + profileName;
commandLine = paths[QString("netctl")] + QString(" stop ") + info[QString("name")];
command.startDetached(commandLine);
}
@ -123,74 +162,46 @@ void Netctl::restartProfileSlot()
{
QProcess command;
QString commandLine;
sendNotification(QString("Info"), i18n("Restart profile %1", info[QString("name")]));
if (useSudo)
commandLine = sudoPath + QString(" \"") + netctlPath + QString(" restart ") + profileName + QString("\"");
commandLine = paths[QString("sudo")] + QString(" ") + paths[QString("netctl")] +
QString(" restart ") + info[QString("name")];
else
commandLine = netctlPath + QString(" restart ") + profileName;
commandLine = paths[QString("netctl")] + QString(" restart ") + info[QString("name")];
command.startDetached(commandLine);
}
void Netctl::enableProfileAutoloadSlot()
{
QProcess command;
QString commandLine, enableStatus;
if (profileStatus == QString("(enable"))
enableStatus = QString("disable");
else
enableStatus = QString("enable");
if (useSudo)
commandLine = sudoPath + QString(" \"") + netctlPath + enableStatus + profileName + QString("\"");
else
commandLine = netctlPath + enableStatus + profileName;
command.startDetached(commandLine);
}
void Netctl::createActions()
{
menuActions.clear();
startProfile = new QAction(QString("Start profile"), this);
startProfileMenu = new QMenu(NULL);
startProfile->setMenu(startProfileMenu);
connect(startProfileMenu, SIGNAL(triggered(QAction *)), this, SLOT(startProfileSlot(QAction *)));
menuActions.append(startProfile);
stopProfile = new QAction(QString("Stop profile"), this);
connect(stopProfile, SIGNAL(triggered(bool)), this, SLOT(stopProfileSlot()));
menuActions.append(stopProfile);
restartProfile = new QAction(QString("Restart profile"), this);
connect(restartProfile, SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot()));
menuActions.append(restartProfile);
enableProfileAutoload = new QAction(QString("Enable profile"), this);
connect(enableProfileAutoload, SIGNAL(triggered(bool)), this, SLOT(enableProfileAutoloadSlot()));
menuActions.append(enableProfileAutoload);
}
QList<QAction*> Netctl::contextualActions()
{
if (status)
contextMenu[QString("title")]->setIcon(QIcon(paths[QString("active")]));
else
contextMenu[QString("title")]->setIcon(QIcon(paths[QString("inactive")]));
contextMenu[QString("title")]->setText(info[QString("name")] + QString(" ") + info[QString("status")]);
if (status) {
startProfile->setText(QString("Start another profile"));
stopProfile->setVisible(true);
stopProfile->setText(QString("Stop ") + profileName);
restartProfile->setVisible(true);
restartProfile->setText(QString("Restart ") + profileName);
enableProfileAutoload->setVisible(true);
if (profileStatus == QString("(enable"))
enableProfileAutoload->setText(QString("Disable ") + profileName);
contextMenu[QString("start")]->setText(i18n("Start another profile"));
contextMenu[QString("stop")]->setVisible(true);
contextMenu[QString("stop")]->setText(i18n("Stop ") + info[QString("name")]);
contextMenu[QString("restart")]->setVisible(true);
contextMenu[QString("restart")]->setText(i18n("Restart ") + info[QString("name")]);
contextMenu[QString("enable")]->setVisible(true);
if (info[QString("status")].contains(QString("enabled")))
contextMenu[QString("enable")]->setText(i18n("Disable ") + info[QString("name")]);
else
enableProfileAutoload->setText(QString("Enable ") + profileName);
contextMenu[QString("enable")]->setText(i18n("Enable ") + info[QString("name")]);
}
else {
startProfile->setText(QString("Start profile"));
stopProfile->setVisible(false);
restartProfile->setVisible(false);
enableProfileAutoload->setVisible(false);
contextMenu[QString("start")]->setText(i18n("Start profile"));
contextMenu[QString("stop")]->setVisible(false);
contextMenu[QString("restart")]->setVisible(false);
contextMenu[QString("enable")]->setVisible(false);
}
if (useWifi)
contextMenu[QString("wifi")]->setVisible(true);
else
contextMenu[QString("wifi")]->setVisible(false);
startProfileMenu->clear();
for (int i=0; i<profileList.count(); i++) {
@ -202,25 +213,66 @@ QList<QAction*> Netctl::contextualActions()
}
// events
void Netctl::showGui()
void Netctl::createActions()
{
QProcess command;
command.startDetached(guiPath);
menuActions.clear();
contextMenu[QString("title")] = new QAction(QString("netctl-gui"), this);
menuActions.append(contextMenu[QString("title")]);
contextMenu[QString("start")] = new QAction(i18n("Start profile"), this);
startProfileMenu = new QMenu(NULL);
contextMenu[QString("start")]->setMenu(startProfileMenu);
connect(startProfileMenu, SIGNAL(triggered(QAction *)), this,
SLOT(startProfileSlot(QAction *)));
menuActions.append(contextMenu[QString("start")]);
contextMenu[QString("stop")] = new QAction(i18n("Stop profile"), this);
connect(contextMenu[QString("stop")], SIGNAL(triggered(bool)), this, SLOT(stopProfileSlot()));
menuActions.append(contextMenu[QString("stop")]);
contextMenu[QString("restart")] = new QAction(i18n("Restart profile"), this);
connect(contextMenu[QString("restart")], SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot()));
menuActions.append(contextMenu[QString("restart")]);
contextMenu[QString("enable")] = new QAction(i18n("Enable profile"), this);
connect(contextMenu[QString("enable")], SIGNAL(triggered(bool)), this, SLOT(enableProfileSlot()));
menuActions.append(contextMenu[QString("enable")]);
contextMenu[QString("wifi")] = new QAction(i18n("Show WiFi menu"), this);
connect(contextMenu[QString("wifi")], SIGNAL(triggered(bool)), this, SLOT(showWifi()));
menuActions.append(contextMenu[QString("wifi")]);
}
// events
void Netctl::sendNotification(const QString eventId, const QString message)
{
KNotification *notification = new KNotification(eventId);
notification->setComponentData(KComponentData("plasma_applet_netctl"));
notification->setTitle(eventId);
notification->setTitle(QString("Netctl ::: ") + eventId);
notification->setText(message);
notification->sendEvent();
delete notification;
}
void Netctl::showGui()
{
sendNotification(QString("Info"), i18n("Start GUI"));
QProcess command;
command.startDetached(paths[QString("gui")]);
}
void Netctl::showWifi()
{
sendNotification(QString("Info"), i18n("Start WiFi menu"));
QProcess command;
command.startDetached(paths[QString("wifi")]);
}
// data engine interaction
void Netctl::connectToEngine()
{
@ -228,119 +280,140 @@ void Netctl::connectToEngine()
netctlEngine->connectSource(QString("statusBool"), this, autoUpdateInterval);
netctlEngine->connectSource(QString("currentProfile"), this, autoUpdateInterval);
netctlEngine->connectSource(QString("statusString"), this, autoUpdateInterval);
if (showBigInterface) {
if (showExtIp)
updateInterface(false);
if (bigInterface[QString("main")]) {
if (bigInterface[QString("extIp")])
netctlEngine->connectSource(QString("extIp"), this, autoUpdateInterval);
if (showIntIp)
if (bigInterface[QString("intIp")])
netctlEngine->connectSource(QString("intIp"), this, autoUpdateInterval);
if (showNetDev)
if (bigInterface[QString("netDev")])
netctlEngine->connectSource(QString("interfaces"), this, autoUpdateInterval);
textFrame->show();
updateInterface(true);
}
}
void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
{
if (data.keys().count() == 0)
return;
QString value = data[QString("value")].toString();
if (value.isEmpty())
value = QString("N\\A");
if (sourceName == QString("currentProfile")) {
info[QString("name")] = value;
// update text
QStringList text;
text.append(info[QString("name")] + QString(" ") + info[QString("status")]);
if (bigInterface[QString("intIp")])
text.append(info[QString("intIp")]);
if (bigInterface[QString("extIp")])
text.append(info[QString("extIp")]);
if (bigInterface[QString("netDev")])
text.append(info[QString("interfaces")]);
if (bigInterface[QString("main")])
textLabel->setText(formatLine[0] + text.join(QString("<br>")) + formatLine[1]);
}
else if (sourceName == QString("extIp")) {
info[QString("extIp")] = value;
}
else if (sourceName == QString("intIp")) {
info[QString("intIp")] = value;
}
else if (sourceName == QString("interfaces")) {
info[QString("interfaces")] = value;
}
else if (sourceName == QString("profiles")) {
profileList = value.split(QString(","));
}
else if (sourceName == QString("statusBool")) {
if (value == QString("true")) {
if (! status)
sendNotification(QString("Info"), i18n("Network is up"));
status = true;
iconWidget->setIcon(paths[QString("active")]);
}
else {
if (status)
sendNotification(QString("Info"), i18n("Network is down"));
status = false;
iconWidget->setIcon(paths[QString("inactive")]);
}
}
else if (sourceName == QString("statusString")) {
info[QString("status")] = QString("(") + value + QString(")");
}
update();
}
void Netctl::disconnectFromEngine()
{
netctlEngine->disconnectSource(QString("profiles"), this);
netctlEngine->disconnectSource(QString("statusBool"), this);
netctlEngine->disconnectSource(QString("currentProfile"), this);
netctlEngine->disconnectSource(QString("statusString"), this);
if (showBigInterface) {
if (showExtIp)
if (bigInterface[QString("main")]) {
if (bigInterface[QString("extIp")])
netctlEngine->disconnectSource(QString("extIp"), this);
if (showIntIp)
if (bigInterface[QString("intIp")])
netctlEngine->disconnectSource(QString("intIp"), this);
if (showNetDev)
if (bigInterface[QString("netDev")])
netctlEngine->disconnectSource(QString("interfaces"), this);
textFrame->hide();
}
update();
}
void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data)
{
if (data.keys().count() == 0)
return;
QString value = data[QString("value")].toString();;
if (value.isEmpty())
value = QString("N\\A");
if (sourceName == QString("currentProfile")) {
profileName = value;
// update text
QStringList text;
text.append(profileName + QString(" ") + profileStatus);
if (showIntIp)
text.append(intIp);
if (showExtIp)
text.append(extIp);
if (showNetDev)
text.append(interfaces);
textLabel->setText(formatLine[0] + text.join(QString("<br>")) + formatLine[1]);
}
else if (sourceName == QString("extIp")) {
extIp = value;
}
else if (sourceName == QString("intIp")) {
intIp = value;
}
else if (sourceName == QString("interfaces")) {
interfaces = value;
}
else if (sourceName == QString("profiles")) {
profileList = value.split(QString(","));
}
else if (sourceName == QString("statusBool")) {
if (value == QString("true")) {
status = true;
iconWidget->setIcon(activeIconPath);
}
else {
iconWidget->setIcon(inactiveIconPath);
status = false;
}
}
else if (sourceName == QString("statusString")) {
profileStatus = QString("(") + value + QString(")");
}
update();
updateInterface(false);
}
// configuration interface
void Netctl::selectGuiExe()
{
KUrl guiUrl = KFileDialog::getOpenUrl(KUrl(), "*");
if (!guiUrl.isEmpty())
uiConfig.lineEdit_gui->setText(guiUrl.path());
}
void Netctl::selectNetctlExe()
{
KUrl netctlUrl = KFileDialog::getOpenUrl(KUrl(), "*");
if (!netctlUrl.isEmpty())
uiConfig.lineEdit_netctl->setText(netctlUrl.path());
}
void Netctl::selectActiveIcon()
{
KUrl activeIconUrl = KFileDialog::getOpenUrl(KUrl(), "*");
if (!activeIconUrl.isEmpty())
uiConfig.lineEdit_activeIcon->setText(activeIconUrl.path());
KUrl url = KFileDialog::getOpenUrl(KUrl(), "*");
if (!url.isEmpty())
uiConfig.lineEdit_activeIcon->setText(url.path());
}
void Netctl::selectGuiExe()
{
KUrl url = KFileDialog::getOpenUrl(KUrl(), "*");
if (!url.isEmpty())
uiConfig.lineEdit_gui->setText(url.path());
}
void Netctl::selectInactiveIcon()
{
KUrl inactiveIconUrl = KFileDialog::getOpenUrl(KUrl(), "*");
if (!inactiveIconUrl.isEmpty())
uiConfig.lineEdit_inactiveIcon->setText(inactiveIconUrl.path());
KUrl url = KFileDialog::getOpenUrl(KUrl(), "*");
if (!url.isEmpty())
uiConfig.lineEdit_inactiveIcon->setText(url.path());
}
void Netctl::selectNetctlExe()
{
KUrl url = KFileDialog::getOpenUrl(KUrl(), "*");
if (!url.isEmpty())
uiConfig.lineEdit_netctl->setText(url.path());
}
void Netctl::selectSudoExe()
{
KUrl url = KFileDialog::getOpenUrl(KUrl(), "*");
if (!url.isEmpty())
uiConfig.lineEdit_sudo->setText(url.path());
}
void Netctl::selectWifiExe()
{
KUrl url = KFileDialog::getOpenUrl(KUrl(), "*");
if (!url.isEmpty())
uiConfig.lineEdit_wifi->setText(url.path());
}
@ -348,35 +421,47 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent)
{
QWidget *configwin = new QWidget;
uiConfig.setupUi(configwin);
QString text = QString(NAME) + " - " + QString(VERSION) + "\n" + "(c) " + QString(DATE) + " " + QString(AUTHOR);
QString text = QString(NAME) + " - " + QString(VERSION) + "\n" + "(c) " +
QString(DATE) + " " + QString(AUTHOR);
uiConfig.label_info->setText(text);
uiConfig.spinBox_autoUpdate->setValue(autoUpdateInterval);
uiConfig.lineEdit_gui->setText(guiPath);
uiConfig.lineEdit_netctl->setText(netctlPath);
uiConfig.lineEdit_gui->setText(paths[QString("gui")]);
uiConfig.lineEdit_netctl->setText(paths[QString("netctl")]);
if (useSudo)
uiConfig.checkBox_sudo->setCheckState(Qt::Checked);
else
uiConfig.checkBox_sudo->setCheckState(Qt::Unchecked);
uiConfig.lineEdit_sudo->setText(sudoPath);
if (showBigInterface)
uiConfig.lineEdit_sudo->setText(paths[QString("sudo")]);
if (useWifi)
uiConfig.checkBox_wifi->setCheckState(Qt::Checked);
else
uiConfig.checkBox_wifi->setCheckState(Qt::Unchecked);
uiConfig.lineEdit_wifi->setText(paths[QString("wifi")]);
if (bigInterface[QString("main")])
uiConfig.checkBox_showBigInterface->setCheckState(Qt::Checked);
else
uiConfig.checkBox_showBigInterface->setCheckState(Qt::Unchecked);
if (showNetDev)
if (bigInterface[QString("netDev")])
uiConfig.checkBox_showNetDev->setCheckState(Qt::Checked);
else
uiConfig.checkBox_showNetDev->setCheckState(Qt::Unchecked);
if (showExtIp)
if (bigInterface[QString("extIp")])
uiConfig.checkBox_showExtIp->setCheckState(Qt::Checked);
else
uiConfig.checkBox_showExtIp->setCheckState(Qt::Unchecked);
if (showIntIp)
if (bigInterface[QString("intIp")])
uiConfig.checkBox_showIntIp->setCheckState(Qt::Checked);
else
uiConfig.checkBox_showIntIp->setCheckState(Qt::Unchecked);
setBigInterface();
KConfigGroup cg = config();
QString fontFamily = cg.readEntry("fontFamily", "Terminus");
int fontSize = cg.readEntry("fontSize", 10);
QString fontColor = cg.readEntry("fontColor", "#000000");
int fontWeight = cg.readEntry("fontWeight", 400);
QString fontStyle = cg.readEntry("fontStyle", "normal");
QFont font = QFont(fontFamily, 12, 400, FALSE);
uiConfig.fontComboBox_font->setCurrentFont(font);
uiConfig.spinBox_fontSize->setValue(fontSize);
@ -386,16 +471,20 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent)
uiConfig.comboBox_fontStyle->setCurrentIndex(0);
else if (fontStyle == "italic")
uiConfig.comboBox_fontStyle->setCurrentIndex(1);
uiConfig.lineEdit_activeIcon->setText(activeIconPath);
uiConfig.lineEdit_inactiveIcon->setText(inactiveIconPath);
uiConfig.lineEdit_activeIcon->setText(paths[QString("active")]);
uiConfig.lineEdit_inactiveIcon->setText(paths[QString("inactive")]);
parent->addPage(configwin, i18n("Netctl plasmoid"), Applet::icon());
connect(uiConfig.checkBox_showBigInterface, SIGNAL(stateChanged(int)), this, SLOT(setBigInterface()));
connect(uiConfig.checkBox_showBigInterface, SIGNAL(stateChanged(int)), this,
SLOT(setBigInterface()));
connect(uiConfig.checkBox_sudo, SIGNAL(stateChanged(int)), this, SLOT(setSudo()));
connect(uiConfig.checkBox_wifi, SIGNAL(stateChanged(int)), this, SLOT(setWifi()));
connect(uiConfig.pushButton_gui, SIGNAL(clicked()), this, SLOT(selectGuiExe()));
connect(uiConfig.pushButton_netctl, SIGNAL(clicked()), this, SLOT(selectNetctlExe()));
connect(uiConfig.pushButton_sudo, SIGNAL(clicked()), this, SLOT(selectSudoExe()));
connect(uiConfig.pushButton_wifi, SIGNAL(clicked()), this, SLOT(selecWifiExe()));
connect(uiConfig.pushButton_activeIcon, SIGNAL(clicked()), this, SLOT(selectActiveIcon()));
connect(uiConfig.pushButton_inactiveIcon, SIGNAL(clicked()), this, SLOT(selectInactiveIcon()));
@ -417,6 +506,11 @@ void Netctl::configAccepted()
else
cg.writeEntry("useSudo", true);
cg.writeEntry("sudoPath", uiConfig.lineEdit_sudo->text());
if (uiConfig.checkBox_wifi->checkState() == 0)
cg.writeEntry("useWifi", false);
else
cg.writeEntry("useWifi", true);
cg.writeEntry("wifiPath", uiConfig.lineEdit_wifi->text());
if (uiConfig.checkBox_showBigInterface->checkState() == 0)
cg.writeEntry("showBigInterface", false);
else
@ -449,22 +543,26 @@ void Netctl::configChanged()
KConfigGroup cg = config();
autoUpdateInterval = cg.readEntry("autoUpdateInterval", 1000);
guiPath = cg.readEntry("guiPath", "/usr/bin/netctl-gui");
netctlPath = cg.readEntry("netctlPath", "/usr/bin/netctl");
paths[QString("gui")] = cg.readEntry("guiPath", "/usr/bin/netctl-gui");
paths[QString("netctl")] = cg.readEntry("netctlPath", "/usr/bin/netctl");
paths[QString("sudo")] = cg.readEntry("sudoPath", "/usr/bin/kdesu");
paths[QString("wifi")] = cg.readEntry("wifiPath", "/usr/bin/netctl-gui -t 3");
useSudo = cg.readEntry("useSudo", true);
sudoPath = cg.readEntry("sudoPath", "/usr/bin/kdesu -c");
showBigInterface = cg.readEntry("showBigInterface", true);
showNetDev = cg.readEntry("showNetDev", true);
showExtIp = cg.readEntry("showExtIp", true);
showIntIp = cg.readEntry("showIntIp", true);
useWifi = cg.readEntry("useWifi", true);
bigInterface[QString("main")] = cg.readEntry("showBigInterface", true);
bigInterface[QString("extIp")] = cg.readEntry("showExtIp", false);
bigInterface[QString("netDev")] = cg.readEntry("showNetDev", true);
bigInterface[QString("intIp")] = cg.readEntry("showIntIp", true);
fontFamily = cg.readEntry("fontFamily", "Terminus");
fontSize = cg.readEntry("fontSize", 10);
fontColor = cg.readEntry("fontColor", "#000000");
fontWeight = cg.readEntry("fontWeight", 400);
fontStyle = cg.readEntry("fontStyle", "normal");
activeIconPath = cg.readEntry("activeIconPath", "/usr/share/icons/hicolor/64x64/apps/network-idle.png");
inactiveIconPath = cg.readEntry("inactiveIconPath", "/usr/share/icons/hicolor/64x64/apps/network-offline.png");
QString fontFamily = cg.readEntry("fontFamily", "Terminus");
int fontSize = cg.readEntry("fontSize", 10);
QString fontColor = cg.readEntry("fontColor", "#000000");
int fontWeight = cg.readEntry("fontWeight", 400);
QString fontStyle = cg.readEntry("fontStyle", "normal");
paths[QString("active")] = cg.readEntry("activeIconPath",
"/usr/share/icons/hicolor/64x64/apps/netctl-idle.png");
paths[QString("inactive")] = cg.readEntry("inactiveIconPath",
"/usr/share/icons/hicolor/64x64/apps/netctl-offline.png");
formatLine[0] = ("<p align=\"center\"><span style=\" font-family:'" + fontFamily + \
"'; font-style:" + fontStyle + \
@ -496,9 +594,18 @@ void Netctl::setSudo()
{
if (uiConfig.checkBox_sudo->checkState() == 0)
uiConfig.lineEdit_sudo->setDisabled(true);
else if (uiConfig.checkBox_showBigInterface->checkState() == 2)
else if (uiConfig.checkBox_sudo->checkState() == 2)
uiConfig.lineEdit_sudo->setEnabled(true);
}
void Netctl::setWifi()
{
if (uiConfig.checkBox_wifi->checkState() == 0)
uiConfig.lineEdit_wifi->setDisabled(true);
else if (uiConfig.checkBox_wifi->checkState() == 2)
uiConfig.checkBox_wifi->setEnabled(true);
}
#include "netctl.moc"

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 Foobar. If not, see <http://www.gnu.org/licenses/>. *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef NETCTL_PLASMOID_H
@ -27,6 +27,7 @@
#include <ui_configwindow.h>
class QGraphicsLinearLayout;
class Netctl : public Plasma::Applet
@ -40,8 +41,9 @@ public:
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
@ -49,18 +51,23 @@ public slots:
void configChanged();
void setBigInterface();
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 selectSudoExe();
void selectWifiExe();
// context menu
void enableProfileSlot();
void startProfileSlot(QAction *profile);
void stopProfileSlot();
void restartProfileSlot();
void enableProfileAutoloadSlot();
protected:
void createConfigurationInterface(KConfigDialog *parent);
@ -70,54 +77,32 @@ private:
// ui
QGraphicsLinearLayout *fullSpaceLayout;
// icon
Plasma::Frame *iconFrame;
Plasma::IconWidget *iconWidget;
// text
Plasma::Frame *textFrame;
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;
QMap<QString, QAction*> contextMenu;
// data engine
Plasma::DataEngine *netctlEngine;
void connectToEngine();
void disconnectFromEngine();
// notification
// configuration interface
Ui::ConfigWindow uiConfig;
// 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)
#endif /* NETCTL_PLASMOID_H */

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

View File

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

View File

@ -0,0 +1,24 @@
find_package(KDE4 REQUIRED)
find_package(Gettext REQUIRED)
if (NOT GETTEXT_MSGFMT_EXECUTABLE)
message(FATAL_ERROR "Please install the msgfmt binary")
endif (NOT GETTEXT_MSGFMT_EXECUTABLE)
file (GLOB _po_files *.po)
set (_gmoFiles)
foreach (_current_PO_FILE ${_po_files})
get_filename_component (_lang ${_current_PO_FILE} NAME_WE)
set (_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
add_custom_command (OUTPUT ${_gmoFile}
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS ${_current_PO_FILE}
)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo DESTINATION ${LOCALE_INSTALL_DIR}/${_lang}/LC_MESSAGES/ RENAME plasma_applet_netctl.mo)
list (APPEND _gmoFiles ${_gmoFile})
endforeach (_current_PO_FILE)
add_custom_target (pofiles ALL DEPENDS ${_gmoFiles})

View File

View File

@ -0,0 +1,15 @@
#!/bin/sh
WDIR=`pwd` # working dir
SATELLITE_LIST=satellite.list
BACKGROUND_LIST=background.list
# Background list
cd "$WDIR"
cd ../images
ls -1 background_* | sed -e "s/background_//g" | sed -e "s/_/ /g" | sed -e "s/\.jpg//g" | sed -e "s/\.png//g" | sed -e "s/\.gif//g" | grep -v '^$' | sort --unique --ignore-leading-blanks > "$WDIR/background.list"
# Satellite list
cd "$WDIR"
cd ../data
cat satellite_images.xml | grep image\ name | sed -e "s/.*<image name=\"\([^\"]*\).*/\1/" | sed -e "s/\&amp;/\&/g" | sed -e "s/\&apos;/'/g" | sed -e "s/\&quot;/\"/g" | sed -e "s/\&lt;/</g" | sed -e "s/\&gt;/>/g" | grep -v '^$' | sort --unique --ignore-leading-blanks > "$WDIR/satellite.list"

289
sources/plasmoid/po/en.po Normal file
View File

@ -0,0 +1,289 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Evgeniy Alekseev <esalexeev@gmail.com>, 2014.
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: http://kde-look.org/content/show.php?content=98925\n"
"POT-Creation-Date: 2014-04-12 18:56+0400\n"
"PO-Revision-Date: 2014-04-12 18:56+0400\n"
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
"Language-Team: Russian <kde-russian@lists.kde.ru>\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Lokalize 1.5\n"
#: netctl.cpp:112
msgid "Set profile %1 disabled"
msgstr "Set profile %1 disabled"
#: netctl.cpp:116
msgid "Set profile %1 enabled"
msgstr "Set profile %1 enabled"
#: netctl.cpp:132
msgid "Start profile %1"
msgstr "Start profile %1"
#: netctl.cpp:151
msgid "Stop profile %1"
msgstr "Stop profile %1"
#: netctl.cpp:165
msgid "Restart profile %1"
msgstr "Restart profile %1"
#: netctl.cpp:178
msgid "Start another profile"
msgstr "Start another profile"
#: netctl.cpp:180
msgid "Stop "
msgstr "Stop "
#: netctl.cpp:182
msgid "Restart "
msgstr "Restart "
#: netctl.cpp:185
msgid "Disable "
msgstr "Disable "
#: netctl.cpp:187
msgid "Enable "
msgstr "Enable "
#: netctl.cpp:190 netctl.cpp:214
msgid "Start profile"
msgstr "Start profile"
#: netctl.cpp:221
msgid "Stop profile"
msgstr "Stop profile"
#: netctl.cpp:225
msgid "Restart profile"
msgstr "Restart profile"
#: netctl.cpp:229
msgid "Enable profile"
msgstr "Enable profile"
#: netctl.cpp:233
msgid "Show WiFi menu"
msgstr "Show WiFi menu"
#: netctl.cpp:253
msgid "Start GUI"
msgstr "Start GUI"
#: netctl.cpp:261
msgid "Start WiFi menu"
msgstr "Start WiFi menu"
#: netctl.cpp:325
msgid "Network is up"
msgstr "Network is up"
#: netctl.cpp:331
msgid "Network is down"
msgstr "Network is down"
#: netctl.cpp:468
msgid "Netctl plasmoid"
msgstr "Netctl plasmoid"
#. i18n: file: configwindow.ui:30
#. i18n: ectx: attribute (title), widget (QWidget, tabConfiguration)
#: po/rc.cpp:3 rc.cpp:3
msgid "Configuration"
msgstr "Configuration"
#. i18n: file: configwindow.ui:54
#. i18n: ectx: property (text), widget (QLabel, label_autoUpdate)
#: po/rc.cpp:6 rc.cpp:6
msgid "Auto update interval, msec"
msgstr "Auto update interval, msec"
#. i18n: file: configwindow.ui:112
#. i18n: ectx: property (text), widget (QLabel, label_gui)
#: po/rc.cpp:9 rc.cpp:9
msgid "Path to GUI"
msgstr "Path to GUI"
#. i18n: file: configwindow.ui:128
#. i18n: ectx: property (text), widget (QPushButton, pushButton_gui)
#. i18n: file: configwindow.ui:161
#. i18n: ectx: property (text), widget (QPushButton, pushButton_netctl)
#. i18n: file: configwindow.ui:197
#. i18n: ectx: property (text), widget (QPushButton, pushButton_sudo)
#. i18n: file: configwindow.ui:233
#. i18n: ectx: property (text), widget (QPushButton, pushButton_wifi)
#. i18n: file: configwindow.ui:621
#. i18n: ectx: property (text), widget (QPushButton, pushButton_activeIcon)
#. i18n: file: configwindow.ui:654
#. i18n: ectx: property (text), widget (QPushButton, pushButton_inactiveIcon)
#. i18n: file: configwindow.ui:128
#. i18n: ectx: property (text), widget (QPushButton, pushButton_gui)
#. i18n: file: configwindow.ui:161
#. i18n: ectx: property (text), widget (QPushButton, pushButton_netctl)
#. i18n: file: configwindow.ui:197
#. i18n: ectx: property (text), widget (QPushButton, pushButton_sudo)
#. i18n: file: configwindow.ui:233
#. i18n: ectx: property (text), widget (QPushButton, pushButton_wifi)
#. i18n: file: configwindow.ui:621
#. i18n: ectx: property (text), widget (QPushButton, pushButton_activeIcon)
#. i18n: file: configwindow.ui:654
#. i18n: ectx: property (text), widget (QPushButton, pushButton_inactiveIcon)
#: po/rc.cpp:12 po/rc.cpp:18 po/rc.cpp:24 po/rc.cpp:30 po/rc.cpp:87
#: po/rc.cpp:93 rc.cpp:12 rc.cpp:18 rc.cpp:24 rc.cpp:30 rc.cpp:87 rc.cpp:93
msgid "Browse"
msgstr "Browse"
#. i18n: file: configwindow.ui:145
#. i18n: ectx: property (text), widget (QLabel, label_netctl)
#: po/rc.cpp:15 rc.cpp:15
msgid "Path to netctl"
msgstr "Path to netctl"
#. i18n: file: configwindow.ui:178
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_sudo)
#: po/rc.cpp:21 rc.cpp:21
msgid "Use sudo for netctl"
msgstr "Use sudo for netctl"
#. i18n: file: configwindow.ui:214
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_wifi)
#: po/rc.cpp:27 rc.cpp:27
msgid "Show 'Start WiFi menu'"
msgstr "Show 'Start WiFi menu'"
#. i18n: file: configwindow.ui:242
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showBigInterface)
#: po/rc.cpp:33 rc.cpp:33
msgid "Show more detailed interface"
msgstr "Show more detailed interface"
#. i18n: file: configwindow.ui:252
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showNetDev)
#: po/rc.cpp:36 rc.cpp:36
msgid "Show network devices"
msgstr "Show network devices"
#. i18n: file: configwindow.ui:262
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showExtIp)
#: po/rc.cpp:39 rc.cpp:39
msgid "Show external IP"
msgstr "Show external IP"
#. i18n: file: configwindow.ui:272
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showIntIp)
#: po/rc.cpp:42 rc.cpp:42
msgid "Show internal IP"
msgstr "Show internal IP"
#. i18n: file: configwindow.ui:296
#. i18n: ectx: attribute (title), widget (QWidget, tabAppearance)
#: po/rc.cpp:45 rc.cpp:45
msgid "Appearance"
msgstr "Appearance"
#. i18n: file: configwindow.ui:310
#. i18n: ectx: property (text), widget (QLabel, label_font)
#: po/rc.cpp:48 rc.cpp:48
msgid "Font"
msgstr "Font"
#. i18n: file: configwindow.ui:342
#. i18n: ectx: property (toolTip), widget (QFontComboBox, fontComboBox_font)
#: po/rc.cpp:51 rc.cpp:51
msgid "Set font family"
msgstr "Set font family"
#. i18n: file: configwindow.ui:359
#. i18n: ectx: property (text), widget (QLabel, label_fontSize)
#: po/rc.cpp:54 rc.cpp:54
msgid "Font size"
msgstr "Font size"
#. i18n: file: configwindow.ui:391
#. i18n: ectx: property (toolTip), widget (QSpinBox, spinBox_fontSize)
#: po/rc.cpp:57 rc.cpp:57
msgid "Set font size"
msgstr "Set font size"
#. i18n: file: configwindow.ui:420
#. i18n: ectx: property (text), widget (QLabel, label_fontColor)
#: po/rc.cpp:60 rc.cpp:60
msgid "Font color"
msgstr "Font color"
#. i18n: file: configwindow.ui:452
#. i18n: ectx: property (toolTip), widget (KColorCombo, kcolorcombo_fontColor)
#: po/rc.cpp:63 rc.cpp:63
msgid "Set font color"
msgstr "Set font color"
#. i18n: file: configwindow.ui:469
#. i18n: ectx: property (text), widget (QLabel, label_fontWeight)
#: po/rc.cpp:66 rc.cpp:66
msgid "Font weight"
msgstr "Font weight"
#. i18n: file: configwindow.ui:501
#. i18n: ectx: property (toolTip), widget (QSpinBox, spinBox_fontWeight)
#: po/rc.cpp:69 rc.cpp:69
msgid "Set font weight"
msgstr "Set font weight"
#. i18n: file: configwindow.ui:533
#. i18n: ectx: property (text), widget (QLabel, label_fontStyle)
#: po/rc.cpp:72 rc.cpp:72
msgid "Font style"
msgstr "Font style"
#. i18n: file: configwindow.ui:565
#. i18n: ectx: property (toolTip), widget (QComboBox, comboBox_fontStyle)
#: po/rc.cpp:75 rc.cpp:75
msgid "Set font style"
msgstr "Set font style"
#. i18n: file: configwindow.ui:569
#. i18n: ectx: property (text), item, widget (QComboBox, comboBox_fontStyle)
#: po/rc.cpp:78 rc.cpp:78
msgid "normal"
msgstr "normal"
#. i18n: file: configwindow.ui:574
#. i18n: ectx: property (text), item, widget (QComboBox, comboBox_fontStyle)
#: po/rc.cpp:81 rc.cpp:81
msgid "italic"
msgstr "italic"
#. i18n: file: configwindow.ui:605
#. i18n: ectx: property (text), widget (QLabel, label_activeIcon)
#: po/rc.cpp:84 rc.cpp:84
msgid "Active icon"
msgstr "Active icon"
#. i18n: file: configwindow.ui:638
#. i18n: ectx: property (text), widget (QLabel, label_inactiveIcon)
#: po/rc.cpp:90 rc.cpp:90
msgid "Inactive icon"
msgstr "Inactive icon"
#: po/rc.cpp:94 rc.cpp:94
msgctxt "NAME OF TRANSLATORS"
msgid "Your names"
msgstr "Evgeniy Alekseev"
#: po/rc.cpp:95 rc.cpp:95
msgctxt "EMAIL OF TRANSLATORS"
msgid "Your emails"
msgstr "esalexeev@gmail.com"

View File

@ -0,0 +1,81 @@
#!/bin/sh
BASEDIR="../" # root of translatable sources
PROJECT="plasma_applet_netctl" # project name
BUGADDR="http://kde-look.org/content/show.php?content=98925" # MSGID-Bugs
WDIR=`pwd` # working dir
SATELLITE_LIST=satellite.list
BACKGROUND_LIST=background.list
add_list()
{
LIST=$1
if [ -z "$LIST" ]
then
echo ">>ERR<< add_list() - missing parameter LIST - exiting"
return
fi
if [ -f "$LIST" ]
then
cat $LIST | while read ROW
do
echo "tr2i18n(\"${ROW}\")" >> ${WDIR}/rc.cpp
done
else
echo ">>ERR<< add_list() - file $LIST does not exist."
fi
}
echo "Preparing rc files"
cd ${BASEDIR}
# we use simple sorting to make sure the lines do not jump around too much from system to system
find . -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > ${WDIR}/rcfiles.list
xargs --arg-file=${WDIR}/rcfiles.list extractrc > ${WDIR}/rc.cpp
# additional string for KAboutData
echo 'i18nc("NAME OF TRANSLATORS","Your names");' >> ${WDIR}/rc.cpp
echo 'i18nc("EMAIL OF TRANSLATORS","Your emails");' >> ${WDIR}/rc.cpp
cd ${WDIR}
# Add Satellite list
add_list "$SATELLITE_LIST"
# Add Background list
add_list "$BACKGROUND_LIST"
echo "Done preparing rc files"
echo "Extracting messages"
cd ${BASEDIR}
# see above on sorting
find . -name '*.cpp' -o -name '*.h' -o -name '*.c' | sort > ${WDIR}/infiles.list
echo "rc.cpp" >> ${WDIR}/infiles.list
cd ${WDIR}
xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 -ktr2i18n:1 \
-kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kaliasLocale -kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 \
--msgid-bugs-address="${BUGADDR}" \
--files-from=infiles.list -D ${BASEDIR} -D ${WDIR} -o ${PROJECT}.pot || { echo "error while calling xgettext. aborting."; exit 1; }
echo "Done extracting messages"
echo "Merging translations"
catalogs=`find . -name '*.po'`
for cat in $catalogs; do
echo $cat
msgmerge -o $cat.new $cat ${PROJECT}.pot
mv $cat.new $cat
done
echo "Done merging translations"
echo "Cleaning up"
cd ${WDIR}
rm rcfiles.list
rm infiles.list
rm rc.cpp
echo "Done"

View File

@ -0,0 +1,287 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://kde-look.org/content/show.php?content=98925\n"
"POT-Creation-Date: 2014-04-12 18:56+0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: netctl.cpp:112
msgid "Set profile %1 disabled"
msgstr ""
#: netctl.cpp:116
msgid "Set profile %1 enabled"
msgstr ""
#: netctl.cpp:132
msgid "Start profile %1"
msgstr ""
#: netctl.cpp:151
msgid "Stop profile %1"
msgstr ""
#: netctl.cpp:165
msgid "Restart profile %1"
msgstr ""
#: netctl.cpp:178
msgid "Start another profile"
msgstr ""
#: netctl.cpp:180
msgid "Stop "
msgstr ""
#: netctl.cpp:182
msgid "Restart "
msgstr ""
#: netctl.cpp:185
msgid "Disable "
msgstr ""
#: netctl.cpp:187
msgid "Enable "
msgstr ""
#: netctl.cpp:190 netctl.cpp:214
msgid "Start profile"
msgstr ""
#: netctl.cpp:221
msgid "Stop profile"
msgstr ""
#: netctl.cpp:225
msgid "Restart profile"
msgstr ""
#: netctl.cpp:229
msgid "Enable profile"
msgstr ""
#: netctl.cpp:233
msgid "Show WiFi menu"
msgstr ""
#: netctl.cpp:253
msgid "Start GUI"
msgstr ""
#: netctl.cpp:261
msgid "Start WiFi menu"
msgstr ""
#: netctl.cpp:325
msgid "Network is up"
msgstr ""
#: netctl.cpp:331
msgid "Network is down"
msgstr ""
#: netctl.cpp:468
msgid "Netctl plasmoid"
msgstr ""
#. i18n: file: configwindow.ui:30
#. i18n: ectx: attribute (title), widget (QWidget, tabConfiguration)
#: po/rc.cpp:3 rc.cpp:3
msgid "Configuration"
msgstr ""
#. i18n: file: configwindow.ui:54
#. i18n: ectx: property (text), widget (QLabel, label_autoUpdate)
#: po/rc.cpp:6 rc.cpp:6
msgid "Auto update interval, msec"
msgstr ""
#. i18n: file: configwindow.ui:112
#. i18n: ectx: property (text), widget (QLabel, label_gui)
#: po/rc.cpp:9 rc.cpp:9
msgid "Path to GUI"
msgstr ""
#. i18n: file: configwindow.ui:128
#. i18n: ectx: property (text), widget (QPushButton, pushButton_gui)
#. i18n: file: configwindow.ui:161
#. i18n: ectx: property (text), widget (QPushButton, pushButton_netctl)
#. i18n: file: configwindow.ui:197
#. i18n: ectx: property (text), widget (QPushButton, pushButton_sudo)
#. i18n: file: configwindow.ui:233
#. i18n: ectx: property (text), widget (QPushButton, pushButton_wifi)
#. i18n: file: configwindow.ui:621
#. i18n: ectx: property (text), widget (QPushButton, pushButton_activeIcon)
#. i18n: file: configwindow.ui:654
#. i18n: ectx: property (text), widget (QPushButton, pushButton_inactiveIcon)
#. i18n: file: configwindow.ui:128
#. i18n: ectx: property (text), widget (QPushButton, pushButton_gui)
#. i18n: file: configwindow.ui:161
#. i18n: ectx: property (text), widget (QPushButton, pushButton_netctl)
#. i18n: file: configwindow.ui:197
#. i18n: ectx: property (text), widget (QPushButton, pushButton_sudo)
#. i18n: file: configwindow.ui:233
#. i18n: ectx: property (text), widget (QPushButton, pushButton_wifi)
#. i18n: file: configwindow.ui:621
#. i18n: ectx: property (text), widget (QPushButton, pushButton_activeIcon)
#. i18n: file: configwindow.ui:654
#. i18n: ectx: property (text), widget (QPushButton, pushButton_inactiveIcon)
#: po/rc.cpp:12 po/rc.cpp:18 po/rc.cpp:24 po/rc.cpp:30 po/rc.cpp:87
#: po/rc.cpp:93 rc.cpp:12 rc.cpp:18 rc.cpp:24 rc.cpp:30 rc.cpp:87 rc.cpp:93
msgid "Browse"
msgstr ""
#. i18n: file: configwindow.ui:145
#. i18n: ectx: property (text), widget (QLabel, label_netctl)
#: po/rc.cpp:15 rc.cpp:15
msgid "Path to netctl"
msgstr ""
#. i18n: file: configwindow.ui:178
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_sudo)
#: po/rc.cpp:21 rc.cpp:21
msgid "Use sudo for netctl"
msgstr ""
#. i18n: file: configwindow.ui:214
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_wifi)
#: po/rc.cpp:27 rc.cpp:27
msgid "Show 'Start WiFi menu'"
msgstr ""
#. i18n: file: configwindow.ui:242
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showBigInterface)
#: po/rc.cpp:33 rc.cpp:33
msgid "Show more detailed interface"
msgstr ""
#. i18n: file: configwindow.ui:252
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showNetDev)
#: po/rc.cpp:36 rc.cpp:36
msgid "Show network devices"
msgstr ""
#. i18n: file: configwindow.ui:262
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showExtIp)
#: po/rc.cpp:39 rc.cpp:39
msgid "Show external IP"
msgstr ""
#. i18n: file: configwindow.ui:272
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showIntIp)
#: po/rc.cpp:42 rc.cpp:42
msgid "Show internal IP"
msgstr ""
#. i18n: file: configwindow.ui:296
#. i18n: ectx: attribute (title), widget (QWidget, tabAppearance)
#: po/rc.cpp:45 rc.cpp:45
msgid "Appearance"
msgstr ""
#. i18n: file: configwindow.ui:310
#. i18n: ectx: property (text), widget (QLabel, label_font)
#: po/rc.cpp:48 rc.cpp:48
msgid "Font"
msgstr ""
#. i18n: file: configwindow.ui:342
#. i18n: ectx: property (toolTip), widget (QFontComboBox, fontComboBox_font)
#: po/rc.cpp:51 rc.cpp:51
msgid "Set font family"
msgstr ""
#. i18n: file: configwindow.ui:359
#. i18n: ectx: property (text), widget (QLabel, label_fontSize)
#: po/rc.cpp:54 rc.cpp:54
msgid "Font size"
msgstr ""
#. i18n: file: configwindow.ui:391
#. i18n: ectx: property (toolTip), widget (QSpinBox, spinBox_fontSize)
#: po/rc.cpp:57 rc.cpp:57
msgid "Set font size"
msgstr ""
#. i18n: file: configwindow.ui:420
#. i18n: ectx: property (text), widget (QLabel, label_fontColor)
#: po/rc.cpp:60 rc.cpp:60
msgid "Font color"
msgstr ""
#. i18n: file: configwindow.ui:452
#. i18n: ectx: property (toolTip), widget (KColorCombo, kcolorcombo_fontColor)
#: po/rc.cpp:63 rc.cpp:63
msgid "Set font color"
msgstr ""
#. i18n: file: configwindow.ui:469
#. i18n: ectx: property (text), widget (QLabel, label_fontWeight)
#: po/rc.cpp:66 rc.cpp:66
msgid "Font weight"
msgstr ""
#. i18n: file: configwindow.ui:501
#. i18n: ectx: property (toolTip), widget (QSpinBox, spinBox_fontWeight)
#: po/rc.cpp:69 rc.cpp:69
msgid "Set font weight"
msgstr ""
#. i18n: file: configwindow.ui:533
#. i18n: ectx: property (text), widget (QLabel, label_fontStyle)
#: po/rc.cpp:72 rc.cpp:72
msgid "Font style"
msgstr ""
#. i18n: file: configwindow.ui:565
#. i18n: ectx: property (toolTip), widget (QComboBox, comboBox_fontStyle)
#: po/rc.cpp:75 rc.cpp:75
msgid "Set font style"
msgstr ""
#. i18n: file: configwindow.ui:569
#. i18n: ectx: property (text), item, widget (QComboBox, comboBox_fontStyle)
#: po/rc.cpp:78 rc.cpp:78
msgid "normal"
msgstr ""
#. i18n: file: configwindow.ui:574
#. i18n: ectx: property (text), item, widget (QComboBox, comboBox_fontStyle)
#: po/rc.cpp:81 rc.cpp:81
msgid "italic"
msgstr ""
#. i18n: file: configwindow.ui:605
#. i18n: ectx: property (text), widget (QLabel, label_activeIcon)
#: po/rc.cpp:84 rc.cpp:84
msgid "Active icon"
msgstr ""
#. i18n: file: configwindow.ui:638
#. i18n: ectx: property (text), widget (QLabel, label_inactiveIcon)
#: po/rc.cpp:90 rc.cpp:90
msgid "Inactive icon"
msgstr ""
#: po/rc.cpp:94 rc.cpp:94
msgctxt "NAME OF TRANSLATORS"
msgid "Your names"
msgstr ""
#: po/rc.cpp:95 rc.cpp:95
msgctxt "EMAIL OF TRANSLATORS"
msgid "Your emails"
msgstr ""

289
sources/plasmoid/po/ru.po Normal file
View File

@ -0,0 +1,289 @@
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
#
# Evgeniy Alekseev <esalexeev@gmail.com>, 2014.
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: http://kde-look.org/content/show.php?content=98925\n"
"POT-Creation-Date: 2014-04-12 18:56+0400\n"
"PO-Revision-Date: 2014-04-12 18:58+0400\n"
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
"Language-Team: Russian <kde-russian@lists.kde.ru>\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Lokalize 1.5\n"
#: netctl.cpp:112
msgid "Set profile %1 disabled"
msgstr "Выключение автозагрузки профиля %1"
#: netctl.cpp:116
msgid "Set profile %1 enabled"
msgstr "Включение автозагрузки профиля %1"
#: netctl.cpp:132
msgid "Start profile %1"
msgstr "Запуск профиля %1"
#: netctl.cpp:151
msgid "Stop profile %1"
msgstr "Остановка профиля %1"
#: netctl.cpp:165
msgid "Restart profile %1"
msgstr "Перезапуск профиля %1"
#: netctl.cpp:178
msgid "Start another profile"
msgstr "Запустить другой профиль"
#: netctl.cpp:180
msgid "Stop "
msgstr "Остановить "
#: netctl.cpp:182
msgid "Restart "
msgstr "Перезапустить "
#: netctl.cpp:185
msgid "Disable "
msgstr "Отключить "
#: netctl.cpp:187
msgid "Enable "
msgstr "Включить "
#: netctl.cpp:190 netctl.cpp:214
msgid "Start profile"
msgstr "Запустить профиль"
#: netctl.cpp:221
msgid "Stop profile"
msgstr "Остановить профиль"
#: netctl.cpp:225
msgid "Restart profile"
msgstr "Перезапустить профиль"
#: netctl.cpp:229
msgid "Enable profile"
msgstr "Включить профиль"
#: netctl.cpp:233
msgid "Show WiFi menu"
msgstr "Запустить WiFi-menu"
#: netctl.cpp:253
msgid "Start GUI"
msgstr "Запуск GUI"
#: netctl.cpp:261
msgid "Start WiFi menu"
msgstr "Запуск WiFi-menu"
#: netctl.cpp:325
msgid "Network is up"
msgstr "Сеть работает"
#: netctl.cpp:331
msgid "Network is down"
msgstr "Сеть не работает"
#: netctl.cpp:468
msgid "Netctl plasmoid"
msgstr "Netctl plasmoid"
#. i18n: file: configwindow.ui:30
#. i18n: ectx: attribute (title), widget (QWidget, tabConfiguration)
#: po/rc.cpp:3 rc.cpp:3
msgid "Configuration"
msgstr "Настройка"
#. i18n: file: configwindow.ui:54
#. i18n: ectx: property (text), widget (QLabel, label_autoUpdate)
#: po/rc.cpp:6 rc.cpp:6
msgid "Auto update interval, msec"
msgstr "Интервал автообновления, мсек"
#. i18n: file: configwindow.ui:112
#. i18n: ectx: property (text), widget (QLabel, label_gui)
#: po/rc.cpp:9 rc.cpp:9
msgid "Path to GUI"
msgstr "Путь к GUI"
#. i18n: file: configwindow.ui:128
#. i18n: ectx: property (text), widget (QPushButton, pushButton_gui)
#. i18n: file: configwindow.ui:161
#. i18n: ectx: property (text), widget (QPushButton, pushButton_netctl)
#. i18n: file: configwindow.ui:197
#. i18n: ectx: property (text), widget (QPushButton, pushButton_sudo)
#. i18n: file: configwindow.ui:233
#. i18n: ectx: property (text), widget (QPushButton, pushButton_wifi)
#. i18n: file: configwindow.ui:621
#. i18n: ectx: property (text), widget (QPushButton, pushButton_activeIcon)
#. i18n: file: configwindow.ui:654
#. i18n: ectx: property (text), widget (QPushButton, pushButton_inactiveIcon)
#. i18n: file: configwindow.ui:128
#. i18n: ectx: property (text), widget (QPushButton, pushButton_gui)
#. i18n: file: configwindow.ui:161
#. i18n: ectx: property (text), widget (QPushButton, pushButton_netctl)
#. i18n: file: configwindow.ui:197
#. i18n: ectx: property (text), widget (QPushButton, pushButton_sudo)
#. i18n: file: configwindow.ui:233
#. i18n: ectx: property (text), widget (QPushButton, pushButton_wifi)
#. i18n: file: configwindow.ui:621
#. i18n: ectx: property (text), widget (QPushButton, pushButton_activeIcon)
#. i18n: file: configwindow.ui:654
#. i18n: ectx: property (text), widget (QPushButton, pushButton_inactiveIcon)
#: po/rc.cpp:12 po/rc.cpp:18 po/rc.cpp:24 po/rc.cpp:30 po/rc.cpp:87
#: po/rc.cpp:93 rc.cpp:12 rc.cpp:18 rc.cpp:24 rc.cpp:30 rc.cpp:87 rc.cpp:93
msgid "Browse"
msgstr "Обзор"
#. i18n: file: configwindow.ui:145
#. i18n: ectx: property (text), widget (QLabel, label_netctl)
#: po/rc.cpp:15 rc.cpp:15
msgid "Path to netctl"
msgstr "Путь к netctl"
#. i18n: file: configwindow.ui:178
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_sudo)
#: po/rc.cpp:21 rc.cpp:21
msgid "Use sudo for netctl"
msgstr "Использовать sudo для netctl"
#. i18n: file: configwindow.ui:214
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_wifi)
#: po/rc.cpp:27 rc.cpp:27
msgid "Show 'Start WiFi menu'"
msgstr "Показать 'Запустить WiFi-menu'"
#. i18n: file: configwindow.ui:242
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showBigInterface)
#: po/rc.cpp:33 rc.cpp:33
msgid "Show more detailed interface"
msgstr "Показать более детальный интерфейс"
#. i18n: file: configwindow.ui:252
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showNetDev)
#: po/rc.cpp:36 rc.cpp:36
msgid "Show network devices"
msgstr "Показать сетевые устройства"
#. i18n: file: configwindow.ui:262
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showExtIp)
#: po/rc.cpp:39 rc.cpp:39
msgid "Show external IP"
msgstr "Показать внешний IP"
#. i18n: file: configwindow.ui:272
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showIntIp)
#: po/rc.cpp:42 rc.cpp:42
msgid "Show internal IP"
msgstr "Показать внутренний IP"
#. i18n: file: configwindow.ui:296
#. i18n: ectx: attribute (title), widget (QWidget, tabAppearance)
#: po/rc.cpp:45 rc.cpp:45
msgid "Appearance"
msgstr "Внешний вид"
#. i18n: file: configwindow.ui:310
#. i18n: ectx: property (text), widget (QLabel, label_font)
#: po/rc.cpp:48 rc.cpp:48
msgid "Font"
msgstr "Шрифт"
#. i18n: file: configwindow.ui:342
#. i18n: ectx: property (toolTip), widget (QFontComboBox, fontComboBox_font)
#: po/rc.cpp:51 rc.cpp:51
msgid "Set font family"
msgstr "Укажите шрифт"
#. i18n: file: configwindow.ui:359
#. i18n: ectx: property (text), widget (QLabel, label_fontSize)
#: po/rc.cpp:54 rc.cpp:54
msgid "Font size"
msgstr "Размер шрифта"
#. i18n: file: configwindow.ui:391
#. i18n: ectx: property (toolTip), widget (QSpinBox, spinBox_fontSize)
#: po/rc.cpp:57 rc.cpp:57
msgid "Set font size"
msgstr "Укажите размер шрифта"
#. i18n: file: configwindow.ui:420
#. i18n: ectx: property (text), widget (QLabel, label_fontColor)
#: po/rc.cpp:60 rc.cpp:60
msgid "Font color"
msgstr "Цвет шрифта"
#. i18n: file: configwindow.ui:452
#. i18n: ectx: property (toolTip), widget (KColorCombo, kcolorcombo_fontColor)
#: po/rc.cpp:63 rc.cpp:63
msgid "Set font color"
msgstr "Укажите цвет шрифта"
#. i18n: file: configwindow.ui:469
#. i18n: ectx: property (text), widget (QLabel, label_fontWeight)
#: po/rc.cpp:66 rc.cpp:66
msgid "Font weight"
msgstr "Толщина шрифта"
#. i18n: file: configwindow.ui:501
#. i18n: ectx: property (toolTip), widget (QSpinBox, spinBox_fontWeight)
#: po/rc.cpp:69 rc.cpp:69
msgid "Set font weight"
msgstr "Укажите ширину шрифта"
#. i18n: file: configwindow.ui:533
#. i18n: ectx: property (text), widget (QLabel, label_fontStyle)
#: po/rc.cpp:72 rc.cpp:72
msgid "Font style"
msgstr "Стиль шрифта"
#. i18n: file: configwindow.ui:565
#. i18n: ectx: property (toolTip), widget (QComboBox, comboBox_fontStyle)
#: po/rc.cpp:75 rc.cpp:75
msgid "Set font style"
msgstr "Укажите стиль шрифта"
#. i18n: file: configwindow.ui:569
#. i18n: ectx: property (text), item, widget (QComboBox, comboBox_fontStyle)
#: po/rc.cpp:78 rc.cpp:78
msgid "normal"
msgstr "normal"
#. i18n: file: configwindow.ui:574
#. i18n: ectx: property (text), item, widget (QComboBox, comboBox_fontStyle)
#: po/rc.cpp:81 rc.cpp:81
msgid "italic"
msgstr "italic"
#. i18n: file: configwindow.ui:605
#. i18n: ectx: property (text), widget (QLabel, label_activeIcon)
#: po/rc.cpp:84 rc.cpp:84
msgid "Active icon"
msgstr "Иконка активного подключения"
#. i18n: file: configwindow.ui:638
#. i18n: ectx: property (text), widget (QLabel, label_inactiveIcon)
#: po/rc.cpp:90 rc.cpp:90
msgid "Inactive icon"
msgstr "Иконка неактивного подключения"
#: po/rc.cpp:94 rc.cpp:94
msgctxt "NAME OF TRANSLATORS"
msgid "Your names"
msgstr "Evgeniy Alekseev"
#: po/rc.cpp:95 rc.cpp:95
msgctxt "EMAIL OF TRANSLATORS"
msgid "Your emails"
msgstr "esalexeev@gmail.com"

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