148 Commits

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

9
.gitignore vendored
View File

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

2
AUTHORS Normal file
View File

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

60
CHANGELOG Normal file
View File

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

View File

@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
netctl-plasmoid
netctl-gui
Copyright (C) 2014 Evgeniy Alekseev
This program is free software: you can redistribute it and/or modify
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
netctl-plasmoid Copyright (C) 2014 Evgeniy Alekseev
netctl-gui Copyright (C) 2014 Evgeniy Alekseev
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

View File

@ -1,37 +1,86 @@
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
pkgname=kdeplasma-applets-netctl
_pkgname=netctl-plasmoid
pkgver=1.0.0
pkgbase=netctl-gui
pkgname=('netctl-gui' 'netctl-gui-qt4' 'kdeplasma-applets-netctl-gui')
pkgver=1.2.0
pkgrel=1
pkgdesc="Plasmoid written on C++ which interacts with netctl"
pkgdesc="Qt4/Qt5 GUI for netctl. Also provides a widget for KDE"
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"
url="http://arcanis.name/projects/netctl-gui"
license=('GPL3')
makedepends=('automoc4' 'cmake' 'kdelibs' 'qt5-base' 'qt5-tools')
optdepends=('kdebase-runtime: sudo support'
'kdeplasma-applets-netctl-gui: KDE widget'
'sudo: sudo support'
'wpa_actiond: netctl-auto support'
'wpa_supplicant: wifi support')
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
install="${pkgbase}.install"
md5sums=('5b3105a64bc162d30a41a2b3bcb06f0a')
prepare() {
if [[ -d ${srcdir}/build ]]; then
rm -rf "${srcdir}/build"
fi
mkdir "${srcdir}/build"
rm -rf "${srcdir}/"{build-plasmoid,build-qt4,build-qt5}
mkdir "${srcdir}/"{build-plasmoid,build-qt4,build-qt5}
}
build () {
cd "${srcdir}/build"
cmake ${_cmakekeys} ../${_pkgname}
build() {
cd "${srcdir}/build-plasmoid"
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DOCS:BOOL=0 \
-DBUILD_GUI:BOOL=0 \
-DBUILD_LIBRARY:BOOL=0 \
"../${pkgbase}"
make
cd "${srcdir}/build-qt4"
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DOCS:BOOL=0 \
-DBUILD_DATAENGINE:BOOL=0 \
-DBUILD_PLASMOID:BOOL=0 \
-DUSE_QT5:BOOL=0 \
"../${pkgbase}"
make
cd "${srcdir}/build-qt5"
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DOCS:BOOL=0 \
-DBUILD_DATAENGINE:BOOL=0 \
-DBUILD_PLASMOID:BOOL=0 \
"../${pkgbase}"
make
}
package() {
cd "${srcdir}/build"
package_kdeplasma-applets-netctl-gui() {
pkgdesc="A plasmoid, which interacts with netctl. A part of netctl-gui"
depends=('netctl' 'kdebase-workspace')
optdepends=('kdebase-runtime: sudo support'
'netctl-gui: graphical front-end'
'netctl-gui-qt4: graphical front-end'
'sudo: sudo support')
cd "${srcdir}/build-plasmoid"
make DESTDIR="${pkgdir}" install
}
package_netctl-gui() {
pkgdesc="Qt5 graphical front-end for netctl. A part of netctl-gui"
depends=('netctl' 'qt5-base' 'xdg-utils')
provides=('netctl-gui-qt4')
conflicts=('netctl-gui-qt4')
cd "${srcdir}/build-qt5"
make DESTDIR="${pkgdir}" install
}
package_netctl-gui-qt4() {
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
depends=('netctl' 'qt4')
provides=('netctl-gui')
conflicts=('netctl-gui')
cd "${srcdir}/build-qt4"
make DESTDIR="${pkgdir}" install
}

View File

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

View File

@ -1,22 +1,20 @@
#!/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 en.qm ru.qm netctl-gui.qm *.cppcheck"
VERSION=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $3}' | cut -c 1)
# create archive
[[ -e ${ARCHIVE}-${VERSION}.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
[[ -e ${ARCHIVE}-${VERSION}-src.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
cp -r "${SRCDIR}" "${ARCHIVE}"
for FILE in ${FILES[*]}; do cp "$FILE" "${ARCHIVE}"; done
for FILE in ${IGNORELIST[*]}; do rm -f "${ARCHIVE}/${FILE}"; done
tar cvJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}" > /dev/null
for FILE in ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done
for FILE in ${IGNORELIST[*]}; do find "${ARCHIVE}" -name "${FILE}" -exec rm -rf {} \;; done
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
rm -rf "${ARCHIVE}"
# update md5sum
MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" PKGBUILD

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,48 +5,67 @@ cmake_policy (SET CMP0002 OLD)
cmake_policy (SET CMP0011 NEW)
cmake_policy (SET CMP0015 NEW)
project (netctl-plasmoid)
project (netctl-gui)
set (PROJECT_AUTHOR "Evgeniy Alekseev")
set (PROJECT_CONTACT "esalexeev@gmail.com")
set (PROJECT_LICENSE "GPLv3")
set (PROJECT_VERSION_MAJOR 1)
set (PROJECT_VERSION_MINOR 0)
set (PROJECT_VERSION_MINOR 2)
set (PROJECT_VERSION_PATCH 0)
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
string (TIMESTAMP CURRENT_YEAR "%Y")
message (STATUS "Project: ${PROJECT_NAME}")
message (STATUS "Version: ${PROJECT_VERSION}")
message (STATUS "Build date: ${CURRENT_DATE}")
# install options
option (WITH_DEBUG_MODE "Build with debug mode" OFF)
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
# components
option (BUILD_GUI "Build GUI" ON)
option (BUILD_LIBRARY "Build library" ON)
option (BUILD_DATAENGINE "Build data engine" ON)
option (BUILD_PLASMOID "Build plasmoid" ON)
# verbose
set (CMAKE_VERBOSE_MAKEFILE ON)
if (BUILD_GUI)
set (BUILD_LIBRARY ON)
endif ()
if (BUILD_PLASMOID)
set (BUILD_DATAENGINE ON)
endif ()
# documentation
option (BUILD_DOCS "Build documentation and install headers" ON)
if (BUILD_DOCS)
set (BUILD_LIBRARY ON)
endif ()
# flags
if (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 (ADD_CXX_FLAGS "-Wall")
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
else ()
message (STATUS "Unknown compiler")
message (STATUS "Unknown compiler")
endif ()
if (BUILD_PLASMOID)
set (BUILD_DATAENGINE ON)
endif ()
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
add_subdirectory (icons)
# resources
set (PROJECT_LIBRARY netctlgui)
set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
add_subdirectory (${PROJECT_RESOURCE_DIR})
# components
if (BUILD_LIBRARY)
add_subdirectory (${PROJECT_LIBRARY})
endif()
if (BUILD_GUI)
add_subdirectory (gui)
add_subdirectory (gui)
endif ()
if (BUILD_DATAENGINE)
add_subdirectory (dataengine)
add_subdirectory (dataengine)
endif ()
if (BUILD_PLASMOID)
add_subdirectory (plasmoid)
add_subdirectory (plasmoid)
endif ()

View File

@ -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

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

View File

@ -1,26 +1,29 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with 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 <KGlobal>
#include <KStandardDirs>
#include <Plasma/DataContainer>
#include <QDir>
#include <QFile>
#include <QProcess>
#include <QTextCodec>
Netctl::Netctl(QObject *parent, const QVariantList &args)
@ -49,48 +52,60 @@ QStringList Netctl::sources() const
}
bool Netctl::readConfiguration()
void Netctl::readConfiguration()
{
// default configuration
checkExtIP = QString("false");
cmd = QString("/usr/bin/netctl");
extIpCmd = QString("wget -qO- http://ifconfig.me/ip");
ipCmd = QString("/usr/bin/ip");
netDir = QString("/sys/class/net/");
QMap<QString, QString> rawConfig;
rawConfig[QString("CMD")] = QString("/usr/bin/netctl");
rawConfig[QString("EXTIP")] = QString("false");
rawConfig[QString("EXTIPCMD")] = QString("wget -qO- http://ifconfig.me/ip");
rawConfig[QString("IPCMD")] = QString("/usr/bin/ip");
rawConfig[QString("NETDIR")] = QString("/sys/class/net/");
rawConfig[QString("NETCTLAUTOCMD")] = QString("/usr/bin/netctl-auto");
QString fileStr;
// FIXME: define configuration file
QFile confFile(QString(getenv("HOME")) + QString("/.kde4/share/config/netctl.conf"));
bool exists = confFile.open(QIODevice::ReadOnly);
if (!exists) {
confFile.setFileName("/usr/share/config/netctl.conf");
exists = confFile.open(QIODevice::ReadOnly);
if (!exists)
return false;
QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf");
QFile confFile(fileName);
if (!confFile.open(QIODevice::ReadOnly)) {
configuration = updateConfiguration(rawConfig);
return;
}
QString fileStr;
QStringList value;
while (true) {
fileStr = QString(confFile.readLine());
fileStr = QString(confFile.readLine()).trimmed();
if (fileStr[0] == QChar('#')) continue;
if (fileStr[0] == QChar(';')) continue;
if (!fileStr.contains(QChar('='))) continue;
value.clear();
for (int i=1; i<fileStr.split(QChar('=')).count(); i++)
value.append(fileStr.split(QChar('='))[i]);
rawConfig[fileStr.split(QChar('='))[0]] = value.join(QChar('='));
if (confFile.atEnd())
break;
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")) &&
(key != QString("NETCTLAUTOCMD")))
value.remove(QChar(' '));
config[key] = value;
}
return config;
}
@ -100,125 +115,142 @@ bool Netctl::sourceRequestEvent(const QString &name)
}
bool Netctl::updateSourceEvent(const QString &source)
QString Netctl::getCurrentProfile(const QString cmd)
{
QProcess command;
QString cmdOutput = QString("");
QString value = QString("");
if (source == QString("currentProfile")) {
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
if (cmdOutput != 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 cmdNetctl, const QString cmdNetctlAuto)
{
QProcess command;
QString status = QString("static");
// check netctl-auto
if (!getCurrentProfile(cmdNetctlAuto).isEmpty())
status = QString("netctl-auto");
else {
// check netctl
command.start(cmdNetctl + QString(" is-enabled ") + getCurrentProfile(cmdNetctl));
command.waitForFinished(-1);
if (command.exitCode() == 0)
status = QString("enabled");
}
return status;
}
bool Netctl::updateSourceEvent(const QString &source)
{
QString key = QString("value");
QString value = QString("");
if (source == QString("currentProfile")) {
value = getCurrentProfile(configuration[QString("NETCTLAUTOCMD")]);
if (value.isEmpty())
value = getCurrentProfile(configuration[QString("CMD")]);
}
else if (source == QString("extIp")) {
if (checkExtIP == QString("true")) {
command.start(extIpCmd);
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
if (cmdOutput != 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("NETCTLAUTOCMD")]).join(QChar(','));
if (value.isEmpty())
value = getProfileList(configuration[QString("CMD")]).join(QChar(','));
}
else if (source == QString("statusBool")) {
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
value = QString("false");
if (cmdOutput != 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("NETCTLAUTOCMD")]))
value = QString("true");
else if (getProfileStatus(configuration[QString("CMD")]))
value = QString("true");
else
value = QString("false");
}
else if (source == QString("statusString")) {
command.start(cmd + QString(" list"));
command.waitForFinished(-1);
cmdOutput = command.readAllStandardOutput();
QString currentProfile;
if (cmdOutput != 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")],
configuration[QString("NETCTLAUTOCMD")]);
}
setData(source, key, value);
return true;
}

View File

@ -1,18 +1,18 @@
/***************************************************************************
* This file is part of netctl-plasmoid *
* This file is part of netctl-gui *
* *
* netctl-plasmoid is free software: you can redistribute it and/or *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-plasmoid is distributed in the hope that it will be useful, *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with 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,33 @@
#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 cmdNetctl, const QString cmdNetctlAuto);
protected:
bool readConfiguration();
bool sourceRequestEvent(const QString &name);
bool updateSourceEvent(const QString &source);
QStringList sources() const;
private:
bool isNetctlAutoRunning();
// configuration
// enable check external IP
QString checkExtIP;
// path to netctl command
QString cmd;
// command to check external IP
QString extIpCmd;
// path to ip command
QString ipCmd;
// path to directory with network device configuration
QString netDir;
QMap<QString, QString> configuration;
void readConfiguration();
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
};
#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 ${PROJECT_RESOURCE_DIR})
set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations)
# executable path
set (EXECUTABLE_OUTPUT_PATH ${SUBPROJECT_BINARY_DIR})
@ -13,7 +15,10 @@ set (TARGETS "")
set (HEADERS "")
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
# build man
file (GLOB SUBPROJECT_MAN_IN *.1)
file (RELATIVE_PATH SUBPROJECT_MAN ${CMAKE_SOURCE_DIR} ${SUBPROJECT_MAN_IN})
configure_file (${SUBPROJECT_MAN_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN})
install (FILES ${SUBPROJECT}.desktop DESTINATION share/applications/)
install (FILES ${SUBPROJECT}-logo.png DESTINATION share/pixmaps/)
install (FILES ${SUBPROJECT}.png DESTINATION share/icons/hicolor/32x32/apps/)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_MAN} DESTINATION share/man/man1/)

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

@ -0,0 +1,64 @@
.TH netctl-gui 1 "@CURRENT_DATE@" "version @PROJECT_VERSION@" "USER COMMANDS"
.SH NAME
netctl-gui is a graphical interface for netctl
.SH SYNOPSIS
.B netctl-gui
[ --about ] [ --netctl-auto ] [ --settings ]
[ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]
[ -s PROFILE | --select PROFILE ]
[ --config FILE ] [ -d | --debug ] [ --default ]
[ --set-opts OPTIONS ] [ -t NUM | --tab NUM ]
[ -v | --version ] [ -i | --info ] [ -h | --help]
.SH DESCRIPTION
Graphical user interface for netctl written on C++ using Qt toolkit. Provides shared library for interaction with netctl and Plasmoid and DataEngine for KDE.
.SH OPTIONS
.TP
--about
show about window
.TP
--netctl-auto
show netctl-auto window
.TP
--settings
show settings window
.TP
-e, --essid ESSID
select ESSID ESSID. This option will set tab to 3 automatically
.TP
-o, --open PROFILE
open profile PROFILE. This option will set tab to 2 automatically
.TP
-s, --select PROFILE
select profile PROFILE. This option will set tab to 1 automatically
.TP
--config FILE
read configuration from file FILE
.TP
-d, --debug
print debug information
.TP
--default
start with default settings
.TP
--set-opts OPTIONS
set options OPTIONS for this run, comma separated. Example "LANGUAGE=en,NETCTL_PATH=/usr/bin/netctl"
.TP
-t, --tab NUM
open a tab with number NUM
.TP
-v, --version
show version and exit
.TP
-i, --info
show build information and exit
.TP
-h, --help
show this help and exit
.SH FILES
.TP
$HOME/.config/netctl-gui.conf
Configuration file
.SH AUTHOR
@PROJECT_AUTHOR@ <\fI@PROJECT_CONTACT@\fR>
.SH LICENSE
This software is licensed under @PROJECT_LICENSE@

View File

@ -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

@ -3,26 +3,69 @@ file (GLOB SOURCES *.cpp)
file (GLOB HEADERS *.h)
file (GLOB FORMS *.ui)
message (STATUS "${SUBPROJECT} Sources: ${SOURCES}")
message (STATUS "${SUBPROJECT} Headers: ${HEADERS}")
message (STATUS "${SUBPROJECT} Forms: ${FORMS}")
file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts)
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources.qrc)
# include_path
include_directories (${SUBPROJECT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/include/
${CMAKE_CURRENT_BINARY_DIR}/../
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR})
link_directories (${PROJECT_LIBRARY}/src/lib)
find_package (Qt4 REQUIRED)
include (${QT_USE_FILE})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
qt4_wrap_ui (UI_HEADERS ${FORMS})
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 ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS})
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations COMMAND ${Qt5_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
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} ${PROJECT_LIBRARY} ${Qt5Widgets_LIBRARIES} ${Qt5Core_LIBRARIES})
else ()
find_package (Qt4 REQUIRED)
include (${QT_USE_FILE})
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
qt4_wrap_ui (UI_HEADERS ${FORMS})
qt4_add_resources (QRC_SOURCES ${RESOURCES})
foreach (LANGUAGE ${LANGUAGES})
set (TS ${LANGUAGE})
string (REPLACE ".ts" ".qm" QM ${TS})
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
add_custom_command (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
endforeach ()
add_custom_target (translations COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
add_custom_command (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES})
source_group ("Generated Files" FILES ${MOC_SOURCES})
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
target_link_libraries (${SUBPROJECT} ${PROJECT_LIBRARY} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
endif()
# install properties
install (TARGETS ${SUBPROJECT} DESTINATION bin)

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

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

View File

@ -0,0 +1,92 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "aboutwindow.h"
#include "ui_aboutwindow.h"
#include <QDebug>
#include <QDialogButtonBox>
#include <QPushButton>
#include "version.h"
AboutWindow::AboutWindow(QWidget *parent, const bool debugCmd)
: QMainWindow(parent),
ui(new Ui::AboutWindow),
debug(debugCmd)
{
ui->setupUi(this);
createUi();
}
AboutWindow::~AboutWindow()
{
if (debug) qDebug() << "[AboutWindow]" << "[~AboutWindow]";
delete uiAbout;
delete ui;
}
void AboutWindow::createText()
{
if (debug) qDebug() << "[AboutWindow]" << "[createText]";
uiAbout->label_name->setText(QString(NAME));
uiAbout->label_version->setText(QApplication::translate("AboutWindow", "Version %1\n(build date %2)")
.arg(QString(VERSION)).arg(QString(BUILD_DATE)));
uiAbout->label_description->setText(QApplication::translate("AboutWindow", "Qt-based graphical interface for netctl."));
uiAbout->label_links->setText(QApplication::translate("AboutWindow", "Links:") + QString("<br>") +
QString("<a href=\"%1\">%2</a><br>").arg(QString(HOMEPAGE)).arg(QApplication::translate("AboutWindow", "Homepage")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(REPOSITORY)).arg(QApplication::translate("AboutWindow", "Repository")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(BUGTRACKER)).arg(QApplication::translate("AboutWindow", "Bugtracker")) +
QString("<a href=\"%1\">%2</a><br>").arg(QString(TRANSLATION)).arg(QApplication::translate("AboutWindow", "Translation issue")) +\
QString("<a href=\"%1\">%2</a>").arg(QString(AUR_PACKAGES)).arg(QApplication::translate("AboutWindow", "AUR packages")));
uiAbout->label_license->setText(QString("<small>&copy; %1 <a href=\"mailto:%2\">%3</a><br>").arg(QString(DATE)).arg(QString(EMAIL)).arg(QString(AUTHOR)) +
QApplication::translate("AboutWindow", "This software is licensed under %1").arg(QString(LICENSE)) +
QString("</small>"));
}
void AboutWindow::createUi()
{
if (debug) qDebug() << "[AboutWindow]" << "[createUi]";
QWidget *aboutWidget = new QWidget();
uiAbout = new Ui::About;
uiAbout->setupUi(aboutWidget);
ui->verticalLayout->addWidget(aboutWidget);
createText();
QDialogButtonBox *buttonBox = new QDialogButtonBox;
buttonBox->addButton(QDialogButtonBox::Close);
ui->verticalLayout->addWidget(buttonBox);
connect(buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
}
// ESC press event
void AboutWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << "[AboutWindow]" << "[keyPressEvent]";
if (pressedKey->key() == Qt::Key_Escape)
close();
}

View File

@ -0,0 +1,51 @@
/***************************************************************************
* 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 ABOUTWINDOW_H
#define ABOUTWINDOW_H
#include <QKeyEvent>
#include <QMainWindow>
#include "ui_about.h"
namespace Ui {
class AboutWindow;
}
class AboutWindow : public QMainWindow
{
Q_OBJECT
public:
explicit AboutWindow(QWidget *parent = 0,
const bool debugCmd = false);
~AboutWindow();
private:
Ui::AboutWindow *ui;
Ui::About *uiAbout;
bool debug;
void createText();
void createUi();
// ESC pressed event
void keyPressEvent(QKeyEvent *pressedKey);
};
#endif /* ABOUTWINDOW_H */

View File

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

View File

@ -0,0 +1,81 @@
/***************************************************************************
* 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)
{
clear();
QMap<QString, QString> bridgeSettings = settings;
if (bridgeSettings.contains(QString("SkipForwardingDelay")))
if (bridgeSettings[QString("SkipForwardingDelay")] == 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,223 @@
/***************************************************************************
* 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 <QApplication>
#include <QGridLayout>
#include <QSpacerItem>
#include <QDebug>
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
: debug(debugCmd)
{
}
ErrorWindow::~ErrorWindow()
{
if (debug) qDebug() << "[ErrorWindow]" << "[~ErrorWindow]";
}
QStringList ErrorWindow::getMessage(const int mess)
{
if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]";
if (debug) qDebug() << "[ErrorWindow]" << "[getMessage]" << ":" << "Message" << mess;
QString message, title;
switch(mess) {
case 1:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not find components");
break;
case 2:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Does not support yet");
break;
case 3:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Profile name is not set");
break;
case 4:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Bind interfaces are not set");
break;
case 5:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Description is not set");
break;
case 6:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Ip settings are not set");
break;
case 7:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Configuration file does not exist");
break;
case 8:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Key is not set");
break;
case 9:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Wireless settings are not set");
break;
case 10:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Configuration file is not set");
break;
case 11:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "ESSID is not set");
break;
case 12:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "MAC address is incorrect");
break;
case 13:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Session ID is not set");
break;
case 14:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "APN is not set");
break;
case 15:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "APN is not set");
break;
case 16:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Empty user/group name");
break;
case 17:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not find profile");
break;
case 18:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Could not find ESSID");
break;
default:
title = QApplication::translate("ErrorWindow", "Error!");
message = QApplication::translate("ErrorWindow", "Unknown error");
break;
}
QStringList fullMessage;
fullMessage.append(title);
fullMessage.append(message);
return fullMessage;
}
QMessageBox::Icon ErrorWindow::getIcon(const int mess)
{
if (debug) qDebug() << "[ErrorWindow]" << "[getIcon]";
if (debug) qDebug() << "[ErrorWindow]" << "[getIcon]" << ":" << "Message" << mess;
QMessageBox::Icon icon;
switch(mess) {
case 1:
icon = QMessageBox::Critical;
break;
case 2:
icon = QMessageBox::Critical;
break;
case 3:
icon = QMessageBox::Critical;
break;
case 4:
icon = QMessageBox::Critical;
break;
case 5:
icon = QMessageBox::Critical;
break;
case 6:
icon = QMessageBox::Critical;
break;
case 7:
icon = QMessageBox::Critical;
break;
case 8:
icon = QMessageBox::Critical;
break;
case 9:
icon = QMessageBox::Critical;
break;
case 10:
icon = QMessageBox::Critical;
break;
case 11:
icon = QMessageBox::Critical;
break;
case 12:
icon = QMessageBox::Critical;
break;
case 13:
icon = QMessageBox::Critical;
break;
case 14:
icon = QMessageBox::Critical;
break;
case 15:
icon = QMessageBox::Critical;
break;
case 16:
icon = QMessageBox::Critical;
break;
case 17:
icon = QMessageBox::Critical;
break;
case 18:
icon = QMessageBox::Critical;
break;
default:
icon = QMessageBox::NoIcon;
break;
}
return icon;
}
void ErrorWindow::showWindow(const int mess, const QString sender)
{
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]";
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Message" << mess;
if (debug) qDebug() << "[ErrorWindow]" << "[showWindow]" << ":" << "Sender" << sender;
QStringList message = getMessage(mess);
QMessageBox messageBox;
messageBox.setText(message[0]);
messageBox.setInformativeText(message[1]);
if (debug)
messageBox.setDetailedText(QApplication::translate("ErrorWindow", "Sender : %1").
arg(sender));
messageBox.setIcon(getIcon(mess));
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.setDefaultButton(QMessageBox::Ok);
QSpacerItem *horizontalSpacer = new QSpacerItem(400, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
QGridLayout *layout = (QGridLayout *)messageBox.layout();
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
messageBox.exec();
return;
}

View File

@ -0,0 +1,45 @@
/***************************************************************************
* 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 <QMessageBox>
#include <QObject>
class ErrorWindow : public QObject
{
Q_OBJECT
public:
explicit ErrorWindow(QWidget *parent = 0,
const bool debugCmd = false);
~ErrorWindow();
public slots:
void showWindow(const int mess = 0,
const QString sender = QString());
private:
bool debug;
QStringList getMessage(const int mess);
QMessageBox::Icon getIcon(const int mess);
};
#endif /* ERRORWINDOW_H */

View File

@ -0,0 +1,165 @@
/***************************************************************************
* 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)
{
clear();
QMap<QString, QString> ethernetSettings = settings;
if (ethernetSettings.contains(QString("SkipNoCarrier")))
if (ethernetSettings[QString("SkipNoCarrier")] == QString("yes"))
ui->checkBox_skip->setCheckState(Qt::Checked);
if (ethernetSettings.contains(QString("Auth8021X")))
if (ethernetSettings[QString("Auth8021X")] == QString("yes"))
ui->checkBox_8021x->setCheckState(Qt::Checked);
if (ethernetSettings.contains(QString("WPAConfigFile")))
ui->lineEdit_wpaConfig->setText(ethernetSettings[QString("WPAConfigFile")]);
if (ethernetSettings.contains(QString("WPADriver")))
for (int i=0; i<ui->comboBox_driver->count(); i++)
if (ethernetSettings[QString("WPADriver")] == 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,205 @@
/***************************************************************************
* 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(QChar(' '));
}
if (ui->listWidget_after->count() != 0) {
QStringList profiles;
for (int i=0; i<ui->listWidget_after->count(); i++)
profiles.append(ui->listWidget_after->item(i)->text());
generalSettings[QString("After")] = profiles.join(QChar(' '));
}
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)
{
clear();
QMap<QString, QString> generalSettings = settings;
if (generalSettings.contains(QString("Description")))
ui->lineEdit_description->setText(generalSettings[QString("Description")]);
if (generalSettings.contains(QString("Connection")))
for (int i=0; i<ui->comboBox_connection->count(); i++)
if (generalSettings[QString("Connection")] == ui->comboBox_connection->itemText(i))
ui->comboBox_connection->setCurrentIndex(i);
if (generalSettings.contains(QString("Interface"))) {
ui->comboBox_interface->addItem(generalSettings[QString("Interface")]);
ui->comboBox_interface->setCurrentIndex(ui->comboBox_interface->count()-1);
}
if (generalSettings.contains(QString("BindsToInterfaces")))
ui->listWidget_bindto->addItems(generalSettings[QString("BindsToInterfaces")].split(QChar('\n')));
if (generalSettings.contains(QString("After")))
ui->listWidget_after->addItems(generalSettings[QString("After")].split(QChar('\n')));
if (generalSettings.contains(QString("ExecUpPost")))
ui->lineEdit_execUpPost->setText(generalSettings[QString("ExecUpPost")]);
if (generalSettings.contains(QString("ExecDownPre")))
ui->lineEdit_execDownPre->setText(generalSettings[QString("ExecDownPre")]);
if (generalSettings.contains(QString("ForceConnect")))
if (generalSettings[QString("ForceConnect")] == QString("yes"))
ui->checkBox_forceConnect->setCheckState(Qt::Checked);
if (generalSettings.contains(QString("NETCTL_DEBUG")))
if (generalSettings[QString("NETCTL_DEBUG")] == 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,359 @@
<?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>429</width>
<height>535</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>
<item>
<property name="text">
<string notr="true">macvlan</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,562 @@
/***************************************************************************
* 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 <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(QChar('.'));
// 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(QChar('.'));
}
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(QChar(' ')).split(QChar('/'))[0]);
QString prefix = getPrefix(ui->lineEdit_ipAddress->text().remove(QChar(' ')).split(QChar('/'))[1]);
ui->listWidget_ipAddress->addItem(ip + QString("/") + prefix);
ui->lineEdit_ipAddress->clear();
}
void IpWidget::addIpRoutes()
{
QString ip = getIp(ui->lineEdit_ipRoutes->text().remove(QChar(' ')).split(QChar('/'))[0]);
QString prefix = getPrefix(ui->lineEdit_ipRoutes->text().remove(QChar(' ')).split(QChar('/'))[1]);
QString ipVia = getIp(ui->lineEdit_ipRoutes2->text().remove(QChar(' ')));
ui->listWidget_ipRoutes->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
ui->lineEdit_ipRoutes->clear();
ui->lineEdit_ipRoutes2->clear();
}
void IpWidget::addIp6()
{
QString ip = getIp6(ui->lineEdit_ipAddress6->text().remove(QChar(' ')).split(QChar('/'))[0]);
QString prefix = getPrefix6(ui->lineEdit_ipAddress6->text().remove(QChar(' ')).split(QChar('/'))[1]);
ui->listWidget_ipAddress6->addItem(ip + QString("/") + prefix);
ui->lineEdit_ipAddress6->clear();
}
void IpWidget::addIpRoutes6()
{
QString ip = getIp6(ui->lineEdit_ipRoutes6->text().remove(QChar(' ')).split(QChar('/'))[0]);
QString prefix = getPrefix6(ui->lineEdit_ipRoutes6->text().remove(QChar(' ')).split(QChar('/'))[1]);
QString ipVia = getIp6(ui->lineEdit_ipRoutes62->text().remove(QChar(' ')));
ui->listWidget_ipRoutes6->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
ui->lineEdit_ipRoutes6->clear();
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(QChar(' ')));
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(QChar(' '));
ipSettings[QString("Gateway")] = QString("'") + ui->lineEdit_gateway->text() + QString("'");
}
if (ui->listWidget_ipRoutes->count() > 0) {
QStringList routes;
for (int i=0; i<ui->listWidget_ipRoutes->count(); i++)
routes.append(QString("'") + ui->listWidget_ipRoutes->item(i)->text() + QString("'"));
ipSettings[QString("Routes")] = routes.join(QChar(' '));
}
}
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(QChar(' '));
ipSettings[QString("Gateway6")] = QString("'") + ui->lineEdit_gateway6->text() + QString("'");
}
if (ui->listWidget_ipRoutes6->count() > 0) {
QStringList routes;
for (int i=0; i<ui->listWidget_ipRoutes6->count(); i++)
routes.append(QString("'") + ui->listWidget_ipRoutes6->item(i)->text() + QString("'"));
ipSettings[QString("Routes6")] = routes.join(QChar(' '));
}
}
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(QChar(' '));
}
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(QChar(' '));
}
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(QChar(' '));
}
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)
{
clear();
QMap<QString, QString> ipSettings = settings;
if (ipSettings.contains(QString("IP"))) {
if (ipSettings[QString("IP")] == QString("no"))
ui->checkBox_ip->setCheckState(Qt::Unchecked);
else {
ui->checkBox_ip->setCheckState(Qt::Checked);
for (int i=0; i<ui->comboBox_ip->count(); i++)
if (ipSettings[QString("IP")] == ui->comboBox_ip->itemText(i))
ui->comboBox_ip->setCurrentIndex(i);
}
}
if (ipSettings.contains(QString("Address")))
ui->listWidget_ipAddress->addItems(ipSettings[QString("Address")].split(QChar('\n')));
if (ipSettings.contains(QString("Gateway")))
ui->lineEdit_gateway->setText(ipSettings[QString("Gateway")]);
if (ipSettings.contains(QString("Routes")))
ui->listWidget_ipRoutes->addItems(ipSettings[QString("Routes")].split(QChar('\n')));
if (ipSettings.contains(QString("IP6"))) {
if (ipSettings[QString("IP6")] == QString("no"))
ui->checkBox_ip6->setCheckState(Qt::Unchecked);
else {
ui->checkBox_ip6->setCheckState(Qt::Checked);
for (int i=0; i<ui->comboBox_ip6->count(); i++)
if (ipSettings[QString("IP6")] == ui->comboBox_ip6->itemText(i))
ui->comboBox_ip6->setCurrentIndex(i);
}
}
if (ipSettings.contains(QString("Address6")))
ui->listWidget_ipAddress6->addItems(ipSettings[QString("Address6")].split(QChar('\n')));
if (ipSettings.contains(QString("Gateway6")))
ui->lineEdit_gateway6->setText(ipSettings[QString("Gateway6")]);
if (ipSettings.contains(QString("Routes6")))
ui->listWidget_ipRoutes6->addItems(ipSettings[QString("Routes6")].split(QChar('\n')));
if (ipSettings.contains(QString("IPCustom")))
ui->listWidget_custom->addItems(ipSettings[QString("IPCustom")].split(QChar('\n')));
if (ipSettings.contains(QString("Hostname")))
ui->lineEdit_hostname->setText(ipSettings[QString("Hostname")]);
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")] == ui->comboBox_dhcp->itemText(i))
ui->comboBox_dhcp->setCurrentIndex(i);
if (ipSettings.contains(QString("DhcpcdOptions")))
ui->lineEdit_dhcpcdOpt->setText(ipSettings[QString("DhcpcdOptions")]
.remove(QChar('\'')).remove(QChar('"')));
if (ipSettings.contains(QString("DhclientOptions")))
ui->lineEdit_dhclientOpt->setText(ipSettings[QString("DhclientOptions")]);
if (ipSettings.contains(QString("DhclientOptions6")))
ui->lineEdit_dhclientOpt6->setText(ipSettings[QString("DhclientOptions6")]);
if (ipSettings.contains(QString("TimeoutDHCP")))
ui->spinBox_timeoutDhcp->setValue(ipSettings[QString("TimeoutDHCP")].toInt());
if (ipSettings.contains(QString("DHCPReleaseOnStop")))
if (ipSettings[QString("DHCPReleaseOnStop")] == QString("yes"))
ui->checkBox_dhcp->setCheckState(Qt::Checked);
if (ipSettings.contains(QString("DNS")))
ui->listWidget_dns->addItems(ipSettings[QString("DNS")].split(QChar('\n')));
if (ipSettings.contains(QString("DNSDomain")))
ui->lineEdit_dnsDomain->setText(ipSettings[QString("DNSDomain")]);
if (ipSettings.contains(QString("DNSSearch")))
ui->lineEdit_dnsSearch->setText(ipSettings[QString("DNSSearch")]);
if (ipSettings.contains(QString("DNSOptions")))
ui->listWidget_dnsOptions->addItems(ipSettings[QString("DNSOptions")].split(QChar('\n')));
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>

View File

@ -0,0 +1,113 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "language.h"
#include <QFile>
#include <QLocale>
Language::Language()
{
}
QString Language::checkLanguage(const QString language, const QString defaultLanguage)
{
QStringList availableLanguages = getAvailableLanguages();
for (int i=0; i<availableLanguages.count(); i++)
if (language == availableLanguages[i])
return availableLanguages[i];
for (int i=0; i<availableLanguages.count(); i++)
if (language.contains(availableLanguages[i] + QChar('_')))
return availableLanguages[i];
return defaultLanguage;
}
QString Language::defineLanguage(const QString configPath, const QString options)
{
QMap<QString, QString> optionsDict = parseOptions(options);
if (optionsDict.contains(QString("LANGUAGE")))
if (getAvailableLanguages().contains(optionsDict[QString("LANGUAGE")]))
return optionsDict[QString("LANGUAGE")];
QString language;
language = defineLanguageFromFile(configPath);
if (language.isEmpty())
language = defineLanguageFromLocale();
language = checkLanguage(language, QString("en"));
return language;
}
QString Language::defineLanguageFromFile(const QString configPath)
{
QString language;
if (configPath.isEmpty())
return language;
QFile configFile(configPath);
QString fileStr;
if (!configFile.open(QIODevice::ReadOnly))
return language;
while (true) {
fileStr = QString(configFile.readLine());
if (fileStr[0] == QChar('#')) continue;
if (fileStr.contains(QString("LANGUAGE=")))
language = fileStr.split(QChar('='))[1]
.remove(QChar(' '))
.trimmed();
if (configFile.atEnd())
break;
}
configFile.close();
return language;
}
QString Language::defineLanguageFromLocale()
{
return QLocale::system().name();
}
QStringList Language::getAvailableLanguages()
{
QStringList languages;
languages.append(QString("en"));
languages.append(QString("ru"));
return languages;
}
QMap<QString, QString> Language::parseOptions(const QString options)
{
QMap<QString, QString> optionsDict;
for (int i=0; i<options.split(QChar(',')).count(); i++) {
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2)
continue;
optionsDict[options.split(QChar(','))[i].split(QChar('='))[0]] =
options.split(QChar(','))[i].split(QChar('='))[1];
}
return optionsDict;
}

View File

@ -0,0 +1,43 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef LANGUAGE_H
#define LANGUAGE_H
#include <QStringList>
class Language : public QObject
{
Q_OBJECT
public:
explicit Language();
static QString checkLanguage(const QString language,
const QString defaultLanguage = QString("en"));
static QString defineLanguage(const QString configPath,
const QString options = QString("OPTIONS"));
static QString defineLanguageFromFile(const QString configPath);
static QString defineLanguageFromLocale();
static QStringList getAvailableLanguages();
private:
static QMap<QString, QString> parseOptions(const QString options);
};
#endif /* LANGUAGE_H */

View File

@ -0,0 +1,94 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "macvlanwidget.h"
#include "ui_macvlanwidget.h"
MacvlanWidget::MacvlanWidget(QWidget *parent)
: QWidget(parent),
ui(new Ui::MacvlanWidget)
{
ui->setupUi(this);
createFilter();
}
MacvlanWidget::~MacvlanWidget()
{
delete ui;
}
void MacvlanWidget::clear()
{
ui->comboBox_mode->setCurrentIndex(0);
ui->lineEdit_mac->clear();
}
void MacvlanWidget::setShown(const bool state)
{
if (state)
show();
else
hide();
}
void MacvlanWidget::createFilter()
{
// mac
ui->lineEdit_mac->setInputMask(QString(">HH:HH:HH:HH:HH:HH"));
}
QMap<QString, QString> MacvlanWidget::getSettings()
{
QMap<QString, QString> macvlanSettings;
if (isOk() != 0)
return macvlanSettings;
macvlanSettings[QString("Mode")] = ui->comboBox_mode->currentText();
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
macvlanSettings[QString("MACAddress")] = ui->lineEdit_mac->text();
return macvlanSettings;
}
int MacvlanWidget::isOk()
{
// all fine
return 0;
}
void MacvlanWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> macvlanSettings = settings;
if (macvlanSettings.contains(QString("Mode")))
for (int i=0; i<ui->comboBox_mode->count(); i++)
if (macvlanSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
ui->comboBox_mode->setCurrentIndex(i);
if (macvlanSettings.contains(QString("MACAddress")))
ui->lineEdit_mac->setText(macvlanSettings[QString("MACAddress")]);
}

View File

@ -0,0 +1,49 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef MACVLANWIDGET_H
#define MACVLANWIDGET_H
#include <QWidget>
namespace Ui {
class MacvlanWidget;
}
class MacvlanWidget : public QWidget
{
Q_OBJECT
public:
explicit MacvlanWidget(QWidget *parent = 0);
~MacvlanWidget();
QMap<QString, QString> getSettings();
int isOk();
void setSettings(const QMap<QString, QString> settings);
public slots:
void clear();
void setShown(const bool state);
private:
Ui::MacvlanWidget *ui;
void createFilter();
};
#endif /* MACVLANWIDGET_H */

View File

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

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

@ -0,0 +1,275 @@
/***************************************************************************
* 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 <QTranslator>
#include <iostream>
#include "language.h"
#include "mainwindow.h"
#include "version.h"
using namespace std;
QChar isParametrEnable(const bool parametr)
{
if (parametr)
return QChar('*');
else
return QChar(' ');
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// translation
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
QDir::separator() + QString("netctl-gui.conf");
QString language = Language::defineLanguage(configPath);
QTranslator translator;
translator.load(QString(":/translations/") + language);
a.installTranslator(&translator);
// reading command line flags
bool error = false;
// windows
bool showAbout = false;
bool showNetctlAuto = false;
bool showSettings = false;
// main functions
QString selectEssid = QString("ESSID");
QString openProfile = QString("PROFILE");
QString selectProfile = QString("PROFILE");
// additional functions
bool debug = false;
bool defaultSettings = false;
QString options = QString("OPTIONS");
int tabNumber = 1;
// messages
bool showVersion = false;
bool showInfo = false;
bool showHelp = false;
// reading
for (int i=1; i<argc; i++) {
// windows
// about
if (QString(argv[i]) == QString("--about")) {
showAbout = true;
}
// netctl-auto
else if (QString(argv[i]) == QString("--netctl-auto")) {
showNetctlAuto = true;
}
// settings
else if (QString(argv[i]) == QString("--settings")) {
showSettings = true;
}
// main functions
// select ESSID
else if ((QString(argv[i]) == QString("-e")) || (QString(argv[i]) == QString("--essid"))) {
selectEssid = QString(argv[i+1]);
i++;
}
// open profile
else if ((QString(argv[i]) == QString("-o")) || (QString(argv[i]) == QString("--open"))) {
openProfile = QString(argv[i+1]);
i++;
}
// select profile
else if ((QString(argv[i]) == QString("-s")) || (QString(argv[i]) == QString("--select"))) {
selectProfile = QString(argv[i+1]);
i++;
}
// additional functions
// config path
else if (QString(argv[i]) == QString("--config")) {
configPath = QString(argv[i+1]);
i++;
}
// debug
else if ((QString(argv[i]) == QString("-d")) || (QString(argv[i]) == QString("--debug"))) {
debug = true;
}
// default settings
else if (QString(argv[i]) == QString("--default")) {
defaultSettings = true;
}
// options
else if (QString(argv[i]) == QString("--set-opts")) {
options = QString(argv[i+1]);
i++;
}
// tab number
else if ((QString(argv[i]) == QString("-t")) || (QString(argv[i]) == QString("--tab"))) {
if (atoi(argv[i+1]) > 3)
tabNumber = 3;
else if (atoi(argv[i+1]) < 1)
tabNumber = 1;
else
tabNumber = atoi(argv[i+1]);
i++;
}
// messages
// version message
else if ((QString(argv[i]) == QString("-v")) || (QString(argv[i]) == QString("--version"))) {
showVersion = true;
}
// info message
else if ((QString(argv[i]) == QString("-i")) || (QString(argv[i]) == QString("--info"))) {
showInfo = true;
}
// help message
else if ((QString(argv[i]) == QString("-h")) || (QString(argv[i]) == QString("--help"))) {
showHelp = true;
}
else {
error = true;
}
}
if (selectEssid != QString("ESSID"))
tabNumber = 3;
if (openProfile != QString("PROFILE"))
tabNumber = 2;
if (selectProfile != QString("PROFILE"))
tabNumber = 1;
// messages
QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n");
QString helpMessage = QString("");
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Usage:"));
helpMessage += QString("netctl-gui [ --about ] [ --netctl-auto ] [ --settings ]\n");
helpMessage += QString(" [ -e ESSID | --essid ESSID ] [ -o PROFILE | --open PROFILE ]\n");
helpMessage += QString(" [ -s PROFILE | --select PROFILE ]\n");
helpMessage += QString(" [ --config FILE ] [ -d | --debug ] [ --default ]\n");
helpMessage += QString(" [ --set-opts OPTIONS ] [ -t NUM | --tab NUM ]\n");
helpMessage += QString(" [ -v | --version ] [ -i | --info ] [ -h | --help]\n\n");
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Parametrs:"));
// windows
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Open window:"));
helpMessage += QString("%1 --about - %2\n")
.arg(isParametrEnable(showAbout))
.arg(QApplication::translate("MainWindow", "show about window"));
helpMessage += QString("%1 --netctl-auto - %2\n")
.arg(isParametrEnable(showNetctlAuto))
.arg(QApplication::translate("MainWindow", "show netctl-auto window"));
helpMessage += QString("%1 --settings - %2\n")
.arg(isParametrEnable(showSettings))
.arg(QApplication::translate("MainWindow", "show settings window"));
// main functions
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Functions:"));
helpMessage += QString(" -e %1 --essid %1 - %2\n")
.arg(selectEssid, -10)
.arg(QApplication::translate("MainWindow", "select ESSID %1").arg(selectEssid));
helpMessage += QString(" -o %1 --open %1 - %2\n")
.arg(openProfile, -10)
.arg(QApplication::translate("MainWindow", "open profile %1").arg(openProfile));
helpMessage += QString(" -s %1 --select %1 - %2\n")
.arg(selectProfile, -10)
.arg(QApplication::translate("MainWindow", "select profile %1").arg(selectProfile));
// additional functions
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Additional flags:"));
helpMessage += QString(" --config %1\n")
.arg(configPath, -10);
helpMessage += QString(" - %1\n")
.arg(QApplication::translate("MainWindow", "read configuration from this file"));
helpMessage += QString("%1 -d --debug - %2\n")
.arg(isParametrEnable(debug))
.arg(QApplication::translate("MainWindow", "print debug information"));
helpMessage += QString("%1 --default - %2\n")
.arg(isParametrEnable(defaultSettings))
.arg(QApplication::translate("MainWindow", "start with default settings"));
helpMessage += QString(" --set-opts %1\n")
.arg(options, -10);
helpMessage += QString(" - %1\n")
.arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
helpMessage += QString(" -t %1 --tab %1 - %2\n")
.arg(QString::number(tabNumber), -3)
.arg(QApplication::translate("MainWindow", "open a tab with number %1").arg(QString::number(tabNumber)));
// messages
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Show messages:"));
helpMessage += QString(" -v --version - %1\n")
.arg(QApplication::translate("MainWindow", "show version and exit"));
helpMessage += QString(" -i --info - %1\n")
.arg(QApplication::translate("MainWindow", "show build information and exit"));
helpMessage += QString(" -h --help - %1\n")
.arg(QApplication::translate("MainWindow", "show this help and exit"));
QString infoMessage = QString("");
infoMessage += QApplication::translate("MainWindow", "Build date: %1").
arg(QString(BUILD_DATE));
infoMessage += QString("\n%1\n").arg(QApplication::translate("MainWindow", "cmake flags:"));
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1 \\\n").arg(QString(CMAKE_BUILD_TYPE));
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1 \\\n").arg(QString(CMAKE_INSTALL_PREFIX));
infoMessage += QString("\t-DBUILD_DOCS=%1 \\\n").arg(QString(PROJECT_BUILD_DOCS));
infoMessage += QString("\t-DBUILD_LIBRARY=%1 \\\n").arg(QString(PROJECT_BUILD_LIBRARY));
infoMessage += QString("\t-DBUILD_GUI=%1 \\\n").arg(QString(PROJECT_BUILD_GUI));
infoMessage += QString("\t-DUSE_QT5=%1 \\\n").arg(QString(PROJECT_USE_QT5));
infoMessage += QString("\t-DBUILD_DATAENGINE=%1 \\\n").arg(QString(PROJECT_BUILD_DATAENGINE));
infoMessage += QString("\t-DBUILD_PLASMOID=%1\n").arg(QString(PROJECT_BUILD_PLASMOID));
QString versionMessage = QString("");
versionMessage += QString("%1\n").arg(QString(NAME));
versionMessage += QString("%1 : %2\n")
.arg(QApplication::translate("MainWindow", "Version"))
.arg(QString(VERSION));
versionMessage += QString("%1 : %2\n")
.arg(QApplication::translate("MainWindow", "Author"))
.arg(QString(AUTHOR));
versionMessage += QString("%1 : %2\n")
.arg(QApplication::translate("MainWindow", "License"))
.arg(QString(LICENSE));
// reread translations
a.removeTranslator(&translator);
language = Language::defineLanguage(configPath, options);
translator.load(QString(":/translations/") + language);
a.installTranslator(&translator);
// running
if (error) {
cout << errorMessage.toUtf8().data() << endl;
cout << helpMessage.toUtf8().data();
return 127;
}
if (showInfo) {
cout << versionMessage.toUtf8().data() << endl;
cout << infoMessage.toUtf8().data();
return 0;
}
if (showHelp) {
cout << helpMessage.toUtf8().data();
return 0;
}
if (showVersion) {
cout << versionMessage.toUtf8().data();
return 0;
}
MainWindow w(0,
showAbout, showNetctlAuto, showSettings,
selectEssid, openProfile, selectProfile,
configPath, debug, defaultSettings, options, tabNumber);
w.show();
return a.exec();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,142 @@
/***************************************************************************
* 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 AboutWindow;
class BridgeWidget;
class ErrorWindow;
class EthernetWidget;
class GeneralWidget;
class IpWidget;
class MacvlanWidget;
class MobileWidget;
class Netctl;
class NetctlAutoWindow;
class NetctlProfile;
class PasswdWidget;
class PppoeWidget;
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 showAbout = false,
const bool showNetctlAuto = false,
const bool showSettings = false,
const QString selectEssid = QString("ESSID"),
const QString openProfile = QString("PROFILE"),
const QString selectProfile = QString("PROFILE"),
const QString configPath = QString(""),
const bool debugCmd = false,
const bool defaultSettings = false,
const QString options = QString("OPTIONS"),
const int tabNum = 1);
~MainWindow();
public slots:
void updateTabs(const int tab);
void updateMenu(const int tab);
// wifi tab slots
void connectToUnknownEssid(const QString passwd);
void setHiddenName(const QString name);
private slots:
// menu update slots
void setMenuActionsShown(const bool state = true);
void updateMenuMain();
void updateMenuProfile();
void updateMenuWifi();
// tab update slots
void updateMainTab();
void updateProfileTab();
void updateWifiTab();
// main tab slots
void mainTabContextualMenu(const QPoint &pos);
void mainTabEditProfile();
void mainTabRemoveProfile();
void mainTabEnableProfile();
void mainTabRestartProfile();
void mainTabStartProfile();
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
// profile tab slots
void profileTabChangeState(const QString current);
void profileTabClear();
void profileTabCreateProfile();
void profileTabLoadProfile();
void profileTabRemoveProfile();
// wifi tab slots
void wifiTabContextualMenu(const QPoint &pos);
void wifiTabSetEnabled(const bool state);
void wifiTabStart();
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
private:
// ui
Ui::MainWindow *ui;
AboutWindow *aboutWin;
ErrorWindow *errorWin;
NetctlAutoWindow *netctlAutoWin;
PasswdWidget *passwdWid;
SettingsWindow *settingsWin;
BridgeWidget *bridgeWid;
EthernetWidget *ethernetWid;
GeneralWidget *generalWid;
IpWidget *ipWid;
MacvlanWidget *macvlanWid;
MobileWidget *mobileWid;
PppoeWidget *pppoeWid;
TunnelWidget *tunnelWid;
TuntapWidget *tuntapWid;
VlanWidget *vlanWid;
WirelessWidget *wirelessWid;
// backend
Netctl *netctlCommand;
NetctlProfile *netctlProfile;
WpaSup *wpaCommand;
bool checkExternalApps(const QString apps);
bool checkState(const QString state, const QString item);
void createActions();
void keyPressEvent(QKeyEvent *pressedKey);
void setIconsToButtons();
bool debug;
bool hiddenNetwork;
// configuration
QMap<QString, QString> configuration;
QMap<QString, QString> parseOptions(const QString options);
};
#endif /* MAINWINDOW_H */

View File

@ -0,0 +1,587 @@
<?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>479</width>
<height>507</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="QWidget" name="widget_netctlAuto" native="true">
<layout class="QHBoxLayout" name="layout_netctlAuto">
<item>
<widget class="QLabel" name="label_netctlAuto">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>netctl-auto is running</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_netctlAuto">
<property name="text">
<string>Show</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QTableWidget" name="tableWidget_main">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<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_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="QComboBox" name="comboBox_profile">
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="editable">
<bool>true</bool>
</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>96</width>
<height>26</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>
<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="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>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>479</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuMenu">
<property name="title">
<string>Menu</string>
</property>
<addaction name="actionNetctlAuto"/>
<addaction name="actionSettings"/>
<addaction name="actionQuit"/>
</widget>
<widget class="QMenu" name="menuActions">
<property name="title">
<string>Actions</string>
</property>
<addaction name="actionMainRefresh"/>
<addaction name="actionWifiRefresh"/>
<addaction name="actionProfileClear"/>
<addaction name="separator"/>
<addaction name="actionMainStart"/>
<addaction name="actionMainRestart"/>
<addaction name="actionMainEnable"/>
<addaction name="actionProfileLoad"/>
<addaction name="actionProfileSave"/>
<addaction name="actionWifiStart"/>
<addaction name="separator"/>
<addaction name="actionMainEdit"/>
<addaction name="actionMainRemove"/>
<addaction name="actionProfileRemove"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Help</string>
</property>
<addaction name="actionAbout"/>
</widget>
<addaction name="menuMenu"/>
<addaction name="menuActions"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionSettings">
<property name="icon">
<iconset theme="configure">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Settings</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action>
<action name="actionQuit">
<property name="icon">
<iconset theme="exit">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Quit</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action>
<action name="actionMainRefresh">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Refresh</string>
</property>
</action>
<action name="actionMainStart">
<property name="icon">
<iconset theme="dialog-apply">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Start profile</string>
</property>
</action>
<action name="actionMainRestart">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Restart profile</string>
</property>
</action>
<action name="actionMainEnable">
<property name="icon">
<iconset theme="edit-add">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Enable profile</string>
</property>
</action>
<action name="actionMainEdit">
<property name="icon">
<iconset theme="edit">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Edit profile</string>
</property>
</action>
<action name="actionMainRemove">
<property name="icon">
<iconset theme="edit-delete">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Remove profile</string>
</property>
</action>
<action name="actionProfileClear">
<property name="icon">
<iconset theme="edit-clear">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Clear</string>
</property>
</action>
<action name="actionWifiRefresh">
<property name="icon">
<iconset theme="stock-refresh">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Refresh</string>
</property>
</action>
<action name="actionProfileLoad">
<property name="icon">
<iconset theme="document-open">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Load profile</string>
</property>
</action>
<action name="actionProfileSave">
<property name="icon">
<iconset theme="document-save">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Save profile</string>
</property>
</action>
<action name="actionWifiStart">
<property name="icon">
<iconset theme="dialog-apply">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Start Wi-Fi</string>
</property>
</action>
<action name="actionProfileRemove">
<property name="icon">
<iconset theme="edit-delete">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Remove profile</string>
</property>
</action>
<action name="actionNetctlAuto">
<property name="text">
<string>netctl-auto</string>
</property>
</action>
<action name="actionAbout">
<property name="icon">
<iconset theme="help-about"/>
</property>
<property name="text">
<string>About</string>
</property>
</action>
</widget>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>tableWidget_main</tabstop>
<tabstop>pushButton_mainRefresh</tabstop>
<tabstop>pushButton_mainRestart</tabstop>
<tabstop>pushButton_mainStart</tabstop>
<tabstop>scrollArea</tabstop>
<tabstop>pushButton_profileClear</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,171 @@
/***************************************************************************
* 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)
{
clear();
QMap<QString, QString> mobileSettings = settings;
if (mobileSettings.contains(QString("User")))
ui->lineEdit_username->setText(mobileSettings[QString("User")]);
if (mobileSettings.contains(QString("Password")))
ui->lineEdit_password->setText(mobileSettings[QString("Password")]);
if (mobileSettings.contains(QString("AccessPointName")))
ui->lineEdit_apn->setText(mobileSettings[QString("AccessPointName")]);
if (mobileSettings.contains(QString("PIN")))
ui->lineEdit_pin->setText(mobileSettings[QString("PIN")]);
if (mobileSettings.contains(QString("Mode")))
for (int i=0; i<ui->comboBox_mode->count(); i++)
if (mobileSettings[QString("Mode")] == 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")] == QString("false"))
ui->checkBox_route->setCheckState(Qt::Unchecked);
if (mobileSettings.contains(QString("UsePeerDNS")))
if (mobileSettings[QString("UsePeerDNS")] == QString("false"))
ui->checkBox_dns->setCheckState(Qt::Unchecked);
if (mobileSettings.contains(QString("OptionsFile")))
ui->lineEdit_options->setText(mobileSettings[QString("OptionsFile")]);
}

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,377 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "netctlautowindow.h"
#include "ui_netctlautowindow.h"
#include <QDebug>
#include <netctlgui/netctlinteract.h>
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const QMap<QString, QString> settings)
: QMainWindow(parent),
ui(new Ui::NetctlAutoWindow),
debug(debugCmd)
{
ui->setupUi(this);
netctlCommand = new Netctl(debug, settings);
createActions();
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Ready"));
}
NetctlAutoWindow::~NetctlAutoWindow()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[~NetctlAutoWindow]";
delete ui;
delete netctlCommand;
}
void NetctlAutoWindow::createActions()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[createActions]";
// menu actions
connect(ui->actionClose, SIGNAL(triggered(bool)), this, SLOT(close()));
connect(ui->actionDisableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoDisableAllProfiles()));
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableProfile()));
connect(ui->actionEnableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableAllProfiles()));\
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(netctlAutoUpdateTable()));
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartProfile()));
// service
connect(ui->actionEnableService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableService()));
connect(ui->actionRestartService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoRestartService()));
connect(ui->actionStartService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartService()));
// table actions
connect(ui->tableWidget, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(netctlAutoStartProfile()));
connect(ui->tableWidget, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(netctlAutoRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(netctlAutoContextualMenu(QPoint)));
// buttons
connect(ui->pushButton_enable, SIGNAL(clicked(bool)), this, SLOT(netctlAutoEnableProfile()));
connect(ui->pushButton_refresh, SIGNAL(clicked(bool)), this, SLOT(netctlAutoUpdateTable()));
connect(ui->pushButton_switch, SIGNAL(clicked(bool)), this, SLOT(netctlAutoStartProfile()));
}
void NetctlAutoWindow::showWindow()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[showWindow]";
netctlAutoUpdateTable();
show();
}
void NetctlAutoWindow::netctlAutoUpdateTable()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoUpdateTable]";
ui->tableWidget->setDisabled(true);
QList<QStringList> profiles = netctlCommand->getProfileListFromNetctlAuto();
// actions
if (netctlCommand->isNetctlAutoEnabled())
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
else
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
ui->actionEnableService->setVisible(true);
if (netctlCommand->isNetctlAutoRunning()) {
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
ui->actionRestartService->setVisible(true);
}
else {
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
ui->actionRestartService->setVisible(false);
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running"));
netctlAutoRefreshButtons(0, 0);
return;
}
ui->tableWidget->setSortingEnabled(false);
ui->tableWidget->selectRow(-1);
ui->tableWidget->sortByColumn(0, Qt::AscendingOrder);
ui->tableWidget->clear();
ui->tableWidget->setRowCount(profiles.count());
// create header
QStringList headerList;
headerList.append(QApplication::translate("NetctlAutoWindow", "Name"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Description"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Active"));
headerList.append(QApplication::translate("NetctlAutoWindow", "Disabled"));
ui->tableWidget->setHorizontalHeaderLabels(headerList);
// create items
for (int i=0; i<profiles.count(); i++) {
// name
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(profiles[i][0]));
ui->tableWidget->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
if (profiles[i][2] == QString("*")) {
QFont font;
font.setBold(true);
ui->tableWidget->item(i, 0)->setFont(font);
}
else if (profiles[i][2] == QString("!")) {
QFont font;
font.setItalic(true);
ui->tableWidget->item(i, 0)->setFont(font);
}
// description
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i][1]));
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
if (profiles[i][2] == QString("*")) {
// active
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QApplication::translate("NetctlAutoWindow", "yes")));
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
else
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(QString("")));
if (profiles[i][2] == QString("!")) {
// disabled
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(QApplication::translate("NetctlAutoWindow", "yes")));
ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
}
else
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(QString("")));
}
ui->tableWidget->setSortingEnabled(true);
ui->tableWidget->resizeRowsToContents();
#if QT_VERSION >= 0x050000
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
#else
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
#endif
ui->tableWidget->setEnabled(true);
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated"));
netctlAutoRefreshButtons(0, 0);
update();
}
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]";
if (ui->tableWidget->currentItem() == 0)
return;
// create menu
QMenu menu(this);
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
startProfile->setIcon(QIcon::fromTheme("dialog-apply"));
QAction *enableProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable profile"));
menu.addSeparator();
QAction *enableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Enable all profiles"));
enableAllProfiles->setIcon(QIcon::fromTheme("edit-add"));
QAction *disableAllProfiles = menu.addAction(QApplication::translate("NetctlAutoWindow", "Disable all profiles"));
disableAllProfiles->setIcon(QIcon::fromTheme("edit-delete"));
// set text
if (ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text() == QString("yes")) {
enableProfile->setVisible(false);
startProfile->setVisible(false);
}
else {
enableProfile->setVisible(true);
startProfile->setVisible(true);
if (ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text() == QString("yes")) {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
enableProfile->setIcon(QIcon::fromTheme("edit-add"));
}
else {
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
}
}
// actions
QAction *action = menu.exec(ui->tableWidget->viewport()->mapToGlobal(pos));
if (action == startProfile) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Switch to profile";
netctlAutoStartProfile();
}
else if (action == enableProfile) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable profile";
netctlAutoEnableProfile();
}
else if (action == enableAllProfiles) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Enable all profiles";
netctlAutoEnableAllProfiles();
}
else if (action == disableAllProfiles) {
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoContextualMenu]" << "Disable all profiles";
netctlAutoDisableAllProfiles();
}
}
void NetctlAutoWindow::netctlAutoDisableAllProfiles()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoDisableAllProfiles]";
ui->tableWidget->setDisabled(true);
if (netctlCommand->autoDisableAllProfiles())
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoEnableProfile()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableProfile]";
if (ui->tableWidget->currentItem() == 0)
return;
ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
if (netctlCommand->autoEnableProfile(profile))
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoEnableAllProfiles()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableAllProfiles]";
ui->tableWidget->setDisabled(true);
if (netctlCommand->autoEnableAllProfiles())
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoStartProfile()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoStartProfile]";
if (ui->tableWidget->currentItem() == 0)
return;
ui->tableWidget->setDisabled(true);
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
if (netctlCommand->autoStartProfile(profile))
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoEnableService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoEnableService]";
if (netctlCommand->autoEnableService())
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoRestartService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoRestartService]";
if (netctlCommand->autoRestartService())
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoStartService()
{
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoStartService]";
if (netctlCommand->autoStartService())
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
else
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
netctlAutoUpdateTable();
}
void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
{
Q_UNUSED(previous);
if (debug) qDebug() << "[NetctlAutoWindow]" << "[netctlAutoRefreshButtons]";
if (current == 0) {
// buttons
ui->pushButton_enable->setDisabled(true);
ui->pushButton_switch->setDisabled(true);
// menu
ui->actionEnable->setVisible(false);
ui->actionSwitch->setVisible(false);
return;
}
if (ui->tableWidget->item(current->row(), 2)->text() == QString("yes")) {
// buttons
ui->pushButton_enable->setDisabled(true);
ui->pushButton_switch->setDisabled(true);
// menu
ui->actionEnable->setVisible(false);
ui->actionSwitch->setVisible(false);
}
else {
// buttons
ui->pushButton_enable->setEnabled(true);
ui->pushButton_switch->setEnabled(true);
// menu
ui->actionEnable->setVisible(true);
ui->actionSwitch->setVisible(true);
if (ui->tableWidget->item(current->row(), 3)->text() == QString("yes")) {
// buttons
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-add"));
// menu
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable profile"));
ui->actionEnable->setIcon(QIcon::fromTheme("edit-add"));
}
else {
// buttons
ui->pushButton_enable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
ui->pushButton_enable->setIcon(QIcon::fromTheme("edit-delete"));
// menu
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable profile"));
ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete"));
}
}
}

View File

@ -0,0 +1,68 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#ifndef NETCTLAUTOWINDOW_H
#define NETCTLAUTOWINDOW_H
#include <QKeyEvent>
#include <QMainWindow>
#include <QTableWidgetItem>
class Netctl;
namespace Ui {
class NetctlAutoWindow;
}
class NetctlAutoWindow : public QMainWindow
{
Q_OBJECT
public:
explicit NetctlAutoWindow(QWidget *parent = 0,
const bool debugCmd = false,
const QMap<QString, QString> settings = QMap<QString, QString>());
~NetctlAutoWindow();
public slots:
void showWindow();
private slots:
// table
void netctlAutoContextualMenu(const QPoint &pos);
void netctlAutoUpdateTable();
// netctl-auto
void netctlAutoDisableAllProfiles();
void netctlAutoEnableProfile();
void netctlAutoEnableAllProfiles();
void netctlAutoStartProfile();
void netctlAutoRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
// service
void netctlAutoEnableService();
void netctlAutoRestartService();
void netctlAutoStartService();
private:
Netctl *netctlCommand;
Ui::NetctlAutoWindow *ui;
bool debug;
void createActions();
};
#endif /* NETCTLAUTOWINDOW_H */

View File

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

View File

@ -0,0 +1,92 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
#include "passwdwidget.h"
#include "ui_passwdwidget.h"
#include <QLineEdit>
#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::setPassword(const bool mode)
{
if (mode) {
ui->lineEdit->setEchoMode(QLineEdit::Password);
ui->label->setText(QApplication::translate("PasswdWidget", "Password"));
}
else {
ui->lineEdit->setEchoMode(QLineEdit::Normal);
ui->label->setText(QApplication::translate("PasswdWidget", "ESSID"));
}
}
void PasswdWidget::cancel()
{
hide();
parent->updateTabs(2);
this->~PasswdWidget();
}
void PasswdWidget::passwdApply()
{
hide();
if (ui->lineEdit->echoMode() == QLineEdit::Normal)
return parent->setHiddenName(ui->lineEdit->text());
else
return parent->connectToUnknownEssid(ui->lineEdit->text());
}

View File

@ -0,0 +1,57 @@
/***************************************************************************
* 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();
void setPassword(const bool mode = true);
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,242 @@
/***************************************************************************
* 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().remove(QChar(':')).remove(QChar(' ')).isEmpty())
pppoeSettings[QString("PPPoESession")] = QString("'") + ui->lineEdit_session->text()
.remove(QChar('\'')).remove(QChar('"')) + QString("'");
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
pppoeSettings[QString("PPPoEMAC")] = QString("'") + ui->lineEdit_mac->text() + QString("'");
if (ui->checkBox_ipv6->checkState() == Qt::Checked)
pppoeSettings[QString("PPPoEIP6")] = QString("yes");
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().remove(QChar(':')).remove(QChar(' ')).isEmpty())
if (ui->lineEdit_mac->text().contains(QChar(' ')))
return 2;
// session id is not set
if (!ui->lineEdit_session->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
if (ui->lineEdit_session->text().split(QChar(':'))[0].remove(QChar(' ')).isEmpty())
return 3;
// session mac address
if (!ui->lineEdit_session->text().remove(QChar(':')).remove(QChar(' ')).isEmpty()) {
QStringList item = ui->lineEdit_session->text().split(QChar(':'));
for (int i=1; i<7; i++)
if (item[i].contains(QChar(' ')))
return 4;
}
// all fine
return 0;
}
void PppoeWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> pppoeSettings = settings;
if (pppoeSettings.contains(QString("User")))
ui->lineEdit_username->setText(pppoeSettings[QString("User")]);
if (pppoeSettings.contains(QString("Password")))
ui->lineEdit_password->setText(pppoeSettings[QString("Password")]);
if (pppoeSettings.contains(QString("ConnectionMode")))
for (int i=0; i<ui->comboBox_connection->count(); i++)
if (pppoeSettings[QString("ConnectionMode")] == 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")] == QString("false"))
ui->checkBox_route->setCheckState(Qt::Unchecked);
if (pppoeSettings.contains(QString("UsePeerDNS")))
if (pppoeSettings[QString("UsePeerDNS")] == 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")]);
if (pppoeSettings.contains(QString("PPPoEService")))
ui->lineEdit_service->setText(pppoeSettings[QString("PPPoEService")]);
if (pppoeSettings.contains(QString("PPPoEAC")))
ui->lineEdit_ac->setText(pppoeSettings[QString("PPPoEAC")]);
if (pppoeSettings.contains(QString("PPPoESession")))
ui->lineEdit_session->setText(pppoeSettings[QString("PPPoESession")]);
if (pppoeSettings.contains(QString("PPPoEMAC")))
ui->lineEdit_mac->setText(pppoeSettings[QString("PPPoEMAC")]);
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,392 @@
/***************************************************************************
* 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 "language.h"
SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QString configFile)
: QMainWindow(parent),
debug(debugCmd),
file(configFile),
ui(new Ui::SettingsWindow)
{
ui->setupUi(this);
addLanguages();
createActions();
}
SettingsWindow::~SettingsWindow()
{
if (debug) qDebug() << "[SettingsWindow]" << "[~SettingsWindow]";
delete ui;
}
void SettingsWindow::createActions()
{
if (debug) qDebug() << "[SettingsWindow]" << "[createActions]";
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(close()));
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(saveSettings()));
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(close()));
connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
// buttons
connect(ui->pushButton_interfaceDir, SIGNAL(clicked(bool)), SLOT(selectIfaceDir()));
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), SLOT(selectNetctlPath()));
connect(ui->pushButton_netctlAutoPath, SIGNAL(clicked(bool)), SLOT(selectNetctlAutoPath()));
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), SLOT(selectProfileDir()));
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), SLOT(selectRfkillDir()));
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), SLOT(selectSudoPath()));
connect(ui->pushButton_systemctlPath, SIGNAL(clicked(bool)), SLOT(selectSystemctlPath()));
connect(ui->pushButton_wpaActiondPath, SIGNAL(clicked(bool)), SLOT(selectWpaActiondPath()));
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), SLOT(selectWpaCliPath()));
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), SLOT(selectWpaSupPath()));
}
// ESC press event
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
{
if (debug) qDebug() << "[SettingsWindow]" << "[keyPressEvent]";
if (pressedKey->key() == Qt::Key_Escape)
close();
}
void SettingsWindow::addLanguages()
{
if (debug) qDebug() << "[SettingsWindow]" << "[addLanguages]";
ui->comboBox_language->clear();
ui->comboBox_language->addItems(Language::getAvailableLanguages());
}
void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
Q_UNUSED(previous)
if (debug) qDebug() << "[SettingsWindow]" << "[changePage]";
for (int i=0; i<ui->treeWidget->topLevelItemCount(); i++)
if (current == ui->treeWidget->topLevelItem(i)) {
ui->stackedWidget->setCurrentIndex(i);
break;
}
}
void SettingsWindow::saveSettings()
{
if (debug) qDebug() << "[SettingsWindow]" << "[saveSettings]";
QMap<QString, QString> settings = readSettings();
QFile configFile(file);
if (!configFile.open(QIODevice::WriteOnly | QIODevice::Text))
return;
QTextStream out(&configFile);
for (int i=0; i<settings.keys().count(); i++)
out << settings.keys()[i] << QString("=") << settings[settings.keys()[i]] << endl;
configFile.close();
}
void SettingsWindow::setDefault()
{
if (debug) qDebug() << "[SettingsWindow]" << "[setDefault]";
setSettings(getDefault());
saveSettings();
}
void SettingsWindow::selectIfaceDir()
{
if (debug) qDebug() << "[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()
{
if (debug) qDebug() << "[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::selectNetctlAutoPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectNetctlAutoPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select netctl-auto command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_netctlAutoPath->setText(filename);
}
void SettingsWindow::selectProfileDir()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectProfileDir]";
QString directory = QFileDialog::getExistingDirectory(
this,
QApplication::translate("SettingsWindow", "Select path to profile directory"),
QString("/etc/"));
if (!directory.isEmpty())
ui->lineEdit_profilePath->setText(directory);
}
void SettingsWindow::selectRfkillDir()
{
if (debug) qDebug() << "[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()
{
if (debug) qDebug() << "[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::selectSystemctlPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectSystemctlPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select systemctl command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_systemctlPath->setText(filename);
}
void SettingsWindow::selectWpaActiondPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaActiondPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select wpa_actiond command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_wpaActiondPath->setText(filename);
}
void SettingsWindow::selectWpaCliPath()
{
if (debug) qDebug() << "[SettingsWindow]" << "[selectWpaCliPath]";
QString filename = QFileDialog::getOpenFileName(
this,
QApplication::translate("SettingsWindow", "Select wpa_cli command"),
QString("/usr/bin/"),
QApplication::translate("SettingsWindow", "All files (*)"));
if (!filename.isEmpty())
ui->lineEdit_wpaCliPath->setText(filename);
}
void SettingsWindow::selectWpaSupPath()
{
if (debug) qDebug() << "[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()
{
if (debug) qDebug() << "[SettingsWindow]" << "[showWindow]";
setSettings(getSettings());
ui->label_info->hide();
show();
}
QMap<QString, QString> SettingsWindow::readSettings()
{
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]";
QMap<QString, QString> settings;
settings[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
settings[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->text();
settings[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
settings[QString("LANGUAGE")] = ui->comboBox_language->currentText();
settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
settings[QString("NETCTLAUTO_PATH")] = ui->lineEdit_netctlAutoPath->text();
settings[QString("NETCTLAUTO_SERVICE")] = ui->lineEdit_netctlAutoService->text();
settings[QString("PID_FILE")] = ui->lineEdit_pid->text();
settings[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
settings[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
settings[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
settings[QString("SUDO_PATH")] = ui->lineEdit_sudo->text();
settings[QString("SYSTEMCTL_PATH")] = ui->lineEdit_systemctlPath->text();
settings[QString("WPAACTIOND_PATH")] = ui->lineEdit_wpaActiondPath->text();
settings[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[SettingsWindow]" << "[readSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
{
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]";
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
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_netctlAutoPath->setText(settings[QString("NETCTLAUTO_PATH")]);
ui->lineEdit_netctlAutoService->setText(settings[QString("NETCTLAUTO_SERVICE")]);
ui->lineEdit_pid->setText(settings[QString("PID_FILE")]);
ui->lineEdit_interface->setText(settings[QString("PREFERED_IFACE")]);
ui->lineEdit_profilePath->setText(settings[QString("PROFILE_DIR")]);
ui->lineEdit_rfkill->setText(settings[QString("RFKILL_DIR")]);
ui->lineEdit_sudo->setText(settings[QString("SUDO_PATH")]);
ui->lineEdit_systemctlPath->setText(settings[QString("SYSTEMCTL_PATH")]);
ui->lineEdit_wpaActiondPath->setText(settings[QString("WPAACTIOND_PATH")]);
ui->lineEdit_wpaCliPath->setText(settings[QString("WPACLI_PATH")]);
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[SettingsWindow]" << "[setSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
}
QMap<QString, QString> SettingsWindow::getDefault()
{
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]";
QMap<QString, QString> settings;
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
settings[QString("CTRL_GROUP")] = QString("users");
settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
settings[QString("LANGUAGE")] = QString("en");
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");
settings[QString("NETCTLAUTO_PATH")] = QString("/usr/bin/netctl-auto");
settings[QString("NETCTLAUTO_SERVICE")] = QString("netctl-auto");
settings[QString("PID_FILE")] = QString("/run/wpa_supplicant_netctl-gui.pid");
settings[QString("PREFERED_IFACE")] = QString("");
settings[QString("PROFILE_DIR")] = QString("/etc/netctl/");
settings[QString("RFKILL_DIR")] = QString("/sys/class/rfkill/");
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl");
settings[QString("WPAACTIOND_PATH")] = QString("/usr/bin/wpa_actiond");
settings[QString("WPACLI_PATH")] = QString("/usr/bin/wpa_cli");
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[SettingsWindow]" << "[getDefault]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}
QMap<QString, QString> SettingsWindow::getSettings()
{
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]";
QMap<QString, QString> settings = getDefault();
QFile configFile(file);
QString fileStr;
if (!configFile.open(QIODevice::ReadOnly))
return settings;
while (true) {
fileStr = QString(configFile.readLine()).trimmed();
if (fileStr[0] == QChar('#')) continue;
if (fileStr[0] == QChar(';')) continue;
if (!fileStr.contains(QChar('='))) continue;
settings[fileStr.split(QChar('='))[0]] = fileStr.split(QChar('='))[1];
if (configFile.atEnd())
break;
}
configFile.close();
for (int i=0; i<settings.keys().count(); i++)
if (debug) qDebug() << "[SettingsWindow]" << "[getSettings]" << ":" <<
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
return settings;
}

View File

@ -0,0 +1,76 @@
/***************************************************************************
* 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>
#include <QTreeWidgetItem>
class MainWindow;
namespace Ui {
class SettingsWindow;
}
class SettingsWindow : public QMainWindow
{
Q_OBJECT
public:
explicit SettingsWindow(QWidget *parent = 0,
const bool debugCmd = false,
const QString configFile = QString(""));
~SettingsWindow();
QMap<QString, QString> getDefault();
QMap<QString, QString> getSettings();
public slots:
void setDefault();
void showWindow();
private slots:
void addLanguages();
void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void saveSettings();
// buttons
void selectIfaceDir();
void selectNetctlPath();
void selectNetctlAutoPath();
void selectProfileDir();
void selectRfkillDir();
void selectSudoPath();
void selectSystemctlPath();
void selectWpaActiondPath();
void selectWpaCliPath();
void selectWpaSupPath();
private:
bool debug;
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,810 @@
<?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>670</width>
<height>331</height>
</rect>
</property>
<property name="windowTitle">
<string>Settings</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTreeWidget" name="treeWidget">
<property name="maximumSize">
<size>
<width>180</width>
<height>16777215</height>
</size>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="indentation">
<number>0</number>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<property name="itemsExpandable">
<bool>false</bool>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
<column>
<property name="text">
<string/>
</property>
</column>
<item>
<property name="text">
<string>General</string>
</property>
<property name="icon">
<iconset theme="preferences-system">
<normaloff/>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>netctl</string>
</property>
<property name="icon">
<iconset resource="../../resources/resources.qrc">
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>sudo</string>
</property>
<property name="icon">
<iconset theme="gksu">
<normaloff/>
</iconset>
</property>
</item>
<item>
<property name="text">
<string>wpa_supplicant</string>
</property>
<property name="icon">
<iconset resource="../../resources/resources.qrc">
<normaloff>:/wifi.png</normaloff>:/wifi.png</iconset>
</property>
</item>
<item>
<property name="text">
<string>Other</string>
</property>
<property name="icon">
<iconset theme="configure">
<normaloff/>
</iconset>
</property>
</item>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page_general">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QScrollArea" name="scrollArea_general">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_general">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<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>424</width>
<height>223</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_netctl">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QScrollArea" name="scrollArea_netctl">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_netctl">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_systemctlPath">
<item>
<widget class="QLabel" name="label_systemctlPath">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>systemctl path</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_systemctlPath">
<property name="toolTip">
<string>Path to systemctl</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_systemctlPath">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<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_netctlAutoPath">
<item>
<widget class="QLabel" name="label_netctlAutoPath">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>netctl-auto path</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_netctlAutoPath">
<property name="toolTip">
<string>Path to netctl-auto</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_netctlAutoPath">
<property name="text">
<string>Browse</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_netctlAutoService">
<item>
<widget class="QLabel" name="label_netctlAutoService">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>netctl-auto service</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_netctlAutoService">
<property name="toolTip">
<string>Name of netctl-auto systemd service</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>424</width>
<height>122</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_sudo">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QScrollArea" name="scrollArea_sudo">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_sudo">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<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>424</width>
<height>244</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_wpaSup">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QScrollArea" name="scrollArea_wpaSup">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_wpaSup">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<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_wpaActiondPath">
<item>
<widget class="QLabel" name="label_wpaActiondPath">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>wpa_actiond path</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_wpaActiondPath">
<property name="toolTip">
<string>Path to wpa_actiond</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_wpaActiondPath">
<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>66</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_other">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QScrollArea" name="scrollArea_other">
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_other">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>454</width>
<height>270</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
<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>424</width>
<height>184</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</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>
<include location="../../resources/resources.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -0,0 +1,123 @@
/***************************************************************************
* 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(QChar('.'));
// 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(QChar('.'));
}
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().remove(QChar('.')).remove(QChar(' ')).isEmpty())
tunnelSettings[QString("Local")] = QString("'") + getIp(ui->lineEdit_local->text().remove(QChar(' '))) + QString("'");
if (!ui->lineEdit_remote->text().remove(QChar('.')).remove(QChar(' ')).isEmpty())
tunnelSettings[QString("Remote")] = QString("'") + getIp(ui->lineEdit_remote->text().remove(QChar(' '))) + QString("'");
return tunnelSettings;
}
int TunnelWidget::isOk()
{
// all fine
return 0;
}
void TunnelWidget::setSettings(const QMap<QString, QString> settings)
{
clear();
QMap<QString, QString> tunnelSettings = settings;
if (tunnelSettings.contains(QString("Mode")))
for (int i=0; i<ui->comboBox_mode->count(); i++)
if (tunnelSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
ui->comboBox_mode->setCurrentIndex(i);
if (tunnelSettings.contains(QString("Local")))
ui->lineEdit_local->setText(tunnelSettings[QString("Local")]);
if (tunnelSettings.contains(QString("Remote")))
ui->lineEdit_remote->setText(tunnelSettings[QString("Remote")]);
}

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,95 @@
/***************************************************************************
* 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)
{
clear();
QMap<QString, QString> tuntapSettings = settings;
if (tuntapSettings.contains(QString("Mode")))
for (int i=0; i<ui->comboBox_mode->count(); i++)
if (tuntapSettings[QString("Mode")] == ui->comboBox_mode->itemText(i))
ui->comboBox_mode->setCurrentIndex(i);
if (tuntapSettings.contains(QString("User")))
ui->lineEdit_user->setText(tuntapSettings[QString("User")]);
if (tuntapSettings.contains(QString("Group")))
ui->lineEdit_group->setText(tuntapSettings[QString("Group")]);
}

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,79 @@
/***************************************************************************
* 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)
{
clear();
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()).trimmed();
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(QChar('\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(QChar(' '));
}
if (ui->spinBox_frequency->value() != 2000)
wirelessSettings[QString("Frequency")] = QString::number(ui->spinBox_frequency->value());
if (ui->spinBox_priority->value() != 0)
wirelessSettings[QString("Priority")] = QString::number(ui->spinBox_priority->value());
if (!ui->lineEdit_country->text().isEmpty())
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(QChar(',')) + 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)
{
clear();
QMap<QString, QString> wirelessSettings = settings;
if (wirelessSettings.contains(QString("Security")))
for (int i=0; i<ui->comboBox_security->count(); i++)
if (wirelessSettings[QString("Security")] == ui->comboBox_security->itemText(i))
ui->comboBox_security->setCurrentIndex(i);
if (wirelessSettings.contains(QString("ESSID")))
ui->lineEdit_essid->setText(wirelessSettings[QString("ESSID")]);
if (wirelessSettings.contains(QString("Key"))) {
// workaround for wireless-wep example
if (wirelessSettings.contains(QString("Security")))
if ((wirelessSettings[QString("Security")] == QString("wep")) &&
(wirelessSettings[QString("Key")][0] == QChar('"')))
wirelessSettings[QString("Key")] = QChar('\\') + wirelessSettings[QString("Key")];
ui->lineEdit_key->setText(wirelessSettings[QString("Key")]);
}
if (wirelessSettings.contains(QString("WPAConfigSection")))
ui->listWidget_wpaConfigSection->addItems(wirelessSettings[QString("WPAConfigSection")].split(QChar('\n')));
if (wirelessSettings.contains(QString("WPAConfigFile")))
ui->lineEdit_wpaConfig->setText(wirelessSettings[QString("WPAConfigFile")]);
if (wirelessSettings.contains(QString("Hidden")))
if (wirelessSettings[QString("Hidden")] == QString("yes"))
ui->checkBox_hidden->setCheckState(Qt::Checked);
if (wirelessSettings.contains(QString("AdHoc")))
if (wirelessSettings[QString("AdHoc")] == QString("yes"))
ui->checkBox_adhoc->setCheckState(Qt::Checked);
if (wirelessSettings.contains(QString("ScanFrequencies")))
ui->listWidget_freq->addItems(wirelessSettings[QString("ScanFrequencies")].split(QChar('\n')));
if (wirelessSettings.contains(QString("Frequency")))
ui->spinBox_frequency->setValue(wirelessSettings[QString("Frequency")].toInt());
if (wirelessSettings.contains(QString("Priority")))
ui->spinBox_priority->setValue(wirelessSettings[QString("Priority")].toInt());
if (wirelessSettings.contains(QString("Country")))
ui->lineEdit_country->setText(wirelessSettings[QString("Country")]);
if (wirelessSettings.contains(QString("WPAGroup")))
ui->lineEdit_wpaGroup->setText(wirelessSettings[QString("WPAGroup")]);
if (wirelessSettings.contains(QString("WPADriver")))
ui->listWidget_drivers->addItems(wirelessSettings[QString("WPADriver")].split(QChar(',')));
if (wirelessSettings.contains(QString("RFKill")))
for (int i=0; i<ui->comboBox_rfkill->count(); i++)
if (wirelessSettings[QString("RFKill")] == 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")] == 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

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -0,0 +1,99 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file netctlprofile.h
* Header of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#ifndef NETCTLPROFILE_H
#define NETCTLPROFILE_H
#include <QDir>
#include <QMap>
#include <QObject>
/**
* @brief The NetctlProfile class interacts with netctl profiles
*/
class NetctlProfile : public QObject
{
Q_OBJECT
public:
/**
* @brief NetctlProfile class constructor
* @param debugCmd show debug messages
* @param settings default settings. Needed keys are
* PROFILE_DIR (path to directory which contains profiles),
* SUDO_PATH (path to sudo command)
*/
explicit NetctlProfile(const bool debugCmd = false,
const QMap<QString, QString> settings = QMap<QString, QString>());
/**
* @brief Netctl class destructor
*/
~NetctlProfile();
/**
* @brief method which copies temporary profile to PROFILE_DIR
* @param oldPath path to temprorary profile
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool copyProfile(const QString oldPath);
/**
* @brief method which creates temporary profile
* @param profile profile name
* @param settings profile configuration. All available keys will be printed to the profile
* @return temporary profile name
*/
QString createProfile(const QString profile, const QMap<QString, QString> settings);
/**
* @brief method which reads settings from profile
* @param profile profile name
* @return settings from profile
*/
QMap<QString, QString> getSettingsFromProfile(const QString profile);
/**
* @brief method which removes profile
* @param profile profile name
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool removeProfile(const QString profile);
private:
/**
* @brief show debug messages
*/
bool debug;
/**
* @brief directory which contains profiles. Default is "/etc/netctl"
*/
QDir *profileDirectory;
/**
* @brief path to sudo command. Default is "/usr/bin/kdesu"
*/
QString sudoCommand;
};
#endif /* NETCTLPROFILE_H */

View File

@ -0,0 +1,67 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file sleepthread.h
* Header of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#ifndef SLEEPTHREAD_H
#define SLEEPTHREAD_H
#include <QThread>
/**
* @brief The SleepThread class is used for sleep current thread in WpaSup class
*/
class SleepThread : public QThread
{
Q_OBJECT
public:
/**
* @brief method which forces the current thread to sleep for usecs microseconds
* @param iSleepTime time in microseconds
*/
static void usleep(long iSleepTime)
{
QThread::usleep(iSleepTime);
}
/**
* @brief method which forces the current thread to sleep for usecs seconds
* @param iSleepTime time in seconds
*/
static void sleep(long iSleepTime)
{
QThread::sleep(iSleepTime);
}
/**
* @brief method which forces the current thread to sleep for usecs milliseconds
* @param iSleepTime time in milliseconds
*/
static void msleep(long iSleepTime)
{
QThread::msleep(iSleepTime);
}
};
#endif /* SLEEPTHREAD_H */

View File

@ -0,0 +1,177 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file wpasupinteract.h
* Header of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#ifndef WPASUPINTERACT_H
#define WPASUPINTERACT_H
#include <QDir>
#include <QMap>
#include <QObject>
class Netctl;
/**
* @brief The WpaSup class interacts with wpa_supplicant
*/
class WpaSup : public QObject
{
Q_OBJECT
public:
/**
* @brief WpaSup class constructor
* @param debugCmd show debug messages
* @param settings default settings. Needed keys are
* CTRL_DIR (path to ctrl_directory),
* CTRL_GROUP (group which is owner of CTRL_DIR),
* IFACE_DIR (path to directory with interfaces),
* PREFERED_IFACE (prefered interface for WiFi),
* PID_FILE (wpa_supplicant PID file),
* SUDO_PATH (path to sudo command),
* WPACLI_PATH (path to wpa_cli command),
* WPA_DRIVERS (wpa_supplicant drivers comma separated),
* WPASUP_PATH (path to wpa_supplicant command)
*/
explicit WpaSup(const bool debugCmd = false,
const QMap<QString, QString> settings = QMap<QString, QString>());
/**
* @brief WpaSup class destructor
*/
~WpaSup();
// general information
/**
* @brief method which gets profile name by ESSID
* @param essid ESSID name
* @return profile name
*/
QString existentProfile(const QString essid);
/**
* @brief method which gets interface list from PREFERED_IFACE and IFACE_DIR
* @return interface list. If PREFERED_IFACE is not empty it will be first element
*/
QStringList getInterfaceList();
/**
* @brief method which checks profile status by ESSID
* @param essid ESSID name
* @return false if profile is inactive
* @return true if profile is active
*/
bool isProfileActive(const QString essid);
/**
* @brief method which checks profile existence by ESSID
* @param essid ESSID name
* @return false if profile does not exist
* @return true if profile exists
*/
bool isProfileExists(const QString essid);
public slots:
// functions
/**
* @brief method which scans WiFi networks
* @return list of essids. Available information is [NAME, NETCTL_STATUS, SIGNAL, SECUITY]:
* NAME is WiFi point name or "<hidden>",
* NETCTL_STATUS may be "new", "exist (active)", "exist (inactive)",
* SIGNAL is Wifi point signal,
* SECURITY may be "WPA2", "WEP", "WEP", "none"
*/
QList<QStringList> scanWifi();
/**
* @brief method which calls wpa_supplicant
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool startWpaSupplicant();
/**
* @brief method which send TERMINATE signal to wpa_supplicant
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool stopWpaSupplicant();
private:
/**
* @brief Netctl class
*/
Netctl *netctlCommand;
/**
* @brief show debug messages
*/
bool debug;
/**
* @brief path to ctrl_directory. Defaults is "/run/wpa_supplicant_netctl-gui"
*/
QString ctrlDir;
/**
* @brief group which is owner of CTRL_DIR. Default is "users"
*/
QString ctrlGroup;
/**
* @brief directory with interfaces. Default is "/sys/class/net/"
*/
QDir *ifaceDirectory;
/**
* @brief prefered interface for WiFi. Default is ""
*/
QString mainInterface;
/**
* @brief wpa_supplicant PID file. Default is "/run/wpa_supplicant_netctl-gui.pid"
*/
QString pidFile;
/**
* @brief path to sudo command. Default is "/usr/bin/kdesu"
*/
QString sudoCommand;
/**
* @brief path to wpa_cli command. Default is "/usr/bin/wpa_cli"
*/
QString wpaCliPath;
/**
* @brief wpa_supplicant drivers comma separated. Default is "nl80211,wext"
*/
QString wpaDrivers;
/**
* @brief path to wpa_supplicant command. Default is "/usr/bin/wpa_supplicant"
*/
QString wpaSupPath;
// functions
/**
* @brief method which calls wpa_cli and returns its output
* @param commandLine command which will be passed to wpa_cli
* @return wpa_cli output
*/
QString getWpaCliOutput(const QString commandLine);
/**
* @brief method which calls wpa_cli
* @param commandLine command which will be passed to wpa_cli
* @return false if components are not found or command exit code is not equal to 0
* @return true if the method was completed without errors
*/
bool wpaCliCall(const QString commandLine);
};
#endif /* WPASUPINTERACT_H */

View File

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

View File

@ -0,0 +1,41 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file main.cpp
* Source code of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#include <netctlgui/netctlinteract.h>
#include <netctlgui/netctlprofile.h>
#include <netctlgui/sleepthread.h>
#include <netctlgui/wpasupinteract.h>
/**
* @fn main
*/
int main(int argc, char *argv[])
/**
* @return 0 - exit without errors
*/
{
return 0;
}

View File

@ -0,0 +1,747 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file netctlinteract.cpp
* Source code of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#include <QDebug>
#include <QFile>
#include <QProcess>
#include <netctlgui/netctlinteract.h>
/**
* @class Netctl
*/
/**
* @fn Netctl
*/
Netctl::Netctl(const bool debugCmd, const QMap<QString, QString> settings)
: debug(debugCmd)
{
if (settings.contains(QString("IFACE_DIR")))
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
else
ifaceDirectory = new QDir(QString("/sys/class/net/"));
if (settings.contains(QString("PREFERED_IFACE")))
mainInterface = settings[QString("PREFERED_IFACE")];
else
mainInterface = QString("");
if (settings.contains(QString("NETCTL_PATH")))
netctlCommand = settings[QString("NETCTL_PATH")];
else
netctlCommand = QString("/usr/bin/netctl");
if (settings.contains(QString("NETCTLAUTO_PATH")))
netctlAutoCommand = settings[QString("NETCTLAUTO_PATH")];
else
netctlAutoCommand = QString("/usr/bin/netctl-auto");
if (settings.contains(QString("NETCTLAUTO_SERVICE")))
netctlAutoService = settings[QString("NETCTLAUTO_SERVICE")];
else
netctlAutoService = QString("netctl-auto");
if (settings.contains(QString("PROFILE_DIR")))
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
else
profileDirectory = new QDir(QString("/etc/netctl/"));
if (settings.contains(QString("SUDO_PATH")))
sudoCommand = settings[QString("SUDO_PATH")];
else
sudoCommand = QString("/usr/bin/kdesu");
if (settings.contains(QString("SYSTEMCTL_PATH")))
systemctlCommand = settings[QString("SYSTEMCTL_PATH")];
else
systemctlCommand = QString("/usr/bin/systemctl");
}
/**
* @fn ~Netctl
*/
Netctl::~Netctl()
{
if (debug) qDebug() << "[Netctl]" << "[~Netctl]";
if (ifaceDirectory != 0)
delete ifaceDirectory;
if (profileDirectory != 0)
delete profileDirectory;
}
// functions
/**
* @fn getNetctlOutput
*/
QString Netctl::getNetctlOutput(const bool sudo, const QString commandLine, const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]";
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Command" << commandLine;
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Profile" << profile;
if (netctlCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Could not find netctl";
return QString();
}
if ((sudo) && (sudoCommand == 0)) {
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Could not find sudo";
return QString();
}
QProcess command;
QString commandText;
if (sudo)
commandText = sudoCommand + QString(" ") + netctlCommand + QString(" ") + commandLine +
QString(" ") + profile;
else
commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile;
if (debug) qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
return command.readAllStandardOutput();
}
/**
* @fn getWifiInterface
*/
QString Netctl::getWifiInterface()
{
if (debug) qDebug() << "[Netctl]" << "[getInterfaceList]";
if (ifaceDirectory == 0) {
if (debug) qDebug() << "[Netctl]" << "[getInterfaceList]" << ":" << "Could not find directory";
return QString();
}
QStringList interfaces;
if (!mainInterface.isEmpty())
interfaces.append(mainInterface);
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i=0; i<allInterfaces.count(); i++) {
if (debug) qDebug() << "[Netctl]" << "[getInterfaceList]" << ":" << "Check directory"
<< ifaceDirectory->path() + QDir::separator() + allInterfaces[i] + QDir::separator() + QString("wireless");
if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] +
QDir::separator() + QString("wireless")).exists())
interfaces.append(allInterfaces[i]);
}
return interfaces[0];
}
/**
* @fn netctlCall
*/
bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[netctlCall]";
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Command" << commandLine;
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Profile" << profile;
if (netctlCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Could not find netctl";
return false;
}
if ((sudo) && (sudoCommand == 0)) {
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Could not find sudo";
return false;
}
QProcess command;
QString commandText;
if (sudo)
commandText = sudoCommand + QString(" ") + netctlCommand + QString(" ") + commandLine +
QString(" ") + profile;
else
commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile;
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (debug) qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() == 0)
return true;
else
return false;
}
/**
* @fn netctlAutoCall
*/
bool Netctl::netctlAutoCall(const bool sudo, const QString commandLine, const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]";
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Command" << commandLine;
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Profile" << profile;
if (netctlAutoCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Could not find netctl-auto";
return false;
}
if ((sudo) && (sudoCommand == 0)) {
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Could not find sudo";
return false;
}
QProcess command;
QString commandText;
if (sudo)
commandText = sudoCommand + QString(" ") + netctlAutoCommand + QString(" ") + commandLine;
else
commandText = netctlAutoCommand + QString(" ") + commandLine;
if (profile != 0)
commandText = commandText + QString(" ") + profile;
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (debug) qDebug() << "[Netctl]" << "[netctlAutoCall]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() == 0)
return true;
else
return false;
}
/**
* @fn systemctlCall
*/
bool Netctl::systemctlCall(const bool sudo, const QString commandLine)
{
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]";
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Command" << commandLine;
if (netctlAutoService == 0) {
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Could not find service";
return false;
}
if ((sudo) && (sudoCommand == 0)) {
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Could not find sudo";
return false;
}
if (systemctlCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Could not find systemctl";
return false;
}
QProcess command;
QString commandText;
QString interface = getWifiInterface();
if (sudo)
commandText = sudoCommand + QString(" ") + systemctlCommand + QString(" ") + commandLine +
QString(" ") + netctlAutoService + QString("@") + interface + QString(".service");
else
commandText = systemctlCommand + QString(" ") + commandLine + QString(" ") + netctlAutoService +
QString("@") + interface + QString(".service");
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (debug) qDebug() << "[Netctl]" << "[systemctlCall]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() == 0)
return true;
else
return false;
}
// general information
/**
* @fn getProfileList
*/
QList<QStringList> Netctl::getProfileList()
{
if (debug) qDebug() << "[Netctl]" << "[getProfileList]";
if (profileDirectory == 0) {
if (debug) qDebug() << "[Netctl]" << "[getProfileList]" << ":" << "Could not find directory";
return QList<QStringList>();
}
QList<QStringList> fullProfilesInfo;
QStringList profiles = profileDirectory->entryList(QDir::Files);
QStringList descriptions = getProfileDescriptions(profiles);
QStringList statuses = getProfileStatuses(profiles);
for (int i=0; i<profiles.count(); i++) {
QStringList profileInfo;
profileInfo.append(profiles[i]);
profileInfo.append(descriptions[i]);
profileInfo.append(statuses[i]);
fullProfilesInfo.append(profileInfo);
}
return fullProfilesInfo;
}
/**
* @fn getProfileListFromNetctlAuto
*/
QList<QStringList> Netctl::getProfileListFromNetctlAuto()
{
if (debug) qDebug() << "[Netctl]" << "[getProfileListFromNetctlAuto]";
if (netctlAutoCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[getProfileListFromNetctlAuto]" << ":" << "Could not find netctl-auto";
return QList<QStringList>();
}
QProcess command;
QString commandText = netctlAutoCommand + QString(" list");
if (debug) qDebug() << "[Netctl]" << "[getProfileListFromNetctlAuto]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
QStringList output = QString(command.readAllStandardOutput()).split(QChar('\n'), QString::SkipEmptyParts);
QList<QStringList> fullProfilesInfo;
for (int i=0; i<output.count(); i++) {
QStringList profileInfo;
profileInfo.append(output[i].mid(2, -1));
profileInfo.append(getProfileDescription(profileInfo[0]));
profileInfo.append(output[i].left(1));
fullProfilesInfo.append(profileInfo);
}
return fullProfilesInfo;
}
/**
* @fn getProfileDescription
*/
QString Netctl::getProfileDescription(const QString profileName)
{
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]";
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Profile" << profileName;
if (profileDirectory == 0) {
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Could not find directory";
return QString();
}
QString description = QString("<unknown>");
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profileName;
if (debug) qDebug() << "[Netctl]" << "[getProfileDescription]" << ":" << "Check" << profileUrl;
QFile profile(profileUrl);
QString fileStr;
if (!profile.open(QIODevice::ReadOnly))
return description;
while (true) {
fileStr = QString(profile.readLine());
if (fileStr[0] == QChar('#')) continue;
if (fileStr.split(QChar('='), QString::SkipEmptyParts).count() == 2)
if (fileStr.split(QChar('='), QString::SkipEmptyParts)[0] == QString("Description"))
description = fileStr.split(QChar('='), QString::SkipEmptyParts)[1].trimmed();
if (profile.atEnd())
break;
}
description.remove(QChar('\'')).remove(QChar('"'));
return description;
}
/**
* @fn getProfileDescriptions
*/
QStringList Netctl::getProfileDescriptions(const QStringList profileList)
{
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]";
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Profile list" << profileList;
if (profileDirectory == 0) {
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Could not find directory";
return QStringList();
}
QStringList descriptions;
for (int i=0; i<profileList.count(); i++) {
QString description = QString("<unknown>");
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profileList[i];
if (debug) qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Check" << profileUrl;
QFile profile(profileUrl);
QString fileStr;
if (!profile.open(QIODevice::ReadOnly)) {
descriptions.append(description);
continue;
}
while (true) {
fileStr = QString(profile.readLine());
if (fileStr[0] == QChar('#')) continue;
if (fileStr.split(QChar('='), QString::SkipEmptyParts).count() == 2)
if (fileStr.split(QChar('='), QString::SkipEmptyParts)[0] == QString("Description"))
description = fileStr.split(QChar('='), QString::SkipEmptyParts)[1].trimmed();
if (profile.atEnd())
break;
}
description.remove(QChar('\'')).remove(QChar('"'));
descriptions.append(description);
}
return descriptions;
}
/**
* @fn getProfileStatus
*/
QString Netctl::getProfileStatus(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[getProfileStatus]";
if (debug) qDebug() << "[Netctl]" << "[getProfileStatus]" << ":" << "Profile" << profile;
QString status;
if (isProfileActive(profile))
status = QString("active");
else
status = QString("inactive");
if (isProfileEnabled(profile))
status = status + QString(" (enabled)");
else
status = status + QString(" (static)");
return status;
}
/**
* @fn getProfileStatuses
*/
QStringList Netctl::getProfileStatuses(const QStringList profileList)
{
if (debug) qDebug() << "[Netctl]" << "[getProfileStatuses]";
if (debug) qDebug() << "[Netctl]" << "[getProfileStatuses]" << ":" << "Profile list" << profileList;
QStringList statuses;
for (int i=0; i<profileList.count(); i++) {
QString status;
if (isProfileActive(profileList[i]))
status = QString("active");
else
status = QString("inactive");
if (isProfileEnabled(profileList[i]))
status = status + QString(" (enabled)");
else
status = status + QString(" (static)");
statuses.append(status);
}
return statuses;
}
/**
* @fn getSsidFromProfile
*/
QString Netctl::getSsidFromProfile(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]";
if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Profile" << profile;
if (profileDirectory == 0) {
if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Could not find directory";
return QString();
}
QString ssidName;
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
if (debug) qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Check" << profileUrl;
QFile profileFile(profileUrl);
QString fileStr;
if (!profileFile.open(QIODevice::ReadOnly))
return ssidName;
while (true) {
fileStr = QString(profileFile.readLine());
if (fileStr[0] == QChar('#')) continue;
if (fileStr.split(QChar('='), QString::SkipEmptyParts).count() == 2)
if (fileStr.split(QChar('='), QString::SkipEmptyParts)[0] == QString("ESSID"))
ssidName = fileStr.split(QChar('='), QString::SkipEmptyParts)[1].trimmed();
if (profileFile.atEnd())
break;
}
profileFile.close();
ssidName.remove(QChar('\'')).remove(QChar('"'));
return ssidName;
}
/**
* @fn isProfileActive
*/
bool Netctl::isProfileActive(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[isProfileActive]";
if (debug) qDebug() << "[Netctl]" << "[isProfileActive]" << ":" << "Profile" << profile;
bool status = false;
QString cmdOutput = getNetctlOutput(false, QString("status"), profile);
if (cmdOutput.contains(QString("Active: active")))
status = true;
return status;
}
/**
* @fn isProfileEnabled
*/
bool Netctl::isProfileEnabled(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[isProfileEnabled]";
if (debug) qDebug() << "[Netctl]" << "[isProfileEnabled]" << ":" << "Profile" << profile;
return netctlCall(false, QString("is-enabled"), profile);
}
/**
* @fn autoIsProfileActive
*/
bool Netctl::autoIsProfileActive(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[autoIsProfileActive]";
if (debug) qDebug() << "[Netctl]" << "[autoIsProfileActive]" << ":" << "Profile" << profile;
bool status = false;
QList<QStringList> profiles = getProfileListFromNetctlAuto();
for (int i=0; i<profiles.count(); i++)
if ((profiles[i][0] == profile) && (profiles[i][2] == QString("*"))) {
status = true;
break;
}
return status;
}
/**
* @fn autoIsProfileEnabled
*/
bool Netctl::autoIsProfileEnabled(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[autoIsProfileEnabled]";
if (debug) qDebug() << "[Netctl]" << "[autoIsProfileEnabled]" << ":" << "Profile" << profile;
bool status = true;
QList<QStringList> profiles = getProfileListFromNetctlAuto();
for (int i=0; i<profiles.count(); i++)
if ((profiles[i][0] == profile) && (profiles[i][2] == QString("!"))) {
status = false;
break;
}
return status;
}
/**
* @fn isNetctlAutoEnabled
*/
bool Netctl::isNetctlAutoEnabled()
{
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]";
if (netctlAutoService == 0) {
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]" << ":" << "Could not find service";
return false;
}
if (systemctlCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]" << ":" << "Could not find systemctl";
return false;
}
QProcess command;
QString interface = getWifiInterface();
QString commandText = systemctlCommand + QString(" is-enabled ") + netctlAutoService + QString("@") +
interface + QString(".service");
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoEnabled]" << ":" << "Cmd returns" << command.exitCode();
QString output = command.readAllStandardOutput().trimmed();
if (output == QString("enabled"))
return true;
else
return false;
}
/**
* @fn isNetctlAutoRunning
*/
bool Netctl::isNetctlAutoRunning()
{
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]";
if (netctlAutoService == 0) {
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Could not find service";
return false;
}
if (systemctlCommand == 0) {
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Could not find systemctl";
return false;
}
QString interface = getWifiInterface();
QProcess command;
QString commandText = systemctlCommand + QString(" is-active ") + netctlAutoService + QString("@") +
interface + QString(".service");
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (debug) qDebug() << "[Netctl]" << "[isNetctlAutoRunning]" << ":" << "Cmd returns" << command.exitCode();
QString output = command.readAllStandardOutput().trimmed();
if (output == QString("active"))
return true;
else
return false;
}
// functions
/**
* @fn enableProfile
*/
bool Netctl::enableProfile(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[enableProfile]";
if (debug) qDebug() << "[Netctl]" << "[enableProfile]" << ":" << "Profile" << profile;
if (isProfileEnabled(profile))
return netctlCall(true, QString("disable"), profile);
else
return netctlCall(true, QString("enable"), profile);
}
/**
* @fn restartProfile
*/
bool Netctl::restartProfile(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[restartProfile]";
if (debug) qDebug() << "[Netctl]" << "[restartProfile]" << ":" << "Profile" << profile;
return netctlCall(true, QString("restart"), profile);
}
/**
* @fn startProfile
*/
bool Netctl::startProfile(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[startProfile]";
if (debug) qDebug() << "[Netctl]" << "[startProfile]" << ":" << "Profile" << profile;
if (isProfileActive(profile))
return netctlCall(true, QString("stop"), profile);
else
return netctlCall(true, QString("start"), profile);
}
/**
* @fn autoDisableAllProfiles
*/
bool Netctl::autoDisableAllProfiles()
{
if (debug) qDebug() << "[Netctl]" << "[autoDisableAllProfiles]";
return netctlAutoCall(false, QString("disable-all"));
}
/**
* @fn autoEnableProfile
*/
bool Netctl::autoEnableProfile(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[autoEnableProfile]";
if (debug) qDebug() << "[Netctl]" << "[autoEnableProfile]" << ":" << "Profile" << profile;
if (autoIsProfileEnabled(profile))
return netctlAutoCall(false, QString("disable"), profile);
else
return netctlAutoCall(false, QString("enable"), profile);
}
/**
* @fn autoEnableAllProfiles
*/
bool Netctl::autoEnableAllProfiles()
{
if (debug) qDebug() << "[Netctl]" << "[autoEnableAllProfiles]";
return netctlAutoCall(false, QString("enable-all"));
}
/**
* @fn autoStartProfile
*/
bool Netctl::autoStartProfile(const QString profile)
{
if (debug) qDebug() << "[Netctl]" << "[autoStartProfile]";
if (debug) qDebug() << "[Netctl]" << "[autoStartProfile]" << ":" << "Profile" << profile;
if (autoIsProfileActive(profile))
return true;
else
return netctlAutoCall(false, QString("switch-to"), profile);
}
/**
* @fn autoEnableService
*/
bool Netctl::autoEnableService()
{
if (debug) qDebug() << "[Netctl]" << "[autoEnableService]";
if (isNetctlAutoEnabled())
return systemctlCall(true, QString("disable"));
else
return systemctlCall(true, QString("enable"));
}
/**
* @fn autoRestartService
*/
bool Netctl::autoRestartService()
{
if (debug) qDebug() << "[Netctl]" << "[autoRestartService]";
if (isNetctlAutoRunning())
return systemctlCall(true, QString("restart"));
else
return true;
}
/**
* @fn autoStartService
*/
bool Netctl::autoStartService()
{
if (debug) qDebug() << "[Netctl]" << "[autoStartService]";
if (isNetctlAutoRunning())
return systemctlCall(true, QString("stop"));
else
return systemctlCall(true, QString("start"));
}

