mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-25 07:57:20 +00:00
Compare commits
87 Commits
Author | SHA1 | Date | |
---|---|---|---|
5a171f6c67 | |||
|
c2e4ea2258 | ||
|
d2714dca02 | ||
|
5efb25dca3 | ||
|
e67493f5c0 | ||
|
32f7b9344c | ||
|
2041e01caa | ||
|
271fdb0d99 | ||
|
45904db741 | ||
|
a216060447 | ||
|
05a613b501 | ||
|
a9c7f98677 | ||
|
5018232c08 | ||
|
aed09bf798 | ||
|
d299e7d9a1 | ||
|
cf7b013726 | ||
|
b65ba2ebe2 | ||
|
69f6a3135b | ||
|
7dc1a5eda3 | ||
|
168a270c98 | ||
|
c3aa3f0c8f | ||
|
e26da85b5f | ||
|
f665a46346 | ||
|
d541d0a755 | ||
|
0f5bf03e38 | ||
|
3695914226 | ||
|
03dbfce482 | ||
|
6a8d2701b0 | ||
|
ff3e000688 | ||
|
824a11457b | ||
|
b7fa17df4e | ||
|
35af460b7b | ||
|
9aa1f6d715 | ||
|
308f9824b4 | ||
|
bf7521481a | ||
|
e4bcfb1653 | ||
|
a2b1d46900 | ||
|
3f49988cef | ||
|
f80d6aae6b | ||
|
ef2694d7a7 | ||
|
26afd90df9 | ||
|
02432be630 | ||
|
275d71d75f | ||
|
b90f441fde | ||
|
19976819a1 | ||
|
362a11f0bc | ||
|
d94aa4ebf7 | ||
|
2cf876cf32 | ||
|
9993fee336 | ||
|
de0c1f208d | ||
|
25ca2ef1d9 | ||
|
1333967535 | ||
|
e70ebe318d | ||
|
dcdf03f639 | ||
|
8b33ec859b | ||
|
53ff63b792 | ||
|
b46ce1620b | ||
|
4c20a54d7e | ||
|
a73968f98b | ||
|
9033c51bb4 | ||
|
d23429891e | ||
|
cf12b3627e | ||
|
582459d174 | ||
|
08e7390f6c | ||
|
c8eae4b222 | ||
|
54583eae6e | ||
|
634b4c3b41 | ||
|
54c5e7958a | ||
|
6ed45fa7a5 | ||
|
73ba838685 | ||
|
924beacc23 | ||
|
a830fc9372 | ||
|
4c7459e833 | ||
|
00a35d75d2 | ||
|
3e92ec2aae | ||
|
3ac0484f21 | ||
|
cbac07b29e | ||
|
7972f2d6d3 | ||
|
afed94745a | ||
|
c8f260c8e2 | ||
|
edb386d24e | ||
|
f188dea8a7 | ||
|
6fb7da4b5b | ||
|
a35e9b0164 | ||
|
4bc428f8b5 | ||
|
030dec5e14 | ||
|
0898a99878 |
181
CHANGELOG
181
CHANGELOG
@ -1,3 +1,135 @@
|
||||
Ver.1.4.9
|
||||
---------
|
||||
* library
|
||||
* fix bug with invalid enabled profile definition (#46)
|
||||
* some imrovements inside
|
||||
* plasmoid
|
||||
* change rendering from Qt to native
|
||||
* update plasmoid to recent plasma changes
|
||||
|
||||
Ver.1.4.8
|
||||
---------
|
||||
* gui
|
||||
* update profile tab to netclt 1.10 and 1.11 changes
|
||||
* plasmoid
|
||||
* fix bug with no action on link activation
|
||||
|
||||
Ver.1.4.7
|
||||
---------
|
||||
* all
|
||||
+ implement support of setting of default configuration values while building
|
||||
* fix language component (refer to #45)
|
||||
* gui
|
||||
* more correct work with configuration file
|
||||
* helper
|
||||
* more correct work with configuration file
|
||||
|
||||
Ver.1.4.6
|
||||
---------
|
||||
* all
|
||||
+ implement time logging feature
|
||||
* gui
|
||||
+ implement autoupdate feature
|
||||
- fix invalid profile path for the external editor
|
||||
* library
|
||||
+ implement netctl-auto support to scanWiFi() method (#44)
|
||||
- fix bug with invalid data in netctl-auto profile list output
|
||||
|
||||
Ver.1.4.5
|
||||
---------
|
||||
* plasmoid
|
||||
+ add translation support to plugin part
|
||||
* more correct interface painting
|
||||
* more correct configuration interface painting
|
||||
* move plugin from private
|
||||
|
||||
Ver.1.4.4
|
||||
---------
|
||||
* dataengine
|
||||
- fix profile status definition
|
||||
|
||||
Ver.1.4.3
|
||||
---------
|
||||
* all
|
||||
- fix clang build (#41)
|
||||
- fix WPA_DRIVERS (#40)
|
||||
* library
|
||||
- fix bug in WpaSup class with invalid returning value
|
||||
|
||||
***
|
||||
|
||||
Ver.1.4.2
|
||||
---------
|
||||
* gui
|
||||
* remove Update call to the helper
|
||||
|
||||
Ver.1.4.1
|
||||
---------
|
||||
* all
|
||||
+ some Easter eggs
|
||||
+ add _DEFAULT_SOURCE to avoid gcc warnings
|
||||
* refactoring
|
||||
* fix cppcheck warnings
|
||||
* update 3rdparty components
|
||||
* fix language defilition
|
||||
* replace General section to Common in settings (see http://doc.qt.io/qt-5/qsettings.html#Format-enum)
|
||||
* gui
|
||||
+ allow to change helper control group from UI (#36)
|
||||
+ allow to open profile in an external editor (#38)
|
||||
+ add IP validators (#34)
|
||||
+ add toolbar configuration
|
||||
+ add notification on hidding to tray
|
||||
+ add returnPressed() signal to lineEdits
|
||||
+ implement needToBeConfigured() signal
|
||||
- remove margins
|
||||
- fix bug with segfault on updating UI with KF5
|
||||
* rewrite ErrorWindow class
|
||||
* split MainWindow class
|
||||
* update WiFi menu to new library functions
|
||||
* improve UI (#25, #28)
|
||||
* more correct component checking (#29, #37)
|
||||
* more correct callbacks with exceptions
|
||||
* dataengine
|
||||
+ add desktop reconfiguration (#30)
|
||||
* improve performance
|
||||
* helper
|
||||
+ add /interface interface
|
||||
+ add /ctrl/{CurrentWiFi,VerboseWiFi} calls
|
||||
+ add /netctl/VerboseProfiles call
|
||||
+ add /netctl/{netctlActiveProfile,netctlProfileList,netctlVerboseProfileList) calls
|
||||
* library
|
||||
+ add NetctlInterface class
|
||||
+ add WpaSup::CurrentWiFi method
|
||||
+ append structures some additional information
|
||||
+ mark Netctl::getProfileDescription() as deprecated
|
||||
+ now WpaSup can connect to already created session (by default)
|
||||
* improve performance
|
||||
* plasmoid
|
||||
+ add desktop reconfiguration (#30)
|
||||
- remove legacy functions from KDE4 plasmoid
|
||||
* improve performance of KF5 plasmoid (#26)
|
||||
* test
|
||||
* fix netctl tests
|
||||
|
||||
***
|
||||
|
||||
Ver.1.4.0
|
||||
---------
|
||||
* all
|
||||
* change settings format from shell-like to ini (#24)
|
||||
* dataengine
|
||||
+ create package for KF5
|
||||
* change NETCTLGUI_DEBUG=yes to DEBUG=yes
|
||||
* update url
|
||||
* gui
|
||||
+ add workarounds to #22 and #23
|
||||
* plasmoid
|
||||
+ create package and plugin for KF5
|
||||
* change NETCTLGUI_DEBUG=yes to DEBUG=yes
|
||||
* update url
|
||||
|
||||
***
|
||||
|
||||
Ver.1.3.3
|
||||
---------
|
||||
* all
|
||||
@ -7,7 +139,6 @@ Ver.1.3.3
|
||||
|
||||
***
|
||||
|
||||
|
||||
Ver.1.3.2
|
||||
---------
|
||||
* all
|
||||
@ -17,10 +148,10 @@ Ver.1.3.2
|
||||
|
||||
Ver.1.3.1
|
||||
---------
|
||||
* gui:
|
||||
* gui
|
||||
* more correct calls of boolean DBus methods
|
||||
* edit helper icon
|
||||
* helper:
|
||||
* helper
|
||||
* more correct calls of boolean DBus methods
|
||||
* more correct systemd service
|
||||
* add ability to create session bus
|
||||
@ -29,18 +160,18 @@ Ver.1.3.1
|
||||
|
||||
Ver.1.3.0
|
||||
---------
|
||||
* all:
|
||||
* all
|
||||
+ add processes error messages
|
||||
+ add support of several active profiles
|
||||
* some bug fixes and refactoring
|
||||
* rewrite debug messages
|
||||
* dataengine:
|
||||
* dataengine
|
||||
+ add new sources: intIp6, extIp6, netctlAutoStatus
|
||||
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
|
||||
* change default command to define external IP
|
||||
* change interface list definition
|
||||
* change internal IP definition
|
||||
* gui:
|
||||
* gui
|
||||
+ add 3rd party license information
|
||||
+ add system tray icon as an alternative to the plasmoid
|
||||
+ add DBus session interface org.netctlgui.netctlgui
|
||||
@ -57,11 +188,11 @@ Ver.1.3.0
|
||||
* rewrite tables to use toolTip
|
||||
* edit about window
|
||||
* change menuBar
|
||||
* helper:
|
||||
* helper
|
||||
+ create daemon DBus system interface org.netctlgui.helper to the library:
|
||||
self control slots, netctl control slots and netctl information slots
|
||||
+ add tests
|
||||
* library:
|
||||
* library
|
||||
+ add custom structures netctlWifiInfo and netctlProfileInfo
|
||||
+ add methods getActiveProfile(), autoGetActiveProfile()
|
||||
+ add slot switchToProfile()
|
||||
@ -76,7 +207,7 @@ Ver.1.3.0
|
||||
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
|
||||
* rename getInterfaceList() to getWirelessInterfaceList()
|
||||
* change temporary directory from $HOME/.cache to system one
|
||||
* plasmoid:
|
||||
* plasmoid
|
||||
+ add 3rd party license information
|
||||
+ allow plasmoid to use system tray
|
||||
+ add ability to use helper
|
||||
@ -89,14 +220,14 @@ Ver.1.3.0
|
||||
|
||||
Ver.1.2.0
|
||||
---------
|
||||
* all:
|
||||
* all
|
||||
+ add icons
|
||||
+ add support of netctl-auto
|
||||
* changes in the project architecture
|
||||
* refactoring
|
||||
* dataengine:
|
||||
* dataengine
|
||||
+ add debug information (NETCTLGUI_DEBUG=yes)
|
||||
* gui:
|
||||
* gui
|
||||
+ add support of macvlan
|
||||
+ add ability to remove profile
|
||||
+ add support of hidden wifi network
|
||||
@ -114,13 +245,13 @@ Ver.1.2.0
|
||||
* refactoring of configuration interface
|
||||
* change setting of the interface to profile tab
|
||||
* rewrite ErrorWindow class
|
||||
* library:
|
||||
* library
|
||||
+ detach backend from frontend
|
||||
+ add error checking
|
||||
+ add doxygen documentation
|
||||
* more debug information
|
||||
* rewrite getSettingsFromProfile() function
|
||||
* plasmoid:
|
||||
* plasmoid
|
||||
+ add dataengine configuration
|
||||
+ add about window
|
||||
+ add debug information (NETCTLGUI_DEBUG=yes)
|
||||
@ -132,26 +263,26 @@ Ver.1.2.0
|
||||
|
||||
Ver.1.1.0 (netctl-1.7 update)
|
||||
-----------------------------
|
||||
* dataengine:
|
||||
* dataengine
|
||||
* change definition if profile is enabled
|
||||
* gui:
|
||||
* gui
|
||||
+ add frequency
|
||||
* change definition if profile is enabled
|
||||
* plasmoid:
|
||||
* plasmoid
|
||||
+ add menu title
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.6
|
||||
---------
|
||||
* gui:
|
||||
* gui
|
||||
* fix error checking
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.5
|
||||
---------
|
||||
* plasmoid:
|
||||
* plasmoid
|
||||
+ add "Start WiFi menu" function
|
||||
* refactoring
|
||||
* edit icon
|
||||
@ -160,9 +291,9 @@ Ver.1.0.5
|
||||
|
||||
Ver.1.0.4
|
||||
---------
|
||||
* gui:
|
||||
* gui
|
||||
+ add Qt5 gui (by default)
|
||||
* plasmoid:
|
||||
* plasmoid
|
||||
+ add notifications
|
||||
* fix run command with sudo from plasmoid
|
||||
|
||||
@ -170,23 +301,23 @@ Ver.1.0.4
|
||||
|
||||
Ver.1.0.3
|
||||
---------
|
||||
* all:
|
||||
* all
|
||||
* refactoring
|
||||
* plasmoid:
|
||||
* plasmoid
|
||||
+ edit russian translation
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.2
|
||||
---------
|
||||
* plasmoid:
|
||||
* plasmoid
|
||||
- fix layout margins
|
||||
|
||||
***
|
||||
|
||||
Ver.1.0.1
|
||||
---------
|
||||
* all:
|
||||
* all
|
||||
- remove scripts
|
||||
|
||||
***
|
||||
|
10
README.md
10
README.md
@ -4,7 +4,7 @@ Netctl GUI
|
||||
Information
|
||||
-----------
|
||||
|
||||
Qt4/Qt5 graphical interface for netctl. It may work with profiles and may create new profiles. Also it may create a connection to WiFi. Moreover, it provides a widget and DataEngine for KDE.
|
||||
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 KDE4/KF5.
|
||||
|
||||
**NOTE** [LOOKING FOR TRANSLATORS!](https://github.com/arcan1s/netctl-gui/issues/3)
|
||||
|
||||
@ -15,8 +15,8 @@ It is recommended to use graphical interface for configuration. Configuration fi
|
||||
|
||||
* `$HOME/.config/netctl-gui.conf` - GUI/helper user configuration
|
||||
* `/etc/netctl-gui.conf` - helper system-wide configuration
|
||||
* `$KDEHOME/share/config/netctl.conf` - DataEngine user configuration
|
||||
* `$KDESYSTEM/share/config/netctl.conf` - DataEngine system-wide configuration
|
||||
* `$HOME/.config/plasma-dataengine-netctl.conf` - DataEngine user configuration
|
||||
* `/etc/xdg/plasma-dataengine-netctl.conf` - DataEngine system-wide configuration
|
||||
|
||||
Instruction
|
||||
===========
|
||||
@ -30,7 +30,8 @@ Dependencies
|
||||
Optional dependencies
|
||||
---------------------
|
||||
|
||||
* kdebase-workspace (widget)
|
||||
* kdebase-workspace (KDE4 widget)
|
||||
* plasma-framework (KF5 widget)
|
||||
* sudo (sudo support)
|
||||
* wpa_supplicant (WiFi support)
|
||||
|
||||
@ -68,6 +69,7 @@ Installation
|
||||
* `-DDBUS_SYSTEMCONF_PATH=/etc/dbus-1/system.d/` - path to dbus system configuration files
|
||||
* `-DSYSTEMD_SERVICE_PATH=lib/systemd/system` - path to systemd services
|
||||
* `-DUSE_CAPABILITIES:BOOL=0` - do not use setcap to get privileges to the helper
|
||||
* `-DBUILD_KDE4:BOOL=1` - build KDE4 plasmoid instead of KF5 one
|
||||
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
|
||||
|
||||
Additional information
|
||||
|
@ -2,22 +2,20 @@
|
||||
|
||||
pkgbase=netctl-gui
|
||||
pkgname=('libnetctlgui' 'netctlgui-helper' 'netctl-gui'
|
||||
'libnetctlgui-qt4' 'netctlgui-helper-qt4' 'netctl-gui-qt4'
|
||||
'kdeplasma-applets-netctl-gui')
|
||||
pkgver=1.3.3
|
||||
pkgrel=2
|
||||
'plasma5-applet-netctl-gui')
|
||||
pkgver=1.4.9
|
||||
pkgrel=1
|
||||
pkgdesc="Qt4/Qt5 GUI for netctl. Also provides a widget for KDE"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcanis.name/projects/netctl-gui"
|
||||
license=('GPL3')
|
||||
makedepends=('automoc4' 'cmake' 'kdelibs' 'qt5-base' 'qt5-tools')
|
||||
makedepends=('cmake' 'extra-cmake-modules' 'plasma-framework' 'qt5-tools')
|
||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
||||
md5sums=('9ba672ef33e9962ccc04fc4de75fad68')
|
||||
|
||||
md5sums=('64c04c36eea017e7c0ddf687d60de128')
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/build-"{plasmoid,qt4,qt5}
|
||||
mkdir "${srcdir}/build-"{plasmoid,qt4,qt5}
|
||||
rm -rf "${srcdir}/build-"{plasmoid,qt5}
|
||||
mkdir "${srcdir}/build-"{plasmoid,qt5}
|
||||
}
|
||||
|
||||
|
||||
@ -25,22 +23,13 @@ build() {
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DKDE_INSTALL_USE_QT_SYS_PATHS=ON \
|
||||
-DBUILD_GUI:BOOL=0 \
|
||||
-DBUILD_LIBRARY:BOOL=0 \
|
||||
-DBUILD_HELPER:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt4"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
-DUSE_CAPABILITIES:BOOL=0 \
|
||||
-DUSE_QT5:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt5"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
@ -52,15 +41,13 @@ build() {
|
||||
}
|
||||
|
||||
|
||||
package_kdeplasma-applets-netctl-gui() {
|
||||
pkgdesc="A plasmoid, which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'kdebase-workspace')
|
||||
package_plasma5-applet-netctl-gui() {
|
||||
pkgdesc="A KF5 plasmoid, which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'plasma-framework')
|
||||
optdepends=('netctlgui-helper: DBus helper daemon'
|
||||
'netctlgui-helper-qt4: DBus helper daemon'
|
||||
'netctl-gui: graphical front-end'
|
||||
'netctl-gui-qt4: graphical front-end'
|
||||
'sudo: sudo support')
|
||||
install="kdeplasma-applets-netctl-gui.install"
|
||||
install="plasma-netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
@ -83,7 +70,7 @@ package_libnetctlgui() {
|
||||
|
||||
package_netctlgui-helper() {
|
||||
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
|
||||
depends=('libnetctlgui')
|
||||
depends=("libnetctlgui=${pkgver}")
|
||||
provides=('netctlgui-helper-qt4')
|
||||
conflicts=('netctlgui-helper-qt4')
|
||||
backup=('etc/netctl-gui.conf'
|
||||
@ -97,8 +84,8 @@ package_netctlgui-helper() {
|
||||
|
||||
package_netctl-gui() {
|
||||
pkgdesc="Qt5 graphical front-end for netctl. A part of netctl-gui"
|
||||
depends=('libnetctlgui' 'xdg-utils')
|
||||
optdepends=('kdeplasma-applets-netctl-gui: KDE widget'
|
||||
depends=("libnetctlgui=${pkgver}" 'xdg-utils')
|
||||
optdepends=('plasma-netctl-gui: KF5 widget'
|
||||
'netctlgui-helper: DBus helper daemon')
|
||||
provides=('netctl-gui-qt4')
|
||||
conflicts=('netctl-gui-qt4')
|
||||
@ -109,48 +96,3 @@ package_netctl-gui() {
|
||||
cd "${srcdir}/build-qt5/resources"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_libnetctlgui-qt4() {
|
||||
pkgdesc="Qt4 library which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'qt4')
|
||||
optdepends=('netctlgui-helper-qt4: DBus helper daemon'
|
||||
'sudo: sudo support'
|
||||
'wpa_supplicant: wifi support')
|
||||
provides=('libnetctlgui')
|
||||
conflicts=('libnetctlgui')
|
||||
install=""
|
||||
|
||||
cd "${srcdir}/build-qt4/netctlgui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctlgui-helper-qt4() {
|
||||
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
|
||||
depends=('libnetctlgui-qt4')
|
||||
provides=('netctlgui-helper')
|
||||
conflicts=('netctlgui-helper')
|
||||
backup=('etc/netctl-gui.conf'
|
||||
'etc/dbus-1/system.d/org.netctlgui.helper.conf')
|
||||
install="netctlgui-helper.install"
|
||||
|
||||
cd "${srcdir}/build-qt4/helper"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctl-gui-qt4() {
|
||||
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
|
||||
depends=('libnetctlgui-qt4')
|
||||
optdepends=('kdeplasma-applets-netctl-gui: KDE widget'
|
||||
'netctlgui-helper-qt4: DBus helper daemon')
|
||||
provides=('netctl-gui')
|
||||
conflicts=('netctl-gui')
|
||||
install="netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-qt4/gui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
cd "${srcdir}/build-qt4/resources"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
101
arch/PKGBUILD-qt4
Normal file
101
arch/PKGBUILD-qt4
Normal file
@ -0,0 +1,101 @@
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
pkgbase=netctl-gui-qt4
|
||||
_pkgbase=netctl-gui
|
||||
pkgname=('libnetctlgui-qt4' 'netctlgui-helper-qt4' 'netctl-gui-qt4'
|
||||
'kdeplasma-applets-netctl-gui')
|
||||
pkgver=1.4.9
|
||||
pkgrel=1
|
||||
pkgdesc="Qt4 GUI for netctl. Also provides a widget for KDE4"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcanis.name/projects/netctl-gui"
|
||||
license=('GPL3')
|
||||
makedepends=('automoc4' 'cmake' 'kdelibs')
|
||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${_pkgbase}-${pkgver}-src.tar.xz")
|
||||
md5sums=('64c04c36eea017e7c0ddf687d60de128')
|
||||
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/build-"{plasmoid,qt4}
|
||||
mkdir "${srcdir}/build-"{plasmoid,qt4}
|
||||
}
|
||||
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_GUI:BOOL=0 \
|
||||
-DBUILD_LIBRARY:BOOL=0 \
|
||||
-DBUILD_HELPER:BOOL=0 \
|
||||
-DBUILD_KDE4:BOOL=1 \
|
||||
"../${_pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt4"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
-DUSE_CAPABILITIES:BOOL=0 \
|
||||
-DUSE_QT5:BOOL=0 \
|
||||
"../${_pkgbase}"
|
||||
make
|
||||
}
|
||||
|
||||
|
||||
package_kdeplasma-applets-netctl-gui() {
|
||||
pkgdesc="A KDE4 plasmoid, which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'kdebase-workspace')
|
||||
optdepends=('netctlgui-helper-qt4: DBus helper daemon'
|
||||
'netctl-gui-qt4: graphical front-end'
|
||||
'sudo: sudo support')
|
||||
install="kdeplasma-applets-netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_libnetctlgui-qt4() {
|
||||
pkgdesc="Qt4 library which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'qt4')
|
||||
optdepends=('netctlgui-helper-qt4: DBus helper daemon'
|
||||
'sudo: sudo support'
|
||||
'wpa_supplicant: wifi support')
|
||||
provides=('libnetctlgui')
|
||||
conflicts=('libnetctlgui')
|
||||
|
||||
cd "${srcdir}/build-qt4/netctlgui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctlgui-helper-qt4() {
|
||||
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
|
||||
depends=("libnetctlgui-qt4=${pkgver}")
|
||||
provides=('netctlgui-helper')
|
||||
conflicts=('netctlgui-helper')
|
||||
backup=('etc/netctl-gui.conf'
|
||||
'etc/dbus-1/system.d/org.netctlgui.helper.conf')
|
||||
install="netctlgui-helper.install"
|
||||
|
||||
cd "${srcdir}/build-qt4/helper"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctl-gui-qt4() {
|
||||
pkgdesc="Qt4 graphical front-end for netctl. A part of netctl-gui"
|
||||
depends=("libnetctlgui-qt4=${pkgver}")
|
||||
optdepends=('kdeplasma-applets-netctl-gui: KDE widget'
|
||||
'netctlgui-helper-qt4: DBus helper daemon')
|
||||
provides=('netctl-gui')
|
||||
conflicts=('netctl-gui')
|
||||
install="netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-qt4/gui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
cd "${srcdir}/build-qt4/resources"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
14
arch/plasma-netctl-gui.install
Normal file
14
arch/plasma-netctl-gui.install
Normal file
@ -0,0 +1,14 @@
|
||||
post_install() {
|
||||
cat << EOF
|
||||
Update plasmoids...
|
||||
EOF
|
||||
kbuildsycoca5 > /dev/null 2>&1
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install "$1"
|
||||
}
|
@ -1,12 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
ARCHIVE="netctl-gui"
|
||||
SRCDIR="sources"
|
||||
MAJOR=$(grep -m1 PROJECT_VERSION_MAJOR ${SRCDIR}/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
||||
MINOR=$(grep -m1 PROJECT_VERSION_MINOR ${SRCDIR}/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
||||
PATCH=$(grep -m1 PROJECT_VERSION_PATCH ${SRCDIR}/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
||||
VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
||||
|
||||
ARCHIVE="netctl-gui"
|
||||
FILES="AUTHORS CHANGELOG COPYING README.md"
|
||||
IGNORELIST="build *.qm *.cppcheck .git*"
|
||||
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)
|
||||
IGNORELIST="build *.qm *.cppcheck .git* *.kdev4"
|
||||
# update submodules
|
||||
git submodule update --init --recursive
|
||||
# create archive
|
||||
@ -14,14 +16,15 @@ git submodule update --init --recursive
|
||||
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
|
||||
cp -r "${SRCDIR}" "${ARCHIVE}"
|
||||
for FILE in ${FILES[*]}; do cp -r "$FILE" "${ARCHIVE}"; done
|
||||
for FILE in ${IGNORELIST[*]}; do find "${ARCHIVE}" -name "${FILE}" -exec rm -rf {} \;; done
|
||||
for FILE in ${IGNORELIST[*]}; do find "${ARCHIVE}" -name "${FILE}" -delete; done
|
||||
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
|
||||
ln -sf "../${ARCHIVE}-${VERSION}-src.tar.xz" arch
|
||||
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}'/" arch/PKGBUILD
|
||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" arch/PKGBUILD
|
||||
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" arch/PKGBUILD{,-qt4}
|
||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" arch/PKGBUILD{,-qt4}
|
||||
# clear
|
||||
find . -type f -name '*src.tar.xz' -not -name "*${VERSION}-src.tar.xz" -exec rm -rf {} \;
|
||||
find arch -type l -xtype l -exec rm -rf {} \;
|
||||
find . -type f -name '*src.tar.xz' -not -name "*${VERSION}-src.tar.xz" -delete
|
||||
find arch -type l -xtype l -delete
|
||||
|
23
sources/.kdev4/netctl-gui.kdev4
Normal file
23
sources/.kdev4/netctl-gui.kdev4
Normal file
@ -0,0 +1,23 @@
|
||||
[Buildset]
|
||||
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x14\x00n\x00e\x00t\x00c\x00t\x00l\x00-\x00g\x00u\x00i)
|
||||
|
||||
[CMake]
|
||||
Build Directory Count=1
|
||||
Current Build Directory Index=0
|
||||
ProjectRootRelative=./
|
||||
|
||||
[CMake][CMake Build Directory 0]
|
||||
Build Directory Path=file:///home/arcanis/Documents/github/netctl-gui/build
|
||||
Build Type=Release
|
||||
CMake Binary=file:///usr/bin/cmake
|
||||
Environment Profile=
|
||||
Extra Arguments=
|
||||
Install Directory=file:///usr
|
||||
|
||||
[Defines And Includes][Compiler]
|
||||
Name=GCC
|
||||
Path=gcc
|
||||
Type=GCC
|
||||
|
||||
[Project]
|
||||
VersionControlSupport=kdevgit
|
23
sources/.kdev4/sources.kdev4
Normal file
23
sources/.kdev4/sources.kdev4
Normal file
@ -0,0 +1,23 @@
|
||||
[Buildset]
|
||||
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x14\x00n\x00e\x00t\x00c\x00t\x00l\x00-\x00g\x00u\x00i)
|
||||
|
||||
[CMake]
|
||||
Build Directory Count=1
|
||||
Current Build Directory Index=0
|
||||
ProjectRootRelative=./
|
||||
|
||||
[CMake][CMake Build Directory 0]
|
||||
Build Directory Path=file:///home/arcanis/Documents/github/netctl-gui/build
|
||||
Build Type=Debug
|
||||
CMake Binary=file:///usr/bin/cmake
|
||||
Environment Profile=
|
||||
Extra Arguments=
|
||||
Install Directory=file:///usr
|
||||
|
||||
[Defines And Includes][Compiler]
|
||||
Name=GCC
|
||||
Path=gcc
|
||||
Type=GCC
|
||||
|
||||
[Project]
|
||||
VersionControlSupport=kdevgit
|
2
sources/3rdparty/language
vendored
2
sources/3rdparty/language
vendored
@ -1 +1 @@
|
||||
Subproject commit a119b60ed10ba1d2b805ee6607178a699a726180
|
||||
Subproject commit 319125b1fafff9da14c89a94de6ba2852c90c9c2
|
4
sources/3rdparty/language-config.h
vendored
4
sources/3rdparty/language-config.h
vendored
@ -4,9 +4,11 @@
|
||||
|
||||
// put your languages here comma separated
|
||||
// the first language is default language
|
||||
#define LANGUAGES "en,ru"
|
||||
#define LANGUAGES "en,ja,ru"
|
||||
// language key in the configuration file
|
||||
#define LANGUAGE_KEY "LANGUAGE"
|
||||
// name of config section in the file if any
|
||||
#define LANGUAGE_SECTION "Common"
|
||||
|
||||
|
||||
#endif /* LANGUAGE_CONFIG_H */
|
||||
|
41
sources/3rdparty/listmap/listmap.cpp
vendored
Normal file
41
sources/3rdparty/listmap/listmap.cpp
vendored
Normal 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/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "listmap.h"
|
||||
|
||||
|
||||
QMap<QString, QString> listToMap(const QStringList list)
|
||||
{
|
||||
QMap<QString, QString> map;
|
||||
for (int i=0; i<list.count(); i++) {
|
||||
QStringList str = list[i].split(QString("=="));
|
||||
if (str.count() != 2) continue;
|
||||
map[str[0]] = str[1];
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
QStringList mapToList(const QMap<QString, QString> map)
|
||||
{
|
||||
QStringList list;
|
||||
for (int i=0; i<map.keys().count(); i++)
|
||||
list.append(QString("%1==%2").arg(map.keys()[i]).arg(map[map.keys()[i]]));
|
||||
|
||||
return list;
|
||||
}
|
29
sources/3rdparty/listmap/listmap.h
vendored
Normal file
29
sources/3rdparty/listmap/listmap.h
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/***************************************************************************
|
||||
* 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 LISTMAP_H
|
||||
#define LISTMAP_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
QMap<QString, QString> listToMap(const QStringList list);
|
||||
QStringList mapToList(const QMap<QString,QString> map);
|
||||
|
||||
|
||||
#endif /* LISTMAP_H */
|
2
sources/3rdparty/pdebug
vendored
2
sources/3rdparty/pdebug
vendored
@ -1 +1 @@
|
||||
Subproject commit 294a590bb966fd79eb2e93a7b02377ca57731cd5
|
||||
Subproject commit 75e4a0df83478802bba53345486b42c56713fe09
|
2
sources/3rdparty/task
vendored
2
sources/3rdparty/task
vendored
@ -1 +1 @@
|
||||
Subproject commit d2798204a1a84a23a9510aeda73d5b9b75d2c8eb
|
||||
Subproject commit dd52af08c9d6a2c8652d2d5e21bc2a433efb497a
|
2
sources/3rdparty/tasks
vendored
2
sources/3rdparty/tasks
vendored
@ -1 +1 @@
|
||||
Subproject commit 230bdecd2c18ee2ec5350d94778a51158565c119
|
||||
Subproject commit 36f7ac299633e96f246fec160939207257ae0097
|
@ -1,4 +1,4 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
cmake_minimum_required (VERSION 2.8.12)
|
||||
|
||||
cmake_policy (SET CMP0003 OLD)
|
||||
cmake_policy (SET CMP0002 OLD)
|
||||
@ -10,8 +10,8 @@ set (PROJECT_AUTHOR "Evgeniy Alekseev")
|
||||
set (PROJECT_CONTACT "esalexeev@gmail.com")
|
||||
set (PROJECT_LICENSE "GPLv3")
|
||||
set (PROJECT_VERSION_MAJOR 1)
|
||||
set (PROJECT_VERSION_MINOR 3)
|
||||
set (PROJECT_VERSION_PATCH 3)
|
||||
set (PROJECT_VERSION_MINOR 4)
|
||||
set (PROJECT_VERSION_PATCH 9)
|
||||
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
|
||||
string (TIMESTAMP CURRENT_YEAR "%Y")
|
||||
@ -23,39 +23,52 @@ message (STATUS "Build date: ${CURRENT_DATE}")
|
||||
# install options
|
||||
option (USE_CAPABILITIES "Use setcap to set capabilities for the helper" ON)
|
||||
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
|
||||
# configuration
|
||||
include (config-defs.cmake)
|
||||
# components
|
||||
option (BUILD_GUI "Build GUI" ON)
|
||||
option (BUILD_HELPER "Build helper" ON)
|
||||
option (BUILD_LIBRARY "Build library" ON)
|
||||
option (BUILD_DATAENGINE "Build DataEngine" ON)
|
||||
option (BUILD_PLASMOID "Build plasmoid" ON)
|
||||
option (BUILD_KDE4 "Build on KDE4" OFF)
|
||||
if (BUILD_GUI OR BUILD_HELPER)
|
||||
set (BUILD_LIBRARY ON)
|
||||
set (BUILD_LIBRARY ON)
|
||||
endif ()
|
||||
if (BUILD_PLASMOID)
|
||||
set (BUILD_DATAENGINE ON)
|
||||
set (BUILD_DATAENGINE ON)
|
||||
endif ()
|
||||
# documentation
|
||||
option (BUILD_DOCS "Build Doxygen documentation" OFF)
|
||||
if (BUILD_DOCS)
|
||||
set (BUILD_LIBRARY ON)
|
||||
set (BUILD_LIBRARY ON)
|
||||
endif ()
|
||||
# test
|
||||
option (BUILD_TEST "Build unit tests" OFF)
|
||||
if (BUILD_TEST)
|
||||
set (BUILD_LIBRARY ON)
|
||||
set (BUILD_LIBRARY ON)
|
||||
endif ()
|
||||
# FIXME: dbus path
|
||||
set (DBUS_SYSTEMCONF_PATH "/etc/dbus-1/system.d/" CACHE STRING "Path to dbus system configuration files")
|
||||
set (SYSTEMD_SERVICE_PATH "lib/systemd/system" CACHE STRING "Path to systemd services")
|
||||
|
||||
# flags
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (CMAKE_CXX_FLAGS "-Wall -std=c++11")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
set (CMAKE_CXX_FLAGS "-Wall -std=c++11")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
# avoid newer gcc warnings
|
||||
add_definitions (-D_DEFAULT_SOURCE)
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set (CMAKE_CXX_FLAGS "-Wall -std=c++11 -stdlib=libc++")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
# linker flags
|
||||
set (CMAKE_EXE_LINKER_FLAGS "-lc++abi")
|
||||
set (CMAKE_MODULE_LINKER_FLAGS "-lc++abi")
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "-lc++abi")
|
||||
else ()
|
||||
message (STATUS "Unknown compiler")
|
||||
message (STATUS "Unknown compiler")
|
||||
endif ()
|
||||
|
||||
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
@ -68,21 +81,25 @@ add_subdirectory (${PROJECT_RESOURCE_DIR})
|
||||
|
||||
# components
|
||||
if (BUILD_LIBRARY)
|
||||
add_subdirectory (${PROJECT_LIBRARY})
|
||||
add_subdirectory (${PROJECT_LIBRARY})
|
||||
endif ()
|
||||
if (BUILD_HELPER)
|
||||
add_subdirectory (helper)
|
||||
add_subdirectory (helper)
|
||||
endif ()
|
||||
if (BUILD_TEST)
|
||||
enable_testing ()
|
||||
add_subdirectory (test)
|
||||
enable_testing ()
|
||||
add_subdirectory (test)
|
||||
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)
|
||||
if (BUILD_KDE4)
|
||||
add_subdirectory (plasmoid-kde4)
|
||||
else ()
|
||||
add_subdirectory (plasmoid-kf5)
|
||||
endif (BUILD_KDE4)
|
||||
endif ()
|
||||
|
41
sources/config-defs.cmake
Normal file
41
sources/config-defs.cmake
Normal file
@ -0,0 +1,41 @@
|
||||
# default configuration options
|
||||
|
||||
# [Common] section
|
||||
set (CFG_LANGUAGE "en" CACHE STRING "LANGUAGE key")
|
||||
set (CFG_MAINUPDATE "0" CACHE STRING "MAINUPDATE key")
|
||||
set (CFG_WIFIUPDATE "0" CACHE STRING "WIFIUPDATE key")
|
||||
set (CFG_SYSTRAY "true" CACHE STRING "SYSTRAY key")
|
||||
set (CFG_CLOSETOTRAY "true" CACHE STRING "CLOSETOTRAY key")
|
||||
set (CFG_STARTTOTRAY "false" CACHE STRING "STARTTOTRAY key")
|
||||
set (CFG_SKIPCOMPONENTS "false" CACHE STRING "SKIPCOMPONENTS key")
|
||||
|
||||
# [Helper] section
|
||||
set (CFG_USE_HELPER "true" CACHE STRING "USE_HELPER key")
|
||||
set (CFG_FORCE_SUDO "false" CACHE STRING "FORCE_SUDO key")
|
||||
set (CFG_CLOSE_HELPER "false" CACHE STRING "CLOSE_HELPER key")
|
||||
set (CFG_HELPER_PATH "netctlgui-helper" CACHE STRING "HELPER_PATH key")
|
||||
set (CFG_HELPER_SERVICE "netctlgui-helper.service" CACHE STRING "HELPER_SERVICE key")
|
||||
|
||||
# [netctl] section
|
||||
set (CFG_SYSTEMCTL_PATH "systemctl" CACHE STRING "SYSTEMCTL_PATH key")
|
||||
set (CFG_NETCTL_PATH "netctl" CACHE STRING "NETCTL_PATH key")
|
||||
set (CFG_NETCTLAUTO_PATH "netctl-auto" CACHE STRING "NETCTLAUTO_PATH key")
|
||||
set (CFG_NETCTLAUTO_SERVICE "netctl-auto" CACHE STRING "NETCTLAUTO_SERVICE key")
|
||||
set (CFG_PROFILE_DIR "/etc/netctl/" CACHE STRING "PROFILE_DIR key")
|
||||
|
||||
# [sudo] section
|
||||
set (CFG_SUDO_PATH "kdesu" CACHE STRING "SUDO_PATH key")
|
||||
|
||||
# [wpa_supplicant] section
|
||||
set (CFG_WPASUP_PATH "wpa_supplicant" CACHE STRING "WPASUP_PATH key")
|
||||
set (CFG_WPACLI_PATH "wpa_cli" CACHE STRING "WPACLI_PATH key")
|
||||
set (CFG_PID_FILE "/run/wpa_supplicant_$i.pid" CACHE STRING "PID_FILE key")
|
||||
set (CFG_WPA_DRIVERS "nl80211,wext" CACHE STRING "WPA_DRIVERS key")
|
||||
set (CFG_CTRL_DIR "/run/wpa_supplicant" CACHE STRING "CTRL_DIR key")
|
||||
set (CFG_CTRL_GROUP "users" CACHE STRING "CTRL_GROUP key")
|
||||
|
||||
# [Other] section
|
||||
set (CFG_EDITOR_PATH "gvim" CACHE STRING "EDITOR_PATH key")
|
||||
set (CFG_IFACE_DIR "/sys/class/net/" CACHE STRING "IFACE_DIR key")
|
||||
set (CFG_RFKILL_DIR "/sys/class/rfkill/" CACHE STRING "RFKILL_DIR key")
|
||||
set (CFG_PREFERED_IFACE "" CACHE STRING "PREFERED_IFACE key")
|
@ -3,21 +3,48 @@ set (SUBPROJECT plasma_engine_netctl)
|
||||
message (STATUS "Subproject ${SUBPROJECT}")
|
||||
|
||||
# find required libaries
|
||||
find_package (KDE4 REQUIRED)
|
||||
include (KDE4Defaults)
|
||||
if (BUILD_KDE4)
|
||||
find_package (KDE4 REQUIRED)
|
||||
include (KDE4Defaults)
|
||||
|
||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
set (KDE_INCLUDE ${KDE4_INCLUDES})
|
||||
else ()
|
||||
find_package (Qt5 REQUIRED COMPONENTS Widgets Network)
|
||||
find_package (ECM 0.0.11 REQUIRED NO_MODULE)
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
||||
find_package(KF5 REQUIRED COMPONENTS Plasma Service)
|
||||
|
||||
include (KDEInstallDirs)
|
||||
include (KDECMakeSettings)
|
||||
include (KDECompilerSettings)
|
||||
|
||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5Network_DEFINITIONS})
|
||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
||||
${Qt5Network_INCLUDE_DIRS})
|
||||
set (KDE_INCLUDE ${ConfigCore_INCLUDE_DIR}
|
||||
${CoreAddons_INCLUDE_DIR}
|
||||
${Plasma_INCLUDE_DIR}
|
||||
${Service_INCLUDE_DIR})
|
||||
endif ()
|
||||
|
||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${PROJECT_TRDPARTY_DIR})
|
||||
${PROJECT_TRDPARTY_DIR}
|
||||
${Qt_INCLUDE}
|
||||
${KDE_INCLUDE})
|
||||
|
||||
set (PLUGIN_NAME ${SUBPROJECT})
|
||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||
file (RELATIVE_PATH SUBPROJECT_DESKTOP ${CMAKE_SOURCE_DIR} ${SUBPROJECT_DESKTOP_IN})
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
|
||||
if (BUILD_KDE4)
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp)
|
||||
else ()
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp)
|
||||
endif ()
|
||||
set (TASK_HEADER ${PROJECT_TRDPARTY_DIR}/task/task.h)
|
||||
file (GLOB SUBPROJECT_CONF *.conf)
|
||||
|
||||
@ -25,11 +52,22 @@ file (GLOB SUBPROJECT_CONF *.conf)
|
||||
configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||
|
||||
# make
|
||||
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTNETWORK_LIBRARY})
|
||||
if (BUILD_KDE4)
|
||||
qt4_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_KDECORE_LIBS} ${KDE4_PLASMA_LIBS} ${QT_QTNETWORK_LIBRARY})
|
||||
else ()
|
||||
qt5_wrap_cpp (TASK_MOC_SOURCE ${TASK_HEADER})
|
||||
add_library (${PLUGIN_NAME} MODULE ${SUBPROJECT_SOURCE} ${TASK_MOC_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${Plasma_LIBRARIES} ${Qt5Network_LIBRARIES})
|
||||
kcoreaddons_desktop_to_json (${PLUGIN_NAME} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP})
|
||||
endif ()
|
||||
|
||||
# install
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
if (BUILD_KDE4)
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
else ()
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR}/plasma/dataengine)
|
||||
endif ()
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJECT_DESKTOP} DESTINATION ${SERVICES_INSTALL_DIR})
|
||||
install (FILES ${SUBPROJECT_CONF} DESTINATION ${CONFIG_INSTALL_DIR})
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="1">
|
||||
<libraries>
|
||||
<library>qt</library>
|
||||
</libraries>
|
||||
</project>
|
@ -1,17 +0,0 @@
|
||||
# Configuration file for netctl data engine
|
||||
|
||||
## Commands
|
||||
# command
|
||||
NETCTLCMD=/usr/bin/netctl
|
||||
# netctl-auto command
|
||||
NETCTLAUTOCMD=/usr/bin/netctl-auto
|
||||
|
||||
## External IP
|
||||
# external IPv4 check command
|
||||
EXTIP4CMD=curl ip4.telize.com
|
||||
# 'true' - check external IPv4
|
||||
EXTIP4=false
|
||||
# external IPv6 check command
|
||||
EXTIP6CMD=curl ip6.telize.com
|
||||
# 'true' - check external IPv6
|
||||
EXTIP6=false
|
@ -17,18 +17,27 @@
|
||||
|
||||
#include "netctl.h"
|
||||
|
||||
#include <KGlobal>
|
||||
#include <KStandardDirs>
|
||||
#include <Plasma/DataContainer>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QNetworkInterface>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
#include <version.h>
|
||||
|
||||
// KF5-KDE4 compability
|
||||
#ifdef BUILD_KDE4
|
||||
#include <KGlobal>
|
||||
#include <KStandardDirs>
|
||||
#else
|
||||
#include <QStandardPaths>
|
||||
#include <pdebug/pdebug-time.h>
|
||||
#endif /* BUILD_KDE4 */
|
||||
|
||||
|
||||
Netctl::Netctl(QObject *parent, const QVariantList &args)
|
||||
@ -36,13 +45,13 @@ Netctl::Netctl(QObject *parent, const QVariantList &args)
|
||||
{
|
||||
Q_UNUSED(args)
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
qInstallMessageHandler(debugString);
|
||||
#endif /* QT_VERSION >= 0x050000 */
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("NETCTLGUI_DEBUG"), QString("no"));
|
||||
if (debugEnv == QString("yes"))
|
||||
debug = true;
|
||||
else
|
||||
debug = false;
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
debug = (debugEnv == QString("yes"));
|
||||
|
||||
setMinimumPollingInterval(333);
|
||||
readConfiguration();
|
||||
@ -65,6 +74,7 @@ QStringList Netctl::sources() const
|
||||
sources.append(QString("current"));
|
||||
sources.append(QString("extip4"));
|
||||
sources.append(QString("extip6"));
|
||||
sources.append(QString("info"));
|
||||
sources.append(QString("interfaces"));
|
||||
sources.append(QString("intip4"));
|
||||
sources.append(QString("intip6"));
|
||||
@ -76,71 +86,43 @@ QStringList Netctl::sources() const
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getCmdOutput(const QString cmd) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
}
|
||||
|
||||
|
||||
void Netctl::readConfiguration()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// default configuration
|
||||
QMap<QString, QString> rawConfig;
|
||||
rawConfig[QString("EXTIP4")] = QString("false");
|
||||
rawConfig[QString("EXTIP4CMD")] = QString("curl ip4.telize.com");
|
||||
rawConfig[QString("EXTIP6")] = QString("false");
|
||||
rawConfig[QString("EXTIP6CMD")] = QString("curl ip6.telize.com");
|
||||
rawConfig[QString("NETCTLCMD")] = QString("/usr/bin/netctl");
|
||||
rawConfig[QString("NETCTLAUTOCMD")] = QString("/usr/bin/netctl-auto");
|
||||
|
||||
QString fileName = KGlobal::dirs()->findResource("config", "netctl.conf");
|
||||
QString fileName;
|
||||
#ifdef BUILD_KDE4
|
||||
fileName = KGlobal::dirs()->findResource("config", "plasma-dataengine-netctl.conf");
|
||||
#else
|
||||
fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, QString("plasma-dataengine-netctl.conf"));
|
||||
#endif /* BUILD_KDE4 */
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||
QFile configFile(fileName);
|
||||
if (!configFile.open(QIODevice::ReadOnly)) {
|
||||
configuration = updateConfiguration(rawConfig);
|
||||
return;
|
||||
}
|
||||
QString fileStr;
|
||||
QStringList value;
|
||||
while (true) {
|
||||
fileStr = QString(configFile.readLine()).trimmed();
|
||||
if ((fileStr.isEmpty()) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
|
||||
if (fileStr.contains(QChar('='))) {
|
||||
value.clear();
|
||||
for (int i=1; i<fileStr.split(QChar('=')).count(); i++)
|
||||
value.append(fileStr.split(QChar('='))[i]);
|
||||
rawConfig[fileStr.split(QChar('='))[0]] = value.join(QChar('='));
|
||||
}
|
||||
if (configFile.atEnd()) break;
|
||||
}
|
||||
configFile.close();
|
||||
configuration = updateConfiguration(rawConfig);
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
|
||||
return;
|
||||
}
|
||||
settings.beginGroup(QString("Netctl commands"));
|
||||
configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("netctl"));
|
||||
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("netctl-auto"));
|
||||
settings.endGroup();
|
||||
|
||||
|
||||
QMap<QString, QString> Netctl::updateConfiguration(const QMap<QString, QString> rawConfig)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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("EXTIP4CMD")) &&
|
||||
(key != QString("EXTIP6CMD")) &&
|
||||
(key != QString("NETCTLCMD")) &&
|
||||
(key != QString("NETCTLAUTOCMD")))
|
||||
value.remove(QChar(' '));
|
||||
config[key] = value;
|
||||
}
|
||||
|
||||
for (int i=0; i<config.keys().count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << config.keys()[i] + QString("=") + config[config.keys()[i]];
|
||||
|
||||
return config;
|
||||
settings.beginGroup(QString("External IP"));
|
||||
configuration[QString("EXTIP4")] = settings.value(QString("EXTIP4"), QString("false"));
|
||||
configuration[QString("EXTIP4CMD")] = settings.value(QString("EXTIP4CMD"), QString("curl ip4.telize.com"));
|
||||
configuration[QString("EXTIP6")] = settings.value(QString("EXTIP6"), QString("false"));
|
||||
configuration[QString("EXTIP6CMD")] = settings.value(QString("EXTIP6CMD"), QString("curl ip6.telize.com"));
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
|
||||
@ -153,65 +135,43 @@ bool Netctl::sourceRequestEvent(const QString &name)
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QString cmd;
|
||||
if (netctlAutoStatus)
|
||||
cmd = cmdNetctlAuto;
|
||||
else
|
||||
cmd = cmdNetctl;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
TaskResult process = runTask(cmd + QString(" list"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
QStringList currentProfile;
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profileList[i][0] == QChar('*'))
|
||||
currentProfile.append(profileList[i]);
|
||||
for (int i=0; i<currentProfile.count(); i++)
|
||||
currentProfile[i].remove(0, 2);
|
||||
|
||||
return currentProfile;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getExtIp(const QString cmd)
|
||||
QString Netctl::getExtIp(const QString cmd) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
|
||||
// test network connection
|
||||
if (!isNetworkActive()) return QString("N\\A");
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
QString extIp = QTextCodec::codecForMib(106)->toUnicode(process.output).trimmed();
|
||||
|
||||
return extIp;
|
||||
return getCmdOutput(cmd);
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getInterfaceList()
|
||||
QString Netctl::getInfo(const QStringList profiles, const QStringList statuses) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (profiles.count() != statuses.count()) return QString("N\\A");
|
||||
|
||||
QStringList list;
|
||||
for (int i=0; i<profiles.count(); i++)
|
||||
list.append(QString("%1 (%2)").arg(profiles.at(i)).arg(statuses.at(i)));
|
||||
if (list.isEmpty()) list.append(QString("N\\A"));
|
||||
|
||||
return list.join(QString(" | "));
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getInterfaceList() const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<QNetworkInterface> rawList = QNetworkInterface::allInterfaces();
|
||||
QStringList interfacesList;
|
||||
for (int i=0; i<rawList.count(); i++)
|
||||
interfacesList.append(rawList[i].name());
|
||||
foreach(QNetworkInterface interface, rawList)
|
||||
interfacesList.append(interface.name());
|
||||
|
||||
return interfacesList;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol)
|
||||
QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
@ -221,100 +181,64 @@ QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol)
|
||||
else if (protocol == QAbstractSocket::IPv6Protocol)
|
||||
intIp = QString("::1/128");
|
||||
QList<QHostAddress> rawList = QNetworkInterface::allAddresses();
|
||||
for (int i=0; i<rawList.count(); i++) {
|
||||
if(rawList[i] == QHostAddress(QHostAddress::LocalHost)) continue;
|
||||
if(rawList[i] == QHostAddress(QHostAddress::LocalHostIPv6)) continue;
|
||||
if (rawList[i].protocol() == protocol) {
|
||||
intIp = rawList[i].toString();
|
||||
break;
|
||||
}
|
||||
foreach(QHostAddress address, rawList) {
|
||||
if (address == QHostAddress(QHostAddress::LocalHost)) continue;
|
||||
if (address == QHostAddress(QHostAddress::LocalHostIPv6)) continue;
|
||||
if (address.protocol() != protocol) continue;
|
||||
intIp = address.toString();
|
||||
break;
|
||||
}
|
||||
|
||||
return intIp;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getNetctlAutoStatus(const QString cmdNetctlAuto)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
TaskResult process = runTask(cmdNetctlAuto + QString(" list"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
QString status;
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
if (cmdOutput.isEmpty()) {
|
||||
netctlAutoStatus = false;
|
||||
status = QString("false");
|
||||
} else {
|
||||
netctlAutoStatus = true;
|
||||
status = QString("true");
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QString cmd;
|
||||
if (netctlAutoStatus)
|
||||
cmd = cmdNetctlAuto;
|
||||
else
|
||||
cmd = cmdNetctl;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
TaskResult process = runTask(cmd + QString(" list"));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
QString output = getCmdOutput(QString("%1 list").arg(cmdNetctlAuto));
|
||||
if (output.isEmpty()) {
|
||||
output = getCmdOutput(QString("%1 list").arg(cmdNetctl));
|
||||
netctlAutoStatus = false;
|
||||
} else
|
||||
netctlAutoStatus = true;
|
||||
|
||||
// parse
|
||||
QStringList currentProfiles;
|
||||
// workaround for first element spaces on which are trimmed
|
||||
QStringList profileList = QString(" %1").arg(output).split(QChar('\n'));
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
bool isActive = (profileList.at(i)[0] == QChar('*'));
|
||||
profileList[i].remove(0, 2);
|
||||
if (isActive) currentProfiles.append(profileList.at(i));
|
||||
}
|
||||
profileList.sort();
|
||||
currentProfiles.sort();
|
||||
|
||||
// return profiles
|
||||
currentProfile = currentProfiles;
|
||||
status = !currentProfiles.isEmpty();
|
||||
return profileList;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
QStringList Netctl::getProfileStringStatus(const QString cmdNetctl) const
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QStringList status;
|
||||
if (netctlAutoStatus)
|
||||
if (netctlAutoStatus) {
|
||||
status.append(QString("netctl-auto"));
|
||||
else {
|
||||
QStringList profiles = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
TaskResult process = runTask(cmdNetctl + QString(" is-enabled ") + profiles[i]);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
if (process.exitCode == 0)
|
||||
status.append(QString("enabled"));
|
||||
else
|
||||
status.append(QString("static"));
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QString status = QString("false");
|
||||
QStringList currentProfile = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
|
||||
if (!currentProfile.isEmpty())
|
||||
status = QString("true");
|
||||
foreach(QString profile, currentProfile) {
|
||||
TaskResult process = runTask(QString("%1 is-enabled %2").arg(cmdNetctl).arg(profile));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
status.append(process.exitCode == 0 ? QString("enabled") : QString("static"));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -325,24 +249,8 @@ void Netctl::initSources()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList sourcesList = sources();
|
||||
for (int i=0; i<sourcesList.count(); i++)
|
||||
setData(sourcesList[i], QString("value"), QString("N\\A"));
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::isNetworkActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString cmd = QString("ping -c 1 google.com");
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd" << cmd;
|
||||
TaskResult process = runTask(cmd);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
|
||||
if (process.exitCode == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
foreach(QString source, sourcesList)
|
||||
setData(source, QString("value"), QString("N\\A"));
|
||||
}
|
||||
|
||||
|
||||
@ -353,18 +261,17 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
|
||||
QString value = QString("N\\A");
|
||||
if (source == QString("active")) {
|
||||
value = getStatus(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")]);
|
||||
value = status ? QString("true") : QString("false");
|
||||
} else if (source == QString("current")) {
|
||||
value = getCurrentProfile(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")])
|
||||
.join(QChar('|'));
|
||||
value = currentProfile.join(QChar('|'));
|
||||
} else if (source == QString("extip4")) {
|
||||
if (configuration[QString("EXTIP4")] == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP4CMD")]);
|
||||
if (configuration[QString("EXTIP4")].toString() == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP4CMD")].toString());
|
||||
} else if (source == QString("extip6")) {
|
||||
if (configuration[QString("EXTIP6")] == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP6CMD")]);
|
||||
if (configuration[QString("EXTIP6")].toString() == QString("true"))
|
||||
value = getExtIp(configuration[QString("EXTIP6CMD")].toString());
|
||||
} else if (source == QString("info")) {
|
||||
value = getInfo(currentProfile, currentStatus);
|
||||
} else if (source == QString("interfaces")) {
|
||||
value = getInterfaceList().join(QChar(','));
|
||||
} else if (source == QString("intip4")) {
|
||||
@ -372,15 +279,13 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
} else if (source == QString("intip6")) {
|
||||
value = getIntIp(QAbstractSocket::IPv6Protocol);
|
||||
} else if (source == QString("netctlauto")) {
|
||||
value = getNetctlAutoStatus(configuration[QString("NETCTLAUTOCMD")]);
|
||||
value = netctlAutoStatus ? QString("true") : QString("false");
|
||||
} else if (source == QString("profiles")) {
|
||||
value = getProfileList(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")])
|
||||
.join(QChar(','));
|
||||
value = getProfileList(configuration[QString("NETCTLCMD")].toString(),
|
||||
configuration[QString("NETCTLAUTOCMD")].toString()).join(QChar(','));
|
||||
} else if (source == QString("status")) {
|
||||
value = getProfileStringStatus(configuration[QString("NETCTLCMD")],
|
||||
configuration[QString("NETCTLAUTOCMD")])
|
||||
.join(QChar('|'));
|
||||
currentStatus = getProfileStringStatus(configuration[QString("NETCTLCMD")].toString());
|
||||
value = currentStatus.join(QChar('|'));
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
|
||||
@ -388,6 +293,10 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
}
|
||||
|
||||
|
||||
#ifdef BUILD_KDE4
|
||||
K_EXPORT_PLASMA_DATAENGINE(netctl, Netctl)
|
||||
#else
|
||||
K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(netctl, Netctl, "plasma-dataengine-netctl.json")
|
||||
#endif /* BUILD_KDE4 */
|
||||
|
||||
#include "netctl.moc"
|
||||
|
@ -27,17 +27,14 @@ class Netctl : public Plasma::DataEngine
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Netctl(QObject *parent, const QVariantList &args);
|
||||
~Netctl();
|
||||
QStringList getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
QString getExtIp(const QString cmd);
|
||||
QStringList getInterfaceList();
|
||||
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol);
|
||||
QString getNetctlAutoStatus(const QString cmdNetctlAuto);
|
||||
explicit Netctl(QObject *parent, const QVariantList &args);
|
||||
virtual ~Netctl();
|
||||
QString getExtIp(const QString cmd) const;
|
||||
QString getInfo(const QStringList profiles, const QStringList statuses) const;
|
||||
QStringList getInterfaceList() const;
|
||||
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol) const;
|
||||
QStringList getProfileList(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
QStringList getProfileStringStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
QString getStatus(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||
bool isNetworkActive();
|
||||
QStringList getProfileStringStatus(const QString cmdNetctl) const;
|
||||
|
||||
public slots:
|
||||
void initSources();
|
||||
@ -48,13 +45,16 @@ protected:
|
||||
QStringList sources() const;
|
||||
|
||||
private:
|
||||
bool netctlAutoStatus;
|
||||
QString currentProfile;
|
||||
bool isNetctlCheckRunning = false;
|
||||
bool netctlAutoStatus = false;
|
||||
bool status = false;
|
||||
QStringList currentProfile;
|
||||
QStringList currentStatus;
|
||||
// configuration
|
||||
bool debug;
|
||||
QMap<QString, QString> configuration;
|
||||
QVariantMap configuration;
|
||||
QString getCmdOutput(const QString cmd) const;
|
||||
void readConfiguration();
|
||||
QMap<QString, QString> updateConfiguration(const QMap<QString, QString> rawConfig);
|
||||
};
|
||||
|
||||
|
||||
|
9
sources/dataengine/plasma-dataengine-netctl.conf
Normal file
9
sources/dataengine/plasma-dataengine-netctl.conf
Normal file
@ -0,0 +1,9 @@
|
||||
[Netctl commands]
|
||||
NETCTLCMD=netctl
|
||||
NETCTLAUTOCMD=netctl-auto
|
||||
|
||||
[External IP]
|
||||
EXTIP4CMD=curl ip4.telize.com
|
||||
EXTIP4=false
|
||||
EXTIP6CMD=curl ip6.telize.com
|
||||
EXTIP6=false
|
@ -10,11 +10,11 @@ X-KDE-ServiceTypes=Plasma/DataEngine
|
||||
X-KDE-Library=plasma_engine_netctl
|
||||
X-Plasma-EngineName=netctl
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=netctl
|
||||
X-KDE-PluginInfo-Version=@PROJECT_VERSION@
|
||||
X-KDE-PluginInfo-Website=http://arcan1s.github.io/projects/netctlplasmoid
|
||||
X-KDE-PluginInfo-Website=https://arcanis.me/projects/netctl-gui/
|
||||
X-KDE-PluginInfo-Category=Network
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
@ -1,12 +1,12 @@
|
||||
# build pages
|
||||
file (GLOB SUBPROJECT_DOCS_IN *.html)
|
||||
file (GLOB SUBPROJECT_IMGS *.png)
|
||||
foreach (DOC_IN ${SUBPROJECT_DOCS_IN})
|
||||
file (RELATIVE_PATH ONE_DOC ${CMAKE_SOURCE_DIR} ${DOC_IN})
|
||||
configure_file (${DOC_IN} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC})
|
||||
set (SUBPROJECT_DOCS ${SUBPROJECT_DOCS} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC})
|
||||
endforeach ()
|
||||
|
||||
foreach (DOC_IN ${SUBPROJECT_DOCS_IN})
|
||||
file (RELATIVE_PATH ONE_DOC ${CMAKE_SOURCE_DIR} ${DOC_IN})
|
||||
configure_file (${DOC_IN} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC})
|
||||
set (SUBPROJECT_DOCS ${SUBPROJECT_DOCS} ${CMAKE_CURRENT_BINARY_DIR}/${ONE_DOC})
|
||||
endforeach ()
|
||||
|
||||
install (FILES ${SUBPROJECT_DOCS} DESTINATION share/doc/${PROJECT_NAME})
|
||||
install (FILES ${SUBPROJECT_IMGS} DESTINATION share/doc/${PROJECT_NAME})
|
||||
|
@ -35,6 +35,7 @@ small {
|
||||
<li><a href="#api">DBus API</a></li>
|
||||
<li><a href="#helper">Helper API</a></li>
|
||||
<li><a href="#ctrl">Helper ctrl API</a></li>
|
||||
<li><a href="#interface">Helper interface API</a></li>
|
||||
<li><a href="#netctl">Helper netctl API</a></li>
|
||||
<li><a href="#gui">GUI API</a></li>
|
||||
<li><a href="#netctlgui">GUI netctlgui API</a></li>
|
||||
@ -74,7 +75,7 @@ small {
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList FindSettings()</td>
|
||||
<td>scans system and suggests the recommended configuration which will be used by the library</td>
|
||||
<td>scans system and suggests the recommended configuration which may be used by the library</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -196,23 +197,105 @@ small {
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<!-- wpa_supplicant actions -->
|
||||
<tr>
|
||||
<td>QStringList CurrentWiFi()</td>
|
||||
<td>returns current WiFi point in format <code>NAME|SECURITY|TYPE|FREQ|MAC|SIGNAL|ACTIVE|EXISTS</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList VerboseWiFi()</td>
|
||||
<td>returns available WiFi points in format <code>NAME|SECURITY|TYPE|FREQS|MACS|SIGNAL|ACTIVE|EXISTS</code>. First line is always active connection (see <code>CurrentWiFi()</code>)</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList WiFi()</td>
|
||||
<td>returns available WiFi points in format <code>NAME|SECURITY|SIGNAL|ACTIVE|EXISTS</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<!-- /interface path -->
|
||||
<tr>
|
||||
<th colspan="3" class="sub"><a href="#interface" class="anchor" id="interface"></a><code>/interface</code> path</th>
|
||||
</tr>
|
||||
<!-- netctl control -->
|
||||
<tr>
|
||||
<td>int Enable(QString profile)</td>
|
||||
<td>enables or disables the profile. Returns is the profile enabled or <code>2</code> if there was an another error</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>int Restart(QString profile)</td>
|
||||
<td>restarts the profile. Returns is the profile active or <code>2</code> if there was an error</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>int Start(QString profile)</td>
|
||||
<td>starts or stops the profile. Returns is the profile active or <code>2</code> if there was an error</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool StopAll()</td>
|
||||
<td>synonym of <code>/ctlr/StopAll()</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool SwitchTo(QString profile)</td>
|
||||
<td>switchs to the profile (works with netctl and netctl-auto). Returns is the profile active or <code>2</code> if there was an error</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>int Create(QString profile, QStringList settingsList)</td>
|
||||
<td>>creates the profile with specified settings. Settings should be given in the format <code>KEY==VALUE</code>. Returns <code>1</code> if action has been performed successfully, <code>0</code> if there was an error in the profile copying and <code>2</code> if there was an another error</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList Profile(QString profile)</td>
|
||||
<td>synonym of <code>/netctl/Profile()</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>int Remove(QString profile)</td>
|
||||
<td>synonym of <code>/ctrl/Remove()</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<!-- information -->
|
||||
<tr>
|
||||
<td>QStringList Information()</td>
|
||||
<td>returns general information in format <code>[IsNetctlAutoActive, NetctlProfiles, NetctlAutoProfiles]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList Status()</td>
|
||||
<td>returns actual information in format <code>[IsNetctlAutoActive, ProfilesNames, ActiveProfile, ActiveProfileEnables]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<!-- wpa_supplicant actions -->
|
||||
<tr>
|
||||
<td>int Essid(QString essid, QStringList settingsList)</td>
|
||||
<td>connects to WiFi point with the given ESSID, calls KnownEssid or UnknownESSID depending on whether there is a profile. Settings may be empty. To get return codes refer to <code>KnownEssid()</code> and <code>UnknownEssid()</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>int KnownEssid(QString essid)</td>
|
||||
<td>connects to WiFi point with the given ESSID with existent profile. Returns <code>Start()</code> if ok, in other cases returns <code>2</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>int UnknownEssid(QString essid, QStringList settingsList)</td>
|
||||
<td>creates a profile and connects to WiFi point with the given ESSID. Returns <code>Start()</code> if ok, in other cases returns <code>2</code></td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<!-- /netctl path -->
|
||||
<tr>
|
||||
<th colspan="3" class="sub"><a href="#netctl" class="anchor" id="netctl"></a><code>/netctl</code> path</th>
|
||||
</tr>
|
||||
<!-- general information -->
|
||||
<tr>
|
||||
<td>QString ActiveProfile()</td>
|
||||
<td>QStringList ActiveProfile()</td>
|
||||
<td>returns active profile from netctl or netctl-auto</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString ActiveProfileStatus()</td>
|
||||
<td>QStringList ActiveProfileStatus()</td>
|
||||
<td>returns active profile status from netctl or netctl-auto. May be <code>netctl-auto</code>, <code>active (enabled)</code>, <code>active (static)</code>, <code>inactive (enabled)</code>, <code>inactive (static)</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
@ -221,11 +304,31 @@ small {
|
||||
<td>returns general information in format <code>[ActiveProfile, ActiveProfileStatus]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList netctlActiveProfile()</td>
|
||||
<td>returns active profile from netctl even if netctl-auto is running</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList netctlProfileList()</td>
|
||||
<td>returns available profiles in format <code>NAME|DESCRIPTION|ACTIVE|ENABLED</code> from netctl even if netctl-auto is running</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList netctlVerboseProfileList()</td>
|
||||
<td>returns available profiles in format <code>NAME|DESCRIPTION|TYPE|INTERFACE|ESSID|ACTIVE|ENABLED|NETCTL-AUTO</code> from netctl even if netctl-auto is running</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList ProfileList()</td>
|
||||
<td>returns available profiles in format <code>NAME|DESCRIPTION|ACTIVE|ENABLED</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList VerboseProfileList()</td>
|
||||
<td>returns available profiles in format <code>NAME|DESCRIPTION|TYPE|INTERFACE|ESSID|ACTIVE|ENABLED|NETCTL-AUTO</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList WirelessInterface()</td>
|
||||
<td>returns wireless interfaces</td>
|
||||
@ -279,11 +382,15 @@ small {
|
||||
<td>returns value of the key by the given profile or empty line</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList ProfileValues(QString profile, QStringList keys)</td>
|
||||
<td>returns values of the keys by the given profile or empty lines</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<!-- gui service -->
|
||||
<tr>
|
||||
<th colspan="3"><a href="#gui" class="anchor" id="gui"></a><code>org.netctlgui.netctlgui</code> service (session bus)</th>
|
||||
</tr>
|
||||
<!-- /netctlgui path -->
|
||||
<tr>
|
||||
<th colspan="3" class="sub"><a href="#netctlgui" class="anchor" id="netctlgui"></a><code>/netctlgui</code> path</th>
|
||||
</tr>
|
||||
@ -303,11 +410,6 @@ small {
|
||||
<td><code>true</code> and closes the application</td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QString Information()</td>
|
||||
<td>returns general information in format <code>[ActiveProfile, ActiveProfileStatus]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>void LibraryDocs()</td>
|
||||
<td>opens the library documentation</td>
|
||||
@ -358,16 +460,11 @@ small {
|
||||
<td>returns the application process UIDs <code>[UID, EUID]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>QStringList VerboseInformation()</td>
|
||||
<td>returns information in format <code>[isNetctlAutoActive, ProfileList, ActiveProfile, isProfileEnabled/autoIsProfileEnabled]</code></td>
|
||||
<td>no</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2><a href="#links" class="anchor" id="links"></a>External links</h2>
|
||||
<ul>
|
||||
<li><a href="http://arcanis.name/projects/netctl-gui/">Homepage</a></li>
|
||||
<li><a href="https://arcanis.me/projects/netctl-gui/">Homepage</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
|
||||
</ul>
|
||||
|
@ -98,7 +98,7 @@ env -i bash -c "source '<profile>'; for i in ${!<key>[@]}; do ec
|
||||
|
||||
<h2><a href="#links" class="anchor" id="links"></a>External links</h2>
|
||||
<ul>
|
||||
<li><a href="http://arcanis.name/projects/netctl-gui/">Homepage</a></li>
|
||||
<li><a href="https://arcanis.me/projects/netctl-gui/">Homepage</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui">Repository</a></li>
|
||||
<li><a href="https://github.com/arcan1s/netctl-gui/issues">Bugtracker</a></li>
|
||||
</ul>
|
||||
|
@ -1,6 +1,14 @@
|
||||
# set files
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp)
|
||||
if (USE_QT5)
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/listmap/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/pdebug/*.cpp)
|
||||
else ()
|
||||
file (GLOB_RECURSE SOURCES *.cpp ${PROJECT_TRDPARTY_DIR}/task/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.cpp
|
||||
${PROJECT_TRDPARTY_DIR}/listmap/*.cpp)
|
||||
endif ()
|
||||
file (GLOB_RECURSE HEADERS *.h ${PROJECT_TRDPARTY_DIR}/task/*.h
|
||||
${PROJECT_TRDPARTY_DIR}/language/*.h)
|
||||
file (GLOB_RECURSE FORMS *.ui ${PROJECT_TRDPARTY_DIR}/about/*.ui)
|
||||
@ -18,40 +26,40 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/includ
|
||||
link_directories (${PROJECT_LIBRARY}/src/lib)
|
||||
|
||||
if (USE_QT5)
|
||||
find_package(Qt5 COMPONENTS Core DBus Widgets LinguistTools REQUIRED)
|
||||
add_definitions(${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5LinguistTools_DEFINITIONS})
|
||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Widgets_LIBRARIES})
|
||||
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt5_wrap_ui (UI_HEADERS ${FORMS})
|
||||
qt5_add_resources (QRC_SOURCES ${RESOURCES})
|
||||
find_package (Qt5 COMPONENTS Core DBus Widgets LinguistTools REQUIRED)
|
||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5LinguistTools_DEFINITIONS})
|
||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5DBus_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||
set (QT_NEEDED_LIBS ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} ${Qt5Widgets_LIBRARIES})
|
||||
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt5_wrap_ui (UI_HEADERS ${FORMS})
|
||||
qt5_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 ${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})
|
||||
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})
|
||||
else ()
|
||||
find_package (Qt4 COMPONENTS QtCore QtDBus QtGui REQUIRED)
|
||||
include (${QT_USE_FILE})
|
||||
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY})
|
||||
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt4_wrap_ui (UI_HEADERS ${FORMS})
|
||||
qt4_add_resources (QRC_SOURCES ${RESOURCES})
|
||||
find_package (Qt4 COMPONENTS QtCore QtDBus QtGui REQUIRED)
|
||||
include (${QT_USE_FILE})
|
||||
set (QT_NEEDED_LIBS ${QT_QTCORE_LIBRARY} ${QT_QTDBUS_LIBRARY} ${QT_QTGUI_LIBRARY})
|
||||
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})
|
||||
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})
|
||||
endif()
|
||||
|
||||
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
||||
|
69
sources/gui/src/bondwidget.cpp
Normal file
69
sources/gui/src/bondwidget.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/***************************************************************************
|
||||
* 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 "bondwidget.h"
|
||||
#include "ui_bondwidget.h"
|
||||
|
||||
|
||||
BondWidget::BondWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::BondWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
BondWidget::~BondWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void BondWidget::clear()
|
||||
{
|
||||
ui->lineEdit_mode->setText(QString("balance-rr"));
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> BondWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
if (ui->lineEdit_mode->text() != QString("balance-rr"))
|
||||
settings[QString("Mode")] = ui->lineEdit_mode->text();
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
int BondWidget::isOk()
|
||||
{
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void BondWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
|
||||
if (settings.contains(QString("Mode")))
|
||||
ui->lineEdit_mode->setText(settings[QString("Mode")]);
|
||||
}
|
47
sources/gui/src/bondwidget.h
Normal file
47
sources/gui/src/bondwidget.h
Normal file
@ -0,0 +1,47 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-gui is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-gui is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef BONDWIDGET_H
|
||||
#define BONDWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class BondWidget;
|
||||
}
|
||||
|
||||
class BondWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BondWidget(QWidget *parent = 0);
|
||||
~BondWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
|
||||
private:
|
||||
Ui::BondWidget *ui;
|
||||
};
|
||||
|
||||
|
||||
#endif /* BONDWIDGET_H */
|
71
sources/gui/src/bondwidget.ui
Normal file
71
sources/gui/src/bondwidget.ui
Normal file
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BondWidget</class>
|
||||
<widget class="QWidget" name="BondWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>550</width>
|
||||
<height>46</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_bond">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Bond settings</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_bond">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mode">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The bonding policy. See the kernel documentation on bonding for details</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -40,26 +40,16 @@ void BridgeWidget::clear()
|
||||
}
|
||||
|
||||
|
||||
void BridgeWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> BridgeWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> bridgeSettings;
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return bridgeSettings;
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
if (ui->checkBox_skip->checkState() == Qt::Checked)
|
||||
bridgeSettings[QString("SkipForwardingDelay")] = QString("yes");
|
||||
settings[QString("SkipForwardingDelay")] = QString("yes");
|
||||
|
||||
return bridgeSettings;
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
@ -73,9 +63,8 @@ int BridgeWidget::isOk()
|
||||
void BridgeWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> bridgeSettings = settings;
|
||||
|
||||
if (bridgeSettings.contains(QString("SkipForwardingDelay")))
|
||||
if (bridgeSettings[QString("SkipForwardingDelay")] == QString("yes"))
|
||||
if (settings.contains(QString("SkipForwardingDelay")))
|
||||
if (settings[QString("SkipForwardingDelay")] == QString("yes"))
|
||||
ui->checkBox_skip->setCheckState(Qt::Checked);
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private:
|
||||
Ui::BridgeWidget *ui;
|
||||
|
@ -6,14 +6,14 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>424</width>
|
||||
<height>76</height>
|
||||
<width>550</width>
|
||||
<height>44</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_bridge">
|
||||
<property name="features">
|
||||
@ -24,15 +24,38 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_bridge">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
||||
<layout class="QHBoxLayout" name="layout_skip">
|
||||
<item>
|
||||
<widget class="QLabel" name="labe_skip">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_skip">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
243
sources/gui/src/calls.cpp
Normal file
243
sources/gui/src/calls.cpp
Normal file
@ -0,0 +1,243 @@
|
||||
/***************************************************************************
|
||||
* 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 "calls.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <listmap/listmap.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "dbusoperation.h"
|
||||
|
||||
|
||||
InterfaceAnswer createProfileSlot(const QString profile, QMap<QString,QString> settings,
|
||||
NetctlInterface* interface, const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (!useHelper) return interface->createProfile(profile, settings);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
args.append(mapToList(settings));
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("Create"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer enableProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (!useHelper) return interface->enableProfile(profile);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("Enable"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer removeProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (!useHelper) return interface->removeProfile(profile);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("Remove"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer restartProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (!useHelper) return interface->restartProfile(profile);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("Restart"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer startProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (!useHelper) return interface->startProfile(profile);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("Start"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer stopAllProfilesSlot(NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (!useHelper) return interface->stopAllProfiles();
|
||||
try {
|
||||
int responce = sendRequestToInterface(QString("StopAll"), debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer switchToProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
if (!useHelper) return interface->switchToProfile(profile);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("SwitchTo"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InterfaceAnswer connectToEssid(const QString essid, QMap<QString,QString> settings,
|
||||
NetctlInterface* interface, const bool useHelper, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "ESSID" << essid;
|
||||
|
||||
|
||||
if (!useHelper) return interface->connectToEssid(essid, settings);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(essid);
|
||||
args.append(mapToList(settings));
|
||||
int responce = sendRequestToInterfaceWithArgs(QString("Essid"), args, debug)[0].toInt();
|
||||
return static_cast<InterfaceAnswer>(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return InterfaceAnswer::Error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
netctlInformation generalInformation(NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (!useHelper) return interface->information();
|
||||
try {
|
||||
QList<QVariant> responce = sendRequestToInterface(QString("Information"), debug);
|
||||
// main
|
||||
netctlInformation info;
|
||||
info.netctlAuto = responce[0].toStringList().takeFirst().toInt();
|
||||
info.netctlAutoEnabled = responce[0].toStringList().takeFirst().toInt();
|
||||
QList<netctlProfileInfo> profiles = parseOutputNetctl(responce);
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
if (profiles[i].netctlAuto)
|
||||
info.netctlAutoProfiles.append(profiles[i]);
|
||||
else
|
||||
info.netctlProfiles.append(profiles[i]);
|
||||
}
|
||||
return info;
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return netctlInformation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> profileInformation(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug)
|
||||
{
|
||||
if (!useHelper) return interface->profileSettings(profile);
|
||||
try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
QStringList responce = sendRequestToInterfaceWithArgs(QString("Profile"), args, debug)[0].toStringList();
|
||||
return listToMap(responce);
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return QMap<QString, QString>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
netctlCurrent trayInformation(NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (!useHelper) return interface->status();
|
||||
try {
|
||||
QStringList responce = sendRequestToInterface(QString("Status"), debug)[0].toStringList();
|
||||
netctlCurrent status;
|
||||
status.netctlAuto = responce[0].toInt();
|
||||
status.profiles = responce[1].split(QChar('|'));
|
||||
status.current = responce[2].split(QChar('|'));
|
||||
QStringList enables = responce[3].split(QChar('|'));
|
||||
for (int i=0; i<enables.count(); i++)
|
||||
status.enables.append(enables[i].toInt());
|
||||
return status;
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return netctlCurrent();
|
||||
}
|
||||
}
|
55
sources/gui/src/calls.h
Normal file
55
sources/gui/src/calls.h
Normal 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 CALLS_H
|
||||
#define CALLS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
// control
|
||||
InterfaceAnswer createProfileSlot(const QString profile, const QMap<QString,QString> settings,
|
||||
NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug = false);
|
||||
InterfaceAnswer enableProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug = false);
|
||||
InterfaceAnswer removeProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug = false);
|
||||
InterfaceAnswer restartProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug = false);
|
||||
InterfaceAnswer startProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug = false);
|
||||
InterfaceAnswer stopAllProfilesSlot(NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug = false);
|
||||
InterfaceAnswer switchToProfileSlot(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug = false);
|
||||
// wireless connection
|
||||
InterfaceAnswer connectToEssid(const QString essid, QMap<QString,QString> settings,
|
||||
NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug = false);
|
||||
// information
|
||||
netctlInformation generalInformation(NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug = false);
|
||||
QMap<QString, QString> profileInformation(const QString profile, NetctlInterface *interface,
|
||||
const bool useHelper, const bool debug = false);
|
||||
netctlCurrent trayInformation(NetctlInterface *interface, const bool useHelper,
|
||||
const bool debug = false);
|
||||
|
||||
|
||||
#endif /* CALLS_H */
|
88
sources/gui/src/commonfunctions.cpp
Normal file
88
sources/gui/src/commonfunctions.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
/***************************************************************************
|
||||
* 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 "commonfunctions.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
|
||||
bool checkExternalApps(const QString apps, const QMap<QString, QString> configuration,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Applications" << apps;
|
||||
|
||||
if (configuration[QString("SKIPCOMPONENTS")] == QString("true")) return true;
|
||||
QStringList cmd;
|
||||
cmd.append("which");
|
||||
// avoid null-lines arguments
|
||||
cmd.append("true");
|
||||
cmd.append(externalApps(apps, configuration));
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd.join(QChar(' '));
|
||||
TaskResult process = runTask(cmd.join(QChar(' ')), false);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
return (process.exitCode == 0);
|
||||
}
|
||||
|
||||
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse)
|
||||
{
|
||||
if (statusBool) return QApplication::translate("MainWindow", "yes");
|
||||
if (!nullFalse) return QApplication::translate("MainWindow", "no");
|
||||
|
||||
return QString("");
|
||||
}
|
||||
|
||||
|
||||
QStringList externalApps(const QString apps, const QMap<QString, QString> configuration)
|
||||
{
|
||||
QStringList app;
|
||||
// editor works always over cmd
|
||||
if ((apps == QString("editor")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("EDITOR_PATH")]);
|
||||
app.append(configuration[QString("SUDO_PATH")]);
|
||||
}
|
||||
if ((apps == QString("helper")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("HELPER_PATH")]);
|
||||
}
|
||||
if ((apps == QString("netctl")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("NETCTL_PATH")]);
|
||||
app.append(configuration[QString("NETCTLAUTO_PATH")]);
|
||||
}
|
||||
if ((apps == QString("systemctl")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("SYSTEMCTL_PATH")]);
|
||||
}
|
||||
if ((apps == QString("wpasup")) || (apps == QString("wpasup-only")) || (apps == QString("all"))) {
|
||||
app.append(configuration[QString("WPACLI_PATH")]);
|
||||
app.append(configuration[QString("WPASUP_PATH")]);
|
||||
}
|
||||
// append sudo
|
||||
// FORCE_SUDO is always true if helper is not running
|
||||
if ((apps.contains(QRegExp(QString("(^all$|^editor$|^netctl$|^sudo$|^systemctl$|^wpasup$)")))) &&
|
||||
(configuration[QString("FORCE_SUDO")] == QString("true")))
|
||||
app.append(configuration[QString("SUDO_PATH")]);
|
||||
|
||||
return app;
|
||||
}
|
33
sources/gui/src/commonfunctions.h
Normal file
33
sources/gui/src/commonfunctions.h
Normal file
@ -0,0 +1,33 @@
|
||||
/***************************************************************************
|
||||
* 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 COMMONFUNCTIONS_H
|
||||
#define COMMONFUNCTIONS_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
bool checkExternalApps(const QString apps = QString("all"),
|
||||
const QMap<QString, QString> configuration = QMap<QString, QString>(),
|
||||
const bool debug = false);
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||
QStringList externalApps(const QString apps,
|
||||
const QMap<QString, QString> configuration = QMap<QString, QString>());
|
||||
|
||||
|
||||
#endif /* COMMONFUNCTIONS_H */
|
@ -23,22 +23,26 @@
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
|
||||
const bool debug)
|
||||
|
||||
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<netctlProfileInfo> profileInfo;
|
||||
if (raw.size() == 0)
|
||||
return profileInfo;
|
||||
for (int i=0; i<raw[0].toStringList().count(); i++) {
|
||||
if (raw.isEmpty()) return profileInfo;
|
||||
QStringList list = raw[0].toStringList();
|
||||
for (int i=0; i<list.count(); i++) {
|
||||
QStringList info = list[i].split(QChar('|'));
|
||||
if (info.count() != 8) continue;
|
||||
netctlProfileInfo profile;
|
||||
QStringList info = raw[0].toStringList()[i].split(QChar('|'));
|
||||
profile.name = info[0];
|
||||
profile.description = info[1];
|
||||
profile.active = info[2].toInt();
|
||||
profile.enabled = info[3].toInt();
|
||||
profile.type = info[2];
|
||||
profile.interface = info[3];
|
||||
profile.essid = info[4];
|
||||
profile.active = info[5].toInt();
|
||||
profile.enabled = info[6].toInt();
|
||||
profile.netctlAuto = info[7].toInt();
|
||||
profileInfo.append(profile);
|
||||
}
|
||||
|
||||
@ -46,22 +50,24 @@ QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
|
||||
}
|
||||
|
||||
|
||||
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
|
||||
const bool debug)
|
||||
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<netctlWifiInfo> wifiInfo;
|
||||
if (raw.size() == 0)
|
||||
return wifiInfo;
|
||||
for (int i=0; i<raw[0].toStringList().count(); i++) {
|
||||
if (raw.isEmpty()) return wifiInfo;
|
||||
QStringList list = raw[0].toStringList();
|
||||
for (int i=0; i<list.count(); i++) {
|
||||
QStringList info = list[i].split(QChar('|'));
|
||||
if (info.count() != 8) continue;
|
||||
netctlWifiInfo wifi;
|
||||
QStringList info = raw[0].toStringList()[i].split(QChar('|'));
|
||||
wifi.name = info[0];
|
||||
wifi.security = info[1];
|
||||
wifi.signal = info[2];
|
||||
wifi.active = info[3].toInt();
|
||||
wifi.exists = info[4].toInt();
|
||||
wifi.type = static_cast<PointType>(info[2].toInt());
|
||||
for (int j=0; j<info[3].split(QChar(',')).count(); j++)
|
||||
wifi.frequencies.append(info[3].split(QChar(','))[j].toInt());
|
||||
wifi.macs = info[4].split(QChar(','));
|
||||
wifi.signal = info[5].toInt();
|
||||
wifi.active = info[6].toInt();
|
||||
wifi.exists = info[7].toInt();
|
||||
wifiInfo.append(wifi);
|
||||
}
|
||||
|
||||
@ -69,37 +75,81 @@ QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendDBusRequest(const QString service, const QString path,
|
||||
const QString interface, const QString cmd,
|
||||
const QList<QVariant> args, const bool system,
|
||||
const bool debug)
|
||||
QList<QVariant> sendRequestToHelper(const QString path, const QString cmd,
|
||||
const QList<QVariant> args, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Service" << service;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Path" << path;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Interface" << interface;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "is system bus" << system;
|
||||
|
||||
QList<QVariant> arguments;
|
||||
QDBusMessage response;
|
||||
if (system) {
|
||||
QDBusConnection bus = QDBusConnection::systemBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
||||
if (!args.isEmpty())
|
||||
request.setArguments(args);
|
||||
response = bus.call(request, QDBus::BlockWithGui);
|
||||
} else {
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(service, path, interface, cmd);
|
||||
if (!args.isEmpty())
|
||||
request.setArguments(args);
|
||||
response = bus.call(request, QDBus::BlockWithGui);
|
||||
}
|
||||
arguments = response.arguments();
|
||||
if (arguments.size() == 0)
|
||||
QDBusConnection bus = QDBusConnection::systemBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, path,
|
||||
DBUS_HELPER_INTERFACE, cmd);
|
||||
if (!args.isEmpty()) request.setArguments(args);
|
||||
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
if (arguments.isEmpty())
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error message" << response.errorMessage();
|
||||
|
||||
return arguments;
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendRequestToCtrl(const QString cmd, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
|
||||
return sendRequestToCtrlWithArgs(cmd, QList<QVariant>(), debug);
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendRequestToCtrlWithArgs(const QString cmd, const QList<QVariant> args,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||
|
||||
return sendRequestToHelper(DBUS_CTRL_PATH, cmd, args, debug);
|
||||
}
|
||||
|
||||
|
||||
QList< QVariant > sendRequestToInterface(const QString cmd, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
|
||||
return sendRequestToInterfaceWithArgs(cmd, QList<QVariant>(), debug);
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendRequestToInterfaceWithArgs(const QString cmd, const QList<QVariant> args,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||
|
||||
return sendRequestToHelper(DBUS_INTERFACE_PATH, cmd, args, debug);
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendRequestToLib(const QString cmd, const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
|
||||
return sendRequestToLibWithArgs(cmd, QList<QVariant>(), debug);
|
||||
}
|
||||
|
||||
|
||||
QList<QVariant> sendRequestToLibWithArgs(const QString cmd, const QList<QVariant> args,
|
||||
const bool debug)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "cmd" << cmd;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "args" << args;
|
||||
|
||||
return sendRequestToHelper(DBUS_LIB_PATH, cmd, args, debug);
|
||||
}
|
||||
|
@ -23,14 +23,19 @@
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw,
|
||||
const bool debug = false);
|
||||
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw,
|
||||
const bool debug = false);
|
||||
QList<QVariant> sendDBusRequest(const QString service, const QString path,
|
||||
const QString interface, const QString cmd,
|
||||
const QList<QVariant> args = QList<QVariant>(),
|
||||
const bool system = true, const bool debug = false);
|
||||
QList<netctlProfileInfo> parseOutputNetctl(const QList<QVariant> raw);
|
||||
QList<netctlWifiInfo> parseOutputWifi(const QList<QVariant> raw);
|
||||
QList<QVariant> sendRequestToHelper(const QString path, const QString cmd,
|
||||
const QList<QVariant> args, const bool debug = false);
|
||||
QList<QVariant> sendRequestToCtrl(const QString cmd, const bool debug = false);
|
||||
QList<QVariant> sendRequestToCtrlWithArgs(const QString cmd, const QList<QVariant> args,
|
||||
const bool debug = false);
|
||||
QList<QVariant> sendRequestToInterface(const QString cmd, const bool debug = false);
|
||||
QList<QVariant> sendRequestToInterfaceWithArgs(const QString cmd, const QList<QVariant> args,
|
||||
const bool debug = false);
|
||||
QList<QVariant> sendRequestToLib(const QString cmd, const bool debug = false);
|
||||
QList<QVariant> sendRequestToLibWithArgs(const QString cmd, const QList<QVariant> args,
|
||||
const bool debug = false);
|
||||
|
||||
|
||||
#endif /* DBUSOPERATION_H */
|
||||
|
@ -37,11 +37,10 @@ ErrorWindow::~ErrorWindow()
|
||||
}
|
||||
|
||||
|
||||
QStringList ErrorWindow::getMessage(const int mess, const QString custom)
|
||||
QStringList ErrorWindow::getMessage(const int mess)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
|
||||
|
||||
QString message, title;
|
||||
switch(mess) {
|
||||
@ -99,7 +98,7 @@ QStringList ErrorWindow::getMessage(const int mess, const QString custom)
|
||||
break;
|
||||
case 14:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "APN is not set");
|
||||
message = QApplication::translate("ErrorWindow", "User is not in network group, helper will not be started");
|
||||
break;
|
||||
case 15:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
@ -121,13 +120,19 @@ QStringList ErrorWindow::getMessage(const int mess, const QString custom)
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Could not run helper");
|
||||
break;
|
||||
case 20:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "IP address does not match the standard");
|
||||
break;
|
||||
case 21:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Key is required for 'gre' mode");
|
||||
break;
|
||||
default:
|
||||
title = QApplication::translate("ErrorWindow", "Error!");
|
||||
message = QApplication::translate("ErrorWindow", "Unknown error");
|
||||
break;
|
||||
}
|
||||
if (!custom.isEmpty())
|
||||
message = custom;
|
||||
|
||||
QStringList fullMessage;
|
||||
fullMessage.append(title);
|
||||
@ -162,6 +167,8 @@ QMessageBox::Icon ErrorWindow::getIcon(const int mess)
|
||||
case 17:
|
||||
case 18:
|
||||
case 19:
|
||||
case 20:
|
||||
case 21:
|
||||
icon = QMessageBox::Critical;
|
||||
break;
|
||||
default:
|
||||
@ -173,21 +180,22 @@ QMessageBox::Icon ErrorWindow::getIcon(const int mess)
|
||||
}
|
||||
|
||||
|
||||
void ErrorWindow::showWindow(const int mess, const QString sender, const QString custom)
|
||||
void ErrorWindow::showWindow(const int mess, const QString sender, const bool debugCmd)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Sender" << sender;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Custom message" << custom;
|
||||
if (debugCmd) qDebug() << PDEBUG;
|
||||
if (debugCmd) qDebug() << PDEBUG << ":" << "Message" << mess;
|
||||
if (debugCmd) qDebug() << PDEBUG << ":" << "Sender" << sender;
|
||||
|
||||
QStringList message = getMessage(mess, custom);
|
||||
ErrorWindow *errorWin = new ErrorWindow(0, debugCmd);
|
||||
QStringList message = errorWin->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));
|
||||
if (mess == 1)
|
||||
messageBox.setDetailedText(sender);
|
||||
else if (debugCmd)
|
||||
messageBox.setDetailedText(QApplication::translate("ErrorWindow", "Sender : %1").arg(sender));
|
||||
messageBox.setIcon(errorWin->getIcon(mess));
|
||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||
|
||||
@ -196,5 +204,5 @@ void ErrorWindow::showWindow(const int mess, const QString sender, const QString
|
||||
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
|
||||
|
||||
messageBox.exec();
|
||||
return;
|
||||
delete errorWin;
|
||||
}
|
||||
|
@ -32,13 +32,13 @@ public:
|
||||
~ErrorWindow();
|
||||
|
||||
public slots:
|
||||
void showWindow(const int mess = 0,
|
||||
const QString sender = QString(),
|
||||
const QString custom = QString());
|
||||
static void showWindow(const int mess = 0,
|
||||
const QString sender = QString(),
|
||||
const bool debugCmd = false);
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
QStringList getMessage(const int mess, const QString custom = QString());
|
||||
QStringList getMessage(const int mess);
|
||||
QMessageBox::Icon getIcon(const int mess);
|
||||
};
|
||||
|
||||
|
@ -46,6 +46,7 @@ void EthernetWidget::clear()
|
||||
showWpa(ui->checkBox_8021x->checkState());
|
||||
ui->lineEdit_wpaConfig->clear();
|
||||
ui->comboBox_driver->setCurrentIndex(0);
|
||||
ui->spinBox_priority->setValue(1);
|
||||
ui->spinBox_timeoutCarrier->setValue(5);
|
||||
ui->spinBox_timeoutWpa->setValue(15);
|
||||
|
||||
@ -54,15 +55,6 @@ void EthernetWidget::clear()
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_ethernetAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
@ -73,8 +65,7 @@ void EthernetWidget::createActions()
|
||||
|
||||
void EthernetWidget::selectWpaConfig()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QString filename = QFileDialog::getOpenFileName(this,
|
||||
QApplication::translate("EthernetWidget", "Select wpa configuration file"),
|
||||
QDir::currentPath(),
|
||||
QApplication::translate("EthernetWidget", "Configuration files (*.conf)"));
|
||||
@ -87,43 +78,41 @@ void EthernetWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_ethernetAdvanced->isChecked()) {
|
||||
ui->widget_ethernetAdvanced->setHidden(false);
|
||||
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
|
||||
ui->pushButton_ethernetAdvanced->setArrowType(Qt::UpArrow);
|
||||
} else {
|
||||
ui->widget_ethernetAdvanced->setHidden(true);
|
||||
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Show advanced"));
|
||||
ui->pushButton_ethernetAdvanced->setArrowType(Qt::DownArrow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::showWpa(const int state)
|
||||
{
|
||||
if (state == 0)
|
||||
ui->widget_wpa->setHidden(true);
|
||||
else
|
||||
ui->widget_wpa->setHidden(false);
|
||||
ui->widget_wpa->setHidden(state == 0);
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> EthernetWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> ethernetSettings;
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return ethernetSettings;
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
if (ui->checkBox_skip->checkState() == Qt::Checked)
|
||||
ethernetSettings[QString("SkipNoCarrier")] = QString("yes");
|
||||
settings[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();
|
||||
settings[QString("Auth8021X")] = QString("yes");
|
||||
settings[QString("WPAConfigFile")] = QString("'%1'").arg(ui->lineEdit_wpaConfig->text());
|
||||
settings[QString("WPADriver")] = ui->comboBox_driver->currentText();
|
||||
}
|
||||
if (ui->spinBox_priority->value() != 1)
|
||||
settings[QString("Priority")] = QString::number(ui->spinBox_priority->value());
|
||||
if (ui->spinBox_timeoutCarrier->value() != 5)
|
||||
ethernetSettings[QString("TimeoutCarrier")] = QString::number(ui->spinBox_timeoutCarrier->value());
|
||||
settings[QString("TimeoutCarrier")] = QString::number(ui->spinBox_timeoutCarrier->value());
|
||||
if (ui->spinBox_timeoutWpa->value() != 15)
|
||||
ethernetSettings[QString("TimeoutWPA")] = QString::number(ui->spinBox_timeoutWpa->value());
|
||||
settings[QString("TimeoutWPA")] = QString::number(ui->spinBox_timeoutWpa->value());
|
||||
|
||||
return ethernetSettings;
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
@ -131,8 +120,7 @@ int EthernetWidget::isOk()
|
||||
{
|
||||
// file wpa_supplicant doesn't exists
|
||||
if (!ui->lineEdit_wpaConfig->text().isEmpty())
|
||||
if (!QFile(ui->lineEdit_wpaConfig->text()).exists())
|
||||
return 1;
|
||||
if (!QFile(ui->lineEdit_wpaConfig->text()).exists()) return 1;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
@ -141,24 +129,25 @@ int EthernetWidget::isOk()
|
||||
void EthernetWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> ethernetSettings = settings;
|
||||
|
||||
if (ethernetSettings.contains(QString("SkipNoCarrier")))
|
||||
if (ethernetSettings[QString("SkipNoCarrier")] == QString("yes"))
|
||||
if (settings.contains(QString("SkipNoCarrier")))
|
||||
if (settings[QString("SkipNoCarrier")] == QString("yes"))
|
||||
ui->checkBox_skip->setCheckState(Qt::Checked);
|
||||
if (ethernetSettings.contains(QString("Auth8021X")))
|
||||
if (ethernetSettings[QString("Auth8021X")] == QString("yes"))
|
||||
if (settings.contains(QString("Auth8021X")))
|
||||
if (settings[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());
|
||||
if (settings.contains(QString("WPAConfigFile")))
|
||||
ui->lineEdit_wpaConfig->setText(settings[QString("WPAConfigFile")]);
|
||||
if (settings.contains(QString("WPADriver"))) {
|
||||
int index = ui->comboBox_driver->findText(settings[QString("WPADriver")]);
|
||||
ui->comboBox_driver->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("Priority")))
|
||||
ui->spinBox_priority->setValue(settings[QString("Priority")].toInt());
|
||||
if (settings.contains(QString("TimeoutCarrier")))
|
||||
ui->spinBox_timeoutCarrier->setValue(settings[QString("TimeoutCarrier")].toInt());
|
||||
if (settings.contains(QString("TimeoutWPA")))
|
||||
ui->spinBox_timeoutWpa->setValue(settings[QString("TimeoutWPA")].toInt());
|
||||
|
||||
showWpa(ui->checkBox_8021x->checkState());
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private slots:
|
||||
void selectWpaConfig();
|
||||
|
@ -6,14 +6,14 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>431</width>
|
||||
<height>296</height>
|
||||
<width>550</width>
|
||||
<height>255</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_ethernet">
|
||||
<property name="features">
|
||||
@ -24,29 +24,29 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_ethernet">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ethernetAdvanced">
|
||||
<item>
|
||||
<spacer name="spacer_ethernetAdvanced">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_ethernetAdvanced">
|
||||
<property name="text">
|
||||
<string>Hide advanced</string>
|
||||
</property>
|
||||
<widget class="QToolButton" name="pushButton_ethernetAdvanced">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::DownArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -54,49 +54,104 @@
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_ethernetAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_skip">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Whether or not the absence of a carrier is acceptable</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Skip no carrier</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="layout_skip">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_skip">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_skip">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Whether or not the absence of a carrier is acceptable</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Skip no carrier</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
<layout class="QHBoxLayout" name="layout_8021x">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8021x">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_8021x">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_wpa" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WPA config file</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaConfig">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Path to a wpa_supplicant configuration file</string>
|
||||
</property>
|
||||
@ -104,6 +159,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wpaConfig">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>4</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
@ -115,19 +176,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WPA driver</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_driver">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>14</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The wpa_supplicant driver to use for 802.1x authentication</string>
|
||||
</property>
|
||||
@ -157,19 +227,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Timeout carrier</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_timeoutCarrier">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Maximum time, in seconds, to wait for a carrier</string>
|
||||
</property>
|
||||
@ -187,19 +266,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Timeout WPA</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_timeoutWpa">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Maximum time, in seconds, to wait for 802.1x authentication to succeed</string>
|
||||
</property>
|
||||
@ -213,6 +301,45 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_priority">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_priority">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Priority</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_priority">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Priority level of the profile. In case of automatic profile selection, profiles are tried in decreasing order of priority</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -223,9 +350,6 @@
|
||||
</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>
|
||||
|
@ -59,6 +59,7 @@ void GeneralWidget::clear()
|
||||
ui->listWidget_after->clear();
|
||||
ui->lineEdit_execUpPost->clear();
|
||||
ui->lineEdit_execDownPre->clear();
|
||||
ui->checkBox_exclude->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_forceConnect->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_debug->setCheckState(Qt::Unchecked);
|
||||
|
||||
@ -67,20 +68,13 @@ void GeneralWidget::clear()
|
||||
}
|
||||
|
||||
|
||||
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->comboBox_after->lineEdit(), SIGNAL(returnPressed()), this, SLOT(addAfter()));
|
||||
connect(ui->pushButton_bindto, SIGNAL(clicked(bool)), this, SLOT(addBindTo()));
|
||||
connect(ui->comboBox_bindto->lineEdit(), SIGNAL(returnPressed()), this, SLOT(addBindTo()));
|
||||
}
|
||||
|
||||
|
||||
@ -100,10 +94,10 @@ void GeneralWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (pressedKey->key() == Qt::Key_Delete) {
|
||||
if (ui->listWidget_bindto->hasFocus() &&
|
||||
(ui->listWidget_bindto->currentItem() != 0))
|
||||
(ui->listWidget_bindto->currentItem() != nullptr))
|
||||
delete ui->listWidget_bindto->currentItem();
|
||||
else if (ui->listWidget_after->hasFocus() &&
|
||||
(ui->listWidget_after->currentItem() != 0))
|
||||
(ui->listWidget_after->currentItem() != nullptr))
|
||||
delete ui->listWidget_after->currentItem();
|
||||
}
|
||||
}
|
||||
@ -123,36 +117,37 @@ void GeneralWidget::showAdvanced()
|
||||
|
||||
QMap<QString, QString> GeneralWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> generalSettings;
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return generalSettings;
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
generalSettings[QString("Description")] = QString("'") + ui->lineEdit_description->text() + QString("'");
|
||||
generalSettings[QString("Connection")] = ui->comboBox_connection->currentText();
|
||||
generalSettings[QString("Interface")] = ui->comboBox_interface->currentText();
|
||||
settings[QString("Description")] = QString("'%1'").arg(ui->lineEdit_description->text());
|
||||
settings[QString("Connection")] = ui->comboBox_connection->currentText();
|
||||
settings[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(' '));
|
||||
settings[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(' '));
|
||||
settings[QString("After")] = profiles.join(QChar(' '));
|
||||
}
|
||||
if (!ui->lineEdit_execUpPost->text().isEmpty())
|
||||
generalSettings[QString("ExecUpPost")] = QString("'") + ui->lineEdit_execUpPost->text() + QString("'");
|
||||
settings[QString("ExecUpPost")] = QString("'%1'").arg(ui->lineEdit_execUpPost->text());
|
||||
if (!ui->lineEdit_execDownPre->text().isEmpty())
|
||||
generalSettings[QString("ExecDownPre")] = QString("'") + ui->lineEdit_execDownPre->text() + QString("'");
|
||||
settings[QString("ExecDownPre")] = QString("'%1'").arg(ui->lineEdit_execDownPre->text());
|
||||
if (ui->checkBox_exclude->checkState() == Qt::Checked)
|
||||
settings[QString("ExcludeAuto")] = QString("yes");
|
||||
if (ui->checkBox_forceConnect->checkState() == Qt::Checked)
|
||||
generalSettings[QString("ForceConnect")] = QString("yes");
|
||||
settings[QString("ForceConnect")] = QString("yes");
|
||||
if (ui->checkBox_debug->checkState() == Qt::Checked)
|
||||
generalSettings[QString("NETCTL_DEBUG")] = QString("yes");
|
||||
settings[QString("NETCTL_DEBUG")] = QString("yes");
|
||||
|
||||
return generalSettings;
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
@ -160,15 +155,13 @@ 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")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("macvlan")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("openvswitch")))
|
||||
if (ui->listWidget_bindto->count() == 0)
|
||||
return 1;
|
||||
(ui->comboBox_connection->currentText() == QString("bridge")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("vlan")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("macvlan")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("openvswitch")))
|
||||
if (ui->listWidget_bindto->count() == 0) return 1;
|
||||
// empty description
|
||||
if (ui->lineEdit_description->text().isEmpty())
|
||||
return 2;
|
||||
if (ui->lineEdit_description->text().isEmpty()) return 2;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
@ -177,30 +170,32 @@ int GeneralWidget::isOk()
|
||||
void GeneralWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> generalSettings = settings;
|
||||
|
||||
if (generalSettings.contains(QString("Description")))
|
||||
ui->lineEdit_description->setText(generalSettings[QString("Description")]);
|
||||
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 (settings.contains(QString("Description")))
|
||||
ui->lineEdit_description->setText(settings[QString("Description")]);
|
||||
if (settings.contains(QString("Connection"))) {
|
||||
int index = ui->comboBox_connection->findText(settings[QString("Connection")]);
|
||||
ui->comboBox_connection->setCurrentIndex(index);
|
||||
}
|
||||
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"))
|
||||
if (settings.contains(QString("Interface"))) {
|
||||
ui->comboBox_interface->addItem(settings[QString("Interface")]);
|
||||
ui->comboBox_interface->setCurrentIndex(ui->comboBox_interface->count() - 1);
|
||||
}
|
||||
if (settings.contains(QString("BindsToInterfaces")))
|
||||
ui->listWidget_bindto->addItems(settings[QString("BindsToInterfaces")].split(QChar('\n')));
|
||||
if (settings.contains(QString("After")))
|
||||
ui->listWidget_after->addItems(settings[QString("After")].split(QChar('\n')));
|
||||
if (settings.contains(QString("ExecUpPost")))
|
||||
ui->lineEdit_execUpPost->setText(settings[QString("ExecUpPost")]);
|
||||
if (settings.contains(QString("ExecDownPre")))
|
||||
ui->lineEdit_execDownPre->setText(settings[QString("ExecDownPre")]);
|
||||
if (settings.contains(QString("ExcludeAuto")))
|
||||
if (settings[QString("ExcludeAuto")] == QString("yes"))
|
||||
ui->checkBox_exclude->setCheckState(Qt::Checked);
|
||||
if (settings.contains(QString("ForceConnect")))
|
||||
if (settings[QString("ForceConnect")] == QString("yes"))
|
||||
ui->checkBox_forceConnect->setCheckState(Qt::Checked);
|
||||
if (generalSettings.contains(QString("NETCTL_DEBUG")))
|
||||
if (generalSettings[QString("NETCTL_DEBUG")] == QString("yes"))
|
||||
if (settings.contains(QString("NETCTL_DEBUG")))
|
||||
if (settings[QString("NETCTL_DEBUG")] == QString("yes"))
|
||||
ui->checkBox_debug->setCheckState(Qt::Checked);
|
||||
}
|
||||
|
@ -43,7 +43,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private slots:
|
||||
void addAfter();
|
||||
|
@ -6,16 +6,22 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>425</width>
|
||||
<height>531</height>
|
||||
<width>550</width>
|
||||
<height>479</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_general">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
@ -24,25 +30,37 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_general">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_description">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>A description of the profile</p></body></html></string>
|
||||
<string>A description of the profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -52,19 +70,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connection</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_connection">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The connection type used by the profile</string>
|
||||
</property>
|
||||
@ -136,19 +163,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Interface</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_interface">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The name of the associated network interface</string>
|
||||
</property>
|
||||
@ -165,18 +201,27 @@
|
||||
<layout class="QHBoxLayout" name="layout_bindtoButton">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_bindto">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Binds to interfaces</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_bindto">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
@ -185,6 +230,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_bindto">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>4</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
@ -210,26 +261,23 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_generalAdvanced">
|
||||
<item>
|
||||
<spacer name="spacer_generalAdvanced">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_generalAdvanced">
|
||||
<property name="text">
|
||||
<string>Hide advanced</string>
|
||||
</property>
|
||||
<widget class="QToolButton" name="pushButton_generalAdvanced">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::DownArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -237,24 +285,36 @@
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_generalAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_after">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_afterButton">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_after">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>After</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_after">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
@ -263,6 +323,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_after">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>4</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
@ -289,19 +355,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Command after starting</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_execUpPost">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>14</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>A command that is executed after a connection is established</string>
|
||||
</property>
|
||||
@ -313,19 +388,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Command before stoping</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_execDownPre">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>14</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>A command that is executed before a connection is brought down</string>
|
||||
</property>
|
||||
@ -334,21 +418,91 @@
|
||||
</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>
|
||||
<layout class="QHBoxLayout" name="layout_exclude">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_exclude">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_exclude">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_debug">
|
||||
<property name="text">
|
||||
<string>Debug mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="layout_forceConnect">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_forceConnect">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_forceConnect">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>14</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_debug">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>14</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Debug mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="1">
|
||||
<libraries>
|
||||
<library>qt</library>
|
||||
</libraries>
|
||||
</project>
|
83
sources/gui/src/ipregexp.cpp
Normal file
83
sources/gui/src/ipregexp.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/***************************************************************************
|
||||
* 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 "ipregexp.h"
|
||||
|
||||
|
||||
IpRegExp::IpRegExp(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
IpRegExp::~IpRegExp()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QRegExp IpRegExp::ip4Regex()
|
||||
{
|
||||
return QRegExp(QString("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"));
|
||||
}
|
||||
|
||||
|
||||
QRegExp IpRegExp::ip4CidrRegex()
|
||||
{
|
||||
return QRegExp(QString("^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(/([0-9]|[1-2][0-9]|3[0-2]))$"));
|
||||
}
|
||||
|
||||
|
||||
QRegExp IpRegExp::ip6Regex()
|
||||
{
|
||||
return QRegExp(QString("^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*"));
|
||||
}
|
||||
|
||||
|
||||
QRegExp IpRegExp::ip6CidrRegex()
|
||||
{
|
||||
return QRegExp(QString("^s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))(%.+)?s*(/(d|dd|1[0-1]d|12[0-8]))$"));
|
||||
}
|
||||
|
||||
|
||||
QRegExpValidator *IpRegExp::ipv4Validator()
|
||||
{
|
||||
return new QRegExpValidator(IpRegExp::ip4Regex());
|
||||
}
|
||||
|
||||
|
||||
QRegExpValidator *IpRegExp::ipv4CidrValidator()
|
||||
{
|
||||
return new QRegExpValidator(IpRegExp::ip4CidrRegex());
|
||||
}
|
||||
|
||||
|
||||
QRegExpValidator *IpRegExp::ipv6Validator()
|
||||
{
|
||||
return new QRegExpValidator(IpRegExp::ip6Regex());
|
||||
}
|
||||
|
||||
|
||||
QRegExpValidator *IpRegExp::ipv6CidrValidator()
|
||||
{
|
||||
return new QRegExpValidator(IpRegExp::ip6CidrRegex());
|
||||
}
|
||||
|
||||
|
||||
bool IpRegExp::checkString(const QString input, const QRegExp regexp)
|
||||
{
|
||||
return regexp.exactMatch(input);
|
||||
}
|
49
sources/gui/src/ipregexp.h
Normal file
49
sources/gui/src/ipregexp.h
Normal 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 IPREGEXP_H
|
||||
#define IPREGEXP_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QRegExp>
|
||||
#include <QRegExpValidator>
|
||||
|
||||
|
||||
class IpRegExp : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IpRegExp(QObject *parent = 0);
|
||||
~IpRegExp();
|
||||
|
||||
// ipv4
|
||||
static QRegExp ip4Regex();
|
||||
static QRegExp ip4CidrRegex();
|
||||
// ipv6
|
||||
static QRegExp ip6Regex();
|
||||
static QRegExp ip6CidrRegex();
|
||||
// validators
|
||||
static QRegExpValidator *ipv4Validator();
|
||||
static QRegExpValidator *ipv4CidrValidator();
|
||||
static QRegExpValidator *ipv6Validator();
|
||||
static QRegExpValidator *ipv6CidrValidator();
|
||||
// check
|
||||
static bool checkString(const QString input, const QRegExp regexp);
|
||||
};
|
||||
|
||||
|
||||
#endif /* IPREGEXP_H */
|
@ -20,6 +20,9 @@
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "errorwindow.h"
|
||||
#include "ipregexp.h"
|
||||
|
||||
|
||||
IpWidget::IpWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
@ -89,15 +92,6 @@ void IpWidget::clear()
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_ipAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
@ -111,32 +105,36 @@ void IpWidget::createActions()
|
||||
connect(ui->comboBox_dhcp, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeDhcpClient(QString)));
|
||||
// buttons
|
||||
connect(ui->pushButton_ipAddress, SIGNAL(clicked(bool)), this, SLOT(addIp()));
|
||||
connect(ui->lineEdit_ipAddress, SIGNAL(returnPressed()), 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->lineEdit_ipAddress6, SIGNAL(returnPressed()), 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->lineEdit_custom, SIGNAL(returnPressed()), this, SLOT(addCustom()));
|
||||
connect(ui->pushButton_dns, SIGNAL(clicked(bool)), this, SLOT(addDns()));
|
||||
connect(ui->lineEdit_dns, SIGNAL(returnPressed()), this, SLOT(addDns()));
|
||||
connect(ui->pushButton_dnsOptions, SIGNAL(clicked(bool)), this, SLOT(addDnsOpt()));
|
||||
connect(ui->lineEdit_dnsOptions, SIGNAL(returnPressed()), 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"));
|
||||
ui->lineEdit_ipAddress->setValidator(IpRegExp::ipv4CidrValidator());
|
||||
ui->lineEdit_gateway->setValidator(IpRegExp::ipv4Validator());
|
||||
ui->lineEdit_ipRoutes->setValidator(IpRegExp::ipv4CidrValidator());
|
||||
ui->lineEdit_ipRoutes2->setValidator(IpRegExp::ipv4Validator());
|
||||
|
||||
// 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"));
|
||||
ui->lineEdit_ipAddress6->setValidator(IpRegExp::ipv6CidrValidator());
|
||||
ui->lineEdit_gateway6->setValidator(IpRegExp::ipv6Validator());
|
||||
ui->lineEdit_ipRoutes6->setValidator(IpRegExp::ipv6CidrValidator());
|
||||
ui->lineEdit_ipRoutes62->setValidator(IpRegExp::ipv6Validator());
|
||||
|
||||
// dns
|
||||
ui->lineEdit_dns->setInputMask(QString("999.999.999.999"));
|
||||
ui->lineEdit_dns->setValidator(IpRegExp::ipv4Validator());
|
||||
}
|
||||
|
||||
|
||||
@ -144,110 +142,47 @@ void IpWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (pressedKey->key() == Qt::Key_Delete) {
|
||||
if (ui->listWidget_ipAddress->hasFocus() &&
|
||||
(ui->listWidget_ipAddress->currentItem() != 0))
|
||||
(ui->listWidget_ipAddress->currentItem() != nullptr))
|
||||
delete ui->listWidget_ipAddress->currentItem();
|
||||
else if (ui->listWidget_ipRoutes->hasFocus() &&
|
||||
(ui->listWidget_ipRoutes->currentItem() != 0))
|
||||
(ui->listWidget_ipRoutes->currentItem() != nullptr))
|
||||
delete ui->listWidget_ipRoutes->currentItem();
|
||||
else if (ui->listWidget_ipAddress6->hasFocus() &&
|
||||
(ui->listWidget_ipAddress6->currentItem() != 0))
|
||||
(ui->listWidget_ipAddress6->currentItem() != nullptr))
|
||||
delete ui->listWidget_ipAddress6->currentItem();
|
||||
else if (ui->listWidget_ipRoutes6->hasFocus() &&
|
||||
(ui->listWidget_ipRoutes6->currentItem() != 0))
|
||||
(ui->listWidget_ipRoutes6->currentItem() != nullptr))
|
||||
delete ui->listWidget_ipRoutes6->currentItem();
|
||||
else if (ui->listWidget_custom->hasFocus() &&
|
||||
(ui->listWidget_custom->currentItem() != 0))
|
||||
(ui->listWidget_custom->currentItem() != nullptr))
|
||||
delete ui->listWidget_custom->currentItem();
|
||||
else if (ui->listWidget_dns->hasFocus() &&
|
||||
(ui->listWidget_dns->currentItem() != 0))
|
||||
(ui->listWidget_dns->currentItem() != nullptr))
|
||||
delete ui->listWidget_dns->currentItem();
|
||||
else if (ui->listWidget_dnsOptions->hasFocus() &&
|
||||
(ui->listWidget_dnsOptions->currentItem() != 0))
|
||||
(ui->listWidget_dnsOptions->currentItem() != nullptr))
|
||||
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]);
|
||||
if (!IpRegExp::checkString(ui->lineEdit_ipAddress->text(), IpRegExp::ip4CidrRegex()))
|
||||
return ErrorWindow::showWindow(20, QString("[IpWidget::addIp]"));
|
||||
|
||||
ui->listWidget_ipAddress->addItem(ip + QString("/") + prefix);
|
||||
ui->listWidget_ipAddress->addItem(ui->lineEdit_ipAddress->text());
|
||||
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(' ')));
|
||||
if ((!IpRegExp::checkString(ui->lineEdit_ipRoutes->text(), IpRegExp::ip4CidrRegex())) ||
|
||||
(!IpRegExp::checkString(ui->lineEdit_ipRoutes2->text(), IpRegExp::ip4Regex())))
|
||||
return ErrorWindow::showWindow(20, QString("[IpWidget::addIpRoutes]"));
|
||||
|
||||
ui->listWidget_ipRoutes->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
|
||||
ui->listWidget_ipRoutes->addItem(QString("%1 via %2").arg(ui->lineEdit_ipRoutes->text()).arg(ui->lineEdit_ipRoutes2->text()));
|
||||
ui->lineEdit_ipRoutes->clear();
|
||||
ui->lineEdit_ipRoutes2->clear();
|
||||
}
|
||||
@ -255,21 +190,21 @@ void IpWidget::addIpRoutes()
|
||||
|
||||
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]);
|
||||
if (!IpRegExp::checkString(ui->lineEdit_ipAddress6->text(), IpRegExp::ip6CidrRegex()))
|
||||
return ErrorWindow::showWindow(20, QString("[IpWidget::addIp6]"));
|
||||
|
||||
ui->listWidget_ipAddress6->addItem(ip + QString("/") + prefix);
|
||||
ui->listWidget_ipAddress6->addItem(ui->lineEdit_ipAddress6->text());
|
||||
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(' ')));
|
||||
if ((!IpRegExp::checkString(ui->lineEdit_ipRoutes6->text(), IpRegExp::ip6CidrRegex())) ||
|
||||
(!IpRegExp::checkString(ui->lineEdit_ipRoutes62->text(), IpRegExp::ip6Regex())))
|
||||
return ErrorWindow::showWindow(20, QString("[IpWidget::addIp6Routes]"));
|
||||
|
||||
ui->listWidget_ipRoutes6->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
|
||||
ui->listWidget_ipRoutes6->addItem(QString("%1 via %2").arg(ui->lineEdit_ipRoutes6->text()).arg(ui->lineEdit_ipRoutes62->text()));
|
||||
ui->lineEdit_ipRoutes6->clear();
|
||||
ui->lineEdit_ipRoutes62->clear();
|
||||
}
|
||||
@ -285,9 +220,10 @@ void IpWidget::addCustom()
|
||||
|
||||
void IpWidget::addDns()
|
||||
{
|
||||
QString ip = getIp(ui->lineEdit_dns->text().remove(QChar(' ')));
|
||||
if (!IpRegExp::checkString(ui->lineEdit_dns->text(), IpRegExp::ip4Regex()))
|
||||
return ErrorWindow::showWindow(20, QString("[IpWidget::addDns]"));
|
||||
|
||||
ui->listWidget_dns->addItem(ip);
|
||||
ui->listWidget_dns->addItem(ui->lineEdit_dns->text());
|
||||
ui->lineEdit_dns->clear();
|
||||
}
|
||||
|
||||
@ -302,61 +238,36 @@ void IpWidget::addDnsOpt()
|
||||
|
||||
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);
|
||||
ui->widget_ip->setHidden(currentText == QString("dhcp"));
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
ui->comboBox_ip->setDisabled(state == 0);
|
||||
ui->widget_ip->setDisabled(state == 0);
|
||||
ui->widget_ipRoutes->setDisabled(state == 0);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
ui->widget_ip6->setHidden(currentText.startsWith(QString("dhcp")));
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
ui->comboBox_ip6->setDisabled(state == 0);
|
||||
ui->widget_ip6->setDisabled(state == 0);
|
||||
ui->widget_ipRoutes6->setDisabled(state == 0);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
ui->widget_dhcpcdOpt->setHidden(currentText != QString("dhcpcd"));
|
||||
ui->widget_dhclientOpt->setHidden(currentText == QString("dhcpcd"));
|
||||
}
|
||||
|
||||
|
||||
@ -364,116 +275,113 @@ void IpWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_ipAdvanced->isChecked()) {
|
||||
ui->widget_ipAdvanced->setHidden(false);
|
||||
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
|
||||
ui->pushButton_ipAdvanced->setArrowType(Qt::UpArrow);
|
||||
} else {
|
||||
ui->widget_ipAdvanced->setHidden(true);
|
||||
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Show advanced"));
|
||||
ui->pushButton_ipAdvanced->setArrowType(Qt::DownArrow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> IpWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> ipSettings;
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return ipSettings;
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
if (ui->checkBox_ip->checkState() == Qt::Checked) {
|
||||
ipSettings[QString("IP")] = ui->comboBox_ip->currentText();
|
||||
settings[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("'");
|
||||
addresses.append(QString("'%1'").arg(ui->listWidget_ipAddress->item(i)->text()));
|
||||
settings[QString("Address")] = addresses.join(QChar(' '));
|
||||
settings[QString("Gateway")] = QString("'%1'").arg(ui->lineEdit_gateway->text());
|
||||
}
|
||||
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(' '));
|
||||
routes.append(QString("'%1'").arg(ui->listWidget_ipRoutes->item(i)->text()));
|
||||
settings[QString("Routes")] = routes.join(QChar(' '));
|
||||
}
|
||||
} else
|
||||
ipSettings[QString("IP")] = QString("no");
|
||||
settings[QString("IP")] = QString("no");
|
||||
if (ui->checkBox_ip6->checkState() == Qt::Checked) {
|
||||
ipSettings[QString("IP6")] = ui->comboBox_ip6->currentText();
|
||||
settings[QString("IP6")] = ui->comboBox_ip6->currentText();
|
||||
if ((ui->comboBox_ip6->currentText() == QString("static")) ||
|
||||
(ui->comboBox_ip6->currentText() == QString("stateless"))) {
|
||||
(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("'");
|
||||
addresses.append(QString("'%1'").arg(ui->listWidget_ipAddress6->item(i)->text()));
|
||||
settings[QString("Address6")] = addresses.join(QChar(' '));
|
||||
settings[QString("Gateway6")] = QString("'%1'").arg(ui->lineEdit_gateway6->text());
|
||||
}
|
||||
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(' '));
|
||||
routes.append(QString("'%1'").arg(ui->listWidget_ipRoutes6->item(i)->text()));
|
||||
settings[QString("Routes6")] = routes.join(QChar(' '));
|
||||
}
|
||||
} else
|
||||
ipSettings[QString("IP6")] = QString("no");
|
||||
settings[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(' '));
|
||||
custom.append(QString("'%1'").arg(ui->listWidget_custom->item(i)->text()));
|
||||
settings[QString("IPCustom")] = custom.join(QChar(' '));
|
||||
}
|
||||
if (!ui->lineEdit_hostname->text().isEmpty())
|
||||
ipSettings[QString("Hostname")] = QString("'") + ui->lineEdit_hostname->text() + QString("'");
|
||||
settings[QString("Hostname")] = QString("'%1'").arg(ui->lineEdit_hostname->text());
|
||||
if (ui->spinBox_timeoutDad->value() != 3)
|
||||
ipSettings[QString("TimeoutDAD")] = QString::number(ui->spinBox_timeoutDad->value());
|
||||
settings[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("'");
|
||||
settings[QString("DhcpcdOptions")] = QString("'%1'").arg(ui->lineEdit_dhcpcdOpt->text());
|
||||
} else if (ui->comboBox_dhcp->currentText() == QString("dhclient")) {
|
||||
ipSettings[QString("DHCPClient")] = ui->comboBox_dhcp->currentText();
|
||||
settings[QString("DHCPClient")] = ui->comboBox_dhcp->currentText();
|
||||
if (!ui->lineEdit_dhclientOpt->text().isEmpty())
|
||||
ipSettings[QString("DhclientOptions")] = QString("'") + ui->lineEdit_dhclientOpt->text() + QString("'");
|
||||
settings[QString("DhclientOptions")] = QString("'%1'").arg(ui->lineEdit_dhclientOpt->text());
|
||||
if (!ui->lineEdit_dhclientOpt6->text().isEmpty())
|
||||
ipSettings[QString("DhclientOptions6")] = QString("'") + ui->lineEdit_dhclientOpt6->text() + QString("'");
|
||||
settings[QString("DhclientOptions6")] = QString("'%1'").arg(ui->lineEdit_dhclientOpt6->text());
|
||||
}
|
||||
if (ui->spinBox_timeoutDhcp->value() != 30)
|
||||
ipSettings[QString("TimeoutDHCP")] = QString::number(ui->spinBox_timeoutDhcp->value());
|
||||
settings[QString("TimeoutDHCP")] = QString::number(ui->spinBox_timeoutDhcp->value());
|
||||
if (ui->checkBox_dhcp->checkState() == Qt::Checked)
|
||||
ipSettings[QString("DHCPReleaseOnStop")] = QString("yes");
|
||||
settings[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(' '));
|
||||
dns.append(QString("'%1'").arg(ui->listWidget_dns->item(i)->text()));
|
||||
settings[QString("DNS")] = dns.join(QChar(' '));
|
||||
}
|
||||
if (!ui->lineEdit_dnsDomain->text().isEmpty())
|
||||
ipSettings[QString("DNSDomain")] = QString("'") + ui->lineEdit_dnsDomain->text() + QString("'");
|
||||
settings[QString("DNSDomain")] = QString("'%1'").arg(ui->lineEdit_dnsDomain->text());
|
||||
if (!ui->lineEdit_dnsSearch->text().isEmpty())
|
||||
ipSettings[QString("DNSSearch")] = QString("'") + ui->lineEdit_dnsSearch->text() + QString("'");
|
||||
settings[QString("DNSSearch")] = QString("'%1'").arg(ui->lineEdit_dnsSearch->text());
|
||||
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(' '));
|
||||
dnsOpt.append(QString("'%1'").arg(ui->listWidget_dnsOptions->item(i)->text()));
|
||||
settings[QString("DNSOptions")] = dnsOpt.join(QChar(' '));
|
||||
}
|
||||
|
||||
return ipSettings;
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
if ((ui->checkBox_ip->checkState() == Qt::Checked) &&
|
||||
(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;
|
||||
if ((ui->checkBox_ip6->checkState() == Qt::Checked) &&
|
||||
((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;
|
||||
}
|
||||
@ -482,70 +390,66 @@ int IpWidget::isOk()
|
||||
void IpWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> ipSettings = settings;
|
||||
|
||||
if (ipSettings.contains(QString("IP"))) {
|
||||
if (ipSettings[QString("IP")] == QString("no"))
|
||||
if (settings.contains(QString("IP"))) {
|
||||
if (settings[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);
|
||||
int index = ui->comboBox_ip->findText(settings[QString("IP")]);
|
||||
ui->comboBox_ip->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
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"))
|
||||
if (settings.contains(QString("Address")))
|
||||
ui->listWidget_ipAddress->addItems(settings[QString("Address")].split(QChar('\n')));
|
||||
if (settings.contains(QString("Gateway")))
|
||||
ui->lineEdit_gateway->setText(settings[QString("Gateway")]);
|
||||
if (settings.contains(QString("Routes")))
|
||||
ui->listWidget_ipRoutes->addItems(settings[QString("Routes")].split(QChar('\n')));
|
||||
if (settings.contains(QString("IP6"))) {
|
||||
if (settings[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);
|
||||
int index = ui->comboBox_ip6->findText(settings[QString("IP6")]);
|
||||
ui->comboBox_ip6->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
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"))
|
||||
if (settings.contains(QString("Address6")))
|
||||
ui->listWidget_ipAddress6->addItems(settings[QString("Address6")].split(QChar('\n')));
|
||||
if (settings.contains(QString("Gateway6")))
|
||||
ui->lineEdit_gateway6->setText(settings[QString("Gateway6")]);
|
||||
if (settings.contains(QString("Routes6")))
|
||||
ui->listWidget_ipRoutes6->addItems(settings[QString("Routes6")].split(QChar('\n')));
|
||||
if (settings.contains(QString("IPCustom")))
|
||||
ui->listWidget_custom->addItems(settings[QString("IPCustom")].split(QChar('\n')));
|
||||
if (settings.contains(QString("Hostname")))
|
||||
ui->lineEdit_hostname->setText(settings[QString("Hostname")]);
|
||||
if (settings.contains(QString("TimeoutDAD")))
|
||||
ui->spinBox_timeoutDad->setValue(settings[QString("TimeoutDAD")].toInt());
|
||||
if (settings.contains(QString("DHCPClient"))) {
|
||||
int index = ui->comboBox_dhcp->findText(settings[QString("DHCPClient")]);
|
||||
ui->comboBox_dhcp->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("DhcpcdOptions")))
|
||||
ui->lineEdit_dhcpcdOpt->setText(settings[QString("DhcpcdOptions")]);
|
||||
if (settings.contains(QString("DhclientOptions")))
|
||||
ui->lineEdit_dhclientOpt->setText(settings[QString("DhclientOptions")]);
|
||||
if (settings.contains(QString("DhclientOptions6")))
|
||||
ui->lineEdit_dhclientOpt6->setText(settings[QString("DhclientOptions6")]);
|
||||
if (settings.contains(QString("TimeoutDHCP")))
|
||||
ui->spinBox_timeoutDhcp->setValue(settings[QString("TimeoutDHCP")].toInt());
|
||||
if (settings.contains(QString("DHCPReleaseOnStop")))
|
||||
if (settings[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')));
|
||||
if (settings.contains(QString("DNS")))
|
||||
ui->listWidget_dns->addItems(settings[QString("DNS")].split(QChar('\n')));
|
||||
if (settings.contains(QString("DNSDomain")))
|
||||
ui->lineEdit_dnsDomain->setText(settings[QString("DNSDomain")]);
|
||||
if (settings.contains(QString("DNSSearch")))
|
||||
ui->lineEdit_dnsSearch->setText(settings[QString("DNSSearch")]);
|
||||
if (settings.contains(QString("DNSOptions")))
|
||||
ui->listWidget_dnsOptions->addItems(settings[QString("DNSOptions")].split(QChar('\n')));
|
||||
|
||||
ipEnable(ui->checkBox_ip->checkState());
|
||||
changeIpMode(ui->comboBox_ip->currentText());
|
||||
|
@ -38,7 +38,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private slots:
|
||||
// buttons
|
||||
@ -64,10 +63,6 @@ private:
|
||||
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);
|
||||
};
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -42,34 +42,24 @@ void MacvlanWidget::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"));
|
||||
ui->lineEdit_mac->setInputMask(QString(">hh:hh:hh:hh:hh:hh"));
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> MacvlanWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> macvlanSettings;
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return macvlanSettings;
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
macvlanSettings[QString("Mode")] = ui->comboBox_mode->currentText();
|
||||
if (!ui->lineEdit_mac->text().remove(QChar(':')).remove(QChar(' ')).isEmpty())
|
||||
macvlanSettings[QString("MACAddress")] = ui->lineEdit_mac->text();
|
||||
settings[QString("Mode")] = ui->comboBox_mode->currentText();
|
||||
if (!ui->lineEdit_mac->text().remove(QChar(':')).isEmpty())
|
||||
settings[QString("MACAddress")] = ui->lineEdit_mac->text();
|
||||
|
||||
return macvlanSettings;
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
@ -83,12 +73,11 @@ int MacvlanWidget::isOk()
|
||||
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")]);
|
||||
if (settings.contains(QString("Mode"))) {
|
||||
int index = ui->comboBox_mode->findText(settings[QString("Mode")]);
|
||||
ui->comboBox_mode->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("MACAddress")))
|
||||
ui->lineEdit_mac->setText(settings[QString("MACAddress")]);
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private:
|
||||
Ui::MacvlanWidget *ui;
|
||||
|
@ -7,13 +7,13 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>396</width>
|
||||
<height>101</height>
|
||||
<height>79</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_macvlan">
|
||||
<property name="features">
|
||||
@ -24,17 +24,35 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_macvlan">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="layout_mode">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">bridge</string>
|
||||
@ -63,19 +81,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>MAC address</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_mac">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Optional static MAC address</string>
|
||||
</property>
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <QDBusMessage>
|
||||
#include <QDir>
|
||||
#include <QLibraryInfo>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QTranslator>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
@ -31,6 +32,10 @@
|
||||
#include "messages.h"
|
||||
#include "version.h"
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <pdebug/pdebug-time.h>
|
||||
#endif /* QT_VERSION >= 0x050000 */
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -43,7 +48,7 @@ bool existingSessionOperation(const QString operation)
|
||||
QDBusMessage response = bus.call(request);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
|
||||
return (!arguments.isEmpty() && bool(arguments[0].toInt()));
|
||||
return (!arguments.isEmpty() && arguments[0].toBool());
|
||||
}
|
||||
|
||||
|
||||
@ -61,7 +66,7 @@ unsigned int getUidFromSession(const int type = 0)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QMap<QString, QVariant> args = getArgs();
|
||||
QVariantMap args = getArgs();
|
||||
// reading
|
||||
for (int i=1; i<argc; i++) {
|
||||
if (QString(argv[i]) == QString("--detached")) {
|
||||
@ -130,6 +135,9 @@ int main(int argc, char *argv[])
|
||||
args[QString("error")] = true;
|
||||
}
|
||||
}
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||
if (!args[QString("debug")].toBool()) args[QString("debug")] = (debugEnv == QString("yes"));
|
||||
if ((args[QString("debug")].toBool()) ||
|
||||
(args[QString("help")].toBool()) ||
|
||||
(args[QString("info")].toBool()) ||
|
||||
@ -137,32 +145,42 @@ int main(int argc, char *argv[])
|
||||
(args[QString("error")].toBool()))
|
||||
args[QString("detached")] = false;
|
||||
if (args[QString("essid")].toString() != QString("ESSID"))
|
||||
args[QString("tab")] = (int) 3;
|
||||
args[QString("tab")] = static_cast<int>(3);
|
||||
if (args[QString("open")].toString() != QString("PROFILE"))
|
||||
args[QString("tab")] = (int) 2;
|
||||
args[QString("tab")] = static_cast<int>(2);
|
||||
if (args[QString("select")].toString() != QString("PROFILE"))
|
||||
args[QString("tab")] = (int) 1;
|
||||
args[QString("tab")] = static_cast<int>(1);
|
||||
|
||||
// check
|
||||
QString robotEnv = environment.value(QString("SKYNET"), QString(""));
|
||||
if (!robotEnv.isEmpty()) {
|
||||
cout << "Sorry, this software is only for humans" << endl;
|
||||
return 2;
|
||||
}
|
||||
|
||||
// detach from console
|
||||
if (args[QString("detached")].toBool())
|
||||
daemon(0, 0);
|
||||
#if QT_VERSION >= 0x050000
|
||||
qInstallMessageHandler(debugString);
|
||||
#endif
|
||||
QApplication a(argc, argv);
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
// reread translations according to flags
|
||||
QString language = Language::defineLanguage(args[QString("config")].toString(),
|
||||
args[QString("options")].toString());
|
||||
QTranslator qtTranslator;
|
||||
qtTranslator.load(QString("qt_") + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
qtTranslator.load(QString("qt_%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
a.installTranslator(&qtTranslator);
|
||||
QTranslator translator;
|
||||
translator.load(QString(":/translations/") + language);
|
||||
translator.load(QString(":/translations/%1").arg(language));
|
||||
a.installTranslator(&translator);
|
||||
|
||||
// running
|
||||
if (args[QString("error")].toBool()) {
|
||||
cout << errorMessage().toUtf8().data() << endl;
|
||||
cout << helpMessage().toUtf8().data();
|
||||
return 127;
|
||||
return 1;
|
||||
} else if (args[QString("help")].toBool()) {
|
||||
cout << helpMessage().toUtf8().data();
|
||||
return 0;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,523 +0,0 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-gui is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-gui is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QLibraryInfo>
|
||||
#include <QTranslator>
|
||||
#include <QUrl>
|
||||
|
||||
#include <language/language.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "aboutwindow.h"
|
||||
#include "dbusoperation.h"
|
||||
#include "errorwindow.h"
|
||||
#include "netctlautowindow.h"
|
||||
#include "passwdwidget.h"
|
||||
#include "settingswindow.h"
|
||||
#include "trayicon.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
void MainWindow::closeMainWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showAboutWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
aboutWin->show();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showMainWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (isHidden()) {
|
||||
updateTabs(ui->tabWidget->currentIndex());
|
||||
show();
|
||||
} else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showNetctlAutoWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
netctlAutoWin->showWindow();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showSettingsWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
settingsWin->showWindow();
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::enableProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool current;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Enable"),
|
||||
args, true, debug);
|
||||
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isProfileEnabled"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else {
|
||||
netctlCommand->enableProfile(profile);
|
||||
current = netctlCommand->isProfileEnabled(profile);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::restartProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool current;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Restart"),
|
||||
args, true, debug)[0].toBool();
|
||||
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else {
|
||||
netctlCommand->restartProfile(profile);
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::startProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool current;
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
QStringList currentProfile = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("ActiveProfile"),
|
||||
QList<QVariant>(), true, debug)[0]
|
||||
.toString().split(QChar('|'));
|
||||
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Start"),
|
||||
args, true, debug);
|
||||
else
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("SwitchTo"),
|
||||
args, true, debug);
|
||||
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else {
|
||||
QStringList currentProfile = netctlCommand->getActiveProfile();
|
||||
if ((currentProfile.isEmpty()) || (currentProfile.contains(profile)))
|
||||
netctlCommand->startProfile(profile);
|
||||
else
|
||||
netctlCommand->switchToProfile(profile);
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::stopAllProfilesSlot()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (useHelper)
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("StopAll"),
|
||||
QList<QVariant>(), true, debug);
|
||||
else
|
||||
netctlCommand->stopAllProfiles();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::switchToProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
bool netctlAutoStatus = false;
|
||||
if (useHelper)
|
||||
netctlAutoStatus = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
|
||||
|
||||
bool current;
|
||||
if (netctlAutoStatus) {
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoStart"),
|
||||
args, true, debug);
|
||||
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoIsProfileActive"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else {
|
||||
netctlCommand->autoStartProfile(profile);
|
||||
current = netctlCommand->autoIsProfileActive(profile);
|
||||
}
|
||||
} else {
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("SwitchTo"),
|
||||
args, true, debug);
|
||||
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else {
|
||||
netctlCommand->switchToProfile(profile);
|
||||
current = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showApi()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("netctl-gui-dbus-api.html"))))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showLibrary()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("html/index.html"))))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showSecurityNotes()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (QDesktopServices::openUrl(QUrl(QString(DOCS_PATH) + QString("netctl-gui-security-notes.html"))))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::forceStartHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("helper"))) {
|
||||
errorWin->showWindow(1, QString(PDEBUG));
|
||||
return false;
|
||||
}
|
||||
|
||||
QString cmd = configuration[QString("HELPER_PATH")] + QString(" -c ") + configPath;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, false);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
if (process.exitCode == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::forceStopHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Close"),
|
||||
QList<QVariant>(), true, debug);
|
||||
|
||||
return !responce.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::startHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (isHelperActive())
|
||||
return forceStopHelper();
|
||||
else
|
||||
return forceStartHelper();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setTab(int tab)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
|
||||
|
||||
switch (tab) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
break;
|
||||
default:
|
||||
tab = 0;
|
||||
break;
|
||||
}
|
||||
ui->tabWidget->setCurrentIndex(tab);
|
||||
|
||||
updateTabs(tab);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateConfiguration(const QMap<QString, QVariant> args)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
deleteObjects();
|
||||
|
||||
settingsWin = new SettingsWindow(this, debug, configPath);
|
||||
if (args[QString("default")].toBool())
|
||||
settingsWin->setDefault();
|
||||
configuration = settingsWin->getSettings();
|
||||
delete settingsWin;
|
||||
QMap<QString, QString> optionsDict = parseOptions(args[QString("options")].toString());
|
||||
for (int i=0; i<optionsDict.keys().count(); i++)
|
||||
configuration[optionsDict.keys()[i]] = optionsDict[optionsDict.keys()[i]];
|
||||
if ((configuration[QString("USE_HELPER")] == QString("true")) &&
|
||||
(checkExternalApps(QString("helper"))))
|
||||
useHelper = true;
|
||||
else {
|
||||
useHelper = false;
|
||||
configuration[QString("USE_HELPER")] = QString("false");
|
||||
}
|
||||
|
||||
// update translation
|
||||
qApp->removeTranslator(translator);
|
||||
QString language = Language::defineLanguage(configPath,
|
||||
args[QString("options")].toString());
|
||||
qtTranslator->load(QString("qt_") + language, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
qApp->installTranslator(qtTranslator);
|
||||
translator->load(QString(":/translations/") + language);
|
||||
qApp->installTranslator(translator);
|
||||
|
||||
createObjects();
|
||||
createActions();
|
||||
createToolBars();
|
||||
|
||||
// tray
|
||||
if ((QSystemTrayIcon::isSystemTrayAvailable()) &&
|
||||
(configuration[QString("SYSTRAY")] == QString("true")))
|
||||
trayIcon->setVisible(true);
|
||||
else
|
||||
trayIcon->setVisible(false);
|
||||
if (trayIcon->isVisible()) {
|
||||
if (configuration[QString("STARTTOTRAY")] == QString("true"))
|
||||
hide();
|
||||
else
|
||||
show();
|
||||
if (args[QString("minimized")].toInt() == 1)
|
||||
show();
|
||||
else if (args[QString("minimized")].toInt() == 2)
|
||||
hide();
|
||||
}
|
||||
else
|
||||
show();
|
||||
|
||||
// update ui
|
||||
setTab(args[QString("tab")].toInt() - 1);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateMenu()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
int tab = ui->tabWidget->currentIndex();
|
||||
setMenuActionsShown(false);
|
||||
|
||||
if (tab == 0)
|
||||
updateMenuMain();
|
||||
else if (tab == 1)
|
||||
updateMenuProfile();
|
||||
else if (tab == 2)
|
||||
updateMenuWifi();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateTabs(const int tab)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Update tab" << tab;
|
||||
|
||||
if (tab == 0)
|
||||
updateMainTab();
|
||||
else if (tab == 1)
|
||||
updateProfileTab();
|
||||
else if (tab == 2)
|
||||
updateWifiTab();
|
||||
updateMenu();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::connectToUnknownEssid(const QString passwd)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (passwdWid != 0)
|
||||
delete passwdWid;
|
||||
QStringList interfaces;
|
||||
if (useHelper)
|
||||
interfaces = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("WirelessInterfaces"),
|
||||
QList<QVariant>(), true, debug)[0].toStringList();
|
||||
else
|
||||
interfaces = netctlCommand->getWirelessInterfaceList();
|
||||
if (interfaces.isEmpty()) return;
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
|
||||
settings[QString("Interface")] = interfaces[0];
|
||||
settings[QString("Connection")] = QString("wireless");
|
||||
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 2)->text();
|
||||
if (security.contains(QString("WPA")))
|
||||
settings[QString("Security")] = QString("wpa");
|
||||
else if (security.contains(QString("WEP")))
|
||||
settings[QString("Security")] = QString("wep");
|
||||
else
|
||||
settings[QString("Security")] = QString("none");
|
||||
settings[QString("ESSID")] = QString("'") +
|
||||
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() +
|
||||
QString("'");
|
||||
if (!passwd.isEmpty())
|
||||
settings[QString("Key")] = QString("'") + passwd + QString("'");
|
||||
settings[QString("IP")] = QString("dhcp");
|
||||
if (hiddenNetwork)
|
||||
settings[QString("Hidden")] = QString("yes");
|
||||
|
||||
QString profile = QString("netctl-gui-") + settings[QString("ESSID")];
|
||||
profile.remove(QChar('"')).remove(QChar('\''));
|
||||
bool status = false;
|
||||
if (useHelper) {
|
||||
QStringList settingsList;
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
settingsList.append(settings.keys()[i] + QString("==") + settings[settings.keys()[i]]);
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
args.append(settingsList);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Create"),
|
||||
args, true, debug);
|
||||
args.clear();
|
||||
args.append(profile);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Start"),
|
||||
args, true, debug);
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isProfileActive"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else {
|
||||
QString profileTempName = netctlProfile->createProfile(profile, settings);
|
||||
netctlProfile->copyProfile(profileTempName);
|
||||
netctlCommand->startProfile(profile);
|
||||
status = netctlCommand->isProfileActive(profile);
|
||||
}
|
||||
QString message;
|
||||
if (status) {
|
||||
message = QApplication::translate("MainWindow", "Connection is successfully.");
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
} else {
|
||||
message = QApplication::translate("MainWindow", "Connection failed.");
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
message += QString("\n");
|
||||
message += QApplication::translate("MainWindow", "Do you want to save profile %1?").arg(profile);
|
||||
int select = QMessageBox::question(this, QApplication::translate("MainWindow", "WiFi menu"),
|
||||
message, QMessageBox::Save | QMessageBox::Discard, QMessageBox::Save);
|
||||
switch (select) {
|
||||
case QMessageBox::Save:
|
||||
break;
|
||||
case QMessageBox::Discard:
|
||||
default:
|
||||
if (useHelper) {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Remove"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else
|
||||
netctlProfile->removeProfile(profile);
|
||||
break;
|
||||
}
|
||||
|
||||
updateWifiTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setHiddenName(const QString name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Set name" << name;
|
||||
|
||||
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->setText(name);
|
||||
|
||||
wifiTabStart();
|
||||
}
|
436
sources/gui/src/mainwidget.cpp
Normal file
436
sources/gui/src/mainwidget.cpp
Normal file
@ -0,0 +1,436 @@
|
||||
/***************************************************************************
|
||||
* 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 "mainwidget.h"
|
||||
#include "ui_mainwidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "calls.h"
|
||||
#include "commonfunctions.h"
|
||||
#include "dbusoperation.h"
|
||||
#include "errorwindow.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
MainWidget::MainWidget(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd)
|
||||
: QMainWindow(parent),
|
||||
debug(debugCmd),
|
||||
configuration(settings)
|
||||
{
|
||||
mainWindow = dynamic_cast<MainWindow *>(parent);
|
||||
useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
|
||||
|
||||
// windows
|
||||
ui = new Ui::MainWidget;
|
||||
ui->setupUi(this);
|
||||
ui->tableWidget_main->setColumnHidden(2, true);
|
||||
ui->tableWidget_main->setColumnHidden(3, true);
|
||||
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("NETCTL_TOOLBAR")].toInt()));
|
||||
|
||||
// append toolbar
|
||||
QMenu *actionMenu = new QMenu(this);
|
||||
actionMenu->addAction(ui->actionSwitch);
|
||||
actionMenu->addAction(ui->actionRestart);
|
||||
actionMenu->addAction(ui->actionEnable);
|
||||
ui->actionStart->setMenu(actionMenu);
|
||||
|
||||
// auto update
|
||||
timer.setSingleShot(true);
|
||||
timer.setInterval(configuration[QString("MAINUPDATE")].toInt() * 1000);
|
||||
|
||||
createActions();
|
||||
}
|
||||
|
||||
|
||||
MainWidget::~MainWidget()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui != nullptr) delete ui;
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea MainWidget::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
bool MainWidget::mainTabSelectProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Profile" << profile;
|
||||
|
||||
for (int i=0; i<ui->tableWidget_main->rowCount(); i++) {
|
||||
if (ui->tableWidget_main->item(i, 0)->text() != profile) continue;
|
||||
ui->tableWidget_main->setCurrentCell(i, 0);
|
||||
}
|
||||
|
||||
return (ui->tableWidget_main->currentItem() != nullptr);
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::update()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (mainWindow->currentTab() == 0) {
|
||||
updateMainTab();
|
||||
updateMenuMain();
|
||||
}
|
||||
|
||||
if (timer.interval() != 0) return timer.start();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::updateMenuMain()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
bool selected = (ui->tableWidget_main->currentItem() != nullptr);
|
||||
ui->actionStart->setEnabled(selected);
|
||||
ui->actionEnable->setEnabled(selected);
|
||||
ui->actionEdit->setEnabled(selected);
|
||||
ui->actionRemove->setEnabled(selected);
|
||||
|
||||
if (selected && !ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) {
|
||||
// visible
|
||||
ui->actionRestart->setEnabled(true);
|
||||
ui->actionSwitch->setEnabled(false);
|
||||
// text
|
||||
ui->actionStart->setText(QApplication::translate("MainWidget", "Stop"));
|
||||
ui->actionStart->setIcon(QIcon::fromTheme("process-stop"));
|
||||
} else {
|
||||
// visible
|
||||
ui->actionRestart->setEnabled(false);
|
||||
ui->actionSwitch->setEnabled(selected);
|
||||
// text
|
||||
ui->actionStart->setText(QApplication::translate("MainWidget", "Start"));
|
||||
ui->actionStart->setIcon(QIcon::fromTheme("system-run"));
|
||||
}
|
||||
if (selected && !ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) {
|
||||
ui->actionEnable->setText(QApplication::translate("MainWidget", "Disable"));
|
||||
ui->actionEnable->setIcon(QIcon::fromTheme("edit-remove"));
|
||||
} else {
|
||||
ui->actionEnable->setText(QApplication::translate("MainWidget", "Enable"));
|
||||
ui->actionEnable->setIcon(QIcon::fromTheme("list-add"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::updateMainTab()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
netctlInformation info = generalInformation(mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
ui->label_netctlAuto->setHidden(!info.netctlAuto);
|
||||
|
||||
ui->tableWidget_main->setSortingEnabled(false);
|
||||
ui->tableWidget_main->selectRow(-1);
|
||||
ui->tableWidget_main->sortByColumn(0, Qt::AscendingOrder);
|
||||
ui->tableWidget_main->clear();
|
||||
ui->tableWidget_main->setRowCount(info.netctlProfiles.count());
|
||||
|
||||
// create header
|
||||
QStringList headerList;
|
||||
headerList.append(QApplication::translate("MainWidget", "Name"));
|
||||
headerList.append(QApplication::translate("MainWidget", "Description"));
|
||||
headerList.append(QApplication::translate("MainWidget", "Active"));
|
||||
headerList.append(QApplication::translate("MainWidget", "Enabled"));
|
||||
ui->tableWidget_main->setHorizontalHeaderLabels(headerList);
|
||||
// create items
|
||||
for (int i=0; i<info.netctlProfiles.count(); i++) {
|
||||
// font
|
||||
QFont font;
|
||||
font.setBold(info.netctlProfiles[i].active);
|
||||
font.setItalic(info.netctlProfiles[i].enabled);
|
||||
// tooltip
|
||||
QString toolTip = QString("");
|
||||
toolTip += QString("%1: %2@%3\n").arg(QApplication::translate("MainWidget", "Type"))
|
||||
.arg(info.netctlProfiles[i].type)
|
||||
.arg(info.netctlProfiles[i].interface);
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWidget", "Active"))
|
||||
.arg(checkStatus(info.netctlProfiles[i].active));
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("MainWidget", "Enabled"))
|
||||
.arg(checkStatus(info.netctlProfiles[i].enabled));
|
||||
toolTip += QString("%1: %2").arg(QApplication::translate("MainWidget", "Is wireless"))
|
||||
.arg(checkStatus(!info.netctlProfiles[i].essid.isEmpty()));
|
||||
// name
|
||||
ui->tableWidget_main->setItem(i, 0, new QTableWidgetItem(info.netctlProfiles[i].name));
|
||||
ui->tableWidget_main->item(i, 0)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
ui->tableWidget_main->item(i, 0)->setToolTip(toolTip);
|
||||
ui->tableWidget_main->item(i, 0)->setFont(font);
|
||||
// description
|
||||
ui->tableWidget_main->setItem(i, 1, new QTableWidgetItem(info.netctlProfiles[i].description));
|
||||
ui->tableWidget_main->item(i, 1)->setTextAlignment(Qt::AlignJustify | Qt::AlignVCenter);
|
||||
ui->tableWidget_main->item(i, 1)->setToolTip(toolTip);
|
||||
// active
|
||||
ui->tableWidget_main->setItem(i, 2, new QTableWidgetItem(checkStatus(info.netctlProfiles[i].active, true)));
|
||||
ui->tableWidget_main->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
// enabled
|
||||
ui->tableWidget_main->setItem(i, 3, new QTableWidgetItem(checkStatus(info.netctlProfiles[i].enabled, true)));
|
||||
ui->tableWidget_main->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
ui->tableWidget_main->setSortingEnabled(true);
|
||||
|
||||
ui->tableWidget_main->resizeRowsToContents();
|
||||
ui->tableWidget_main->resizeColumnsToContents();
|
||||
ui->tableWidget_main->resizeRowsToContents();
|
||||
#if QT_VERSION >= 0x050000
|
||||
ui->tableWidget_main->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
#else
|
||||
ui->tableWidget_main->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
#endif
|
||||
|
||||
mainWindow->setDisabled(false);
|
||||
mainWindow->showMessage(true);
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabContextualMenu(const QPoint &pos)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
// create menu
|
||||
QMenu menu(this);
|
||||
QAction *refreshTable = menu.addAction(QApplication::translate("MainWidget", "Refresh"));
|
||||
refreshTable->setIcon(QIcon::fromTheme("view-refresh"));
|
||||
menu.addSeparator();
|
||||
QAction *startProfile = menu.addAction(QApplication::translate("MainWidget", "Start profile"));
|
||||
QAction *restartProfile = menu.addAction(QApplication::translate("MainWidget", "Restart profile"));
|
||||
restartProfile->setIcon(QIcon::fromTheme("view-refresh"));
|
||||
QAction *enableProfile = menu.addAction(QApplication::translate("MainWidget", "Enable profile"));
|
||||
menu.addSeparator();
|
||||
QAction *editProfile = menu.addAction(QApplication::translate("MainWidget", "Edit profile"));
|
||||
editProfile->setIcon(QIcon::fromTheme("document-edit"));
|
||||
QAction *removeProfile = menu.addAction(QApplication::translate("MainWidget", "Remove profile"));
|
||||
removeProfile->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
|
||||
// set text
|
||||
if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text().isEmpty()) {
|
||||
restartProfile->setVisible(true);
|
||||
startProfile->setText(QApplication::translate("MainWidget", "Stop profile"));
|
||||
startProfile->setIcon(QIcon::fromTheme("process-stop"));
|
||||
} else {
|
||||
restartProfile->setVisible(false);
|
||||
startProfile->setText(QApplication::translate("MainWidget", "Start profile"));
|
||||
startProfile->setIcon(QIcon::fromTheme("system-run"));
|
||||
}
|
||||
if (!ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 3)->text().isEmpty()) {
|
||||
enableProfile->setText(QApplication::translate("MainWidget", "Disable profile"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("edit-remove"));
|
||||
} else {
|
||||
enableProfile->setText(QApplication::translate("MainWidget", "Enable profile"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("list-add"));
|
||||
}
|
||||
|
||||
// actions
|
||||
QAction *action = menu.exec(ui->tableWidget_main->viewport()->mapToGlobal(pos));
|
||||
if (action == refreshTable) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Refresh table";
|
||||
updateMainTab();
|
||||
} else if (action == startProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Start profile";
|
||||
mainTabStartProfile();
|
||||
} else if (action == restartProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Restart profile";
|
||||
mainTabRestartProfile();
|
||||
} else if (action == enableProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Enable profile";
|
||||
mainTabEnableProfile();
|
||||
} else if (action == editProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Edit profile";
|
||||
mainTabEditProfile();
|
||||
} else if (action == removeProfile) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Remove profile";
|
||||
mainTabRemoveProfile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabEditProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
mainWindow->setTab(1);
|
||||
mainWindow->openProfileSlot(profile);
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabEnableProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
InterfaceAnswer answer = enableProfileSlot(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
// TODO check if status has been changed?
|
||||
mainWindow->showMessage(answer != InterfaceAnswer::Error);
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabRemoveProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("sudo"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("sudo"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
InterfaceAnswer answer = removeProfileSlot(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabRestartProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
InterfaceAnswer answer = restartProfileSlot(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabStartProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
InterfaceAnswer answer = startProfileSlot(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabStopAllProfiles()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
InterfaceAnswer answer = stopAllProfilesSlot(mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::mainTabSwitchToProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
InterfaceAnswer answer = switchToProfileSlot(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWidget::createActions()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// menu actions
|
||||
connect(&timer, SIGNAL(timeout()), this, SLOT(update()));
|
||||
connect(ui->actionEnable, SIGNAL(triggered(bool)), this, SLOT(mainTabEnableProfile()));
|
||||
connect(ui->actionEdit, SIGNAL(triggered(bool)), this, SLOT(mainTabEditProfile()));
|
||||
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(updateMainTab()));
|
||||
connect(ui->actionRemove, SIGNAL(triggered(bool)), this, SLOT(mainTabRemoveProfile()));
|
||||
connect(ui->actionRestart, SIGNAL(triggered(bool)), this, SLOT(mainTabRestartProfile()));
|
||||
connect(ui->actionStart, SIGNAL(triggered(bool)), this, SLOT(mainTabStartProfile()));
|
||||
connect(ui->actionStop_all, SIGNAL(triggered(bool)), this, SLOT(mainTabStopAllProfiles()));
|
||||
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(mainTabSwitchToProfile()));
|
||||
// main tab events
|
||||
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
|
||||
connect(ui->tableWidget_main, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
|
||||
this, SLOT(updateMenuMain()));
|
||||
connect(ui->tableWidget_main, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(mainTabContextualMenu(QPoint)));
|
||||
}
|
79
sources/gui/src/mainwidget.h
Normal file
79
sources/gui/src/mainwidget.h
Normal 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/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef MAINWIDGET_H
|
||||
#define MAINWIDGET_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QTimer>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class MainWidget;
|
||||
}
|
||||
|
||||
class MainWidget : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWidget(QWidget *parent = 0,
|
||||
const QMap<QString,QString> settings = QMap<QString,QString>(),
|
||||
const bool debugCmd = false);
|
||||
~MainWidget();
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
|
||||
public slots:
|
||||
bool mainTabSelectProfileSlot(const QString profile);
|
||||
void update();
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
|
||||
private slots:
|
||||
// update slots
|
||||
void updateMenuMain();
|
||||
void updateMainTab();
|
||||
// main tab slots
|
||||
void mainTabContextualMenu(const QPoint &pos);
|
||||
void mainTabEditProfile();
|
||||
void mainTabEnableProfile();
|
||||
void mainTabRemoveProfile();
|
||||
void mainTabRestartProfile();
|
||||
void mainTabStartProfile();
|
||||
void mainTabStopAllProfiles();
|
||||
void mainTabSwitchToProfile();
|
||||
|
||||
private:
|
||||
// ui
|
||||
MainWindow *mainWindow = nullptr;
|
||||
Ui::MainWidget *ui = nullptr;
|
||||
// backend
|
||||
void createActions();
|
||||
QString configPath;
|
||||
bool debug = false;
|
||||
QTimer timer;
|
||||
bool useHelper = true;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
};
|
||||
|
||||
|
||||
#endif /* MAINWIDGET_H */
|
208
sources/gui/src/mainwidget.ui
Normal file
208
sources/gui/src/mainwidget.ui
Normal file
@ -0,0 +1,208 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWidget</class>
|
||||
<widget class="QMainWindow" name="MainWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>515</width>
|
||||
<height>477</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</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>
|
||||
<property name="columnCount">
|
||||
<number>4</number>
|
||||
</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/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>Main actions toolbar</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonFollowStyle</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionStart"/>
|
||||
<addaction name="actionStop_all"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionEdit"/>
|
||||
<addaction name="actionRemove"/>
|
||||
</widget>
|
||||
<action name="actionRefresh">
|
||||
<property name="icon">
|
||||
<iconset theme="view-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Refresh table</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStart">
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Start or stop selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSwitch">
|
||||
<property name="text">
|
||||
<string>Switch</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Switch to selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRestart">
|
||||
<property name="icon">
|
||||
<iconset theme="view-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restart</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Restart selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEnable">
|
||||
<property name="icon">
|
||||
<iconset theme="list-add">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enable or disable selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStop_all">
|
||||
<property name="icon">
|
||||
<iconset theme="process-stop">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stop all</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Stop all profiles</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEdit">
|
||||
<property name="icon">
|
||||
<iconset theme="document-edit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Edit selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRemove">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-delete">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -21,37 +21,38 @@
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QLibraryInfo>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QSettings>
|
||||
#include <QTranslator>
|
||||
#include <QUrl>
|
||||
|
||||
#include <language/language.h>
|
||||
#include <listmap/listmap.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "aboutwindow.h"
|
||||
#include "bridgewidget.h"
|
||||
#include "calls.h"
|
||||
#include "commonfunctions.h"
|
||||
#include "dbusoperation.h"
|
||||
#include "errorwindow.h"
|
||||
#include "ethernetwidget.h"
|
||||
#include "generalwidget.h"
|
||||
#include "ipwidget.h"
|
||||
#include "macvlanwidget.h"
|
||||
#include "mobilewidget.h"
|
||||
#include "mainwidget.h"
|
||||
#include "netctlautowindow.h"
|
||||
#include "netctlguiadaptor.h"
|
||||
#include "newprofilewidget.h"
|
||||
#include "passwdwidget.h"
|
||||
#include "pppoewidget.h"
|
||||
#include "settingswindow.h"
|
||||
#include "trayicon.h"
|
||||
#include "tunnelwidget.h"
|
||||
#include "tuntapwidget.h"
|
||||
#include "version.h"
|
||||
#include "vlanwidget.h"
|
||||
#include "wirelesswidget.h"
|
||||
#include "wifimenuwidget.h"
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent,
|
||||
const QMap<QString, QVariant> args,
|
||||
QTranslator *qtAppTranslator,
|
||||
QTranslator *appTranslator)
|
||||
MainWindow::MainWindow(QWidget *parent, const QVariantMap args,
|
||||
QTranslator *qtAppTranslator, QTranslator *appTranslator)
|
||||
: QMainWindow(parent),
|
||||
configPath(args[QString("config")].toString()),
|
||||
debug(args[QString("debug")].toBool()),
|
||||
@ -72,24 +73,19 @@ MainWindow::MainWindow(QWidget *parent,
|
||||
if (debug) qDebug() << PDEBUG << ":" << "settings" << args[QString("settings")].toBool();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "tab" << args[QString("tab")].toInt();
|
||||
|
||||
ui = new Ui::MainWindow;
|
||||
ui->setupUi(this);
|
||||
updateConfiguration(args);
|
||||
|
||||
// main actions
|
||||
if (args[QString("essid")].toString() != QString("ESSID")) {
|
||||
for (int i=0; i<ui->tableWidget_wifi->rowCount(); i++)
|
||||
if (ui->tableWidget_wifi->item(i, 0)->text() == args[QString("essid")].toString())
|
||||
ui->tableWidget_wifi->setCurrentCell(i, 0);
|
||||
if (ui->tableWidget_wifi->currentItem() == 0)
|
||||
errorWin->showWindow(18, QString(PDEBUG));
|
||||
if (!wifiMenuWidget->wifiTabSelectEssidSlot(args[QString("essid")].toString()))
|
||||
ErrorWindow::showWindow(18, QString(PDEBUG), debug);
|
||||
} else if (args[QString("open")].toString() != QString("PROFILE")) {
|
||||
ui->comboBox_profile->addItem(args[QString("open")].toString());
|
||||
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count()-1);
|
||||
newProfileWidget->profileTabOpenProfileSlot(args[QString("open")].toString());
|
||||
} else if (args[QString("select")].toString() != QString("PROFILE")) {
|
||||
for (int i=0; i<ui->tableWidget_main->rowCount(); i++)
|
||||
if (ui->tableWidget_main->item(i, 0)->text() == args[QString("select")].toString())
|
||||
ui->tableWidget_main->setCurrentCell(i, 0);
|
||||
if (ui->tableWidget_main->currentItem() == 0)
|
||||
errorWin->showWindow(17, QString(PDEBUG));
|
||||
if (!mainWidget->mainTabSelectProfileSlot(args[QString("select")].toString()))
|
||||
ErrorWindow::showWindow(17, QString(PDEBUG), debug);
|
||||
}
|
||||
|
||||
// show windows
|
||||
@ -108,42 +104,34 @@ MainWindow::~MainWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if ((useHelper) && (configuration[QString("CLOSE_HELPER")] == QString("true")))
|
||||
if (configuration[QString("CLOSE_HELPER")] == QString("true"))
|
||||
forceStopHelper();
|
||||
deleteObjects();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
QStringList MainWindow::printInformation()
|
||||
int MainWindow::currentTab()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile;
|
||||
QString status;
|
||||
if (useHelper) {
|
||||
QStringList request = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Information"),
|
||||
QList<QVariant>(), true, debug)[0].toStringList();
|
||||
profile = request[0];
|
||||
status = request[1];
|
||||
} else {
|
||||
if (netctlCommand->isNetctlAutoRunning()) {
|
||||
profile = netctlCommand->autoGetActiveProfile();
|
||||
status = QString("netctl-auto");
|
||||
} else {
|
||||
QStringList currentProfiles = netctlCommand->getActiveProfile();
|
||||
profile = currentProfiles.join(QChar('|'));
|
||||
QStringList statusList;
|
||||
for (int i=0; i<currentProfiles.count(); i++)
|
||||
statusList.append(netctlCommand->getProfileStatus(currentProfiles[i]));
|
||||
status = statusList.join(QChar('|'));
|
||||
}
|
||||
}
|
||||
QStringList output;
|
||||
output.append(profile);
|
||||
output.append(status);
|
||||
return ui->stackedWidget->currentIndex();
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
Qt::ToolBarArea MainWindow::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::emitNeedToBeConfigured()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
emit(needToBeConfigured());
|
||||
}
|
||||
|
||||
|
||||
@ -151,79 +139,15 @@ QStringList MainWindow::printSettings()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList settingsList;
|
||||
for (int i=0; i<configuration.keys().count(); i++)
|
||||
settingsList.append(configuration.keys()[i] + QString("==") +
|
||||
configuration[configuration.keys()[i]]);
|
||||
|
||||
return settingsList;
|
||||
return mapToList(configuration);
|
||||
}
|
||||
|
||||
|
||||
QStringList MainWindow::printTrayInformation()
|
||||
netctlCurrent MainWindow::printTrayInformation()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList information;
|
||||
QString current;
|
||||
QString enabled;
|
||||
bool netctlAutoStatus = false;
|
||||
QList<netctlProfileInfo> profiles;
|
||||
if (useHelper) {
|
||||
current = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("ActiveProfile"),
|
||||
QList<QVariant>(), true, debug)[0].toString();
|
||||
netctlAutoStatus = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("ProfileList"),
|
||||
QList<QVariant>(), true, debug), debug);
|
||||
if (netctlAutoStatus) {
|
||||
QList<QVariant> args;
|
||||
args.append(current);
|
||||
enabled = QString::number(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoIsProfileEnabled"),
|
||||
args, true, debug)[0].toBool());
|
||||
} else {
|
||||
QStringList currentProfiles = current.split(QChar('|'));
|
||||
QStringList enabledList;
|
||||
for (int i=0; i<currentProfiles.count(); i++) {
|
||||
QList<QVariant> args;
|
||||
args.append(currentProfiles[i]);
|
||||
enabledList.append(QString::number(
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isProfileEnabled"),
|
||||
args, true, debug)[0].toBool()));
|
||||
enabled = enabledList.join(QChar('|'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
netctlAutoStatus = netctlCommand->isNetctlAutoRunning();
|
||||
if (netctlAutoStatus) {
|
||||
current = netctlCommand->autoGetActiveProfile();
|
||||
enabled = QString::number(netctlCommand->autoIsProfileEnabled(current));
|
||||
profiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||
} else {
|
||||
QStringList currentProfiles = netctlCommand->getActiveProfile();
|
||||
current = currentProfiles.join(QChar('|'));
|
||||
QStringList enabledList;
|
||||
for (int i=0; i<currentProfiles.count(); i++)
|
||||
enabledList.append(QString::number(netctlCommand->isProfileEnabled(currentProfiles[i])));
|
||||
enabled = enabledList.join(QChar('|'));
|
||||
profiles = netctlCommand->getProfileList();
|
||||
}
|
||||
}
|
||||
|
||||
information.append(QString::number(netctlAutoStatus));
|
||||
QStringList profileList;
|
||||
for (int i=0; i<profiles.count(); i++)
|
||||
profileList.append(profiles[i].name);
|
||||
information.append(profileList.join(QChar('|')));
|
||||
information.append(current);
|
||||
information.append(enabled);
|
||||
|
||||
return information;
|
||||
return trayInformation(netctlInterface, useHelper, debug);
|
||||
}
|
||||
|
||||
|
||||
@ -231,11 +155,9 @@ bool MainWindow::isHelperActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<QVariant> responce = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Active"),
|
||||
QList<QVariant>(), true, debug);
|
||||
QList<QVariant> responce = sendRequestToCtrl(QString("Active"), debug);
|
||||
|
||||
return (!responce.isEmpty() && bool(responce[0].toInt()));
|
||||
return (!responce.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
@ -243,18 +165,15 @@ bool MainWindow::isHelperServiceActive()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString cmd = configuration[QString("SYSTEMCTL_PATH")] + QString(" is-active ") +
|
||||
configuration[QString("HELPER_SERVICE")];
|
||||
QString cmd = QString("%1 is-active %2").arg(configuration[QString("SYSTEMCTL_PATH")])
|
||||
.arg(configuration[QString("HELPER_SERVICE")]);
|
||||
if (debug) qDebug() << PDEBUG << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, false);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
if (process.exitCode != 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
return (process.exitCode == 0);
|
||||
}
|
||||
|
||||
|
||||
@ -262,62 +181,294 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if ((QSystemTrayIcon::isSystemTrayAvailable()) &&
|
||||
(configuration[QString("SYSTRAY")] == QString("true"))) {
|
||||
if ((QSystemTrayIcon::isSystemTrayAvailable()) && (configuration[QString("SYSTRAY")] == QString("true"))) {
|
||||
hide();
|
||||
trayIcon->showMessage(QApplication::translate("MainWindow", "Information"),
|
||||
QApplication::translate("MainWindow", "Application has been hidden to tray"));
|
||||
event->ignore();
|
||||
} else
|
||||
closeMainWindow();
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::checkExternalApps(const QString apps = QString("all"))
|
||||
// tray icon
|
||||
void MainWindow::closeMainWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (configuration[QString("SKIPCOMPONENTS")] == QString("true")) return true;
|
||||
QStringList cmd;
|
||||
cmd.append("which");
|
||||
cmd.append(configuration[QString("SUDO_PATH")]);
|
||||
if ((apps == QString("helper")) || (apps == QString("all"))) {
|
||||
cmd.append(configuration[QString("HELPER_PATH")]);
|
||||
}
|
||||
if ((apps == QString("netctl")) || (apps == QString("all"))) {
|
||||
cmd.append(configuration[QString("NETCTL_PATH")]);
|
||||
cmd.append(configuration[QString("NETCTLAUTO_PATH")]);
|
||||
}
|
||||
if ((apps == QString("systemctl")) || (apps == QString("all"))) {
|
||||
cmd.append(configuration[QString("SYSTEMCTL_PATH")]);
|
||||
}
|
||||
if ((apps == QString("wpasup")) || (apps == QString("all"))) {
|
||||
cmd.append(configuration[QString("WPACLI_PATH")]);
|
||||
cmd.append(configuration[QString("WPASUP_PATH")]);
|
||||
storeToolBars();
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::openProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
newProfileWidget->profileTabOpenProfileSlot(profile);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showAboutWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
aboutWin->show();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showMainWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (isHidden()) {
|
||||
setTab(ui->stackedWidget->currentIndex());
|
||||
show();
|
||||
} else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showNetctlAutoWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
netctlAutoWin->showWindow();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showSettingsWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
storeToolBars();
|
||||
settingsWin->showWindow();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showApi()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
showMessage(QDesktopServices::openUrl(QUrl(QString("%1netctl-gui-dbus-api.html").arg(QString(DOCS_PATH)))));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showLibrary()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
showMessage(QDesktopServices::openUrl(QUrl(QString("%1html/index.html").arg(QString(DOCS_PATH)))));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showSecurityNotes()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
showMessage(QDesktopServices::openUrl(QUrl(QString("%1netctl-gui-security-notes.html").arg(QString(DOCS_PATH)))));
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::forceStartHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("helper"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("helper"), configuration).join(QChar('\n')), debug);
|
||||
emit(needToBeConfigured());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd.join(QChar(' '));
|
||||
TaskResult process = runTask(cmd.join(QChar(' ')), false);
|
||||
QString cmd = QString("%1 -c %2").arg(configuration[QString("HELPER_PATH")]).arg(configPath);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, false);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
if (process.exitCode != 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
return (process.exitCode == 0);
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::forceStopHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QList<QVariant> responce = sendRequestToCtrl(QString("Close"), debug);
|
||||
|
||||
return (!responce.isEmpty());
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::startHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (isHelperActive())
|
||||
return forceStopHelper();
|
||||
else
|
||||
return forceStartHelper();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setDisabled(const bool disabled)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->toolBar->setDisabled(disabled);
|
||||
ui->stackedWidget->setDisabled(disabled);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::setTab(int tab)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Set tab" << tab;
|
||||
if (ui->stackedWidget->currentWidget() == nullptr) return;
|
||||
|
||||
if ((tab > 2) || (tab < 0)) tab = 0;
|
||||
if (tab != ui->stackedWidget->currentIndex())
|
||||
return ui->stackedWidget->setCurrentIndex(tab);
|
||||
|
||||
switch (tab) {
|
||||
case 1:
|
||||
newProfileWidget->update();
|
||||
break;
|
||||
case 2:
|
||||
wifiMenuWidget->update();
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
mainWidget->update();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showMessage(const bool status)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Status" << status;
|
||||
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::storeToolBars()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QSettings settings(configPath, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Toolbars"));
|
||||
settings.setValue(QString("MAIN_TOOLBAR"), QString::number(getToolBarArea()));
|
||||
settings.setValue(QString("NETCTL_TOOLBAR"), QString::number(mainWidget->getToolBarArea()));
|
||||
settings.setValue(QString("NETCTLAUTO_TOOLBAR"), QString::number(netctlAutoWin->getToolBarArea()));
|
||||
settings.setValue(QString("PROFILE_TOOLBAR"), QString::number(newProfileWidget->getToolBarArea()));
|
||||
settings.setValue(QString("WIFI_TOOLBAR"), QString::number(wifiMenuWidget->getToolBarArea()));
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateConfiguration(const QVariantMap args)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
deleteObjects();
|
||||
|
||||
QString actualConfigPath = QFile(configPath).exists() ? configPath : QString("/etc/netctl-gui.conf");
|
||||
settingsWin = new SettingsWindow(this, debug, actualConfigPath);
|
||||
if (args[QString("default")].toBool())
|
||||
settingsWin->setDefault();
|
||||
configuration = settingsWin->getSettings();
|
||||
delete settingsWin;
|
||||
QMap<QString, QString> optionsDict = parseOptions(args[QString("options")].toString());
|
||||
for (int i=0; i<optionsDict.keys().count(); i++)
|
||||
configuration[optionsDict.keys()[i]] = optionsDict[optionsDict.keys()[i]];
|
||||
useHelper = ((configuration[QString("USE_HELPER")] == QString("true")) &&
|
||||
(checkExternalApps(QString("helper"), configuration, debug)));
|
||||
|
||||
// update translation
|
||||
qApp->removeTranslator(translator);
|
||||
QString language = Language::defineLanguage(actualConfigPath, args[QString("options")].toString());
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Language is" << language;
|
||||
qtTranslator->load(QString("qt_%1").arg(language), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
|
||||
qApp->installTranslator(qtTranslator);
|
||||
translator->load(QString(":/translations/%1").arg(language));
|
||||
qApp->installTranslator(translator);
|
||||
|
||||
createObjects();
|
||||
createActions();
|
||||
|
||||
// tray
|
||||
trayIcon->setVisible(QSystemTrayIcon::isSystemTrayAvailable() && (configuration[QString("SYSTRAY")] == QString("true")));
|
||||
if (trayIcon->isVisible()) {
|
||||
setHidden(configuration[QString("STARTTOTRAY")] == QString("true"));
|
||||
if (args[QString("minimized")].toInt() == 1)
|
||||
show();
|
||||
else if (args[QString("minimized")].toInt() == 2)
|
||||
hide();
|
||||
}
|
||||
else
|
||||
show();
|
||||
|
||||
// update ui
|
||||
setTab(args[QString("tab")].toInt() - 1);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// private slots
|
||||
void MainWindow::setTabByAction(QAction *action)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (action == nullptr) return;
|
||||
|
||||
if (action == ui->actionNetctl)
|
||||
setTab(0);
|
||||
else if (action == ui->actionProfiles)
|
||||
setTab(1);
|
||||
else if (action == ui->actionWiFi_menu)
|
||||
setTab(2);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::reportABug()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
showMessage(QDesktopServices::openUrl(QUrl(QString(BUGTRACKER))));
|
||||
}
|
||||
|
||||
|
||||
// window signals
|
||||
bool MainWindow::checkHelperStatus()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (useHelper) useHelper = isHelperActive();
|
||||
if (useHelper)
|
||||
sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("Update"),
|
||||
QList<QVariant>(), true, debug);
|
||||
else
|
||||
if (!useHelper) {
|
||||
configuration[QString("CLOSE_HELPER")] = QString("false");
|
||||
configuration[QString("FORCE_SUDO")] = QString("true");
|
||||
configuration[QString("USE_HELPER")] = QString("false");
|
||||
}
|
||||
if (isHelperServiceActive())
|
||||
configuration[QString("CLOSE_HELPER")] = QString("false");
|
||||
|
||||
@ -325,48 +476,23 @@ bool MainWindow::checkHelperStatus()
|
||||
}
|
||||
|
||||
|
||||
QString MainWindow::checkStatus(const bool statusBool, const bool nullFalse)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
|
||||
|
||||
if (statusBool)
|
||||
return QApplication::translate("MainWindow", "yes");
|
||||
if (nullFalse)
|
||||
return QString("");
|
||||
else
|
||||
return QApplication::translate("MainWindow", "no");
|
||||
}
|
||||
|
||||
|
||||
// window signals
|
||||
void MainWindow::createActions()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
|
||||
connect(ui->pushButton_menu, SIGNAL(clicked(bool)), this, SLOT(updateToolBars()));
|
||||
connect(ui->pushButton_action, SIGNAL(clicked(bool)), this, SLOT(updateToolBars()));
|
||||
connect(ui->pushButton_help, SIGNAL(clicked(bool)), this, SLOT(updateToolBars()));
|
||||
connect(ui->toolBar, SIGNAL(actionTriggered(QAction *)), this, SLOT(setTabByAction(QAction *)));
|
||||
connect(ui->actionNetctl_auto, SIGNAL(triggered()), this, SLOT(showNetctlAutoWindow()));
|
||||
connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(setTab(int)));
|
||||
connect(this, SIGNAL(needToBeConfigured()), this, SLOT(showSettingsWindow()));
|
||||
|
||||
// main tab events
|
||||
connect(ui->pushButton_netctlAuto, SIGNAL(clicked(bool)), this, SLOT(showNetctlAutoWindow()));
|
||||
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
|
||||
connect(ui->tableWidget_main, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
|
||||
this, SLOT(updateMenuMain()));
|
||||
connect(ui->tableWidget_main, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(mainTabContextualMenu(QPoint)));
|
||||
|
||||
// profile tab events
|
||||
connect(ui->comboBox_profile, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabLoadProfile()));
|
||||
connect(ui->comboBox_profile, SIGNAL(editTextChanged(QString)), this, SLOT(updateMenuProfile()));
|
||||
connect(generalWid->connectionType, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabChangeState(QString)));
|
||||
|
||||
// wifi tab events
|
||||
connect(ui->tableWidget_wifi, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(wifiTabStart()));
|
||||
connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
|
||||
this, SLOT(updateMenuWifi()));
|
||||
connect(ui->tableWidget_wifi, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(wifiTabContextualMenu(QPoint)));
|
||||
// menu
|
||||
connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(showSettingsWindow()));
|
||||
connect(ui->actionSecurity, SIGNAL(triggered()), this, SLOT(showSecurityNotes()));
|
||||
connect(ui->actionDBus_API, SIGNAL(triggered()), this, SLOT(showApi()));
|
||||
connect(ui->actionLibrary, SIGNAL(triggered()), this, SLOT(showLibrary()));
|
||||
connect(ui->actionReport_a_bug, SIGNAL(triggered()), this, SLOT(reportABug()));
|
||||
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(showAboutWindow()));
|
||||
connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(closeMainWindow()));
|
||||
}
|
||||
|
||||
|
||||
@ -392,154 +518,31 @@ void MainWindow::createObjects()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// error messages
|
||||
errorWin = new ErrorWindow(this, debug);
|
||||
// backend
|
||||
createDBusSession();
|
||||
if (useHelper)
|
||||
if (!forceStartHelper()) {
|
||||
errorWin->showWindow(19, QString(PDEBUG));
|
||||
useHelper = false;
|
||||
}
|
||||
if ((useHelper) && (!forceStartHelper())) {
|
||||
ErrorWindow::showWindow(19, QString(PDEBUG), debug);
|
||||
useHelper = false;
|
||||
}
|
||||
checkHelperStatus();
|
||||
|
||||
netctlCommand = new Netctl(debug, configuration);
|
||||
netctlProfile = new NetctlProfile(debug, configuration);
|
||||
netctlInterface = new NetctlInterface(debug, configuration);
|
||||
wpaCommand = new WpaSup(debug, configuration);
|
||||
// frontend
|
||||
trayIcon = new TrayIcon(this, debug);
|
||||
mainWidget = new MainWidget(this, configuration, debug);
|
||||
netctlAutoWin = new NetctlAutoWindow(this, configuration, debug);
|
||||
newProfileWidget = new NewProfileWidget(this, configuration, debug);
|
||||
wifiMenuWidget = new WiFiMenuWidget(this, configuration, debug);
|
||||
trayIcon = new TrayIcon(this, configuration, debug);
|
||||
// windows
|
||||
ui = new Ui::MainWindow;
|
||||
ui->setupUi(this);
|
||||
ui->tableWidget_main->setColumnHidden(2, true);
|
||||
ui->tableWidget_main->setColumnHidden(3, true);
|
||||
ui->tableWidget_wifi->setColumnHidden(3, true);
|
||||
ui->tableWidget_wifi->setColumnHidden(4, true);
|
||||
ui->retranslateUi(this);
|
||||
ui->stackedWidget->addWidget(mainWidget);
|
||||
ui->stackedWidget->addWidget(newProfileWidget);
|
||||
ui->stackedWidget->addWidget(wifiMenuWidget);
|
||||
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("MAIN_TOOLBAR")].toInt()));
|
||||
aboutWin = new AboutWindow(this, debug);
|
||||
netctlAutoWin = new NetctlAutoWindow(this, debug, configuration);
|
||||
settingsWin = new SettingsWindow(this, debug, configPath);
|
||||
// profile widgets
|
||||
generalWid = new GeneralWidget(this, configuration);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(generalWid);
|
||||
ipWid = new IpWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(ipWid);
|
||||
bridgeWid = new BridgeWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid);
|
||||
ethernetWid = new EthernetWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid);
|
||||
macvlanWid = new MacvlanWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(macvlanWid);
|
||||
mobileWid = new MobileWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
|
||||
pppoeWid = new PppoeWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);
|
||||
tunnelWid = new TunnelWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(tunnelWid);
|
||||
tuntapWid = new TuntapWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(tuntapWid);
|
||||
vlanWid = new VlanWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
|
||||
wirelessWid = new WirelessWidget(this, configuration);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::createToolBars()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
mainToolBar = new QToolBar(this);
|
||||
mainToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
|
||||
toolBarActions[QString("netctlAuto")] = mainToolBar->addAction(QApplication::translate("MainWindow", "netctl-auto"),
|
||||
this, SLOT(showNetctlAutoWindow()));
|
||||
toolBarActions[QString("settings")] = mainToolBar->addAction(QIcon::fromTheme(QString("configure")),
|
||||
QApplication::translate("MainWindow", "Settings"),
|
||||
this, SLOT(showSettingsWindow()));
|
||||
appShortcuts[QString("settingsShortcut")] = new QShortcut(QKeySequence(QApplication::translate("MainWindow", "Ctrl+S")),
|
||||
this, SLOT(showSettingsWindow()));
|
||||
toolBarActions[QString("quit")] = mainToolBar->addAction(QIcon::fromTheme(QString("exit")),
|
||||
QApplication::translate("MainWindow", "Quit"),
|
||||
this, SLOT(closeMainWindow()));
|
||||
appShortcuts[QString("quitShortcut")] = new QShortcut(QKeySequence(QApplication::translate("MainWindow", "Ctrl+Q")),
|
||||
this, SLOT(closeMainWindow()));
|
||||
ui->centralLayout->insertWidget(1, mainToolBar);
|
||||
mainToolBar->setHidden(true);
|
||||
|
||||
actionToolBar = new QToolBar(this);
|
||||
actionToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
|
||||
toolBarActions[QString("mainRefresh")] = actionToolBar->addAction(QIcon::fromTheme(QString("stock-refresh")),
|
||||
QApplication::translate("MainWindow", "Refresh"),
|
||||
this, SLOT(updateMainTab()));
|
||||
toolBarActions[QString("profileClear")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-clear")),
|
||||
QApplication::translate("MainWindow", "Clear"),
|
||||
this, SLOT(profileTabClear()));
|
||||
toolBarActions[QString("wifiRefresh")] = actionToolBar->addAction(QIcon::fromTheme(QString("stock-refresh")),
|
||||
QApplication::translate("MainWindow", "Refresh"),
|
||||
this, SLOT(updateWifiTab()));
|
||||
|
||||
actionMenu = new QToolButton(this);
|
||||
actionMenu->setPopupMode(QToolButton::DelayedPopup);
|
||||
actionMenu->setToolButtonStyle(Qt::ToolButtonFollowStyle);
|
||||
QMenu *menu = new QMenu(actionMenu);
|
||||
toolBarActions[QString("mainStart")] = menu->addAction(QIcon::fromTheme(QString("system-run")),
|
||||
QApplication::translate("MainWindow", "Start"),
|
||||
this, SLOT(mainTabStartProfile()));
|
||||
toolBarActions[QString("mainSwitch")] = menu->addAction(QIcon::fromTheme(QString("system-run")),
|
||||
QApplication::translate("MainWindow", "Switch"),
|
||||
this, SLOT(mainTabSwitchToProfile()));
|
||||
toolBarActions[QString("mainRestart")] = menu->addAction(QIcon::fromTheme(QString("stock-refresh")),
|
||||
QApplication::translate("MainWindow", "Restart"),
|
||||
this, SLOT(mainTabRestartProfile()));
|
||||
toolBarActions[QString("mainEnable")] = menu->addAction(QIcon::fromTheme(QString("edit-add")),
|
||||
QApplication::translate("MainWindow", "Enable"),
|
||||
this, SLOT(mainTabEnableProfile()));
|
||||
toolBarActions[QString("mainStopAll")] = menu->addAction(QIcon::fromTheme(QString("process-stop")),
|
||||
QApplication::translate("MainWindow", "Stop all"),
|
||||
this, SLOT(mainTabStopAllProfiles()));
|
||||
toolBarActions[QString("profileLoad")] = menu->addAction(QIcon::fromTheme(QString("document-open")),
|
||||
QApplication::translate("MainWindow", "Load"),
|
||||
this, SLOT(profileTabLoadProfile()));
|
||||
toolBarActions[QString("profileSave")] = menu->addAction(QIcon::fromTheme(QString("document-save")),
|
||||
QApplication::translate("MainWindow", "Save"),
|
||||
this, SLOT(profileTabCreateProfile()));
|
||||
toolBarActions[QString("wifiStart")] = menu->addAction(QIcon::fromTheme(QString("system-run")),
|
||||
QApplication::translate("MainWindow", "Start"),
|
||||
this, SLOT(wifiTabStart()));
|
||||
actionMenu->setMenu(menu);
|
||||
actionToolBar->addWidget(actionMenu);
|
||||
|
||||
toolBarActions[QString("mainEdit")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit")),
|
||||
QApplication::translate("MainWindow", "Edit"),
|
||||
this, SLOT(mainTabEditProfile()));
|
||||
toolBarActions[QString("mainRemove")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-delete")),
|
||||
QApplication::translate("MainWindow", "Remove"),
|
||||
this, SLOT(mainTabRemoveProfile()));
|
||||
toolBarActions[QString("profileRemove")] = actionToolBar->addAction(QIcon::fromTheme(QString("edit-delete")),
|
||||
QApplication::translate("MainWindow", "Remove"),
|
||||
this, SLOT(profileTabRemoveProfile()));
|
||||
ui->centralLayout->insertWidget(1, actionToolBar);
|
||||
actionToolBar->setHidden(true);
|
||||
|
||||
helpToolBar = new QToolBar(this);
|
||||
helpToolBar->setToolButtonStyle(Qt::ToolButtonFollowStyle);
|
||||
toolBarActions[QString("security")] = helpToolBar->addAction(QIcon::fromTheme(QString("security-medium")),
|
||||
QApplication::translate("MainWindow", "Security"),
|
||||
this, SLOT(showSecurityNotes()));
|
||||
toolBarActions[QString("api")] = helpToolBar->addAction(QApplication::translate("MainWindow", "DBus API"),
|
||||
this, SLOT(showApi()));
|
||||
toolBarActions[QString("library")] = helpToolBar->addAction(QApplication::translate("MainWindow", "Library"),
|
||||
this, SLOT(showLibrary()));
|
||||
helpToolBar->addSeparator();
|
||||
toolBarActions[QString("report")] = helpToolBar->addAction(QIcon::fromTheme(QString("tools-report-bug")),
|
||||
QApplication::translate("MainWindow", "Report a bug"),
|
||||
this, SLOT(reportABug()));
|
||||
toolBarActions[QString("about")] = helpToolBar->addAction(QIcon::fromTheme(QString("help-about")),
|
||||
QApplication::translate("MainWindow", "About"),
|
||||
this, SLOT(showAboutWindow()));
|
||||
ui->centralLayout->insertWidget(1, helpToolBar);
|
||||
helpToolBar->setHidden(true);
|
||||
|
||||
ui->pushButton_menu->click();
|
||||
}
|
||||
|
||||
|
||||
@ -547,58 +550,22 @@ void MainWindow::deleteObjects()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// workaround to avoid crash on window closing
|
||||
disconnect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(setTab(int)));
|
||||
|
||||
QDBusConnection::sessionBus().unregisterObject(DBUS_OBJECT_PATH);
|
||||
QDBusConnection::sessionBus().unregisterService(DBUS_SERVICE);
|
||||
if (netctlCommand != nullptr) delete netctlCommand;
|
||||
if (netctlProfile != nullptr) delete netctlProfile;
|
||||
if (netctlInterface != nullptr) delete netctlInterface;
|
||||
if (wpaCommand != nullptr) delete wpaCommand;
|
||||
|
||||
if (bridgeWid != nullptr) delete bridgeWid;
|
||||
if (ethernetWid != nullptr) delete ethernetWid;
|
||||
if (generalWid != nullptr) delete generalWid;
|
||||
if (ipWid != nullptr) delete ipWid;
|
||||
if (macvlanWid != nullptr) delete macvlanWid;
|
||||
if (mobileWid != nullptr) delete mobileWid;
|
||||
if (pppoeWid != nullptr) delete pppoeWid;
|
||||
if (tunnelWid != nullptr) delete tunnelWid;
|
||||
if (tuntapWid != nullptr) delete tuntapWid;
|
||||
if (vlanWid != nullptr) delete vlanWid;
|
||||
if (wirelessWid != nullptr) delete wirelessWid;
|
||||
|
||||
if (aboutWin != nullptr) delete aboutWin;
|
||||
if (errorWin != nullptr) delete errorWin;
|
||||
if (netctlAutoWin != nullptr) delete netctlAutoWin;
|
||||
if (settingsWin != nullptr) delete settingsWin;
|
||||
if (actionMenu != nullptr) {
|
||||
actionMenu->menu()->clear();
|
||||
delete actionMenu;
|
||||
}
|
||||
if (actionToolBar != nullptr) {
|
||||
actionToolBar->clear();
|
||||
delete actionToolBar;
|
||||
}
|
||||
if (helpToolBar != nullptr) {
|
||||
helpToolBar->clear();
|
||||
delete helpToolBar;
|
||||
}
|
||||
if (mainToolBar != nullptr) {
|
||||
mainToolBar->clear();
|
||||
delete mainToolBar;
|
||||
delete appShortcuts[QString("settingsShortcut")];
|
||||
delete appShortcuts[QString("quitShortcut")];
|
||||
}
|
||||
if (trayIcon != nullptr) delete trayIcon;
|
||||
if (ui != nullptr) delete ui;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (pressedKey->key() == Qt::Key_Return)
|
||||
if (ui->comboBox_profile->hasFocus())
|
||||
profileTabLoadProfile();
|
||||
if (mainWidget != nullptr) delete mainWidget;
|
||||
if (netctlAutoWin != nullptr) delete netctlAutoWin;
|
||||
if (newProfileWidget != nullptr) delete newProfileWidget;
|
||||
if (wifiMenuWidget != nullptr) delete wifiMenuWidget;
|
||||
}
|
||||
|
||||
|
||||
@ -608,12 +575,12 @@ QMap<QString, QString> MainWindow::parseOptions(const QString options)
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
for (int i=0; i<options.split(QChar(',')).count(); i++) {
|
||||
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2) continue;
|
||||
settings[options.split(QChar(','))[i].split(QChar('='))[0]] =
|
||||
options.split(QChar(','))[i].split(QChar('='))[1];
|
||||
QStringList option = options.split(QChar(','))[i].split(QChar('='));
|
||||
if (option.count() != 2) continue;
|
||||
settings[option[0]] = option[1];
|
||||
}
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
if (debug) qDebug() << PDEBUG << ":" << QString("%1=%2").arg(settings.keys()[i]).arg(settings[settings.keys()[i]]);
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
@ -20,31 +20,18 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QShortcut>
|
||||
#include <QTableWidgetItem>
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
class AboutWindow;
|
||||
class BridgeWidget;
|
||||
class ErrorWindow;
|
||||
class EthernetWidget;
|
||||
class GeneralWidget;
|
||||
class IpWidget;
|
||||
class MacvlanWidget;
|
||||
class MobileWidget;
|
||||
class MainWidget;
|
||||
class NetctlAutoWindow;
|
||||
class PasswdWidget;
|
||||
class PppoeWidget;
|
||||
class NewProfileWidget;
|
||||
class SettingsWindow;
|
||||
class TrayIcon;
|
||||
class TunnelWidget;
|
||||
class TuntapWidget;
|
||||
class VlanWidget;
|
||||
class WirelessWidget;
|
||||
class WiFiMenuWidget;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@ -55,16 +42,22 @@ class MainWindow : public QMainWindow
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0,
|
||||
const QMap<QString, QVariant> args = QMap<QString, QVariant>(),
|
||||
QTranslator *qtAppTranslator = 0,
|
||||
QTranslator *appTranslator = 0);
|
||||
explicit MainWindow(QWidget *parent = nullptr,
|
||||
const QVariantMap args = QVariantMap(),
|
||||
QTranslator *qtAppTranslator = nullptr,
|
||||
QTranslator *appTranslator = nullptr);
|
||||
~MainWindow();
|
||||
QStringList printInformation();
|
||||
int currentTab();
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
void emitNeedToBeConfigured();
|
||||
QStringList printSettings();
|
||||
QStringList printTrayInformation();
|
||||
netctlCurrent printTrayInformation();
|
||||
bool isHelperActive();
|
||||
bool isHelperServiceActive();
|
||||
// library interfaces
|
||||
Netctl *netctlCommand = nullptr;
|
||||
NetctlInterface *netctlInterface = nullptr;
|
||||
WpaSup *wpaCommand = nullptr;
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
@ -72,16 +65,11 @@ protected:
|
||||
public slots:
|
||||
// actions from trayicon
|
||||
void closeMainWindow();
|
||||
void openProfileSlot(const QString profile);
|
||||
void showAboutWindow();
|
||||
void showMainWindow();
|
||||
void showNetctlAutoWindow();
|
||||
void showSettingsWindow();
|
||||
// trayicon control slots
|
||||
bool enableProfileSlot(const QString profile);
|
||||
bool startProfileSlot(const QString profile);
|
||||
bool stopAllProfilesSlot();
|
||||
bool switchToProfileSlot(const QString profile);
|
||||
bool restartProfileSlot(const QString profile);
|
||||
// open docs
|
||||
void showApi();
|
||||
void showLibrary();
|
||||
@ -91,89 +79,38 @@ public slots:
|
||||
bool forceStopHelper();
|
||||
bool startHelper();
|
||||
// main
|
||||
void setDisabled(const bool disabled = true);
|
||||
void setTab(int tab);
|
||||
void updateConfiguration(const QMap<QString, QVariant> args = QMap<QString, QVariant>());
|
||||
void updateMenu();
|
||||
void updateTabs(const int tab);
|
||||
// wifi tab slots
|
||||
void connectToUnknownEssid(const QString passwd);
|
||||
void setHiddenName(const QString name);
|
||||
void showMessage(const bool status);
|
||||
void storeToolBars();
|
||||
void updateConfiguration(const QVariantMap args = QVariantMap());
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
|
||||
signals:
|
||||
void needToBeConfigured();
|
||||
|
||||
private slots:
|
||||
void setTabByAction(QAction *action);
|
||||
void reportABug();
|
||||
// menu update slots
|
||||
void setMenuActionsShown(const bool state = true);
|
||||
void updateMenuMain();
|
||||
void updateMenuProfile();
|
||||
void updateMenuWifi();
|
||||
void updateToolBars();
|
||||
// tab update slots
|
||||
void updateMainTab();
|
||||
void updateProfileTab();
|
||||
void updateWifiTab();
|
||||
// main tab slots
|
||||
void mainTabContextualMenu(const QPoint &pos);
|
||||
void mainTabEditProfile();
|
||||
void mainTabEnableProfile();
|
||||
QStringList mainTabGetActiveProfiles();
|
||||
void mainTabRemoveProfile();
|
||||
void mainTabRestartProfile();
|
||||
void mainTabStartProfile();
|
||||
void mainTabStopAllProfiles();
|
||||
void mainTabSwitchToProfile();
|
||||
// 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();
|
||||
|
||||
private:
|
||||
// ui
|
||||
TrayIcon *trayIcon = nullptr;
|
||||
QMap<QString, QShortcut *> appShortcuts;
|
||||
QMap<QString, QAction *> toolBarActions;
|
||||
QToolButton *actionMenu = nullptr;
|
||||
QToolBar *actionToolBar = nullptr;
|
||||
QToolBar *helpToolBar = nullptr;
|
||||
QToolBar *mainToolBar = nullptr;
|
||||
Ui::MainWindow *ui = nullptr;
|
||||
AboutWindow *aboutWin = nullptr;
|
||||
ErrorWindow *errorWin = nullptr;
|
||||
MainWidget *mainWidget = nullptr;
|
||||
NetctlAutoWindow *netctlAutoWin = nullptr;
|
||||
PasswdWidget *passwdWid = nullptr;
|
||||
NewProfileWidget *newProfileWidget = nullptr;
|
||||
SettingsWindow *settingsWin = nullptr;
|
||||
BridgeWidget *bridgeWid = nullptr;
|
||||
EthernetWidget *ethernetWid = nullptr;
|
||||
GeneralWidget *generalWid = nullptr;
|
||||
IpWidget *ipWid = nullptr;
|
||||
MacvlanWidget *macvlanWid = nullptr;
|
||||
MobileWidget *mobileWid = nullptr;
|
||||
PppoeWidget *pppoeWid = nullptr;
|
||||
TunnelWidget *tunnelWid = nullptr;
|
||||
TuntapWidget *tuntapWid = nullptr;
|
||||
VlanWidget *vlanWid = nullptr;
|
||||
WirelessWidget *wirelessWid = nullptr;
|
||||
WiFiMenuWidget *wifiMenuWidget = nullptr;
|
||||
// backend
|
||||
Netctl *netctlCommand = nullptr;
|
||||
NetctlProfile *netctlProfile = nullptr;
|
||||
WpaSup *wpaCommand = nullptr;
|
||||
bool checkExternalApps(const QString apps);
|
||||
bool checkHelperStatus();
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||
void createActions();
|
||||
void createDBusSession();
|
||||
void createObjects();
|
||||
void createToolBars();
|
||||
void deleteObjects();
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
QString configPath;
|
||||
bool debug = false;
|
||||
bool hiddenNetwork;
|
||||
bool useHelper = true;
|
||||
QTranslator *qtTranslator = nullptr;
|
||||
QTranslator *translator = nullptr;
|
||||
|
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>469</width>
|
||||
<width>600</width>
|
||||
<height>497</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -16,283 +16,189 @@
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="centralLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_menus">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_menu">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border: none;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Menu</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_action">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border: none;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Actions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_help">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border: none;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_main">
|
||||
<attribute name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
||||
</attribute>
|
||||
<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>
|
||||
<property name="columnCount">
|
||||
<number>4</number>
|
||||
</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/>
|
||||
<column/>
|
||||
</widget>
|
||||
</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="icon">
|
||||
<iconset theme="document-new">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</attribute>
|
||||
<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>437</width>
|
||||
<height>368</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>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_wifi">
|
||||
<attribute name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/wifi.png</normaloff>:/wifi.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>WiFi menu</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>
|
||||
<property name="columnCount">
|
||||
<number>5</number>
|
||||
</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>Signal</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Security</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column/>
|
||||
<column/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuMenu">
|
||||
<property name="title">
|
||||
<string>Menu</string>
|
||||
</property>
|
||||
<addaction name="actionSettings"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSecurity"/>
|
||||
<addaction name="actionDBus_API"/>
|
||||
<addaction name="actionLibrary"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionReport_a_bug"/>
|
||||
<addaction name="actionAbout"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<addaction name="menuMenu"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>Toolbar</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonFollowStyle</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionNetctl_auto"/>
|
||||
<addaction name="actionNetctl"/>
|
||||
<addaction name="actionProfiles"/>
|
||||
<addaction name="actionWiFi_menu"/>
|
||||
</widget>
|
||||
<action name="actionSecurity">
|
||||
<property name="icon">
|
||||
<iconset theme="security-medium">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Security</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show security notes</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDBus_API">
|
||||
<property name="text">
|
||||
<string>DBus API</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show DBus API</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLibrary">
|
||||
<property name="text">
|
||||
<string>Library</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Show library docs</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReport_a_bug">
|
||||
<property name="icon">
|
||||
<iconset theme="tools-report-bug">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Report a bug</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="icon">
|
||||
<iconset theme="help-about">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>About</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>About this application</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<property name="icon">
|
||||
<iconset theme="application-exit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<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="actionNetctl">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>netctl control</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>netctl control</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfiles">
|
||||
<property name="icon">
|
||||
<iconset theme="document-new">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Profiles</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Profiles</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+P</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionWiFi_menu">
|
||||
<property name="icon">
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/wifi.png</normaloff>:/wifi.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WiFi menu</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+W</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNetctl_auto">
|
||||
<property name="text">
|
||||
<string>netctl-auto</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>tableWidget_main</tabstop>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
<tabstop>tableWidget_wifi</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../resources/resources.qrc"/>
|
||||
</resources>
|
||||
|
@ -25,18 +25,16 @@
|
||||
|
||||
QString errorMessage()
|
||||
{
|
||||
QString errorMessage = QApplication::translate("MainWindow", "Unknown flag\n");
|
||||
|
||||
return errorMessage;
|
||||
return QApplication::translate("MainWindow", "Unknown flag\n");
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QVariant> getArgs()
|
||||
QVariantMap getArgs()
|
||||
{
|
||||
QMap<QString, QVariant> args;
|
||||
QVariantMap args;
|
||||
// windows
|
||||
args[QString("detached")] = false;
|
||||
args[QString("minimized")] = (int) 0;
|
||||
args[QString("minimized")] = static_cast<int>(0);
|
||||
args[QString("about")] = false;
|
||||
args[QString("auto")] = false;
|
||||
args[QString("settings")] = false;
|
||||
@ -45,11 +43,11 @@ QMap<QString, QVariant> getArgs()
|
||||
args[QString("open")] = QString("PROFILE");
|
||||
args[QString("select")] = QString("PROFILE");
|
||||
// additional functions
|
||||
args[QString("config")] = QString(QDir::homePath() + QString("/.config/netctl-gui.conf"));
|
||||
args[QString("config")] = QString("%1/.config/netctl-gui.conf").arg(QDir::homePath());
|
||||
args[QString("debug")] = false;
|
||||
args[QString("defaults")] = false;
|
||||
args[QString("options")] = QString("OPTIONS");
|
||||
args[QString("tab")] = (int) 1;
|
||||
args[QString("tab")] = static_cast<int>(1);
|
||||
// messages
|
||||
args[QString("error")] = false;
|
||||
args[QString("help")] = false;
|
||||
@ -68,46 +66,29 @@ QString helpMessage()
|
||||
helpMessage += QString("%1\n").arg(QApplication::translate("MainWindow", "Options:"));
|
||||
// windows
|
||||
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Open window:"));
|
||||
helpMessage += QString(" --detached - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "start detached from console"));
|
||||
helpMessage += QString(" --maximized - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "start maximized"));
|
||||
helpMessage += QString(" --minimized - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "start minimized to tray"));
|
||||
helpMessage += QString(" --about - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "show about window"));
|
||||
helpMessage += QString(" --netctl-auto - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "show netctl-auto window"));
|
||||
helpMessage += QString(" --settings - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "show settings window"));
|
||||
helpMessage += QString(" --detached - %1\n").arg(QApplication::translate("MainWindow", "start detached from console"));
|
||||
helpMessage += QString(" --maximized - %1\n").arg(QApplication::translate("MainWindow", "start maximized"));
|
||||
helpMessage += QString(" --minimized - %1\n").arg(QApplication::translate("MainWindow", "start minimized to tray"));
|
||||
helpMessage += QString(" --about - %1\n").arg(QApplication::translate("MainWindow", "show about window"));
|
||||
helpMessage += QString(" --netctl-auto - %1\n").arg(QApplication::translate("MainWindow", "show netctl-auto window"));
|
||||
helpMessage += QString(" --settings - %1\n").arg(QApplication::translate("MainWindow", "show settings window"));
|
||||
// main functions
|
||||
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Functions:"));
|
||||
helpMessage += QString(" -e, --essid <arg> - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "select this ESSID"));
|
||||
helpMessage += QString(" -o, --open <arg> - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "open this profile"));
|
||||
helpMessage += QString(" -s, --select <arg> - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "select this profile"));
|
||||
helpMessage += QString(" -e, --essid <arg> - %1\n").arg(QApplication::translate("MainWindow", "select this ESSID"));
|
||||
helpMessage += QString(" -o, --open <arg> - %1\n").arg(QApplication::translate("MainWindow", "open this profile"));
|
||||
helpMessage += QString(" -s, --select <arg> - %1\n").arg(QApplication::translate("MainWindow", "select this profile"));
|
||||
// additional functions
|
||||
helpMessage += QString(" %1\n").arg(QApplication::translate("MainWindow", "Additional flags:"));
|
||||
helpMessage += QString(" -c, --config <arg> - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "read configuration from this file"));
|
||||
helpMessage += QString(" -d, --debug - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "print debug information"));
|
||||
helpMessage += QString(" --default - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "start with default settings"));
|
||||
helpMessage += QString(" --set-opts <arg> - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
|
||||
helpMessage += QString(" -t, --tab <arg> - %1\n")
|
||||
.arg(QApplication::translate("MainWindow", "open a tab with this number"));
|
||||
helpMessage += QString(" -c, --config <arg> - %1\n").arg(QApplication::translate("MainWindow", "read configuration from this file"));
|
||||
helpMessage += QString(" -d, --debug - %1\n").arg(QApplication::translate("MainWindow", "print debug information"));
|
||||
helpMessage += QString(" --default - %1\n").arg(QApplication::translate("MainWindow", "start with default settings"));
|
||||
helpMessage += QString(" --set-opts <arg> - %1\n").arg(QApplication::translate("MainWindow", "set options for this run, comma separated"));
|
||||
helpMessage += QString(" -t, --tab <arg> - %1\n").arg(QApplication::translate("MainWindow", "open a tab with this number"));
|
||||
// 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"));
|
||||
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"));
|
||||
|
||||
return helpMessage;
|
||||
}
|
||||
@ -117,8 +98,7 @@ QString infoMessage()
|
||||
{
|
||||
QString infoMessage = QString("");
|
||||
// build information
|
||||
infoMessage += QApplication::translate("MainWindow", "Build date: %1").
|
||||
arg(QString(BUILD_DATE));
|
||||
infoMessage += QApplication::translate("MainWindow", "Build date: %1").arg(QString(BUILD_DATE));
|
||||
// cmake
|
||||
infoMessage += QString("\n%1:\n").arg(QApplication::translate("MainWindow", "cmake flags"));
|
||||
// cmake properties
|
||||
@ -141,6 +121,7 @@ QString infoMessage()
|
||||
infoMessage += QString("\t-DDBUS_SYSTEMCONF_PATH=%1\n").arg(QString(PROJECT_DBUS_SYSTEMCONF_PATH));
|
||||
infoMessage += QString("\t-DSYSTEMD_SERVICE_PATH=%1\n").arg(QString(PROJECT_SYSTEMD_SERVICE_PATH));
|
||||
infoMessage += QString("\t-DUSE_CAPABILITIES=%1\n").arg(QString(PROJECT_USE_CAPABILITIES));
|
||||
infoMessage += QString("\t-DUSE_KDE4=%1\n").arg(QString(PROJECT_USE_KDE4));
|
||||
infoMessage += QString("\t-DUSE_QT5=%1\n").arg(QString(PROJECT_USE_QT5));
|
||||
// transport information
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "DBus configuration"));
|
||||
@ -163,15 +144,9 @@ QString versionMessage()
|
||||
{
|
||||
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));
|
||||
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));
|
||||
|
||||
return versionMessage;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
QString errorMessage();
|
||||
QMap<QString, QVariant> getArgs();
|
||||
QVariantMap getArgs();
|
||||
QString helpMessage();
|
||||
QString infoMessage();
|
||||
QString versionMessage();
|
||||
|
@ -46,9 +46,11 @@ void MobileWidget::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_init->setText(QString("ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"));
|
||||
ui->spinBox_fail->setValue(5);
|
||||
ui->lineEdit_chat->clear();
|
||||
ui->lineEdit_options->clear();
|
||||
|
||||
ui->pushButton_mobileAdvanced->setChecked(false);;
|
||||
@ -56,26 +58,28 @@ void MobileWidget::clear()
|
||||
}
|
||||
|
||||
|
||||
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_chat, SIGNAL(clicked(bool)), this, SLOT(selectChatFile()));
|
||||
connect(ui->pushButton_options, SIGNAL(clicked(bool)), this, SLOT(selectOptionsFile()));
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::selectChatFile()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this,
|
||||
QApplication::translate("MobileWidget", "Select chat file"),
|
||||
QDir::currentPath(),
|
||||
QApplication::translate("MobileWidget", "All (*.*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_chat->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::selectOptionsFile()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QString filename = QFileDialog::getOpenFileName(this,
|
||||
QApplication::translate("MobileWidget", "Select options file"),
|
||||
QDir::currentPath(),
|
||||
QApplication::translate("MobileWidget", "Configuration files (*.conf)"));
|
||||
@ -88,53 +92,54 @@ void MobileWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_mobileAdvanced->isChecked()) {
|
||||
ui->widget_mobileAdvanced->setHidden(false);
|
||||
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
|
||||
ui->pushButton_mobileAdvanced->setArrowType(Qt::UpArrow);
|
||||
} else {
|
||||
ui->widget_mobileAdvanced->setHidden(true);
|
||||
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Show advanced"));
|
||||
ui->pushButton_mobileAdvanced->setArrowType(Qt::DownArrow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> MobileWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> mobileSettings;
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return mobileSettings;
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
if (!ui->lineEdit_username->text().isEmpty())
|
||||
mobileSettings[QString("User")] = QString("'") + ui->lineEdit_username->text() + QString("'");
|
||||
settings[QString("User")] = QString("'%1'").arg(ui->lineEdit_username->text());
|
||||
if (!ui->lineEdit_password->text().isEmpty())
|
||||
mobileSettings[QString("Password")] = QString("'") + ui->lineEdit_password->text() + QString("'");
|
||||
mobileSettings[QString("AccessPointName")] = ui->lineEdit_apn->text();
|
||||
settings[QString("Password")] = QString("'%1'").arg(ui->lineEdit_password->text());
|
||||
settings[QString("AccessPointName")] = ui->lineEdit_apn->text();
|
||||
if (!ui->lineEdit_pin->text().isEmpty())
|
||||
mobileSettings[QString("PIN")] = QString("'") + ui->lineEdit_pin->text() + QString("'");
|
||||
settings[QString("PIN")] = QString("'%1'").arg(ui->lineEdit_pin->text());
|
||||
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());
|
||||
settings[QString("PIN")] = QString("None");
|
||||
settings[QString("Mode")] = ui->comboBox_mode->currentText();
|
||||
if (ui->checkBox_route->checkState() == Qt::Unchecked)
|
||||
mobileSettings[QString("DefaultRoute")] = QString("false");
|
||||
settings[QString("DefaultRoute")] = QString("false");
|
||||
if (ui->checkBox_dns->checkState() == Qt::Unchecked)
|
||||
mobileSettings[QString("UsePeerDNS")] = QString("false");
|
||||
settings[QString("UsePeerDNS")] = QString("false");
|
||||
if (ui->lineEdit_init->text() != QString("ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"))
|
||||
settings[QString("Init")] = QString("'%1'").arg(ui->lineEdit_init->text());
|
||||
if (ui->spinBox_fail->value() != 5)
|
||||
settings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
|
||||
if (!ui->lineEdit_chat->text().isEmpty())
|
||||
settings[QString("ChatScript")] = QString("'%1'").arg(ui->lineEdit_chat->text());
|
||||
if (!ui->lineEdit_options->text().isEmpty())
|
||||
mobileSettings[QString("OptionsFile")] = QString("'") + ui->lineEdit_options->text() + QString("'");
|
||||
settings[QString("OptionsFile")] = QString("'%1'").arg(ui->lineEdit_options->text());
|
||||
|
||||
return mobileSettings;
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
int MobileWidget::isOk()
|
||||
{
|
||||
// APN is not set
|
||||
if (ui->lineEdit_apn->text().isEmpty())
|
||||
return 1;
|
||||
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;
|
||||
if (!QFile(ui->lineEdit_options->text()).exists()) return 2;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
@ -143,28 +148,31 @@ int MobileWidget::isOk()
|
||||
void MobileWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> mobileSettings = settings;
|
||||
|
||||
if (mobileSettings.contains(QString("User")))
|
||||
ui->lineEdit_username->setText(mobileSettings[QString("User")]);
|
||||
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"))
|
||||
if (settings.contains(QString("User")))
|
||||
ui->lineEdit_username->setText(settings[QString("User")]);
|
||||
if (settings.contains(QString("Password")))
|
||||
ui->lineEdit_password->setText(settings[QString("Password")]);
|
||||
if (settings.contains(QString("AccessPointName")))
|
||||
ui->lineEdit_apn->setText(settings[QString("AccessPointName")]);
|
||||
if (settings.contains(QString("PIN")))
|
||||
ui->lineEdit_pin->setText(settings[QString("PIN")]);
|
||||
if (settings.contains(QString("Mode"))) {
|
||||
int index = ui->comboBox_mode->findText(settings[QString("Mode")]);
|
||||
ui->comboBox_mode->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("DefaultRoute")))
|
||||
if (settings[QString("DefaultRoute")] == QString("false"))
|
||||
ui->checkBox_route->setCheckState(Qt::Unchecked);
|
||||
if (mobileSettings.contains(QString("UsePeerDNS")))
|
||||
if (mobileSettings[QString("UsePeerDNS")] == QString("false"))
|
||||
if (settings.contains(QString("UsePeerDNS")))
|
||||
if (settings[QString("UsePeerDNS")] == QString("false"))
|
||||
ui->checkBox_dns->setCheckState(Qt::Unchecked);
|
||||
if (mobileSettings.contains(QString("OptionsFile")))
|
||||
ui->lineEdit_options->setText(mobileSettings[QString("OptionsFile")]);
|
||||
if (settings.contains(QString("Init")))
|
||||
ui->lineEdit_init->setText(settings[QString("Init")]);
|
||||
if (settings.contains(QString("MaxFail")))
|
||||
ui->spinBox_fail->setValue(settings[QString("MaxFail")].toInt());
|
||||
if (settings.contains(QString("ChatScript")))
|
||||
ui->lineEdit_chat->setText(settings[QString("ChatScript")]);
|
||||
if (settings.contains(QString("OptionsFile")))
|
||||
ui->lineEdit_options->setText(settings[QString("OptionsFile")]);
|
||||
}
|
||||
|
@ -38,9 +38,9 @@ public:
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private slots:
|
||||
void selectChatFile();
|
||||
void selectOptionsFile();
|
||||
void showAdvanced();
|
||||
|
||||
|
@ -7,13 +7,13 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>445</width>
|
||||
<height>370</height>
|
||||
<height>376</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_mobile">
|
||||
<property name="features">
|
||||
@ -24,23 +24,35 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_mobile">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Username</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_username">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The username and password to connect with</string>
|
||||
</property>
|
||||
@ -52,19 +64,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The username and password to connect with</string>
|
||||
</property>
|
||||
@ -76,19 +97,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Access point name</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_apn">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The access point (apn) to connect on</string>
|
||||
</property>
|
||||
@ -100,19 +130,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PIN</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_pin">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>If your modem requires a PIN to unlock, use this option</string>
|
||||
</property>
|
||||
@ -124,19 +163,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>This option is used to specify the connection mode</string>
|
||||
</property>
|
||||
@ -172,26 +220,23 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mobileAdvanced">
|
||||
<item>
|
||||
<spacer name="spacer_mobileAdvanced">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mobileAdvanced">
|
||||
<property name="text">
|
||||
<string>Show advanced</string>
|
||||
</property>
|
||||
<widget class="QToolButton" name="pushButton_mobileAdvanced">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::DownArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -199,23 +244,134 @@
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_mobileAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_route">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_route">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_route">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_dns">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_dns">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_dns">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_init">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_init">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Init</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_init">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An initialization string sent to the modem before dialing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Max fail</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_fail">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The number of consecutive failed connection attempts to tolerate</string>
|
||||
</property>
|
||||
@ -230,48 +386,77 @@
|
||||
</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>
|
||||
<layout class="QHBoxLayout" name="layout_chat">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_chat">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Chat script</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_chat">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Path to a chat file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_chat">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>4</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Options file</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_options">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>A file to read additional pppd options from</string>
|
||||
</property>
|
||||
@ -279,6 +464,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_options">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>4</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
@ -301,10 +492,7 @@
|
||||
<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>
|
||||
|
@ -20,26 +20,29 @@
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "calls.h"
|
||||
#include "commonfunctions.h"
|
||||
#include "dbusoperation.h"
|
||||
#include "version.h"
|
||||
#include "errorwindow.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const bool debugCmd, const QMap<QString, QString> settings)
|
||||
NetctlAutoWindow::NetctlAutoWindow(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::NetctlAutoWindow),
|
||||
debug(debugCmd)
|
||||
debug(debugCmd),
|
||||
configuration(settings)
|
||||
{
|
||||
if (settings[QString("USE_HELPER")] == QString("true"))
|
||||
useHelper = true;
|
||||
else
|
||||
useHelper = false;
|
||||
mainWindow = dynamic_cast<MainWindow *>(parent);
|
||||
useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
|
||||
|
||||
// ui
|
||||
ui = new Ui::NetctlAutoWindow;
|
||||
ui->setupUi(this);
|
||||
ui->tableWidget->setColumnHidden(2, true);
|
||||
ui->tableWidget->setColumnHidden(3, true);
|
||||
netctlCommand = new Netctl(debug, settings);
|
||||
updateToolBarState(static_cast<Qt::ToolBarArea>(settings[QString("NETCTLAUTO_TOOLBAR")].toInt()));
|
||||
|
||||
createActions();
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Ready"));
|
||||
@ -51,22 +54,14 @@ NetctlAutoWindow::~NetctlAutoWindow()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
delete ui;
|
||||
delete netctlCommand;
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAutoWindow::checkStatus(const bool statusBool, const bool nullFalse)
|
||||
Qt::ToolBarArea NetctlAutoWindow::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Status" << statusBool;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Return null false" << nullFalse;
|
||||
|
||||
if (statusBool)
|
||||
return QApplication::translate("NetctlAutoWindow", "yes");
|
||||
if (nullFalse)
|
||||
return QString("");
|
||||
else
|
||||
return QApplication::translate("NetctlAutoWindow", "no");
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
@ -78,9 +73,9 @@ void NetctlAutoWindow::createActions()
|
||||
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->actionEnableAll, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableAllProfiles()));
|
||||
connect(ui->actionSwitch, SIGNAL(triggered(bool)), this, SLOT(netctlAutoStartProfile()));
|
||||
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(netctlAutoUpdateTable()));
|
||||
// service
|
||||
connect(ui->actionEnableService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoEnableService()));
|
||||
connect(ui->actionRestartService, SIGNAL(triggered(bool)), this, SLOT(netctlAutoRestartService()));
|
||||
@ -90,11 +85,17 @@ void NetctlAutoWindow::createActions()
|
||||
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::showMessage(const bool status)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
}
|
||||
|
||||
|
||||
@ -108,12 +109,24 @@ void NetctlAutoWindow::showWindow()
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui->tableWidget->currentItem() == 0)
|
||||
return;
|
||||
if (ui->tableWidget->currentItem() == nullptr) return;
|
||||
// create menu
|
||||
QMenu menu(this);
|
||||
QAction *startProfile = menu.addAction(QApplication::translate("NetctlAutoWindow", "Switch to profile"));
|
||||
@ -121,24 +134,18 @@ void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
|
||||
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"));
|
||||
enableAllProfiles->setIcon(QIcon::fromTheme("list-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().isEmpty()) {
|
||||
enableProfile->setVisible(false);
|
||||
startProfile->setVisible(false);
|
||||
startProfile->setVisible(ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 2)->text().isEmpty());
|
||||
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
|
||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("list-add"));
|
||||
} else {
|
||||
enableProfile->setVisible(true);
|
||||
startProfile->setVisible(true);
|
||||
if (!ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 3)->text().isEmpty()) {
|
||||
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"));
|
||||
}
|
||||
enableProfile->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||
enableProfile->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
}
|
||||
|
||||
// actions
|
||||
@ -162,88 +169,74 @@ void NetctlAutoWindow::netctlAutoContextualMenu(const QPoint &pos)
|
||||
void NetctlAutoWindow::netctlAutoUpdateTable()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
netctlInformation info = generalInformation(mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
|
||||
// actions
|
||||
bool enabled = false;
|
||||
bool running = false;
|
||||
if (useHelper) {
|
||||
enabled = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoEnabled"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
running = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("isNetctlAutoActive"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
} else {
|
||||
enabled = netctlCommand->isNetctlAutoEnabled();
|
||||
running = netctlCommand->isNetctlAutoRunning();
|
||||
}
|
||||
if (enabled)
|
||||
ui->actionDisableAll->setEnabled(info.netctlAuto);
|
||||
ui->actionEnableAll->setEnabled(info.netctlAuto);
|
||||
ui->actionRestartService->setEnabled(info.netctlAuto);
|
||||
if (info.netctlAutoEnabled)
|
||||
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Disable service"));
|
||||
else
|
||||
ui->actionEnableService->setText(QApplication::translate("NetctlAutoWindow", "Enable service"));
|
||||
ui->actionEnableService->setVisible(true);
|
||||
if (running) {
|
||||
if (info.netctlAuto) {
|
||||
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is running"));
|
||||
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Stop service"));
|
||||
ui->actionDisableAll->setVisible(true);
|
||||
ui->actionEnableAll->setVisible(true);
|
||||
ui->actionRestartService->setVisible(true);
|
||||
} else {
|
||||
ui->label_info->setText(QApplication::translate("NetctlAutoWindow", "netctl-auto is not running"));
|
||||
ui->actionStartService->setText(QApplication::translate("NetctlAutoWindow", "Start service"));
|
||||
ui->actionDisableAll->setVisible(false);
|
||||
ui->actionEnableAll->setVisible(false);
|
||||
ui->actionRestartService->setVisible(false);
|
||||
netctlAutoRefreshButtons(0, 0);
|
||||
netctlAutoRefreshButtons(nullptr, nullptr);
|
||||
return;
|
||||
}
|
||||
QList<netctlProfileInfo> profiles;
|
||||
if (useHelper)
|
||||
profiles = parseOutputNetctl(sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_LIB_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("ProfileList"),
|
||||
QList<QVariant>(), true, debug), debug);
|
||||
else
|
||||
profiles = netctlCommand->getProfileListFromNetctlAuto();
|
||||
|
||||
ui->tableWidget->setSortingEnabled(false);
|
||||
ui->tableWidget->selectRow(-1);
|
||||
ui->tableWidget->sortByColumn(0, Qt::AscendingOrder);
|
||||
ui->tableWidget->clear();
|
||||
ui->tableWidget->setRowCount(profiles.count());
|
||||
ui->tableWidget->setRowCount(info.netctlAutoProfiles.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"));
|
||||
headerList.append(QApplication::translate("NetctlAutoWindow", "Enabled"));
|
||||
ui->tableWidget->setHorizontalHeaderLabels(headerList);
|
||||
// create items
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
for (int i=0; i<info.netctlAutoProfiles.count(); i++) {
|
||||
// font
|
||||
QFont font;
|
||||
font.setBold(profiles[i].active);
|
||||
font.setItalic(profiles[i].enabled);
|
||||
font.setBold(info.netctlAutoProfiles[i].active);
|
||||
font.setItalic(info.netctlAutoProfiles[i].enabled);
|
||||
// tooltip
|
||||
QString toolTip = QString("");
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Profile")).arg(profiles[i].name);
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Active")).arg(checkStatus(profiles[i].active));
|
||||
toolTip += QString("%1: %2").arg(QApplication::translate("NetctlAutoWindow", "Disabled")).arg(checkStatus(!profiles[i].enabled));
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Profile"))
|
||||
.arg(info.netctlAutoProfiles[i].name);
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("NetctlAutoWindow", "Active"))
|
||||
.arg(checkStatus(info.netctlAutoProfiles[i].active));
|
||||
toolTip += QString("%1: %2").arg(QApplication::translate("NetctlAutoWindow", "Disabled"))
|
||||
.arg(checkStatus(!info.netctlAutoProfiles[i].enabled));
|
||||
// name
|
||||
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(profiles[i].name));
|
||||
ui->tableWidget->setItem(i, 0, new QTableWidgetItem(info.netctlAutoProfiles[i].name));
|
||||
ui->tableWidget->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(i, 0)->setToolTip(toolTip);
|
||||
ui->tableWidget->item(i, 0)->setFont(font);
|
||||
// description
|
||||
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(profiles[i].description));
|
||||
ui->tableWidget->setItem(i, 1, new QTableWidgetItem(info.netctlAutoProfiles[i].description));
|
||||
ui->tableWidget->item(i, 1)->setTextAlignment(Qt::AlignJustify | Qt::AlignVCenter);
|
||||
ui->tableWidget->item(i, 1)->setToolTip(toolTip);
|
||||
// active
|
||||
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(checkStatus(profiles[i].active, true)));
|
||||
ui->tableWidget->setItem(i, 2, new QTableWidgetItem(checkStatus(info.netctlAutoProfiles[i].active, true)));
|
||||
ui->tableWidget->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
// enabled
|
||||
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(checkStatus(!profiles[i].enabled, true)));
|
||||
ui->tableWidget->setItem(i, 3, new QTableWidgetItem(checkStatus(info.netctlAutoProfiles[i].enabled, true)));
|
||||
ui->tableWidget->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
@ -258,10 +251,11 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
||||
ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
#endif
|
||||
|
||||
ui->tableWidget->setEnabled(true);
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Updated"));
|
||||
ui->tableWidget->setCurrentCell(-1, -1);
|
||||
ui->tableWidget->setDisabled(false);
|
||||
showMessage(true);
|
||||
|
||||
netctlAutoRefreshButtons(0, 0);
|
||||
netctlAutoRefreshButtons(nullptr, nullptr);
|
||||
update();
|
||||
}
|
||||
|
||||
@ -269,19 +263,21 @@ void NetctlAutoWindow::netctlAutoUpdateTable()
|
||||
void NetctlAutoWindow::netctlAutoDisableAllProfiles()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoDisableAll"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoDisableAllProfiles();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoDisableAllProfiles();
|
||||
else try {
|
||||
responce = sendRequestToCtrl(QString("autoDisableAll"), debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
@ -290,24 +286,25 @@ void NetctlAutoWindow::netctlAutoDisableAllProfiles()
|
||||
void NetctlAutoWindow::netctlAutoEnableProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget->currentItem() == nullptr) return;
|
||||
|
||||
if (ui->tableWidget->currentItem() == 0)
|
||||
return;
|
||||
ui->tableWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||
bool status = false;
|
||||
if (useHelper) {
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoEnableProfile(profile);
|
||||
else try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoEnable"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoEnableProfile(profile);
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
responce = sendRequestToCtrlWithArgs(QString("autoEnable"), args, debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
@ -316,19 +313,21 @@ void NetctlAutoWindow::netctlAutoEnableProfile()
|
||||
void NetctlAutoWindow::netctlAutoEnableAllProfiles()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
ui->tableWidget->setDisabled(true);
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoEnableAll"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoEnableAllProfiles();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoEnableAllProfiles();
|
||||
else try {
|
||||
responce = sendRequestToCtrl(QString("autoEnableAll"), debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
@ -337,24 +336,25 @@ void NetctlAutoWindow::netctlAutoEnableAllProfiles()
|
||||
void NetctlAutoWindow::netctlAutoStartProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget->currentItem() == nullptr) return;
|
||||
|
||||
if (ui->tableWidget->currentItem() == 0)
|
||||
return;
|
||||
ui->tableWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget->item(ui->tableWidget->currentItem()->row(), 0)->text();
|
||||
bool status = false;
|
||||
if (useHelper) {
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoStartProfile(profile);
|
||||
else try {
|
||||
QList<QVariant> args;
|
||||
args.append(profile);
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoStart"),
|
||||
args, true, debug)[0].toBool();
|
||||
} else
|
||||
status = netctlCommand->autoStartProfile(profile);
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
responce = sendRequestToCtrlWithArgs(QString("autoStart"), args, debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
@ -363,18 +363,20 @@ void NetctlAutoWindow::netctlAutoStartProfile()
|
||||
void NetctlAutoWindow::netctlAutoEnableService()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoServiceEnable"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoEnableService();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoEnableService();
|
||||
else try {
|
||||
responce = sendRequestToCtrl(QString("autoServiceEnable"), debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
@ -383,18 +385,20 @@ void NetctlAutoWindow::netctlAutoEnableService()
|
||||
void NetctlAutoWindow::netctlAutoRestartService()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("systemctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("systemctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoServiceRestart"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoRestartService();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoRestartService();
|
||||
else try {
|
||||
responce = sendRequestToCtrl(QString("autoServiceRestart"), debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
@ -403,18 +407,20 @@ void NetctlAutoWindow::netctlAutoRestartService()
|
||||
void NetctlAutoWindow::netctlAutoStartService()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("systemctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("systemctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
bool status = false;
|
||||
if (useHelper)
|
||||
status = sendDBusRequest(DBUS_HELPER_SERVICE, DBUS_CTRL_PATH,
|
||||
DBUS_HELPER_INTERFACE, QString("autoServiceStart"),
|
||||
QList<QVariant>(), true, debug)[0].toBool();
|
||||
else
|
||||
status = netctlCommand->autoStartService();
|
||||
if (status)
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("NetctlAutoWindow", "Error"));
|
||||
bool responce = false;
|
||||
if (!useHelper)
|
||||
responce = mainWindow->netctlCommand->autoStartService();
|
||||
else try {
|
||||
responce = sendRequestToCtrl(QString("autoServiceStart"), debug)[0].toBool();
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
}
|
||||
showMessage(responce);
|
||||
|
||||
netctlAutoUpdateTable();
|
||||
}
|
||||
@ -425,43 +431,14 @@ void NetctlAutoWindow::netctlAutoRefreshButtons(QTableWidgetItem *current, QTabl
|
||||
Q_UNUSED(previous);
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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().isEmpty()) {
|
||||
// buttons
|
||||
ui->pushButton_enable->setDisabled(true);
|
||||
ui->pushButton_switch->setDisabled(true);
|
||||
// menu
|
||||
ui->actionEnable->setVisible(false);
|
||||
ui->actionSwitch->setVisible(false);
|
||||
bool selected = (current != nullptr);
|
||||
ui->actionEnable->setEnabled(selected);
|
||||
ui->actionSwitch->setEnabled(selected && ui->tableWidget->item(current->row(), 2)->text().isEmpty());
|
||||
if (selected && !ui->tableWidget->item(current->row(), 3)->text().isEmpty()) {
|
||||
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Disable"));
|
||||
ui->actionEnable->setIcon(QIcon::fromTheme("edit-delete"));
|
||||
} 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().isEmpty()) {
|
||||
// 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"));
|
||||
}
|
||||
ui->actionEnable->setText(QApplication::translate("NetctlAutoWindow", "Enable"));
|
||||
ui->actionEnable->setIcon(QIcon::fromTheme("list-add"));
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,11 @@
|
||||
#ifndef NETCTLAUTOWINDOW_H
|
||||
#define NETCTLAUTOWINDOW_H
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QMainWindow>
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
|
||||
class Netctl;
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class NetctlAutoWindow;
|
||||
@ -35,12 +34,15 @@ class NetctlAutoWindow : public QMainWindow
|
||||
|
||||
public:
|
||||
explicit NetctlAutoWindow(QWidget *parent = 0,
|
||||
const bool debugCmd = false,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>(),
|
||||
const bool debugCmd = false);
|
||||
~NetctlAutoWindow();
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
|
||||
public slots:
|
||||
void showMessage(const bool status);
|
||||
void showWindow();
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
|
||||
private slots:
|
||||
// table
|
||||
@ -58,12 +60,14 @@ private slots:
|
||||
void netctlAutoStartService();
|
||||
|
||||
private:
|
||||
Netctl *netctlCommand = nullptr;
|
||||
// ui
|
||||
Ui::NetctlAutoWindow *ui = nullptr;
|
||||
MainWindow *mainWindow = nullptr;
|
||||
// backend
|
||||
void createActions();
|
||||
bool debug = false;
|
||||
bool useHelper = true;
|
||||
QString checkStatus(const bool statusBool, const bool nullFalse = false);
|
||||
void createActions();
|
||||
QMap<QString, QString> configuration;
|
||||
};
|
||||
|
||||
|
||||
|
@ -14,12 +14,9 @@
|
||||
<string>netctl-auto</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="centralLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_info">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
@ -65,65 +62,27 @@
|
||||
<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>
|
||||
<property name="icon">
|
||||
<iconset theme="edit-add"/>
|
||||
</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="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>Toolbar</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonFollowStyle</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSwitch"/>
|
||||
<addaction name="actionEnable"/>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
@ -137,11 +96,6 @@
|
||||
<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"/>
|
||||
@ -153,27 +107,6 @@
|
||||
</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="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Switch to profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClose">
|
||||
<property name="icon">
|
||||
<iconset theme="exit">
|
||||
@ -189,7 +122,7 @@
|
||||
</action>
|
||||
<action name="actionEnableAll">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-add">
|
||||
<iconset theme="list-add">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
@ -211,6 +144,9 @@
|
||||
<property name="text">
|
||||
<string>Start service</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Start or stop service</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRestartService">
|
||||
<property name="text">
|
||||
@ -221,16 +157,51 @@
|
||||
<property name="text">
|
||||
<string>Enable service</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enable or disable service</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRefresh">
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<iconset theme="view-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Refresh table</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEnable">
|
||||
<property name="icon">
|
||||
<iconset theme="list-add">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enable or disable profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSwitch">
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Switch</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Switch to profile</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@ -54,12 +54,6 @@ bool NetctlGuiAdaptor::Close()
|
||||
}
|
||||
|
||||
|
||||
QStringList NetctlGuiAdaptor::Information()
|
||||
{
|
||||
return mainWindow->printInformation();
|
||||
}
|
||||
|
||||
|
||||
void NetctlGuiAdaptor::LibraryDocs()
|
||||
{
|
||||
return mainWindow->showLibrary();
|
||||
@ -70,8 +64,7 @@ QString NetctlGuiAdaptor::Pony()
|
||||
{
|
||||
QString pony;
|
||||
QFile ponyFile(QString(":pinkiepie"));
|
||||
if (!ponyFile.open(QIODevice::ReadOnly))
|
||||
return pony;
|
||||
if (!ponyFile.open(QIODevice::ReadOnly)) return pony;
|
||||
pony = QTextCodec::codecForMib(106)->toUnicode(ponyFile.readAll());
|
||||
ponyFile.close();
|
||||
|
||||
@ -134,9 +127,3 @@ QStringList NetctlGuiAdaptor::UIDs()
|
||||
|
||||
return uids;
|
||||
}
|
||||
|
||||
|
||||
QStringList NetctlGuiAdaptor::VerboseInformation()
|
||||
{
|
||||
return mainWindow->printTrayInformation();
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ public slots:
|
||||
bool Active();
|
||||
void ApiDocs();
|
||||
bool Close();
|
||||
QStringList Information();
|
||||
void LibraryDocs();
|
||||
QString Pony();
|
||||
bool Restore();
|
||||
@ -48,7 +47,6 @@ public slots:
|
||||
bool ShowNetctlAuto();
|
||||
bool ShowSettings();
|
||||
QStringList UIDs();
|
||||
QStringList VerboseInformation();
|
||||
|
||||
private:
|
||||
MainWindow *mainWindow;
|
||||
|
494
sources/gui/src/newprofilewidget.cpp
Normal file
494
sources/gui/src/newprofilewidget.cpp
Normal file
@ -0,0 +1,494 @@
|
||||
/***************************************************************************
|
||||
* 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 "newprofilewidget.h"
|
||||
#include "ui_newprofilewidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "bondwidget.h"
|
||||
#include "bridgewidget.h"
|
||||
#include "calls.h"
|
||||
#include "commonfunctions.h"
|
||||
#include "dbusoperation.h"
|
||||
#include "errorwindow.h"
|
||||
#include "ethernetwidget.h"
|
||||
#include "generalwidget.h"
|
||||
#include "ipwidget.h"
|
||||
#include "mainwindow.h"
|
||||
#include "macvlanwidget.h"
|
||||
#include "mobilewidget.h"
|
||||
#include "pppoewidget.h"
|
||||
#include "tunnelwidget.h"
|
||||
#include "tuntapwidget.h"
|
||||
#include "vlanwidget.h"
|
||||
#include "wirelesswidget.h"
|
||||
|
||||
|
||||
NewProfileWidget::NewProfileWidget(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd)
|
||||
: QMainWindow(parent),
|
||||
debug(debugCmd),
|
||||
configuration(settings)
|
||||
{
|
||||
mainWindow = dynamic_cast<MainWindow *>(parent);
|
||||
useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
|
||||
|
||||
// windows
|
||||
ui = new Ui::NewProfileWidget;
|
||||
ui->setupUi(this);
|
||||
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("PROFILE_TOOLBAR")].toInt()));
|
||||
// profile widgets
|
||||
generalWid = new GeneralWidget(this, configuration);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(generalWid);
|
||||
ipWid = new IpWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(ipWid);
|
||||
bondWid = new BondWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(bondWid);
|
||||
bridgeWid = new BridgeWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid);
|
||||
ethernetWid = new EthernetWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid);
|
||||
macvlanWid = new MacvlanWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(macvlanWid);
|
||||
mobileWid = new MobileWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
|
||||
pppoeWid = new PppoeWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);
|
||||
tunnelWid = new TunnelWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(tunnelWid);
|
||||
tuntapWid = new TuntapWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(tuntapWid);
|
||||
vlanWid = new VlanWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
|
||||
wirelessWid = new WirelessWidget(this, configuration);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
|
||||
|
||||
createActions();
|
||||
}
|
||||
|
||||
|
||||
NewProfileWidget::~NewProfileWidget()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (bondWid != nullptr) delete bondWid;
|
||||
if (bridgeWid != nullptr) delete bridgeWid;
|
||||
if (ethernetWid != nullptr) delete ethernetWid;
|
||||
if (generalWid != nullptr) delete generalWid;
|
||||
if (ipWid != nullptr) delete ipWid;
|
||||
if (macvlanWid != nullptr) delete macvlanWid;
|
||||
if (mobileWid != nullptr) delete mobileWid;
|
||||
if (pppoeWid != nullptr) delete pppoeWid;
|
||||
if (tunnelWid != nullptr) delete tunnelWid;
|
||||
if (tuntapWid != nullptr) delete tuntapWid;
|
||||
if (vlanWid != nullptr) delete vlanWid;
|
||||
if (wirelessWid != nullptr) delete wirelessWid;
|
||||
|
||||
if (ui != nullptr) delete ui;
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea NewProfileWidget::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::profileTabOpenProfileSlot(const QString profile)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->comboBox_profile->addItem(profile);
|
||||
ui->comboBox_profile->setCurrentIndex(ui->comboBox_profile->count() - 1);
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::update()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
updateProfileTab();
|
||||
updateMenuProfile();
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::updateMenuProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
bool selected = !ui->comboBox_profile->currentText().isEmpty();
|
||||
ui->actionLoad->setEnabled(selected);
|
||||
ui->actionRemove->setEnabled(selected);
|
||||
ui->actionSave->setEnabled(selected);
|
||||
ui->actionEditor->setEnabled(selected);
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::updateProfileTab()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
ui->comboBox_profile->clear();
|
||||
QList<netctlProfileInfo> profiles = generalInformation(mainWindow->netctlInterface,
|
||||
useHelper, debug).netctlProfiles;
|
||||
for (int i=0; i<profiles.count(); i++)
|
||||
ui->comboBox_profile->addItem(profiles[i].name);
|
||||
ui->comboBox_profile->setCurrentIndex(-1);
|
||||
|
||||
generalWid->clear();
|
||||
ipWid->clear();
|
||||
bondWid->clear();
|
||||
bridgeWid->clear();
|
||||
ethernetWid->clear();
|
||||
macvlanWid->clear();
|
||||
mobileWid->clear();
|
||||
pppoeWid->clear();
|
||||
tunnelWid->clear();
|
||||
tuntapWid->clear();
|
||||
vlanWid->clear();
|
||||
wirelessWid->clear();
|
||||
|
||||
profileTabChangeState(generalWid->connectionType->currentText());
|
||||
mainWindow->setDisabled(false);
|
||||
mainWindow->showMessage(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::profileTabChangeState(const QString current)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Current type" << current;
|
||||
|
||||
generalWid->setVisible(true);
|
||||
ipWid->setVisible((current != QString("pppoe")) && (current != QString("mobile_ppp")));
|
||||
bondWid->setVisible(current == QString("bond"));
|
||||
bridgeWid->setVisible(current == QString("bridge"));
|
||||
ethernetWid->setVisible((current == QString("ethernet")) ||
|
||||
(current == QString("vlan")) ||
|
||||
(current == QString("macvlan")));
|
||||
macvlanWid->setVisible(current == QString("macvlan"));
|
||||
mobileWid->setVisible(current == QString("mobile_ppp"));
|
||||
pppoeWid->setVisible(current == QString("pppoe"));
|
||||
tunnelWid->setVisible(current == QString("tunnel"));
|
||||
tuntapWid->setVisible(current == QString("tuntap"));
|
||||
vlanWid->setVisible(current == QString("vlan"));
|
||||
wirelessWid->setVisible(current == QString("wireless"));
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::profileTabCreateProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("sudo"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("sudo"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
// error checking
|
||||
if (ui->comboBox_profile->currentText().isEmpty())
|
||||
return ErrorWindow::showWindow(3, QString(PDEBUG), debug);
|
||||
if (generalWid->isOk() == 1)
|
||||
return ErrorWindow::showWindow(4, QString(PDEBUG), debug);
|
||||
else if (generalWid->isOk() == 2)
|
||||
return ErrorWindow::showWindow(5, QString(PDEBUG), debug);
|
||||
if ((generalWid->connectionType->currentText() == QString("ethernet")) ||
|
||||
(generalWid->connectionType->currentText() == QString("wireless")) ||
|
||||
(generalWid->connectionType->currentText() == QString("bond")) ||
|
||||
(generalWid->connectionType->currentText() == QString("dummy")) ||
|
||||
(generalWid->connectionType->currentText() == QString("bridge")) ||
|
||||
(generalWid->connectionType->currentText() == QString("tunnel")) ||
|
||||
(generalWid->connectionType->currentText() == QString("tuntap")) ||
|
||||
(generalWid->connectionType->currentText() == QString("vlan")) ||
|
||||
(generalWid->connectionType->currentText() == QString("macvlan")) ||
|
||||
(generalWid->connectionType->currentText() == QString("openvswitch"))) {
|
||||
if (ipWid->isOk() == 1)
|
||||
return ErrorWindow::showWindow(6, QString(PDEBUG), debug);
|
||||
else if (ipWid->isOk() == 2)
|
||||
return ErrorWindow::showWindow(6, QString(PDEBUG), debug);
|
||||
}
|
||||
if (generalWid->connectionType->currentText() == QString("ethernet")) {
|
||||
if (ethernetWid->isOk() == 1)
|
||||
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
|
||||
} else if (generalWid->connectionType->currentText() == QString("wireless")) {
|
||||
if (wirelessWid->isOk() == 1)
|
||||
return ErrorWindow::showWindow(8, QString(PDEBUG), debug);
|
||||
else if (wirelessWid->isOk() == 2)
|
||||
return ErrorWindow::showWindow(9, QString(PDEBUG), debug);
|
||||
else if (wirelessWid->isOk() == 3)
|
||||
return ErrorWindow::showWindow(10, QString(PDEBUG), debug);
|
||||
else if (wirelessWid->isOk() == 4)
|
||||
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
|
||||
else if (wirelessWid->isOk() == 5)
|
||||
return ErrorWindow::showWindow(11, QString(PDEBUG), debug);
|
||||
} else if (generalWid->connectionType->currentText() == QString("bond")) {
|
||||
} else if (generalWid->connectionType->currentText() == QString("bridge")) {
|
||||
} else if (generalWid->connectionType->currentText() == QString("pppoe")) {
|
||||
if (pppoeWid->isOk() == 1)
|
||||
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
|
||||
else if (pppoeWid->isOk() == 2)
|
||||
return ErrorWindow::showWindow(12, QString(PDEBUG), debug);
|
||||
else if (pppoeWid->isOk() == 3)
|
||||
return ErrorWindow::showWindow(13, QString(PDEBUG), debug);
|
||||
else if (pppoeWid->isOk() == 4)
|
||||
return ErrorWindow::showWindow(12, QString(PDEBUG), debug);
|
||||
} else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
|
||||
if (mobileWid->isOk() == 1)
|
||||
return ErrorWindow::showWindow(15, QString(PDEBUG), debug);
|
||||
if (mobileWid->isOk() == 2)
|
||||
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("tunnel")) {
|
||||
if (tunnelWid->isOk() == 1)
|
||||
return ErrorWindow::showWindow(20, QString(PDEBUG), debug);
|
||||
else if (tunnelWid->isOk() == 2)
|
||||
return ErrorWindow::showWindow(21, QString(PDEBUG), debug);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("tuntap")) {
|
||||
if (tuntapWid->isOk() == 1)
|
||||
return ErrorWindow::showWindow(15, QString(PDEBUG), debug);
|
||||
else if (tuntapWid->isOk() == 2)
|
||||
return ErrorWindow::showWindow(15, QString(PDEBUG), debug);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("vlan")) {
|
||||
if (ethernetWid->isOk() == 1)
|
||||
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("macvlan")) {
|
||||
if (ethernetWid->isOk() == 1)
|
||||
return ErrorWindow::showWindow(7, QString(PDEBUG), debug);
|
||||
}
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
// read settings
|
||||
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
|
||||
QMap<QString, QString> settings;
|
||||
settings = generalWid->getSettings();
|
||||
if (generalWid->connectionType->currentText() == QString("ethernet")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = ethernetWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if (generalWid->connectionType->currentText() == QString("wireless")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = wirelessWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if ((generalWid->connectionType->currentText() == QString("dummy")) ||
|
||||
(generalWid->connectionType->currentText() == QString("openvswitch"))) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if (generalWid->connectionType->currentText() == QString("bond")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = bondWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if (generalWid->connectionType->currentText() == QString("bridge")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = bridgeWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if (generalWid->connectionType->currentText() == QString("pppoe")) {
|
||||
QMap<QString, QString> addSettings = pppoeWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
|
||||
QMap<QString, QString> addSettings = mobileWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if (generalWid->connectionType->currentText() == QString("tunnel")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = tunnelWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if (generalWid->connectionType->currentText() == QString("tuntap")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = tuntapWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if (generalWid->connectionType->currentText() == QString("vlan")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = ethernetWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = vlanWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
} else if (generalWid->connectionType->currentText() == QString("macvlan")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = ethernetWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = macvlanWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
}
|
||||
|
||||
// call netctlprofile
|
||||
InterfaceAnswer answer = createProfileSlot(profile, settings, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
|
||||
updateProfileTab();
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::profileTabLoadProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
|
||||
if (profile.isEmpty()) return;
|
||||
QMap<QString, QString> settings = profileInformation(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
|
||||
if (settings.isEmpty()) return ErrorWindow::showWindow(17, QString(PDEBUG), debug);
|
||||
|
||||
generalWid->setSettings(settings);
|
||||
if (generalWid->connectionType->currentText() == QString("ethernet")) {
|
||||
ipWid->setSettings(settings);
|
||||
ethernetWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("wireless")) {
|
||||
ipWid->setSettings(settings);
|
||||
wirelessWid->setSettings(settings);
|
||||
} else if ((generalWid->connectionType->currentText() == QString("dummy")) ||
|
||||
(generalWid->connectionType->currentText() == QString("openvswitch"))) {
|
||||
ipWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("bridge")) {
|
||||
ipWid->setSettings(settings);
|
||||
bridgeWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("bond")) {
|
||||
ipWid->setSettings(settings);
|
||||
bondWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("pppoe")) {
|
||||
pppoeWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
|
||||
mobileWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("tunnel")) {
|
||||
ipWid->setSettings(settings);
|
||||
tunnelWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("tuntap")) {
|
||||
ipWid->setSettings(settings);
|
||||
tuntapWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("vlan")) {
|
||||
ipWid->setSettings(settings);
|
||||
ethernetWid->setSettings(settings);
|
||||
vlanWid->setSettings(settings);
|
||||
} else if (generalWid->connectionType->currentText() == QString("macvlan")) {
|
||||
ipWid->setSettings(settings);
|
||||
ethernetWid->setSettings(settings);
|
||||
macvlanWid->setSettings(settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::profileTabOpenInEditor()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("editor"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("editor"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
QString directory = QDir(configuration[QString("PROFILE_DIR")]).absolutePath();
|
||||
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
|
||||
profile = QString("%1/%2").arg(directory).arg(profile);
|
||||
QString cmd = QString("%1 %2 %3").arg(configuration[QString("SUDO_PATH")])
|
||||
.arg(configuration[QString("EDITOR_PATH")])
|
||||
.arg(profile);
|
||||
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, false);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
mainWindow->showMessage(process.exitCode == 0);
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::profileTabRemoveProfile()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("sudo"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("sudo"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QString profile = QFileInfo(ui->comboBox_profile->currentText()).fileName();
|
||||
InterfaceAnswer answer = removeProfileSlot(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
|
||||
updateProfileTab();
|
||||
}
|
||||
|
||||
|
||||
void NewProfileWidget::createActions()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// menu actions
|
||||
connect(ui->actionClear, SIGNAL(triggered(bool)), this, SLOT(updateProfileTab()));
|
||||
connect(ui->actionEditor, SIGNAL(triggered(bool)), this, SLOT(profileTabOpenInEditor()));
|
||||
connect(ui->actionLoad, SIGNAL(triggered(bool)), this, SLOT(profileTabLoadProfile()));
|
||||
connect(ui->actionRemove, SIGNAL(triggered(bool)), this, SLOT(profileTabRemoveProfile()));
|
||||
connect(ui->actionSave, SIGNAL(triggered(bool)), this, SLOT(profileTabCreateProfile()));
|
||||
// main tab events
|
||||
connect(ui->comboBox_profile, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabLoadProfile()));
|
||||
connect(ui->comboBox_profile, SIGNAL(editTextChanged(QString)), this, SLOT(updateMenuProfile()));
|
||||
connect(ui->comboBox_profile->lineEdit(), SIGNAL(returnPressed()), this, SLOT(profileTabLoadProfile()));
|
||||
connect(generalWid->connectionType, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabChangeState(QString)));
|
||||
}
|
96
sources/gui/src/newprofilewidget.h
Normal file
96
sources/gui/src/newprofilewidget.h
Normal file
@ -0,0 +1,96 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-gui *
|
||||
* *
|
||||
* netctl-gui is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-gui is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef NEWPROFILEWIDGET_H
|
||||
#define NEWPROFILEWIDGET_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <netctlgui/netctlgui.h>
|
||||
|
||||
|
||||
class BondWidget;
|
||||
class BridgeWidget;
|
||||
class EthernetWidget;
|
||||
class GeneralWidget;
|
||||
class IpWidget;
|
||||
class MainWindow;
|
||||
class MacvlanWidget;
|
||||
class MobileWidget;
|
||||
class PppoeWidget;
|
||||
class TunnelWidget;
|
||||
class TuntapWidget;
|
||||
class VlanWidget;
|
||||
class WirelessWidget;
|
||||
|
||||
namespace Ui {
|
||||
class NewProfileWidget;
|
||||
}
|
||||
|
||||
class NewProfileWidget : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NewProfileWidget(QWidget *parent = 0,
|
||||
const QMap<QString,QString> settings = QMap<QString,QString>(),
|
||||
const bool debugCmd = false);
|
||||
~NewProfileWidget();
|
||||
Qt::ToolBarArea getToolBarArea();
|
||||
|
||||
public slots:
|
||||
void profileTabOpenProfileSlot(const QString profile);
|
||||
void update();
|
||||
void updateToolBarState(const Qt::ToolBarArea area = Qt::TopToolBarArea);
|
||||
|
||||
private slots:
|
||||
// update slots
|
||||
void updateMenuProfile();
|
||||
void updateProfileTab();
|
||||
// profile tab slots
|
||||
void profileTabChangeState(const QString current);
|
||||
void profileTabCreateProfile();
|
||||
void profileTabLoadProfile();
|
||||
void profileTabOpenInEditor();
|
||||
void profileTabRemoveProfile();
|
||||
|
||||
private:
|
||||
// ui
|
||||
MainWindow *mainWindow;
|
||||
Ui::NewProfileWidget *ui = nullptr;
|
||||
BondWidget *bondWid = nullptr;
|
||||
BridgeWidget *bridgeWid = nullptr;
|
||||
EthernetWidget *ethernetWid = nullptr;
|
||||
GeneralWidget *generalWid = nullptr;
|
||||
IpWidget *ipWid = nullptr;
|
||||
MacvlanWidget *macvlanWid = nullptr;
|
||||
MobileWidget *mobileWid = nullptr;
|
||||
PppoeWidget *pppoeWid = nullptr;
|
||||
TunnelWidget *tunnelWid = nullptr;
|
||||
TuntapWidget *tuntapWid = nullptr;
|
||||
VlanWidget *vlanWid = nullptr;
|
||||
WirelessWidget *wirelessWid = nullptr;
|
||||
// backend
|
||||
void createActions();
|
||||
bool debug = false;
|
||||
bool useHelper = true;
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
};
|
||||
|
||||
|
||||
#endif /* NEWPROFILEWIDGET_H */
|
179
sources/gui/src/newprofilewidget.ui
Normal file
179
sources/gui/src/newprofilewidget.ui
Normal file
@ -0,0 +1,179 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>NewProfileWidget</class>
|
||||
<widget class="QMainWindow" name="NewProfileWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>472</width>
|
||||
<height>409</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_profile">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_profile">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Profile</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_profile">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>459</width>
|
||||
<height>342</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">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>New profile toolbar</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonFollowStyle</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionClear"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionLoad"/>
|
||||
<addaction name="actionSave"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionRemove"/>
|
||||
<addaction name="actionEditor"/>
|
||||
</widget>
|
||||
<action name="actionClear">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-clear">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Clear data</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLoad">
|
||||
<property name="icon">
|
||||
<iconset theme="document-open">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Load selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="icon">
|
||||
<iconset theme="document-save">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRemove">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-delete">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove selected profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionEditor">
|
||||
<property name="icon">
|
||||
<iconset theme="document-open">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open in editor</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Open in an external editor</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -20,10 +20,10 @@
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "wifimenuwidget.h"
|
||||
|
||||
|
||||
PasswdWidget::PasswdWidget(MainWindow *wid)
|
||||
PasswdWidget::PasswdWidget(WiFiMenuWidget *wid)
|
||||
: QWidget(wid),
|
||||
parent(wid),
|
||||
ui(new Ui::PasswdWidget)
|
||||
@ -49,6 +49,7 @@ void PasswdWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
|
||||
void PasswdWidget::createActions()
|
||||
{
|
||||
connect(ui->checkBox_showSymbols, SIGNAL(stateChanged(int)), this, SLOT(setEchoMode(int)));
|
||||
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()));
|
||||
@ -64,19 +65,21 @@ void PasswdWidget::setFocusToLineEdit()
|
||||
void PasswdWidget::setPassword(const bool mode)
|
||||
{
|
||||
if (mode) {
|
||||
ui->lineEdit->setEchoMode(QLineEdit::Password);
|
||||
ui->checkBox_showSymbols->setCheckState(Qt::Checked);
|
||||
setEchoMode(ui->checkBox_showSymbols->checkState());
|
||||
ui->label->setText(QApplication::translate("PasswdWidget", "Password"));
|
||||
} else {
|
||||
ui->lineEdit->setEchoMode(QLineEdit::Normal);
|
||||
ui->label->setText(QApplication::translate("PasswdWidget", "ESSID"));
|
||||
}
|
||||
passwdMode = mode;
|
||||
}
|
||||
|
||||
|
||||
void PasswdWidget::cancel()
|
||||
{
|
||||
hide();
|
||||
parent->updateTabs(2);
|
||||
parent->update();
|
||||
this->~PasswdWidget();
|
||||
}
|
||||
|
||||
@ -84,8 +87,17 @@ void PasswdWidget::cancel()
|
||||
void PasswdWidget::passwdApply()
|
||||
{
|
||||
hide();
|
||||
if (ui->lineEdit->echoMode() == QLineEdit::Normal)
|
||||
return parent->setHiddenName(ui->lineEdit->text());
|
||||
else
|
||||
if (passwdMode)
|
||||
return parent->connectToUnknownEssid(ui->lineEdit->text());
|
||||
else
|
||||
return parent->setHiddenName(ui->lineEdit->text());
|
||||
}
|
||||
|
||||
|
||||
void PasswdWidget::setEchoMode(const int mode)
|
||||
{
|
||||
if (mode == 0)
|
||||
ui->lineEdit->setEchoMode(QLineEdit::Password);
|
||||
else
|
||||
ui->lineEdit->setEchoMode(QLineEdit::Normal);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
class WiFiMenuWidget;
|
||||
|
||||
namespace Ui {
|
||||
class PasswdWidget;
|
||||
@ -34,7 +34,7 @@ class PasswdWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PasswdWidget(MainWindow *wid = 0);
|
||||
explicit PasswdWidget(WiFiMenuWidget *wid = 0);
|
||||
~PasswdWidget();
|
||||
|
||||
public slots:
|
||||
@ -44,13 +44,15 @@ public slots:
|
||||
private slots:
|
||||
void cancel();
|
||||
void passwdApply();
|
||||
void setEchoMode(const int mode);
|
||||
|
||||
private:
|
||||
MainWindow *parent;
|
||||
WiFiMenuWidget *parent;
|
||||
Ui::PasswdWidget *ui;
|
||||
// ESC pressed event
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
void createActions();
|
||||
bool passwdMode = true;
|
||||
};
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>264</width>
|
||||
<height>86</height>
|
||||
<height>109</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -16,9 +16,6 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<spacer name="spacer2">
|
||||
@ -37,13 +34,28 @@
|
||||
<layout class="QHBoxLayout" name="layout_passwd">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
@ -51,6 +63,36 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_showSymbols">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_showSymbols">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_showSymbols">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show symbols</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer1">
|
||||
<property name="orientation">
|
||||
@ -65,41 +107,11 @@
|
||||
</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>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -65,21 +65,12 @@ void PppoeWidget::clear()
|
||||
}
|
||||
|
||||
|
||||
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"));
|
||||
ui->lineEdit_session->setInputMask(QString(">00000:hh:hh:hh:hh:hh:hh"));
|
||||
// mac
|
||||
ui->lineEdit_mac->setInputMask(QString(">HH:HH:HH:HH:HH:HH"));
|
||||
ui->lineEdit_mac->setInputMask(QString(">hh:hh:hh:hh:hh:hh"));
|
||||
}
|
||||
|
||||
|
||||
@ -93,17 +84,13 @@ void PppoeWidget::createActions()
|
||||
|
||||
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);
|
||||
ui->widget_timeout->setHidden(currentText == QString("persist"));
|
||||
}
|
||||
|
||||
|
||||
void PppoeWidget::selectOptionsFile()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QString filename = QFileDialog::getOpenFileName(this,
|
||||
QApplication::translate("PppoeWidget", "Select options file"),
|
||||
QDir::currentPath(),
|
||||
QApplication::translate("PppoeWidget", "Configuration files (*.conf)"));
|
||||
@ -116,55 +103,53 @@ void PppoeWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_pppoeAdvanced->isChecked()) {
|
||||
ui->widget_pppoeAdvanced->setHidden(false);
|
||||
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Hide advanced"));
|
||||
ui->pushButton_pppoeAdvanced->setArrowType(Qt::UpArrow);
|
||||
} else {
|
||||
ui->widget_pppoeAdvanced->setHidden(true);
|
||||
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Show advanced"));
|
||||
ui->pushButton_pppoeAdvanced->setArrowType(Qt::DownArrow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> PppoeWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> pppoeSettings;
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return pppoeSettings;
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
if (!ui->lineEdit_username->text().isEmpty())
|
||||
pppoeSettings[QString("User")] = QString("'") + ui->lineEdit_username->text() + QString("'");
|
||||
settings[QString("User")] = QString("'%1'").arg(ui->lineEdit_username->text());
|
||||
if (!ui->lineEdit_password->text().isEmpty())
|
||||
pppoeSettings[QString("Password")] = QString("'") + ui->lineEdit_password->text() + QString("'");
|
||||
pppoeSettings[QString("ConnectionMode")] = QString("'") + ui->comboBox_connection->currentText() + QString("'");
|
||||
settings[QString("Password")] = QString("'%1'").arg(ui->lineEdit_password->text());
|
||||
settings[QString("ConnectionMode")] = QString("'%1'").arg(ui->comboBox_connection->currentText());
|
||||
if (ui->comboBox_connection->currentText() == QString("demand"))
|
||||
pppoeSettings[QString("IdleTimeout")] = QString::number(ui->spinBox_timeout->value());
|
||||
settings[QString("IdleTimeout")] = QString::number(ui->spinBox_timeout->value());
|
||||
if (ui->spinBox_fail->value() != 5)
|
||||
pppoeSettings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
|
||||
settings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
|
||||
if (ui->checkBox_route->checkState() == Qt::Unchecked)
|
||||
pppoeSettings[QString("DefaultRoute")] = QString("false");
|
||||
settings[QString("DefaultRoute")] = QString("false");
|
||||
if (ui->checkBox_dns->checkState() == Qt::Unchecked)
|
||||
pppoeSettings[QString("UsePeerDNS")] = QString("false");
|
||||
settings[QString("UsePeerDNS")] = QString("false");
|
||||
if (!ui->lineEdit_unit->text().isEmpty())
|
||||
pppoeSettings[QString("PPPUnit")] = ui->lineEdit_unit->text();
|
||||
settings[QString("PPPUnit")] = ui->lineEdit_unit->text();
|
||||
if (ui->spinBox_lcpInterval->value() != 30)
|
||||
pppoeSettings[QString("LCPEchoInterval")] = QString::number(ui->spinBox_lcpInterval->value());
|
||||
settings[QString("LCPEchoInterval")] = QString::number(ui->spinBox_lcpInterval->value());
|
||||
if (ui->spinBox_lcpFailure->value() != 4)
|
||||
pppoeSettings[QString("LCPEchoFailure")] = QString::number(ui->spinBox_lcpFailure->value());
|
||||
settings[QString("LCPEchoFailure")] = QString::number(ui->spinBox_lcpFailure->value());
|
||||
if (!ui->lineEdit_options->text().isEmpty())
|
||||
pppoeSettings[QString("OptionsFile")] = QString("'") + ui->lineEdit_options->text() + QString("'");
|
||||
settings[QString("OptionsFile")] = QString("'%1'").arg(ui->lineEdit_options->text());
|
||||
if (!ui->lineEdit_service->text().isEmpty())
|
||||
pppoeSettings[QString("PPPoEService")] = QString("'") + ui->lineEdit_service->text() + QString("'");
|
||||
settings[QString("PPPoEService")] = QString("'%1'").arg(ui->lineEdit_service->text());
|
||||
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("'");
|
||||
settings[QString("PPPoEAC")] = QString("'%1'").arg(ui->lineEdit_ac->text());
|
||||
if (!ui->lineEdit_session->text().remove(QChar(':')).isEmpty())
|
||||
settings[QString("PPPoESession")] = QString("'%1'").arg(ui->lineEdit_session->text());
|
||||
if (!ui->lineEdit_mac->text().remove(QChar(':')).isEmpty())
|
||||
settings[QString("PPPoEMAC")] = QString("'%1'").arg(ui->lineEdit_mac->text());
|
||||
if (ui->checkBox_ipv6->checkState() == Qt::Checked)
|
||||
pppoeSettings[QString("PPPoEIP6")] = QString("yes");
|
||||
settings[QString("PPPoEIP6")] = QString("yes");
|
||||
|
||||
return pppoeSettings;
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
@ -172,22 +157,18 @@ int PppoeWidget::isOk()
|
||||
{
|
||||
// config file doesn't exist
|
||||
if (!ui->lineEdit_options->text().isEmpty())
|
||||
if (!QFile(ui->lineEdit_options->text()).exists())
|
||||
return 1;
|
||||
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;
|
||||
if (!ui->lineEdit_mac->text().remove(QChar(':')).isEmpty())
|
||||
if (ui->lineEdit_mac->text().length() != (6 * 2 + 5)) 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;
|
||||
if (!ui->lineEdit_session->text().remove(QChar(':')).isEmpty())
|
||||
if (ui->lineEdit_session->text().split(QChar(':'))[0].isEmpty()) return 3;
|
||||
// session mac address
|
||||
if (!ui->lineEdit_session->text().remove(QChar(':')).remove(QChar(' ')).isEmpty()) {
|
||||
if (!ui->lineEdit_session->text().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;
|
||||
item.removeFirst();
|
||||
if (item.join(QChar(':')).length() != (6 * 2 + 5)) return 4;
|
||||
}
|
||||
// all fine
|
||||
return 0;
|
||||
@ -197,44 +178,43 @@ int PppoeWidget::isOk()
|
||||
void PppoeWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> pppoeSettings = settings;
|
||||
|
||||
if (pppoeSettings.contains(QString("User")))
|
||||
ui->lineEdit_username->setText(pppoeSettings[QString("User")]);
|
||||
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"))
|
||||
if (settings.contains(QString("User")))
|
||||
ui->lineEdit_username->setText(settings[QString("User")]);
|
||||
if (settings.contains(QString("Password")))
|
||||
ui->lineEdit_password->setText(settings[QString("Password")]);
|
||||
if (settings.contains(QString("ConnectionMode"))) {
|
||||
int index = ui->comboBox_connection->findText(settings[QString("ConnectionMode")]);
|
||||
ui->comboBox_connection->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("IdleTimeout")))
|
||||
ui->spinBox_timeout->setValue(settings[QString("IdleTimeout")].toInt());
|
||||
if (settings.contains(QString("MaxFail")))
|
||||
ui->spinBox_fail->setValue(settings[QString("MaxFail")].toInt());
|
||||
if (settings.contains(QString("DefaultRoute")))
|
||||
if (settings[QString("DefaultRoute")] == QString("false"))
|
||||
ui->checkBox_route->setCheckState(Qt::Unchecked);
|
||||
if (pppoeSettings.contains(QString("UsePeerDNS")))
|
||||
if (pppoeSettings[QString("UsePeerDNS")] == QString("false"))
|
||||
if (settings.contains(QString("UsePeerDNS")))
|
||||
if (settings[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"))
|
||||
if (settings.contains(QString("PPPUnit")))
|
||||
ui->lineEdit_unit->setText(settings[QString("PPPUnit")]);
|
||||
if (settings.contains(QString("LCPEchoInterval")))
|
||||
ui->spinBox_lcpInterval->setValue(settings[QString("LCPEchoInterval")].toInt());
|
||||
if (settings.contains(QString("LCPEchoFailure")))
|
||||
ui->spinBox_lcpFailure->setValue(settings[QString("LCPEchoFailure")].toInt());
|
||||
if (settings.contains(QString("OptionsFile")))
|
||||
ui->lineEdit_options->setText(settings[QString("OptionsFile")]);
|
||||
if (settings.contains(QString("PPPoEService")))
|
||||
ui->lineEdit_service->setText(settings[QString("PPPoEService")]);
|
||||
if (settings.contains(QString("PPPoEAC")))
|
||||
ui->lineEdit_ac->setText(settings[QString("PPPoEAC")]);
|
||||
if (settings.contains(QString("PPPoESession")))
|
||||
ui->lineEdit_session->setText(settings[QString("PPPoESession")]);
|
||||
if (settings.contains(QString("PPPoEMAC")))
|
||||
ui->lineEdit_mac->setText(settings[QString("PPPoEMAC")]);
|
||||
if (settings.contains(QString("PPPoEIP6")))
|
||||
if (settings[QString("PPPoEIP6")] == QString("yes"))
|
||||
ui->checkBox_dns->setCheckState(Qt::Checked);
|
||||
|
||||
changeMode(ui->comboBox_connection->currentText());
|
||||
|
@ -38,7 +38,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private slots:
|
||||
void changeMode(const QString currentText);
|
||||
|
@ -6,13 +6,10 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>431</width>
|
||||
<height>602</height>
|
||||
<width>484</width>
|
||||
<height>561</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_pppoe">
|
||||
@ -28,19 +25,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Username</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_username">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The username and password to connect with</string>
|
||||
</property>
|
||||
@ -52,19 +58,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The username and password to connect with</string>
|
||||
</property>
|
||||
@ -76,19 +91,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connection mode</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_connection">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>This option specifies how a connection should be established</string>
|
||||
</property>
|
||||
@ -111,19 +135,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Idle timeout</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_timeout">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>This option specifies the idle time (in seconds) after which ‘pppd’ should disconnect</string>
|
||||
</property>
|
||||
@ -157,13 +190,16 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_pppoeAdvanced">
|
||||
<property name="text">
|
||||
<string>Show advanced</string>
|
||||
</property>
|
||||
<widget class="QToolButton" name="pushButton_pppoeAdvanced">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="arrowType">
|
||||
<enum>Qt::DownArrow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -171,23 +207,174 @@
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_pppoeAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_route">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_route">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_route">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_dns">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_dns">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_dns">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ipv6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_ipv6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_ipv6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enable IPv6 support</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PPPoE IPv6</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_options">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_options">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>7</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Options file</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_options">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>10</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<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="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>4</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Max fail</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_fail">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The number of consecutive failed connection attempts to tolerate</string>
|
||||
</property>
|
||||
@ -201,49 +388,32 @@
|
||||
</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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PPP unit</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_unit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set the ppp unit number in the interface name (ppp0, ppp1, etc.)</string>
|
||||
</property>
|
||||
@ -255,19 +425,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>LCP echo interval</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_lcpInterval">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>These options override default LCP parameters from ‘/etc/ppp/options’</string>
|
||||
</property>
|
||||
@ -288,19 +467,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>LCP echo failure</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_lcpFailure">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>These options override default LCP parameters from ‘/etc/ppp/options’</string>
|
||||
</property>
|
||||
@ -314,54 +502,32 @@
|
||||
</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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PPPoE service</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_service">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>This option specifies the PPPoE service name</string>
|
||||
</property>
|
||||
@ -373,19 +539,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PPPoE AC</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_ac">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>This option specifies the PPPoE access concentrator name</string>
|
||||
</property>
|
||||
@ -397,19 +572,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PPPoE session</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_session">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>This option specifies an existing session to attach to, MAC address</string>
|
||||
</property>
|
||||
@ -421,19 +605,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PPPoE MAC</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_mac">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Only connect to specified MAC address</string>
|
||||
</property>
|
||||
@ -441,16 +634,6 @@
|
||||
</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>
|
||||
|
@ -22,11 +22,15 @@
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
#include <QSettings>
|
||||
#include <grp.h>
|
||||
|
||||
#include <language/language.h>
|
||||
#include <pdebug/pdebug.h>
|
||||
#include <task/taskadds.h>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QString configFile)
|
||||
@ -37,6 +41,7 @@ SettingsWindow::SettingsWindow(QWidget *parent, const bool debugCmd, const QStri
|
||||
{
|
||||
ui->setupUi(this);
|
||||
addLanguages();
|
||||
addGroups();
|
||||
createActions();
|
||||
}
|
||||
|
||||
@ -57,10 +62,12 @@ void SettingsWindow::createActions()
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(closeWindow()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(restoreSettings()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
|
||||
connect(ui->buttonBox_applyGroup->button(QDialogButtonBox::Apply), SIGNAL(clicked(bool)), this, SLOT(applyHelperGroup()));
|
||||
connect(ui->checkBox_enableTray, SIGNAL(stateChanged(int)), this, SLOT(setTray()));
|
||||
connect(ui->treeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
|
||||
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem *)));
|
||||
// buttons
|
||||
connect(ui->pushButton_editorPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_helperPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_interfacesDir, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), this, SLOT(selectAbstractSomething()));
|
||||
@ -75,6 +82,48 @@ void SettingsWindow::createActions()
|
||||
}
|
||||
|
||||
|
||||
int SettingsWindow::indexByToolBarPosition(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Area" << area;
|
||||
|
||||
switch (area) {
|
||||
case Qt::LeftToolBarArea:
|
||||
return 0;
|
||||
case Qt::RightToolBarArea:
|
||||
return 1;
|
||||
case Qt::TopToolBarArea:
|
||||
return 2;
|
||||
case Qt::BottomToolBarArea:
|
||||
return 3;
|
||||
case Qt::NoToolBarArea:
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea SettingsWindow::indexToToolBarPosition(const int index)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Index" << index;
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
return Qt::LeftToolBarArea;
|
||||
case 1:
|
||||
return Qt::RightToolBarArea;
|
||||
case 2:
|
||||
return Qt::TopToolBarArea;
|
||||
case 3:
|
||||
return Qt::BottomToolBarArea;
|
||||
case 4:
|
||||
default:
|
||||
return Qt::NoToolBarArea;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ESC press event
|
||||
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
@ -94,9 +143,81 @@ void SettingsWindow::addLanguages()
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::applyHelperGroup()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString group = ui->comboBox_group->currentText();
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Group" << group;
|
||||
if (group.isEmpty()) return;
|
||||
|
||||
// create
|
||||
QFile policyFile(QString("%1/org.netctlgui.helper.conf").arg(QDir::tempPath()));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Save to" << policyFile.fileName();
|
||||
if (!policyFile.open(QIODevice::WriteOnly | QIODevice::Text)) return;
|
||||
|
||||
// write
|
||||
QTextStream out(&policyFile);
|
||||
// header
|
||||
out << "<!DOCTYPE busconfig PUBLIC" << endl;
|
||||
out << " \"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN\"" << endl;
|
||||
out << " \"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd\">" << endl;
|
||||
out << "<busconfig>" << endl;
|
||||
// group body
|
||||
out << " <policy group=\"" << group << "\">" << endl;
|
||||
out << " <allow own=\"org.netctlgui.helper\"/>" << endl;
|
||||
out << " <allow send_destination=\"org.netctlgui.helper\"/>" << endl;
|
||||
out << " <allow receive_sender=\"org.netctlgui.helper\"/>" << endl;
|
||||
out << " </policy>" << endl;
|
||||
// root body
|
||||
out << " <policy user=\"root\">" << endl;
|
||||
out << " <allow own=\"org.netctlgui.helper\"/>" << endl;
|
||||
out << " <allow send_destination=\"org.netctlgui.helper\"/>" << endl;
|
||||
out << " <allow receive_sender=\"org.netctlgui.helper\"/>" << endl;
|
||||
out << " </policy>" << endl;
|
||||
// footer
|
||||
out << "</busconfig>" << endl;
|
||||
policyFile.close();
|
||||
|
||||
// copy
|
||||
QString newPath = QString("%1/org.netctlgui.helper.conf").arg(PROJECT_DBUS_SYSTEMCONF_PATH);
|
||||
QString cmd = QString("%1 /usr/bin/mv \"%2\" \"%3\"").arg(ui->lineEdit_sudo->text())
|
||||
.arg(policyFile.fileName())
|
||||
.arg(newPath);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Run cmd" << cmd;
|
||||
TaskResult process = runTask(cmd, false);
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||
if (process.exitCode != 0)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Error" << process.error;
|
||||
|
||||
// update
|
||||
setHelperGroup();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::addGroups()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
ui->comboBox_group->clear();
|
||||
|
||||
QFile groupFile(QString("/etc/group"));
|
||||
if (!groupFile.open(QIODevice::ReadOnly)) return;
|
||||
while (true) {
|
||||
QString fileStr = QString(groupFile.readLine()).trimmed();
|
||||
if ((fileStr.isEmpty()) && (!groupFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar('#')) && (!groupFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar(';')) && (!groupFile.atEnd())) continue;
|
||||
if (fileStr.contains(QChar(':'))) ui->comboBox_group->addItem(fileStr.split(QChar(':'))[0]);
|
||||
if (groupFile.atEnd()) break;
|
||||
}
|
||||
groupFile.close();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous)
|
||||
Q_UNUSED(previous);
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
for (int i=0; i<ui->treeWidget->topLevelItemCount(); i++)
|
||||
@ -113,7 +234,7 @@ void SettingsWindow::closeWindow()
|
||||
|
||||
saveSettings();
|
||||
close();
|
||||
((MainWindow *)parent())->updateConfiguration();
|
||||
dynamic_cast<MainWindow *>(parent())->updateConfiguration();
|
||||
}
|
||||
|
||||
|
||||
@ -121,14 +242,96 @@ void SettingsWindow::saveSettings()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
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();
|
||||
QMap<QString, QString> config = readSettings();
|
||||
QSettings settings(file, QSettings::IniFormat);
|
||||
|
||||
settings.beginGroup(QString("Common"));
|
||||
settings.setValue(QString("LANGUAGE"), config[QString("LANGUAGE")]);
|
||||
settings.setValue(QString("MAINUPDATE"), config[QString("MAINUPDATE")]);
|
||||
settings.setValue(QString("WIFIUPDATE"), config[QString("WIFIUPDATE")]);
|
||||
settings.setValue(QString("SYSTRAY"), config[QString("SYSTRAY")]);
|
||||
settings.setValue(QString("CLOSETOTRAY"), config[QString("CLOSETOTRAY")]);
|
||||
settings.setValue(QString("STARTTOTRAY"), config[QString("STARTTOTRAY")]);
|
||||
settings.setValue(QString("SKIPCOMPONENTS"), config[QString("SKIPCOMPONENTS")]);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Helper"));
|
||||
settings.setValue(QString("USE_HELPER"), config[QString("USE_HELPER")]);
|
||||
settings.setValue(QString("FORCE_SUDO"), config[QString("FORCE_SUDO")]);
|
||||
settings.setValue(QString("CLOSE_HELPER"), config[QString("CLOSE_HELPER")]);
|
||||
settings.setValue(QString("HELPER_PATH"), config[QString("HELPER_PATH")]);
|
||||
settings.setValue(QString("HELPER_SERVICE"), config[QString("HELPER_SERVICE")]);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("netctl"));
|
||||
settings.setValue(QString("SYSTEMCTL_PATH"), config[QString("SYSTEMCTL_PATH")]);
|
||||
settings.setValue(QString("NETCTL_PATH"), config[QString("NETCTL_PATH")]);
|
||||
settings.setValue(QString("NETCTLAUTO_PATH"), config[QString("NETCTLAUTO_PATH")]);
|
||||
settings.setValue(QString("NETCTLAUTO_PATH"), config[QString("NETCTLAUTO_PATH")]);
|
||||
settings.setValue(QString("PROFILE_DIR"), config[QString("PROFILE_DIR")]);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("sudo"));
|
||||
settings.setValue(QString("SUDO_PATH"), config[QString("SUDO_PATH")]);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("wpa_supplicant"));
|
||||
settings.setValue(QString("WPASUP_PATH"), config[QString("WPASUP_PATH")]);
|
||||
settings.setValue(QString("WPACLI_PATH"), config[QString("WPACLI_PATH")]);
|
||||
settings.setValue(QString("PID_FILE"), config[QString("PID_FILE")]);
|
||||
settings.setValue(QString("WPA_DRIVERS"), config[QString("WPA_DRIVERS")]);
|
||||
settings.setValue(QString("CTRL_DIR"), config[QString("CTRL_DIR")]);
|
||||
settings.setValue(QString("CTRL_GROUP"), config[QString("CTRL_GROUP")]);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Other"));
|
||||
settings.setValue(QString("EDITOR_PATH"), config[QString("EDITOR_PATH")]);
|
||||
settings.setValue(QString("IFACE_DIR"), config[QString("IFACE_DIR")]);
|
||||
settings.setValue(QString("RFKILL_DIR"), config[QString("RFKILL_DIR")]);
|
||||
settings.setValue(QString("PREFERED_IFACE"), config[QString("PREFERED_IFACE")]);
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Toolbars"));
|
||||
settings.setValue(QString("MAIN_TOOLBAR"), config[QString("MAIN_TOOLBAR")]);
|
||||
settings.setValue(QString("NETCTL_TOOLBAR"), config[QString("NETCTL_TOOLBAR")]);
|
||||
settings.setValue(QString("NETCTLAUTO_TOOLBAR"), config[QString("NETCTLAUTO_TOOLBAR")]);
|
||||
settings.setValue(QString("PROFILE_TOOLBAR"), config[QString("PROFILE_TOOLBAR")]);
|
||||
settings.setValue(QString("WIFI_TOOLBAR"), config[QString("WIFI_TOOLBAR")]);
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::setHelperGroup()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString group;
|
||||
QFile policyFile(QString("%1/org.netctlgui.helper.conf").arg(QString(PROJECT_DBUS_SYSTEMCONF_PATH)));
|
||||
if (!policyFile.open(QIODevice::ReadOnly)) return;
|
||||
while (true) {
|
||||
QString fileStr = QString(policyFile.readLine()).trimmed();
|
||||
if ((fileStr.isEmpty()) && (!policyFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar('#')) && (!policyFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar(';')) && (!policyFile.atEnd())) continue;
|
||||
if (fileStr.contains(QString("policy group"))) try {
|
||||
// line is ' <policy group="network">'
|
||||
QStringList fields = fileStr.split(QChar(' '), QString::SkipEmptyParts);
|
||||
group = fields[1].split(QChar('='))[1];
|
||||
group.remove(QChar('<')).remove(QChar('>')).remove(QChar('\'')).remove(QChar('"'));
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Group detected" << group;
|
||||
} catch (...) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "An exception recevied";
|
||||
return;
|
||||
}
|
||||
if (policyFile.atEnd()) break;
|
||||
}
|
||||
policyFile.close();
|
||||
|
||||
if (group.isEmpty()) return;
|
||||
int index = ui->comboBox_group->findText(group);
|
||||
ui->comboBox_group->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
|
||||
@ -136,13 +339,8 @@ void SettingsWindow::setTray()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui->checkBox_enableTray->checkState() == 0) {
|
||||
ui->checkBox_closeToTray->setDisabled(true);
|
||||
ui->checkBox_startToTray->setDisabled(true);
|
||||
} else if (ui->checkBox_enableTray->checkState() == 2) {
|
||||
ui->checkBox_closeToTray->setEnabled(true);
|
||||
ui->checkBox_startToTray->setEnabled(true);
|
||||
}
|
||||
ui->checkBox_closeToTray->setDisabled(ui->checkBox_enableTray->checkState() == 0);
|
||||
ui->checkBox_startToTray->setDisabled(ui->checkBox_enableTray->checkState() == 0);
|
||||
}
|
||||
|
||||
|
||||
@ -171,8 +369,11 @@ void SettingsWindow::selectAbstractSomething()
|
||||
bool isDir = false;
|
||||
QString path = QString("/usr/bin");
|
||||
QString text = QApplication::translate("SettingsWindow", "Select helper command");
|
||||
QLineEdit *lineEdit = ui->lineEdit_helperPath;
|
||||
if (sender() == ui->pushButton_helperPath) {
|
||||
QLineEdit *lineEdit = ui->lineEdit_editorPath;
|
||||
if (sender() == ui->pushButton_editorPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select editor command");
|
||||
lineEdit = ui->lineEdit_editorPath;
|
||||
} else if (sender() == ui->pushButton_helperPath) {
|
||||
text = QApplication::translate("SettingsWindow", "Select helper command");
|
||||
lineEdit = ui->lineEdit_helperPath;
|
||||
} else if (sender() == ui->pushButton_interfacesDir) {
|
||||
@ -225,6 +426,7 @@ void SettingsWindow::showWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
setHelperGroup();
|
||||
setSettings(getSettings());
|
||||
setTray();
|
||||
updateHelper();
|
||||
@ -237,115 +439,137 @@ QMap<QString, QString> SettingsWindow::readSettings()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
if (ui->checkBox_helperClose->checkState() == 2)
|
||||
settings[QString("CLOSE_HELPER")] = QString("true");
|
||||
else
|
||||
settings[QString("CLOSE_HELPER")] = QString("false");
|
||||
if (ui->checkBox_closeToTray->checkState() == 2)
|
||||
settings[QString("CLOSETOTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("CLOSETOTRAY")] = QString("false");
|
||||
settings[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
|
||||
settings[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->text();
|
||||
if (ui->checkBox_forceSudo->checkState() == 2)
|
||||
settings[QString("FORCE_SUDO")] = QString("true");
|
||||
else
|
||||
settings[QString("FORCE_SUDO")] = QString("false");
|
||||
settings[QString("HELPER_PATH")] = ui->lineEdit_helperPath->text();
|
||||
settings[QString("HELPER_SERVICE")] = ui->lineEdit_helperService->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();
|
||||
if (ui->checkBox_components->checkState() == 2)
|
||||
settings[QString("SKIPCOMPONENTS")] = QString("true");
|
||||
else
|
||||
settings[QString("SKIPCOMPONENTS")] = QString("false");
|
||||
if (ui->checkBox_startToTray->checkState() == 2)
|
||||
settings[QString("STARTTOTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("STARTTOTRAY")] = QString("false");
|
||||
settings[QString("SUDO_PATH")] = ui->lineEdit_sudo->text();
|
||||
settings[QString("SYSTEMCTL_PATH")] = ui->lineEdit_systemctlPath->text();
|
||||
if (ui->checkBox_enableTray->checkState() == 2)
|
||||
settings[QString("SYSTRAY")] = QString("true");
|
||||
else
|
||||
settings[QString("SYSTRAY")] = QString("false");
|
||||
if (ui->checkBox_useHelper->checkState() == 2)
|
||||
settings[QString("USE_HELPER")] = QString("true");
|
||||
else
|
||||
settings[QString("USE_HELPER")] = QString("false");
|
||||
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() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
QMap<QString, QString> config;
|
||||
|
||||
return settings;
|
||||
if (ui->checkBox_helperClose->checkState() == 2)
|
||||
config[QString("CLOSE_HELPER")] = QString("true");
|
||||
else
|
||||
config[QString("CLOSE_HELPER")] = QString("false");
|
||||
if (ui->checkBox_closeToTray->checkState() == 2)
|
||||
config[QString("CLOSETOTRAY")] = QString("true");
|
||||
else
|
||||
config[QString("CLOSETOTRAY")] = QString("false");
|
||||
config[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
|
||||
config[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->text();
|
||||
if (ui->checkBox_forceSudo->checkState() == 2)
|
||||
config[QString("FORCE_SUDO")] = QString("true");
|
||||
else
|
||||
config[QString("FORCE_SUDO")] = QString("false");
|
||||
config[QString("EDITOR_PATH")] = ui->lineEdit_editorPath->text();
|
||||
config[QString("HELPER_PATH")] = ui->lineEdit_helperPath->text();
|
||||
config[QString("HELPER_SERVICE")] = ui->lineEdit_helperService->text();
|
||||
config[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
|
||||
config[QString("LANGUAGE")] = ui->comboBox_language->currentText();
|
||||
config[QString("MAINUPDATE")] = QString::number(ui->spinBox_mainAutoUpdate->value());
|
||||
config[QString("MAIN_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_mainToolbar->currentIndex()));
|
||||
config[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
|
||||
config[QString("NETCTL_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_netctlToolbar->currentIndex()));
|
||||
config[QString("NETCTLAUTO_PATH")] = ui->lineEdit_netctlAutoPath->text();
|
||||
config[QString("NETCTLAUTO_SERVICE")] = ui->lineEdit_netctlAutoService->text();
|
||||
config[QString("NETCTLAUTO_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_netctlAutoToolbar->currentIndex()));
|
||||
config[QString("PID_FILE")] = ui->lineEdit_pid->text();
|
||||
config[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
|
||||
config[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
|
||||
config[QString("PROFILE_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_profilesToolbar->currentIndex()));
|
||||
config[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
|
||||
if (ui->checkBox_components->checkState() == 2)
|
||||
config[QString("SKIPCOMPONENTS")] = QString("true");
|
||||
else
|
||||
config[QString("SKIPCOMPONENTS")] = QString("false");
|
||||
if (ui->checkBox_startToTray->checkState() == 2)
|
||||
config[QString("STARTTOTRAY")] = QString("true");
|
||||
else
|
||||
config[QString("STARTTOTRAY")] = QString("false");
|
||||
config[QString("SUDO_PATH")] = ui->lineEdit_sudo->text();
|
||||
config[QString("SYSTEMCTL_PATH")] = ui->lineEdit_systemctlPath->text();
|
||||
if (ui->checkBox_enableTray->checkState() == 2)
|
||||
config[QString("SYSTRAY")] = QString("true");
|
||||
else
|
||||
config[QString("SYSTRAY")] = QString("false");
|
||||
if (ui->checkBox_useHelper->checkState() == 2)
|
||||
config[QString("USE_HELPER")] = QString("true");
|
||||
else
|
||||
config[QString("USE_HELPER")] = QString("false");
|
||||
config[QString("WIFIUPDATE")] = QString::number(ui->spinBox_wifiAutoUpdate->value());
|
||||
config[QString("WIFI_TOOLBAR")] = QString::number(indexToToolBarPosition(ui->comboBox_wifiToolbar->currentIndex()));
|
||||
config[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
|
||||
config[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
|
||||
config[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
|
||||
|
||||
for (int i=0; i<config.keys().count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << QString("%1=%2").arg(config.keys()[i]).arg(config[config.keys()[i]]);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
||||
void SettingsWindow::setSettings(const QMap<QString, QString> config)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (settings[QString("CLOSE_HELPER")] == QString("true"))
|
||||
if (config[QString("CLOSE_HELPER")] == QString("true"))
|
||||
ui->checkBox_helperClose->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_helperClose->setCheckState(Qt::Unchecked);
|
||||
if (settings[QString("CLOSETOTRAY")] == QString("true"))
|
||||
if (config[QString("CLOSETOTRAY")] == QString("true"))
|
||||
ui->checkBox_closeToTray->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_closeToTray->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
|
||||
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
|
||||
if (settings[QString("FORCE_SUDO")] == QString("true"))
|
||||
ui->lineEdit_wpaDir->setText(config[QString("CTRL_DIR")]);
|
||||
ui->lineEdit_wpaGroup->setText(config[QString("CTRL_GROUP")]);
|
||||
if (config[QString("FORCE_SUDO")] == QString("true"))
|
||||
ui->checkBox_forceSudo->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_forceSudo->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_helperPath->setText(settings[QString("HELPER_PATH")]);
|
||||
ui->lineEdit_helperService->setText(settings[QString("HELPER_SERVICE")]);
|
||||
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")]);
|
||||
if (settings[QString("SKIPCOMPONENTS")] == QString("true"))
|
||||
ui->lineEdit_editorPath->setText(config[QString("EDITOR_PATH")]);
|
||||
ui->lineEdit_helperPath->setText(config[QString("HELPER_PATH")]);
|
||||
ui->lineEdit_helperService->setText(config[QString("HELPER_SERVICE")]);
|
||||
ui->lineEdit_interfacesDir->setText(config[QString("IFACE_DIR")]);
|
||||
int index = ui->comboBox_language->findText(config[QString("LANGUAGE")]);
|
||||
ui->comboBox_language->setCurrentIndex(index);
|
||||
ui->spinBox_mainAutoUpdate->setValue(config[QString("MAINUPDATE")].toInt());
|
||||
index = indexByToolBarPosition(static_cast<Qt::ToolBarArea>(config[QString("MAIN_TOOLBAR")].toInt()));
|
||||
ui->comboBox_mainToolbar->setCurrentIndex(index);
|
||||
ui->lineEdit_netctlPath->setText(config[QString("NETCTL_PATH")]);
|
||||
index = indexByToolBarPosition(static_cast<Qt::ToolBarArea>(config[QString("NETCTL_TOOLBAR")].toInt()));
|
||||
ui->comboBox_netctlToolbar->setCurrentIndex(index);
|
||||
ui->lineEdit_netctlAutoPath->setText(config[QString("NETCTLAUTO_PATH")]);
|
||||
ui->lineEdit_netctlAutoService->setText(config[QString("NETCTLAUTO_SERVICE")]);
|
||||
index = indexByToolBarPosition(static_cast<Qt::ToolBarArea>(config[QString("NETCTLAUTO_TOOLBAR")].toInt()));
|
||||
ui->comboBox_netctlAutoToolbar->setCurrentIndex(index);
|
||||
ui->lineEdit_pid->setText(config[QString("PID_FILE")]);
|
||||
ui->lineEdit_interface->setText(config[QString("PREFERED_IFACE")]);
|
||||
index = indexByToolBarPosition(static_cast<Qt::ToolBarArea>(config[QString("PROFILE_TOOLBAR")].toInt()));
|
||||
ui->comboBox_profilesToolbar->setCurrentIndex(index);
|
||||
ui->lineEdit_profilePath->setText(config[QString("PROFILE_DIR")]);
|
||||
ui->lineEdit_rfkill->setText(config[QString("RFKILL_DIR")]);
|
||||
if (config[QString("SKIPCOMPONENTS")] == QString("true"))
|
||||
ui->checkBox_components->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_components->setCheckState(Qt::Unchecked);
|
||||
if (settings[QString("STARTTOTRAY")] == QString("true"))
|
||||
if (config[QString("STARTTOTRAY")] == QString("true"))
|
||||
ui->checkBox_startToTray->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_startToTray->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_sudo->setText(settings[QString("SUDO_PATH")]);
|
||||
ui->lineEdit_systemctlPath->setText(settings[QString("SYSTEMCTL_PATH")]);
|
||||
if (settings[QString("SYSTRAY")] == QString("true"))
|
||||
ui->lineEdit_sudo->setText(config[QString("SUDO_PATH")]);
|
||||
ui->lineEdit_systemctlPath->setText(config[QString("SYSTEMCTL_PATH")]);
|
||||
if (config[QString("SYSTRAY")] == QString("true"))
|
||||
ui->checkBox_enableTray->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_enableTray->setCheckState(Qt::Unchecked);
|
||||
if (settings[QString("USE_HELPER")] == QString("true"))
|
||||
if (config[QString("USE_HELPER")] == QString("true"))
|
||||
ui->checkBox_useHelper->setCheckState(Qt::Checked);
|
||||
else
|
||||
ui->checkBox_useHelper->setCheckState(Qt::Unchecked);
|
||||
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() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
ui->spinBox_wifiAutoUpdate->setValue(config[QString("WIFIUPDATE")].toInt());
|
||||
index = indexByToolBarPosition(static_cast<Qt::ToolBarArea>(config[QString("WIFI_TOOLBAR")].toInt()));
|
||||
ui->comboBox_wifiToolbar->setCurrentIndex(index);
|
||||
ui->lineEdit_wpaCliPath->setText(config[QString("WPACLI_PATH")]);
|
||||
ui->lineEdit_wpaSupPath->setText(config[QString("WPASUP_PATH")]);
|
||||
ui->lineEdit_wpaSupDrivers->setText(config[QString("WPA_DRIVERS")]);
|
||||
|
||||
for (int i=0; i<config.keys().count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << QString("%1=%2").arg(config.keys()[i]).arg(config[config.keys()[i]]);
|
||||
}
|
||||
|
||||
|
||||
@ -353,62 +577,77 @@ QMap<QString, QString> SettingsWindow::getDefault()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
settings[QString("CLOSE_HELPER")] = QString("false");
|
||||
settings[QString("CLOSETOTRAY")] = QString("true");
|
||||
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
|
||||
settings[QString("CTRL_GROUP")] = QString("users");
|
||||
settings[QString("FORCE_SUDO")] = QString("false");
|
||||
settings[QString("HELPER_PATH")] = QString("/usr/bin/netctlgui-helper");
|
||||
settings[QString("HELPER_SERVICE")] = QString("netctlgui-helper.service");
|
||||
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("SKIPCOMPONENTS")] = QString("false");
|
||||
settings[QString("STARTTOTRAY")] = QString("false");
|
||||
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
|
||||
settings[QString("SYSTEMCTL_PATH")] = QString("/usr/bin/systemctl");
|
||||
settings[QString("SYSTRAY")] = QString("true");
|
||||
settings[QString("USE_HELPER")] = QString("true");
|
||||
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() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
return getSettings(QString("/dev/null"));
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> SettingsWindow::getSettings()
|
||||
QMap<QString, QString> SettingsWindow::getSettings(QString fileName)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (fileName.isEmpty()) fileName = file;
|
||||
|
||||
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.isEmpty()) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar('#')) && (!configFile.atEnd())) continue;
|
||||
if ((fileStr[0] == QChar(';')) && (!configFile.atEnd())) continue;
|
||||
if (fileStr.contains(QChar('=')))
|
||||
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() << PDEBUG << ":" << settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
QMap<QString, QString> config;
|
||||
QSettings settings(fileName, QSettings::IniFormat);
|
||||
|
||||
return settings;
|
||||
config[QString("LANGUAGE")] = Language::defineLanguage(fileName, QString());
|
||||
settings.beginGroup(QString("Common"));
|
||||
config[QString("LANGUAGE")] = settings.value(QString("LANGUAGE"), config[QString("LANGUAGE")]).toString();
|
||||
config[QString("MAINUPDATE")] = settings.value(QString("MAINUPDATE"), QString(MAINUPDATE)).toString();
|
||||
config[QString("WIFIUPDATE")] = settings.value(QString("WIFIUPDATE"), QString(WIFIUPDATE)).toString();
|
||||
config[QString("SYSTRAY")] = settings.value(QString("SYSTRAY"), QString(SYSTRAY)).toString();
|
||||
config[QString("CLOSETOTRAY")] = settings.value(QString("CLOSETOTRAY"), QString(CLOSETOTRAY)).toString();
|
||||
config[QString("STARTTOTRAY")] = settings.value(QString("STARTTOTRAY"), QString(STARTTOTRAY)).toString();
|
||||
config[QString("SKIPCOMPONENTS")] = settings.value(QString("SKIPCOMPONENTS"), QString(SKIPCOMPONENTS)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Helper"));
|
||||
config[QString("USE_HELPER")] = settings.value(QString("USE_HELPER"), QString(USE_HELPER)).toString();
|
||||
config[QString("FORCE_SUDO")] = settings.value(QString("FORCE_SUDO"), QString(FORCE_SUDO)).toString();
|
||||
config[QString("CLOSE_HELPER")] = settings.value(QString("CLOSE_HELPER"), QString(CLOSE_HELPER)).toString();
|
||||
config[QString("HELPER_PATH")] = settings.value(QString("HELPER_PATH"), QString(HELPER_PATH)).toString();
|
||||
config[QString("HELPER_SERVICE")] = settings.value(QString("HELPER_SERVICE"), QString(HELPER_SERVICE)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("netctl"));
|
||||
config[QString("SYSTEMCTL_PATH")] = settings.value(QString("SYSTEMCTL_PATH"), QString(SYSTEMCTL_PATH)).toString();
|
||||
config[QString("NETCTL_PATH")] = settings.value(QString("NETCTL_PATH"), QString(NETCTL_PATH)).toString();
|
||||
config[QString("NETCTLAUTO_PATH")] = settings.value(QString("NETCTLAUTO_PATH"), QString(NETCTLAUTO_PATH)).toString();
|
||||
config[QString("NETCTLAUTO_SERVICE")] = settings.value(QString("NETCTLAUTO_SERVICE"), QString(NETCTLAUTO_SERVICE)).toString();
|
||||
config[QString("PROFILE_DIR")] = settings.value(QString("PROFILE_DIR"), QString(PROFILE_DIR)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("sudo"));
|
||||
config[QString("SUDO_PATH")] = settings.value(QString("SUDO_PATH"), QString(SUDO_PATH)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("wpa_supplicant"));
|
||||
config[QString("WPASUP_PATH")] = settings.value(QString("WPASUP_PATH"), QString(WPASUP_PATH)).toString();
|
||||
config[QString("WPACLI_PATH")] = settings.value(QString("WPACLI_PATH"), QString(WPACLI_PATH)).toString();
|
||||
config[QString("PID_FILE")] = settings.value(QString("PID_FILE"), QString(PID_FILE)).toString();
|
||||
config[QString("WPA_DRIVERS")] = settings.value(QString("WPA_DRIVERS"), QString(WPA_DRIVERS)).toString();
|
||||
config[QString("CTRL_DIR")] = settings.value(QString("CTRL_DIR"), QString(CTRL_DIR)).toString();
|
||||
config[QString("CTRL_GROUP")] = settings.value(QString("CTRL_GROUP"), QString(CTRL_GROUP)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Other"));
|
||||
config[QString("EDITOR_PATH")] = settings.value(QString("EDITOR_PATH"), QString(EDITOR_PATH)).toString();
|
||||
config[QString("IFACE_DIR")] = settings.value(QString("IFACE_DIR"), QString(IFACE_DIR)).toString();
|
||||
config[QString("RFKILL_DIR")] = settings.value(QString("RFKILL_DIR"), QString(RFKILL_DIR)).toString();
|
||||
config[QString("PREFERED_IFACE")] = settings.value(QString("PREFERED_IFACE"), QString(PREFERED_IFACE)).toString();
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup(QString("Toolbars"));
|
||||
config[QString("MAIN_TOOLBAR")] = settings.value(QString("MAIN_TOOLBAR"), Qt::TopToolBarArea).toString();
|
||||
config[QString("NETCTL_TOOLBAR")] = settings.value(QString("NETCTL_TOOLBAR"), Qt::TopToolBarArea).toString();
|
||||
config[QString("NETCTLAUTO_TOOLBAR")] = settings.value(QString("NETCTLAUTO_TOOLBAR"), Qt::TopToolBarArea).toString();
|
||||
config[QString("PROFILE_TOOLBAR")] = settings.value(QString("PROFILE_TOOLBAR"), Qt::TopToolBarArea).toString();
|
||||
config[QString("WIFI_TOOLBAR")] = settings.value(QString("WIFI_TOOLBAR"), Qt::TopToolBarArea).toString();
|
||||
settings.endGroup();
|
||||
|
||||
for (int i=0; i<config.keys().count(); i++)
|
||||
if (debug) qDebug() << PDEBUG << ":" << QString("%1=%2").arg(config.keys()[i]).arg(config[config.keys()[i]]);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@ -416,7 +655,7 @@ void SettingsWindow::startHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
((MainWindow *)parent())->startHelper();
|
||||
dynamic_cast<MainWindow *>(parent())->startHelper();
|
||||
updateHelper();
|
||||
}
|
||||
|
||||
@ -425,12 +664,12 @@ void SettingsWindow::updateHelper()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (((MainWindow *)parent())->isHelperServiceActive()) {
|
||||
if (dynamic_cast<MainWindow *>(parent())->isHelperServiceActive()) {
|
||||
ui->label_status->setText(QApplication::translate("SettingsWindow", "Active (systemd)"));
|
||||
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Stop"));
|
||||
ui->pushButton_status->setIcon(QIcon::fromTheme("process-stop"));
|
||||
ui->pushButton_status->setDisabled(true);
|
||||
} else if (((MainWindow *)parent())->isHelperActive()) {
|
||||
} else if (dynamic_cast<MainWindow *>(parent())->isHelperActive()) {
|
||||
ui->label_status->setText(QApplication::translate("SettingsWindow", "Active"));
|
||||
ui->pushButton_status->setText(QApplication::translate("SettingsWindow", "Stop"));
|
||||
ui->pushButton_status->setIcon(QIcon::fromTheme("process-stop"));
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
const QString configFile = QString(""));
|
||||
~SettingsWindow();
|
||||
QMap<QString, QString> getDefault();
|
||||
QMap<QString, QString> getSettings();
|
||||
QMap<QString, QString> getSettings(QString fileName = QString(""));
|
||||
|
||||
public slots:
|
||||
void closeWindow();
|
||||
@ -48,9 +48,12 @@ public slots:
|
||||
void showWindow();
|
||||
|
||||
private slots:
|
||||
void addGroups();
|
||||
void addLanguages();
|
||||
void applyHelperGroup();
|
||||
void changePage(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void saveSettings();
|
||||
void setHelperGroup();
|
||||
void setTray();
|
||||
void updateHelper();
|
||||
// buttons
|
||||
@ -62,10 +65,12 @@ private:
|
||||
QString file;
|
||||
Ui::SettingsWindow *ui;
|
||||
void createActions();
|
||||
int indexByToolBarPosition(const Qt::ToolBarArea area);
|
||||
Qt::ToolBarArea indexToToolBarPosition(const int index);
|
||||
// ESC pressed event
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
QMap<QString, QString> readSettings();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
void setSettings(const QMap<QString, QString> config);
|
||||
};
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,18 +19,19 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "calls.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
TrayIcon::TrayIcon(QObject *parent, const bool debugCmd)
|
||||
TrayIcon::TrayIcon(QObject *parent, const QMap<QString, QString> settings, const bool debugCmd)
|
||||
: QSystemTrayIcon(parent),
|
||||
debug(debugCmd)
|
||||
{
|
||||
mainWindow = (MainWindow *)parent;
|
||||
mainWindow = dynamic_cast<MainWindow *>(parent);
|
||||
useHelper = (settings[QString("USE_HELPER")] == QString("true"));
|
||||
|
||||
init();
|
||||
}
|
||||
@ -40,45 +41,10 @@ TrayIcon::~TrayIcon()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
setContextMenu(0);
|
||||
setContextMenu(nullptr);
|
||||
startProfileMenu->clear();
|
||||
switchToProfileMenu->clear();
|
||||
menuActions->clear();
|
||||
delete startProfileMenu;
|
||||
delete switchToProfileMenu;
|
||||
delete menuActions;
|
||||
for (int i=0; i<contextMenu.keys().count(); i++)
|
||||
delete contextMenu[contextMenu.keys()[i]];
|
||||
}
|
||||
|
||||
|
||||
int TrayIcon::showInformation()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (supportsMessages()) {
|
||||
QString title = QApplication::translate("TrayIcon", "netctl status");
|
||||
QStringList info = mainWindow->printInformation();
|
||||
QString message = QString("%1: %2\n").arg(QApplication::translate("TrayIcon", "Profile")).arg(info[0]);
|
||||
message += QString("%1: %2").arg(QApplication::translate("TrayIcon", "Status")).arg(info[1]);
|
||||
showMessage(title, message, QSystemTrayIcon::Information);
|
||||
}
|
||||
else
|
||||
return showInformationInWindow();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int TrayIcon::showInformationInWindow()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString title = QApplication::translate("TrayIcon", "netctl status");
|
||||
QStringList info = mainWindow->printInformation();
|
||||
QString message = QString("%1: %2\n").arg(QApplication::translate("TrayIcon", "Profile")).arg(info[0]);
|
||||
message += QString("%1: %2").arg(QApplication::translate("TrayIcon", "Status")).arg(info[1]);
|
||||
|
||||
return QMessageBox::information(0, title, message);
|
||||
}
|
||||
|
||||
|
||||
@ -86,87 +52,53 @@ void TrayIcon::updateMenu()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QStringList info = mainWindow->printTrayInformation();
|
||||
bool netctlAutoStatus = info[0].toInt();
|
||||
QStringList profiles = info[1].split(QChar('|'));
|
||||
QString current = info[2];
|
||||
QString enabled = info[3];
|
||||
netctlCurrent info = mainWindow->printTrayInformation();
|
||||
|
||||
if (current.isEmpty()) {
|
||||
if (info.current.isEmpty()) {
|
||||
contextMenu[QString("title")]->setIcon(QIcon(QString(":network-offline-64x64")));
|
||||
contextMenu[QString("title")]->setText(QApplication::translate("TrayIcon", "(inactive)"));
|
||||
} else {
|
||||
contextMenu[QString("title")]->setIcon(QIcon(QString(":network-idle-64x64")));
|
||||
QStringList currentProfiles, status;
|
||||
if (netctlAutoStatus) {
|
||||
currentProfiles.append(current);
|
||||
status.append(QApplication::translate("TrayIcon", "(netctl-auto)"));
|
||||
} else {
|
||||
for (int i=0; i<enabled.split(QChar('|')).count(); i++) {
|
||||
currentProfiles.append(current.split(QChar('|'))[i]);
|
||||
if (enabled.split(QChar('|'))[i] == QString("0"))
|
||||
status.append(QApplication::translate("TrayIcon", "static"));
|
||||
else
|
||||
status.append(QApplication::translate("TrayIcon", "enabled"));
|
||||
}
|
||||
}
|
||||
QStringList profiles;
|
||||
for (int i=0; i<currentProfiles.count(); i++)
|
||||
profiles.append(currentProfiles[i] + QString(" (") + status[i] + QString(")"));
|
||||
if (info.netctlAuto)
|
||||
profiles.append(QString("%1 (%2)").arg(info.current[0])
|
||||
.arg(QApplication::translate("TrayIcon", "netctl-auto")));
|
||||
else
|
||||
for (int i=0; i<info.current.count(); i++) {
|
||||
QString status;
|
||||
if (info.enables[i])
|
||||
status = QApplication::translate("TrayIcon", "enabled");
|
||||
else
|
||||
status = QApplication::translate("TrayIcon", "static");
|
||||
profiles.append(QString("%1 (%2)").arg(info.current[i]).arg(status));
|
||||
}
|
||||
contextMenu[QString("title")]->setText(profiles.join(QString(" | ")));
|
||||
}
|
||||
|
||||
if (netctlAutoStatus) {
|
||||
contextMenu[QString("start")]->setVisible(false);
|
||||
contextMenu[QString("stop")]->setVisible(false);
|
||||
contextMenu[QString("stopall")]->setVisible(false);
|
||||
contextMenu[QString("switch")]->setVisible(true);
|
||||
contextMenu[QString("restart")]->setVisible(false);
|
||||
contextMenu[QString("enable")]->setVisible(false);
|
||||
startProfileMenu->menuAction()->setVisible(!info.netctlAuto);
|
||||
contextMenu[QString("stop")]->setVisible(!info.netctlAuto && (info.current.count() == 1));
|
||||
contextMenu[QString("stopall")]->setVisible(!info.netctlAuto && (info.current.count() > 1));
|
||||
switchToProfileMenu->menuAction()->setVisible(info.netctlAuto);
|
||||
contextMenu[QString("restart")]->setVisible(!info.netctlAuto && (info.current.count() == 1));
|
||||
contextMenu[QString("enable")]->setVisible(!info.netctlAuto && (info.current.count() == 1));
|
||||
|
||||
if (info.netctlAuto) {
|
||||
switchToProfileMenu->clear();
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
QAction *profile = new QAction(profiles[i], this);
|
||||
switchToProfileMenu->addAction(profile);
|
||||
}
|
||||
for (int i=0; i<info.profiles.count(); i++)
|
||||
switchToProfileMenu->addAction(info.profiles[i]);
|
||||
} else {
|
||||
if (current.contains(QChar('|'))) {
|
||||
contextMenu[QString("start")]->setVisible(true);
|
||||
contextMenu[QString("stop")]->setVisible(false);
|
||||
contextMenu[QString("stopall")]->setVisible(true);
|
||||
contextMenu[QString("switch")]->setVisible(false);
|
||||
contextMenu[QString("restart")]->setVisible(false);
|
||||
contextMenu[QString("enable")]->setVisible(false);
|
||||
} else {
|
||||
contextMenu[QString("start")]->setVisible(true);
|
||||
contextMenu[QString("stop")]->setVisible(!current.isEmpty());
|
||||
contextMenu[QString("switch")]->setVisible(false);
|
||||
contextMenu[QString("stopall")]->setVisible(false);
|
||||
contextMenu[QString("restart")]->setVisible(!current.isEmpty());
|
||||
contextMenu[QString("enable")]->setVisible(!current.isEmpty());
|
||||
}
|
||||
if (!current.isEmpty()) {
|
||||
contextMenu[QString("start")]->setText(QApplication::translate("TrayIcon", "Start another profile"));
|
||||
contextMenu[QString("stop")]->setText(QApplication::translate("TrayIcon", "Stop %1").arg(current));
|
||||
contextMenu[QString("restart")]->setText(QApplication::translate("TrayIcon", "Restart %1").arg(current));
|
||||
if (enabled.split(QChar('|'))[0].toInt())
|
||||
contextMenu[QString("enable")]->setText(QApplication::translate("TrayIcon", "Disable %1").arg(current));
|
||||
if (info.current.count() == 1) {
|
||||
contextMenu[QString("stop")]->setText(QApplication::translate("TrayIcon", "Stop %1").arg(info.current[0]));
|
||||
contextMenu[QString("restart")]->setText(QApplication::translate("TrayIcon", "Restart %1").arg(info.current[0]));
|
||||
if (info.enables[0])
|
||||
contextMenu[QString("enable")]->setText(QApplication::translate("TrayIcon", "Disable %1").arg(info.current[0]));
|
||||
else
|
||||
contextMenu[QString("enable")]->setText(QApplication::translate("TrayIcon", "Enable %1").arg(current));
|
||||
} else
|
||||
contextMenu[QString("start")]->setText(QApplication::translate("TrayIcon", "Start profile"));
|
||||
startProfileMenu->clear();
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
QAction *profile = new QAction(profiles[i], this);
|
||||
startProfileMenu->addAction(profile);
|
||||
contextMenu[QString("enable")]->setText(QApplication::translate("TrayIcon", "Enable %1").arg(info.current[0]));
|
||||
}
|
||||
startProfileMenu->clear();
|
||||
for (int i=0; i<info.profiles.count(); i++)
|
||||
startProfileMenu->addAction(info.profiles[i]);
|
||||
}
|
||||
|
||||
if (mainWindow->isHidden())
|
||||
contextMenu[QString("gui")]->setText(QApplication::translate("TrayIcon", "Show"));
|
||||
else
|
||||
contextMenu[QString("gui")]->setText(QApplication::translate("TrayIcon", "Hide"));
|
||||
|
||||
setContextMenu(menuActions);
|
||||
}
|
||||
|
||||
|
||||
@ -176,55 +108,43 @@ void TrayIcon::createActions()
|
||||
|
||||
menuActions = new QMenu();
|
||||
|
||||
contextMenu[QString("title")] = new QAction(QIcon(":icon"), QApplication::translate("TrayIcon", "Status"), this);
|
||||
menuActions->addAction(contextMenu[QString("title")]);
|
||||
connect(contextMenu[QString("title")], SIGNAL(triggered(bool)), this, SLOT(showInformationInWindow()));
|
||||
|
||||
contextMenu[QString("title")] = menuActions->addAction(QIcon(":icon"),
|
||||
QApplication::translate("TrayIcon", "Status"),
|
||||
mainWindow,
|
||||
SLOT(showMainWindow()));
|
||||
menuActions->addSeparator();
|
||||
|
||||
contextMenu[QString("start")] = new QAction(QIcon::fromTheme("system-run"), QApplication::translate("TrayIcon", "Start profile"), this);
|
||||
startProfileMenu = new QMenu();
|
||||
contextMenu[QString("start")]->setMenu(startProfileMenu);
|
||||
connect(startProfileMenu, SIGNAL(triggered(QAction *)), this, SLOT(startProfileSlot(QAction *)));
|
||||
menuActions->addAction(contextMenu[QString("start")]);
|
||||
startProfileMenu = menuActions->addMenu(QIcon::fromTheme("system-run"),
|
||||
QApplication::translate("TrayIcon", "Start profile"));
|
||||
connect(startProfileMenu, SIGNAL(triggered(QAction *)), this, SLOT(startProfileTraySlot(QAction *)));
|
||||
|
||||
contextMenu[QString("stop")] = new QAction(QIcon::fromTheme("process-stop"), QApplication::translate("TrayIcon", "Stop profile"), this);
|
||||
connect(contextMenu[QString("stop")], SIGNAL(triggered(bool)), this, SLOT(stopProfileSlot()));
|
||||
menuActions->addAction(contextMenu[QString("stop")]);
|
||||
contextMenu[QString("stop")] = menuActions->addAction(QIcon::fromTheme("process-stop"),
|
||||
QApplication::translate("TrayIcon", "Stop profile"),
|
||||
this,
|
||||
SLOT(startProfileTraySlot()));
|
||||
contextMenu[QString("stopall")] = menuActions->addAction(QIcon::fromTheme("process-stop"),
|
||||
QApplication::translate("TrayIcon", "Stop all profiles"),
|
||||
this,
|
||||
SLOT(stopAllProfilesTraySlot()));
|
||||
|
||||
contextMenu[QString("stopall")] = new QAction(QIcon::fromTheme("process-stop"), QApplication::translate("TrayIcon", "Stop all profiles"), this);
|
||||
connect(contextMenu[QString("stopall")], SIGNAL(triggered(bool)), this, SLOT(stopAllProfilesSlot()));
|
||||
menuActions->addAction(contextMenu[QString("stopall")]);
|
||||
|
||||
contextMenu[QString("switch")] = new QAction(QIcon::fromTheme("system-run"), QApplication::translate("TrayIcon", "Switch to profile"), this);
|
||||
switchToProfileMenu = new QMenu();
|
||||
contextMenu[QString("switch")]->setMenu(switchToProfileMenu);
|
||||
connect(switchToProfileMenu, SIGNAL(triggered(QAction *)), this, SLOT(switchToProfileSlot(QAction *)));
|
||||
menuActions->addAction(contextMenu[QString("switch")]);
|
||||
|
||||
contextMenu[QString("restart")] = new QAction(QIcon::fromTheme("stock-refresh"), QApplication::translate("TrayIcon", "Restart profile"), this);
|
||||
connect(contextMenu[QString("restart")], SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot()));
|
||||
menuActions->addAction(contextMenu[QString("restart")]);
|
||||
|
||||
contextMenu[QString("enable")] = new QAction(QApplication::translate("TrayIcon", "Enable profile"), this);
|
||||
connect(contextMenu[QString("enable")], SIGNAL(triggered(bool)), this, SLOT(enableProfileSlot()));
|
||||
menuActions->addAction(contextMenu[QString("enable")]);
|
||||
switchToProfileMenu = menuActions->addMenu(QIcon::fromTheme("system-run"),
|
||||
QApplication::translate("TrayIcon", "Switch to profile"));
|
||||
connect(switchToProfileMenu, SIGNAL(triggered(QAction *)), this, SLOT(switchToProfileTraySlot(QAction *)));
|
||||
|
||||
contextMenu[QString("restart")] = menuActions->addAction(QIcon::fromTheme("view-refresh"),
|
||||
QApplication::translate("TrayIcon", "Restart profile"),
|
||||
this,
|
||||
SLOT(restartProfileTraySlot()));
|
||||
contextMenu[QString("enable")] = menuActions->addAction(QIcon::fromTheme("list-add"),
|
||||
QApplication::translate("TrayIcon", "Enable profile"),
|
||||
this,
|
||||
SLOT(enableProfileTraySlot()));
|
||||
menuActions->addSeparator();
|
||||
|
||||
contextMenu[QString("gui")] = new QAction(QApplication::translate("TrayIcon", "Show"), this);
|
||||
connect(contextMenu[QString("gui")], SIGNAL(triggered(bool)), mainWindow, SLOT(showMainWindow()));
|
||||
menuActions->addAction(contextMenu[QString("gui")]);
|
||||
|
||||
contextMenu[QString("auto")] = new QAction(QApplication::translate("TrayIcon", "Show netctl-auto"), this);
|
||||
connect(contextMenu[QString("auto")], SIGNAL(triggered(bool)), mainWindow, SLOT(showNetctlAutoWindow()));
|
||||
menuActions->addAction(contextMenu[QString("auto")]);
|
||||
|
||||
menuActions->addSeparator();
|
||||
|
||||
contextMenu[QString("quit")] = new QAction(QApplication::translate("TrayIcon", "Quit"), this);
|
||||
connect(contextMenu[QString("quit")], SIGNAL(triggered(bool)), mainWindow, SLOT(closeMainWindow()));
|
||||
menuActions->addAction(contextMenu[QString("quit")]);
|
||||
contextMenu[QString("quit")] = menuActions->addAction(QIcon::fromTheme("application-exit"),
|
||||
QApplication::translate("TrayIcon", "Quit"),
|
||||
mainWindow,
|
||||
SLOT(closeMainWindow()));
|
||||
}
|
||||
|
||||
|
||||
@ -236,6 +156,7 @@ void TrayIcon::init()
|
||||
setToolTip(QString("netctl-gui"));
|
||||
|
||||
createActions();
|
||||
setContextMenu(menuActions);
|
||||
|
||||
connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||
this, SLOT(itemActivated(QSystemTrayIcon::ActivationReason)));
|
||||
@ -249,14 +170,9 @@ void TrayIcon::itemActivated(const QSystemTrayIcon::ActivationReason reason)
|
||||
|
||||
switch (reason) {
|
||||
case QSystemTrayIcon::Trigger:
|
||||
showInformation();
|
||||
break;
|
||||
case QSystemTrayIcon::DoubleClick:
|
||||
mainWindow->showMainWindow();
|
||||
break;
|
||||
case QSystemTrayIcon::Context:
|
||||
// clear menu before update
|
||||
setContextMenu(0);
|
||||
updateMenu();
|
||||
break;
|
||||
default:
|
||||
@ -265,59 +181,59 @@ void TrayIcon::itemActivated(const QSystemTrayIcon::ActivationReason reason)
|
||||
}
|
||||
|
||||
|
||||
bool TrayIcon::enableProfileSlot()
|
||||
void TrayIcon::enableProfileTraySlot()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile = mainWindow->printInformation()[0];
|
||||
QStringList profiles = mainWindow->printTrayInformation().current;
|
||||
if (profiles.isEmpty()) return;
|
||||
|
||||
return mainWindow->enableProfileSlot(profile);
|
||||
enableProfileSlot(profiles[0], mainWindow->netctlInterface, useHelper, debug);
|
||||
}
|
||||
|
||||
|
||||
bool TrayIcon::restartProfileSlot()
|
||||
void TrayIcon::restartProfileTraySlot()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile = mainWindow->printInformation()[0];
|
||||
QStringList profiles = mainWindow->printTrayInformation().current;
|
||||
if (profiles.isEmpty()) return;
|
||||
|
||||
return mainWindow->restartProfileSlot(profile);
|
||||
restartProfileSlot(profiles[0], mainWindow->netctlInterface, useHelper, debug);
|
||||
}
|
||||
|
||||
|
||||
bool TrayIcon::startProfileSlot(QAction *action)
|
||||
void TrayIcon::startProfileTraySlot(QAction *action)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile = action->text().remove(QChar('&'));
|
||||
QString profile;
|
||||
if (action == nullptr) {
|
||||
QStringList profiles = mainWindow->printTrayInformation().current;
|
||||
if (profiles.isEmpty()) return;
|
||||
profile = profiles[0];
|
||||
} else
|
||||
profile = action->text().remove(QChar('&'));
|
||||
|
||||
return mainWindow->switchToProfileSlot(profile);
|
||||
startProfileSlot(profile, mainWindow->netctlInterface, useHelper, debug);
|
||||
}
|
||||
|
||||
|
||||
bool TrayIcon::stopProfileSlot()
|
||||
void TrayIcon::stopAllProfilesTraySlot()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile = mainWindow->printInformation()[0];
|
||||
|
||||
return mainWindow->startProfileSlot(profile);
|
||||
stopAllProfilesSlot(mainWindow->netctlInterface, useHelper, debug);
|
||||
}
|
||||
|
||||
|
||||
bool TrayIcon::stopAllProfilesSlot()
|
||||
void TrayIcon::switchToProfileTraySlot(QAction *action)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (action == nullptr) return;
|
||||
|
||||
return mainWindow->stopAllProfilesSlot();
|
||||
}
|
||||
|
||||
|
||||
bool TrayIcon::switchToProfileSlot(QAction *action)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
QString profile = action->text().remove(QChar('&'));
|
||||
|
||||
return mainWindow->switchToProfileSlot(profile);
|
||||
QStringList profiles = mainWindow->printTrayInformation().current;
|
||||
if (profiles.isEmpty()) return;
|
||||
|
||||
switchToProfileSlot(profiles[0], mainWindow->netctlInterface, useHelper, debug);
|
||||
}
|
||||
|
@ -31,25 +31,24 @@ class TrayIcon : public QSystemTrayIcon
|
||||
|
||||
public:
|
||||
explicit TrayIcon(QObject *parent = 0,
|
||||
const QMap<QString,QString> settings = QMap<QString,QString>(),
|
||||
const bool debugCmd = false);
|
||||
~TrayIcon();
|
||||
|
||||
public slots:
|
||||
int showInformation();
|
||||
int showInformationInWindow();
|
||||
void updateMenu();
|
||||
|
||||
private slots:
|
||||
void itemActivated(const QSystemTrayIcon::ActivationReason reason);
|
||||
bool enableProfileSlot();
|
||||
bool restartProfileSlot();
|
||||
bool startProfileSlot(QAction *action);
|
||||
bool stopProfileSlot();
|
||||
bool stopAllProfilesSlot();
|
||||
bool switchToProfileSlot(QAction *action);
|
||||
void enableProfileTraySlot();
|
||||
void restartProfileTraySlot();
|
||||
void startProfileTraySlot(QAction *action = nullptr);
|
||||
void stopAllProfilesTraySlot();
|
||||
void switchToProfileTraySlot(QAction *action);
|
||||
|
||||
private:
|
||||
bool debug;
|
||||
bool useHelper = true;
|
||||
MainWindow *mainWindow;
|
||||
// contextual actions
|
||||
QMenu *menuActions;
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "tunnelwidget.h"
|
||||
#include "ui_tunnelwidget.h"
|
||||
|
||||
#include "ipregexp.h"
|
||||
|
||||
|
||||
TunnelWidget::TunnelWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
@ -40,68 +42,41 @@ 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();
|
||||
ui->lineEdit_key->clear();
|
||||
}
|
||||
|
||||
|
||||
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('.'));
|
||||
ui->lineEdit_local->setValidator(IpRegExp::ipv4Validator());
|
||||
ui->lineEdit_remote->setValidator(IpRegExp::ipv4Validator());
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> TunnelWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> tunnelSettings;
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return tunnelSettings;
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
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("'");
|
||||
settings[QString("Mode")] = QString("'%1'").arg(ui->comboBox_mode->currentText());
|
||||
if (!IpRegExp::checkString(ui->lineEdit_local->text(), IpRegExp::ip4Regex()))
|
||||
settings[QString("Local")] = QString("'%1'").arg(ui->lineEdit_local->text());
|
||||
settings[QString("Remote")] = QString("'%1'").arg(ui->lineEdit_remote->text());
|
||||
if (ui->comboBox_mode->currentText() == QString("gre"))
|
||||
settings[QString("Key")] = QString("'%1'").arg(ui->lineEdit_key->text());
|
||||
|
||||
return tunnelSettings;
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
int TunnelWidget::isOk()
|
||||
{
|
||||
// ip is not correct
|
||||
if (!IpRegExp::checkString(ui->lineEdit_remote->text(), IpRegExp::ip4Regex())) return 1;
|
||||
// key is empty
|
||||
if (ui->comboBox_mode->currentText() == QString("gre"))
|
||||
if (ui->lineEdit_key->text().isEmpty()) return 2;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
@ -110,14 +85,15 @@ int TunnelWidget::isOk()
|
||||
void TunnelWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> tunnelSettings = settings;
|
||||
|
||||
if (tunnelSettings.contains(QString("Mode")))
|
||||
for (int i=0; i<ui->comboBox_mode->count(); i++)
|
||||
if (tunnelSettings[QString("Mode")] == 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")]);
|
||||
if (settings.contains(QString("Mode"))) {
|
||||
int index = ui->comboBox_mode->findText(settings[QString("Mode")]);
|
||||
ui->comboBox_mode->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("Local")))
|
||||
ui->lineEdit_local->setText(settings[QString("Local")]);
|
||||
if (settings.contains(QString("Remote")))
|
||||
ui->lineEdit_remote->setText(settings[QString("Remote")]);
|
||||
if (settings.contains(QString("Key")))
|
||||
ui->lineEdit_key->setText(settings[QString("Key")]);
|
||||
}
|
||||
|
@ -38,12 +38,10 @@ public:
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private:
|
||||
Ui::TunnelWidget *ui;
|
||||
void createFilter();
|
||||
QString getIp(const QString rawIp);
|
||||
};
|
||||
|
||||
|
||||
|
@ -7,13 +7,13 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>411</width>
|
||||
<height>146</height>
|
||||
<height>137</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_tunnel">
|
||||
<property name="features">
|
||||
@ -24,23 +24,35 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_tunnel">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The tunnel type</string>
|
||||
</property>
|
||||
@ -92,19 +104,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Local</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_local">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The address of the local end of the tunnel</string>
|
||||
</property>
|
||||
@ -116,19 +137,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remote</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_remote">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The address of the remote end of the tunnel</string>
|
||||
</property>
|
||||
@ -136,6 +166,39 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_key">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_key">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_key">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>A key identifying an individual traffic flow within a tunnel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -42,38 +42,26 @@ void TuntapWidget::clear()
|
||||
}
|
||||
|
||||
|
||||
void TuntapWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> TuntapWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> tuntapSettings;
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return tuntapSettings;
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
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("'");
|
||||
settings[QString("Mode")] = QString("'%1'").arg(ui->comboBox_mode->currentText());
|
||||
settings[QString("User")] = QString("'%1'").arg(ui->lineEdit_user->text());
|
||||
settings[QString("Group")] = QString("'%1'").arg(ui->lineEdit_group->text());
|
||||
|
||||
return tuntapSettings;
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
int TuntapWidget::isOk()
|
||||
{
|
||||
// empty username
|
||||
if (ui->lineEdit_user->text().isEmpty())
|
||||
return 1;
|
||||
if (ui->lineEdit_user->text().isEmpty()) return 1;
|
||||
// empty group name
|
||||
if (ui->lineEdit_group->text().isEmpty())
|
||||
return 2;
|
||||
if (ui->lineEdit_group->text().isEmpty()) return 2;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
@ -82,14 +70,13 @@ int TuntapWidget::isOk()
|
||||
void TuntapWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
clear();
|
||||
QMap<QString, QString> tuntapSettings = settings;
|
||||
|
||||
if (tuntapSettings.contains(QString("Mode")))
|
||||
for (int i=0; i<ui->comboBox_mode->count(); i++)
|
||||
if (tuntapSettings[QString("Mode")] == 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")]);
|
||||
if (settings.contains(QString("Mode"))) {
|
||||
int index = ui->comboBox_mode->findText(settings[QString("Mode")]);
|
||||
ui->comboBox_mode->setCurrentIndex(index);
|
||||
}
|
||||
if (settings.contains(QString("User")))
|
||||
ui->lineEdit_user->setText(settings[QString("User")]);
|
||||
if (settings.contains(QString("Group")))
|
||||
ui->lineEdit_group->setText(settings[QString("Group")]);
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private:
|
||||
Ui::TuntapWidget *ui;
|
||||
|
@ -7,13 +7,13 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>424</width>
|
||||
<height>146</height>
|
||||
<height>108</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_tuntap">
|
||||
<property name="features">
|
||||
@ -24,23 +24,35 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_tuntap">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Either ‘tun’, or ‘tap’</string>
|
||||
</property>
|
||||
@ -62,19 +74,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>User</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_user">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The owning user of the tun/tap interface</string>
|
||||
</property>
|
||||
@ -86,19 +107,28 @@
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Group</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_group">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The owning group of the tun/tap interface</string>
|
||||
</property>
|
||||
|
@ -40,25 +40,15 @@ void VlanWidget::clear()
|
||||
}
|
||||
|
||||
|
||||
void VlanWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> VlanWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> vlanSettings;
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return vlanSettings;
|
||||
if (isOk() != 0) return settings;
|
||||
|
||||
vlanSettings[QString("VLANID")] = QString::number(ui->spinBox_vlan->value());
|
||||
settings[QString("VLANID")] = QString::number(ui->spinBox_vlan->value());
|
||||
|
||||
return vlanSettings;
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
@ -72,8 +62,7 @@ int VlanWidget::isOk()
|
||||
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());
|
||||
if (settings.contains(QString("VLANID")))
|
||||
ui->spinBox_vlan->setValue(settings[QString("VLANID")].toInt());
|
||||
}
|
||||
|
@ -38,7 +38,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private:
|
||||
Ui::VlanWidget *ui;
|
||||
|
@ -7,13 +7,13 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>393</width>
|
||||
<height>81</height>
|
||||
<height>46</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_vlan">
|
||||
<property name="features">
|
||||
@ -24,23 +24,35 @@
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_vlan">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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 name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>vlan ID</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_vlan">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>vlan identifier</string>
|
||||
</property>
|
||||
|
450
sources/gui/src/wifimenuwidget.cpp
Normal file
450
sources/gui/src/wifimenuwidget.cpp
Normal file
@ -0,0 +1,450 @@
|
||||
/***************************************************************************
|
||||
* 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 "wifimenuwidget.h"
|
||||
#include "ui_wifimenuwidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "calls.h"
|
||||
#include "commonfunctions.h"
|
||||
#include "dbusoperation.h"
|
||||
#include "errorwindow.h"
|
||||
#include "mainwindow.h"
|
||||
#include "passwdwidget.h"
|
||||
|
||||
|
||||
WiFiMenuWidget::WiFiMenuWidget(QWidget *parent, const QMap<QString, QString> settings, const bool debugCmd)
|
||||
: QMainWindow(parent),
|
||||
debug(debugCmd),
|
||||
configuration(settings)
|
||||
{
|
||||
mainWindow = dynamic_cast<MainWindow *>(parent);
|
||||
useHelper = (configuration[QString("USE_HELPER")] == QString("true"));
|
||||
|
||||
// windows
|
||||
ui = new Ui::WiFiMenuWidget;
|
||||
ui->setupUi(this);
|
||||
ui->tableWidget_wifi->setColumnHidden(5, true);
|
||||
ui->tableWidget_wifi->setColumnHidden(6, true);
|
||||
updateToolBarState(static_cast<Qt::ToolBarArea>(configuration[QString("WIFI_TOOLBAR")].toInt()));
|
||||
|
||||
// auto update
|
||||
timer.setSingleShot(true);
|
||||
timer.setInterval(configuration[QString("WIFIUPDATE")].toInt() * 1000);
|
||||
|
||||
createActions();
|
||||
}
|
||||
|
||||
|
||||
WiFiMenuWidget::~WiFiMenuWidget()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (ui != nullptr) delete ui;
|
||||
}
|
||||
|
||||
|
||||
Qt::ToolBarArea WiFiMenuWidget::getToolBarArea()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return toolBarArea(ui->toolBar);
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::update()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
if (mainWindow->currentTab() == 2) {
|
||||
updateWifiTab();
|
||||
updateMenuWifi();
|
||||
}
|
||||
|
||||
if (timer.interval() != 0) return timer.start();
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::updateToolBarState(const Qt::ToolBarArea area)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Toolbar area" << area;
|
||||
|
||||
removeToolBar(ui->toolBar);
|
||||
if (area != Qt::NoToolBarArea) {
|
||||
addToolBar(area, ui->toolBar);
|
||||
ui->toolBar->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool WiFiMenuWidget::wifiTabSelectEssidSlot(const QString essid)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Essid" << essid;
|
||||
|
||||
for (int i=0; i<ui->tableWidget_wifi->rowCount(); i++) {
|
||||
if (ui->tableWidget_wifi->item(i, 0)->text() != essid) continue;
|
||||
ui->tableWidget_wifi->setCurrentCell(i, 0);
|
||||
}
|
||||
return (ui->tableWidget_wifi->currentItem() != nullptr);
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::connectToUnknownEssid(const QString passwd)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_wifi->currentItem() == nullptr) return;
|
||||
if (passwdWid != nullptr) delete passwdWid;
|
||||
|
||||
QMap<QString, QString> settings;
|
||||
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 2)->text();
|
||||
if (security.contains(QString("WPA")))
|
||||
settings[QString("Security")] = QString("wpa");
|
||||
else if (security.contains(QString("WEP")))
|
||||
settings[QString("Security")] = QString("wep");
|
||||
else
|
||||
settings[QString("Security")] = QString("none");
|
||||
if (!passwd.isEmpty())
|
||||
settings[QString("Key")] = QString("'%1'").arg(passwd);
|
||||
if (hiddenNetwork)
|
||||
settings[QString("Hidden")] = QString("yes");
|
||||
QString essid = QString("'%1'").arg(ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text());
|
||||
InterfaceAnswer answer = connectToEssid(essid, settings, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
|
||||
QString profile = QString("netctl-gui-%1").arg(essid);
|
||||
profile.remove(QChar('"')).remove(QChar('\''));
|
||||
QString message;
|
||||
if (answer == InterfaceAnswer::True) {
|
||||
message = QApplication::translate("MainWindow", "Connection is successfully");
|
||||
mainWindow->showMessage(true);
|
||||
} else {
|
||||
message = QApplication::translate("MainWindow", "Connection failed");
|
||||
mainWindow->showMessage(false);
|
||||
}
|
||||
message += QString("\n");
|
||||
message += QApplication::translate("MainWindow", "Do you want to save profile %1?").arg(profile);
|
||||
int select = QMessageBox::question(this, QApplication::translate("MainWindow", "WiFi menu"),
|
||||
message, QMessageBox::Save | QMessageBox::Discard, QMessageBox::Save);
|
||||
|
||||
switch (select) {
|
||||
case QMessageBox::Save:
|
||||
break;
|
||||
case QMessageBox::Discard:
|
||||
default:
|
||||
removeProfileSlot(profile, mainWindow->netctlInterface, useHelper, debug);
|
||||
break;
|
||||
}
|
||||
|
||||
updateWifiTab();
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::setHiddenName(const QString name)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Set name" << name;
|
||||
|
||||
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->setText(name);
|
||||
|
||||
wifiTabStart();
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::updateMenuWifi()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
bool selected = (ui->tableWidget_wifi->currentItem() != nullptr);
|
||||
ui->actionStart->setEnabled(selected);
|
||||
if (selected && ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 5)->text().isEmpty()) {
|
||||
ui->actionStart->setText(QApplication::translate("WiFiMenuWidget", "Start"));
|
||||
ui->actionStart->setIcon(QIcon::fromTheme("system-run"));
|
||||
} else {
|
||||
ui->actionStart->setText(QApplication::translate("WiFiMenuWidget", "Stop"));
|
||||
ui->actionStart->setIcon(QIcon::fromTheme("process-stop"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::updateText(const netctlWifiInfo current)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!wifiTabSetEnabled(checkExternalApps(QString("wpasup-only"), configuration, debug))) return;
|
||||
|
||||
QString text = QString("");
|
||||
if (!current.macs.isEmpty()) {
|
||||
text += QString("%1 - %2 - %3 ").arg(current.name).arg(current.security).arg(current.macs[0]);
|
||||
text += QString("(%1 %2)").arg(current.frequencies[0]).arg(QApplication::translate("WiFiMenuWidget", "MHz"));
|
||||
}
|
||||
|
||||
ui->label_wifi->setText(text);
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::updateWifiTab()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!wifiTabSetEnabled(checkExternalApps(QString("wpasup-only"), configuration, debug))) return;
|
||||
if (!checkExternalApps(QString("wpasup"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("wpasup"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
QList<netctlWifiInfo> scanResults;
|
||||
if (useHelper)
|
||||
scanResults = parseOutputWifi(sendRequestToCtrl(QString("VerboseWiFi"), debug));
|
||||
else
|
||||
scanResults = mainWindow->wpaCommand->scanWifi();
|
||||
|
||||
ui->tableWidget_wifi->setSortingEnabled(false);
|
||||
ui->tableWidget_wifi->selectRow(-1);
|
||||
ui->tableWidget_wifi->sortByColumn(3, Qt::AscendingOrder);
|
||||
ui->tableWidget_wifi->clear();
|
||||
// -1 because the first is always current point
|
||||
ui->tableWidget_wifi->setRowCount(scanResults.count() - 1);
|
||||
|
||||
// create header
|
||||
QStringList headerList;
|
||||
headerList.append(QApplication::translate("WiFiMenuWidget", "Name"));
|
||||
headerList.append(QApplication::translate("WiFiMenuWidget", "Type"));
|
||||
headerList.append(QApplication::translate("WiFiMenuWidget", "# of points"));
|
||||
headerList.append(QApplication::translate("WiFiMenuWidget", "Signal"));
|
||||
headerList.append(QApplication::translate("WiFiMenuWidget", "Security"));
|
||||
headerList.append(QApplication::translate("WiFiMenuWidget", "Active"));
|
||||
headerList.append(QApplication::translate("WiFiMenuWidget", "Exists"));
|
||||
ui->tableWidget_wifi->setHorizontalHeaderLabels(headerList);
|
||||
// create items
|
||||
netctlWifiInfo current = scanResults.isEmpty() ? netctlWifiInfo() : scanResults.takeFirst();
|
||||
for (int i=0; i<scanResults.count(); i++) {
|
||||
// font
|
||||
QFont font;
|
||||
font.setBold(scanResults[i].active);
|
||||
font.setItalic(scanResults[i].exists);
|
||||
// type
|
||||
QString type;
|
||||
switch (scanResults[i].type) {
|
||||
case PointType::TwoG:
|
||||
type = QApplication::translate("WiFiMenuWidget", "2GHz");
|
||||
break;
|
||||
case PointType::FiveG:
|
||||
type = QApplication::translate("WiFiMenuWidget", "5GHz");
|
||||
break;
|
||||
case PointType::TwoAndFiveG:
|
||||
type = QApplication::translate("WiFiMenuWidget", "2GHz and 5GHz");
|
||||
break;
|
||||
case PointType::None:
|
||||
default:
|
||||
type = QApplication::translate("WiFiMenuWidget", "N\\A");
|
||||
break;
|
||||
}
|
||||
// tooltip
|
||||
QString toolTip = QString("");
|
||||
for (int j=0; j<scanResults[i].macs.count(); j++)
|
||||
toolTip += QString("%1 %2: %3 (%4 %5)\n").arg(QApplication::translate("WiFiMenuWidget", "Point"))
|
||||
.arg(j + 1)
|
||||
.arg(scanResults[i].macs[j])
|
||||
.arg(scanResults[i].frequencies[j])
|
||||
.arg(QApplication::translate("WiFiMenuWidget", "MHz"));
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("WiFiMenuWidget", "Type"))
|
||||
.arg(type);
|
||||
toolTip += QString("%1: %2\n").arg(QApplication::translate("WiFiMenuWidget", "Active"))
|
||||
.arg(checkStatus(scanResults[i].active));
|
||||
toolTip += QString("%1: %2").arg(QApplication::translate("WiFiMenuWidget", "Exists"))
|
||||
.arg(checkStatus(scanResults[i].exists));
|
||||
// name
|
||||
ui->tableWidget_wifi->setItem(i, 0, new QTableWidgetItem(scanResults[i].name));
|
||||
ui->tableWidget_wifi->item(i, 0)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
||||
ui->tableWidget_wifi->item(i, 0)->setToolTip(toolTip);
|
||||
ui->tableWidget_wifi->item(i, 0)->setFont(font);
|
||||
// type
|
||||
ui->tableWidget_wifi->setItem(i, 1, new QTableWidgetItem(type));
|
||||
ui->tableWidget_wifi->item(i, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui->tableWidget_wifi->item(i, 1)->setToolTip(toolTip);
|
||||
// count
|
||||
ui->tableWidget_wifi->setItem(i, 2, new QTableWidgetItem(QString::number(scanResults[i].frequencies.count())));
|
||||
ui->tableWidget_wifi->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui->tableWidget_wifi->item(i, 2)->setToolTip(toolTip);
|
||||
// signal
|
||||
ui->tableWidget_wifi->setItem(i, 3, new QTableWidgetItem(QString::number(scanResults[i].signal)));
|
||||
ui->tableWidget_wifi->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui->tableWidget_wifi->item(i, 3)->setToolTip(toolTip);
|
||||
// security
|
||||
ui->tableWidget_wifi->setItem(i, 4, new QTableWidgetItem(scanResults[i].security));
|
||||
ui->tableWidget_wifi->item(i, 4)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
ui->tableWidget_wifi->item(i, 4)->setToolTip(toolTip);
|
||||
// active
|
||||
ui->tableWidget_wifi->setItem(i, 5, new QTableWidgetItem(checkStatus(scanResults[i].active, true)));
|
||||
ui->tableWidget_wifi->item(i, 5)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
// exists
|
||||
ui->tableWidget_wifi->setItem(i, 6, new QTableWidgetItem(checkStatus(scanResults[i].exists, true)));
|
||||
ui->tableWidget_wifi->item(i, 6)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
ui->tableWidget_wifi->setSortingEnabled(true);
|
||||
|
||||
ui->tableWidget_wifi->resizeRowsToContents();
|
||||
ui->tableWidget_wifi->resizeColumnsToContents();
|
||||
ui->tableWidget_wifi->resizeRowsToContents();
|
||||
#if QT_VERSION >= 0x050000
|
||||
ui->tableWidget_wifi->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
#else
|
||||
ui->tableWidget_wifi->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||
#endif
|
||||
|
||||
updateText(current);
|
||||
mainWindow->setDisabled(false);
|
||||
mainWindow->showMessage(true);
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::wifiTabContextualMenu(const QPoint &pos)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (ui->tableWidget_wifi->currentItem() == nullptr) return;
|
||||
|
||||
// create menu
|
||||
QMenu menu(this);
|
||||
QAction *refreshTable = menu.addAction(QApplication::translate("WiFiMenuWidget", "Refresh"));
|
||||
refreshTable->setIcon(QIcon::fromTheme("view-refresh"));
|
||||
menu.addSeparator();
|
||||
QAction *startWifi = menu.addAction(QApplication::translate("WiFiMenuWidget", "Start WiFi"));
|
||||
|
||||
// set text
|
||||
if (ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 5)->text().isEmpty()) {
|
||||
startWifi->setText(QApplication::translate("WiFiMenuWidget", "Start WiFi"));
|
||||
startWifi->setIcon(QIcon::fromTheme("system-run"));
|
||||
|
||||
} else {
|
||||
startWifi->setText(QApplication::translate("WiFiMenuWidget", "Stop WiFi"));
|
||||
startWifi->setIcon(QIcon::fromTheme("process-stop"));
|
||||
}
|
||||
|
||||
// actions
|
||||
QAction *action = menu.exec(ui->tableWidget_wifi->viewport()->mapToGlobal(pos));
|
||||
if (action == refreshTable) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Refresh WiFi";
|
||||
updateWifiTab();
|
||||
} else if (action == startWifi) {
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Start WiFi";
|
||||
wifiTabStart();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool WiFiMenuWidget::wifiTabSetEnabled(const bool state)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "State" << state;
|
||||
|
||||
ui->actionFunc->setEnabled(!state);
|
||||
ui->tableWidget_wifi->setEnabled(state);
|
||||
if (!state) ui->label_wifi->setText(QApplication::translate("WiFiMenuWidget", "Please install 'wpa_supplicant' before use it"));
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
int WiFiMenuWidget::wifiTabShowInfo()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
return QMessageBox::information(this, QApplication::translate("WiFiMenuWidget", "Information"),
|
||||
QApplication::translate("WiFiMenuWidget", "This isn't the functionality you're looking for"));
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::wifiTabStart()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (!checkExternalApps(QString("netctl"), configuration, debug)) {
|
||||
ErrorWindow::showWindow(1, externalApps(QString("netctl"), configuration).join(QChar('\n')), debug);
|
||||
return mainWindow->emitNeedToBeConfigured();
|
||||
}
|
||||
if (ui->tableWidget_wifi->currentItem() == nullptr) return;
|
||||
|
||||
mainWindow->setDisabled(true);
|
||||
|
||||
// name is hidden
|
||||
if (ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() == QString("<hidden>")) {
|
||||
hiddenNetwork = true;
|
||||
passwdWid = new PasswdWidget(this);
|
||||
passwdWid->setPassword(false);
|
||||
int widgetWidth = 2 * width() / 3;
|
||||
int widgetHeight = 110;
|
||||
int x = (width() - widgetWidth) / 2;
|
||||
int y = (height() - widgetHeight) / 2;
|
||||
passwdWid->setGeometry(x, y, widgetWidth, widgetHeight);
|
||||
passwdWid->show();
|
||||
passwdWid->setFocusToLineEdit();
|
||||
return;
|
||||
}
|
||||
|
||||
// name isn't hidden
|
||||
hiddenNetwork = false;
|
||||
QString profile = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text();
|
||||
if (!ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 6)->text().isEmpty()) {
|
||||
InterfaceAnswer answer = startProfileSlot(profile, mainWindow->netctlInterface,
|
||||
useHelper, debug);
|
||||
mainWindow->showMessage(answer == InterfaceAnswer::True);
|
||||
} else {
|
||||
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text();
|
||||
if (security == QString("none")) return connectToUnknownEssid(QString(""));
|
||||
else {
|
||||
passwdWid = new PasswdWidget(this);
|
||||
passwdWid->setPassword(true);
|
||||
int widgetWidth = 2 * width() / 3;
|
||||
int widgetHeight = 110;
|
||||
int x = (width() - widgetWidth) / 2;
|
||||
int y = (height() - widgetHeight) / 2;
|
||||
passwdWid->setGeometry(x, y, widgetWidth, widgetHeight);
|
||||
passwdWid->show();
|
||||
passwdWid->setFocusToLineEdit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
updateWifiTab();
|
||||
}
|
||||
|
||||
|
||||
void WiFiMenuWidget::createActions()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// menu actions
|
||||
connect(&timer, SIGNAL(timeout()), this, SLOT(update()));
|
||||
connect(ui->actionFunc, SIGNAL(triggered(bool)), this, SLOT(wifiTabShowInfo()));
|
||||
connect(ui->actionRefresh, SIGNAL(triggered(bool)), this, SLOT(updateWifiTab()));
|
||||
connect(ui->actionStart, SIGNAL(triggered(bool)), this, SLOT(wifiTabStart()));
|
||||
// wifi tab events
|
||||
connect(ui->tableWidget_wifi, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(wifiTabStart()));
|
||||
connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)),
|
||||
this, SLOT(updateMenuWifi()));
|
||||
connect(ui->tableWidget_wifi, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(wifiTabContextualMenu(QPoint)));
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user