mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 23:47:21 +00:00
Compare commits
144 Commits
V.1.3.0-al
...
master
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 | ||
|
8dd48fa7cc | ||
|
287405f81a | ||
|
fa27b80060 | ||
|
c2c14c4911 | ||
|
e2deb8751d | ||
|
1fe7d6e21f | ||
|
e68be6d4f1 | ||
|
45d3a42754 | ||
|
cb0410a182 | ||
|
9d349461cf | ||
|
d41a34673b | ||
|
b199b43f58 | ||
|
6d212efe1e | ||
|
d32486d882 | ||
|
5afa65ce68 | ||
|
5b46247df2 | ||
|
bda5433716 | ||
|
835e82ca63 | ||
|
98cdb18d62 | ||
|
cd59a9b294 | ||
|
4780433c4d | ||
|
28a4934a82 | ||
|
4e8bbeed35 | ||
|
f86ef0514b | ||
|
4c004af1ae | ||
|
66e3a737d4 | ||
|
9cf6552c71 | ||
|
f18e74917b | ||
|
b909222db9 | ||
|
0c7868536a | ||
|
fc3956caf1 | ||
|
4cf3c85070 | ||
|
6e57baccaf | ||
|
5ed704e676 | ||
|
eb3753ab25 | ||
|
f9d71577f3 | ||
|
814f2c7904 | ||
|
ceca889be4 | ||
|
696283b1e1 | ||
|
15cc3a8595 | ||
|
e8c3441f29 | ||
|
2de7b26f66 | ||
|
8f35aeb88f | ||
|
b49188c104 | ||
|
f8bf8830be | ||
|
6e6c547460 | ||
|
d287f52ba5 | ||
|
8cc02a07fb | ||
|
28d51484b1 | ||
|
e7d2e0bd38 | ||
|
999914926a | ||
|
e21b2201ab | ||
|
d65ded6072 | ||
|
16662f697b | ||
|
35d740b778 | ||
|
0a16364a7a | ||
|
e9090ab4a9 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -25,3 +25,5 @@ usr/
|
||||
# translations
|
||||
*.qm
|
||||
|
||||
# temporary bckps
|
||||
*~
|
||||
|
12
.gitmodules
vendored
Normal file
12
.gitmodules
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
[submodule "sources/3rdparty/tasks"]
|
||||
path = sources/3rdparty/tasks
|
||||
url = https://github.com/mhogomchungu/tasks.git
|
||||
[submodule "sources/3rdparty/pdebug"]
|
||||
path = sources/3rdparty/pdebug
|
||||
url = https://github.com/arcan1s/qtadds-pdebug.git
|
||||
[submodule "sources/3rdparty/language"]
|
||||
path = sources/3rdparty/language
|
||||
url = https://github.com/arcan1s/qtadds-language.git
|
||||
[submodule "sources/3rdparty/task"]
|
||||
path = sources/3rdparty/task
|
||||
url = https://github.com/arcan1s/qtadds-taskadds-qprocess.git
|
3
AUTHORS
3
AUTHORS
@ -1,2 +1,5 @@
|
||||
Current developers:
|
||||
Evgeniy Alekseev aka arcanis <esalexeev (at) gmail (dot) com>
|
||||
|
||||
Translators:
|
||||
@nosada (Japanese translation)
|
||||
|
214
CHANGELOG
214
CHANGELOG
@ -1,17 +1,177 @@
|
||||
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
|
||||
* update Japanese translation
|
||||
* dataengine
|
||||
- fix #19
|
||||
|
||||
***
|
||||
|
||||
Ver.1.3.2
|
||||
---------
|
||||
* all
|
||||
+ add Japanese translation (thanks to @nosada)
|
||||
|
||||
***
|
||||
|
||||
Ver.1.3.1
|
||||
---------
|
||||
* gui
|
||||
* more correct calls of boolean DBus methods
|
||||
* edit helper icon
|
||||
* helper
|
||||
* more correct calls of boolean DBus methods
|
||||
* more correct systemd service
|
||||
* add ability to create session bus
|
||||
|
||||
***
|
||||
|
||||
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
|
||||
@ -21,29 +181,33 @@ Ver.1.3.0
|
||||
+ add ability to use helper
|
||||
+ add ability to start minimized/maximized/detached
|
||||
+ add ability to don't save profile from WiFi tab
|
||||
+ add ability to skip external components checking
|
||||
- remove buttons
|
||||
* more correct actions into SettingsWindow
|
||||
* update to library changes
|
||||
* rewrite tables to use toolTip
|
||||
* edit about window
|
||||
* helper:
|
||||
* change menuBar
|
||||
* 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()
|
||||
+ add slot stopAllProfiles()
|
||||
+ add slot reenableProfile()
|
||||
+ add slots getRecommendedConfiguration()
|
||||
+ add slots forceStartProfile() and forceStopProfile()
|
||||
+ add double quotes to profile names
|
||||
+ add tests
|
||||
* rewrite to use [tasks](https://github.com/mhogomchungu/tasks) (see #7)
|
||||
* rename getInterfaceList() to getWirelessInterfaceList()
|
||||
* change temporaty directory from $HOME/.cache to system one
|
||||
- remove functions getProfileDescriptions() and getProfileStatuses()
|
||||
- remove SleepThread class
|
||||
* plasmoid:
|
||||
* 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
|
||||
+ add 3rd party license information
|
||||
+ allow plasmoid to use system tray
|
||||
+ add ability to use helper
|
||||
@ -56,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
|
||||
@ -81,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)
|
||||
@ -99,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
|
||||
@ -127,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
|
||||
|
||||
@ -137,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
|
||||
|
||||
***
|
||||
|
147
PKGBUILD
147
PKGBUILD
@ -1,147 +0,0 @@
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
pkgbase=netctl-gui
|
||||
pkgname=('libnetctlgui' 'netctlgui-helper' 'netctl-gui'
|
||||
'libnetctlgui-qt4' 'netctlgui-helper-qt4' 'netctl-gui-qt4'
|
||||
'kdeplasma-applets-netctl-gui')
|
||||
pkgver=1.3.0
|
||||
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')
|
||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
||||
install="${pkgbase}.install"
|
||||
md5sums=('d99eba4101fee42ebbfa5735aa706bc9')
|
||||
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/build-"{plasmoid,qt4,qt5}
|
||||
mkdir "${srcdir}/build-"{plasmoid,qt4,qt5}
|
||||
}
|
||||
|
||||
|
||||
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 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt4"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
-DUSE_QT5:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
|
||||
cd "${srcdir}/build-qt5"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
}
|
||||
|
||||
|
||||
package_kdeplasma-applets-netctl-gui() {
|
||||
pkgdesc="A plasmoid, which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'kdebase-workspace')
|
||||
optdepends=('kdebase-runtime: sudo support'
|
||||
'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="${pkgbase}.install"
|
||||
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_libnetctlgui() {
|
||||
pkgdesc="Qt5 library which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'qt5-base')
|
||||
optdepends=('netctlgui-helper: DBus helper daemon'
|
||||
'sudo: sudo support'
|
||||
'wpa_supplicant: wifi support')
|
||||
provides=('libnetctlgui-qt4')
|
||||
conflicts=('libnetctlgui-qt4')
|
||||
|
||||
cd "${srcdir}/build-qt5/netctlgui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctlgui-helper() {
|
||||
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
|
||||
depends=('libnetctlgui')
|
||||
provides=('netctlgui-helper-qt4')
|
||||
conflicts=('netctlgui-helper-qt4')
|
||||
backup=('etc/netctlgui-helper.conf')
|
||||
|
||||
cd "${srcdir}/build-qt5/helper"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
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'
|
||||
'netctlgui-helper: DBus helper daemon')
|
||||
provides=('netctl-gui-qt4')
|
||||
conflicts=('netctl-gui-qt4')
|
||||
install="${pkgbase}.install"
|
||||
|
||||
cd "${srcdir}/build-qt5/gui"
|
||||
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')
|
||||
provides=('netctlgui-helper')
|
||||
conflicts=('netctlgui-helper')
|
||||
backup=('etc/netctlgui-helper.conf')
|
||||
|
||||
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="${pkgbase}.install"
|
||||
|
||||
cd "${srcdir}/build-qt4/gui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
38
README.md
38
README.md
@ -4,14 +4,19 @@ 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)
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
It is recommended to use graphical interface for widget and DataEngine configuration. All settings of GUI are stored in `$HOME/.config/netctl-gui.conf`. It is highly recommended to edit it from graphical interface.
|
||||
It is recommended to use graphical interface for configuration. Configuration files are:
|
||||
|
||||
* `$HOME/.config/netctl-gui.conf` - GUI/helper user configuration
|
||||
* `/etc/netctl-gui.conf` - helper system-wide configuration
|
||||
* `$HOME/.config/plasma-dataengine-netctl.conf` - DataEngine user configuration
|
||||
* `/etc/xdg/plasma-dataengine-netctl.conf` - DataEngine system-wide configuration
|
||||
|
||||
Instruction
|
||||
===========
|
||||
@ -25,7 +30,8 @@ Dependencies
|
||||
Optional dependencies
|
||||
---------------------
|
||||
|
||||
* kdebase-workspace (widget)
|
||||
* kdebase-workspace (KDE4 widget)
|
||||
* plasma-framework (KF5 widget)
|
||||
* sudo (sudo support)
|
||||
* wpa_supplicant (WiFi support)
|
||||
|
||||
@ -50,14 +56,21 @@ Installation
|
||||
|
||||
Available cmake flags:
|
||||
|
||||
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
|
||||
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
|
||||
* `-DBUILD_GUI:BOOL=0` - do not build GUI
|
||||
* `-DBUILD_HELPER:BOOL=0` - do not build helper daemon
|
||||
* `-DBUILD_LIBRARY:BOOL=0` - do not build library
|
||||
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
|
||||
* `-DBUILD_TEST:BOOL=1` - build auto tests for the library and the helper
|
||||
* `-DUSE_QT5:BOOL=0` - use Qt4 instead of Qt5 for GUI
|
||||
* components:
|
||||
* `-DBUILD_DATAENGINE:BOOL=0` - do not build DataEngine
|
||||
* `-DBUILD_GUI:BOOL=0` - do not build GUI
|
||||
* `-DBUILD_HELPER:BOOL=0` - do not build helper daemon
|
||||
* `-DBUILD_LIBRARY:BOOL=0` - do not build library
|
||||
* `-DBUILD_PLASMOID:BOOL=0` - do not build Plasmoid
|
||||
* additional components:
|
||||
* `-DBUILD_DOCS:BOOL=0` - do not build developer documentation
|
||||
* `-DBUILD_TEST:BOOL=1` - build auto tests for the library and the helper
|
||||
* project properties:
|
||||
* `-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
|
||||
======================
|
||||
@ -65,9 +78,6 @@ Additional information
|
||||
TODO (wish list)
|
||||
----------------
|
||||
|
||||
* remove suid bit from helper (polkit/logind/etc)
|
||||
* check/update documentation
|
||||
|
||||
Links
|
||||
-----
|
||||
|
||||
|
98
arch/PKGBUILD
Normal file
98
arch/PKGBUILD
Normal file
@ -0,0 +1,98 @@
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
pkgbase=netctl-gui
|
||||
pkgname=('libnetctlgui' 'netctlgui-helper' 'netctl-gui'
|
||||
'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=('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=('64c04c36eea017e7c0ddf687d60de128')
|
||||
|
||||
prepare() {
|
||||
rm -rf "${srcdir}/build-"{plasmoid,qt5}
|
||||
mkdir "${srcdir}/build-"{plasmoid,qt5}
|
||||
}
|
||||
|
||||
|
||||
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-qt5"
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBUILD_DATAENGINE:BOOL=0 \
|
||||
-DBUILD_PLASMOID:BOOL=0 \
|
||||
-DUSE_CAPABILITIES:BOOL=0 \
|
||||
"../${pkgbase}"
|
||||
make
|
||||
}
|
||||
|
||||
|
||||
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'
|
||||
'netctl-gui: graphical front-end'
|
||||
'sudo: sudo support')
|
||||
install="plasma-netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-plasmoid"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_libnetctlgui() {
|
||||
pkgdesc="Qt5 library which interacts with netctl. A part of netctl-gui"
|
||||
depends=('netctl' 'qt5-base')
|
||||
optdepends=('netctlgui-helper: DBus helper daemon'
|
||||
'sudo: sudo support'
|
||||
'wpa_supplicant: wifi support')
|
||||
provides=('libnetctlgui-qt4')
|
||||
conflicts=('libnetctlgui-qt4')
|
||||
|
||||
cd "${srcdir}/build-qt5/netctlgui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctlgui-helper() {
|
||||
pkgdesc="Helper daemon for netctl-gui. A part of netctl-gui"
|
||||
depends=("libnetctlgui=${pkgver}")
|
||||
provides=('netctlgui-helper-qt4')
|
||||
conflicts=('netctlgui-helper-qt4')
|
||||
backup=('etc/netctl-gui.conf'
|
||||
'etc/dbus-1/system.d/org.netctlgui.helper.conf')
|
||||
install="netctlgui-helper.install"
|
||||
|
||||
cd "${srcdir}/build-qt5/helper"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
}
|
||||
|
||||
|
||||
package_netctl-gui() {
|
||||
pkgdesc="Qt5 graphical front-end for netctl. A part of netctl-gui"
|
||||
depends=("libnetctlgui=${pkgver}" 'xdg-utils')
|
||||
optdepends=('plasma-netctl-gui: KF5 widget'
|
||||
'netctlgui-helper: DBus helper daemon')
|
||||
provides=('netctl-gui-qt4')
|
||||
conflicts=('netctl-gui-qt4')
|
||||
install="netctl-gui.install"
|
||||
|
||||
cd "${srcdir}/build-qt5/gui"
|
||||
make DESTDIR="${pkgdir}" install
|
||||
cd "${srcdir}/build-qt5/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/kdeplasma-applets-netctl-gui.install
Normal file
14
arch/kdeplasma-applets-netctl-gui.install
Normal file
@ -0,0 +1,14 @@
|
||||
post_install() {
|
||||
cat << EOF
|
||||
Update plasmoids...
|
||||
EOF
|
||||
kbuildsycoca4 > /dev/null 2>&1
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install "$1"
|
||||
}
|
11
arch/libnetctlgui.install
Normal file
11
arch/libnetctlgui.install
Normal file
@ -0,0 +1,11 @@
|
||||
post_install() {
|
||||
true
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install "$1"
|
||||
}
|
@ -4,9 +4,9 @@ post_install() {
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install
|
||||
post_install "$1"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
post_install
|
||||
post_install "$1"
|
||||
}
|
11
arch/netctlgui-helper.install
Normal file
11
arch/netctlgui-helper.install
Normal file
@ -0,0 +1,11 @@
|
||||
post_install() {
|
||||
setcap cap_setuid=ep usr/bin/netctlgui-helper 2>/dev/null || chmod +s usr/bin/netctlgui-helper
|
||||
cat << EOF
|
||||
Note: users should be in network group if you want to get them access to the system bus
|
||||
See http://arcanis.name/devs/netctl-gui-security-notes.html#helper
|
||||
EOF
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install "$1"
|
||||
}
|
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,21 +1,30 @@
|
||||
#!/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 en.qm ru.qm netctl-gui.qm *.cppcheck"
|
||||
VERSION=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
|
||||
$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
|
||||
$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $3}' | cut -c 1)
|
||||
IGNORELIST="build *.qm *.cppcheck .git* *.kdev4"
|
||||
# update submodules
|
||||
git submodule update --init --recursive
|
||||
# create archive
|
||||
[[ -e ${ARCHIVE}-${VERSION}-src.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
|
||||
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
|
||||
cp -r "${SRCDIR}" "${ARCHIVE}"
|
||||
for FILE in ${FILES[*]}; do cp -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}'/" PKGBUILD
|
||||
sed -i "s/pkgver=[0-9.]*/pkgver=${VERSION}/" 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" -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
|
1
sources/3rdparty/language
vendored
Submodule
1
sources/3rdparty/language
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 319125b1fafff9da14c89a94de6ba2852c90c9c2
|
14
sources/3rdparty/language-config.h
vendored
Normal file
14
sources/3rdparty/language-config.h
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef LANGUAGE_CONFIG_H
|
||||
#define LANGUAGE_CONFIG_H
|
||||
|
||||
|
||||
// put your languages here comma separated
|
||||
// the first language is default language
|
||||
#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 */
|
@ -15,31 +15,27 @@
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef PRETTY_DEBUG_H
|
||||
#define PRETTY_DEBUG_H
|
||||
#include "listmap.h"
|
||||
|
||||
|
||||
inline const char *pDebug(const std::string prettyFunction)
|
||||
QMap<QString, QString> listToMap(const QStringList list)
|
||||
{
|
||||
return prettyFunction.c_str();
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
inline std::string pFuncInfo(const std::string prettyFunction)
|
||||
QStringList mapToList(const QMap<QString, QString> map)
|
||||
{
|
||||
size_t colons = prettyFunction.find("::");
|
||||
// workaround for functions which are not belong to any class
|
||||
if (colons == std::string::npos)
|
||||
colons = prettyFunction.rfind("(");
|
||||
size_t begin = prettyFunction.substr(0, colons).rfind(" ") + 1;
|
||||
size_t end = prettyFunction.rfind("(") - begin;
|
||||
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 "[" + prettyFunction.substr(begin, end) + "]";
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
#define PDEBUG pDebug(pFuncInfo(__PRETTY_FUNCTION__))
|
||||
|
||||
|
||||
#endif /* PRETTY_DEBUG_H */
|
@ -15,29 +15,15 @@
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef LANGUAGE_H
|
||||
#define LANGUAGE_H
|
||||
#ifndef LISTMAP_H
|
||||
#define LISTMAP_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
class Language : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Language();
|
||||
static QString checkLanguage(const QString language,
|
||||
const QString defaultLanguage = QString("en"));
|
||||
static QString defineLanguage(const QString configPath,
|
||||
const QString options = QString("OPTIONS"));
|
||||
static QString defineLanguageFromFile(const QString configPath);
|
||||
static QString defineLanguageFromLocale();
|
||||
static QStringList getAvailableLanguages();
|
||||
|
||||
private:
|
||||
static QMap<QString, QString> parseOptions(const QString options);
|
||||
};
|
||||
QMap<QString, QString> listToMap(const QStringList list);
|
||||
QStringList mapToList(const QMap<QString,QString> map);
|
||||
|
||||
|
||||
#endif /* LANGUAGE_H */
|
||||
#endif /* LISTMAP_H */
|
1
sources/3rdparty/pdebug
vendored
Submodule
1
sources/3rdparty/pdebug
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 75e4a0df83478802bba53345486b42c56713fe09
|
1
sources/3rdparty/task
vendored
Submodule
1
sources/3rdparty/task
vendored
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit dd52af08c9d6a2c8652d2d5e21bc2a433efb497a
|
41
sources/3rdparty/task/README.md
vendored
41
sources/3rdparty/task/README.md
vendored
@ -1,41 +0,0 @@
|
||||
|
||||
|
||||
Asynchronous programming in Qt/C++ using tasks,continuations and resumable functions.
|
||||
|
||||
This project is inspired by this[1] video on channel9.
|
||||
|
||||
The project seeks to do async based programming in Qt/C++ using modern C++ with lambdas.
|
||||
|
||||
The project has two sets of APIs.
|
||||
|
||||
1. Task::run().then() API provides async based programming with continuation[4].
|
||||
|
||||
2. Task::await() API provides the first API presented in a different way[5].
|
||||
|
||||
Under certain use cases,they can be used interchangeably, and in others,only one or the other can be used.Some of the problems
|
||||
the first API causes and solved by the second API are discussed in this[7] youtube video.
|
||||
|
||||
Example use case for the Task::run().then() API can be found here[0]. Additional example is [2] where an API is
|
||||
declared and [3] where the declared API is used.
|
||||
|
||||
Example use case of the Task::await() API is here[6] where a function call "blocks" waiting for a result without "hanging" the entire GUI application.
|
||||
|
||||
A short tutorial on task/async/await as implemented in C# can be viewed from this[8] link.
|
||||
|
||||
[0] https://github.com/mhogomchungu/tasks/blob/master/example.cpp
|
||||
|
||||
[1] http://channel9.msdn.com/Blogs/Charles/Asynchronous-Programming-for-C-Developers-PPL-Tasks-and-Windows-8
|
||||
|
||||
[2] https://github.com/mhogomchungu/zuluCrypt/blob/d0439a4e36521e42fa9392b82dcefd3224d53334/zuluMount-gui/zulumounttask.h#L61
|
||||
|
||||
[3] https://github.com/mhogomchungu/zuluCrypt/blob/d0439a4e36521e42fa9392b82dcefd3224d53334/zuluMount-gui/mainwindow.cpp#L812
|
||||
|
||||
[4] Disscussion about this can be found on the following link among other places: http://isocpp.org/files/papers/N3558.pdf
|
||||
|
||||
[5] Disscussion about this can be found on the following link among other places: http://isocpp.org/files/papers/N3564.pdf
|
||||
|
||||
[6] https://github.com/mhogomchungu/zuluCrypt/blob/7123e3c3a7c8c5b3b3b6958464fd92a7f780d827/zuluMount-gui/keydialog.cpp#L511
|
||||
|
||||
[7] https://www.youtube.com/watch?v=Y475RshtAHA
|
||||
|
||||
[8] http://www.youtube.com/watch?v=DqjIQiZ_ql4
|
385
sources/3rdparty/task/task.h
vendored
385
sources/3rdparty/task/task.h
vendored
@ -1,385 +0,0 @@
|
||||
/*
|
||||
* copyright: 2014
|
||||
* name : mhogo mchungu
|
||||
* email: mhogomchungu@gmail.com
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef __TASK_H_INCLUDED__
|
||||
#define __TASK_H_INCLUDED__
|
||||
|
||||
#include <utility>
|
||||
#include <future>
|
||||
#include <functional>
|
||||
#include <QThread>
|
||||
#include <QEventLoop>
|
||||
|
||||
/*
|
||||
*
|
||||
* Examples on how to use the library are at the end of this file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Task
|
||||
{
|
||||
class Thread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Thread()
|
||||
{
|
||||
connect( this,SIGNAL( finished() ),this,SLOT( deleteLater() ) ) ;
|
||||
}
|
||||
protected:
|
||||
virtual ~Thread()
|
||||
{
|
||||
}
|
||||
private:
|
||||
virtual void run( void )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
class future
|
||||
{
|
||||
public:
|
||||
future() : m_function( []( T t ){ Q_UNUSED( t ) ; } )
|
||||
{
|
||||
}
|
||||
void setActions( std::function< void( void ) > start,
|
||||
std::function< void( void ) > cancel,
|
||||
std::function< T ( void ) > get )
|
||||
{
|
||||
m_start = std::move( start ) ;
|
||||
m_cancel = std::move( cancel ) ;
|
||||
m_get = std::move( get ) ;
|
||||
}
|
||||
void then( std::function< void( T ) > function )
|
||||
{
|
||||
m_function = std::move( function ) ;
|
||||
m_start() ;
|
||||
}
|
||||
T get()
|
||||
{
|
||||
return m_get() ;
|
||||
}
|
||||
T await()
|
||||
{
|
||||
QEventLoop p ;
|
||||
|
||||
T q ;
|
||||
|
||||
m_function = [ & ]( T r ){ q = std::move( r ) ; p.exit() ; } ;
|
||||
|
||||
m_start() ;
|
||||
|
||||
p.exec() ;
|
||||
|
||||
return q ;
|
||||
}
|
||||
void start()
|
||||
{
|
||||
m_start() ;
|
||||
}
|
||||
void cancel()
|
||||
{
|
||||
m_cancel() ;
|
||||
}
|
||||
void run( T r )
|
||||
{
|
||||
m_function( std::move( r ) ) ;
|
||||
}
|
||||
private:
|
||||
std::function< void( T ) > m_function ;
|
||||
std::function< void( void ) > m_start ;
|
||||
std::function< void( void ) > m_cancel ;
|
||||
std::function< T ( void ) > m_get ;
|
||||
};
|
||||
|
||||
template< typename T >
|
||||
class ThreadHelper : public Thread
|
||||
{
|
||||
public:
|
||||
ThreadHelper( std::function< T ( void ) >&& function ) : m_function( std::move( function ) )
|
||||
{
|
||||
}
|
||||
future<T>& Future( void )
|
||||
{
|
||||
m_future.setActions( [ this ](){ this->start() ; },
|
||||
[ this ](){ this->deleteLater() ; },
|
||||
[ this ](){ T r = m_function() ; this->deleteLater() ; return r ; } ) ;
|
||||
return m_future ;
|
||||
}
|
||||
private:
|
||||
~ThreadHelper()
|
||||
{
|
||||
m_future.run( std::move( m_cargo ) ) ;
|
||||
}
|
||||
void run( void )
|
||||
{
|
||||
m_cargo = m_function() ;
|
||||
}
|
||||
std::function< T ( void ) > m_function ;
|
||||
future<T> m_future ;
|
||||
T m_cargo ;
|
||||
};
|
||||
|
||||
class future_1
|
||||
{
|
||||
public:
|
||||
future_1() : m_function( [](){} )
|
||||
{
|
||||
}
|
||||
void setActions( std::function< void( void ) > start,
|
||||
std::function< void( void ) > cancel,
|
||||
std::function< void( void ) > get )
|
||||
{
|
||||
m_start = std::move( start ) ;
|
||||
m_cancel = std::move( cancel ) ;
|
||||
m_get = std::move( get ) ;
|
||||
}
|
||||
void then( std::function< void( void ) > function )
|
||||
{
|
||||
m_function = std::move( function ) ;
|
||||
m_start() ;
|
||||
}
|
||||
void get()
|
||||
{
|
||||
m_get() ;
|
||||
}
|
||||
void await()
|
||||
{
|
||||
QEventLoop p ;
|
||||
|
||||
m_function = [ & ](){ p.exit() ; } ;
|
||||
|
||||
m_start() ;
|
||||
|
||||
p.exec() ;
|
||||
}
|
||||
void start()
|
||||
{
|
||||
m_start() ;
|
||||
}
|
||||
void run()
|
||||
{
|
||||
m_function() ;
|
||||
}
|
||||
void cancel()
|
||||
{
|
||||
m_cancel() ;
|
||||
}
|
||||
private:
|
||||
std::function< void( void ) > m_function ;
|
||||
std::function< void( void ) > m_start ;
|
||||
std::function< void( void ) > m_cancel ;
|
||||
std::function< void( void ) > m_get ;
|
||||
};
|
||||
|
||||
class ThreadHelper_1 : public Thread
|
||||
{
|
||||
public:
|
||||
ThreadHelper_1( std::function< void ( void ) >&& function ) : m_function( std::move( function ) )
|
||||
{
|
||||
}
|
||||
future_1& Future( void )
|
||||
{
|
||||
m_future.setActions( [ this ](){ this->start() ; },
|
||||
[ this ](){ this->deleteLater() ; },
|
||||
[ this ](){ m_function() ; this->deleteLater() ; } ) ;
|
||||
return m_future ;
|
||||
}
|
||||
private:
|
||||
~ThreadHelper_1()
|
||||
{
|
||||
m_future.run() ;
|
||||
}
|
||||
void run( void )
|
||||
{
|
||||
m_function() ;
|
||||
}
|
||||
std::function< void ( void ) > m_function ;
|
||||
future_1 m_future ;
|
||||
};
|
||||
|
||||
/*
|
||||
* Below APIs runs two tasks,the first one will run in a different thread and
|
||||
* the second one will be run on the original thread after the completion of the
|
||||
* first one.
|
||||
*/
|
||||
|
||||
template< typename T >
|
||||
future<T>& run( std::function< T ( void ) > function )
|
||||
{
|
||||
auto t = new ThreadHelper<T>( std::move( function ) ) ;
|
||||
return t->Future() ;
|
||||
}
|
||||
|
||||
static inline future_1& run( std::function< void( void ) > function )
|
||||
{
|
||||
auto t = new ThreadHelper_1( std::move( function ) ) ;
|
||||
return t->Future() ;
|
||||
}
|
||||
|
||||
static inline void exec( std::function< void( void ) > function )
|
||||
{
|
||||
Task::run( std::move( function ) ).start() ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Below APIs implements resumable functions where a function will be "blocked"
|
||||
* waiting for the function to return without "hanging" the current thread.
|
||||
*
|
||||
* recommending reading up on C#'s await keyword to get a sense of what is being
|
||||
* discussed below.
|
||||
*/
|
||||
|
||||
static inline void await( Task::future_1& e )
|
||||
{
|
||||
e.await() ;
|
||||
}
|
||||
|
||||
static inline void await( std::function< void( void ) > function )
|
||||
{
|
||||
Task::run( std::move( function ) ).await() ;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T await( std::function< T ( void ) > function )
|
||||
{
|
||||
return Task::run<T>( std::move( function ) ).await() ;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T await( Task::future<T>& e )
|
||||
{
|
||||
return e.await() ;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T await( std::future<T>&& t )
|
||||
{
|
||||
return Task::await<T>( [ & ](){ return t.get() ; } ) ;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/*
|
||||
* Examples on how to use the library
|
||||
*/
|
||||
/*
|
||||
* templated version that passes a return value of one function to another function
|
||||
*/
|
||||
auto _a = [](){
|
||||
/*
|
||||
* task _a does what task _a does here.
|
||||
*
|
||||
* This function body will run on a different thread
|
||||
*/
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
auto _b = []( int r ){
|
||||
/*
|
||||
*
|
||||
* task _b does what task _b does here.
|
||||
*
|
||||
* r is a const reference to a value returned by _a
|
||||
*
|
||||
* This function body will run on the original thread
|
||||
*/
|
||||
}
|
||||
|
||||
Task::run<int>( _a ).then( _b ) ;
|
||||
|
||||
alternatively,
|
||||
|
||||
Task::future<int>& e = Task::run( _a ) ;
|
||||
|
||||
e.then( _b ) ;
|
||||
|
||||
/*
|
||||
* Non templated version that does not pass around return value
|
||||
*/
|
||||
auto _c = [](){
|
||||
/*
|
||||
* task _a does what task _a does here.
|
||||
*
|
||||
* This function body will run on a different thread
|
||||
*/
|
||||
}
|
||||
|
||||
auto _d = [](){
|
||||
/*
|
||||
* task _b does what task _b does here.
|
||||
*
|
||||
* r is a const reference to a value returned by _a
|
||||
*
|
||||
* This function body will run on the original thread
|
||||
*/
|
||||
}
|
||||
|
||||
Task::run( _c ).then( _d ) ;
|
||||
|
||||
/*
|
||||
* if no continuation
|
||||
*/
|
||||
Task::exec( _c ) ;
|
||||
|
||||
/*
|
||||
* Task::await() is used to "block" without "hanging" the calling thread until the function returns.
|
||||
*
|
||||
* Its use case is to do sync programming without hanging the calling thread.
|
||||
*
|
||||
* example use case for it is to "block" on function in a GUI thread withough blocking the GUI thread
|
||||
* hanging the application.
|
||||
*/
|
||||
|
||||
/*
|
||||
* await example when the called function return no result
|
||||
*/
|
||||
Task::await( _c ) ;
|
||||
|
||||
/*
|
||||
* await example when the called function return a result
|
||||
*/
|
||||
int r = Task::await<int>( _a ) ;
|
||||
|
||||
alternatively,
|
||||
|
||||
Task::future<int>& e = Task::run<int>( _a ) ;
|
||||
|
||||
int r = e.await() ;
|
||||
|
||||
alternatively,
|
||||
|
||||
int r = Task::run<int>( _a ).await() ;
|
||||
|
||||
#endif
|
||||
|
||||
#endif //__TASK_H_INCLUDED__
|
1
sources/3rdparty/tasks
vendored
Submodule
1
sources/3rdparty/tasks
vendored
Submodule
@ -0,0 +1 @@
|
||||
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 0)
|
||||
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")
|
||||
@ -21,66 +21,85 @@ message (STATUS "Version: ${PROJECT_VERSION}")
|
||||
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)
|
||||
|
||||
# resources
|
||||
set (PROJECT_TRDPARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
|
||||
set (PROJECT_LIBRARY netctlgui)
|
||||
set (PROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
|
||||
add_subdirectory (${PROJECT_RESOURCE_DIR})
|
||||
|
||||
# components
|
||||
if (BUILD_LIBRARY)
|
||||
add_subdirectory (${PROJECT_LIBRARY})
|
||||
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,28 +3,71 @@ 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})
|
||||
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||
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 ()
|
||||
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_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 SUBPROJECT_SOURCE *.cpp)
|
||||
set (TASK_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/task.h)
|
||||
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)
|
||||
|
||||
# prepare
|
||||
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
|
@ -15,19 +15,29 @@
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include <KGlobal>
|
||||
#include <KStandardDirs>
|
||||
#include "netctl.h"
|
||||
|
||||
#include <Plasma/DataContainer>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QNetworkInterface>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QSettings>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "netctl.h"
|
||||
#include "pdebug.h"
|
||||
#include "taskadds.h"
|
||||
#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)
|
||||
@ -35,16 +45,17 @@ 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();
|
||||
initSources();
|
||||
}
|
||||
|
||||
|
||||
@ -63,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"));
|
||||
@ -74,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();
|
||||
}
|
||||
|
||||
|
||||
@ -151,63 +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;
|
||||
|
||||
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;
|
||||
|
||||
@ -217,101 +181,76 @@ 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].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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getStatus(const QString cmdNetctl, const QString cmdNetctlAuto)
|
||||
void Netctl::initSources()
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
getNetctlAutoStatus(cmdNetctlAuto);
|
||||
|
||||
QString status = QString("false");
|
||||
QStringList currentProfile = getCurrentProfile(cmdNetctl, cmdNetctlAuto);
|
||||
if (!currentProfile.isEmpty())
|
||||
status = QString("true");
|
||||
|
||||
return status;
|
||||
QStringList sourcesList = sources();
|
||||
foreach(QString source, sourcesList)
|
||||
setData(source, QString("value"), QString("N\\A"));
|
||||
}
|
||||
|
||||
|
||||
@ -322,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")) {
|
||||
@ -341,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);
|
||||
|
||||
@ -357,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,16 +27,17 @@ 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);
|
||||
QStringList getProfileStringStatus(const QString cmdNetctl) const;
|
||||
|
||||
public slots:
|
||||
void initSources();
|
||||
|
||||
protected:
|
||||
bool sourceRequestEvent(const QString &name);
|
||||
@ -44,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);
|
||||
};
|
||||
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
../3rdparty/pdebug/pdebug.h
|
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 +0,0 @@
|
||||
../3rdparty/task/task.h
|
@ -1 +0,0 @@
|
||||
../3rdparty/task/taskadds.cpp
|
@ -1 +0,0 @@
|
||||
../3rdparty/task/taskadds.h
|
@ -63,6 +63,7 @@ _netctl_gui_settings=(
|
||||
'PREFERED_IFACE'
|
||||
'PROFILE_DIR'
|
||||
'RFKILL_DIR'
|
||||
'SKIPCOMPONENTS'
|
||||
'STARTTOTRAY'
|
||||
'SUDO_PATH'
|
||||
'SYSTEMCTL_PATH'
|
||||
|
@ -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})
|
||||
|
@ -1,3 +1,4 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
@ -20,27 +21,28 @@ th {
|
||||
th.sub {
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
}
|
||||
small {
|
||||
font-size: 70%;
|
||||
}
|
||||
</style>
|
||||
<h1>netctl-gui DBus API description</h1>
|
||||
<h3>Project version : @PROJECT_VERSION@</h3>
|
||||
<ol>
|
||||
<li><a href="#api">DBus API</a></li>
|
||||
<li><a href="#helper">Helper API</a></li>
|
||||
<ul>
|
||||
<li><a href="#ctrl">Helper ctrl API</a></li>
|
||||
<li><a href="#netctl">Helper netctl API</a></li>
|
||||
</ul>
|
||||
<li><a href="#gui">GUI API</a></li>
|
||||
<ul>
|
||||
<li><a href="#netctlgui">GUI netctlgui API</a></li>
|
||||
</ul>
|
||||
<li><a href="#links">External links</a></li>
|
||||
</ol>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2><a href="#api" class="anchor" name="api"></a>DBus API</h2>
|
||||
<h1>netctl-gui DBus API description</h1>
|
||||
<h3>Project version : @PROJECT_VERSION@</h3>
|
||||
<ol>
|
||||
<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>
|
||||
<li><a href="#links">External links</a></li>
|
||||
</ol>
|
||||
|
||||
<h2><a href="#api" class="anchor" id="api"></a>DBus API</h2>
|
||||
<table>
|
||||
<tbody><tr>
|
||||
<th>method</th>
|
||||
@ -49,11 +51,11 @@ th.sub {
|
||||
</tr>
|
||||
<!-- helper service -->
|
||||
<tr>
|
||||
<th colspan="3"><a href="#helper" class="anchor" name="helper"></a><code>org.netctlgui.helper</code> service (system bus)</th>
|
||||
<th colspan="3"><a href="#helper" class="anchor" id="helper"></a><code>org.netctlgui.helper</code> service (system bus)</th>
|
||||
</tr>
|
||||
<!-- /ctrl path -->
|
||||
<tr>
|
||||
<th colspan="3" class="sub"><a href="#ctrl" class="anchor" name="ctrl"></a><code>/ctrl</code> path</th>
|
||||
<th colspan="3" class="sub"><a href="#ctrl" class="anchor" id="ctrl"></a><code>/ctrl</code> path</th>
|
||||
</tr>
|
||||
<!-- helper actions -->
|
||||
<tr>
|
||||
@ -73,7 +75,7 @@ th.sub {
|
||||
</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>
|
||||
@ -112,6 +114,16 @@ th.sub {
|
||||
<td>enables or disables the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool forceStart(QString profile)</td>
|
||||
<td>force starts the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool forceStop(QString profile)</td>
|
||||
<td>force stops the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
<td>yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>bool Reenable(QString profile)</td>
|
||||
<td>reenables the profile. Returns <code>true</code> if action has been performed successfully</td>
|
||||
@ -185,23 +197,105 @@ th.sub {
|
||||
<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" name="netctl"></a><code>/netctl</code> path</th>
|
||||
<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>
|
||||
@ -210,11 +304,31 @@ th.sub {
|
||||
<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>
|
||||
@ -268,13 +382,17 @@ th.sub {
|
||||
<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" name="gui"></a><code>org.netctlgui.netctlgui</code> service (session bus)</th>
|
||||
<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" name="netctlgui"></a><code>/netctlgui</code> path</th>
|
||||
<th colspan="3" class="sub"><a href="#netctlgui" class="anchor" id="netctlgui"></a><code>/netctlgui</code> path</th>
|
||||
</tr>
|
||||
<!-- gui actions -->
|
||||
<tr>
|
||||
@ -292,11 +410,6 @@ th.sub {
|
||||
<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>
|
||||
@ -347,24 +460,19 @@ th.sub {
|
||||
<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" name="links"></a>External links</h2>
|
||||
<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>
|
||||
|
||||
<p align="center" style="font-size: 70%">
|
||||
<small>
|
||||
© 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
|
||||
This software is licensed under @PROJECT_LICENSE@
|
||||
</p>
|
||||
</small>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,62 +1,79 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>netctl-gui secutiry notes</title>
|
||||
<style type="text/css">
|
||||
|
||||
img {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
}
|
||||
small {
|
||||
font-size: 70%;
|
||||
}
|
||||
</style>
|
||||
<h1>netctl-gui security notes</h1>
|
||||
<h3>Project version : @PROJECT_VERSION@</h3>
|
||||
<ol>
|
||||
<li><a href="#description">Description</a></li>
|
||||
<li><a href="#arch">Architecture</a></li>
|
||||
<li><a href="#library">Library</a></li>
|
||||
<li><a href="#helper">Helper</a></li>
|
||||
<li><a href="#gui">Graphical interface</a></li>
|
||||
<li><a href="#kde">KDE components</a></li>
|
||||
<li><a href="#links">External links</a></li>
|
||||
</ol>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2><a href="#description" class="anchor" name="description"></a>Description</h2>
|
||||
<h1>netctl-gui security notes</h1>
|
||||
<h3>Project version : @PROJECT_VERSION@</h3>
|
||||
<ol>
|
||||
<li><a href="#arch">Architecture</a></li>
|
||||
<li><a href="#library">Library</a></li>
|
||||
<li><a href="#helper">Helper</a></li>
|
||||
<li><a href="#gui">Graphical interface</a></li>
|
||||
<li><a href="#kde">KDE components</a></li>
|
||||
<li><a href="#links">External links</a></li>
|
||||
</ol>
|
||||
|
||||
<h2><a href="#description" class="anchor" id="description"></a>Description</h2>
|
||||
<p></p>
|
||||
|
||||
<h2><a href="#arch" class="anchor" name="arch"></a>Architecture</h2>
|
||||
<img src="architecture.png" alt="architecture" align="middle">
|
||||
<h2><a href="#arch" class="anchor" id="arch"></a>Architecture</h2>
|
||||
<img src="architecture.png" alt="architecture">
|
||||
|
||||
<h2><a href="#library" class="anchor" name="library"></a>Library</h2>
|
||||
<p>According to <a href="#arch">the scheme<a> the library gets information from netctl and can control it. Also it provides some additional functions such as a profile creation and removal and access to wpa_supplicant functions. Some functions do not require additional permissions, but other ones do it. All dynamic arguments including profile names and paths are in double quotes to avoid white spaces problem. The functions which <b>require</b> root privileges are:</p>
|
||||
<h2><a href="#library" class="anchor" id="library"></a>Library</h2>
|
||||
<p>According to <a href="#arch">the scheme</a> the library gets information from netctl and can control it. Also it provides some additional functions such as a profile creation and removal and access to wpa_supplicant functions. Some functions do not require additional permissions, but other ones do it. All dynamic arguments including profile names and paths are in double quotes to avoid white spaces problem. The functions which <b>require</b> root privileges are:</p>
|
||||
<ul>
|
||||
<li>Netctl control module</li>
|
||||
<ul>
|
||||
<li><ul>
|
||||
<li><code>netctl stop-all|start|stop|restart|switch-to|enable|disable|reenable <profile></code>. They are commands which provide a general control to netctl.</li>
|
||||
<li><code>systemctl start|restart|enable <netctl-auto@service></code>. They are commands which provide ability to control netctl-auto systemd service.</li>
|
||||
</ul>
|
||||
</ul></li>
|
||||
<li>Netctl profiles module</li>
|
||||
<ul>
|
||||
<li><ul>
|
||||
<li>Copying of a temporary profile from home directory to netctl profiles directory. <code>cp</code> command is used for it.</li>
|
||||
<li>Removal of a profile. <code>rm</code> command is used for it.</li>
|
||||
</ul>
|
||||
</ul></li>
|
||||
<li>WiFi module</li>
|
||||
<ul>
|
||||
<li><ul>
|
||||
<li>This module require root privileges to start <code>wpa_supplicant</code> only. For the futher interaction user must be in <code>CTRL_GROUP</code>.</li>
|
||||
</ul>
|
||||
</ul></li>
|
||||
</ul>
|
||||
|
||||
<p>If library will be initialized with <code>FORCE_SUDO=true</code> than it will use <code>sudo</code> command (which can be transferred to the library by <code>SUDO_PATH</code> option). Otherwise it will try to set UID of children processes to 0. Please note that <code>sudo</code> command and UID setting will be used only for those commands which require it.</p>
|
||||
|
||||
<h2><a href="#helper" class="anchor" name="helper"></a>Helper</h2>
|
||||
<p>Profiles reading should be described. Since profiles has shell-like syntax some variables (which provide an array) cannot be reading by usual ways. To do it library uses bash:</p>
|
||||
<pre>
|
||||
# define system variables
|
||||
env -i bash -c "set"
|
||||
# get profile and system variable list
|
||||
env -i bash -c "source '<profile>'; set"
|
||||
# get profile variables
|
||||
env -i bash -c "source '<profile>'; for i in ${!<key>[@]}; do echo ${<key>[$i]}; done"
|
||||
</pre>
|
||||
|
||||
<h2><a href="#helper" class="anchor" id="helper"></a>Helper</h2>
|
||||
<p>First of all the helper <b>does not interact</b> with netctl directly, it uses the library to do it. So all library security notes are applicable here. To start the helper and to create DBus services user must be in <code>network</code> group by default (or must be root). But you may change it by editing <code>$DBUS_SYSTEMCONF_PATH/org.netctlgui.helper.conf</code> policy file (<code>/etc/dbus-1/system.d/org.netctlgui.helper.conf</code> by default). Please refer to DBus documentation to do it.</p>
|
||||
|
||||
<p>There are two binaries <code>netctgui-helper</code> and <code>netctlgui-helper-suid</code>. They are the same, but the second one has SUID bit, so it can be running by normal user without any password. Please note that <b>it is dangerous</b> and recommended way is to use systemd daemon. In this case you may not install <code>netctlgui-helper-suid</code> binary.</p>
|
||||
<p>By default <code>netctgui-helper</code> binary has capabilities to set UID to the children processes (<code>CAP_SETUID</code>). If you do not want to get these capabilities you may use <code>-DUSE_CAPABILITIES</code> cmake flag. Please refer to <code>man 7 capabilities</code> for more details.</p>
|
||||
|
||||
<p>There are two configuration files <code>$HOME/.config/netctl-gui.conf</code> and <code>/etc/netctl-gui.conf</code>. The first one is a user configuration and the second one is a system-wide. Please note that by default user configuration has higher priority than system-wide, but running with <code>--system</code> flag user configuration will not be reading. The helper and GUI configurations are the same (although some keys aren't needed).</p>
|
||||
|
||||
<h2><a href="#gui" class="anchor" name="gui"></a>Graphical interface</h2>
|
||||
<h2><a href="#gui" class="anchor" id="gui"></a>Graphical interface</h2>
|
||||
<p>Graphical interface may interact with netctl over <a href="#helper">DBus (the helper)</a> and over <a href="#library">the library</a>. Please refer to their notes to any additional information. If user uses helper he should have permissions to run it.</p>
|
||||
|
||||
<h2><a href="#kde" class="anchor" name="kde"></a>KDE components</h2>
|
||||
<h2><a href="#kde" class="anchor" id="kde"></a>KDE components</h2>
|
||||
<p>There are two netctl-based commands which are run from the DataEngine</p>
|
||||
<ul>
|
||||
<li><code><cmd> list</code></li>
|
||||
@ -79,17 +96,17 @@
|
||||
|
||||
<p>The other way is to use DBus communication with <a href="#helper">the helper</a>. In this case user should have rights to start the helper.</p>
|
||||
|
||||
<h2><a href="#links" class="anchor" name="links"></a>External links</h2>
|
||||
<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>
|
||||
|
||||
<p align="center" style="font-size: 70%">
|
||||
<small>
|
||||
© 2014-@CURRENT_YEAR@ <a href="mailto:@PROJECT_CONTACT@">@PROJECT_AUTHOR@</a><br>
|
||||
This software is licensed under @PROJECT_LICENSE@
|
||||
</p>
|
||||
</small>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -64,7 +64,7 @@ Configuration file
|
||||
.RE
|
||||
.SH SEE ALSO
|
||||
.BR netctlgui-helper (1)
|
||||
.BR netctlgui-helper.conf (5)
|
||||
.BR netctl-gui.conf (5)
|
||||
.SH STANDARDS
|
||||
See
|
||||
.B @CMAKE_INSTALL_PREFIX@/share/doc/netctl-gui/netctl-gui-dbus-api.html
|
||||
|
@ -1,7 +1,17 @@
|
||||
# set files
|
||||
file (GLOB SOURCES *.cpp)
|
||||
file (GLOB HEADERS *.h)
|
||||
file (GLOB FORMS *.ui)
|
||||
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)
|
||||
|
||||
file (GLOB LANGUAGES ${SUBPROJECT_TRANSLATION_DIR}/*.ts)
|
||||
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources.qrc)
|
||||
@ -11,44 +21,45 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}/../../${PROJECT_LIBRARY}/includ
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR})
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${PROJECT_TRDPARTY_DIR})
|
||||
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})
|
||||
|
@ -22,7 +22,8 @@
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "pdebug.h"
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "version.h"
|
||||
|
||||
|
||||
|
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")]);
|
||||
}
|
@ -15,30 +15,33 @@
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef BONDWIDGET_H
|
||||
#define BONDWIDGET_H
|
||||
|
||||
#include "taskadds.h"
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
TaskResult runTask(const QString cmd, const bool useSuid)
|
||||
{
|
||||
return Task::await<TaskResult>( [ & ]() {
|
||||
TaskResult r;
|
||||
if (useSuid) {
|
||||
RootProcess command;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
r.exitCode = command.exitCode();
|
||||
r.output = command.readAllStandardOutput();
|
||||
r.error = command.readAllStandardError();
|
||||
} else {
|
||||
QProcess command;
|
||||
command.start(cmd);
|
||||
command.waitForFinished(-1);
|
||||
r.exitCode = command.exitCode();
|
||||
r.output = command.readAllStandardOutput();
|
||||
r.error = command.readAllStandardError();
|
||||
}
|
||||
|
||||
return r;
|
||||
});
|
||||
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 */
|
@ -21,24 +21,28 @@
|
||||
#include <QDBusMessage>
|
||||
#include <QDebug>
|
||||
|
||||
#include "pdebug.h"
|
||||
#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 */
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <QSpacerItem>
|
||||
#include <QDebug>
|
||||
|
||||
#include "pdebug.h"
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
|
||||
ErrorWindow::ErrorWindow(QWidget *parent, const bool debugCmd)
|
||||
@ -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
@ -1,115 +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 "language.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QLocale>
|
||||
|
||||
|
||||
Language::Language()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QString Language::checkLanguage(const QString language, const QString defaultLanguage)
|
||||
{
|
||||
QStringList availableLanguages = getAvailableLanguages();
|
||||
for (int i=0; i<availableLanguages.count(); i++)
|
||||
if (language == availableLanguages[i])
|
||||
return availableLanguages[i];
|
||||
for (int i=0; i<availableLanguages.count(); i++)
|
||||
if (language.contains(availableLanguages[i] + QChar('_')))
|
||||
return availableLanguages[i];
|
||||
|
||||
return defaultLanguage;
|
||||
}
|
||||
|
||||
|
||||
QString Language::defineLanguage(const QString configPath, const QString options)
|
||||
{
|
||||
QMap<QString, QString> optionsDict = parseOptions(options);
|
||||
if (optionsDict.contains(QString("LANGUAGE")))
|
||||
if (getAvailableLanguages().contains(optionsDict[QString("LANGUAGE")]))
|
||||
return optionsDict[QString("LANGUAGE")];
|
||||
|
||||
QString language;
|
||||
language = defineLanguageFromFile(configPath);
|
||||
if (language.isEmpty())
|
||||
language = defineLanguageFromLocale();
|
||||
language = checkLanguage(language, QString("en"));
|
||||
|
||||
return language;
|
||||
}
|
||||
|
||||
|
||||
QString Language::defineLanguageFromFile(const QString configPath)
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
if (configPath.isEmpty())
|
||||
return QString("");
|
||||
QFile configFile(configPath);
|
||||
QString fileStr;
|
||||
if (!configFile.open(QIODevice::ReadOnly))
|
||||
return QString("");
|
||||
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();
|
||||
|
||||
if (settings.contains(QString("LANGUAGE")))
|
||||
return settings[QString("LANGUAGE")];
|
||||
else
|
||||
return QString("");
|
||||
}
|
||||
|
||||
|
||||
QString Language::defineLanguageFromLocale()
|
||||
{
|
||||
return QLocale::system().name();
|
||||
}
|
||||
|
||||
|
||||
QStringList Language::getAvailableLanguages()
|
||||
{
|
||||
QStringList languages;
|
||||
languages.append(QString("en"));
|
||||
languages.append(QString("ru"));
|
||||
|
||||
return languages;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> Language::parseOptions(const QString options)
|
||||
{
|
||||
QMap<QString, QString> optionsDict;
|
||||
for (int i=0; i<options.split(QChar(',')).count(); i++) {
|
||||
if (options.split(QChar(','))[i].split(QChar('=')).count() < 2)
|
||||
continue;
|
||||
optionsDict[options.split(QChar(','))[i].split(QChar('='))[0]] =
|
||||
options.split(QChar(','))[i].split(QChar('='))[1];
|
||||
}
|
||||
|
||||
return optionsDict;
|
||||
}
|
@ -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,15 +21,21 @@
|
||||
#include <QDBusMessage>
|
||||
#include <QDir>
|
||||
#include <QLibraryInfo>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QTranslator>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "language.h"
|
||||
#include <language/language.h>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "messages.h"
|
||||
#include "version.h"
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <pdebug/pdebug-time.h>
|
||||
#endif /* QT_VERSION >= 0x050000 */
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -42,7 +48,7 @@ bool existingSessionOperation(const QString operation)
|
||||
QDBusMessage response = bus.call(request);
|
||||
QList<QVariant> arguments = response.arguments();
|
||||
|
||||
return !arguments.isEmpty();
|
||||
return (!arguments.isEmpty() && arguments[0].toBool());
|
||||
}
|
||||
|
||||
|
||||
@ -60,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")) {
|
||||
@ -129,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()) ||
|
||||
@ -136,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,521 +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 "aboutwindow.h"
|
||||
#include "dbusoperation.h"
|
||||
#include "errorwindow.h"
|
||||
#include "language.h"
|
||||
#include "netctlautowindow.h"
|
||||
#include "passwdwidget.h"
|
||||
#include "pdebug.h"
|
||||
#include "settingswindow.h"
|
||||
#include "taskadds.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();
|
||||
|
||||
// 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,35 +21,38 @@
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <QDebug>
|
||||
#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 "pdebug.h"
|
||||
#include "pppoewidget.h"
|
||||
#include "settingswindow.h"
|
||||
#include "taskadds.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()),
|
||||
@ -70,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
|
||||
@ -106,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());
|
||||
}
|
||||
|
||||
|
||||
@ -149,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);
|
||||
}
|
||||
|
||||
|
||||
@ -229,9 +155,7 @@ 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());
|
||||
}
|
||||
@ -241,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);
|
||||
}
|
||||
|
||||
|
||||
@ -260,61 +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;
|
||||
|
||||
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");
|
||||
|
||||
@ -322,74 +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->actionAbout, SIGNAL(triggered(bool)), this, SLOT(showAboutWindow()));
|
||||
connect(ui->actionApi, SIGNAL(triggered(bool)), this, SLOT(showApi()));
|
||||
connect(ui->actionLibrary, SIGNAL(triggered(bool)), this, SLOT(showLibrary()));
|
||||
connect(ui->actionNetctlAuto, SIGNAL(triggered(bool)), this, SLOT(showNetctlAutoWindow()));
|
||||
connect(ui->actionReport, SIGNAL(triggered(bool)), this, SLOT(reportABug()));
|
||||
connect(ui->actionSecurity, SIGNAL(triggered(bool)), this, SLOT(showSecurityNotes()));
|
||||
connect(ui->actionSettings, SIGNAL(triggered(bool)), this, SLOT(showSettingsWindow()));
|
||||
connect(ui->actionQuit, SIGNAL(triggered(bool)), this, SLOT(closeMainWindow()));
|
||||
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()));
|
||||
|
||||
// actions menu
|
||||
connect(ui->menuActions, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
||||
connect(ui->actionMainEdit, SIGNAL(triggered(bool)), this, SLOT(mainTabEditProfile()));
|
||||
connect(ui->actionMainEnable, SIGNAL(triggered(bool)), this, SLOT(mainTabEnableProfile()));
|
||||
connect(ui->actionMainRefresh, SIGNAL(triggered(bool)), this, SLOT(updateMainTab()));
|
||||
connect(ui->actionMainRemove, SIGNAL(triggered(bool)), this, SLOT(mainTabRemoveProfile()));
|
||||
connect(ui->actionMainRestart, SIGNAL(triggered(bool)), this, SLOT(mainTabRestartProfile()));
|
||||
connect(ui->actionMainStart, SIGNAL(triggered(bool)), this, SLOT(mainTabStartProfile()));
|
||||
connect(ui->actionMainStopAll, SIGNAL(triggered(bool)), this, SLOT(mainTabStopAllProfiles()));
|
||||
connect(ui->actionMainSwitch, SIGNAL(triggered(bool)), this, SLOT(mainTabSwitchToProfile()));
|
||||
connect(ui->actionProfileClear, SIGNAL(triggered(bool)), this, SLOT(profileTabClear()));
|
||||
connect(ui->actionProfileLoad, SIGNAL(triggered(bool)), this, SLOT(profileTabLoadProfile()));
|
||||
connect(ui->actionProfileRemove, SIGNAL(triggered(bool)), this, SLOT(profileTabRemoveProfile()));
|
||||
connect(ui->actionProfileSave, SIGNAL(triggered(bool)), this, SLOT(profileTabCreateProfile()));
|
||||
connect(ui->actionWifiRefresh, SIGNAL(triggered(bool)), this, SLOT(updateWifiTab()));
|
||||
connect(ui->actionWifiStart, SIGNAL(triggered(bool)), this, SLOT(wifiTabStart()));
|
||||
|
||||
// main tab events
|
||||
connect(ui->pushButton_mainRefresh, SIGNAL(clicked(bool)), this, SLOT(updateMainTab()));
|
||||
connect(ui->pushButton_mainRestart, SIGNAL(clicked(bool)), this, SLOT(mainTabRestartProfile()));
|
||||
connect(ui->pushButton_mainStart, SIGNAL(clicked(bool)), this, SLOT(mainTabStartProfile()));
|
||||
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(mainTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
|
||||
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->pushButton_profileClear, SIGNAL(clicked(bool)), this, SLOT(profileTabClear()));
|
||||
connect(ui->pushButton_profileSave, SIGNAL(clicked(bool)), this, SLOT(profileTabCreateProfile()));
|
||||
connect(generalWid->connectionType, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabChangeState(QString)));
|
||||
|
||||
// wifi tab events
|
||||
connect(ui->pushButton_wifiRefresh, SIGNAL(clicked(bool)), this, SLOT(updateWifiTab()));
|
||||
connect(ui->pushButton_wifiStart, SIGNAL(clicked(bool)), this, SLOT(wifiTabStart()));
|
||||
connect(ui->tableWidget_wifi, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(wifiTabStart()));
|
||||
connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(wifiTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
|
||||
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()));
|
||||
}
|
||||
|
||||
|
||||
@ -415,55 +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);
|
||||
}
|
||||
|
||||
|
||||
@ -471,40 +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 (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;
|
||||
}
|
||||
|
||||
|
||||
@ -514,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,28 +20,18 @@
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QTableWidgetItem>
|
||||
#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;
|
||||
@ -52,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);
|
||||
@ -69,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();
|
||||
@ -88,83 +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();
|
||||
// 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();
|
||||
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
// profile tab slots
|
||||
void profileTabChangeState(const QString current);
|
||||
void profileTabClear();
|
||||
void profileTabCreateProfile();
|
||||
void profileTabLoadProfile();
|
||||
void profileTabRemoveProfile();
|
||||
// wifi tab slots
|
||||
void wifiTabContextualMenu(const QPoint &pos);
|
||||
void wifiTabSetEnabled(const bool state);
|
||||
void wifiTabStart();
|
||||
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
|
||||
private:
|
||||
// ui
|
||||
TrayIcon *trayIcon = 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 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>
|
||||
@ -14,414 +14,26 @@
|
||||
<string>Netctl GUI</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<layout class="QVBoxLayout" name="centralLayout">
|
||||
<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>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mainButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainRefresh">
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_mainButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainRestart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restart</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainStart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_new">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="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>338</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="scrollArea_layout"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_newProfileButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_profileClear">
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="edit-clear">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_newProfileButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_profileSave">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="document-save">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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>Connect to Wi-Fi</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wifi">
|
||||
<property name="text">
|
||||
<string>Please install 'wpa_supplicant' before using it</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget_wifi">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<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>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wifiButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wifiRefresh">
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_wifiButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wifiStart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</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>469</width>
|
||||
<width>600</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -429,47 +41,102 @@
|
||||
<property name="title">
|
||||
<string>Menu</string>
|
||||
</property>
|
||||
<addaction name="actionNetctlAuto"/>
|
||||
<addaction name="actionSettings"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuActions">
|
||||
<property name="title">
|
||||
<string>Actions</string>
|
||||
</property>
|
||||
<addaction name="actionMainRefresh"/>
|
||||
<addaction name="actionWifiRefresh"/>
|
||||
<addaction name="actionProfileClear"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionMainStart"/>
|
||||
<addaction name="actionMainSwitch"/>
|
||||
<addaction name="actionMainRestart"/>
|
||||
<addaction name="actionMainEnable"/>
|
||||
<addaction name="actionMainStopAll"/>
|
||||
<addaction name="actionProfileLoad"/>
|
||||
<addaction name="actionProfileSave"/>
|
||||
<addaction name="actionWifiStart"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionMainEdit"/>
|
||||
<addaction name="actionMainRemove"/>
|
||||
<addaction name="actionProfileRemove"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuHelp">
|
||||
<property name="title">
|
||||
<string>Help</string>
|
||||
</property>
|
||||
<addaction name="actionSecurity"/>
|
||||
<addaction name="actionApi"/>
|
||||
<addaction name="actionDBus_API"/>
|
||||
<addaction name="actionLibrary"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionReport"/>
|
||||
<addaction name="actionReport_a_bug"/>
|
||||
<addaction name="actionAbout"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<addaction name="menuMenu"/>
|
||||
<addaction name="menuActions"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</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="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">
|
||||
@ -483,214 +150,55 @@
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<action name="actionNetctl">
|
||||
<property name="icon">
|
||||
<iconset theme="exit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
<string>netctl control</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>netctl control</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainRefresh">
|
||||
<action name="actionProfiles">
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<iconset theme="document-new">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
<string>Profiles</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Profiles</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+P</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainStart">
|
||||
<action name="actionWiFi_menu">
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
<iconset resource="../../resources/resources.qrc">
|
||||
<normaloff>:/wifi.png</normaloff>:/wifi.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start profile</string>
|
||||
<string>WiFi menu</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+W</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainRestart">
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restart profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainEnable">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-add">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainEdit">
|
||||
<property name="icon">
|
||||
<iconset theme="edit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainRemove">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-delete">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfileClear">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-clear">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionWifiRefresh">
|
||||
<property name="icon">
|
||||
<iconset theme="stock-refresh">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfileLoad">
|
||||
<property name="icon">
|
||||
<iconset theme="document-open">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Load profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfileSave">
|
||||
<property name="icon">
|
||||
<iconset theme="document-save">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionWifiStart">
|
||||
<property name="icon">
|
||||
<iconset theme="system-run">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start Wi-Fi</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionProfileRemove">
|
||||
<property name="icon">
|
||||
<iconset theme="edit-delete">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNetctlAuto">
|
||||
<action name="actionNetctl_auto">
|
||||
<property name="text">
|
||||
<string>netctl-auto</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="icon">
|
||||
<iconset theme="help-about">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>About</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReport">
|
||||
<property name="icon">
|
||||
<iconset theme="tools-report-bug">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Report a bug</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionApi">
|
||||
<property name="text">
|
||||
<string>DBus API reference</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSecurity">
|
||||
<property name="icon">
|
||||
<iconset theme="security-medium">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Security notes</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLibrary">
|
||||
<property name="text">
|
||||
<string>Library documentation</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainSwitch">
|
||||
<property name="icon">
|
||||
<iconset theme="system-run"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Switch to profile</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMainStopAll">
|
||||
<property name="icon">
|
||||
<iconset theme="process-stop"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Stop all profiles</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>tableWidget_main</tabstop>
|
||||
<tabstop>pushButton_mainRefresh</tabstop>
|
||||
<tabstop>pushButton_mainRestart</tabstop>
|
||||
<tabstop>pushButton_mainStart</tabstop>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
<tabstop>pushButton_profileClear</tabstop>
|
||||
<tabstop>pushButton_profileSave</tabstop>
|
||||
<tabstop>tableWidget_wifi</tabstop>
|
||||
<tabstop>pushButton_wifiRefresh</tabstop>
|
||||
<tabstop>pushButton_wifiStart</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<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,19 +98,33 @@ QString infoMessage()
|
||||
{
|
||||
QString infoMessage = QString("");
|
||||
// build information
|
||||
infoMessage += QCoreApplication::translate("MainWindow", "Build date: %1").
|
||||
arg(QString(BUILD_DATE));
|
||||
infoMessage += QString("\n%1:\n").arg(QCoreApplication::translate("MainWindow", "cmake flags"));
|
||||
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1 \\\n").arg(QString(CMAKE_BUILD_TYPE));
|
||||
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1 \\\n").arg(QString(CMAKE_INSTALL_PREFIX));
|
||||
infoMessage += QString("\t-DBUILD_DOCS=%1 \\\n").arg(QString(PROJECT_BUILD_DOCS));
|
||||
infoMessage += QString("\t-DBUILD_LIBRARY=%1 \\\n").arg(QString(PROJECT_BUILD_LIBRARY));
|
||||
infoMessage += QString("\t-DBUILD_GUI=%1 \\\n").arg(QString(PROJECT_BUILD_GUI));
|
||||
infoMessage += QString("\t-DUSE_QT5=%1 \\\n").arg(QString(PROJECT_USE_QT5));
|
||||
infoMessage += QString("\t-DBUILD_DATAENGINE=%1 \\\n").arg(QString(PROJECT_BUILD_DATAENGINE));
|
||||
infoMessage += QApplication::translate("MainWindow", "Build date: %1").arg(QString(BUILD_DATE));
|
||||
// cmake
|
||||
infoMessage += QString("\n%1:\n").arg(QApplication::translate("MainWindow", "cmake flags"));
|
||||
// cmake properties
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "cmake properties"));
|
||||
infoMessage += QString("\t-DCMAKE_BUILD_TYPE=%1\n").arg(QString(CMAKE_BUILD_TYPE));
|
||||
infoMessage += QString("\t-DCMAKE_INSTALL_PREFIX=%1\n").arg(QString(CMAKE_INSTALL_PREFIX));
|
||||
// components
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Components"));
|
||||
infoMessage += QString("\t-DBUILD_DATAENGINE=%1\n").arg(QString(PROJECT_BUILD_DATAENGINE));
|
||||
infoMessage += QString("\t-DBUILD_GUI=%1\n").arg(QString(PROJECT_BUILD_GUI));
|
||||
infoMessage += QString("\t-DBUILD_HELPER=%1\n").arg(QString(PROJECT_BUILD_HELPER));
|
||||
infoMessage += QString("\t-DBUILD_LIBRARY=%1\n").arg(QString(PROJECT_BUILD_LIBRARY));
|
||||
infoMessage += QString("\t-DBUILD_PLASMOID=%1\n").arg(QString(PROJECT_BUILD_PLASMOID));
|
||||
// additional components
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Additional components"));
|
||||
infoMessage += QString("\t-DBUILD_DOCS=%1\n").arg(QString(PROJECT_BUILD_DOCS));
|
||||
infoMessage += QString("\t-DBUILD_TEST=%1\n").arg(QString(PROJECT_BUILD_TEST));
|
||||
// project properties
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Project properties"));
|
||||
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(QCoreApplication::translate("MainWindow", "DBus configuration"));
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "DBus configuration"));
|
||||
infoMessage += QString("\tDBUS_SERVICE=%1\n").arg(QString(DBUS_SERVICE));
|
||||
infoMessage += QString("\tDBUS_INTERFACE=%1\n").arg(QString(DBUS_INTERFACE));
|
||||
infoMessage += QString("\tDBUS_OBJECT_PATH=%1\n").arg(QString(DBUS_OBJECT_PATH));
|
||||
@ -138,11 +133,8 @@ QString infoMessage()
|
||||
infoMessage += QString("\tDBUS_CTRL_PATH=%1\n").arg(QString(DBUS_CTRL_PATH));
|
||||
infoMessage += QString("\tDBUS_LIB_PATH=%1\n").arg(QString(DBUS_LIB_PATH));
|
||||
// docs path
|
||||
infoMessage += QString("%1:\n").arg(QCoreApplication::translate("MainWindow", "Documentation"));
|
||||
infoMessage += QString("%1:\n").arg(QApplication::translate("MainWindow", "Documentation"));
|
||||
infoMessage += QString("\tDOCS_PATH=%1\n").arg(QString(DOCS_PATH));
|
||||
QStringList docs = QDir(QString(DOCS_PATH)).entryList(QDir::NoDotAndDotDot);
|
||||
for (int i=0; i<docs.count(); i++)
|
||||
infoMessage += QString("\t%1\n").arg(docs[i]);
|
||||
|
||||
return infoMessage;
|
||||
}
|
||||
@ -152,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 "pdebug.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;
|
||||
};
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user