View File

@ -0,0 +1,216 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file netctlprofile.cpp
* Source code of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QProcess>
#include <QTextStream>
#include <netctlgui/netctlprofile.h>
/**
* @class NetctlProfile
*/
/**
* @fn NetctlProfile
*/
NetctlProfile::NetctlProfile(const bool debugCmd, const QMap<QString, QString> settings)
: debug(debugCmd)
{
if (settings.contains(QString("PROFILE_DIR")))
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
else
profileDirectory = new QDir(QString("/etc/netctl/"));
if (settings.contains(QString("SUDO_PATH")))
sudoCommand = settings[QString("SUDO_PATH")];
else
sudoCommand = QString("/usr/bin/kdesu");
}
/**
* @fn ~NetctlProfile
*/
NetctlProfile::~NetctlProfile()
{
if (debug) qDebug() << "[NetctlProfile]" << "[~NetctlProfile]";
if (profileDirectory != 0)
delete profileDirectory;
}
/**
* @fn copyProfile
*/
bool NetctlProfile::copyProfile(const QString oldPath)
{
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]";
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Path" << oldPath;
if (profileDirectory == 0) {
if (debug) qDebug() << "[NetctlProfile]" << "[profileDirectory]" << ":" << "Could not find directory";
return false;
}
if (sudoCommand == 0) {
if (debug) qDebug() << "[NetctlProfile]" << "[profileDirectory]" << ":" << "Could not find sudo";
return false;
}
QProcess command;
QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
QString commandText = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath;
if (debug) qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (command.exitCode() == 0)
return true;
else
return false;
}
/**
* @fn createProfile
*/
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings)
{
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]";
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Profile" << profile;
QString profileTempName = QDir::homePath() + QDir::separator() +
QString(".cache") + QDir::separator() + QFileInfo(profile).fileName();
QFile profileFile(profileTempName);
if (debug) qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Save to" << profileTempName;
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
return profileTempName;
QTextStream out(&profileFile);
for (int i=0; i<settings.keys().count(); i++) {
out << settings.keys()[i] << QString("=");
if ((settings.keys()[i] == QString("BindsToInterfaces")) ||
(settings.keys()[i] == QString("After")) ||
(settings.keys()[i] == QString("Address")) ||
(settings.keys()[i] == QString("Routes")) ||
(settings.keys()[i] == QString("Address6")) ||
(settings.keys()[i] == QString("Routes6")) ||
(settings.keys()[i] == QString("IPCustom")) ||
(settings.keys()[i] == QString("DNS")) ||
(settings.keys()[i] == QString("DNSOptions")) ||
(settings.keys()[i] == QString("ScanFrequencies")) ||
(settings.keys()[i] == QString("WPAConfigSection")))
out << QString("(") + settings[settings.keys()[i]] << QString(")") << endl;
else
out << settings[settings.keys()[i]] << endl;
}
profileFile.close();
return profileTempName;
}
/**
* @fn getSettingsFromProfile
*/
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile)
{
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]";
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Profile" << profile;
if (profileDirectory == 0) {
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Could not find directory";
return QMap<QString, QString>();
}
// getting variables list
// system variables
QProcess shell;
QString cmd = QString("env -i bash -c \"set\"");
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Run cmd" << cmd;
shell.start(cmd);
shell.waitForFinished(-1);
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Cmd returns" << shell.exitCode();
QStringList output = QString(shell.readAllStandardOutput()).trimmed().split(QChar('\n'));
QStringList systemVariables;
systemVariables.append(QString("PIPESTATUS"));
for (int i=0; i<output.count(); i++)
systemVariables.append(output[i].split(QChar('='))[0]);
// profile variables
QMap<QString, QString> settings;
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
cmd = QString("env -i bash -c \"source ") + profileUrl + QString("; set\"");
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Run cmd" << cmd;
shell.start(cmd);
shell.waitForFinished(-1);
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Cmd returns" << shell.exitCode();
output = QString(shell.readAllStandardOutput()).trimmed().split(QChar('\n'));
// gettings variables
QStringList keys;
for (int i=0; i<output.count(); i++)
if (!systemVariables.contains(output[i].split(QChar('='))[0]))
keys.append(output[i].split(QChar('='))[0]);
for (int i=0; i<keys.count(); i++){
cmd = QString("env -i bash -c \"source ") + profileUrl +
QString("; for i in ${!") + keys[i] + QString("[@]}; do echo ${") +
keys[i] + QString("[$i]}; done\"");
shell.start(cmd);
shell.waitForFinished(-1);
settings[keys[i]] = shell.readAllStandardOutput().trimmed();
if (debug) qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << keys[i] << "=" << settings[keys[i]];
}
return settings;
}
/**
* @fn removeProfile
*/
bool NetctlProfile::removeProfile(const QString profile)
{
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]";
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Profile" << profile;
if (profileDirectory == 0) {
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Could not find directory";
return false;
}
if (sudoCommand == 0) {
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Could not find sudo";
return false;
}
QProcess command;
QString profilePath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(profile).fileName();
QString commandText = sudoCommand + QString(" /usr/bin/rm ") + profilePath;
if (debug) qDebug() << "[NetctlProfile]" << "[removeProfile]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
if (command.exitCode() == 0)
return true;
else
return false;
}

View File

@ -0,0 +1,389 @@
/***************************************************************************
* This file is part of netctl-gui *
* *
* netctl-gui is free software: you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* netctl-gui is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
***************************************************************************/
/**
* @file wpasupinteract.cpp
* Source code of netctlgui library
* @author Evgeniy Alekseev
* @copyright GPLv3
* @bug https://github.com/arcan1s/netctl-gui/issues
*/
#include <QDebug>
#include <QProcess>
#include <netctlgui/netctlinteract.h>
#include <netctlgui/sleepthread.h>
#include <netctlgui/wpasupinteract.h>
/**
* @class WpaSup
*/
/**
* @fn WpaSup
*/
WpaSup::WpaSup(const bool debugCmd, const QMap<QString, QString> settings)
: debug(debugCmd)
{
netctlCommand = new Netctl(debug, settings);
if (settings.contains(QString("CTRL_DIR")))
ctrlDir = settings[QString("CTRL_DIR")];
else
ctrlDir = QString("/run/wpa_supplicant_netctl-gui");
if (settings.contains(QString("CTRL_GROUP")))
ctrlGroup = settings[QString("CTRL_GROUP")];
else
ctrlGroup = QString("users");
if (settings.contains(QString("IFACE_DIR")))
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
else
ifaceDirectory = new QDir(QString("/sys/class/net/"));
if (settings.contains(QString("PREFERED_IFACE")))
mainInterface = settings[QString("PREFERED_IFACE")];
else
mainInterface = QString("");
if (settings.contains(QString("PID_FILE")))
pidFile = settings[QString("PID_FILE")];
else
pidFile = QString("/run/wpa_supplicant_netctl-gui.pid");
if (settings.contains(QString("SUDO_PATH")))
sudoCommand = settings[QString("SUDO_PATH")];
else
sudoCommand = QString("/usr/bin/kdesu");
if (settings.contains(QString("WPACLI_PATH")))
wpaCliPath = settings[QString("WPACLI_PATH")];
else
wpaCliPath = QString("/usr/bin/wpa_cli");
if (settings.contains(QString("WPA_DRIVERS")))
wpaDrivers = settings[QString("WPA_DRIVERS")];
else
wpaDrivers = QString("nl80211,wext");
if (settings.contains(QString("WPASUP_PATH")))
wpaSupPath = settings[QString("WPASUP_PATH")];
else
wpaSupPath = QString("/usr/bin/wpa_supplicant");
// terminate old loaded profile
if (QFile(pidFile).exists() || QDir(ctrlDir).exists())
stopWpaSupplicant();
}
/**
* @fn ~WpaSup
*/
WpaSup::~WpaSup()
{
if (debug) qDebug() << "[WpaSup]" << "[~WpaSup]";
delete netctlCommand;
if (ifaceDirectory != 0)
delete ifaceDirectory;
}
// general information
/**
* @fn existentProfile
*/
QString WpaSup::existentProfile(const QString essid)
{
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]";
if (debug) qDebug() << "[WpaSup]" << "[existentProfile]" << ":" << "ESSID" << essid;
QString profileFile = QString("");
QList<QStringList> profileList = netctlCommand->getProfileList();
for (int i=0; i<profileList.count(); i++)
if (essid == netctlCommand->getSsidFromProfile(profileList[i][0]))
profileFile = profileList[i][0];
return profileFile;
}
/**
* @fn getInterfaceList
*/
QStringList WpaSup::getInterfaceList()
{
if (debug) qDebug() << "[WpaSup]" << "[getInterfaceList]";
if (ifaceDirectory == 0) {
if (debug) qDebug() << "[WpaSup]" << "[getInterfaceList]" << ":" << "Could not find directory";
return QStringList();
}
QStringList interfaces;
if (!mainInterface.isEmpty())
interfaces.append(mainInterface);
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i=0; i<allInterfaces.count(); i++) {
if (debug) qDebug() << "[WpaSup]" << "[getInterfaceList]" << ":" << "Check directory"
<< ifaceDirectory->path() + QDir::separator() + allInterfaces[i] + QDir::separator() + QString("wireless");
if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] +
QDir::separator() + QString("wireless")).exists())
interfaces.append(allInterfaces[i]);
}
return interfaces;
}
/**
* @fn isProfileActive
*/
bool WpaSup::isProfileActive(const QString essid)
{
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]";
if (debug) qDebug() << "[WpaSup]" << "[isProfileActive]" << ":" << "ESSID" << essid;
QString profileFile;
QList<QStringList> profileList = netctlCommand->getProfileList();
for (int i=0; i<profileList.count(); i++)
if (essid == netctlCommand->getSsidFromProfile(profileList[i][0])) {
profileFile = profileList[i][0];
break;
}
return netctlCommand->isProfileActive(profileFile);
}
/**
* @fn isProfileExists
*/
bool WpaSup::isProfileExists(const QString essid)
{
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]";
if (debug) qDebug() << "[WpaSup]" << "[isProfileExists]" << ":" << "ESSID" << essid;
bool exists = false;
QList<QStringList> profileList = netctlCommand->getProfileList();
for (int i=0; i<profileList.count(); i++)
if (essid == netctlCommand->getSsidFromProfile(profileList[i][0])) {
exists = true;
break;
}
return exists;
}
/**
* @fn scanWifi
*/
QList<QStringList> WpaSup::scanWifi()
{
if (debug) qDebug() << "[WpaSup]" << "[scanWifi]";
QList<QStringList> scanResults;
if (!startWpaSupplicant()) {
stopWpaSupplicant();
return scanResults;
}
if (!wpaCliCall(QString("scan")))
return scanResults;
SleepThread::sleep(3);
QStringList rawOutput = getWpaCliOutput(QString("scan_results")).split(QChar('\n'), QString::SkipEmptyParts);
// remove table header
rawOutput.removeFirst();
// remove duplicates
QStringList rawList;
for (int i=0; i<rawOutput.count(); i++) {
bool exist = false;
if (rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts).count() > 4)
for (int j=0; j<rawList.count(); j++)
if (rawList[j].split(QChar('\t'), QString::SkipEmptyParts).count() > 4)
if (rawOutput[i].split(QChar('\t'), QString::SkipEmptyParts)[4] ==
rawList[j].split(QChar('\t'), QString::SkipEmptyParts)[4])
exist = true;
if (!exist)
rawList.append(rawOutput[i]);
}
for (int i=0; i<rawList.count(); i++) {
QStringList wifiPoint;
// point name
if (rawList[i].split(QChar('\t'), QString::SkipEmptyParts).count() > 4)
wifiPoint.append(rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[4]);
else
wifiPoint.append(QString("<hidden>"));
// profile status
QString status;
if (isProfileExists(wifiPoint[0])) {
status = QString("exists");
if (isProfileActive(wifiPoint[0]))
status = status + QString(" (active)");
else
status = status + QString(" (inactive)");
}
else
status = QString("new");
wifiPoint.append(status);
// point signal
wifiPoint.append(rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[2]);
// point security
QString security = rawList[i].split(QChar('\t'), QString::SkipEmptyParts)[3];
if (security.contains(QString("WPA2")))
security = QString("WPA2");
else if (security.contains(QString("WPA")))
security = QString("WPA");
else if (security.contains(QString("WEP")))
security = QString("WEP");
else
security = QString("none");
wifiPoint.append(security);
scanResults.append(wifiPoint);
}
stopWpaSupplicant();
return scanResults;
}
/**
* @fn startWpaSupplicant
*/
bool WpaSup::startWpaSupplicant()
{
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]";
if (ctrlDir == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find directory";
return false;
}
if (ctrlGroup == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find group";
return false;
}
if (pidFile == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find PID file";
return false;
}
if (sudoCommand == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find sudo";
return false;
}
if (wpaDrivers == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find drivers";
return false;
}
if (wpaSupPath == 0) {
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Could not find wpa_supplicant";
return false;
}
if (QFile(pidFile).exists())
return true;
QProcess command;
QString interface = getInterfaceList()[0];
QString commandText = sudoCommand + QString(" ") + wpaSupPath + QString(" -B -P ") + pidFile +
QString(" -i ") + interface + QString(" -D ") + wpaDrivers +
QString(" -C \"DIR=") + ctrlDir + QString(" GROUP=") + ctrlGroup + QString("\"");
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
SleepThread::sleep(1);
if (debug) qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() == 0)
return true;
else
return false;
}
/**
* @fn stopWpaSupplicant
*/
bool WpaSup::stopWpaSupplicant()
{
if (debug) qDebug() << "[WpaSup]" << "[stopWpaSupplicant]";
return wpaCliCall(QString("terminate"));
}
// functions
/**
* @fn getWpaCliOutput
*/
QString WpaSup::getWpaCliOutput(const QString commandLine)
{
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]";
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Command" << commandLine;
if (ctrlDir == 0) {
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find directory";
return QString();
}
if (pidFile == 0) {
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find PID file";
return QString();
}
if (wpaCliPath == 0) {
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Could not find wpa_cli";
return QString();
}
QProcess command;
QString interface = getInterfaceList()[0];
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
QString(" -P ") + pidFile + QString(" ") + commandLine;
if (debug) qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
return command.readAllStandardOutput();
}
/**
* @fn wpaCliCall
*/
bool WpaSup::wpaCliCall(const QString commandLine)
{
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]";
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Command" << commandLine;
if (ctrlDir == 0) {
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find directory";
return false;
}
if (pidFile == 0) {
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find PID file";
return false;
}
if (wpaCliPath == 0) {
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Could not find wpa_cli";
return false;
}
QProcess command;
QString interface = getInterfaceList()[0];
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
QString(" -P ") + pidFile + QString(" ") + commandLine;
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Run cmd" << commandText;
command.start(commandText);
command.waitForFinished(-1);
SleepThread::sleep(1);
if (debug) qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Cmd returns" << command.exitCode();
if (command.exitCode() == 0)
return true;
else
return false;
}

View File

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

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

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

View File

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

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