mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-27 04:29:58 +00:00
Compare commits
65 Commits
Author | SHA1 | Date | |
---|---|---|---|
762e43c0d6 | |||
f02e553164 | |||
44a5ee9083 | |||
e576ff3b51 | |||
20e744d3cd | |||
6132de0951 | |||
80e4b3e3d3 | |||
028b636d22 | |||
682b6c5b4f | |||
996d2d5bee | |||
d0a39b6770 | |||
8c9904ac4b | |||
e969be6b89 | |||
9e854d8893 | |||
ecea3f2cf8 | |||
e24b908015 | |||
2abe09473a | |||
f258f18e8c | |||
c66891ee60 | |||
3f02c047c2 | |||
2cade97786 | |||
fbad5a6c7d | |||
710941c259 | |||
32fb8ceb54 | |||
9b3902e971 | |||
9184aa78f4 | |||
0c219544b2 | |||
946b470d11 | |||
76877f737e | |||
4dd6a8276d | |||
4da239e41f | |||
d98b3694a4 | |||
ac1a135844 | |||
806cc02075 | |||
887cc013a7 | |||
3cb4e1dfee | |||
03b4744097 | |||
23df40960c | |||
026f08d0cf | |||
13c63163b1 | |||
a56119d0de | |||
f3b6457a9b | |||
d85e5560fa | |||
9cad2e2c29 | |||
49fcfafc9e | |||
a20cac49aa | |||
4e53eaa1ea | |||
6b9f9beabc | |||
6e427519af | |||
61bf2627cc | |||
ec27411b1d | |||
b81bd78327 | |||
8d3a3d29d2 | |||
da7f1488c8 | |||
b439906be4 | |||
65086a9aa3 | |||
95a3e0d544 | |||
d9571b76cf | |||
4a2a27176f | |||
fc43861ba6 | |||
121ba0e54f | |||
7a6930ce2c | |||
e4c2402530 | |||
c6902c6c6b | |||
af414bb720 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -18,5 +18,8 @@
|
||||
# Build directory
|
||||
build/
|
||||
sources/build/
|
||||
sources/build/*/
|
||||
tmp/
|
||||
|
||||
# translations
|
||||
*.qm
|
||||
|
||||
|
44
PKGBUILD
44
PKGBUILD
@ -1,33 +1,35 @@
|
||||
# Maintainer: Evgeniy "arcanis" Alexeev <arcanis.arch at gmail dot com>
|
||||
|
||||
pkgname=kdeplasma-applets-netctl
|
||||
_pkgname=netctl-plasmoid
|
||||
pkgver=1.0.0
|
||||
# comment out needed line if you dont need this component
|
||||
#_build_gui=0
|
||||
#_build_plasmoid=0
|
||||
|
||||
pkgname=netctl-gui
|
||||
pkgver=1.0.2
|
||||
pkgrel=1
|
||||
pkgdesc="Plasmoid written on C++ which interacts with netctl"
|
||||
pkgdesc="Qt4 GUI for netctl. Provides a plasmoid for KDE4"
|
||||
arch=('i686' 'x86_64')
|
||||
url="http://arcan1s.github.io/projects/netctlplasmoid"
|
||||
url="http://arcanis.name/projects/netctl-gui"
|
||||
license=('GPLv3')
|
||||
depends=('kdebase-workspace')
|
||||
makedepends=('cmake' 'automoc4')
|
||||
source=(https://github.com/arcan1s/netctlplasmoid/releases/download/V.${pkgver}/${_pkgname}-${pkgver}-src.tar.xz)
|
||||
install=${pkgname}.install
|
||||
md5sums=('5ac750e391936a6f3494a819b7b4d0b2')
|
||||
_cmakekeys="-DCMAKE_INSTALL_PREFIX=$(kde4-config --prefix)
|
||||
-DBUILD_GUI:BOOL=1
|
||||
-DBUILD_PLASMOID:BOOL=1
|
||||
-DCMAKE_BUILD_TYPE=Release"
|
||||
depends=('netctl' 'qt4')
|
||||
makedepends=('automoc4' 'cmake' 'desktop-file-utils' 'xdg-utils')
|
||||
optdepends=('kdebase-runtime: sudo support'
|
||||
'sudo: sudo support'
|
||||
'wpa_supplicant: wifi support')
|
||||
source=("https://github.com/arcan1s/netctlplasmoid/releases/download/V.${pkgver}/${pkgname}-${pkgver}-src.tar.xz")
|
||||
install="${pkgname}.install"
|
||||
md5sums=('9bbdf2bc3dfbbde0ff63e04d7d081c0d')
|
||||
|
||||
prepare() {
|
||||
if [[ -d ${srcdir}/build ]]; then
|
||||
# flags
|
||||
_cmakekeys="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release"
|
||||
[[ ${_build_gui} == 0 ]] && _cmakekeys=${_cmakekeys}" -DBUILD_GUI:BOOL=0"
|
||||
[[ ${_build_plasmoid} == 0 ]] && _cmakekeys=${_cmakekeys}" -DBUILD_DATAENGINE:BOOL=0 -DBUILD_PLASMOID:BOOL=0" || depends[1]='kdebase-workspace'
|
||||
|
||||
build() {
|
||||
rm -rf "${srcdir}/build"
|
||||
fi
|
||||
mkdir "${srcdir}/build"
|
||||
}
|
||||
|
||||
build () {
|
||||
cd "${srcdir}/build"
|
||||
cmake ${_cmakekeys} ../${_pkgname}
|
||||
cmake ${_cmakekeys} "../${pkgname}"
|
||||
make
|
||||
}
|
||||
|
||||
|
66
README.md
66
README.md
@ -1,4 +1,64 @@
|
||||
netctl-plasmoid
|
||||
===============
|
||||
Netctl GUI
|
||||
==========
|
||||
|
||||
Plasmoid written on C++ which interacts with netctl
|
||||
Information
|
||||
-----------
|
||||
Graphical interface for netctl. Now 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.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
It is recommended to use graphical interface for widget configuration. DataEngine settings are stored in `/usr/share/config/netctl.conf`:
|
||||
|
||||
* `CMD` - netctl command. Default value is `/usr/bin/netctl`.
|
||||
* `IPCMD` - ip command. `/usr/bin/ip` by default.
|
||||
* `NETDIR` - a directory, which contains subdirectories with names of network interfaces. Default is `/sys/class/net/`.
|
||||
* `EXTIPCMD` - a command, which returns external IP address. Default value is `wget -qO- http://ifconfig.me/ip`.
|
||||
* `EXTIP` - `true` will enable external IP definition. Default is `false`.
|
||||
|
||||
All settings of GUI are stored in `$HOME/.config/netctl-gui.conf`. It is highly recommended to edit it from graphical interface.
|
||||
|
||||
Instruction
|
||||
===========
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
* netctl
|
||||
* qt4
|
||||
|
||||
Optional dependencies
|
||||
---------------------
|
||||
* kdebase-workspace (widget)
|
||||
* sudo (sudo support)
|
||||
* wpa_supplicant (WiFi support)
|
||||
|
||||
Make dependencies
|
||||
-----------------
|
||||
* automoc4
|
||||
* cmake
|
||||
|
||||
Installation
|
||||
------------
|
||||
* download sources
|
||||
* extract it and install the application:
|
||||
|
||||
cd /path/to/extracted/archive
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release ../
|
||||
make
|
||||
sudo make install
|
||||
|
||||
If you want install it without KDE widget just run:
|
||||
|
||||
cd /path/to/extracted/archive
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DBUILD_DATAENGINE:BOOL=0 -DBUILD_PLASMOID:BOOL=0 ../
|
||||
make
|
||||
sudo make install
|
||||
|
||||
Additional information
|
||||
======================
|
||||
|
||||
Links
|
||||
-----
|
||||
* [Homepage](http://arcanis.name/projects/netctl-gui)
|
||||
* Archlinux [AUR](https://aur.archlinux.org/packages/netctl-gui) package
|
||||
|
@ -1,15 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
ARCHIVE="netctl-plasmoid"
|
||||
ARCHIVE="netctl-gui"
|
||||
SRCDIR="sources"
|
||||
FILES="LICENSE README.md"
|
||||
IGNORELIST="CMakeLists.txt.user"
|
||||
IGNORELIST="gui/resources/translations/english.qm gui/resources/translations/russian.qm"
|
||||
VERSION=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
|
||||
$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
|
||||
$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $3}' | cut -c 1)
|
||||
|
||||
# create archive
|
||||
[[ -e ${ARCHIVE}-${VERSION}.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
|
||||
[[ -e ${ARCHIVE}-${VERSION}-src.tar.xz ]] && rm -f "${ARCHIVE}-${VERSION}-src.tar.xz"
|
||||
[[ -d ${ARCHIVE} ]] && rm -rf "${ARCHIVE}"
|
||||
cp -r "${SRCDIR}" "${ARCHIVE}"
|
||||
for FILE in ${FILES[*]}; do cp "$FILE" "${ARCHIVE}"; done
|
||||
|
@ -1,5 +1,4 @@
|
||||
post_install() {
|
||||
kbuildsycoca4 > /dev/null 2>&1
|
||||
xdg-icon-resource forceupdate --theme hicolor 2> /dev/null
|
||||
update-desktop-database -q
|
||||
}
|
Before Width: | Height: | Size: 147 KiB After Width: | Height: | Size: 147 KiB |
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 133 KiB |
BIN
screenshots/gui_profile_general.png
Normal file
BIN
screenshots/gui_profile_general.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 105 KiB |
@ -8,30 +8,23 @@ cmake_policy (SET CMP0015 NEW)
|
||||
project (netctl-plasmoid)
|
||||
set (PROJECT_VERSION_MAJOR 1)
|
||||
set (PROJECT_VERSION_MINOR 0)
|
||||
set (PROJECT_VERSION_PATCH 0)
|
||||
set (PROJECT_VERSION_PATCH 2)
|
||||
set (PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||
configure_file (${CMAKE_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
|
||||
|
||||
message (STATUS "Version: ${PROJECT_VERSION}")
|
||||
|
||||
# install options
|
||||
option (WITH_DEBUG_MODE "Build with debug mode" OFF)
|
||||
option (BUILD_GUI "Build GUI" ON)
|
||||
option (BUILD_DATAENGINE "Build data engine" ON)
|
||||
option (BUILD_PLASMOID "Build plasmoid" ON)
|
||||
|
||||
# verbose
|
||||
set (CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
# flags
|
||||
if (WITH_DEBUG_MODE)
|
||||
add_definitions (-DDEBUG_MODE=1)
|
||||
endif ()
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (ADD_CXX_FLAGS "-Wall")
|
||||
set (CMAKE_CXX_FLAGS "-O0 ${ADD_CXX_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -O0")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
||||
else ()
|
||||
message (STATUS "Unknown compiler")
|
||||
endif ()
|
||||
|
@ -6,12 +6,8 @@ message (STATUS "Subproject ${SUBPROJECT}")
|
||||
find_package (KDE4 REQUIRED)
|
||||
include (KDE4Defaults)
|
||||
|
||||
add_definitions (${QT_DEFINITIONS}
|
||||
${KDE4_DEFINITIONS})
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||
|
||||
set (PLUGIN_NAME ${SUBPROJECT})
|
||||
file (GLOB SUBPROJECT_DESKTOP_IN *.desktop)
|
||||
|
@ -12,7 +12,7 @@
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "netctl.h"
|
||||
@ -71,9 +71,7 @@ bool Netctl::readConfiguration()
|
||||
|
||||
while (true) {
|
||||
fileStr = QString(confFile.readLine());
|
||||
if (confFile.atEnd())
|
||||
break;
|
||||
else if (fileStr[0] != '#') {
|
||||
if (fileStr[0] != '#') {
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2) {
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("EXTIP"))
|
||||
checkExtIP = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
|
||||
@ -87,6 +85,8 @@ bool Netctl::readConfiguration()
|
||||
netDir = fileStr.split(QString("="), QString::SkipEmptyParts)[1].split(QString("\n"), QString::SkipEmptyParts)[0];
|
||||
}
|
||||
}
|
||||
if (confFile.atEnd())
|
||||
break;
|
||||
}
|
||||
|
||||
confFile.close();
|
||||
@ -110,7 +110,7 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
command.start(cmd + QString(" list"));
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
if (cmdOutput != QString("")) {
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2) {
|
||||
@ -125,7 +125,7 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
command.start(extIpCmd);
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
if (cmdOutput != QString(""))
|
||||
if (!cmdOutput.isEmpty())
|
||||
value = cmdOutput.split(QString("\n"), QString::SkipEmptyParts)[0];
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
@ -145,7 +145,7 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
command.start(ipCmd + QString(" addr show ") + netDevices[i]);
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
if (cmdOutput != QString("")) {
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList deviceInfo = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int j=0; j<deviceInfo.count(); j++)
|
||||
if (deviceInfo[j].split(QString(" "), QString::SkipEmptyParts)[0] == QString("inet"))
|
||||
@ -160,7 +160,7 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
QStringList list;
|
||||
if (cmdOutput != QString("")) {
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 1)
|
||||
@ -176,7 +176,7 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
value = QString("false");
|
||||
if (cmdOutput != QString("")) {
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2) {
|
||||
@ -191,7 +191,7 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
QString currentProfile;
|
||||
if (cmdOutput != QString("")) {
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList profileList = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profileList[i].split(QString(" "), QString::SkipEmptyParts).count() == 2) {
|
||||
@ -202,20 +202,17 @@ bool Netctl::updateSourceEvent(const QString &source)
|
||||
command.start(cmd + QString(" status ") + currentProfile);
|
||||
command.waitForFinished(-1);
|
||||
cmdOutput = command.readAllStandardOutput();
|
||||
if (cmdOutput != QString("")) {
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList profile = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profile.count(); i++)
|
||||
if (profile[i].split(QString(" "), QString::SkipEmptyParts)[0] == QString("Loaded:")) {
|
||||
if (profile[i].indexOf(QString("enabled")) > -1) {
|
||||
if (profile[i].contains(QString("enabled")))
|
||||
value = QString("enabled");
|
||||
break;
|
||||
}
|
||||
else if (profile[i].indexOf(QString("static")) > -1) {
|
||||
else if (profile[i].contains(QString("static")))
|
||||
value = QString("static");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
setData(source, QString("value"), value);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef NETCTL_DE_H
|
||||
@ -20,6 +20,7 @@
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
|
||||
|
||||
class Netctl : public Plasma::DataEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -33,6 +34,7 @@ protected:
|
||||
bool updateSourceEvent(const QString &source);
|
||||
QStringList sources() const;
|
||||
|
||||
private:
|
||||
// configuration
|
||||
// enable check external IP
|
||||
QString checkExtIP;
|
||||
@ -46,4 +48,5 @@ protected:
|
||||
QString netDir;
|
||||
};
|
||||
|
||||
|
||||
#endif /* NETCTL_DE_H */
|
||||
|
@ -1,6 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Netctl DataEngine
|
||||
Name=Netctl
|
||||
Comment=Data engine for netctl
|
||||
ServiceTypes=Plasma/DataEngine
|
||||
Type=Service
|
||||
|
@ -5,6 +5,8 @@ message (STATUS "Subproject ${SUBPROJECT}")
|
||||
# set directories
|
||||
set (SUBPROJECT_BINARY_DIR bin)
|
||||
set (SUBPROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
set (SUBPROJECT_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
|
||||
set (SUBPROJECT_TRANSLATION_DIR ${SUBPROJECT_RESOURCE_DIR}/translations)
|
||||
# executable path
|
||||
set (EXECUTABLE_OUTPUT_PATH ${SUBPROJECT_BINARY_DIR})
|
||||
|
||||
@ -15,5 +17,3 @@ set (HEADERS "")
|
||||
add_subdirectory (${SUBPROJECT_SOURCE_DIR})
|
||||
|
||||
install (FILES ${SUBPROJECT}.desktop DESTINATION share/applications/)
|
||||
install (FILES ${SUBPROJECT}-logo.png DESTINATION share/pixmaps/)
|
||||
install (FILES ${SUBPROJECT}.png DESTINATION share/icons/hicolor/32x32/apps/)
|
||||
|
10
sources/gui/netctl-gui.desktop
Normal file
10
sources/gui/netctl-gui.desktop
Normal file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Name=Netctl GUI
|
||||
Comment=GUI written on Qt4 for netctl
|
||||
Exec=netctl-gui
|
||||
Icon=netctl-gui.png
|
||||
Terminal=false
|
||||
Encoding=UTF-8
|
||||
Type=Application
|
||||
Categories=Network
|
144
sources/gui/netctl.profile
Normal file
144
sources/gui/netctl.profile
Normal file
@ -0,0 +1,144 @@
|
||||
! - обязательное поле
|
||||
[ddsg] - условие для этой опции
|
||||
в массиве первая опция - дефолт
|
||||
yes - бинарная опция, по дефолту стоит no (и наоборот)
|
||||
|
||||
GENERAL
|
||||
=======
|
||||
Description=
|
||||
! Connection=ethernet|wireless|bond|bridge|dummy|pppoe|mobile_ppp|tunnel|tuntap|vlan
|
||||
! Interface=
|
||||
BindsToInterfaces=(массив интерфейсов, которые будет ожидать этот профиль)
|
||||
After=(список профилей, которые будут запущены перед этим)
|
||||
ExecUpPost=команда, которая будет запущена после
|
||||
ExecDownPre=команда, которая будет запущена перед
|
||||
ForceConnect=yes - включить, даже если интерфейс уже поднят
|
||||
|
||||
IP
|
||||
==
|
||||
! IP=static|dhcp|no
|
||||
! IP6=static|stateless|dhcp-noaddr|dhcp|no
|
||||
[IP=static] Address=('192.168.1.23/24' '192.168.1.87/24')
|
||||
[IP=static] Gateway='192.168.1.1'
|
||||
Routes=('192.168.0.0/24 via 192.168.1.2')
|
||||
[IP6=static]|[IP6=stateless] Address6=('1234:5678:9abc:def::1/64' '1234:3456::123/96')
|
||||
[IP6=static]|[IP6=stateless] Gateway6='1234:0:123::abcd'
|
||||
Routes6=('192.168.0.0/24 via 192.168.1.2')
|
||||
[IP=dhcp] DHCPClient=dhcpcd|dhclient
|
||||
[IP=dhcp] DHCPReleaseOnStop=yes - release the DHCP lease when the profile is stopped.
|
||||
[IP=dhcp][DHCPClient=dhcpcd] DhcpcdOptions=опции
|
||||
[IP=dhcp][DHCPClient=dhclient] DhclientOptions=опции
|
||||
[IP=dhcp][DHCPClient=dhclient] DhclientOptions6=опции
|
||||
IPCustom=('addr add dev eth0 192.168.1.23/24 brd +' 'route add default via 192.168.1.1') - команда для ip напрямую
|
||||
Hostname=
|
||||
DNS=('192.168.1.1')
|
||||
DNSDomain= domain для /etc/resolv.conf
|
||||
DNSSearch= search для /etc/resolv.conf
|
||||
DNSOptions=() массив options для /etc/resolv.conf
|
||||
TimeoutDHCP=30 - время в секундах
|
||||
TimeoutDAD=3 - время в секундах для ipv6 удаление дубликата
|
||||
|
||||
ETHERNET
|
||||
========
|
||||
SkipNoCarrier=yes
|
||||
Auth8021X=yes
|
||||
WPAConfigFile=/etc/wpa_supplicant.conf
|
||||
WPADriver=wired|nl80211|wext
|
||||
TimeoutCarrier=5
|
||||
TimeoutWPA=15
|
||||
+ IP
|
||||
|
||||
WIRELESS
|
||||
========
|
||||
Security=none|wep|wpa|wpa-configsection|wpa-config
|
||||
! ESSID=
|
||||
AP=MAC address
|
||||
[Security=wep]|[Security=wpa] ! Key='superpass'
|
||||
Hidden=yes
|
||||
AdHoc=yes
|
||||
ScanFrequencies=A space-separated list of frequencies in MHz to scan when searching for the network.
|
||||
Priority=0
|
||||
[Security=wpa-configsection] ! WPAConfigSection=(
|
||||
'ssid="University"'
|
||||
'key_mgmt=WPA-EAP'
|
||||
'eap=TTLS'
|
||||
'group=TKIP'
|
||||
'pairwise=TKIP CCMP'
|
||||
'anonymous_identity="anonymous"'
|
||||
'identity="myusername"'
|
||||
'password="mypassword"'
|
||||
'priority=1'
|
||||
'phase2="auth=PAP"'
|
||||
)
|
||||
WPAConfigFile=/etc/wpa_supplicant.conf
|
||||
Country=страна
|
||||
WPAGroup=wheel (группа)
|
||||
WPADriver=nl80211,wext
|
||||
TimeoutWPA=15
|
||||
RFKill=for X in 0..2 $(cat /sys/class/rfkill/rfkillX/name)|auto
|
||||
ExcludeAuto=yes
|
||||
+ IP
|
||||
|
||||
BOND
|
||||
====
|
||||
! BindsToInterfaces=
|
||||
+ IP
|
||||
|
||||
BRIDGE
|
||||
======
|
||||
! BindsToInterfaces=
|
||||
+ IP
|
||||
|
||||
DUMMY
|
||||
=====
|
||||
+ IP
|
||||
|
||||
PPPOE
|
||||
=====
|
||||
-User='example@yourprovider.com'
|
||||
-Password='very secret'
|
||||
ConnectionMode=persist|demand
|
||||
[ConnectionMode=demand] IdleTimeout=0
|
||||
MaxFail=5
|
||||
DefaultRoute=false
|
||||
UsePeerDNS=false
|
||||
PPPUnit=ppp0|ppp1|...
|
||||
-LCPEchoInterval=30
|
||||
-LCPEchoFailure=4
|
||||
OptionsFile=доп файл
|
||||
PPPoEService=имя
|
||||
PPPoEAC=имя
|
||||
PPPoESession='sessid:macaddr'
|
||||
PPPoEMAC=мак
|
||||
PPPoEIP6=yes
|
||||
|
||||
MOBILE_PPP
|
||||
==========
|
||||
MaxFail=5
|
||||
DefaultRoute=false
|
||||
UsePeerDNS=false
|
||||
-User='example@yourprovider.com'
|
||||
-Password='very secret'
|
||||
AccessPointName=имя
|
||||
Pin=код
|
||||
Mode=None|3Gpref|3Gonly|GPRSpref|GPRSonly
|
||||
OptionsFile=доп файл
|
||||
|
||||
TUNNEL
|
||||
======
|
||||
Mode=ipip|gre|sit|isatap|ip6ip6|ipip6|ip6gre|any
|
||||
Local='172.16.0.1'
|
||||
Remote='216.66.80.26'
|
||||
+ ip
|
||||
|
||||
TUNTAP
|
||||
======
|
||||
Mode=tun|tap
|
||||
User='nobody'
|
||||
Group='nobody'
|
||||
+ ip
|
||||
|
||||
VLAN
|
||||
====
|
||||
! BindsToInterfaces=
|
||||
VLANID=55
|
6
sources/gui/resources/resources.qrc
Normal file
6
sources/gui/resources/resources.qrc
Normal file
@ -0,0 +1,6 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>translations/english.qm</file>
|
||||
<file>translations/russian.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
1454
sources/gui/resources/translations/english.ts
Normal file
1454
sources/gui/resources/translations/english.ts
Normal file
File diff suppressed because it is too large
Load Diff
1454
sources/gui/resources/translations/russian.ts
Normal file
1454
sources/gui/resources/translations/russian.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -3,25 +3,39 @@ file (GLOB SOURCES *.cpp)
|
||||
file (GLOB HEADERS *.h)
|
||||
file (GLOB FORMS *.ui)
|
||||
|
||||
set (LANGUAGES english
|
||||
russian)
|
||||
set (RESOURCES ${SUBPROJECT_RESOURCE_DIR}/resources.qrc)
|
||||
|
||||
message (STATUS "${SUBPROJECT} Sources: ${SOURCES}")
|
||||
message (STATUS "${SUBPROJECT} Headers: ${HEADERS}")
|
||||
message (STATUS "${SUBPROJECT} Forms: ${FORMS}")
|
||||
|
||||
# include_path
|
||||
include_directories (${SUBPROJECT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||
|
||||
find_package (Qt4 REQUIRED)
|
||||
include (${QT_USE_FILE})
|
||||
qt4_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt4_wrap_ui (UI_HEADERS ${FORMS})
|
||||
qt4_add_resources (QRC_SOURCES ${RESOURCES})
|
||||
|
||||
foreach (LANGUAGE ${LANGUAGES})
|
||||
set (TS ${SUBPROJECT_TRANSLATION_DIR}/${LANGUAGE}.ts)
|
||||
set (QM ${SUBPROJECT_TRANSLATION_DIR}/${LANGUAGE}.qm)
|
||||
set (TRANSLATIONS ${TRANSLATIONS} ${TS})
|
||||
set (TRANSLATIONS_BINARY ${TRANSLATIONS_BINARY} ${QM})
|
||||
add_custom_command (OUTPUT ${QM} COMMAND ${QT_LRELEASE_EXECUTABLE} ${TS} MAIN_DEPENDENCY ${TS})
|
||||
endforeach ()
|
||||
add_custom_target (translations COMMAND ${QT_LUPDATE_EXECUTABLE} ${HEADERS} ${SOURCES} ${UI_HEADERS} -ts ${TRANSLATIONS})
|
||||
add_custom_command (TARGET translations COMMAND ${QT_LRELEASE_EXECUTABLE} ${TRANSLATIONS})
|
||||
message (STATUS "${SUBPROJECT} Translations: ${TRANSLATIONS_BINARY}")
|
||||
|
||||
source_group ("Header Files" FILES ${HEADERS})
|
||||
source_group ("Source Files" FILES ${SOURCES})
|
||||
source_group ("Generated Files" FILES ${MOC_SOURCES})
|
||||
|
||||
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES})
|
||||
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${QRC_SOURCES} ${TRANSLATIONS})
|
||||
target_link_libraries (${SUBPROJECT} ${QT_LIBRARIES} ${QT_QTMAIN_LIBRARY})
|
||||
|
||||
# install properties
|
||||
|
80
sources/gui/src/bridgewidget.cpp
Normal file
80
sources/gui/src/bridgewidget.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "bridgewidget.h"
|
||||
#include "ui_bridgewidget.h"
|
||||
|
||||
|
||||
BridgeWidget::BridgeWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::BridgeWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
BridgeWidget::~BridgeWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void BridgeWidget::clear()
|
||||
{
|
||||
ui->checkBox_skip->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
|
||||
|
||||
void BridgeWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> BridgeWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> bridgeSettings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return bridgeSettings;
|
||||
|
||||
if (ui->checkBox_skip->checkState() == Qt::Checked)
|
||||
bridgeSettings[QString("SkipForwardingDelay")] = QString("yes");
|
||||
|
||||
return bridgeSettings;
|
||||
}
|
||||
|
||||
|
||||
int BridgeWidget::isOk()
|
||||
{
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void BridgeWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
QMap<QString, QString> bridgeSettings = settings;
|
||||
|
||||
if (bridgeSettings.contains(QString("SkipForwardingDelay")))
|
||||
if (bridgeSettings[QString("SkipForwardingDelay")].remove(QString("'")) == QString("yes"))
|
||||
ui->checkBox_skip->setCheckState(Qt::Checked);
|
||||
}
|
48
sources/gui/src/bridgewidget.h
Normal file
48
sources/gui/src/bridgewidget.h
Normal file
@ -0,0 +1,48 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef BRIDGEWIDGET_H
|
||||
#define BRIDGEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class BridgeWidget;
|
||||
}
|
||||
|
||||
class BridgeWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BridgeWidget(QWidget *parent = 0);
|
||||
~BridgeWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private:
|
||||
Ui::BridgeWidget *ui;
|
||||
};
|
||||
|
||||
|
||||
#endif /* BRIDGEWIDGET_H */
|
45
sources/gui/src/bridgewidget.ui
Normal file
45
sources/gui/src/bridgewidget.ui
Normal file
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BridgeWidget</class>
|
||||
<widget class="QWidget" name="BridgeWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>424</width>
|
||||
<height>76</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_bridge">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Bridge settings</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_bridge">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_skip">
|
||||
<property name="toolTip">
|
||||
<string>Skip (R)STP and immediately activate all bridge members</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Skip forwarding delay</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
96
sources/gui/src/errorwindow.cpp
Normal file
96
sources/gui/src/errorwindow.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "errorwindow.h"
|
||||
#include "ui_errorwindow.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
ErrorWindow::ErrorWindow(QWidget *parent, const int messageNumber)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::ErrorWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
qDebug() << "[ErrorWindow]" << "[ErrorWindow]" << ":" << "Initializate with error code" << messageNumber;
|
||||
setMessage(messageNumber);
|
||||
}
|
||||
|
||||
ErrorWindow::~ErrorWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ErrorWindow::setMessage(const int mess)
|
||||
{
|
||||
QString message;
|
||||
switch(mess) {
|
||||
case 1:
|
||||
message = QApplication::translate("ErrorWindow", "Could not find components");
|
||||
break;
|
||||
case 2:
|
||||
message = QApplication::translate("ErrorWindow", "Does not support yet");
|
||||
break;
|
||||
case 3:
|
||||
message = QApplication::translate("ErrorWindow", "Profile name is not set");
|
||||
break;
|
||||
case 4:
|
||||
message = QApplication::translate("ErrorWindow", "Bind interfaces are not set");
|
||||
break;
|
||||
case 5:
|
||||
message = QApplication::translate("ErrorWindow", "Description is not set");
|
||||
break;
|
||||
case 6:
|
||||
message = QApplication::translate("ErrorWindow", "Ip settings are not set");
|
||||
break;
|
||||
case 7:
|
||||
message = QApplication::translate("ErrorWindow", "Configuration file does not exist");
|
||||
break;
|
||||
case 8:
|
||||
message = QApplication::translate("ErrorWindow", "Key is not set");
|
||||
break;
|
||||
case 9:
|
||||
message = QApplication::translate("ErrorWindow", "Wireless settings are not set");
|
||||
break;
|
||||
case 10:
|
||||
message = QApplication::translate("ErrorWindow", "Configuration file is not set");
|
||||
break;
|
||||
case 11:
|
||||
message = QApplication::translate("ErrorWindow", "ESSID is not set");
|
||||
break;
|
||||
case 12:
|
||||
message = QApplication::translate("ErrorWindow", "MAC address is incorrect");
|
||||
break;
|
||||
case 13:
|
||||
message = QApplication::translate("ErrorWindow", "Session ID is not set");
|
||||
break;
|
||||
case 14:
|
||||
message = QApplication::translate("ErrorWindow", "APN is not set");
|
||||
break;
|
||||
case 15:
|
||||
message = QApplication::translate("ErrorWindow", "APN is not set");
|
||||
break;
|
||||
case 16:
|
||||
message = QApplication::translate("ErrorWindow", "Empty user/group name");
|
||||
break;
|
||||
default:
|
||||
message = QApplication::translate("ErrorWindow", "Unknown error");
|
||||
break;
|
||||
}
|
||||
|
||||
ui->label->setText(message);
|
||||
}
|
42
sources/gui/src/errorwindow.h
Normal file
42
sources/gui/src/errorwindow.h
Normal file
@ -0,0 +1,42 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef ERRORWINDOW_H
|
||||
#define ERRORWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class ErrorWindow;
|
||||
}
|
||||
|
||||
class ErrorWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ErrorWindow(QWidget *parent = 0,
|
||||
const int messageNumber = 0);
|
||||
~ErrorWindow();
|
||||
|
||||
private:
|
||||
Ui::ErrorWindow *ui;
|
||||
void setMessage(const int mess);
|
||||
};
|
||||
|
||||
#endif /* ERRORWINDOW_H */
|
123
sources/gui/src/errorwindow.ui
Normal file
123
sources/gui/src/errorwindow.ui
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ErrorWindow</class>
|
||||
<widget class="QMainWindow" name="ErrorWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>287</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Error</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<spacer name="spacer2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_main">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Error text</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_button">
|
||||
<item>
|
||||
<spacer name="spacer_button1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_button2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>pushButton</sender>
|
||||
<signal>clicked(bool)</signal>
|
||||
<receiver>ErrorWindow</receiver>
|
||||
<slot>close()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>143</x>
|
||||
<y>83</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>252</x>
|
||||
<y>80</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
164
sources/gui/src/ethernetwidget.cpp
Normal file
164
sources/gui/src/ethernetwidget.cpp
Normal file
@ -0,0 +1,164 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "ethernetwidget.h"
|
||||
#include "ui_ethernetwidget.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QFile>
|
||||
|
||||
|
||||
EthernetWidget::EthernetWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::EthernetWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createActions();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
EthernetWidget::~EthernetWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::clear()
|
||||
{
|
||||
ui->checkBox_skip->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_8021x->setCheckState(Qt::Unchecked);
|
||||
showWpa(ui->checkBox_8021x->checkState());
|
||||
ui->lineEdit_wpaConfig->setText(QString("/etc/wpa_supplicant.conf"));
|
||||
ui->comboBox_driver->setCurrentIndex(0);
|
||||
ui->spinBox_timeoutCarrier->setValue(5);
|
||||
ui->spinBox_timeoutWpa->setValue(15);
|
||||
|
||||
ui->pushButton_ethernetAdvanced->setChecked(false);
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_ethernetAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
connect(ui->pushButton_wpaConfig, SIGNAL(clicked(bool)), this, SLOT(selectWpaConfig()));
|
||||
connect(ui->checkBox_8021x, SIGNAL(stateChanged(int)), this, SLOT(showWpa(int)));
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::selectWpaConfig()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("EthernetWidget", "Select wpa configuration file"),
|
||||
QDir::currentPath(),
|
||||
QApplication::translate("EthernetWidget", "Configuration files (*.conf)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_wpaConfig->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_ethernetAdvanced->isChecked()) {
|
||||
ui->widget_ethernetAdvanced->setShown(true);
|
||||
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
ui->widget_ethernetAdvanced->setHidden(true);
|
||||
ui->pushButton_ethernetAdvanced->setText(QApplication::translate("EthernetWidget", "Show advanced"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::showWpa(const int state)
|
||||
{
|
||||
if (state == 0)
|
||||
ui->widget_wpa->setHidden(true);
|
||||
else
|
||||
ui->widget_wpa->setShown(true);
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> EthernetWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> ethernetSettings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return ethernetSettings;
|
||||
|
||||
if (ui->checkBox_skip->checkState() == Qt::Checked)
|
||||
ethernetSettings[QString("SkipNoCarrier")] = QString("yes");
|
||||
if (ui->checkBox_8021x->checkState() == Qt::Checked) {
|
||||
ethernetSettings[QString("Auth8021X")] = QString("yes");
|
||||
ethernetSettings[QString("WPAConfigFile")] = QString("'") + ui->lineEdit_wpaConfig->text() + QString("'");
|
||||
ethernetSettings[QString("WPADriver")] = ui->comboBox_driver->currentText();
|
||||
}
|
||||
if (ui->spinBox_timeoutCarrier->value() != 5)
|
||||
ethernetSettings[QString("TimeoutCarrier")] = QString::number(ui->spinBox_timeoutCarrier->value());
|
||||
if (ui->spinBox_timeoutWpa->value() != 15)
|
||||
ethernetSettings[QString("TimeoutWPA")] = QString::number(ui->spinBox_timeoutWpa->value());
|
||||
|
||||
return ethernetSettings;
|
||||
}
|
||||
|
||||
|
||||
int EthernetWidget::isOk()
|
||||
{
|
||||
// file wpa_supplicant doesn't exists
|
||||
if (!ui->lineEdit_wpaConfig->text().isEmpty())
|
||||
if (!QFile(ui->lineEdit_wpaConfig->text()).exists())
|
||||
return 1;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void EthernetWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
QMap<QString, QString> ethernetSettings = settings;
|
||||
|
||||
if (ethernetSettings.contains(QString("SkipNoCarrier")))
|
||||
if (ethernetSettings[QString("SkipNoCarrier")].remove(QString("'")) == QString("yes"))
|
||||
ui->checkBox_skip->setCheckState(Qt::Checked);
|
||||
if (ethernetSettings.contains(QString("Auth8021X")))
|
||||
if (ethernetSettings[QString("Auth8021X")].remove(QString("'")) == QString("yes"))
|
||||
ui->checkBox_8021x->setCheckState(Qt::Checked);
|
||||
if (ethernetSettings.contains(QString("WPAConfigFile")))
|
||||
ui->lineEdit_wpaConfig->setText(ethernetSettings[QString("WPAConfigFile")].remove(QString("'")));
|
||||
if (ethernetSettings.contains(QString("WPADriver")))
|
||||
for (int i=0; i<ui->comboBox_driver->count(); i++)
|
||||
if (ethernetSettings[QString("WPADriver")].remove(QString("'")) == ui->comboBox_driver->itemText(i))
|
||||
ui->comboBox_driver->setCurrentIndex(i);
|
||||
if (ethernetSettings.contains(QString("TimeoutCarrier")))
|
||||
ui->spinBox_timeoutCarrier->setValue(ethernetSettings[QString("TimeoutCarrier")].toInt());
|
||||
if (ethernetSettings.contains(QString("TimeoutWPA")))
|
||||
ui->spinBox_timeoutWpa->setValue(ethernetSettings[QString("TimeoutWPA")].toInt());
|
||||
|
||||
showWpa(ui->checkBox_8021x->checkState());
|
||||
}
|
55
sources/gui/src/ethernetwidget.h
Normal file
55
sources/gui/src/ethernetwidget.h
Normal file
@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef ETHERNETWIDGET_H
|
||||
#define ETHERNETWIDGET_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class EthernetWidget;
|
||||
}
|
||||
|
||||
class EthernetWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EthernetWidget(QWidget *parent = 0);
|
||||
~EthernetWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private slots:
|
||||
void selectWpaConfig();
|
||||
void showAdvanced();
|
||||
void showWpa(const int state);
|
||||
|
||||
private:
|
||||
Ui::EthernetWidget *ui;
|
||||
void createActions();
|
||||
};
|
||||
|
||||
|
||||
#endif /* ETHERNETWIDGET_H */
|
237
sources/gui/src/ethernetwidget.ui
Normal file
237
sources/gui/src/ethernetwidget.ui
Normal file
@ -0,0 +1,237 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EthernetWidget</class>
|
||||
<widget class="QWidget" name="EthernetWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>431</width>
|
||||
<height>296</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_ethernet">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Ethernet options</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_ethernet">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ethernetAdvanced">
|
||||
<item>
|
||||
<spacer name="spacer_ethernetAdvanced">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_ethernetAdvanced">
|
||||
<property name="text">
|
||||
<string>Hide advanced</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_ethernetAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_skip">
|
||||
<property name="toolTip">
|
||||
<string><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>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_8021x">
|
||||
<property name="toolTip">
|
||||
<string>Set to ‘yes’ to use 802.1x authentication</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>802.1x authentication</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_wpa" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wpaConfig">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wpaConfig">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WPA config file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaConfig">
|
||||
<property name="toolTip">
|
||||
<string>Path to a wpa_supplicant configuration file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wpaConfig">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_driver">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_driver">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WPA driver</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_driver">
|
||||
<property name="toolTip">
|
||||
<string>The wpa_supplicant driver to use for 802.1x authentication</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>wired</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>nl80211</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>wext</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_timeoutCarrier">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_timeoutCarrier">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Timeout carrier</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_timeoutCarrier">
|
||||
<property name="toolTip">
|
||||
<string>Maximum time, in seconds, to wait for a carrier</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_timeoutWpa">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_timeoutWpa">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Timeout WPA</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_timeoutWpa">
|
||||
<property name="toolTip">
|
||||
<string>Maximum time, in seconds, to wait for 802.1x authentication to succeed</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>15</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>pushButton_ethernetAdvanced</tabstop>
|
||||
<tabstop>checkBox_skip</tabstop>
|
||||
<tabstop>checkBox_8021x</tabstop>
|
||||
<tabstop>lineEdit_wpaConfig</tabstop>
|
||||
<tabstop>pushButton_wpaConfig</tabstop>
|
||||
<tabstop>comboBox_driver</tabstop>
|
||||
<tabstop>spinBox_timeoutCarrier</tabstop>
|
||||
<tabstop>spinBox_timeoutWpa</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
204
sources/gui/src/generalwidget.cpp
Normal file
204
sources/gui/src/generalwidget.cpp
Normal file
@ -0,0 +1,204 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "generalwidget.h"
|
||||
#include "ui_generalwidget.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
|
||||
GeneralWidget::GeneralWidget(QWidget *parent, const QMap<QString, QString> settings)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::GeneralWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connectionType = ui->comboBox_connection;
|
||||
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
|
||||
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
||||
createActions();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
GeneralWidget::~GeneralWidget()
|
||||
{
|
||||
delete connectionType;
|
||||
delete ifaceDirectory;
|
||||
delete profileDirectory;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::clear()
|
||||
{
|
||||
ui->lineEdit_description->setText(QString("Generated by Netctl GUI"));
|
||||
ui->comboBox_connection->setCurrentIndex(0);
|
||||
ui->comboBox_interface->clear();
|
||||
ui->comboBox_interface->addItems(ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot));
|
||||
ui->comboBox_bindto->clear();
|
||||
ui->comboBox_bindto->addItems(ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot));
|
||||
ui->listWidget_bindto->setCurrentRow(-1);
|
||||
ui->listWidget_bindto->clear();
|
||||
ui->comboBox_after->clear();
|
||||
ui->comboBox_after->addItems(profileDirectory->entryList(QDir::Files));
|
||||
ui->listWidget_after->setCurrentRow(-1);
|
||||
ui->listWidget_after->clear();
|
||||
ui->lineEdit_execUpPost->clear();
|
||||
ui->lineEdit_execDownPre->clear();
|
||||
ui->checkBox_forceConnect->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_debug->setCheckState(Qt::Unchecked);
|
||||
|
||||
ui->pushButton_generalAdvanced->setChecked(false);
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_generalAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
connect(ui->pushButton_after, SIGNAL(clicked(bool)), this, SLOT(addAfter()));
|
||||
connect(ui->pushButton_bindto, SIGNAL(clicked(bool)), this, SLOT(addBindTo()));
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::addAfter()
|
||||
{
|
||||
ui->listWidget_after->addItem(ui->comboBox_after->currentText());
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::addBindTo()
|
||||
{
|
||||
ui->listWidget_bindto->addItem(ui->comboBox_bindto->currentText());
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (pressedKey->key() == Qt::Key_Delete) {
|
||||
if (ui->listWidget_bindto->hasFocus() &&
|
||||
(ui->listWidget_bindto->currentItem() != 0))
|
||||
delete ui->listWidget_bindto->currentItem();
|
||||
else if (ui->listWidget_after->hasFocus() &&
|
||||
(ui->listWidget_after->currentItem() != 0))
|
||||
delete ui->listWidget_after->currentItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_generalAdvanced->isChecked()) {
|
||||
ui->widget_generalAdvanced->setShown(true);
|
||||
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
ui->widget_generalAdvanced->setHidden(true);
|
||||
ui->pushButton_generalAdvanced->setText(QApplication::translate("GeneralWidget", "Show advanced"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> GeneralWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> generalSettings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return generalSettings;
|
||||
|
||||
generalSettings[QString("Description")] = QString("'") + ui->lineEdit_description->text() + QString("'");
|
||||
generalSettings[QString("Connection")] = ui->comboBox_connection->currentText();
|
||||
generalSettings[QString("Interface")] = ui->comboBox_interface->currentText();
|
||||
if (ui->listWidget_bindto->count() != 0) {
|
||||
QStringList interfaces;
|
||||
for (int i=0; i<ui->listWidget_bindto->count(); i++)
|
||||
interfaces.append(ui->listWidget_bindto->item(i)->text());
|
||||
generalSettings[QString("BindsToInterfaces")] = interfaces.join(QString(" "));
|
||||
}
|
||||
if (ui->listWidget_after->count() != 0) {
|
||||
QStringList profiles;
|
||||
for (int i=0; i<ui->listWidget_after->count(); i++)
|
||||
profiles.append(ui->listWidget_after->item(i)->text());
|
||||
generalSettings[QString("After")] = profiles.join(QString(" "));
|
||||
}
|
||||
if (!ui->lineEdit_execUpPost->text().isEmpty())
|
||||
generalSettings[QString("ExecUpPost")] = QString("'") + ui->lineEdit_execUpPost->text() + QString("'");
|
||||
if (!ui->lineEdit_execDownPre->text().isEmpty())
|
||||
generalSettings[QString("ExecDownPre")] = QString("'") + ui->lineEdit_execDownPre->text() + QString("'");
|
||||
if (ui->checkBox_forceConnect->checkState() == Qt::Checked)
|
||||
generalSettings[QString("ForceConnect")] = QString("yes");
|
||||
if (ui->checkBox_debug->checkState() == Qt::Checked)
|
||||
generalSettings[QString("NETCTL_DEBUG")] = QString("yes");
|
||||
|
||||
return generalSettings;
|
||||
}
|
||||
|
||||
|
||||
int GeneralWidget::isOk()
|
||||
{
|
||||
// bind interfaces is not set
|
||||
if ((ui->comboBox_connection->currentText() == QString("bond")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("bridge")) ||
|
||||
(ui->comboBox_connection->currentText() == QString("vlan")))
|
||||
if (ui->listWidget_bindto->count() == 0)
|
||||
return 1;
|
||||
// empty description
|
||||
if (ui->lineEdit_description->text().isEmpty())
|
||||
return 2;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void GeneralWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
QMap<QString, QString> generalSettings = settings;
|
||||
|
||||
if (generalSettings.contains(QString("Description")))
|
||||
ui->lineEdit_description->setText(generalSettings[QString("Description")].remove(QString("'")));
|
||||
if (generalSettings.contains(QString("Connection")))
|
||||
for (int i=0; i<ui->comboBox_connection->count(); i++)
|
||||
if (generalSettings[QString("Connection")].remove(QString("'")) == ui->comboBox_connection->itemText(i))
|
||||
ui->comboBox_connection->setCurrentIndex(i);
|
||||
if (generalSettings.contains(QString("Interface")))
|
||||
for (int i=0; i<ui->comboBox_interface->count(); i++)
|
||||
if (generalSettings[QString("Interface")].remove(QString("'")) == ui->comboBox_interface->itemText(i))
|
||||
ui->comboBox_interface->setCurrentIndex(i);
|
||||
if (generalSettings.contains(QString("BindsToInterfaces")))
|
||||
ui->listWidget_bindto->addItems(generalSettings[QString("BindsToInterfaces")].split(QString(" ")));
|
||||
if (generalSettings.contains(QString("After")))
|
||||
ui->listWidget_after->addItems(generalSettings[QString("After")].split(QString(" ")));
|
||||
if (generalSettings.contains(QString("ExecUpPost")))
|
||||
ui->lineEdit_execUpPost->setText(generalSettings[QString("ExecUpPost")].remove(QString("'")));
|
||||
if (generalSettings.contains(QString("ExecDownPre")))
|
||||
ui->lineEdit_execDownPre->setText(generalSettings[QString("ExecDownPre")].remove(QString("'")));
|
||||
if (generalSettings.contains(QString("ForceConnect")))
|
||||
if (generalSettings[QString("ForceConnect")].remove(QString("'")) == QString("yes"))
|
||||
ui->checkBox_forceConnect->setCheckState(Qt::Checked);
|
||||
if (generalSettings.contains(QString("NETCTL_DEBUG")))
|
||||
if (generalSettings[QString("NETCTL_DEBUG")].remove(QString("'")) == QString("yes"))
|
||||
ui->checkBox_debug->setCheckState(Qt::Checked);
|
||||
}
|
62
sources/gui/src/generalwidget.h
Normal file
62
sources/gui/src/generalwidget.h
Normal file
@ -0,0 +1,62 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef GENERALWIDGET_H
|
||||
#define GENERALWIDGET_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class GeneralWidget;
|
||||
}
|
||||
|
||||
class GeneralWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GeneralWidget(QWidget *parent = 0,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
~GeneralWidget();
|
||||
QComboBox *connectionType;
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private slots:
|
||||
void addAfter();
|
||||
void addBindTo();
|
||||
void showAdvanced();
|
||||
|
||||
private:
|
||||
QDir *ifaceDirectory;
|
||||
QDir *profileDirectory;
|
||||
Ui::GeneralWidget *ui;
|
||||
void createActions();
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
};
|
||||
|
||||
|
||||
#endif /* GENERALWIDGET_H */
|
354
sources/gui/src/generalwidget.ui
Normal file
354
sources/gui/src/generalwidget.ui
Normal file
@ -0,0 +1,354 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GeneralWidget</class>
|
||||
<widget class="QWidget" name="GeneralWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>431</width>
|
||||
<height>537</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_general">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>General</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_general">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_description">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_description">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_description">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>A description of the profile</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_connection">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_connection">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_connection">
|
||||
<property name="toolTip">
|
||||
<string>The connection type used by the profile</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">ethernet</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">wireless</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">bond</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">bridge</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">dummy</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">pppoe</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">mobile_ppp</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">tunnel</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">tuntap</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">vlan</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_interface">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_interface">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Interface</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_interface">
|
||||
<property name="toolTip">
|
||||
<string>The name of the associated network interface</string>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_bindto">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_bindtoButton">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_bindto">
|
||||
<property name="text">
|
||||
<string>Binds to interfaces</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_bindto">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_bindto">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_bindto">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An array of physical network interfaces that this profile needs before it can be started</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_generalAdvanced">
|
||||
<item>
|
||||
<spacer name="spacer_generalAdvanced">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_generalAdvanced">
|
||||
<property name="text">
|
||||
<string>Hide advanced</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_generalAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_after">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_afterButton">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_after">
|
||||
<property name="text">
|
||||
<string>After</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_after">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_after">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_after">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An array of profile names that should be started before this profile is started</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_execUpPost">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_execUpPost">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Command after starting</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_execUpPost">
|
||||
<property name="toolTip">
|
||||
<string>A command that is executed after a connection is established</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_execDownPre">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_execDownPre">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Command before stoping</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_execDownPre">
|
||||
<property name="toolTip">
|
||||
<string>A command that is executed before a connection is brought down</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_forceConnect">
|
||||
<property name="toolTip">
|
||||
<string>Set to ‘yes’ to force connecting even if the interface is up</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Force connect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_debug">
|
||||
<property name="text">
|
||||
<string>Debug mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
568
sources/gui/src/ipwidget.cpp
Normal file
568
sources/gui/src/ipwidget.cpp
Normal file
@ -0,0 +1,568 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "ipwidget.h"
|
||||
#include "ui_ipwidget.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QKeyEvent>
|
||||
|
||||
|
||||
IpWidget::IpWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::IpWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createActions();
|
||||
createFilter();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
IpWidget::~IpWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::clear()
|
||||
{
|
||||
ui->checkBox_ip->setCheckState(Qt::Checked);
|
||||
ui->comboBox_ip->setCurrentIndex(0);
|
||||
ipEnable(ui->checkBox_ip->checkState());
|
||||
changeIpMode(ui->comboBox_ip->currentText());
|
||||
ui->lineEdit_ipAddress->clear();
|
||||
ui->listWidget_ipAddress->setCurrentRow(-1);
|
||||
ui->listWidget_ipAddress->clear();
|
||||
ui->lineEdit_gateway->clear();
|
||||
ui->lineEdit_ipRoutes->clear();
|
||||
ui->lineEdit_ipRoutes2->clear();
|
||||
ui->listWidget_ipRoutes->setCurrentRow(-1);
|
||||
ui->listWidget_ipRoutes->clear();
|
||||
ui->checkBox_ip6->setCheckState(Qt::Unchecked);
|
||||
ui->comboBox_ip6->setCurrentIndex(0);
|
||||
ip6Enable(ui->checkBox_ip6->checkState());
|
||||
changeIp6Mode(ui->comboBox_ip6->currentText());
|
||||
ui->lineEdit_ipAddress6->clear();
|
||||
ui->listWidget_ipAddress6->setCurrentRow(-1);
|
||||
ui->listWidget_ipAddress6->clear();
|
||||
ui->lineEdit_gateway6->clear();
|
||||
ui->lineEdit_ipRoutes6->clear();
|
||||
ui->lineEdit_ipRoutes62->clear();
|
||||
ui->listWidget_ipRoutes6->setCurrentRow(-1);
|
||||
ui->listWidget_ipRoutes6->clear();
|
||||
ui->lineEdit_custom->clear();
|
||||
ui->listWidget_custom->clear();
|
||||
ui->lineEdit_hostname->clear();
|
||||
ui->spinBox_timeoutDad->setValue(3);
|
||||
ui->comboBox_dhcp->setCurrentIndex(0);
|
||||
changeDhcpClient(ui->comboBox_dhcp->currentText());
|
||||
ui->lineEdit_dhcpcdOpt->clear();
|
||||
ui->lineEdit_dhclientOpt->clear();
|
||||
ui->lineEdit_dhclientOpt6->clear();
|
||||
ui->spinBox_timeoutDhcp->setValue(30);
|
||||
ui->checkBox_dhcp->setCheckState(Qt::Unchecked);
|
||||
ui->lineEdit_dns->clear();
|
||||
ui->listWidget_dns->setCurrentRow(-1);
|
||||
ui->listWidget_dns->clear();
|
||||
ui->lineEdit_dnsDomain->clear();
|
||||
ui->lineEdit_dnsSearch->clear();
|
||||
ui->lineEdit_dnsOptions->clear();
|
||||
ui->listWidget_dnsOptions->setCurrentRow(-1);
|
||||
ui->listWidget_dnsOptions->clear();
|
||||
|
||||
ui->pushButton_ipAdvanced->setChecked(false);;
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_ipAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
// ip mode
|
||||
connect(ui->checkBox_ip, SIGNAL(stateChanged(int)), this, SLOT(ipEnable(int)));
|
||||
connect(ui->comboBox_ip, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeIpMode(QString)));
|
||||
// ipv6 mode
|
||||
connect(ui->checkBox_ip6, SIGNAL(stateChanged(int)), this, SLOT(ip6Enable(int)));
|
||||
connect(ui->comboBox_ip6, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeIp6Mode(QString)));
|
||||
// dhcp client
|
||||
connect(ui->comboBox_dhcp, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeDhcpClient(QString)));
|
||||
// buttons
|
||||
connect(ui->pushButton_ipAddress, SIGNAL(clicked(bool)), this, SLOT(addIp()));
|
||||
connect(ui->pushButton_ipRoutes, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes()));
|
||||
connect(ui->pushButton_ipAddress6, SIGNAL(clicked(bool)), this, SLOT(addIp6()));
|
||||
connect(ui->pushButton_ipRoutes6, SIGNAL(clicked(bool)), this, SLOT(addIpRoutes6()));
|
||||
connect(ui->pushButton_custom, SIGNAL(clicked(bool)), this, SLOT(addCustom()));
|
||||
connect(ui->pushButton_dns, SIGNAL(clicked(bool)), this, SLOT(addDns()));
|
||||
connect(ui->pushButton_dnsOptions, SIGNAL(clicked(bool)), this, SLOT(addDnsOpt()));
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::createFilter()
|
||||
{
|
||||
// using input mask because validators is not comfortable
|
||||
// ipv4
|
||||
ui->lineEdit_ipAddress->setInputMask(QString("999.999.999.999/99"));
|
||||
ui->lineEdit_gateway->setInputMask(QString("999.999.999.999"));
|
||||
ui->lineEdit_ipRoutes->setInputMask(QString("999.999.999.999/99"));
|
||||
ui->lineEdit_ipRoutes2->setInputMask(QString("999.999.999.999"));
|
||||
|
||||
// ipv6
|
||||
ui->lineEdit_ipAddress6->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh/999"));
|
||||
ui->lineEdit_gateway6->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh"));
|
||||
ui->lineEdit_ipRoutes6->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh/999"));
|
||||
ui->lineEdit_ipRoutes62->setInputMask(QString("<hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh:hhhh"));
|
||||
|
||||
// dns
|
||||
ui->lineEdit_dns->setInputMask(QString("999.999.999.999"));
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (pressedKey->key() == Qt::Key_Delete) {
|
||||
if (ui->listWidget_ipAddress->hasFocus() &&
|
||||
(ui->listWidget_ipAddress->currentItem() != 0))
|
||||
delete ui->listWidget_ipAddress->currentItem();
|
||||
else if (ui->listWidget_ipRoutes->hasFocus() &&
|
||||
(ui->listWidget_ipRoutes->currentItem() != 0))
|
||||
delete ui->listWidget_ipRoutes->currentItem();
|
||||
else if (ui->listWidget_ipAddress6->hasFocus() &&
|
||||
(ui->listWidget_ipAddress6->currentItem() != 0))
|
||||
delete ui->listWidget_ipAddress6->currentItem();
|
||||
else if (ui->listWidget_ipRoutes6->hasFocus() &&
|
||||
(ui->listWidget_ipRoutes6->currentItem() != 0))
|
||||
delete ui->listWidget_ipRoutes6->currentItem();
|
||||
else if (ui->listWidget_custom->hasFocus() &&
|
||||
(ui->listWidget_custom->currentItem() != 0))
|
||||
delete ui->listWidget_custom->currentItem();
|
||||
else if (ui->listWidget_dns->hasFocus() &&
|
||||
(ui->listWidget_dns->currentItem() != 0))
|
||||
delete ui->listWidget_dns->currentItem();
|
||||
else if (ui->listWidget_dnsOptions->hasFocus() &&
|
||||
(ui->listWidget_dnsOptions->currentItem() != 0))
|
||||
delete ui->listWidget_dnsOptions->currentItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QString IpWidget::getIp(const QString rawIp)
|
||||
{
|
||||
QStringList ip = rawIp.split(QString("."));
|
||||
|
||||
// fix empty fields
|
||||
if (ip[0].isEmpty())
|
||||
ip[0] = QString("127");
|
||||
if (ip[1].isEmpty())
|
||||
ip[1] = QString("0");
|
||||
if (ip[2].isEmpty())
|
||||
ip[2] = QString("0");
|
||||
if (ip[3].isEmpty())
|
||||
ip[3] = QString("1");
|
||||
// fix numbers
|
||||
for (int i=0; i<4; i++)
|
||||
if (ip[i].toInt() > 255)
|
||||
ip[i] = QString("255");
|
||||
|
||||
return ip.join(QString("."));
|
||||
}
|
||||
|
||||
|
||||
QString IpWidget::getPrefix(const QString rawPrefix)
|
||||
{
|
||||
QString prefix;
|
||||
|
||||
if (rawPrefix.isEmpty())
|
||||
prefix = QString("24");
|
||||
else if (rawPrefix.toInt() > 32)
|
||||
prefix = QString("32");
|
||||
else
|
||||
prefix = rawPrefix;
|
||||
|
||||
return prefix;
|
||||
}
|
||||
|
||||
|
||||
QString IpWidget::getIp6(const QString rawIp)
|
||||
{
|
||||
QString ip = rawIp;
|
||||
|
||||
for (int i=0; i<5; i++)
|
||||
ip.replace(QString(":::"), QString("::"));
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
||||
QString IpWidget::getPrefix6(const QString rawPrefix)
|
||||
{
|
||||
QString prefix;
|
||||
|
||||
if (rawPrefix.isEmpty())
|
||||
prefix = QString("64");
|
||||
else if (rawPrefix.toInt() > 128)
|
||||
prefix = QString("128");
|
||||
else
|
||||
prefix = rawPrefix;
|
||||
|
||||
return prefix;
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addIp()
|
||||
{
|
||||
QString ip = getIp(ui->lineEdit_ipAddress->text().remove(" ").split(QString("/"))[0]);
|
||||
QString prefix = getPrefix(ui->lineEdit_ipAddress->text().remove(" ").split(QString("/"))[1]);
|
||||
|
||||
ui->listWidget_ipAddress->addItem(ip + QString("/") + prefix);
|
||||
ui->lineEdit_ipAddress->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addIpRoutes()
|
||||
{
|
||||
QString ip = getIp(ui->lineEdit_ipRoutes->text().remove(" ").split(QString("/"))[0]);
|
||||
QString prefix = getPrefix(ui->lineEdit_ipRoutes->text().remove(" ").split(QString("/"))[1]);
|
||||
QString ipVia = getIp(ui->lineEdit_ipRoutes2->text().remove(" "));
|
||||
|
||||
ui->listWidget_ipRoutes->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
|
||||
ui->lineEdit_ipRoutes->clear();
|
||||
ui->lineEdit_ipRoutes2->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addIp6()
|
||||
{
|
||||
QString ip = getIp6(ui->lineEdit_ipAddress6->text().remove(" ").split(QString("/"))[0]);
|
||||
QString prefix = getPrefix6(ui->lineEdit_ipAddress6->text().remove(" ").split(QString("/"))[1]);
|
||||
|
||||
ui->listWidget_ipAddress6->addItem(ip + QString("/") + prefix);
|
||||
ui->lineEdit_ipAddress6->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addIpRoutes6()
|
||||
{
|
||||
QString ip = getIp6(ui->lineEdit_ipRoutes6->text().remove(" ").split(QString("/"))[0]);
|
||||
QString prefix = getPrefix6(ui->lineEdit_ipRoutes6->text().remove(" ").split(QString("/"))[1]);
|
||||
QString ipVia = getIp6(ui->lineEdit_ipRoutes62->text().remove(" "));
|
||||
|
||||
ui->listWidget_ipRoutes6->addItem(ip + QString("/") + prefix + QString(" via ") + ipVia);
|
||||
ui->lineEdit_ipRoutes6->clear();
|
||||
ui->lineEdit_ipRoutes62->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addCustom()
|
||||
{
|
||||
if (!ui->lineEdit_custom->text().isEmpty())
|
||||
ui->listWidget_custom->addItem(ui->lineEdit_custom->text());
|
||||
ui->lineEdit_custom->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addDns()
|
||||
{
|
||||
QString ip = getIp(ui->lineEdit_dns->text().remove(" "));
|
||||
|
||||
ui->listWidget_dns->addItem(ip);
|
||||
ui->lineEdit_dns->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::addDnsOpt()
|
||||
{
|
||||
if (!ui->lineEdit_dnsOptions->text().isEmpty())
|
||||
ui->listWidget_dnsOptions->addItem(ui->lineEdit_dnsOptions->text());
|
||||
ui->lineEdit_dnsOptions->clear();
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::changeIpMode(const QString currentText)
|
||||
{
|
||||
if (currentText == QString("dhcp"))
|
||||
ui->widget_ip->setHidden(true);
|
||||
else if (currentText == QString("static"))
|
||||
ui->widget_ip->setShown(true);
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::ipEnable(const int state)
|
||||
{
|
||||
if (state == 0) {
|
||||
ui->comboBox_ip->setDisabled(true);
|
||||
ui->widget_ip->setDisabled(true);
|
||||
ui->widget_ipRoutes->setDisabled(true);
|
||||
}
|
||||
else {
|
||||
ui->comboBox_ip->setEnabled(true);
|
||||
ui->widget_ip->setEnabled(true);
|
||||
ui->widget_ipRoutes->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::changeIp6Mode(const QString currentText)
|
||||
{
|
||||
if ((currentText == QString("dhcp")) ||
|
||||
(currentText == QString("dhcp-noaddr")))
|
||||
ui->widget_ip6->setHidden(true);
|
||||
else if ((currentText == QString("static")) ||
|
||||
(currentText == QString("stateless")))
|
||||
ui->widget_ip6->setShown(true);
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::ip6Enable(const int state)
|
||||
{
|
||||
if (state == 0) {
|
||||
ui->comboBox_ip6->setDisabled(true);
|
||||
ui->widget_ip6->setDisabled(true);
|
||||
ui->widget_ipRoutes6->setDisabled(true);
|
||||
}
|
||||
else {
|
||||
ui->comboBox_ip6->setEnabled(true);
|
||||
ui->widget_ip6->setEnabled(true);
|
||||
ui->widget_ipRoutes6->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::changeDhcpClient(const QString currentText)
|
||||
{
|
||||
if (currentText == QString("dhcpcd")) {
|
||||
ui->widget_dhcpcdOpt->setShown(true);
|
||||
ui->widget_dhclientOpt->setHidden(true);
|
||||
}
|
||||
else if (currentText == QString("dhclient")) {
|
||||
ui->widget_dhcpcdOpt->setHidden(true);
|
||||
ui->widget_dhclientOpt->setShown(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_ipAdvanced->isChecked()) {
|
||||
ui->widget_ipAdvanced->setShown(true);
|
||||
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
ui->widget_ipAdvanced->setHidden(true);
|
||||
ui->pushButton_ipAdvanced->setText(QApplication::translate("IpWidget", "Show advanced"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> IpWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> ipSettings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return ipSettings;
|
||||
|
||||
if (ui->checkBox_ip->checkState() == Qt::Checked) {
|
||||
ipSettings[QString("IP")] = ui->comboBox_ip->currentText();
|
||||
if (ui->comboBox_ip->currentText() == QString("static")) {
|
||||
QStringList addresses;
|
||||
for (int i=0; i<ui->listWidget_ipAddress->count(); i++)
|
||||
addresses.append(QString("'") + ui->listWidget_ipAddress->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("Address")] = addresses.join(QString(" "));
|
||||
ipSettings[QString("Gateway")] = QString("'") + ui->lineEdit_gateway->text() + QString("'");
|
||||
}
|
||||
if (ui->listWidget_ipRoutes->count() > 0) {
|
||||
QStringList routes;
|
||||
for (int i=0; i<ui->listWidget_ipRoutes->count(); i++)
|
||||
routes.append(QString("'") + ui->listWidget_ipRoutes->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("Routes")] = routes.join(QString(" "));
|
||||
}
|
||||
}
|
||||
else
|
||||
ipSettings[QString("IP")] = QString("no");
|
||||
if (ui->checkBox_ip6->checkState() == Qt::Checked) {
|
||||
ipSettings[QString("IP6")] = ui->comboBox_ip6->currentText();
|
||||
if ((ui->comboBox_ip6->currentText() == QString("static")) ||
|
||||
(ui->comboBox_ip6->currentText() == QString("stateless"))) {
|
||||
QStringList addresses;
|
||||
for (int i=0; i<ui->listWidget_ipAddress6->count(); i++)
|
||||
addresses.append(QString("'") + ui->listWidget_ipAddress6->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("Address6")] = addresses.join(QString(" "));
|
||||
ipSettings[QString("Gateway6")] = QString("'") + ui->lineEdit_gateway6->text() + QString("'");
|
||||
}
|
||||
if (ui->listWidget_ipRoutes6->count() > 0) {
|
||||
QStringList routes;
|
||||
for (int i=0; i<ui->listWidget_ipRoutes6->count(); i++)
|
||||
routes.append(QString("'") + ui->listWidget_ipRoutes6->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("Routes6")] = routes.join(QString(" "));
|
||||
}
|
||||
}
|
||||
else
|
||||
ipSettings[QString("IP6")] = QString("no");
|
||||
if (ui->listWidget_custom->count() > 0) {
|
||||
QStringList custom;
|
||||
for (int i=0; i<ui->listWidget_custom->count(); i++)
|
||||
custom.append(QString("'") + ui->listWidget_custom->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("IPCustom")] = custom.join(QString(" "));
|
||||
}
|
||||
if (!ui->lineEdit_hostname->text().isEmpty())
|
||||
ipSettings[QString("Hostname")] = QString("'") + ui->lineEdit_hostname->text() + QString("'");
|
||||
if (ui->spinBox_timeoutDad->value() != 3)
|
||||
ipSettings[QString("TimeoutDAD")] = QString::number(ui->spinBox_timeoutDad->value());
|
||||
if (ui->comboBox_dhcp->currentText() == QString("dhcpcd")) {
|
||||
if (!ui->lineEdit_dhcpcdOpt->text().isEmpty())
|
||||
ipSettings[QString("DhcpcdOptions")] = QString("'") + ui->lineEdit_dhcpcdOpt->text() + QString("'");
|
||||
}
|
||||
else if (ui->comboBox_dhcp->currentText() == QString("dhclient")) {
|
||||
ipSettings[QString("DHCPClient")] = ui->comboBox_dhcp->currentText();
|
||||
if (!ui->lineEdit_dhclientOpt->text().isEmpty())
|
||||
ipSettings[QString("DhclientOptions")] = QString("'") + ui->lineEdit_dhclientOpt->text() + QString("'");
|
||||
if (!ui->lineEdit_dhclientOpt6->text().isEmpty())
|
||||
ipSettings[QString("DhclientOptions6")] = QString("'") + ui->lineEdit_dhclientOpt6->text() + QString("'");
|
||||
}
|
||||
if (ui->spinBox_timeoutDhcp->value() != 30)
|
||||
ipSettings[QString("TimeoutDHCP")] = QString::number(ui->spinBox_timeoutDhcp->value());
|
||||
if (ui->checkBox_dhcp->checkState() == Qt::Checked)
|
||||
ipSettings[QString("DHCPReleaseOnStop")] = QString("yes");
|
||||
if (ui->listWidget_dns->count() > 0) {
|
||||
QStringList dns;
|
||||
for (int i=0; i<ui->listWidget_dns->count(); i++)
|
||||
dns.append(QString("'") + ui->listWidget_dns->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("DNS")] = dns.join(QString(" "));
|
||||
}
|
||||
if (!ui->lineEdit_dnsDomain->text().isEmpty())
|
||||
ipSettings[QString("DNSDomain")] = QString("'") + ui->lineEdit_dnsDomain->text() + QString("'");
|
||||
if (!ui->lineEdit_dnsSearch->text().isEmpty())
|
||||
ipSettings[QString("DNSSearch")] = QString("'") + ui->lineEdit_dnsSearch->text() + QString("'");
|
||||
if (ui->listWidget_dnsOptions->count() > 0) {
|
||||
QStringList dnsOpt;
|
||||
for (int i=0; i<ui->listWidget_dnsOptions->count(); i++)
|
||||
dnsOpt.append(QString("'") + ui->listWidget_dnsOptions->item(i)->text() + QString("'"));
|
||||
ipSettings[QString("DNSOptions")] = dnsOpt.join(QString(" "));
|
||||
}
|
||||
|
||||
return ipSettings;
|
||||
}
|
||||
|
||||
|
||||
int IpWidget::isOk()
|
||||
{
|
||||
// ip settings is not set
|
||||
if (ui->checkBox_ip->checkState() == Qt::Checked)
|
||||
if (ui->comboBox_ip->currentText() == QString("static"))
|
||||
if ((ui->listWidget_ipAddress->count() == 0) ||
|
||||
(ui->lineEdit_gateway->text().isEmpty()))
|
||||
return 1;
|
||||
// ipv6 settings is not set
|
||||
if (ui->checkBox_ip6->checkState() == Qt::Checked)
|
||||
if ((ui->comboBox_ip6->currentText() == QString("static")) ||
|
||||
(ui->comboBox_ip6->currentText() == QString("stateless")))
|
||||
if ((ui->listWidget_ipAddress6->count() == 0) ||
|
||||
(ui->lineEdit_gateway6->text().isEmpty()))
|
||||
return 2;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void IpWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
QMap<QString, QString> ipSettings = settings;
|
||||
|
||||
if (ipSettings.contains(QString("IP"))) {
|
||||
if (ipSettings[QString("IP")].remove(QString("'")) == QString("no"))
|
||||
ui->checkBox_ip->setCheckState(Qt::Unchecked);
|
||||
else {
|
||||
ui->checkBox_ip->setCheckState(Qt::Checked);
|
||||
for (int i=0; i<ui->comboBox_ip->count(); i++)
|
||||
if (ipSettings[QString("IP")].remove(QString("'")) == ui->comboBox_ip->itemText(i))
|
||||
ui->comboBox_ip->setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
if (ipSettings.contains(QString("Address")))
|
||||
ui->listWidget_ipAddress->addItems(ipSettings[QString("Address")].remove(QString("'")).split(QString(" ")));
|
||||
if (ipSettings.contains(QString("Gateway")))
|
||||
ui->lineEdit_gateway->setText(ipSettings[QString("Gateway")].remove(QString("'")));
|
||||
if (ipSettings.contains(QString("Routes")))
|
||||
ui->listWidget_ipRoutes->addItems(ipSettings[QString("Routes")].remove(QString("'")).split(QString(" ")));
|
||||
if (ipSettings.contains(QString("IP6"))) {
|
||||
if (ipSettings[QString("IP6")].remove(QString("'")) == QString("no"))
|
||||
ui->checkBox_ip6->setCheckState(Qt::Unchecked);
|
||||
else {
|
||||
ui->checkBox_ip6->setCheckState(Qt::Checked);
|
||||
for (int i=0; i<ui->comboBox_ip6->count(); i++)
|
||||
if (ipSettings[QString("IP6")].remove(QString("'")) == ui->comboBox_ip6->itemText(i))
|
||||
ui->comboBox_ip6->setCurrentIndex(i);
|
||||
}
|
||||
}
|
||||
if (ipSettings.contains(QString("Address6")))
|
||||
ui->listWidget_ipAddress6->addItems(ipSettings[QString("Address6")].remove(QString("'")).split(QString(" ")));
|
||||
if (ipSettings.contains(QString("Gateway6")))
|
||||
ui->lineEdit_gateway6->setText(ipSettings[QString("Gateway6")].remove(QString("'")));
|
||||
if (ipSettings.contains(QString("Routes6")))
|
||||
ui->listWidget_ipRoutes6->addItems(ipSettings[QString("Routes6")].remove(QString("'")).split(QString(" ")));
|
||||
if (ipSettings.contains(QString("IPCustom"))) {
|
||||
QStringList custom;
|
||||
if (ipSettings[QString("IPCustom")].contains(QString("\n")))
|
||||
custom = ipSettings[QString("IPCustom")].split(QString("'\n'"));
|
||||
else
|
||||
custom = ipSettings[QString("IPCustom")].split(QString("' '"));
|
||||
for (int i=0; i<custom.count(); i++)
|
||||
ui->listWidget_custom->addItem(custom[i].remove(QString("'")));
|
||||
}
|
||||
if (ipSettings.contains(QString("Hostname")))
|
||||
ui->lineEdit_hostname->setText(ipSettings[QString("Hostname")].remove(QString("'")));
|
||||
if (ipSettings.contains(QString("TimeoutDAD")))
|
||||
ui->spinBox_timeoutDad->setValue(ipSettings[QString("TimeoutDAD")].toInt());
|
||||
if (ipSettings.contains(QString("DHCPClient")))
|
||||
for (int i=0; i<ui->comboBox_dhcp->count(); i++)
|
||||
if (ipSettings[QString("DHCPClient")].remove(QString("'")) == ui->comboBox_dhcp->itemText(i))
|
||||
ui->comboBox_dhcp->setCurrentIndex(i);
|
||||
if (ipSettings.contains(QString("DhcpcdOptions")))
|
||||
ui->lineEdit_dhcpcdOpt->setText(ipSettings[QString("DhcpcdOptions")].remove(QString("'")));
|
||||
if (ipSettings.contains(QString("DhclientOptions")))
|
||||
ui->lineEdit_dhclientOpt->setText(ipSettings[QString("DhclientOptions")].remove(QString("'")));
|
||||
if (ipSettings.contains(QString("DhclientOptions6")))
|
||||
ui->lineEdit_dhclientOpt6->setText(ipSettings[QString("DhclientOptions6")].remove(QString("'")));
|
||||
if (ipSettings.contains(QString("TimeoutDHCP")))
|
||||
ui->spinBox_timeoutDhcp->setValue(ipSettings[QString("TimeoutDHCP")].toInt());
|
||||
if (ipSettings.contains(QString("DHCPReleaseOnStop")))
|
||||
if (ipSettings[QString("DHCPReleaseOnStop")].remove(QString("'")) == QString("yes"))
|
||||
ui->checkBox_dhcp->setCheckState(Qt::Checked);
|
||||
if (ipSettings.contains(QString("DNS")))
|
||||
ui->listWidget_dns->addItems(ipSettings[QString("DNS")].remove(QString("'")).split(QString(" ")));
|
||||
if (ipSettings.contains(QString("DNSDomain")))
|
||||
ui->lineEdit_dnsDomain->setText(ipSettings[QString("DNSDomain")].remove(QString("'")));
|
||||
if (ipSettings.contains(QString("DNSSearch")))
|
||||
ui->lineEdit_dnsSearch->setText(ipSettings[QString("DNSSearch")].remove(QString("'")));
|
||||
if (ipSettings.contains(QString("DNSOptions")))
|
||||
ui->listWidget_dnsOptions->addItems(ipSettings[QString("DNSOptions")].remove(QString("'")).split(QString(" ")));
|
||||
|
||||
ipEnable(ui->checkBox_ip->checkState());
|
||||
changeIpMode(ui->comboBox_ip->currentText());
|
||||
ip6Enable(ui->checkBox_ip6->checkState());
|
||||
changeIp6Mode(ui->comboBox_ip6->currentText());
|
||||
changeDhcpClient(ui->comboBox_dhcp->currentText());
|
||||
}
|
74
sources/gui/src/ipwidget.h
Normal file
74
sources/gui/src/ipwidget.h
Normal file
@ -0,0 +1,74 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef IPWIDGET_H
|
||||
#define IPWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class IpWidget;
|
||||
}
|
||||
|
||||
class IpWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IpWidget(QWidget *parent = 0);
|
||||
~IpWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private slots:
|
||||
// buttons
|
||||
void addIp();
|
||||
void addIpRoutes();
|
||||
void addIp6();
|
||||
void addIpRoutes6();
|
||||
void addCustom();
|
||||
void addDns();
|
||||
void addDnsOpt();
|
||||
// ip mode
|
||||
void changeIpMode(const QString currentText);
|
||||
void ipEnable(const int state);
|
||||
// ipv6 mode
|
||||
void changeIp6Mode(const QString currentText);
|
||||
void ip6Enable(int state);
|
||||
// dhcp client
|
||||
void changeDhcpClient(const QString currentText);
|
||||
void showAdvanced();
|
||||
|
||||
private:
|
||||
Ui::IpWidget *ui;
|
||||
void createActions();
|
||||
void createFilter();
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
QString getIp(const QString rawIp);
|
||||
QString getPrefix(const QString rawPrefix);
|
||||
QString getIp6(const QString rawIp);
|
||||
QString getPrefix6(const QString rawPrefix);
|
||||
};
|
||||
|
||||
|
||||
#endif /* IPWIDGET_H */
|
900
sources/gui/src/ipwidget.ui
Normal file
900
sources/gui/src/ipwidget.ui
Normal file
@ -0,0 +1,900 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>IpWidget</class>
|
||||
<widget class="QWidget" name="IpWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>430</width>
|
||||
<height>1353</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_ip">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>IP options</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_ip">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ip">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_ip">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IP</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_ip">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>dhcp</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>static</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_ip" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_ipAddress">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ipAddressLine">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_ipAddress">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_ipAddress"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_ipAddress">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_ipAddress">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An array of IP addresses suffixed with ‘/<netmask>’</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_gateway">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_gateway">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Gateway</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_gateway">
|
||||
<property name="toolTip">
|
||||
<string>An IP routing gateway address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ip6">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_ip6">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IP6</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_ip6">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>dhcp</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>dhcp-noaddr</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>static</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>stateless</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_ip6" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_ipAddress6">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ipAddress6Line">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_ipAddress6">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Address6</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_ipAddress6"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_ipAddress6">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_ipAddress6">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An array of IPv6 addresses</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_gateway6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_gateway6">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Gateway6</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_gateway6">
|
||||
<property name="toolTip">
|
||||
<string>An IPv6 routing gateway address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ipAdvanced">
|
||||
<item>
|
||||
<spacer name="spacer_ipAdvanced">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_ipAdvanced">
|
||||
<property name="text">
|
||||
<string>Hide advanced</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_ipAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_ipRoutes" native="true">
|
||||
<layout class="QVBoxLayout" name="layout_ipRoutes">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ipRoutesLine">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_ipRoutes">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Routes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_ipRoutes"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ipRoutesLine2">
|
||||
<item>
|
||||
<spacer name="spacer_ipRoutes">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>68</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_ipRoutes2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>via</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_ipRoutes2"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_ipRoutes">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_ipRoutes">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An array of custom routes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_ipRoutes6" native="true">
|
||||
<layout class="QVBoxLayout" name="layout_ipRoutes6">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ipRoutes6Line">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_ipRoutes6">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Routes6</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_ipRoutes6"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ipRoutes62">
|
||||
<item>
|
||||
<spacer name="spacer_ipRoutes6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>68</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_ipRoutes62">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>75</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>via</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_ipRoutes62"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_ipRoutes6">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_ipRoutes6">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An array of custom routes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_custom">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_customLine">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_custom">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Custom</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_custom"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_custom">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_custom">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An array of argument lines to pass to ip</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_hostmane">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_hostname">
|
||||
<property name="text">
|
||||
<string>Hostname</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_hostname">
|
||||
<property name="toolTip">
|
||||
<string>A system hostname</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_timeoutDad">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_timeoutDad">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Timeout DAD</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_timeoutDad">
|
||||
<property name="toolTip">
|
||||
<string>Maximum time, in seconds, to wait for IPv6’s Duplicate Address Detection to succeed</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_dhcp" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_dhcp">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_dhcp">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DHCP client</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_dhcp">
|
||||
<property name="toolTip">
|
||||
<string>The name of the preferred DHCP client</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>dhcpcd</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>dhclient</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_dhcpcdOpt" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_dhcpcdOpt">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>dhcpcd options</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_dhcpcdOpt">
|
||||
<property name="toolTip">
|
||||
<string>Additional options to be passed to the DHCP client</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_dhclientOpt" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_dhclientOpt">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_dhclientOpt">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>dhclient options</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_dhclientOpt">
|
||||
<property name="toolTip">
|
||||
<string>Additional options to be passed to the DHCP client</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_dhclientOpt6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_dhclientOpt6">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>dhclient options (6)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_dhclientOpt6">
|
||||
<property name="toolTip">
|
||||
<string>Additional options to be passed to the DHCP client</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_timeoutDhcp">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_timeoutDhcp">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Timeout DHCP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_timeoutDhcp">
|
||||
<property name="toolTip">
|
||||
<string>Maximum time, in seconds, to wait for DHCP to be successful</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>30</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_dhcp">
|
||||
<property name="toolTip">
|
||||
<string>Set to ‘yes’ to release the DHCP lease when the profile is stopped</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DHCP release on stop</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_dns" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_dns">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_dnsLine">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_dns">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DNS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_dns"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_dns">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_dns">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An array of DNS nameservers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_dnsDomain">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_dnsDomain">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DNS domain</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_dnsDomain">
|
||||
<property name="toolTip">
|
||||
<string>A ‘domain’ line for /etc/resolv.conf</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_dnsSearch">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_dnsSearch">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DNS search</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_dnsSearch">
|
||||
<property name="toolTip">
|
||||
<string>A ‘search’ line for /etc/resolv.conf</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_dnsOptions">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_dnsOptionsLine">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_dnsOptions">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>DNS options</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_dnsOptions"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_dnsOptions">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_dnsOptions">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>An array of ‘options’ lines for /etc/resolv.conf</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>checkBox_ip</tabstop>
|
||||
<tabstop>comboBox_ip</tabstop>
|
||||
<tabstop>lineEdit_ipAddress</tabstop>
|
||||
<tabstop>pushButton_ipAddress</tabstop>
|
||||
<tabstop>listWidget_ipAddress</tabstop>
|
||||
<tabstop>lineEdit_gateway</tabstop>
|
||||
<tabstop>checkBox_ip6</tabstop>
|
||||
<tabstop>comboBox_ip6</tabstop>
|
||||
<tabstop>lineEdit_ipAddress6</tabstop>
|
||||
<tabstop>pushButton_ipAddress6</tabstop>
|
||||
<tabstop>listWidget_ipAddress6</tabstop>
|
||||
<tabstop>lineEdit_gateway6</tabstop>
|
||||
<tabstop>pushButton_ipAdvanced</tabstop>
|
||||
<tabstop>lineEdit_ipRoutes</tabstop>
|
||||
<tabstop>lineEdit_ipRoutes2</tabstop>
|
||||
<tabstop>pushButton_ipRoutes</tabstop>
|
||||
<tabstop>listWidget_ipRoutes</tabstop>
|
||||
<tabstop>lineEdit_ipRoutes6</tabstop>
|
||||
<tabstop>lineEdit_ipRoutes62</tabstop>
|
||||
<tabstop>pushButton_ipRoutes6</tabstop>
|
||||
<tabstop>listWidget_ipRoutes6</tabstop>
|
||||
<tabstop>lineEdit_custom</tabstop>
|
||||
<tabstop>pushButton_custom</tabstop>
|
||||
<tabstop>listWidget_custom</tabstop>
|
||||
<tabstop>lineEdit_hostname</tabstop>
|
||||
<tabstop>spinBox_timeoutDad</tabstop>
|
||||
<tabstop>comboBox_dhcp</tabstop>
|
||||
<tabstop>lineEdit_dhcpcdOpt</tabstop>
|
||||
<tabstop>lineEdit_dhclientOpt</tabstop>
|
||||
<tabstop>lineEdit_dhclientOpt6</tabstop>
|
||||
<tabstop>spinBox_timeoutDhcp</tabstop>
|
||||
<tabstop>checkBox_dhcp</tabstop>
|
||||
<tabstop>lineEdit_dns</tabstop>
|
||||
<tabstop>pushButton_dns</tabstop>
|
||||
<tabstop>listWidget_dns</tabstop>
|
||||
<tabstop>lineEdit_dnsDomain</tabstop>
|
||||
<tabstop>lineEdit_dnsSearch</tabstop>
|
||||
<tabstop>lineEdit_dnsOptions</tabstop>
|
||||
<tabstop>pushButton_dnsOptions</tabstop>
|
||||
<tabstop>listWidget_dnsOptions</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
106
sources/gui/src/main.cpp
Normal file
106
sources/gui/src/main.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
#include <QTranslator>
|
||||
#include <iostream>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
|
||||
// translation
|
||||
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
|
||||
QDir::separator() + QString("netctl-gui.conf");
|
||||
QFile configFile(configPath);
|
||||
QString fileStr;
|
||||
QString language = QString("english");
|
||||
if (configFile.open(QIODevice::ReadOnly))
|
||||
while (true) {
|
||||
fileStr = QString(configFile.readLine());
|
||||
if (fileStr[0] != '#') {
|
||||
if (fileStr.contains(QString("LANGUAGE=")))
|
||||
language = fileStr.split(QString("="))[1]
|
||||
.remove(QString(" "))
|
||||
.trimmed();
|
||||
}
|
||||
if (configFile.atEnd())
|
||||
break;
|
||||
}
|
||||
configFile.close();
|
||||
QTranslator translator;
|
||||
translator.load(QString(":/translations/") + language);
|
||||
a.installTranslator(&translator);
|
||||
|
||||
QString helpMessage = QString("");
|
||||
helpMessage += QApplication::translate("MainWindow", " Netctl GUI\n");
|
||||
helpMessage += QApplication::translate("MainWindow", "Version : %1 License : GPLv3\n")
|
||||
.arg(QString(VERSION));
|
||||
helpMessage += QApplication::translate("MainWindow", " Evgeniy Alekseev aka arcanis\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " E-mail : esalexeev@gmail.com\n\n");
|
||||
helpMessage += QApplication::translate("MainWindow", "Usage:\n");
|
||||
helpMessage += QApplication::translate("MainWindow", "netctl-gui [ --default ] [ -t NUM | --tab NUM ] [ -h | --help]\n\n");
|
||||
helpMessage += QApplication::translate("MainWindow", "Parametrs:\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " --default - start with default settings\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " -t NUM --tab NUM - open a tab with number NUM\n");
|
||||
helpMessage += QApplication::translate("MainWindow", " -h --help - show this help and exit\n");
|
||||
bool defaultSettings = false;
|
||||
int tabNumber = 0;
|
||||
|
||||
for (int i=1; i<argc; i++) {
|
||||
// help message
|
||||
if (((argv[i][0] == '-') && (argv[i][1] == 'h') && (argv[i][2] == '\0')) ||
|
||||
((argv[i][0] == '-') && (argv[i][1] == '-') && (argv[i][2] == 'h') && (argv[i][3] == 'e') &&
|
||||
(argv[i][4] == 'l') && (argv[i][5] == 'p') && (argv[i][6] == '\0'))) {
|
||||
cout << helpMessage.toUtf8().data();
|
||||
return 0;
|
||||
}
|
||||
// default settings
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] == '-') && (argv[i][2] == 'd') && (argv[i][3] == 'e') &&
|
||||
(argv[i][4] == 'f') && (argv[i][5] == 'a') && (argv[i][6] == 'u') && (argv[i][7] == 'l') &&
|
||||
(argv[i][8] == 't') && (argv[i][9] == '\0')) {
|
||||
defaultSettings = true;
|
||||
}
|
||||
// tab number
|
||||
else if (((argv[i][0] == '-') && (argv[i][1] == 't') && (argv[i][2] == '\0')) ||
|
||||
((argv[i][0] == '-') && (argv[i][1] == '-') && (argv[i][2] == 't') &&
|
||||
(argv[i][3] == 'a') && (argv[i][4] == 'b') && (argv[i][5] == '\0'))) {
|
||||
if (atoi(argv[i+1]) > 3)
|
||||
tabNumber = 3;
|
||||
else if (atoi(argv[i+1]) < 1)
|
||||
tabNumber = 1;
|
||||
else
|
||||
tabNumber = atoi(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow w(0, defaultSettings, tabNumber);
|
||||
w.show();
|
||||
return a.exec();
|
||||
}
|
962
sources/gui/src/mainwindow.cpp
Normal file
962
sources/gui/src/mainwindow.cpp
Normal file
@ -0,0 +1,962 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
|
||||
#include "bridgewidget.h"
|
||||
#include "errorwindow.h"
|
||||
#include "ethernetwidget.h"
|
||||
#include "generalwidget.h"
|
||||
#include "ipwidget.h"
|
||||
#include "mobilewidget.h"
|
||||
#include "netctlinteract.h"
|
||||
#include "netctlprofile.h"
|
||||
#include "passwdwidget.h"
|
||||
#include "pppoewidget.h"
|
||||
#include "settingswindow.h"
|
||||
#include "tunnelwidget.h"
|
||||
#include "tuntapwidget.h"
|
||||
#include "vlanwidget.h"
|
||||
#include "wpasupinteract.h"
|
||||
#include "wirelesswidget.h"
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent, const bool defaultSettings, const int tabNum)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << QString("defaultSettings") << defaultSettings;
|
||||
qDebug() << "[MainWindow]" << "[MainWindow]" << ":" << QString("tabNum") << tabNum;
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->tabWidget->setCurrentIndex(tabNum-1);
|
||||
|
||||
QString configPath = QDir::homePath() + QDir::separator() + QString(".config") +
|
||||
QDir::separator() + QString("netctl-gui.conf");
|
||||
settingsWin = new SettingsWindow(this, configPath);
|
||||
if (defaultSettings)
|
||||
settingsWin->setDefault();
|
||||
configuration = settingsWin->getSettings();
|
||||
|
||||
// gui
|
||||
generalWid = new GeneralWidget(this, configuration);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(generalWid);
|
||||
ipWid = new IpWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(ipWid);
|
||||
bridgeWid = new BridgeWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(bridgeWid);
|
||||
ethernetWid = new EthernetWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(ethernetWid);
|
||||
mobileWid = new MobileWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(mobileWid);
|
||||
pppoeWid = new PppoeWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(pppoeWid);
|
||||
tunnelWid = new TunnelWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(tunnelWid);
|
||||
tuntapWid = new TuntapWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(tuntapWid);
|
||||
vlanWid = new VlanWidget(this);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(vlanWid);
|
||||
wirelessWid = new WirelessWidget(this, configuration);
|
||||
ui->scrollAreaWidgetContents->layout()->addWidget(wirelessWid);
|
||||
// backend
|
||||
netctlCommand = new Netctl(this, configuration);
|
||||
netctlProfile = new NetctlProfile(this, configuration);
|
||||
wpaCommand = new WpaSup(this, configuration);
|
||||
|
||||
createActions();
|
||||
updateTabs(ui->tabWidget->currentIndex());
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Ready"));
|
||||
}
|
||||
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete netctlCommand;
|
||||
delete netctlProfile;
|
||||
delete wpaCommand;
|
||||
|
||||
delete bridgeWid;
|
||||
delete ethernetWid;
|
||||
delete generalWid;
|
||||
delete ipWid;
|
||||
delete mobileWid;
|
||||
delete pppoeWid;
|
||||
delete tunnelWid;
|
||||
delete tuntapWid;
|
||||
delete vlanWid;
|
||||
delete wirelessWid;
|
||||
|
||||
delete settingsWin;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::checkExternalApps(const QString apps = QString("all"))
|
||||
{
|
||||
QStringList commandLine;
|
||||
commandLine.append("which");
|
||||
commandLine.append(configuration[QString("SUDO_PATH")]);
|
||||
if ((apps == QString("netctl")) || (apps == QString("all"))) {
|
||||
commandLine.append(configuration[QString("NETCTL_PATH")]);
|
||||
}
|
||||
if ((apps == QString("wpasup")) || (apps == QString("all"))) {
|
||||
commandLine.append(configuration[QString("WPACLI_PATH")]);
|
||||
commandLine.append(configuration[QString("WPASUP_PATH")]);
|
||||
}
|
||||
QProcess command;
|
||||
qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Run cmd" << commandLine.join(QString(" "));
|
||||
command.start(commandLine.join(QString(" ")));
|
||||
command.waitForFinished(-1);
|
||||
qDebug() << "[MainWindow]" << "[checkExternalApps]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (command.exitCode() != 0)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::checkState(const QString state, const QString item)
|
||||
{
|
||||
if (item.contains(state))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// window signals
|
||||
void MainWindow::createActions()
|
||||
{
|
||||
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(updateTabs(int)));
|
||||
connect(ui->actionSettings, SIGNAL(triggered(bool)), settingsWin, SLOT(showWindow()));
|
||||
connect(ui->actionQuit, SIGNAL(triggered(bool)), this, SLOT(close()));
|
||||
|
||||
// main page events
|
||||
connect(ui->pushButton_mainRefresh, SIGNAL(clicked(bool)), this, SLOT(updateMainTab()));
|
||||
connect(ui->pushButton_mainEnable, SIGNAL(clicked(bool)), this, SLOT(mainTabEnableProfile()));
|
||||
connect(ui->pushButton_mainRestart, SIGNAL(clicked(bool)), this, SLOT(mainTabRestartProfile()));
|
||||
connect(ui->pushButton_mainStart, SIGNAL(clicked(bool)), this, SLOT(mainTabStartProfile()));
|
||||
connect(ui->tableWidget_main, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(mainTabStartProfile()));
|
||||
connect(ui->tableWidget_main, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(mainTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
|
||||
|
||||
// profile tab events
|
||||
connect(ui->lineEdit_profile, SIGNAL(returnPressed()), this, SLOT(profileTabLoadProfile()));
|
||||
connect(ui->pushButton_profile, SIGNAL(clicked(bool)), this, SLOT(profileTabBrowseProfile()));
|
||||
connect(ui->pushButton_profileClear, SIGNAL(clicked(bool)), this, SLOT(profileTabClear()));
|
||||
connect(ui->pushButton_profileSave, SIGNAL(clicked(bool)), this, SLOT(profileTabCreateProfile()));
|
||||
connect(ui->pushButton_profileLoad, SIGNAL(clicked(bool)), this, SLOT(profileTabLoadProfile()));
|
||||
connect(generalWid->connectionType, SIGNAL(currentIndexChanged(QString)), this, SLOT(profileTabChangeState(QString)));
|
||||
|
||||
// wifi page events
|
||||
connect(ui->pushButton_wifiRefresh, SIGNAL(clicked(bool)), this, SLOT(updateWifiTab()));
|
||||
connect(ui->pushButton_wifiStart, SIGNAL(clicked(bool)), this, SLOT(wifiTabStart()));
|
||||
connect(ui->tableWidget_wifi, SIGNAL(itemActivated(QTableWidgetItem *)), this, SLOT(wifiTabStart()));
|
||||
connect(ui->tableWidget_wifi, SIGNAL(currentItemChanged(QTableWidgetItem *, QTableWidgetItem *)), this, SLOT(wifiTabRefreshButtons(QTableWidgetItem *, QTableWidgetItem *)));
|
||||
}
|
||||
|
||||
|
||||
// window slots
|
||||
void MainWindow::updateTabs(const int tab)
|
||||
{
|
||||
if (tab == 0)
|
||||
updateMainTab();
|
||||
else if (tab == 1)
|
||||
updateProfileTab();
|
||||
else if (tab == 2)
|
||||
updateWifiTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateMainTab()
|
||||
{
|
||||
if (!checkExternalApps(QString("netctl"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "[MainWindow]" << "[updateMainTab]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QList<QStringList> profiles = netctlCommand->getProfileList();;
|
||||
|
||||
ui->tableWidget_main->setSortingEnabled(false);
|
||||
ui->tableWidget_main->selectRow(-1);
|
||||
ui->tableWidget_main->sortByColumn(0, Qt::AscendingOrder);
|
||||
ui->tableWidget_main->clear();
|
||||
ui->tableWidget_main->setRowCount(profiles.count());
|
||||
|
||||
// create header
|
||||
ui->tableWidget_main->setHorizontalHeaderLabels(QApplication::translate("MainWindow", "Name Description Status")
|
||||
.split(QString(" ")));
|
||||
// create items
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
// name
|
||||
ui->tableWidget_main->setItem(i, 0, new QTableWidgetItem(profiles[i][0]));
|
||||
ui->tableWidget_main->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
// description
|
||||
ui->tableWidget_main->setItem(i, 1, new QTableWidgetItem(profiles[i][1]));
|
||||
ui->tableWidget_main->item(i, 1)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
// status
|
||||
ui->tableWidget_main->setItem(i, 2, new QTableWidgetItem(profiles[i][2]));
|
||||
ui->tableWidget_main->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
ui->tableWidget_main->setSortingEnabled(true);
|
||||
ui->tableWidget_main->resizeRowsToContents();
|
||||
ui->tableWidget_main->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
||||
ui->tabWidget->setEnabled(true);
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated"));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateProfileTab()
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[updateProfileTab]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
profileTabClear();
|
||||
ui->tabWidget->setEnabled(true);
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated"));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateWifiTab()
|
||||
{
|
||||
wifiTabSetEnabled(checkExternalApps(QString("wpasup")));
|
||||
if (!checkExternalApps(QString("wpasup"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
|
||||
QList<QStringList> scanResults = wpaCommand->scanWifi();
|
||||
|
||||
qDebug() << "[MainWindow]" << "[updateWifiTab]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
ui->tableWidget_wifi->setSortingEnabled(false);
|
||||
ui->tableWidget_wifi->selectRow(-1);
|
||||
ui->tableWidget_wifi->sortByColumn(0, Qt::AscendingOrder);
|
||||
ui->tableWidget_wifi->clear();
|
||||
ui->tableWidget_wifi->setRowCount(scanResults.count());
|
||||
|
||||
// create header
|
||||
ui->tableWidget_wifi->setHorizontalHeaderLabels(QApplication::translate("MainWindow", "Name Status Signal Security")
|
||||
.split(QString(" ")));
|
||||
// create items
|
||||
for (int i=0; i<scanResults.count(); i++) {
|
||||
// name
|
||||
ui->tableWidget_wifi->setItem(i, 0, new QTableWidgetItem(scanResults[i][0]));
|
||||
ui->tableWidget_wifi->item(i, 0)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||
// status
|
||||
ui->tableWidget_wifi->setItem(i, 1, new QTableWidgetItem(scanResults[i][1]));
|
||||
ui->tableWidget_wifi->item(i, 1)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
// signal
|
||||
ui->tableWidget_wifi->setItem(i, 2, new QTableWidgetItem(scanResults[i][2]));
|
||||
ui->tableWidget_wifi->item(i, 2)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
// security
|
||||
ui->tableWidget_wifi->setItem(i, 3, new QTableWidgetItem(scanResults[i][3]));
|
||||
ui->tableWidget_wifi->item(i, 3)->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
}
|
||||
|
||||
ui->tableWidget_wifi->setSortingEnabled(true);
|
||||
ui->tableWidget_wifi->resizeRowsToContents();
|
||||
ui->tableWidget_wifi->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
|
||||
ui->tabWidget->setEnabled(true);
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Updated"));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
// main tab slots
|
||||
void MainWindow::mainTabEnableProfile()
|
||||
{
|
||||
if (!checkExternalApps(QString("netctl"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == 0)
|
||||
return;
|
||||
|
||||
qDebug() << "[MainWindow]" << "[mainTabEnableProfile]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
netctlCommand->enableProfile(profile);
|
||||
QString item = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text();
|
||||
if (checkState(QString("enabled"), item)) {
|
||||
if (netctlCommand->isProfileEnabled(profile))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
}
|
||||
else {
|
||||
if (netctlCommand->isProfileEnabled(profile))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::mainTabRestartProfile()
|
||||
{
|
||||
if (!checkExternalApps(QString("netctl"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == 0)
|
||||
return;
|
||||
|
||||
qDebug() << "[MainWindow]" << "[mainTabRestartProfile]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
netctlCommand->restartProfile(profile);
|
||||
if (netctlCommand->isProfileActive(profile))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::mainTabStartProfile()
|
||||
{
|
||||
if (!checkExternalApps(QString("netctl"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (ui->tableWidget_main->currentItem() == 0)
|
||||
return;
|
||||
|
||||
qDebug() << "[MainWindow]" << "[mainTabStartProfile]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 0)->text();
|
||||
netctlCommand->startProfile(profile);
|
||||
QString item = ui->tableWidget_main->item(ui->tableWidget_main->currentItem()->row(), 2)->text();
|
||||
if (checkState(QString("inactive"), item)) {
|
||||
if (netctlCommand->isProfileActive(profile))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
}
|
||||
else {
|
||||
if (netctlCommand->isProfileActive(profile))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
updateMainTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
if (!checkExternalApps(QString("netctl"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (current == 0) {
|
||||
ui->pushButton_mainEnable->setDisabled(true);
|
||||
ui->pushButton_mainRestart->setDisabled(true);
|
||||
ui->pushButton_mainStart->setDisabled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "[MainWindow]" << "[mainTabRefreshButtons]";
|
||||
ui->pushButton_mainEnable->setEnabled(true);
|
||||
ui->pushButton_mainStart->setEnabled(true);
|
||||
|
||||
QString item = ui->tableWidget_main->item(current->row(), 2)->text();
|
||||
if (!checkState(QString("inactive"), item)) {
|
||||
ui->pushButton_mainRestart->setEnabled(true);
|
||||
ui->pushButton_mainStart->setText(QApplication::translate("MainWindow", "Stop"));
|
||||
}
|
||||
else {
|
||||
ui->pushButton_mainRestart->setDisabled(true);
|
||||
ui->pushButton_mainStart->setText(QApplication::translate("MainWindow", "Start"));
|
||||
}
|
||||
if (checkState(QString("enabled"), item))
|
||||
ui->pushButton_mainEnable->setText(QApplication::translate("MainWindow", "Disable"));
|
||||
else
|
||||
ui->pushButton_mainEnable->setText(QApplication::translate("MainWindow", "Enable"));
|
||||
}
|
||||
|
||||
|
||||
// profile tab slots
|
||||
void MainWindow::profileTabBrowseProfile()
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[profileTabBrowseProfile]";
|
||||
QString filename = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
QApplication::translate("MainWindow", "Save profile as..."),
|
||||
QString("/etc/netctl/"),
|
||||
QApplication::translate("MainWindow", "Profile (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_profile->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::profileTabChangeState(const QString current)
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[profileTabChangeState]";
|
||||
if (current == QString("ethernet")) {
|
||||
generalWid->setShown(true);
|
||||
ipWid->setShown(true);
|
||||
bridgeWid->setShown(false);
|
||||
ethernetWid->setShown(true);
|
||||
mobileWid->setShown(false);
|
||||
pppoeWid->setShown(false);
|
||||
tunnelWid->setShown(false);
|
||||
tuntapWid->setShown(false);
|
||||
vlanWid->setShown(false);
|
||||
wirelessWid->setShown(false);
|
||||
}
|
||||
else if (current == QString("wireless")) {
|
||||
generalWid->setShown(true);
|
||||
ipWid->setShown(true);
|
||||
bridgeWid->setShown(false);
|
||||
ethernetWid->setShown(false);
|
||||
mobileWid->setShown(false);
|
||||
pppoeWid->setShown(false);
|
||||
tunnelWid->setShown(false);
|
||||
tuntapWid->setShown(false);
|
||||
vlanWid->setShown(false);
|
||||
wirelessWid->setShown(true);
|
||||
}
|
||||
else if ((current == QString("bond")) ||
|
||||
(current == QString("dummy"))) {
|
||||
generalWid->setShown(true);
|
||||
ipWid->setShown(true);
|
||||
bridgeWid->setShown(false);
|
||||
ethernetWid->setShown(false);
|
||||
mobileWid->setShown(false);
|
||||
pppoeWid->setShown(false);
|
||||
tunnelWid->setShown(false);
|
||||
tuntapWid->setShown(false);
|
||||
vlanWid->setShown(false);
|
||||
wirelessWid->setShown(false);
|
||||
}
|
||||
else if (current == QString("bridge")) {
|
||||
generalWid->setShown(true);
|
||||
ipWid->setShown(true);
|
||||
bridgeWid->setShown(true);
|
||||
ethernetWid->setShown(false);
|
||||
mobileWid->setShown(false);
|
||||
pppoeWid->setShown(false);
|
||||
tunnelWid->setShown(false);
|
||||
tuntapWid->setShown(false);
|
||||
vlanWid->setShown(false);
|
||||
wirelessWid->setShown(false);
|
||||
}
|
||||
else if (current == QString("pppoe")) {
|
||||
generalWid->setShown(true);
|
||||
ipWid->setShown(false);
|
||||
bridgeWid->setShown(false);
|
||||
ethernetWid->setShown(false);
|
||||
mobileWid->setShown(false);
|
||||
pppoeWid->setShown(true);
|
||||
tunnelWid->setShown(false);
|
||||
tuntapWid->setShown(false);
|
||||
vlanWid->setShown(false);
|
||||
wirelessWid->setShown(false);
|
||||
}
|
||||
else if (current == QString("mobile_ppp")) {
|
||||
generalWid->setShown(true);
|
||||
ipWid->setShown(false);
|
||||
bridgeWid->setShown(false);
|
||||
ethernetWid->setShown(false);
|
||||
mobileWid->setShown(true);
|
||||
pppoeWid->setShown(false);
|
||||
tunnelWid->setShown(false);
|
||||
tuntapWid->setShown(false);
|
||||
vlanWid->setShown(false);
|
||||
wirelessWid->setShown(false);
|
||||
}
|
||||
else if (current == QString("tunnel")) {
|
||||
generalWid->setShown(true);
|
||||
ipWid->setShown(true);
|
||||
bridgeWid->setShown(false);
|
||||
ethernetWid->setShown(false);
|
||||
mobileWid->setShown(false);
|
||||
pppoeWid->setShown(false);
|
||||
tunnelWid->setShown(true);
|
||||
tuntapWid->setShown(false);
|
||||
vlanWid->setShown(false);
|
||||
wirelessWid->setShown(false);
|
||||
}
|
||||
else if (current == QString("tuntap")) {
|
||||
generalWid->setShown(true);
|
||||
ipWid->setShown(true);
|
||||
bridgeWid->setShown(false);
|
||||
ethernetWid->setShown(false);
|
||||
mobileWid->setShown(false);
|
||||
pppoeWid->setShown(false);
|
||||
tunnelWid->setShown(false);
|
||||
tuntapWid->setShown(true);
|
||||
vlanWid->setShown(false);
|
||||
wirelessWid->setShown(false);
|
||||
}
|
||||
else if (current == QString("vlan")) {
|
||||
generalWid->setShown(true);
|
||||
ipWid->setShown(true);
|
||||
bridgeWid->setShown(false);
|
||||
ethernetWid->setShown(true);
|
||||
mobileWid->setShown(false);
|
||||
pppoeWid->setShown(false);
|
||||
tunnelWid->setShown(false);
|
||||
tuntapWid->setShown(false);
|
||||
vlanWid->setShown(true);
|
||||
wirelessWid->setShown(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::profileTabClear()
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[profileTabClear]";
|
||||
ui->lineEdit_profile->clear();
|
||||
|
||||
generalWid->clear();
|
||||
ipWid->clear();
|
||||
bridgeWid->clear();
|
||||
ethernetWid->clear();
|
||||
mobileWid->clear();
|
||||
pppoeWid->clear();
|
||||
tunnelWid->clear();
|
||||
tuntapWid->clear();
|
||||
vlanWid->clear();
|
||||
wirelessWid->clear();
|
||||
|
||||
profileTabChangeState(generalWid->connectionType->currentText());
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::profileTabCreateProfile()
|
||||
{
|
||||
// error checking
|
||||
if (ui->lineEdit_profile->text().isEmpty()) {
|
||||
errorWin = new ErrorWindow(this, 3);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (generalWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 4);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (generalWid->isOk() == 2) {
|
||||
errorWin = new ErrorWindow(this, 5);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if ((generalWid->connectionType->currentText() == QString("ethernet")) ||
|
||||
(generalWid->connectionType->currentText() == QString("wireless")) ||
|
||||
(generalWid->connectionType->currentText() == QString("bond")) ||
|
||||
(generalWid->connectionType->currentText() == QString("dummy")) ||
|
||||
(generalWid->connectionType->currentText() == QString("bridge")) ||
|
||||
(generalWid->connectionType->currentText() == QString("tunnel")) ||
|
||||
(generalWid->connectionType->currentText() == QString("tuntap")) ||
|
||||
(generalWid->connectionType->currentText() == QString("vlan"))) {
|
||||
if (ipWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 6);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (ipWid->isOk() == 2) {
|
||||
errorWin = new ErrorWindow(this, 6);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (generalWid->connectionType->currentText() == QString("ethernet")) {
|
||||
if (ethernetWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 7);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("wireless")) {
|
||||
if (wirelessWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 8);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (wirelessWid->isOk() == 2) {
|
||||
errorWin = new ErrorWindow(this, 9);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (wirelessWid->isOk() == 3) {
|
||||
errorWin = new ErrorWindow(this, 10);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (wirelessWid->isOk() == 4) {
|
||||
errorWin = new ErrorWindow(this, 7);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (wirelessWid->isOk() == 5) {
|
||||
errorWin = new ErrorWindow(this, 11);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("bridge")) {
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("pppoe")) {
|
||||
if (pppoeWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 7);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (pppoeWid->isOk() == 2) {
|
||||
errorWin = new ErrorWindow(this, 12);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (pppoeWid->isOk() == 3) {
|
||||
errorWin = new ErrorWindow(this, 13);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
else if (pppoeWid->isOk() == 4) {
|
||||
errorWin = new ErrorWindow(this, 12);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
|
||||
if (mobileWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 14);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (mobileWid->isOk() == 2) {
|
||||
errorWin = new ErrorWindow(this, 7);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("tunnel")) {
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("tuntap")) {
|
||||
if (tuntapWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 15);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (tuntapWid->isOk() == 2) {
|
||||
errorWin = new ErrorWindow(this, 15);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("vlan")) {
|
||||
if (ethernetWid->isOk() == 1) {
|
||||
errorWin = new ErrorWindow(this, 7);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "[MainWindow]" << "[profileTabCreateProfile]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
// read settings
|
||||
QString profile = ui->lineEdit_profile->text();
|
||||
QMap<QString, QString> settings;
|
||||
settings = generalWid->getSettings();
|
||||
if (generalWid->connectionType->currentText() == QString("ethernet")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = ethernetWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("wireless")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = wirelessWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
}
|
||||
else if ((generalWid->connectionType->currentText() == QString("bond")) ||
|
||||
(generalWid->connectionType->currentText() == QString("dummy"))) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("bridge")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = bridgeWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("pppoe")) {
|
||||
QMap<QString, QString> addSettings = pppoeWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
|
||||
QMap<QString, QString> addSettings = mobileWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("tunnel")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = tunnelWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("tuntap")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = tuntapWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("vlan")) {
|
||||
QMap<QString, QString> addSettings = ipWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = ethernetWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
addSettings = vlanWid->getSettings();
|
||||
for (int i=0; i<addSettings.keys().count(); i++)
|
||||
settings.insert(addSettings.keys()[i], addSettings[addSettings.keys()[i]]);
|
||||
}
|
||||
|
||||
// call netctlprofile
|
||||
QString profileTempName = netctlProfile->createProfile(profile, settings);
|
||||
if (netctlProfile->copyProfile(profileTempName))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
|
||||
updateProfileTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::profileTabLoadProfile()
|
||||
{
|
||||
qDebug() << "[MainWindow]" << "[profileTabLoadProfile]";
|
||||
QString profile = ui->lineEdit_profile->text();
|
||||
QMap<QString, QString> settings = netctlProfile->getSettingsFromProfile(profile);
|
||||
|
||||
generalWid->setSettings(settings);
|
||||
if (generalWid->connectionType->currentText() == QString("ethernet")) {
|
||||
ipWid->setSettings(settings);
|
||||
ethernetWid->setSettings(settings);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("wireless")) {
|
||||
ipWid->setSettings(settings);
|
||||
wirelessWid->setSettings(settings);
|
||||
}
|
||||
else if ((generalWid->connectionType->currentText() == QString("bond")) ||
|
||||
(generalWid->connectionType->currentText() == QString("dummy"))) {
|
||||
ipWid->setSettings(settings);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("bridge")) {
|
||||
ipWid->setSettings(settings);
|
||||
bridgeWid->setSettings(settings);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("pppoe")) {
|
||||
pppoeWid->setSettings(settings);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("mobile_ppp")) {
|
||||
mobileWid->setSettings(settings);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("tunnel")) {
|
||||
ipWid->setSettings(settings);
|
||||
tunnelWid->setSettings(settings);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("tuntap")) {
|
||||
ipWid->setSettings(settings);
|
||||
tuntapWid->setSettings(settings);
|
||||
}
|
||||
else if (generalWid->connectionType->currentText() == QString("vlan")) {
|
||||
ipWid->setSettings(settings);
|
||||
ethernetWid->setSettings(settings);
|
||||
vlanWid->setSettings(settings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// wifi tab slots
|
||||
void MainWindow::wifiTabSetEnabled(const bool state)
|
||||
{
|
||||
if (state) {
|
||||
ui->tableWidget_wifi->show();
|
||||
ui->pushButton_wifiRefresh->setEnabled(true);
|
||||
ui->label_wifi->hide();
|
||||
}
|
||||
else {
|
||||
ui->tableWidget_wifi->hide();
|
||||
ui->pushButton_wifiRefresh->setDisabled(true);
|
||||
ui->pushButton_wifiStart->setDisabled(true);
|
||||
ui->label_wifi->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::connectToUnknownEssid(const QString passwd)
|
||||
{
|
||||
if (!passwd.isEmpty())
|
||||
delete passwdWid;
|
||||
|
||||
qDebug() << "[MainWindow]" << "[connectToUnknownEssid]";
|
||||
QMap<QString, QString> settings;
|
||||
settings[QString("Description")] = QString("'Automatically generated profile by Netctl GUI'");
|
||||
settings[QString("Interface")] = wpaCommand->getInterfaceList()[0];
|
||||
settings[QString("Connection")] = QString("wireless");
|
||||
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text();
|
||||
if (checkState(QString("WPA"), security))
|
||||
settings[QString("Security")] = QString("wpa");
|
||||
else if (checkState(QString("wep"), security))
|
||||
settings[QString("Security")] = QString("wep");
|
||||
else
|
||||
settings[QString("Security")] = QString("none");
|
||||
settings[QString("ESSID")] = QString("'") +
|
||||
ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() +
|
||||
QString("'");
|
||||
if (!passwd.isEmpty())
|
||||
settings[QString("Key")] = QString("'") + passwd + QString("'");
|
||||
settings[QString("IP")] = QString("dhcp");
|
||||
|
||||
QString profile = QString("netctl-gui-") + settings[QString("ESSID")];
|
||||
profile.remove(QString("'"));
|
||||
QString profileTempName = netctlProfile->createProfile(profile, settings);
|
||||
if (netctlProfile->copyProfile(profileTempName))
|
||||
netctlCommand->startProfile(profile);
|
||||
if (netctlCommand->isProfileActive(profile))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
updateWifiTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::wifiTabStart()
|
||||
{
|
||||
if (!checkExternalApps(QString("wpasup"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (ui->tableWidget_wifi->currentItem() == 0)
|
||||
return;
|
||||
if (ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text() == QString("<hidden>")) {
|
||||
ui->pushButton_wifiStart->setDisabled(true);
|
||||
errorWin = new ErrorWindow(this, 2);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "[MainWindow]" << "[wifiTabStart]";
|
||||
ui->tabWidget->setDisabled(true);
|
||||
QString profile = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 0)->text();
|
||||
QString item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text();
|
||||
if (checkState(QString("exists"), item)) {
|
||||
QString profileName = wpaCommand->existentProfile(profile);
|
||||
netctlCommand->startProfile(profileName);
|
||||
item = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 1)->text();
|
||||
if (checkState(QString("inactive"), item)) {
|
||||
if (netctlCommand->isProfileActive(profileName))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
}
|
||||
else {
|
||||
if (netctlCommand->isProfileActive(profileName))
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Done"));
|
||||
else
|
||||
ui->statusBar->showMessage(QApplication::translate("MainWindow", "Error"));
|
||||
}
|
||||
}
|
||||
else {
|
||||
QString security = ui->tableWidget_wifi->item(ui->tableWidget_wifi->currentItem()->row(), 3)->text();
|
||||
if (checkState(QString("none"), security))
|
||||
return connectToUnknownEssid(QString(""));
|
||||
else {
|
||||
passwdWid = new PasswdWidget(this);
|
||||
int widgetWidth = 270;
|
||||
int widgetHeight = 86;
|
||||
int x = (width() - widgetWidth) / 2;
|
||||
int y = (height() - widgetHeight) / 2;
|
||||
passwdWid->setGeometry(x, y, widgetWidth, widgetHeight);
|
||||
passwdWid->show();
|
||||
passwdWid->setFocusToLineEdit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
updateWifiTab();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous)
|
||||
{
|
||||
Q_UNUSED(previous);
|
||||
if (!checkExternalApps(QString("wpasup"))) {
|
||||
errorWin = new ErrorWindow(this, 1);
|
||||
errorWin->show();
|
||||
return;
|
||||
}
|
||||
if (current == 0) {
|
||||
ui->pushButton_wifiStart->setDisabled(true);
|
||||
return;
|
||||
}
|
||||
if (ui->tableWidget_wifi->item(current->row(), 0)->text() == QString("<hidden>")) {
|
||||
ui->pushButton_wifiStart->setDisabled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "[MainWindow]" << "[wifiTabRefreshButtons]";
|
||||
ui->pushButton_wifiStart->setEnabled(true);
|
||||
QString item = ui->tableWidget_wifi->item(current->row(), 1)->text();
|
||||
if (checkState(QString("exists"), item)) {
|
||||
if (!checkState(QString("inactive"), item))
|
||||
ui->pushButton_wifiStart->setText(QApplication::translate("MainWindow", "Stop"));
|
||||
else
|
||||
ui->pushButton_wifiStart->setText(QApplication::translate("MainWindow", "Start"));
|
||||
}
|
||||
else
|
||||
ui->pushButton_wifiStart->setText(QApplication::translate("MainWindow", "Start"));
|
||||
}
|
110
sources/gui/src/mainwindow.h
Normal file
110
sources/gui/src/mainwindow.h
Normal file
@ -0,0 +1,110 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
|
||||
class BridgeWidget;
|
||||
class ErrorWindow;
|
||||
class EthernetWidget;
|
||||
class GeneralWidget;
|
||||
class IpWidget;
|
||||
class MobileWidget;
|
||||
class Netctl;
|
||||
class NetctlProfile;
|
||||
class PasswdWidget;
|
||||
class PppoeWidget;
|
||||
class SettingsWindow;
|
||||
class TunnelWidget;
|
||||
class TuntapWidget;
|
||||
class VlanWidget;
|
||||
class WirelessWidget;
|
||||
class WpaSup;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0,
|
||||
const bool defaultSettings = false,
|
||||
const int tabNum = 1);
|
||||
~MainWindow();
|
||||
Netctl *netctlCommand;
|
||||
NetctlProfile *netctlProfile;
|
||||
WpaSup *wpaCommand;
|
||||
|
||||
public slots:
|
||||
void updateTabs(const int tab);
|
||||
// wifi tab slots
|
||||
void connectToUnknownEssid(const QString passwd);
|
||||
|
||||
private slots:
|
||||
void updateMainTab();
|
||||
void updateProfileTab();
|
||||
void updateWifiTab();
|
||||
// main tab slots
|
||||
void mainTabEnableProfile();
|
||||
void mainTabRestartProfile();
|
||||
void mainTabStartProfile();
|
||||
void mainTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
// profile tab slots
|
||||
void profileTabBrowseProfile();
|
||||
void profileTabChangeState(const QString current);
|
||||
void profileTabClear();
|
||||
void profileTabCreateProfile();
|
||||
void profileTabLoadProfile();
|
||||
// wifi tab slots
|
||||
void wifiTabSetEnabled(const bool state);
|
||||
void wifiTabStart();
|
||||
void wifiTabRefreshButtons(QTableWidgetItem *current, QTableWidgetItem *previous);
|
||||
|
||||
private:
|
||||
// ui
|
||||
Ui::MainWindow *ui;
|
||||
BridgeWidget *bridgeWid;
|
||||
EthernetWidget *ethernetWid;
|
||||
GeneralWidget *generalWid;
|
||||
IpWidget *ipWid;
|
||||
MobileWidget *mobileWid;
|
||||
PppoeWidget *pppoeWid;
|
||||
TunnelWidget *tunnelWid;
|
||||
TuntapWidget *tuntapWid;
|
||||
VlanWidget *vlanWid;
|
||||
WirelessWidget *wirelessWid;
|
||||
// backend
|
||||
ErrorWindow *errorWin;
|
||||
PasswdWidget *passwdWid;
|
||||
SettingsWindow *settingsWin;
|
||||
bool checkExternalApps(const QString apps);
|
||||
bool checkState(const QString state, const QString item);
|
||||
void createActions();
|
||||
// configuration
|
||||
QMap<QString, QString> configuration;
|
||||
};
|
||||
|
||||
|
||||
#endif /* MAINWINDOW_H */
|
408
sources/gui/src/mainwindow.ui
Normal file
408
sources/gui/src/mainwindow.ui
Normal file
@ -0,0 +1,408 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>491</width>
|
||||
<height>519</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Netctl GUI</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_main">
|
||||
<attribute name="title">
|
||||
<string>Connect to profile</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget_main">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Description</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mainButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainRefresh">
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_mainButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainEnable">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Enable</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainRestart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restart</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mainStart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_new">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Create a new profile</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_profile">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_profile">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_profile"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_profile">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>98</width>
|
||||
<height>28</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="scrollArea_layout"/>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_newProfileButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_profileClear">
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_profileLoad">
|
||||
<property name="text">
|
||||
<string>Load</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_newProfileButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_profileSave">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_wifi">
|
||||
<attribute name="title">
|
||||
<string>Connect to Wi-Fi</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wifi">
|
||||
<property name="text">
|
||||
<string>Please install 'wpa_supplicant' before using it</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="tableWidget_wifi">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Signal</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Security</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wifiButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wifiRefresh">
|
||||
<property name="text">
|
||||
<string>Refresh</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_wifiButtons">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wifiStart">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Start</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>491</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuMenu">
|
||||
<property name="title">
|
||||
<string>Menu</string>
|
||||
</property>
|
||||
<addaction name="actionSettings"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<addaction name="menuMenu"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionSettings">
|
||||
<property name="text">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<property name="text">
|
||||
<string>Quit</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>tableWidget_main</tabstop>
|
||||
<tabstop>pushButton_mainRefresh</tabstop>
|
||||
<tabstop>pushButton_mainEnable</tabstop>
|
||||
<tabstop>pushButton_mainRestart</tabstop>
|
||||
<tabstop>pushButton_mainStart</tabstop>
|
||||
<tabstop>lineEdit_profile</tabstop>
|
||||
<tabstop>pushButton_profile</tabstop>
|
||||
<tabstop>scrollArea</tabstop>
|
||||
<tabstop>pushButton_profileClear</tabstop>
|
||||
<tabstop>pushButton_profileLoad</tabstop>
|
||||
<tabstop>pushButton_profileSave</tabstop>
|
||||
<tabstop>tableWidget_wifi</tabstop>
|
||||
<tabstop>pushButton_wifiRefresh</tabstop>
|
||||
<tabstop>pushButton_wifiStart</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
170
sources/gui/src/mobilewidget.cpp
Normal file
170
sources/gui/src/mobilewidget.cpp
Normal file
@ -0,0 +1,170 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "mobilewidget.h"
|
||||
#include "ui_mobilewidget.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QFile>
|
||||
|
||||
|
||||
MobileWidget::MobileWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::MobileWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createActions();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
MobileWidget::~MobileWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::clear()
|
||||
{
|
||||
ui->lineEdit_username->clear();
|
||||
ui->lineEdit_password->clear();
|
||||
ui->lineEdit_apn->clear();
|
||||
ui->lineEdit_pin->clear();
|
||||
ui->comboBox_mode->setCurrentIndex(0);
|
||||
ui->spinBox_fail->setValue(5);
|
||||
ui->checkBox_route->setCheckState(Qt::Checked);
|
||||
ui->checkBox_dns->setCheckState(Qt::Checked);
|
||||
ui->lineEdit_options->clear();
|
||||
|
||||
ui->pushButton_mobileAdvanced->setChecked(false);;
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_mobileAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
connect(ui->pushButton_options, SIGNAL(clicked(bool)), this, SLOT(selectOptionsFile()));
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::selectOptionsFile()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("MobileWidget", "Select options file"),
|
||||
QDir::currentPath(),
|
||||
QApplication::translate("MobileWidget", "Configuration files (*.conf)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_options->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_mobileAdvanced->isChecked()) {
|
||||
ui->widget_mobileAdvanced->setShown(true);
|
||||
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
ui->widget_mobileAdvanced->setHidden(true);
|
||||
ui->pushButton_mobileAdvanced->setText(QApplication::translate("MobileWidget", "Show advanced"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> MobileWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> mobileSettings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return mobileSettings;
|
||||
|
||||
if (!ui->lineEdit_username->text().isEmpty())
|
||||
mobileSettings[QString("User")] = QString("'") + ui->lineEdit_username->text() + QString("'");
|
||||
if (!ui->lineEdit_password->text().isEmpty())
|
||||
mobileSettings[QString("Password")] = QString("'") + ui->lineEdit_password->text() + QString("'");
|
||||
mobileSettings[QString("AccessPointName")] = ui->lineEdit_apn->text();
|
||||
if (!ui->lineEdit_pin->text().isEmpty())
|
||||
mobileSettings[QString("PIN")] = QString("'") + ui->lineEdit_pin->text() + QString("'");
|
||||
else
|
||||
mobileSettings[QString("PIN")] = QString("None");
|
||||
mobileSettings[QString("Mode")] = ui->comboBox_mode->currentText();
|
||||
if (ui->spinBox_fail->value() != 5)
|
||||
mobileSettings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
|
||||
if (ui->checkBox_route->checkState() == Qt::Unchecked)
|
||||
mobileSettings[QString("DefaultRoute")] = QString("false");
|
||||
if (ui->checkBox_dns->checkState() == Qt::Unchecked)
|
||||
mobileSettings[QString("UsePeerDNS")] = QString("false");
|
||||
if (!ui->lineEdit_options->text().isEmpty())
|
||||
mobileSettings[QString("OptionsFile")] = QString("'") + ui->lineEdit_options->text() + QString("'");
|
||||
|
||||
return mobileSettings;
|
||||
}
|
||||
|
||||
|
||||
int MobileWidget::isOk()
|
||||
{
|
||||
// APN is not set
|
||||
if (ui->lineEdit_apn->text().isEmpty())
|
||||
return 1;
|
||||
// config file doesn't exist
|
||||
if (!ui->lineEdit_options->text().isEmpty())
|
||||
if (!QFile(ui->lineEdit_options->text()).exists())
|
||||
return 2;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void MobileWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
QMap<QString, QString> mobileSettings = settings;
|
||||
|
||||
if (mobileSettings.contains(QString("User")))
|
||||
ui->lineEdit_username->setText(mobileSettings[QString("User")].remove(QString("'")));
|
||||
if (mobileSettings.contains(QString("Password")))
|
||||
ui->lineEdit_password->setText(mobileSettings[QString("Password")].remove(QString("'")));
|
||||
if (mobileSettings.contains(QString("AccessPointName")))
|
||||
ui->lineEdit_apn->setText(mobileSettings[QString("AccessPointName")].remove(QString("'")));
|
||||
if (mobileSettings.contains(QString("PIN")))
|
||||
ui->lineEdit_pin->setText(mobileSettings[QString("PIN")].remove(QString("'")));
|
||||
if (mobileSettings.contains(QString("Mode")))
|
||||
for (int i=0; i<ui->comboBox_mode->count(); i++)
|
||||
if (mobileSettings[QString("Mode")].remove(QString("'")) == ui->comboBox_mode->itemText(i))
|
||||
ui->comboBox_mode->setCurrentIndex(i);
|
||||
if (mobileSettings.contains(QString("MaxFail")))
|
||||
ui->spinBox_fail->setValue(mobileSettings[QString("MaxFail")].toInt());
|
||||
if (mobileSettings.contains(QString("DefaultRoute")))
|
||||
if (mobileSettings[QString("DefaultRoute")].remove(QString("'")) == QString("false"))
|
||||
ui->checkBox_route->setCheckState(Qt::Unchecked);
|
||||
if (mobileSettings.contains(QString("UsePeerDNS")))
|
||||
if (mobileSettings[QString("UsePeerDNS")].remove(QString("'")) == QString("false"))
|
||||
ui->checkBox_dns->setCheckState(Qt::Unchecked);
|
||||
if (mobileSettings.contains(QString("OptionsFile")))
|
||||
ui->lineEdit_options->setText(mobileSettings[QString("OptionsFile")].remove(QString("'")));
|
||||
}
|
53
sources/gui/src/mobilewidget.h
Normal file
53
sources/gui/src/mobilewidget.h
Normal file
@ -0,0 +1,53 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef MOBILEWIDGET_H
|
||||
#define MOBILEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class MobileWidget;
|
||||
}
|
||||
|
||||
class MobileWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MobileWidget(QWidget *parent = 0);
|
||||
~MobileWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private slots:
|
||||
void selectOptionsFile();
|
||||
void showAdvanced();
|
||||
|
||||
private:
|
||||
Ui::MobileWidget *ui;
|
||||
void createActions();
|
||||
};
|
||||
|
||||
|
||||
#endif /* MOBILEWIDGET_H */
|
313
sources/gui/src/mobilewidget.ui
Normal file
313
sources/gui/src/mobilewidget.ui
Normal file
@ -0,0 +1,313 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MobileWidget</class>
|
||||
<widget class="QWidget" name="MobileWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>445</width>
|
||||
<height>370</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_mobile">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Mobile PPP settings</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_mobile">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_username">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_username">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Username</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_username">
|
||||
<property name="toolTip">
|
||||
<string>The username and password to connect with</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_password">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_password">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password">
|
||||
<property name="toolTip">
|
||||
<string>The username and password to connect with</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_apn">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_apn">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Access point name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_apn">
|
||||
<property name="toolTip">
|
||||
<string>The access point (apn) to connect on</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_pin">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_pin">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PIN</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_pin">
|
||||
<property name="toolTip">
|
||||
<string>If your modem requires a PIN to unlock, use this option</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mode">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mode">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mode">
|
||||
<property name="toolTip">
|
||||
<string>This option is used to specify the connection mode</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>None</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3Gpref</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>3Gonly</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>GPRSpref</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>GPRSonly</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mobileAdvanced">
|
||||
<item>
|
||||
<spacer name="spacer_mobileAdvanced">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_mobileAdvanced">
|
||||
<property name="text">
|
||||
<string>Show advanced</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_mobileAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fail">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fail">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Max fail</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_fail">
|
||||
<property name="toolTip">
|
||||
<string>The number of consecutive failed connection attempts to tolerate</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_route">
|
||||
<property name="toolTip">
|
||||
<string>Use the default route provided by the peer</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default route</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_dns">
|
||||
<property name="toolTip">
|
||||
<string>Use the DNS provided by the peer</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use peer DNS</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_options">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_options">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Options file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_options">
|
||||
<property name="toolTip">
|
||||
<string>A file to read additional pppd options from</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_options">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>lineEdit_username</tabstop>
|
||||
<tabstop>lineEdit_password</tabstop>
|
||||
<tabstop>lineEdit_apn</tabstop>
|
||||
<tabstop>lineEdit_pin</tabstop>
|
||||
<tabstop>comboBox_mode</tabstop>
|
||||
<tabstop>pushButton_mobileAdvanced</tabstop>
|
||||
<tabstop>spinBox_fail</tabstop>
|
||||
<tabstop>checkBox_route</tabstop>
|
||||
<tabstop>checkBox_dns</tabstop>
|
||||
<tabstop>lineEdit_options</tabstop>
|
||||
<tabstop>pushButton_options</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
228
sources/gui/src/netctlinteract.cpp
Normal file
228
sources/gui/src/netctlinteract.cpp
Normal file
@ -0,0 +1,228 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "netctlinteract.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QProcess>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
Netctl::Netctl(MainWindow *wid, const QMap<QString, QString> settings)
|
||||
: parent(wid)
|
||||
{
|
||||
netctlCommand = settings[QString("NETCTL_PATH")];
|
||||
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
||||
sudoCommand = settings[QString("SUDO_PATH")];
|
||||
}
|
||||
|
||||
|
||||
Netctl::~Netctl()
|
||||
{
|
||||
delete profileDirectory;
|
||||
}
|
||||
|
||||
|
||||
// functions
|
||||
QString Netctl::getNetctlOutput(const bool sudo, const QString commandLine, const QString profile)
|
||||
{
|
||||
QProcess command;
|
||||
QString commandText;
|
||||
if (sudo)
|
||||
commandText = sudoCommand + QString(" ") + netctlCommand + QString(" ") + commandLine +
|
||||
QString(" ") + profile;
|
||||
else
|
||||
commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile;
|
||||
qDebug() << "[Netctl]" << "[getNetctlOutput]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
return command.readAllStandardOutput();
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::netctlCall(const bool sudo, const QString commandLine, const QString profile)
|
||||
{
|
||||
QProcess command;
|
||||
QString commandText;
|
||||
if (sudo)
|
||||
commandText = sudoCommand + QString(" ") + netctlCommand + QString(" ") + commandLine +
|
||||
QString(" ") + profile;
|
||||
else
|
||||
commandText = netctlCommand + QString(" ") + commandLine + QString(" ") + profile;
|
||||
qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
qDebug() << "[Netctl]" << "[netctlCall]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (command.exitCode() == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// general information
|
||||
QList<QStringList> Netctl::getProfileList()
|
||||
{
|
||||
QList<QStringList> fullProfilesInfo;
|
||||
QStringList profiles = profileDirectory->entryList(QDir::Files);
|
||||
QStringList descriptions = getProfileDescriptions(profiles);
|
||||
QStringList statuses = getProfileStatuses(profiles);
|
||||
|
||||
for (int i=0; i<profiles.count(); i++) {
|
||||
QStringList profileInfo;
|
||||
profileInfo.append(profiles[i]);
|
||||
profileInfo.append(descriptions[i]);
|
||||
profileInfo.append(statuses[i]);
|
||||
fullProfilesInfo.append(profileInfo);
|
||||
}
|
||||
return fullProfilesInfo;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileDescriptions(const QStringList profileList)
|
||||
{
|
||||
QStringList descriptions;
|
||||
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profileList[i];
|
||||
qDebug() << "[Netctl]" << "[getProfileDescriptions]" << ":" << "Check" << profileUrl;
|
||||
QFile profile(profileUrl);
|
||||
QString fileStr;
|
||||
if (profile.open(QIODevice::ReadOnly))
|
||||
while (true) {
|
||||
fileStr = QString(profile.readLine());
|
||||
if (fileStr[0] != '#')
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2)
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("Description"))
|
||||
descriptions.append(fileStr.split(QString("="), QString::SkipEmptyParts)[1].trimmed());
|
||||
if (profile.atEnd())
|
||||
break;
|
||||
}
|
||||
else
|
||||
descriptions.append(QString("<unknown>"));
|
||||
}
|
||||
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
descriptions[i].remove(QChar('\''));
|
||||
descriptions[i].remove(QChar('"'));
|
||||
}
|
||||
|
||||
return descriptions;
|
||||
}
|
||||
|
||||
|
||||
QStringList Netctl::getProfileStatuses(const QStringList profileList)
|
||||
{
|
||||
QStringList statuses;
|
||||
|
||||
for (int i=0; i<profileList.count(); i++) {
|
||||
QString status;
|
||||
if (isProfileActive(profileList[i]))
|
||||
status = QString("active");
|
||||
else
|
||||
status = QString("inactive");
|
||||
if (isProfileEnabled(profileList[i]))
|
||||
status = status + QString(" (enabled)");
|
||||
else
|
||||
status = status + QString(" (static)");
|
||||
statuses.append(status);
|
||||
}
|
||||
|
||||
return statuses;
|
||||
}
|
||||
|
||||
|
||||
QString Netctl::getSsidFromProfile(const QString profile)
|
||||
{
|
||||
QString ssidName = QString("");
|
||||
QString profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
|
||||
qDebug() << "[Netctl]" << "[getSsidFromProfile]" << ":" << "Check" << profileUrl;
|
||||
QFile profileFile(profileUrl);
|
||||
QString fileStr;
|
||||
if (!profileFile.open(QIODevice::ReadOnly))
|
||||
return ssidName;
|
||||
|
||||
while (true) {
|
||||
fileStr = QString(profileFile.readLine());
|
||||
if (fileStr[0] != '#') {
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2)
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts)[0] == QString("ESSID"))
|
||||
ssidName = fileStr.split(QString("="), QString::SkipEmptyParts)[1].trimmed();
|
||||
}
|
||||
if (profileFile.atEnd())
|
||||
break;
|
||||
}
|
||||
|
||||
profileFile.close();
|
||||
|
||||
ssidName.remove(QChar('\''));
|
||||
ssidName.remove(QChar('"'));
|
||||
return ssidName;
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::isProfileActive(const QString profile)
|
||||
{
|
||||
bool status = false;
|
||||
QString cmdOutput = getNetctlOutput(false, QString("status"), profile);
|
||||
if (!cmdOutput.isEmpty())
|
||||
if (cmdOutput.contains(QString("Active: active")))
|
||||
status = true;
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::isProfileEnabled(const QString profile)
|
||||
{
|
||||
bool status = false;
|
||||
QString cmdOutput = getNetctlOutput(false, QString("status"), profile);
|
||||
if (!cmdOutput.isEmpty()) {
|
||||
QStringList profileStatus = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||
for (int i=0; i<profileStatus.count(); i++)
|
||||
if (profileStatus[i].split(QString(" "), QString::SkipEmptyParts)[0] == QString("Loaded:"))
|
||||
if (profileStatus[i].contains(QString("enabled")))
|
||||
status = true;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
// functions
|
||||
bool Netctl::enableProfile(const QString profile)
|
||||
{
|
||||
if (isProfileEnabled(profile))
|
||||
return netctlCall(true, QString("disable"), profile);
|
||||
else
|
||||
return netctlCall(true, QString("enable"), profile);
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::restartProfile(const QString profile)
|
||||
{
|
||||
return netctlCall(true, QString("restart"), profile);
|
||||
}
|
||||
|
||||
|
||||
bool Netctl::startProfile(const QString profile)
|
||||
{
|
||||
if (isProfileActive(profile))
|
||||
return netctlCall(true, QString("stop"), profile);
|
||||
else
|
||||
return netctlCall(true, QString("start"), profile);
|
||||
}
|
61
sources/gui/src/netctlinteract.h
Normal file
61
sources/gui/src/netctlinteract.h
Normal file
@ -0,0 +1,61 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef NETCTLINTERACT_H
|
||||
#define NETCTLINTERACT_H
|
||||
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class Netctl : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Netctl(MainWindow *wid = 0,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
~Netctl();
|
||||
// general information
|
||||
QList<QStringList> getProfileList();
|
||||
QStringList getProfileDescriptions(const QStringList profileList);
|
||||
QStringList getProfileStatuses(const QStringList profileList);
|
||||
QString getSsidFromProfile(const QString profile);
|
||||
bool isProfileActive(const QString profile);
|
||||
bool isProfileEnabled(const QString profile);
|
||||
|
||||
public slots:
|
||||
// functions
|
||||
bool enableProfile(const QString profile);
|
||||
bool restartProfile(const QString profile);
|
||||
bool startProfile(const QString profile);
|
||||
|
||||
private:
|
||||
MainWindow *parent;
|
||||
QString netctlCommand;
|
||||
QDir *profileDirectory;
|
||||
QString sudoCommand;
|
||||
// functions
|
||||
QString getNetctlOutput(const bool sudo, const QString commandLine, const QString profile);
|
||||
bool netctlCall(const bool sudo, const QString commandLine, const QString profile);
|
||||
};
|
||||
|
||||
|
||||
#endif /* NETCTLINTERACT_H */
|
156
sources/gui/src/netctlprofile.cpp
Normal file
156
sources/gui/src/netctlprofile.cpp
Normal file
@ -0,0 +1,156 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "netctlprofile.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QProcess>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
NetctlProfile::NetctlProfile(MainWindow *wid, const QMap<QString, QString> settings)
|
||||
: parent(wid)
|
||||
{
|
||||
profileDirectory = new QDir(settings[QString("PROFILE_DIR")]);
|
||||
sudoCommand = settings[QString("SUDO_PATH")];
|
||||
}
|
||||
|
||||
|
||||
NetctlProfile::~NetctlProfile()
|
||||
{
|
||||
delete profileDirectory;
|
||||
}
|
||||
|
||||
|
||||
bool NetctlProfile::copyProfile(const QString oldPath)
|
||||
{
|
||||
QString newPath = profileDirectory->absolutePath() + QDir::separator() + QFileInfo(oldPath).fileName();
|
||||
QProcess command;
|
||||
QString commandText = sudoCommand + QString(" /usr/bin/mv ") + oldPath + QString(" ") + newPath;
|
||||
qDebug() << "[NetctlProfile]" << "[copyProfile]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
if (command.exitCode() == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QString NetctlProfile::createProfile(const QString profile, const QMap<QString, QString> settings)
|
||||
{
|
||||
|
||||
QString profileTempName = QDir::homePath() + QDir::separator() +
|
||||
QString(".cache") + QDir::separator() + QFileInfo(profile).fileName();
|
||||
QFile profileFile(profileTempName);
|
||||
qDebug() << "[NetctlProfile]" << "[createProfile]" << ":" << "Save to" << profileTempName;
|
||||
|
||||
if (!profileFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return profileTempName;
|
||||
|
||||
QTextStream out(&profileFile);
|
||||
for (int i=0; i<settings.keys().count(); i++) {
|
||||
out << settings.keys()[i] << QString("=");
|
||||
if ((settings.keys()[i] == QString("BindsToInterfaces")) ||
|
||||
(settings.keys()[i] == QString("After")) ||
|
||||
(settings.keys()[i] == QString("Address")) ||
|
||||
(settings.keys()[i] == QString("Routes")) ||
|
||||
(settings.keys()[i] == QString("Address6")) ||
|
||||
(settings.keys()[i] == QString("Routes6")) ||
|
||||
(settings.keys()[i] == QString("IPCustom")) ||
|
||||
(settings.keys()[i] == QString("DNS")) ||
|
||||
(settings.keys()[i] == QString("DNSOptions")) ||
|
||||
(settings.keys()[i] == QString("WPAConfigSection")) ||
|
||||
(settings.keys()[i] == QString("WPAConfigSection")))
|
||||
out << QString("(") + settings[settings.keys()[i]] << QString(")\n");
|
||||
else
|
||||
out << settings[settings.keys()[i]] << QString("\n");
|
||||
}
|
||||
profileFile.close();
|
||||
|
||||
return profileTempName;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> NetctlProfile::getSettingsFromProfile(const QString profile)
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
QString fileStr, profileUrl;
|
||||
if (profile[0] == QDir::separator())
|
||||
profileUrl = profile;
|
||||
else
|
||||
profileUrl = profileDirectory->absolutePath() + QDir::separator() + profile;
|
||||
QFile profileFile(profileUrl);
|
||||
qDebug() << "[NetctlProfile]" << "[getSettingsFromProfile]" << ":" << "Read from" << profileUrl;
|
||||
|
||||
if (!profileFile.open(QIODevice::ReadOnly))
|
||||
return settings;
|
||||
while (true) {
|
||||
fileStr = QString(profileFile.readLine());
|
||||
if (fileStr[0] != '#') {
|
||||
if (fileStr.split(QString("="), QString::SkipEmptyParts).count() == 2) {
|
||||
if ((fileStr.split(QString("="))[1][0] == QChar('(')) &&
|
||||
(fileStr.split(QString("="))[1][fileStr.split(QString("="))[1].size()-2] == QChar(')')))
|
||||
settings[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
|
||||
.remove(QString("("))
|
||||
.remove(QString(")"))
|
||||
.trimmed();
|
||||
else if (fileStr.split(QString("="))[1][0] == QChar('(')) {
|
||||
QString parameterName = fileStr.split(QString("="))[0];
|
||||
QStringList parameter;
|
||||
if (!fileStr.split(QString("="))[1]
|
||||
.remove(QString("("))
|
||||
.remove(QString(")"))
|
||||
.trimmed()
|
||||
.isEmpty())
|
||||
parameter.append(fileStr.split(QString("="))[1]
|
||||
.remove(QString("("))
|
||||
.remove(QString(")"))
|
||||
.trimmed());
|
||||
while(true) {
|
||||
fileStr = QString(profileFile.readLine());
|
||||
if (fileStr[fileStr.size()-2] == QChar(')'))
|
||||
break;
|
||||
if (!fileStr.remove(QString("("))
|
||||
.remove(QString(")"))
|
||||
.trimmed()
|
||||
.isEmpty())
|
||||
parameter.append(fileStr.remove(QString("("))
|
||||
.remove(QString(")"))
|
||||
.trimmed());
|
||||
if (profileFile.atEnd())
|
||||
break;
|
||||
}
|
||||
settings[parameterName] = parameter.join(QString("\n"));
|
||||
}
|
||||
else
|
||||
settings[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
|
||||
.trimmed();
|
||||
}
|
||||
|
||||
}
|
||||
if (profileFile.atEnd())
|
||||
break;
|
||||
}
|
||||
|
||||
profileFile.close();
|
||||
return settings;
|
||||
}
|
47
sources/gui/src/netctlprofile.h
Normal file
47
sources/gui/src/netctlprofile.h
Normal file
@ -0,0 +1,47 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef NETCTLPROFILE_H
|
||||
#define NETCTLPROFILE_H
|
||||
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class NetctlProfile : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NetctlProfile(MainWindow *wid = 0,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
~NetctlProfile();
|
||||
bool copyProfile(const QString oldPath);
|
||||
QString createProfile(const QString profile, const QMap<QString, QString> settings);
|
||||
QMap<QString, QString> getSettingsFromProfile(const QString profile);
|
||||
|
||||
private:
|
||||
MainWindow *parent;
|
||||
QDir *profileDirectory;
|
||||
QString sudoCommand;
|
||||
};
|
||||
|
||||
|
||||
#endif /* NETCTLPROFILE_H */
|
74
sources/gui/src/passwdwidget.cpp
Normal file
74
sources/gui/src/passwdwidget.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "passwdwidget.h"
|
||||
#include "ui_passwdwidget.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
PasswdWidget::PasswdWidget(MainWindow *wid)
|
||||
: QWidget(wid),
|
||||
parent(wid),
|
||||
ui(new Ui::PasswdWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createActions();
|
||||
}
|
||||
|
||||
|
||||
PasswdWidget::~PasswdWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
// ESC press event
|
||||
void PasswdWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (pressedKey->key() == Qt::Key_Escape)
|
||||
cancel();
|
||||
}
|
||||
|
||||
|
||||
void PasswdWidget::createActions()
|
||||
{
|
||||
connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(passwdApply()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(cancel()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(passwdApply()));
|
||||
}
|
||||
|
||||
|
||||
void PasswdWidget::setFocusToLineEdit()
|
||||
{
|
||||
ui->lineEdit->setFocus(Qt::ActiveWindowFocusReason);
|
||||
}
|
||||
|
||||
|
||||
void PasswdWidget::cancel()
|
||||
{
|
||||
hide();
|
||||
parent->updateTabs(2);
|
||||
this->~PasswdWidget();
|
||||
}
|
||||
|
||||
|
||||
void PasswdWidget::passwdApply()
|
||||
{
|
||||
hide();
|
||||
return parent->connectToUnknownEssid(ui->lineEdit->text());
|
||||
}
|
56
sources/gui/src/passwdwidget.h
Normal file
56
sources/gui/src/passwdwidget.h
Normal file
@ -0,0 +1,56 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef PASSWDWIDGET_H
|
||||
#define PASSWDWIDGET_H
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class PasswdWidget;
|
||||
}
|
||||
|
||||
class PasswdWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PasswdWidget(MainWindow *wid = 0);
|
||||
~PasswdWidget();
|
||||
|
||||
public slots:
|
||||
void setFocusToLineEdit();
|
||||
|
||||
private slots:
|
||||
void cancel();
|
||||
void passwdApply();
|
||||
|
||||
private:
|
||||
MainWindow *parent;
|
||||
Ui::PasswdWidget *ui;
|
||||
// ESC pressed event
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
void createActions();
|
||||
};
|
||||
|
||||
|
||||
#endif /* PASSWDWIDGET_H */
|
108
sources/gui/src/passwdwidget.ui
Normal file
108
sources/gui/src/passwdwidget.ui
Normal file
@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PasswdWidget</class>
|
||||
<widget class="QWidget" name="PasswdWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>264</width>
|
||||
<height>86</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<spacer name="spacer2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_passwd">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_button">
|
||||
<item>
|
||||
<spacer name="spacer_button1">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_button2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
240
sources/gui/src/pppoewidget.cpp
Normal file
240
sources/gui/src/pppoewidget.cpp
Normal file
@ -0,0 +1,240 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "pppoewidget.h"
|
||||
#include "ui_pppoewidget.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QFile>
|
||||
|
||||
|
||||
PppoeWidget::PppoeWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::PppoeWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createActions();
|
||||
createFilter();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
PppoeWidget::~PppoeWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void PppoeWidget::clear()
|
||||
{
|
||||
ui->lineEdit_username->clear();
|
||||
ui->lineEdit_password->clear();
|
||||
ui->comboBox_connection->setCurrentIndex(0);
|
||||
changeMode(ui->comboBox_connection->currentText());
|
||||
ui->spinBox_timeout->setValue(300);
|
||||
ui->spinBox_fail->setValue(5);
|
||||
ui->checkBox_route->setCheckState(Qt::Checked);
|
||||
ui->checkBox_dns->setCheckState(Qt::Checked);
|
||||
ui->lineEdit_unit->clear();
|
||||
ui->spinBox_lcpInterval->setValue(30);
|
||||
ui->spinBox_lcpFailure->setValue(4);
|
||||
ui->lineEdit_options->clear();
|
||||
ui->lineEdit_service->clear();
|
||||
ui->lineEdit_ac->clear();
|
||||
ui->lineEdit_session->clear();
|
||||
ui->lineEdit_mac->clear();
|
||||
ui->checkBox_ipv6->setCheckState(Qt::Unchecked);
|
||||
|
||||
ui->pushButton_pppoeAdvanced->setChecked(false);;
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
|
||||
void PppoeWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void PppoeWidget::createFilter()
|
||||
{
|
||||
// session mac
|
||||
ui->lineEdit_session->setInputMask(QString(">99999:HH:HH:HH:HH:HH:HH"));
|
||||
// mac
|
||||
ui->lineEdit_mac->setInputMask(QString(">HH:HH:HH:HH:HH:HH"));
|
||||
}
|
||||
|
||||
|
||||
void PppoeWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_pppoeAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
connect(ui->comboBox_connection, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeMode(QString)));
|
||||
connect(ui->pushButton_options, SIGNAL(clicked(bool)), this, SLOT(selectOptionsFile()));
|
||||
}
|
||||
|
||||
|
||||
void PppoeWidget::changeMode(const QString currentText)
|
||||
{
|
||||
if (currentText == QString("persist"))
|
||||
ui->widget_timeout->setHidden(true);
|
||||
else if (currentText == QString("demand"))
|
||||
ui->widget_timeout->setShown(true);
|
||||
}
|
||||
|
||||
|
||||
void PppoeWidget::selectOptionsFile()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("PppoeWidget", "Select options file"),
|
||||
QDir::currentPath(),
|
||||
QApplication::translate("PppoeWidget", "Configuration files (*.conf)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_options->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void PppoeWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_pppoeAdvanced->isChecked()) {
|
||||
ui->widget_pppoeAdvanced->setShown(true);
|
||||
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
ui->widget_pppoeAdvanced->setHidden(true);
|
||||
ui->pushButton_pppoeAdvanced->setText(QApplication::translate("PppoeWidget", "Show advanced"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> PppoeWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> pppoeSettings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return pppoeSettings;
|
||||
|
||||
if (!ui->lineEdit_username->text().isEmpty())
|
||||
pppoeSettings[QString("User")] = QString("'") + ui->lineEdit_username->text() + QString("'");
|
||||
if (!ui->lineEdit_password->text().isEmpty())
|
||||
pppoeSettings[QString("Password")] = QString("'") + ui->lineEdit_password->text() + QString("'");
|
||||
pppoeSettings[QString("ConnectionMode")] = QString("'") + ui->comboBox_connection->currentText() + QString("'");
|
||||
if (ui->comboBox_connection->currentText() == QString("demand"))
|
||||
pppoeSettings[QString("IdleTimeout")] = QString::number(ui->spinBox_timeout->value());
|
||||
if (ui->spinBox_fail->value() != 5)
|
||||
pppoeSettings[QString("MaxFail")] = QString::number(ui->spinBox_fail->value());
|
||||
if (ui->checkBox_route->checkState() == Qt::Unchecked)
|
||||
pppoeSettings[QString("DefaultRoute")] = QString("false");
|
||||
if (ui->checkBox_dns->checkState() == Qt::Unchecked)
|
||||
pppoeSettings[QString("UsePeerDNS")] = QString("false");
|
||||
if (!ui->lineEdit_unit->text().isEmpty())
|
||||
pppoeSettings[QString("PPPUnit")] = ui->lineEdit_unit->text();
|
||||
if (ui->spinBox_lcpInterval->value() != 30)
|
||||
pppoeSettings[QString("LCPEchoInterval")] = QString::number(ui->spinBox_lcpInterval->value());
|
||||
if (ui->spinBox_lcpFailure->value() != 4)
|
||||
pppoeSettings[QString("LCPEchoFailure")] = QString::number(ui->spinBox_lcpFailure->value());
|
||||
if (!ui->lineEdit_options->text().isEmpty())
|
||||
pppoeSettings[QString("OptionsFile")] = QString("'") + ui->lineEdit_options->text() + QString("'");
|
||||
if (!ui->lineEdit_service->text().isEmpty())
|
||||
pppoeSettings[QString("PPPoEService")] = QString("'") + ui->lineEdit_service->text() + QString("'");
|
||||
if (!ui->lineEdit_ac->text().isEmpty())
|
||||
pppoeSettings[QString("PPPoEAC")] = QString("'") + ui->lineEdit_ac->text() + QString("'");
|
||||
if (!ui->lineEdit_session->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty())
|
||||
pppoeSettings[QString("PPPoESession")] = QString("'") + ui->lineEdit_session->text().remove(QString(" ")) + QString("'");
|
||||
if (!ui->lineEdit_mac->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty())
|
||||
pppoeSettings[QString("PPPoEMAC")] = QString("'") + ui->lineEdit_mac->text() + QString("'");
|
||||
if (ui->checkBox_ipv6->checkState() == Qt::Checked)
|
||||
pppoeSettings[QString("PPPoEIP6")] = QString("yes");
|
||||
|
||||
return pppoeSettings;
|
||||
}
|
||||
|
||||
|
||||
int PppoeWidget::isOk()
|
||||
{
|
||||
// config file doesn't exist
|
||||
if (!ui->lineEdit_options->text().isEmpty())
|
||||
if (!QFile(ui->lineEdit_options->text()).exists())
|
||||
return 1;
|
||||
// mac address
|
||||
if (!ui->lineEdit_mac->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty())
|
||||
if (ui->lineEdit_mac->text().contains(QString(" ")))
|
||||
return 2;
|
||||
// session id is not set
|
||||
if (!ui->lineEdit_session->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty())
|
||||
if (ui->lineEdit_session->text().split(QString(":"))[0].remove(QString(" ")).isEmpty())
|
||||
return 3;
|
||||
// session mac address
|
||||
if (!ui->lineEdit_session->text().split(QString(":")).join(QString("")).remove(QString(" ")).isEmpty()) {
|
||||
QStringList item = ui->lineEdit_session->text().split(QString(":"));
|
||||
for (int i=1; i<7; i++)
|
||||
if (item[i].contains(QString(" ")))
|
||||
return 4;
|
||||
}
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void PppoeWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
QMap<QString, QString> pppoeSettings = settings;
|
||||
|
||||
if (pppoeSettings.contains(QString("User")))
|
||||
ui->lineEdit_username->setText(pppoeSettings[QString("User")].remove(QString("'")));
|
||||
if (pppoeSettings.contains(QString("Password")))
|
||||
ui->lineEdit_password->setText(pppoeSettings[QString("Password")].remove(QString("'")));
|
||||
if (pppoeSettings.contains(QString("ConnectionMode")))
|
||||
for (int i=0; i<ui->comboBox_connection->count(); i++)
|
||||
if (pppoeSettings[QString("ConnectionMode")].remove(QString("'")) == ui->comboBox_connection->itemText(i))
|
||||
ui->comboBox_connection->setCurrentIndex(i);
|
||||
if (pppoeSettings.contains(QString("IdleTimeout")))
|
||||
ui->spinBox_timeout->setValue(pppoeSettings[QString("IdleTimeout")].toInt());
|
||||
if (pppoeSettings.contains(QString("MaxFail")))
|
||||
ui->spinBox_fail->setValue(pppoeSettings[QString("MaxFail")].toInt());
|
||||
if (pppoeSettings.contains(QString("DefaultRoute")))
|
||||
if (pppoeSettings[QString("DefaultRoute")].remove(QString("'")) == QString("false"))
|
||||
ui->checkBox_route->setCheckState(Qt::Unchecked);
|
||||
if (pppoeSettings.contains(QString("UsePeerDNS")))
|
||||
if (pppoeSettings[QString("UsePeerDNS")].remove(QString("'")) == QString("false"))
|
||||
ui->checkBox_dns->setCheckState(Qt::Unchecked);
|
||||
if (pppoeSettings.contains(QString("PPPUnit")))
|
||||
ui->lineEdit_unit->setText(pppoeSettings[QString("PPPUnit")]);
|
||||
if (pppoeSettings.contains(QString("LCPEchoInterval")))
|
||||
ui->spinBox_lcpInterval->setValue(pppoeSettings[QString("LCPEchoInterval")].toInt());
|
||||
if (pppoeSettings.contains(QString("LCPEchoFailure")))
|
||||
ui->spinBox_lcpFailure->setValue(pppoeSettings[QString("LCPEchoFailure")].toInt());
|
||||
if (pppoeSettings.contains(QString("OptionsFile")))
|
||||
ui->lineEdit_options->setText(pppoeSettings[QString("OptionsFile")].remove(QString("'")));
|
||||
if (pppoeSettings.contains(QString("PPPoEService")))
|
||||
ui->lineEdit_service->setText(pppoeSettings[QString("PPPoEService")].remove(QString("'")));
|
||||
if (pppoeSettings.contains(QString("PPPoEAC")))
|
||||
ui->lineEdit_ac->setText(pppoeSettings[QString("PPPoEAC")].remove(QString("'")));
|
||||
if (pppoeSettings.contains(QString("PPPoESession")))
|
||||
ui->lineEdit_session->setText(pppoeSettings[QString("PPPoESession")].remove(QString("'")));
|
||||
if (pppoeSettings.contains(QString("PPPoEMAC")))
|
||||
ui->lineEdit_mac->setText(pppoeSettings[QString("PPPoEMAC")].remove(QString("'")));
|
||||
if (pppoeSettings.contains(QString("PPPoEIP6")))
|
||||
if (pppoeSettings[QString("PPPoEIP6")] == QString("yes"))
|
||||
ui->checkBox_dns->setCheckState(Qt::Checked);
|
||||
|
||||
changeMode(ui->comboBox_connection->currentText());
|
||||
}
|
55
sources/gui/src/pppoewidget.h
Normal file
55
sources/gui/src/pppoewidget.h
Normal file
@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef PPPOEWIDGET_H
|
||||
#define PPPOEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class PppoeWidget;
|
||||
}
|
||||
|
||||
class PppoeWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PppoeWidget(QWidget *parent = 0);
|
||||
~PppoeWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private slots:
|
||||
void changeMode(const QString currentText);
|
||||
void selectOptionsFile();
|
||||
void showAdvanced();
|
||||
|
||||
private:
|
||||
Ui::PppoeWidget *ui;
|
||||
void createActions();
|
||||
void createFilter();
|
||||
};
|
||||
|
||||
|
||||
#endif /* PPPOEWIDGET_H */
|
465
sources/gui/src/pppoewidget.ui
Normal file
465
sources/gui/src/pppoewidget.ui
Normal file
@ -0,0 +1,465 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PppoeWidget</class>
|
||||
<widget class="QWidget" name="PppoeWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>431</width>
|
||||
<height>602</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_pppoe">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>PPPoE settings</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_pppoe">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_username">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_username">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Username</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_username">
|
||||
<property name="toolTip">
|
||||
<string>The username and password to connect with</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_password">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_password">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_password">
|
||||
<property name="toolTip">
|
||||
<string>The username and password to connect with</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_connection">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_connection">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connection mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_connection">
|
||||
<property name="toolTip">
|
||||
<string>This option specifies how a connection should be established</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>persist</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>demand</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_timeout" native="true">
|
||||
<layout class="QHBoxLayout" name="layout_timeout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_timeout">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Idle timeout</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_timeout">
|
||||
<property name="toolTip">
|
||||
<string>This option specifies the idle time (in seconds) after which ‘pppd’ should disconnect</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>300</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_pppoeAdvanced">
|
||||
<item>
|
||||
<spacer name="spacer_pppoeAdvanced">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_pppoeAdvanced">
|
||||
<property name="text">
|
||||
<string>Show advanced</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_pppoeAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fail">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fail">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Max fail</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_fail">
|
||||
<property name="toolTip">
|
||||
<string>The number of consecutive failed connection attempts to tolerate</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_route">
|
||||
<property name="toolTip">
|
||||
<string>Use the default route provided by the peer</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default route</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_dns">
|
||||
<property name="toolTip">
|
||||
<string>Use the DNS provided by the peer</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use peer DNS</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_unit">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_unit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PPP unit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_unit">
|
||||
<property name="toolTip">
|
||||
<string>Set the ppp unit number in the interface name (ppp0, ppp1, etc.)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_lcpInterval">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_lcpInterval">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>LCP echo interval</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_lcpInterval">
|
||||
<property name="toolTip">
|
||||
<string>These options override default LCP parameters from ‘/etc/ppp/options’</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>499</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>30</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_lcpFailure">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_lcpFailure">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>LCP echo failure</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_lcpFailure">
|
||||
<property name="toolTip">
|
||||
<string>These options override default LCP parameters from ‘/etc/ppp/options’</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>4</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_options">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_options">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Options file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_options">
|
||||
<property name="toolTip">
|
||||
<string>A file to read additional pppd options from</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_options">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_service">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_service">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PPPoE service</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_service">
|
||||
<property name="toolTip">
|
||||
<string>This option specifies the PPPoE service name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_ac">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_ac">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PPPoE AC</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_ac">
|
||||
<property name="toolTip">
|
||||
<string>This option specifies the PPPoE access concentrator name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_session">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_session">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PPPoE session</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_session">
|
||||
<property name="toolTip">
|
||||
<string>This option specifies an existing session to attach to, MAC address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mac">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mac">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PPPoE MAC</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_mac">
|
||||
<property name="toolTip">
|
||||
<string>Only connect to specified MAC address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_ipv6">
|
||||
<property name="toolTip">
|
||||
<string>Enable IPv6 support</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PPPoE IPv6</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
294
sources/gui/src/settingswindow.cpp
Normal file
294
sources/gui/src/settingswindow.cpp
Normal file
@ -0,0 +1,294 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "settingswindow.h"
|
||||
#include "ui_settingswindow.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
SettingsWindow::SettingsWindow(MainWindow *wid, const QString configFile)
|
||||
: QMainWindow(wid),
|
||||
parent(wid),
|
||||
file(configFile),
|
||||
ui(new Ui::SettingsWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
addLanguages();
|
||||
createActions();
|
||||
}
|
||||
|
||||
|
||||
SettingsWindow::~SettingsWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::createActions()
|
||||
{
|
||||
connect(ui->comboBox_language, SIGNAL(currentIndexChanged(int)), ui->label_info, SLOT(show()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Reset), SIGNAL(clicked(bool)), this, SLOT(setDefault()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(saveSettings()));
|
||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||
// buttons
|
||||
connect(ui->pushButton_interfaceDir, SIGNAL(clicked(bool)), SLOT(selectIfaceDir()));
|
||||
connect(ui->pushButton_netctlPath, SIGNAL(clicked(bool)), SLOT(selectNetctlPath()));
|
||||
connect(ui->pushButton_profilePath, SIGNAL(clicked(bool)), SLOT(selectProfileDir()));
|
||||
connect(ui->pushButton_rfkill, SIGNAL(clicked(bool)), SLOT(selectRfkillDir()));
|
||||
connect(ui->pushButton_sudo, SIGNAL(clicked(bool)), SLOT(selectSudoPath()));
|
||||
connect(ui->pushButton_wpaCliPath, SIGNAL(clicked(bool)), SLOT(selectWpaCliPath()));
|
||||
connect(ui->pushButton_wpaSupPath, SIGNAL(clicked(bool)), SLOT(selectWpaSupPath()));
|
||||
}
|
||||
|
||||
|
||||
// ESC press event
|
||||
void SettingsWindow::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (pressedKey->key() == Qt::Key_Escape)
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::addLanguages()
|
||||
{
|
||||
ui->comboBox_language->addItem(QString("english"));
|
||||
ui->comboBox_language->addItem(QString("russian"));
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::saveSettings()
|
||||
{
|
||||
QMap<QString, QString> settings = readSettings();
|
||||
QFile configFile(file);
|
||||
|
||||
if (!configFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return;
|
||||
QTextStream out(&configFile);
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
out << settings.keys()[i] << QString("=") << settings[settings.keys()[i]] << QString("\n");
|
||||
configFile.close();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::setDefault()
|
||||
{
|
||||
setSettings(getDefault());
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectIfaceDir()
|
||||
{
|
||||
QString directory = QFileDialog::getExistingDirectory(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select path to directory with interfaces"),
|
||||
QString("/sys/"));
|
||||
if (!directory.isEmpty())
|
||||
ui->lineEdit_interfacesDir->setText(directory);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectNetctlPath()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select netctl command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_netctlPath->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectProfileDir()
|
||||
{
|
||||
QString directory = QFileDialog::getExistingDirectory(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select path to profile directory"),
|
||||
QString("/etc/"));
|
||||
if (!directory.isEmpty())
|
||||
ui->lineEdit_profilePath->setText(directory);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectRfkillDir()
|
||||
{
|
||||
QString directory = QFileDialog::getExistingDirectory(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select path to directory with rfkill devices"),
|
||||
QString("/sys/"));
|
||||
if (!directory.isEmpty())
|
||||
ui->lineEdit_rfkill->setText(directory);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectSudoPath()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select sudo command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_sudo->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectWpaCliPath()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select wpa_cli command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_wpaCliPath->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::selectWpaSupPath()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("SettingsWindow", "Select wpa_supplicant command"),
|
||||
QString("/usr/bin/"),
|
||||
QApplication::translate("SettingsWindow", "All files (*)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_wpaSupPath->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::showWindow()
|
||||
{
|
||||
setSettings(getSettings());
|
||||
ui->label_info->hide();
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> SettingsWindow::readSettings()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
settings[QString("CTRL_DIR")] = ui->lineEdit_wpaDir->text();
|
||||
settings[QString("CTRL_GROUP")] = ui->lineEdit_wpaGroup->text();
|
||||
settings[QString("IFACE_DIR")] = ui->lineEdit_interfacesDir->text();
|
||||
settings[QString("LANGUAGE")] = ui->comboBox_language->currentText();
|
||||
settings[QString("NETCTL_PATH")] = ui->lineEdit_netctlPath->text();
|
||||
settings[QString("PID_FILE")] = ui->lineEdit_pid->text();
|
||||
settings[QString("PREFERED_IFACE")] = ui->lineEdit_interface->text();
|
||||
settings[QString("PROFILE_DIR")] = ui->lineEdit_profilePath->text();
|
||||
settings[QString("RFKILL_DIR")] = ui->lineEdit_rfkill->text();
|
||||
settings[QString("SUDO_PATH")] = ui->lineEdit_sudo->text();
|
||||
settings[QString("WPACLI_PATH")] = ui->lineEdit_wpaCliPath->text();
|
||||
settings[QString("WPASUP_PATH")] = ui->lineEdit_wpaSupPath->text();
|
||||
settings[QString("WPA_DRIVERS")] = ui->lineEdit_wpaSupDrivers->text();
|
||||
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
qDebug() << "[SettingsWindow]" << "[readSettings]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
void SettingsWindow::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
ui->lineEdit_wpaDir->setText(settings[QString("CTRL_DIR")]);
|
||||
ui->lineEdit_wpaGroup->setText(settings[QString("CTRL_GROUP")]);
|
||||
ui->lineEdit_interfacesDir->setText(settings[QString("IFACE_DIR")]);
|
||||
ui->comboBox_language->setCurrentIndex(0);
|
||||
for (int i=0; i<ui->comboBox_language->count(); i++)
|
||||
if (ui->comboBox_language->itemText(i) == settings[QString("LANGUAGE")])
|
||||
ui->comboBox_language->setCurrentIndex(i);
|
||||
ui->lineEdit_netctlPath->setText(settings[QString("NETCTL_PATH")]);
|
||||
ui->lineEdit_pid->setText(settings[QString("PID_FILE")]);
|
||||
ui->lineEdit_interface->setText(settings[QString("PREFERED_IFACE")]);
|
||||
ui->lineEdit_profilePath->setText(settings[QString("PROFILE_DIR")]);
|
||||
ui->lineEdit_rfkill->setText(settings[QString("RFKILL_DIR")]);
|
||||
ui->lineEdit_sudo->setText(settings[QString("SUDO_PATH")]);
|
||||
ui->lineEdit_wpaCliPath->setText(settings[QString("WPACLI_PATH")]);
|
||||
ui->lineEdit_wpaSupPath->setText(settings[QString("WPASUP_PATH")]);
|
||||
ui->lineEdit_wpaSupDrivers->setText(settings[QString("WPA_DRIVERS")]);
|
||||
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
qDebug() << "[SettingsWindow]" << "[setSettings]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> SettingsWindow::getDefault()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
|
||||
settings[QString("CTRL_DIR")] = QString("/run/wpa_supplicant_netctl-gui");
|
||||
settings[QString("CTRL_GROUP")] = QString("users");
|
||||
settings[QString("IFACE_DIR")] = QString("/sys/class/net/");
|
||||
settings[QString("LANGUAGE")] = QString("english");
|
||||
settings[QString("NETCTL_PATH")] = QString("/usr/bin/netctl");
|
||||
settings[QString("PID_FILE")] = QString("/run/wpa_supplicant_netctl-gui.pid");
|
||||
settings[QString("PREFERED_IFACE")] = QString("");
|
||||
settings[QString("PROFILE_DIR")] = QString("/etc/netctl/");
|
||||
settings[QString("RFKILL_DIR")] = QString("/sys/class/rfkill/");
|
||||
settings[QString("SUDO_PATH")] = QString("/usr/bin/kdesu");
|
||||
settings[QString("WPACLI_PATH")] = QString("/usr/bin/wpa_cli");
|
||||
settings[QString("WPASUP_PATH")] = QString("/usr/bin/wpa_supplicant");
|
||||
settings[QString("WPA_DRIVERS")] = QString("nl80211,wext");
|
||||
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
qDebug() << "[SettingsWindow]" << "[getDefault]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> SettingsWindow::getSettings()
|
||||
{
|
||||
QMap<QString, QString> settings;
|
||||
QFile configFile(file);
|
||||
QString fileStr;
|
||||
|
||||
if (!configFile.open(QIODevice::ReadOnly))
|
||||
return getDefault();
|
||||
while (true) {
|
||||
fileStr = QString(configFile.readLine());
|
||||
if (fileStr[0] != '#') {
|
||||
if (fileStr.contains(QString("=")))
|
||||
settings[fileStr.split(QString("="))[0]] = fileStr.split(QString("="))[1]
|
||||
.remove(QString(" "))
|
||||
.trimmed();
|
||||
}
|
||||
if (configFile.atEnd())
|
||||
break;
|
||||
}
|
||||
|
||||
configFile.close();
|
||||
|
||||
for (int i=0; i<settings.keys().count(); i++)
|
||||
qDebug() << "[SettingsWindow]" << "[getSettings]" << ":" <<
|
||||
settings.keys()[i] + QString("=") + settings[settings.keys()[i]];
|
||||
|
||||
return settings;
|
||||
}
|
70
sources/gui/src/settingswindow.h
Normal file
70
sources/gui/src/settingswindow.h
Normal file
@ -0,0 +1,70 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SETTINGSWINDOW_H
|
||||
#define SETTINGSWINDOW_H
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QMainWindow>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
|
||||
namespace Ui {
|
||||
class SettingsWindow;
|
||||
}
|
||||
|
||||
class SettingsWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsWindow(MainWindow *wid = 0,
|
||||
const QString configFile = QString(""));
|
||||
~SettingsWindow();
|
||||
QMap<QString, QString> getDefault();
|
||||
QMap<QString, QString> getSettings();
|
||||
|
||||
public slots:
|
||||
void setDefault();
|
||||
void showWindow();
|
||||
|
||||
private slots:
|
||||
void addLanguages();
|
||||
void saveSettings();
|
||||
// buttons
|
||||
void selectIfaceDir();
|
||||
void selectNetctlPath();
|
||||
void selectProfileDir();
|
||||
void selectRfkillDir();
|
||||
void selectSudoPath();
|
||||
void selectWpaCliPath();
|
||||
void selectWpaSupPath();
|
||||
|
||||
private:
|
||||
MainWindow *parent;
|
||||
QString file;
|
||||
Ui::SettingsWindow *ui;
|
||||
void createActions();
|
||||
// ESC pressed event
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
QMap<QString, QString> readSettings();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
};
|
||||
|
||||
|
||||
#endif /* SETTINGSWINDOW_H */
|
502
sources/gui/src/settingswindow.ui
Normal file
502
sources/gui/src/settingswindow.ui
Normal file
@ -0,0 +1,502 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SettingsWindow</class>
|
||||
<widget class="QMainWindow" name="SettingsWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>461</width>
|
||||
<height>287</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_general">
|
||||
<attribute name="title">
|
||||
<string>General</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_language">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_language">
|
||||
<property name="text">
|
||||
<string>Language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_language">
|
||||
<property name="toolTip">
|
||||
<string>Select a language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_info">
|
||||
<property name="text">
|
||||
<string>You will need to restart the application</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_general">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_netctl">
|
||||
<attribute name="title">
|
||||
<string>netctl</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_netctlPath">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_netctlPath">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>netctl path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_netctlPath">
|
||||
<property name="toolTip">
|
||||
<string>Path to netctl</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_netctlPath">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_profilePath">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_profilePath">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Profile path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_profilePath">
|
||||
<property name="toolTip">
|
||||
<string>Path to profile directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_profilePath">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_netctl">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_sudo">
|
||||
<attribute name="title">
|
||||
<string>sudo</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_sudo">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_sudo">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>sudo path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_sudo">
|
||||
<property name="toolTip">
|
||||
<string>Path to sudo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_sudo">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_sudo">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>192</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_wpaSup">
|
||||
<attribute name="title">
|
||||
<string>wpa_supplicant</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wpaSupPath">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wpaSupPath">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>wpa_supplicant path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaSupPath">
|
||||
<property name="toolTip">
|
||||
<string>Path to wpa_supplicant</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wpaSupPath">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wpaCliPath">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wpaCliPath">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>wpa_cli path</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaCliPath">
|
||||
<property name="toolTip">
|
||||
<string>Path to wpa_cli</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wpaCliPath">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_pid">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_pid">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PID file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_pid">
|
||||
<property name="toolTip">
|
||||
<string>wpa_supplicant PID file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wpaSupDrivers">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wpaSupDrivers">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>wpa_supplicant drivers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaSupDrivers">
|
||||
<property name="toolTip">
|
||||
<string>wpa_supplicant drivers comma separated</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wpaDir">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wpaDir">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ctrl_interface directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaDir">
|
||||
<property name="toolTip">
|
||||
<string>Path to control directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wpaGroup">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wpaGroup">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ctrl_interface group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaGroup">
|
||||
<property name="toolTip">
|
||||
<string>Group of control directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_wpaSup">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_other">
|
||||
<attribute name="title">
|
||||
<string>Other</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_interfacesDir">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_interfacesDir">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Path to interface list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_interfacesDir">
|
||||
<property name="toolTip">
|
||||
<string>Path to directory which contains network devices</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_interfaceDir">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_rfkill">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_rfkill">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Path to rfkill device list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_rfkill">
|
||||
<property name="toolTip">
|
||||
<string>Path to directory which contains rfkill devices</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_rfkill">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_interface">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_interface">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Prefered wireless interface</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_interface">
|
||||
<property name="toolTip">
|
||||
<string>Prefered wireless interface</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_other">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>130</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
46
sources/gui/src/sleepthread.h
Normal file
46
sources/gui/src/sleepthread.h
Normal file
@ -0,0 +1,46 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SLEEPTHREAD_H
|
||||
#define SLEEPTHREAD_H
|
||||
|
||||
#include <QThread>
|
||||
|
||||
|
||||
class SleepThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static void usleep(long iSleepTime)
|
||||
{
|
||||
QThread::usleep(iSleepTime);
|
||||
}
|
||||
|
||||
static void sleep(long iSleepTime)
|
||||
{
|
||||
QThread::sleep(iSleepTime);
|
||||
}
|
||||
|
||||
static void msleep(long iSleepTime)
|
||||
{
|
||||
QThread::msleep(iSleepTime);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* SLEEPTHREAD_H */
|
122
sources/gui/src/tunnelwidget.cpp
Normal file
122
sources/gui/src/tunnelwidget.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "tunnelwidget.h"
|
||||
#include "ui_tunnelwidget.h"
|
||||
|
||||
|
||||
TunnelWidget::TunnelWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::TunnelWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createFilter();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
TunnelWidget::~TunnelWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void TunnelWidget::clear()
|
||||
{
|
||||
ui->comboBox_mode->setCurrentIndex(0);
|
||||
ui->lineEdit_local->clear();
|
||||
ui->lineEdit_remote->clear();
|
||||
}
|
||||
|
||||
|
||||
void TunnelWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void TunnelWidget::createFilter()
|
||||
{
|
||||
// using input mask because validators is not comfortable
|
||||
// ipv4
|
||||
ui->lineEdit_local->setInputMask(QString("999.999.999.999"));
|
||||
ui->lineEdit_remote->setInputMask(QString("999.999.999.999"));
|
||||
}
|
||||
|
||||
|
||||
QString TunnelWidget::getIp(const QString rawIp)
|
||||
{
|
||||
QStringList ip = rawIp.split(QString("."));
|
||||
|
||||
// fix empty fields
|
||||
if (ip[0].isEmpty())
|
||||
ip[0] = QString("127");
|
||||
if (ip[1].isEmpty())
|
||||
ip[1] = QString("0");
|
||||
if (ip[2].isEmpty())
|
||||
ip[2] = QString("0");
|
||||
if (ip[3].isEmpty())
|
||||
ip[3] = QString("1");
|
||||
// fix numbers
|
||||
for (int i=0; i<4; i++)
|
||||
if (ip[i].toInt() > 255)
|
||||
ip[i] = QString("255");
|
||||
|
||||
return ip.join(QString("."));
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> TunnelWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> tunnelSettings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return tunnelSettings;
|
||||
|
||||
tunnelSettings[QString("Mode")] = QString("'") + ui->comboBox_mode->currentText() + QString("'");
|
||||
if (!ui->lineEdit_local->text().split(QString(".")).join(QString("")).remove(QString(" ")).isEmpty())
|
||||
tunnelSettings[QString("Local")] = QString("'") + getIp(ui->lineEdit_local->text().remove(QString(" "))) + QString("'");
|
||||
if (!ui->lineEdit_remote->text().split(QString(".")).join(QString("")).remove(QString(" ")).isEmpty())
|
||||
tunnelSettings[QString("Remote")] = QString("'") + getIp(ui->lineEdit_remote->text().remove(QString(" "))) + QString("'");
|
||||
|
||||
return tunnelSettings;
|
||||
}
|
||||
|
||||
|
||||
int TunnelWidget::isOk()
|
||||
{
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void TunnelWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
QMap<QString, QString> tunnelSettings = settings;
|
||||
|
||||
if (tunnelSettings.contains(QString("Mode")))
|
||||
for (int i=0; i<ui->comboBox_mode->count(); i++)
|
||||
if (tunnelSettings[QString("Mode")].remove(QString("'")) == ui->comboBox_mode->itemText(i))
|
||||
ui->comboBox_mode->setCurrentIndex(i);
|
||||
if (tunnelSettings.contains(QString("Local")))
|
||||
ui->lineEdit_local->setText(tunnelSettings[QString("Local")].remove(QString("'")));
|
||||
if (tunnelSettings.contains(QString("Remote")))
|
||||
ui->lineEdit_remote->setText(tunnelSettings[QString("Remote")].remove(QString("'")));
|
||||
}
|
50
sources/gui/src/tunnelwidget.h
Normal file
50
sources/gui/src/tunnelwidget.h
Normal file
@ -0,0 +1,50 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TUNNELWIDGET_H
|
||||
#define TUNNELWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class TunnelWidget;
|
||||
}
|
||||
|
||||
class TunnelWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TunnelWidget(QWidget *parent = 0);
|
||||
~TunnelWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private:
|
||||
Ui::TunnelWidget *ui;
|
||||
void createFilter();
|
||||
QString getIp(const QString rawIp);
|
||||
};
|
||||
|
||||
|
||||
#endif /* TUNNELWIDGET_H */
|
152
sources/gui/src/tunnelwidget.ui
Normal file
152
sources/gui/src/tunnelwidget.ui
Normal file
@ -0,0 +1,152 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TunnelWidget</class>
|
||||
<widget class="QWidget" name="TunnelWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>411</width>
|
||||
<height>146</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_tunnel">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Tunnel settings</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_tunnel">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mode">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mode">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mode">
|
||||
<property name="toolTip">
|
||||
<string>The tunnel type</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>ipip</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>gre</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>sit</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>isatap</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>ip6ip6</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>ipip6</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>ip6gre</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>any</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_local">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_local">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Local</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_local">
|
||||
<property name="toolTip">
|
||||
<string>The address of the local end of the tunnel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_remote">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_remote">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remote</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_remote">
|
||||
<property name="toolTip">
|
||||
<string>The address of the remote end of the tunnel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>comboBox_mode</tabstop>
|
||||
<tabstop>lineEdit_local</tabstop>
|
||||
<tabstop>lineEdit_remote</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
94
sources/gui/src/tuntapwidget.cpp
Normal file
94
sources/gui/src/tuntapwidget.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "tuntapwidget.h"
|
||||
#include "ui_tuntapwidget.h"
|
||||
|
||||
|
||||
TuntapWidget::TuntapWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::TuntapWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
TuntapWidget::~TuntapWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void TuntapWidget::clear()
|
||||
{
|
||||
ui->comboBox_mode->setCurrentIndex(0);
|
||||
ui->lineEdit_user->setText(QString("nobody"));
|
||||
ui->lineEdit_group->setText(QString("nobody"));
|
||||
}
|
||||
|
||||
|
||||
void TuntapWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> TuntapWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> tuntapSettings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return tuntapSettings;
|
||||
|
||||
tuntapSettings[QString("Mode")] = QString("'") + ui->comboBox_mode->currentText() + QString("'");
|
||||
tuntapSettings[QString("User")] = QString("'") + ui->lineEdit_user->text() + QString("'");
|
||||
tuntapSettings[QString("Group")] = QString("'") + ui->lineEdit_group->text() + QString("'");
|
||||
|
||||
return tuntapSettings;
|
||||
}
|
||||
|
||||
|
||||
int TuntapWidget::isOk()
|
||||
{
|
||||
// empty username
|
||||
if (ui->lineEdit_user->text().isEmpty())
|
||||
return 1;
|
||||
// empty group name
|
||||
if (ui->lineEdit_group->text().isEmpty())
|
||||
return 2;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void TuntapWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
QMap<QString, QString> tuntapSettings = settings;
|
||||
|
||||
if (tuntapSettings.contains(QString("Mode")))
|
||||
for (int i=0; i<ui->comboBox_mode->count(); i++)
|
||||
if (tuntapSettings[QString("Mode")].remove(QString("'")) == ui->comboBox_mode->itemText(i))
|
||||
ui->comboBox_mode->setCurrentIndex(i);
|
||||
if (tuntapSettings.contains(QString("User")))
|
||||
ui->lineEdit_user->setText(tuntapSettings[QString("User")].remove(QString("'")));
|
||||
if (tuntapSettings.contains(QString("Group")))
|
||||
ui->lineEdit_group->setText(tuntapSettings[QString("Group")].remove(QString("'")));
|
||||
}
|
48
sources/gui/src/tuntapwidget.h
Normal file
48
sources/gui/src/tuntapwidget.h
Normal file
@ -0,0 +1,48 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef TUNTAPWIDGET_H
|
||||
#define TUNTAPWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class TuntapWidget;
|
||||
}
|
||||
|
||||
class TuntapWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TuntapWidget(QWidget *parent = 0);
|
||||
~TuntapWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private:
|
||||
Ui::TuntapWidget *ui;
|
||||
};
|
||||
|
||||
|
||||
#endif /* TUNTAPWIDGET_H */
|
117
sources/gui/src/tuntapwidget.ui
Normal file
117
sources/gui/src/tuntapwidget.ui
Normal file
@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TuntapWidget</class>
|
||||
<widget class="QWidget" name="TuntapWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>424</width>
|
||||
<height>146</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_tuntap">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Tuntap settings</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_tuntap">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_mode">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_mode">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_mode">
|
||||
<property name="toolTip">
|
||||
<string>Either ‘tun’, or ‘tap’</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>tun</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>tap</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_user">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_user">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>User</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_user">
|
||||
<property name="toolTip">
|
||||
<string>The owning user of the tun/tap interface</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_group">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_group">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_group">
|
||||
<property name="toolTip">
|
||||
<string>The owning group of the tun/tap interface</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
78
sources/gui/src/vlanwidget.cpp
Normal file
78
sources/gui/src/vlanwidget.cpp
Normal file
@ -0,0 +1,78 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "vlanwidget.h"
|
||||
#include "ui_vlanwidget.h"
|
||||
|
||||
|
||||
VlanWidget::VlanWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::VlanWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
VlanWidget::~VlanWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void VlanWidget::clear()
|
||||
{
|
||||
ui->spinBox_vlan->setValue(55);
|
||||
}
|
||||
|
||||
|
||||
void VlanWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> VlanWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> vlanSettings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return vlanSettings;
|
||||
|
||||
vlanSettings[QString("VLANID")] = QString::number(ui->spinBox_vlan->value());
|
||||
|
||||
return vlanSettings;
|
||||
}
|
||||
|
||||
|
||||
int VlanWidget::isOk()
|
||||
{
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void VlanWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
QMap<QString, QString> vlanSettings = settings;
|
||||
|
||||
if (vlanSettings.contains(QString("VLANID")))
|
||||
ui->spinBox_vlan->setValue(vlanSettings[QString("VLANID")].toInt());
|
||||
}
|
48
sources/gui/src/vlanwidget.h
Normal file
48
sources/gui/src/vlanwidget.h
Normal file
@ -0,0 +1,48 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef VLANWIDGET_H
|
||||
#define VLANWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class VlanWidget;
|
||||
}
|
||||
|
||||
class VlanWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit VlanWidget(QWidget *parent = 0);
|
||||
~VlanWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private:
|
||||
Ui::VlanWidget *ui;
|
||||
};
|
||||
|
||||
|
||||
#endif /* VLANWIDGET_H */
|
65
sources/gui/src/vlanwidget.ui
Normal file
65
sources/gui/src/vlanwidget.ui
Normal file
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>VlanWidget</class>
|
||||
<widget class="QWidget" name="VlanWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>393</width>
|
||||
<height>81</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_vlan">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>vlan settings</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_vlan">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_vlan">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_vlan">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>vlan ID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_vlan">
|
||||
<property name="toolTip">
|
||||
<string>vlan identifier</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>55</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
347
sources/gui/src/wirelesswidget.cpp
Normal file
347
sources/gui/src/wirelesswidget.cpp
Normal file
@ -0,0 +1,347 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "wirelesswidget.h"
|
||||
#include "ui_wirelesswidget.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFile>
|
||||
#include <QKeyEvent>
|
||||
|
||||
|
||||
WirelessWidget::WirelessWidget(QWidget *parent, const QMap<QString, QString> settings)
|
||||
: QWidget(parent),
|
||||
ui(new Ui::WirelessWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
rfkillDirectory = new QDir(settings[QString("RFKILL_DIR")]);
|
||||
createActions();
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
WirelessWidget::~WirelessWidget()
|
||||
{
|
||||
delete rfkillDirectory;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::clear()
|
||||
{
|
||||
ui->comboBox_security->setCurrentIndex(0);
|
||||
changeSecurity(ui->comboBox_security->currentText());
|
||||
ui->lineEdit_essid->clear();
|
||||
ui->lineEdit_wpaConfigSection->clear();
|
||||
ui->listWidget_wpaConfigSection->setCurrentRow(-1);
|
||||
ui->listWidget_wpaConfigSection->clear();
|
||||
ui->lineEdit_wpaConfig->setText(QString("/etc/wpa_supplicant.conf"));
|
||||
ui->lineEdit_key->clear();
|
||||
ui->checkBox_hidden->setCheckState(Qt::Unchecked);
|
||||
ui->checkBox_adhoc->setCheckState(Qt::Unchecked);
|
||||
ui->spinBox_freq->setValue(2412);
|
||||
ui->listWidget_freq->setCurrentRow(-1);
|
||||
ui->listWidget_freq->clear();
|
||||
ui->spinBox_priority->setValue(0);
|
||||
ui->lineEdit_country->clear();
|
||||
ui->lineEdit_wpaGroup->setText(QString("wheel"));
|
||||
ui->comboBox_drivers->setCurrentIndex(0);
|
||||
ui->listWidget_drivers->setCurrentRow(-1);
|
||||
ui->listWidget_drivers->clear();
|
||||
ui->comboBox_rfkill->addItem(QString("auto"));
|
||||
if (rfkillDirectory->exists()) {
|
||||
QStringList rfkillDevices = rfkillDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (int i=0; i<rfkillDevices.count(); i++) {
|
||||
QFile device(rfkillDirectory->absolutePath() + QDir::separator() + rfkillDevices[i] +
|
||||
QDir::separator() + QString("name"));
|
||||
QString deviceName;
|
||||
if (device.open(QIODevice::ReadOnly))
|
||||
deviceName = QString(device.readLine()).remove(QString("\n"));
|
||||
ui->comboBox_rfkill->addItem(deviceName);
|
||||
}
|
||||
}
|
||||
ui->comboBox_rfkill->setCurrentIndex(0);
|
||||
ui->spinBox_timeoutWpa->setValue(15);
|
||||
ui->checkBox_exclude->setCheckState(Qt::Unchecked);
|
||||
|
||||
ui->pushButton_wirelessAdvanced->setChecked(false);
|
||||
showAdvanced();
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::setShown(const bool state)
|
||||
{
|
||||
if (state)
|
||||
show();
|
||||
else
|
||||
hide();
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::createActions()
|
||||
{
|
||||
connect(ui->pushButton_wirelessAdvanced, SIGNAL(clicked(bool)), this, SLOT(showAdvanced()));
|
||||
connect(ui->pushButton_drivers, SIGNAL(clicked(bool)), this, SLOT(addDriver()));
|
||||
connect(ui->pushButton_freq, SIGNAL(clicked(bool)), this, SLOT(addFreq()));
|
||||
connect(ui->pushButton_wpaConfigSection, SIGNAL(clicked(bool)), this, SLOT(addOption()));
|
||||
connect(ui->pushButton_wpaConfig, SIGNAL(clicked(bool)), this, SLOT(selectWpaConfig()));
|
||||
connect(ui->comboBox_security, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeSecurity(QString)));
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::keyPressEvent(QKeyEvent *pressedKey)
|
||||
{
|
||||
if (pressedKey->key() == Qt::Key_Delete) {
|
||||
if (ui->listWidget_wpaConfigSection->hasFocus() &&
|
||||
(ui->listWidget_wpaConfigSection->currentItem() != 0))
|
||||
delete ui->listWidget_wpaConfigSection->currentItem();
|
||||
else if (ui->listWidget_freq->hasFocus() &&
|
||||
(ui->listWidget_freq->currentItem() != 0))
|
||||
delete ui->listWidget_freq->currentItem();
|
||||
else if (ui->listWidget_drivers->hasFocus() &&
|
||||
(ui->listWidget_drivers->currentItem() != 0))
|
||||
delete ui->listWidget_drivers->currentItem();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::addDriver()
|
||||
{
|
||||
QString driver = ui->comboBox_drivers->currentText();
|
||||
bool exists = false;
|
||||
for (int i=0; i<ui->listWidget_drivers->count(); i++)
|
||||
if (ui->listWidget_drivers->item(i)->text() == driver)
|
||||
exists = true;
|
||||
if (!exists)
|
||||
ui->listWidget_drivers->addItem(driver);
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::addFreq()
|
||||
{
|
||||
QString freq = QString::number(ui->spinBox_freq->value());
|
||||
bool exists = false;
|
||||
for (int i=0; i<ui->listWidget_freq->count(); i++)
|
||||
if (ui->listWidget_freq->item(i)->text() == freq)
|
||||
exists = true;
|
||||
if (!exists)
|
||||
ui->listWidget_freq->addItem(freq);
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::addOption()
|
||||
{
|
||||
if (!ui->lineEdit_wpaConfigSection->text().isEmpty())
|
||||
ui->listWidget_wpaConfigSection->addItem(ui->lineEdit_wpaConfigSection->text());
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::changeSecurity(const QString currentText)
|
||||
{
|
||||
if (currentText == QString("none")) {
|
||||
ui->widget_essid->setShown(true);
|
||||
ui->widget_wpaConfigSection->setHidden(true);
|
||||
ui->widget_wpaConfig->setHidden(true);
|
||||
ui->widget_key->setHidden(true);
|
||||
}
|
||||
else if ((currentText == QString("wep")) ||
|
||||
(currentText == QString("wpa"))) {
|
||||
ui->widget_essid->setShown(true);
|
||||
ui->widget_wpaConfigSection->setHidden(true);
|
||||
ui->widget_wpaConfig->setHidden(true);
|
||||
ui->widget_key->setShown(true);
|
||||
}
|
||||
else if (currentText == QString("wpa-configsection")) {
|
||||
ui->widget_essid->setHidden(true);
|
||||
ui->widget_wpaConfigSection->setShown(true);
|
||||
ui->widget_wpaConfig->setHidden(true);
|
||||
ui->widget_key->setHidden(true);
|
||||
}
|
||||
else if (currentText == QString("wpa-config")) {
|
||||
ui->widget_essid->setHidden(true);
|
||||
ui->widget_wpaConfigSection->setHidden(true);
|
||||
ui->widget_wpaConfig->setShown(true);
|
||||
ui->widget_key->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::selectWpaConfig()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
QApplication::translate("EthernetWidget", "Select wpa configuration file"),
|
||||
QDir::currentPath(),
|
||||
QApplication::translate("EthernetWidget", "Configuration files (*.conf)"));
|
||||
if (!filename.isEmpty())
|
||||
ui->lineEdit_wpaConfig->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::showAdvanced()
|
||||
{
|
||||
if (ui->pushButton_wirelessAdvanced->isChecked()) {
|
||||
ui->widget_wirelessAdvanced->setShown(true);
|
||||
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Hide advanced"));
|
||||
}
|
||||
else {
|
||||
ui->widget_wirelessAdvanced->setHidden(true);
|
||||
ui->pushButton_wirelessAdvanced->setText(QApplication::translate("WirelessWidget", "Show advanced"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QMap<QString, QString> WirelessWidget::getSettings()
|
||||
{
|
||||
QMap<QString, QString> wirelessSettings;
|
||||
|
||||
if (isOk() != 0)
|
||||
return wirelessSettings;
|
||||
|
||||
wirelessSettings[QString("Security")] = ui->comboBox_security->currentText();
|
||||
wirelessSettings[QString("ESSID")] = QString("'") + ui->lineEdit_essid->text() + QString("'");
|
||||
if (ui->comboBox_security->currentText() == QString("wep")) {
|
||||
if (ui->lineEdit_key->text().indexOf(QString("\\\"")) == 0)
|
||||
wirelessSettings[QString("Key")] = ui->lineEdit_key->text();
|
||||
else
|
||||
wirelessSettings[QString("Key")] = QString("'") + ui->lineEdit_key->text() + QString("'");
|
||||
}
|
||||
else if (ui->comboBox_security->currentText() == QString("wpa"))
|
||||
wirelessSettings[QString("Key")] = QString("'") + ui->lineEdit_key->text() + QString("'");
|
||||
if (ui->comboBox_security->currentText() == QString("wpa-configsection")) {
|
||||
QStringList section;
|
||||
for (int i=0; i<ui->listWidget_wpaConfigSection->count(); i++)
|
||||
section.append(QString("'") + ui->listWidget_wpaConfigSection->item(i)->text() + QString("'"));
|
||||
wirelessSettings[QString("WPAConfigSection")] = QString("\n") + section.join(QString("\n")) + QString("\n");
|
||||
}
|
||||
if (ui->comboBox_security->currentText() == QString("wpa-config"))
|
||||
wirelessSettings[QString("WPAConfigFile")] = QString("'") + ui->lineEdit_wpaConfig->text() + QString("'");
|
||||
if (ui->checkBox_hidden->checkState() == Qt::Checked)
|
||||
wirelessSettings[QString("Hidden")] = QString("yes");
|
||||
if (ui->checkBox_adhoc->checkState() == Qt::Checked)
|
||||
wirelessSettings[QString("AdHoc")] = QString("yes");
|
||||
if (ui->listWidget_freq->count() != 0) {
|
||||
QStringList freqs;
|
||||
for (int i=0; i<ui->listWidget_freq->count(); i++)
|
||||
freqs.append(ui->listWidget_freq->item(i)->text());
|
||||
wirelessSettings[QString("ScanFrequencies")] = freqs.join(QString(" "));
|
||||
}
|
||||
if (ui->spinBox_priority->value() != 0)
|
||||
wirelessSettings[QString("Priority")] = QString::number(ui->spinBox_priority->value());
|
||||
if (!ui->lineEdit_country->text().isEmpty())
|
||||
wirelessSettings[QString("Country")] = QString("'") + ui->lineEdit_country->text() + QString("'");
|
||||
if (ui->lineEdit_wpaGroup->text() != QString("wheel"))
|
||||
wirelessSettings[QString("WPAGroup")] = QString("'") + ui->lineEdit_wpaGroup->text() + QString("'");
|
||||
if (ui->listWidget_drivers->count() != 0) {
|
||||
QStringList drivers;
|
||||
for (int i=0; i<ui->listWidget_drivers->count(); i++)
|
||||
drivers.append(ui->listWidget_drivers->item(i)->text());
|
||||
wirelessSettings[QString("WPADriver")] = QString("'") + drivers.join(QString(",")) + QString("'");
|
||||
}
|
||||
if (ui->comboBox_rfkill->currentText() != QString("auto"))
|
||||
wirelessSettings[QString("RFKill")] = ui->comboBox_rfkill->currentText();
|
||||
if (ui->spinBox_timeoutWpa->value() != 15)
|
||||
wirelessSettings[QString("TimeoutWPA")] = QString::number(ui->spinBox_timeoutWpa->value());
|
||||
if (ui->checkBox_exclude->checkState() == Qt::Checked)
|
||||
wirelessSettings[QString("ExcludeAuto")] = QString("yes");
|
||||
|
||||
return wirelessSettings;
|
||||
}
|
||||
|
||||
|
||||
int WirelessWidget::isOk()
|
||||
{
|
||||
// empty key
|
||||
if ((ui->comboBox_security->currentText() == QString("wep")) ||
|
||||
(ui->comboBox_security->currentText() == QString("wpa")))
|
||||
if (ui->lineEdit_key->text().isEmpty())
|
||||
return 1;
|
||||
// empty settings
|
||||
if (ui->comboBox_security->currentText() == QString("wpa-configsection"))
|
||||
if (ui->listWidget_wpaConfigSection->count() == 0)
|
||||
return 2;
|
||||
// file is not set
|
||||
if (ui->comboBox_security->currentText() == QString("wpa-config"))
|
||||
if (ui->lineEdit_wpaConfig->text().isEmpty())
|
||||
return 3;
|
||||
// file wpa_supplicant doesn't exists
|
||||
if (ui->comboBox_security->currentText() == QString("wpa-config"))
|
||||
if (!ui->lineEdit_wpaConfig->text().isEmpty())
|
||||
if (!QFile(ui->lineEdit_wpaConfig->text()).exists())
|
||||
return 4;
|
||||
// essid is not set
|
||||
if ((ui->comboBox_security->currentText() == QString("none")) ||
|
||||
(ui->comboBox_security->currentText() == QString("wep")) ||
|
||||
(ui->comboBox_security->currentText() == QString("wpa")))
|
||||
if (ui->lineEdit_essid->text().isEmpty())
|
||||
return 5;
|
||||
// all fine
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void WirelessWidget::setSettings(const QMap<QString, QString> settings)
|
||||
{
|
||||
QMap<QString, QString> wirelessSettings = settings;
|
||||
|
||||
if (wirelessSettings.contains(QString("Security")))
|
||||
for (int i=0; i<ui->comboBox_security->count(); i++)
|
||||
if (wirelessSettings[QString("Security")].remove(QString("'")) == ui->comboBox_security->itemText(i))
|
||||
ui->comboBox_security->setCurrentIndex(i);
|
||||
if (wirelessSettings.contains(QString("ESSID")))
|
||||
ui->lineEdit_essid->setText(wirelessSettings[QString("ESSID")].remove(QString("'")));
|
||||
if (wirelessSettings.contains(QString("Key")))
|
||||
ui->lineEdit_key->setText(wirelessSettings[QString("Key")].remove(QString("'")));
|
||||
if (wirelessSettings.contains(QString("WPAConfigSection"))) {
|
||||
QStringList custom;
|
||||
if (wirelessSettings[QString("WPAConfigSection")].contains(QString("\n")))
|
||||
custom = wirelessSettings[QString("WPAConfigSection")].split(QString("'\n'"));
|
||||
else
|
||||
custom = wirelessSettings[QString("WPAConfigSection")].split(QString("' '"));
|
||||
for (int i=0; i<custom.count(); i++)
|
||||
ui->listWidget_wpaConfigSection->addItem(custom[i].remove(QString("'")));
|
||||
}
|
||||
if (wirelessSettings.contains(QString("WPAConfigFile")))
|
||||
ui->lineEdit_wpaConfig->setText(wirelessSettings[QString("WPAConfigFile")].remove(QString("'")));
|
||||
if (wirelessSettings.contains(QString("Hidden")))
|
||||
if (wirelessSettings[QString("Hidden")].remove(QString("'")) == QString("yes"))
|
||||
ui->checkBox_hidden->setCheckState(Qt::Checked);
|
||||
if (wirelessSettings.contains(QString("AdHoc")))
|
||||
if (wirelessSettings[QString("AdHoc")].remove(QString("'")) == QString("yes"))
|
||||
ui->checkBox_adhoc->setCheckState(Qt::Checked);
|
||||
if (wirelessSettings.contains(QString("ScanFrequencies")))
|
||||
ui->listWidget_freq->addItems(wirelessSettings[QString("ScanFrequencies")].split(QString("\n")));
|
||||
if (wirelessSettings.contains(QString("Priority")))
|
||||
ui->spinBox_priority->setValue(wirelessSettings[QString("Priority")].toInt());
|
||||
if (wirelessSettings.contains(QString("Country")))
|
||||
ui->lineEdit_country->setText(wirelessSettings[QString("Country")].remove(QString("'")));
|
||||
if (wirelessSettings.contains(QString("WPAGroup")))
|
||||
ui->lineEdit_wpaGroup->setText(wirelessSettings[QString("WPAGroup")].remove(QString("'")));
|
||||
if (wirelessSettings.contains(QString("WPADriver")))
|
||||
ui->listWidget_drivers->addItems(wirelessSettings[QString("WPADriver")].split(QString(",")));
|
||||
if (wirelessSettings.contains(QString("RFKill")))
|
||||
for (int i=0; i<ui->comboBox_rfkill->count(); i++)
|
||||
if (wirelessSettings[QString("RFKill")].remove(QString("'")) == ui->comboBox_rfkill->itemText(i))
|
||||
ui->comboBox_rfkill->setCurrentIndex(i);
|
||||
if (wirelessSettings.contains(QString("TimeoutWPA")))
|
||||
ui->spinBox_timeoutWpa->setValue(wirelessSettings[QString("TimeoutWPA")].toInt());
|
||||
if (wirelessSettings.contains(QString("ExcludeAuto")))
|
||||
if (wirelessSettings[QString("ExcludeAuto")].remove(QString("'")) == QString("yes"))
|
||||
ui->checkBox_exclude->setCheckState(Qt::Checked);
|
||||
|
||||
changeSecurity(ui->comboBox_security->currentText());
|
||||
}
|
62
sources/gui/src/wirelesswidget.h
Normal file
62
sources/gui/src/wirelesswidget.h
Normal file
@ -0,0 +1,62 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef WIRELESSWIDGET_H
|
||||
#define WIRELESSWIDGET_H
|
||||
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
#include <QWidget>
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class WirelessWidget;
|
||||
}
|
||||
|
||||
class WirelessWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WirelessWidget(QWidget *parent = 0,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
~WirelessWidget();
|
||||
QMap<QString, QString> getSettings();
|
||||
int isOk();
|
||||
void setSettings(const QMap<QString, QString> settings);
|
||||
|
||||
public slots:
|
||||
void clear();
|
||||
void setShown(const bool state);
|
||||
|
||||
private slots:
|
||||
void addDriver();
|
||||
void addFreq();
|
||||
void addOption();
|
||||
void changeSecurity(const QString currentText);
|
||||
void showAdvanced();
|
||||
void selectWpaConfig();
|
||||
|
||||
private:
|
||||
QDir *rfkillDirectory;
|
||||
Ui::WirelessWidget *ui;
|
||||
void createActions();
|
||||
void keyPressEvent(QKeyEvent *pressedKey);
|
||||
};
|
||||
|
||||
|
||||
#endif /* WIRELESSWIDGET_H */
|
540
sources/gui/src/wirelesswidget.ui
Normal file
540
sources/gui/src/wirelesswidget.ui
Normal file
@ -0,0 +1,540 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>WirelessWidget</class>
|
||||
<widget class="QWidget" name="WirelessWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>431</width>
|
||||
<height>776</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QDockWidget" name="dockWidget_wireless">
|
||||
<property name="features">
|
||||
<set>QDockWidget::NoDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Wireless options</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents_wireless">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_security">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_security">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Security</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_security">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>none</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>wep</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>wpa</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>wpa-configsection</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>wpa-config</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_essid" native="true">
|
||||
<layout class="QHBoxLayout" name="layout_essid">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_essid">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>ESSID</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_essid">
|
||||
<property name="toolTip">
|
||||
<string>The name of the network to connect to</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_wpaConfigSection" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wpaConfigSection">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wpaConfigSection">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wpa config section</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaConfigSection"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wpaConfigSection">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_wpaConfigSection">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Array of lines that form a network block for wpa_supplicant</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_wpaConfig" native="true">
|
||||
<layout class="QHBoxLayout" name="layout_wpaConfigFile">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wpaConfig">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wpa config file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaConfig">
|
||||
<property name="toolTip">
|
||||
<string>Path to a wpa_supplicant configuration file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wpaConfig">
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_key" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_key">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Key</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_key">
|
||||
<property name="toolTip">
|
||||
<string>The secret key to a WEP, or WPA encrypted network</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_hidden">
|
||||
<property name="toolTip">
|
||||
<string>Whether or not the specified network is a hidden network</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hidden</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_adhoc">
|
||||
<property name="toolTip">
|
||||
<string>Whether or not to use ad-hoc mode</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Ad-hoc</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_wirelessAdvanced">
|
||||
<item>
|
||||
<spacer name="spacer_wirelessAdvanced">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_wirelessAdvanced">
|
||||
<property name="text">
|
||||
<string>Show advanced</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_wirelessAdvanced" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_freq">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_freqLine">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_freq">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Scan frequencies</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_freq">
|
||||
<property name="minimum">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>6000</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>2412</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_freq">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_freq">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>A space-separated list of frequencies in MHz to scan when searching for the network</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_priority">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_priority">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Priority</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_priority">
|
||||
<property name="toolTip">
|
||||
<string>Priority group for the network</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_country">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_country">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Country</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_country">
|
||||
<property name="toolTip">
|
||||
<string>The country for which frequency regulations will be enforced</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layourt_wpaGroup">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_wpaGroup">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WPA group</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_wpaGroup">
|
||||
<property name="toolTip">
|
||||
<string>Group that has the authority to configure wpa_supplicant via its control interface</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="layout_drivers">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_driversLine">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_drivers">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Drivers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_drivers">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>west</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>nl80211</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>wired</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_drivers">
|
||||
<property name="text">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget_drivers">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The wpa_supplicant driver to use</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_rfkill">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_rfkill">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>RFkill device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBox_rfkill">
|
||||
<property name="toolTip">
|
||||
<string>The name of an rfkill device</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_timeoutWpa">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_timeoutWpa">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Timeout WPA</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinBox_timeoutWpa">
|
||||
<property name="toolTip">
|
||||
<string>Maximum time, in seconds, to wait for steps in the association and authentication to succeed</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>15</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_exclude">
|
||||
<property name="toolTip">
|
||||
<string>Whether or not to exclude this profile from automatic profile selection</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exclude auto</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>comboBox_security</tabstop>
|
||||
<tabstop>lineEdit_essid</tabstop>
|
||||
<tabstop>lineEdit_wpaConfigSection</tabstop>
|
||||
<tabstop>pushButton_wpaConfigSection</tabstop>
|
||||
<tabstop>listWidget_wpaConfigSection</tabstop>
|
||||
<tabstop>lineEdit_wpaConfig</tabstop>
|
||||
<tabstop>pushButton_wpaConfig</tabstop>
|
||||
<tabstop>lineEdit_key</tabstop>
|
||||
<tabstop>checkBox_hidden</tabstop>
|
||||
<tabstop>checkBox_adhoc</tabstop>
|
||||
<tabstop>pushButton_wirelessAdvanced</tabstop>
|
||||
<tabstop>spinBox_freq</tabstop>
|
||||
<tabstop>pushButton_freq</tabstop>
|
||||
<tabstop>listWidget_freq</tabstop>
|
||||
<tabstop>spinBox_priority</tabstop>
|
||||
<tabstop>lineEdit_country</tabstop>
|
||||
<tabstop>lineEdit_wpaGroup</tabstop>
|
||||
<tabstop>comboBox_drivers</tabstop>
|
||||
<tabstop>pushButton_drivers</tabstop>
|
||||
<tabstop>listWidget_drivers</tabstop>
|
||||
<tabstop>comboBox_rfkill</tabstop>
|
||||
<tabstop>spinBox_timeoutWpa</tabstop>
|
||||
<tabstop>checkBox_exclude</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
231
sources/gui/src/wpasupinteract.cpp
Normal file
231
sources/gui/src/wpasupinteract.cpp
Normal file
@ -0,0 +1,231 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "wpasupinteract.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QProcess>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "netctlinteract.h"
|
||||
#include "sleepthread.h"
|
||||
|
||||
|
||||
WpaSup::WpaSup(MainWindow *wid, const QMap<QString, QString> settings)
|
||||
: parent(wid)
|
||||
{
|
||||
ctrlDir = settings[QString("CTRL_DIR")];
|
||||
ctrlGroup = settings[QString("CTRL_GROUP")];
|
||||
ifaceDirectory = new QDir(settings[QString("IFACE_DIR")]);
|
||||
mainInterface = settings[QString("PREFERED_IFACE")];
|
||||
pidFile = settings[QString("PID_FILE")];
|
||||
sudoCommand = settings[QString("SUDO_PATH")];
|
||||
wpaCliPath = settings[QString("WPACLI_PATH")];
|
||||
wpaDrivers = settings[QString("WPA_DRIVERS")];
|
||||
wpaSupPath = settings[QString("WPASUP_PATH")];
|
||||
|
||||
// terminate old loaded profile
|
||||
if (QFile(pidFile).exists() || QDir(ctrlDir).exists())
|
||||
stopWpaSupplicant();
|
||||
}
|
||||
|
||||
|
||||
WpaSup::~WpaSup()
|
||||
{
|
||||
delete ifaceDirectory;
|
||||
}
|
||||
|
||||
|
||||
// general information
|
||||
QString WpaSup::existentProfile(const QString profile)
|
||||
{
|
||||
QString profileFile = QString("");
|
||||
QList<QStringList> profileList = parent->netctlCommand->getProfileList();
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profile == parent->netctlCommand->getSsidFromProfile(profileList[i][0]))
|
||||
profileFile = profileList[i][0];
|
||||
return profileFile;
|
||||
}
|
||||
|
||||
|
||||
QStringList WpaSup::getInterfaceList()
|
||||
{
|
||||
QStringList interfaces;
|
||||
|
||||
if (!mainInterface.isEmpty())
|
||||
interfaces.append(mainInterface);
|
||||
QStringList allInterfaces = ifaceDirectory->entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (int i=0; i<allInterfaces.count(); i++) {
|
||||
qDebug() << "[WpaSup]" << "[getInterfaceList]" << ":" << "Check directory"
|
||||
<< ifaceDirectory->path() + QDir::separator() + allInterfaces[i] + QDir::separator() + QString("wireless");
|
||||
if (QDir(ifaceDirectory->path() + QDir::separator() + allInterfaces[i] +
|
||||
QDir::separator() + QString("wireless")).exists())
|
||||
interfaces.append(allInterfaces[i]);
|
||||
}
|
||||
|
||||
return interfaces;
|
||||
}
|
||||
|
||||
|
||||
bool WpaSup::isProfileActive(const QString profile)
|
||||
{
|
||||
QString profileFile;
|
||||
QList<QStringList> profileList = parent->netctlCommand->getProfileList();
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profile == parent->netctlCommand->getSsidFromProfile(profileList[i][0]))
|
||||
profileFile = profileList[i][0];
|
||||
return parent->netctlCommand->isProfileActive(profileFile);
|
||||
}
|
||||
|
||||
|
||||
bool WpaSup::isProfileExists(const QString profile)
|
||||
{
|
||||
bool exists = false;
|
||||
QList<QStringList> profileList = parent->netctlCommand->getProfileList();
|
||||
for (int i=0; i<profileList.count(); i++)
|
||||
if (profile == parent->netctlCommand->getSsidFromProfile(profileList[i][0]))
|
||||
exists = true;
|
||||
return exists;
|
||||
}
|
||||
|
||||
|
||||
// functions
|
||||
bool WpaSup::wpaCliCall(const QString commandLine)
|
||||
{
|
||||
QString interface = getInterfaceList()[0];
|
||||
QProcess command;
|
||||
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
|
||||
QString(" -P ") + pidFile + QString(" ") + commandLine;
|
||||
qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
SleepThread::sleep(1);
|
||||
qDebug() << "[WpaSup]" << "[wpaCliCall]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (command.exitCode() == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
QString WpaSup::getWpaCliOutput(const QString commandLine)
|
||||
{
|
||||
QString interface = getInterfaceList()[0];
|
||||
QProcess command;
|
||||
QString commandText = wpaCliPath + QString(" -i ") + interface + QString(" -p ") + ctrlDir +
|
||||
QString(" -P ") + pidFile + QString(" ") + commandLine;
|
||||
qDebug() << "[WpaSup]" << "[getWpaCliOutput]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
return command.readAllStandardOutput();
|
||||
}
|
||||
|
||||
|
||||
QList<QStringList> WpaSup::scanWifi()
|
||||
{
|
||||
QList<QStringList> scanResults;
|
||||
if (!startWpaSupplicant()) {
|
||||
stopWpaSupplicant();
|
||||
return scanResults;
|
||||
}
|
||||
if (!wpaCliCall(QString("scan")))
|
||||
return scanResults;
|
||||
SleepThread::sleep(3);
|
||||
|
||||
QStringList rawOutput = getWpaCliOutput(QString("scan_results")).split(QString("\n"), QString::SkipEmptyParts);
|
||||
// remove table header
|
||||
rawOutput.removeFirst();
|
||||
// remove duplicates
|
||||
QStringList rawList;
|
||||
for (int i=0; i<rawOutput.count(); i++) {
|
||||
bool exist = false;
|
||||
if (rawOutput[i].split(QString("\t"), QString::SkipEmptyParts).count() > 4)
|
||||
for (int j=0; j<rawList.count(); j++)
|
||||
if (rawList[j].split(QString("\t"), QString::SkipEmptyParts).count() > 4)
|
||||
if (rawOutput[i].split(QString("\t"), QString::SkipEmptyParts)[4] ==
|
||||
rawList[j].split(QString("\t"), QString::SkipEmptyParts)[4])
|
||||
exist = true;
|
||||
if (!exist)
|
||||
rawList.append(rawOutput[i]);
|
||||
}
|
||||
|
||||
for (int i=0; i<rawList.count(); i++) {
|
||||
QStringList wifiPoint;
|
||||
|
||||
// point name
|
||||
if (rawList[i].split(QString("\t"), QString::SkipEmptyParts).count() > 4)
|
||||
wifiPoint.append(rawList[i].split(QString("\t"), QString::SkipEmptyParts)[4]);
|
||||
else
|
||||
wifiPoint.append(QString("<hidden>"));
|
||||
// profile status
|
||||
QString status;
|
||||
if (isProfileExists(wifiPoint[0])) {
|
||||
status = QString("exists");
|
||||
if (isProfileActive(wifiPoint[0]))
|
||||
status = status + QString(" (active)");
|
||||
else
|
||||
status = status + QString(" (inactive)");
|
||||
}
|
||||
else
|
||||
status = QString("new");
|
||||
wifiPoint.append(status);
|
||||
// point signal
|
||||
wifiPoint.append(rawList[i].split(QString("\t"), QString::SkipEmptyParts)[2]);
|
||||
// point security
|
||||
QString security = rawList[i].split(QString("\t"), QString::SkipEmptyParts)[3];
|
||||
if (security.contains(QString("WPA2")))
|
||||
security = QString("WPA2");
|
||||
else if (security.contains(QString("WPA")))
|
||||
security = QString("WPA");
|
||||
else if (security.contains(QString("WEP")))
|
||||
security = QString("WEP");
|
||||
else
|
||||
security = QString("none");
|
||||
wifiPoint.append(security);
|
||||
|
||||
scanResults.append(wifiPoint);
|
||||
}
|
||||
|
||||
stopWpaSupplicant();
|
||||
return scanResults;
|
||||
}
|
||||
|
||||
|
||||
bool WpaSup::startWpaSupplicant()
|
||||
{
|
||||
if (!QFile(pidFile).exists()) {
|
||||
QString interface = getInterfaceList()[0];
|
||||
QProcess command;
|
||||
QString commandText = sudoCommand + QString(" ") + wpaSupPath + QString(" -B -P ") + pidFile +
|
||||
QString(" -i ") + interface + QString(" -D ") + wpaDrivers +
|
||||
QString(" -C \"DIR=") + ctrlDir + QString(" GROUP=") + ctrlGroup + QString("\"");
|
||||
qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Run cmd" << commandText;
|
||||
command.start(commandText);
|
||||
command.waitForFinished(-1);
|
||||
SleepThread::sleep(1);
|
||||
qDebug() << "[WpaSup]" << "[startWpaSupplicant]" << ":" << "Cmd returns" << command.exitCode();
|
||||
if (command.exitCode() != 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool WpaSup::stopWpaSupplicant()
|
||||
{
|
||||
return wpaCliCall(QString("terminate"));
|
||||
}
|
65
sources/gui/src/wpasupinteract.h
Normal file
65
sources/gui/src/wpasupinteract.h
Normal file
@ -0,0 +1,65 @@
|
||||
/***************************************************************************
|
||||
* This file is part of netctl-plasmoid *
|
||||
* *
|
||||
* netctl-plasmoid is free software: you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* netctl-plasmoid is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef WPASUPINTERACT_H
|
||||
#define WPASUPINTERACT_H
|
||||
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
|
||||
|
||||
class MainWindow;
|
||||
|
||||
class WpaSup : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WpaSup(MainWindow *wid = 0,
|
||||
const QMap<QString, QString> settings = QMap<QString, QString>());
|
||||
~WpaSup();
|
||||
// general information
|
||||
QString existentProfile(const QString profile);
|
||||
QStringList getInterfaceList();
|
||||
bool isProfileActive(const QString profile);
|
||||
bool isProfileExists(const QString profile);
|
||||
|
||||
public slots:
|
||||
// functions
|
||||
QList<QStringList> scanWifi();
|
||||
bool startWpaSupplicant();
|
||||
bool stopWpaSupplicant();
|
||||
|
||||
private:
|
||||
MainWindow *parent;
|
||||
QString ctrlDir;
|
||||
QString ctrlGroup;
|
||||
QDir *ifaceDirectory;
|
||||
QString mainInterface;
|
||||
QString pidFile;
|
||||
QString sudoCommand;
|
||||
QString wpaCliPath;
|
||||
QString wpaDrivers;
|
||||
QString wpaSupPath;
|
||||
// functions
|
||||
bool wpaCliCall(const QString commandLine);
|
||||
QString getWpaCliOutput(const QString commandLine);
|
||||
};
|
||||
|
||||
|
||||
#endif /* WPASUPINTERACT_H */
|
@ -6,12 +6,10 @@ message (STATUS "Subproject ${SUBPROJECT}")
|
||||
find_package (KDE4 REQUIRED)
|
||||
include (KDE4Defaults)
|
||||
|
||||
add_definitions (${QT_DEFINITIONS}
|
||||
${KDE4_DEFINITIONS})
|
||||
include_directories (${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${KDE4_INCLUDES}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||
add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
|
||||
include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../)
|
||||
|
||||
add_subdirectory (po)
|
||||
|
||||
# set sources
|
||||
set (PLUGIN_NAME ${SUBPROJECT})
|
||||
|
@ -23,7 +23,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabConfiguration">
|
||||
<attribute name="title">
|
||||
|
@ -12,12 +12,11 @@
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#include "netctl.h"
|
||||
#include "ui_configwindow.h"
|
||||
#include <version.h>
|
||||
|
||||
#include <KConfigDialog>
|
||||
#include <KFileDialog>
|
||||
@ -27,11 +26,12 @@
|
||||
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QMenu>
|
||||
#include <cstdio>
|
||||
|
||||
#include <version.h>
|
||||
|
||||
|
||||
Netctl::Netctl(QObject *parent, const QVariantList &args) :
|
||||
Plasma::Applet(parent, args)
|
||||
Netctl::Netctl(QObject *parent, const QVariantList &args)
|
||||
: Plasma::Applet(parent, args)
|
||||
{
|
||||
setBackgroundHints(DefaultBackground);
|
||||
setHasConfigurationInterface(true);
|
||||
@ -43,17 +43,15 @@ Netctl::Netctl(QObject *parent, const QVariantList &args) :
|
||||
|
||||
Netctl::~Netctl()
|
||||
{
|
||||
delete startProfileMenu;
|
||||
delete startProfile;
|
||||
delete stopProfile;
|
||||
delete restartProfile;
|
||||
delete enableProfileAutoload;
|
||||
// delete startProfileMenu;
|
||||
// delete startProfile;
|
||||
// delete stopProfile;
|
||||
// delete restartProfile;
|
||||
// delete enableProfileAutoload;
|
||||
|
||||
delete iconWidget;
|
||||
delete iconFrame;
|
||||
delete textFrame;
|
||||
// delete iconWidget;
|
||||
|
||||
delete netctlEngine;
|
||||
// delete netctlEngine;
|
||||
}
|
||||
|
||||
|
||||
@ -64,33 +62,40 @@ void Netctl::init()
|
||||
// generate ui
|
||||
// main layout
|
||||
fullSpaceLayout = new QGraphicsLinearLayout();
|
||||
fullSpaceLayout->setContentsMargins(1, 1, 1, 1);
|
||||
setLayout(fullSpaceLayout);
|
||||
|
||||
// frames
|
||||
// icon
|
||||
iconFrame = new Plasma::Frame();
|
||||
QGraphicsLinearLayout *iconLayout = new QGraphicsLinearLayout();
|
||||
iconWidget = new Plasma::IconWidget(KIcon(""), QString(), this);
|
||||
iconWidget->setPreferredSize(30, 30);
|
||||
connect(iconWidget, SIGNAL(doubleClicked()), this, SLOT(showGui()));
|
||||
iconFrame->setLayout(iconLayout);
|
||||
iconLayout->addItem(iconWidget);
|
||||
fullSpaceLayout->addItem(iconFrame);
|
||||
fullSpaceLayout->addItem(iconWidget);
|
||||
// text
|
||||
textFrame = new Plasma::Frame();
|
||||
QGraphicsLinearLayout *textLayout = new QGraphicsLinearLayout();
|
||||
textLabel = new Plasma::Label();
|
||||
textLayout->addItem(textLabel);
|
||||
textFrame->setLayout(textLayout);
|
||||
fullSpaceLayout->addItem(textFrame);
|
||||
textFrame->hide();
|
||||
// stretch
|
||||
fullSpaceLayout->addStretch(1);
|
||||
textLabel->setPreferredHeight(30);
|
||||
fullSpaceLayout->addItem(textLabel);
|
||||
|
||||
// read variables
|
||||
configChanged();
|
||||
}
|
||||
|
||||
|
||||
void Netctl::updateInterface(bool setShown)
|
||||
{
|
||||
if (setShown) {
|
||||
textLabel->show();
|
||||
fullSpaceLayout->updateGeometry();
|
||||
updateGeometry();
|
||||
}
|
||||
else {
|
||||
textLabel->hide();
|
||||
fullSpaceLayout->updateGeometry();
|
||||
updateGeometry();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// context menu
|
||||
void Netctl::startProfileSlot(QAction *profile)
|
||||
{
|
||||
@ -100,9 +105,10 @@ void Netctl::startProfileSlot(QAction *profile)
|
||||
if (status)
|
||||
commandLine = netctlPath + QString(" stop ") + profileName + QString(" && ");
|
||||
if (useSudo)
|
||||
commandLine = sudoPath + QString(" \"") + commandLine + netctlPath + QString(" start ") + profile->text().mid(1) + QString("\"");
|
||||
commandLine = sudoPath + QString(" \"") + commandLine +
|
||||
netctlPath + QString(" start ") + profile->text().remove(QString("&")) + QString("\"");
|
||||
else
|
||||
commandLine = commandLine + netctlPath + QString(" start ") + profile->text().mid(1);
|
||||
commandLine = commandLine + netctlPath + QString(" start ") + profile->text().remove(QString("&"));
|
||||
command.startDetached(commandLine);
|
||||
}
|
||||
|
||||
@ -135,10 +141,10 @@ void Netctl::enableProfileAutoloadSlot()
|
||||
{
|
||||
QProcess command;
|
||||
QString commandLine, enableStatus;
|
||||
if (profileStatus == QString("(enable"))
|
||||
enableStatus = QString("disable");
|
||||
if (profileStatus.contains(QString("enabled")))
|
||||
enableStatus = QString(" disable ");
|
||||
else
|
||||
enableStatus = QString("enable");
|
||||
enableStatus = QString(" enable ");
|
||||
if (useSudo)
|
||||
commandLine = sudoPath + QString(" \"") + netctlPath + enableStatus + profileName + QString("\"");
|
||||
else
|
||||
@ -180,7 +186,7 @@ QList<QAction*> Netctl::contextualActions()
|
||||
restartProfile->setVisible(true);
|
||||
restartProfile->setText(QString("Restart ") + profileName);
|
||||
enableProfileAutoload->setVisible(true);
|
||||
if (profileStatus == QString("(enable"))
|
||||
if (profileStatus.contains(QString("enabled")))
|
||||
enableProfileAutoload->setText(QString("Disable ") + profileName);
|
||||
else
|
||||
enableProfileAutoload->setText(QString("Enable ") + profileName);
|
||||
@ -228,6 +234,7 @@ void Netctl::connectToEngine()
|
||||
netctlEngine->connectSource(QString("statusBool"), this, autoUpdateInterval);
|
||||
netctlEngine->connectSource(QString("currentProfile"), this, autoUpdateInterval);
|
||||
netctlEngine->connectSource(QString("statusString"), this, autoUpdateInterval);
|
||||
updateInterface(false);
|
||||
if (showBigInterface) {
|
||||
if (showExtIp)
|
||||
netctlEngine->connectSource(QString("extIp"), this, autoUpdateInterval);
|
||||
@ -235,7 +242,7 @@ void Netctl::connectToEngine()
|
||||
netctlEngine->connectSource(QString("intIp"), this, autoUpdateInterval);
|
||||
if (showNetDev)
|
||||
netctlEngine->connectSource(QString("interfaces"), this, autoUpdateInterval);
|
||||
textFrame->show();
|
||||
updateInterface(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,9 +260,8 @@ void Netctl::disconnectFromEngine()
|
||||
netctlEngine->disconnectSource(QString("intIp"), this);
|
||||
if (showNetDev)
|
||||
netctlEngine->disconnectSource(QString("interfaces"), this);
|
||||
textFrame->hide();
|
||||
}
|
||||
update();
|
||||
updateInterface(false);
|
||||
}
|
||||
|
||||
|
||||
@ -263,7 +269,7 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
|
||||
{
|
||||
if (data.keys().count() == 0)
|
||||
return;
|
||||
QString value = data[QString("value")].toString();;
|
||||
QString value = data[QString("value")].toString();
|
||||
if (value.isEmpty())
|
||||
value = QString("N\\A");
|
||||
|
||||
@ -279,6 +285,7 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
|
||||
text.append(extIp);
|
||||
if (showNetDev)
|
||||
text.append(interfaces);
|
||||
if (showBigInterface)
|
||||
textLabel->setText(formatLine[0] + text.join(QString("<br>")) + formatLine[1]);
|
||||
}
|
||||
else if (sourceName == QString("extIp")) {
|
||||
@ -455,7 +462,7 @@ void Netctl::configChanged()
|
||||
sudoPath = cg.readEntry("sudoPath", "/usr/bin/kdesu -c");
|
||||
showBigInterface = cg.readEntry("showBigInterface", true);
|
||||
showNetDev = cg.readEntry("showNetDev", true);
|
||||
showExtIp = cg.readEntry("showExtIp", true);
|
||||
showExtIp = cg.readEntry("showExtIp", false);
|
||||
showIntIp = cg.readEntry("showIntIp", true);
|
||||
|
||||
fontFamily = cg.readEntry("fontFamily", "Terminus");
|
||||
@ -463,8 +470,8 @@ void Netctl::configChanged()
|
||||
fontColor = cg.readEntry("fontColor", "#000000");
|
||||
fontWeight = cg.readEntry("fontWeight", 400);
|
||||
fontStyle = cg.readEntry("fontStyle", "normal");
|
||||
activeIconPath = cg.readEntry("activeIconPath", "/usr/share/icons/hicolor/64x64/apps/network-idle.png");
|
||||
inactiveIconPath = cg.readEntry("inactiveIconPath", "/usr/share/icons/hicolor/64x64/apps/network-offline.png");
|
||||
activeIconPath = cg.readEntry("activeIconPath", "/usr/share/icons/hicolor/64x64/apps/netctl-idle.png");
|
||||
inactiveIconPath = cg.readEntry("inactiveIconPath", "/usr/share/icons/hicolor/64x64/apps/netctl-offline.png");
|
||||
|
||||
formatLine[0] = ("<p align=\"center\"><span style=\" font-family:'" + fontFamily + \
|
||||
"'; font-style:" + fontStyle + \
|
||||
|
@ -12,7 +12,7 @@
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with Foobar. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* along with netctl-plasmoid. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef NETCTL_PLASMOID_H
|
||||
@ -27,6 +27,7 @@
|
||||
|
||||
#include <ui_configwindow.h>
|
||||
|
||||
|
||||
class QGraphicsLinearLayout;
|
||||
|
||||
class Netctl : public Plasma::Applet
|
||||
@ -51,6 +52,8 @@ public slots:
|
||||
void setSudo();
|
||||
|
||||
private slots:
|
||||
// ui
|
||||
void updateInterface(bool setHidden);
|
||||
// configuration interface
|
||||
void selectGuiExe();
|
||||
void selectNetctlExe();
|
||||
@ -70,10 +73,8 @@ private:
|
||||
// ui
|
||||
QGraphicsLinearLayout *fullSpaceLayout;
|
||||
// icon
|
||||
Plasma::Frame *iconFrame;
|
||||
Plasma::IconWidget *iconWidget;
|
||||
// text
|
||||
Plasma::Frame *textFrame;
|
||||
Plasma::Label *textLabel;
|
||||
bool status;
|
||||
QString profileName;
|
||||
@ -96,7 +97,7 @@ private:
|
||||
void connectToEngine();
|
||||
void disconnectFromEngine();
|
||||
// notification
|
||||
|
||||
//
|
||||
// configuration interface
|
||||
Ui::ConfigWindow uiConfig;
|
||||
// configuration
|
||||
@ -120,4 +121,5 @@ private:
|
||||
|
||||
K_EXPORT_PLASMA_APPLET(netctl, Netctl)
|
||||
|
||||
|
||||
#endif /* NETCTL_PLASMOID_H */
|
||||
|
24
sources/plasmoid/po/CMakeLists.txt
Normal file
24
sources/plasmoid/po/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
find_package(KDE4 REQUIRED)
|
||||
find_package(Gettext REQUIRED)
|
||||
|
||||
if (NOT GETTEXT_MSGFMT_EXECUTABLE)
|
||||
message(FATAL_ERROR "Please install the msgfmt binary")
|
||||
endif (NOT GETTEXT_MSGFMT_EXECUTABLE)
|
||||
|
||||
file (GLOB _po_files *.po)
|
||||
|
||||
set (_gmoFiles)
|
||||
|
||||
foreach (_current_PO_FILE ${_po_files})
|
||||
get_filename_component (_lang ${_current_PO_FILE} NAME_WE)
|
||||
set (_gmoFile ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo)
|
||||
add_custom_command (OUTPUT ${_gmoFile}
|
||||
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${_gmoFile} ${_current_PO_FILE}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
DEPENDS ${_current_PO_FILE}
|
||||
)
|
||||
|
||||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${_lang}.gmo DESTINATION ${LOCALE_INSTALL_DIR}/${_lang}/LC_MESSAGES/ RENAME plasma_applet_netctl.mo)
|
||||
list (APPEND _gmoFiles ${_gmoFile})
|
||||
endforeach (_current_PO_FILE)
|
||||
add_custom_target (pofiles ALL DEPENDS ${_gmoFiles})
|
0
sources/plasmoid/po/background.list
Normal file
0
sources/plasmoid/po/background.list
Normal file
15
sources/plasmoid/po/create_list_files.sh
Executable file
15
sources/plasmoid/po/create_list_files.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
WDIR=`pwd` # working dir
|
||||
SATELLITE_LIST=satellite.list
|
||||
BACKGROUND_LIST=background.list
|
||||
|
||||
# Background list
|
||||
cd "$WDIR"
|
||||
cd ../images
|
||||
ls -1 background_* | sed -e "s/background_//g" | sed -e "s/_/ /g" | sed -e "s/\.jpg//g" | sed -e "s/\.png//g" | sed -e "s/\.gif//g" | grep -v '^$' | sort --unique --ignore-leading-blanks > "$WDIR/background.list"
|
||||
|
||||
# Satellite list
|
||||
cd "$WDIR"
|
||||
cd ../data
|
||||
cat satellite_images.xml | grep image\ name | sed -e "s/.*<image name=\"\([^\"]*\).*/\1/" | sed -e "s/\&/\&/g" | sed -e "s/\'/'/g" | sed -e "s/\"/\"/g" | sed -e "s/\</</g" | sed -e "s/\>/>/g" | grep -v '^$' | sort --unique --ignore-leading-blanks > "$WDIR/satellite.list"
|
199
sources/plasmoid/po/en.po
Normal file
199
sources/plasmoid/po/en.po
Normal file
@ -0,0 +1,199 @@
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
#
|
||||
# Evgeniy Alekseev <esalexeev@gmail.com>, 2014.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: http://kde-look.org/content/show.php?content=98925\n"
|
||||
"POT-Creation-Date: 2014-03-25 10:52+0400\n"
|
||||
"PO-Revision-Date: 2014-03-25 10:54+0400\n"
|
||||
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
|
||||
"Language-Team: Russian <kde-russian@lists.kde.ru>\n"
|
||||
"Language: ru\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<"
|
||||
"=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
|
||||
"X-Generator: Lokalize 1.5\n"
|
||||
|
||||
#: netctl.cpp:398
|
||||
msgid "Netctl plasmoid"
|
||||
msgstr "Netctl plasmoid"
|
||||
|
||||
#. i18n: file: configwindow.ui:30
|
||||
#. i18n: ectx: attribute (title), widget (QWidget, tabConfiguration)
|
||||
#: po/rc.cpp:3 rc.cpp:3
|
||||
msgid "Configuration"
|
||||
msgstr "Configuration"
|
||||
|
||||
#. i18n: file: configwindow.ui:54
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_autoUpdate)
|
||||
#: po/rc.cpp:6 rc.cpp:6
|
||||
msgid "Auto update interval, msec"
|
||||
msgstr "Auto update interval, msec"
|
||||
|
||||
#. i18n: file: configwindow.ui:112
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_gui)
|
||||
#: po/rc.cpp:9 rc.cpp:9
|
||||
msgid "Path to GUI"
|
||||
msgstr "Path to GUI"
|
||||
|
||||
#. i18n: file: configwindow.ui:128
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_gui)
|
||||
#. i18n: file: configwindow.ui:164
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_netctl)
|
||||
#. i18n: file: configwindow.ui:578
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_activeIcon)
|
||||
#. i18n: file: configwindow.ui:614
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_inactiveIcon)
|
||||
#. i18n: file: configwindow.ui:128
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_gui)
|
||||
#. i18n: file: configwindow.ui:164
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_netctl)
|
||||
#. i18n: file: configwindow.ui:578
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_activeIcon)
|
||||
#. i18n: file: configwindow.ui:614
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_inactiveIcon)
|
||||
#: po/rc.cpp:12 po/rc.cpp:18 po/rc.cpp:78 po/rc.cpp:84 rc.cpp:12 rc.cpp:18
|
||||
#: rc.cpp:78 rc.cpp:84
|
||||
msgid "Browse"
|
||||
msgstr "Browse"
|
||||
|
||||
#. i18n: file: configwindow.ui:148
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_netctl)
|
||||
#: po/rc.cpp:15 rc.cpp:15
|
||||
msgid "Path to netctl"
|
||||
msgstr "Path to netctl"
|
||||
|
||||
#. i18n: file: configwindow.ui:184
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_sudo)
|
||||
#: po/rc.cpp:21 rc.cpp:21
|
||||
msgid "Use sudo for netctl"
|
||||
msgstr "Use sudo for netctl"
|
||||
|
||||
#. i18n: file: configwindow.ui:199
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showBigInterface)
|
||||
#: po/rc.cpp:24 rc.cpp:24
|
||||
msgid "Show more detailed interface"
|
||||
msgstr "Show more detailed interface"
|
||||
|
||||
#. i18n: file: configwindow.ui:209
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showNetDev)
|
||||
#: po/rc.cpp:27 rc.cpp:27
|
||||
msgid "Show network devices"
|
||||
msgstr "Show network devices"
|
||||
|
||||
#. i18n: file: configwindow.ui:219
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showExtIp)
|
||||
#: po/rc.cpp:30 rc.cpp:30
|
||||
msgid "Show external IP"
|
||||
msgstr "Show external IP"
|
||||
|
||||
#. i18n: file: configwindow.ui:229
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showIntIp)
|
||||
#: po/rc.cpp:33 rc.cpp:33
|
||||
msgid "Show internal IP"
|
||||
msgstr "Show internal IP"
|
||||
|
||||
#. i18n: file: configwindow.ui:253
|
||||
#. i18n: ectx: attribute (title), widget (QWidget, tabAppearance)
|
||||
#: po/rc.cpp:36 rc.cpp:36
|
||||
msgid "Appearance"
|
||||
msgstr "Appearance"
|
||||
|
||||
#. i18n: file: configwindow.ui:267
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_font)
|
||||
#: po/rc.cpp:39 rc.cpp:39
|
||||
msgid "Font"
|
||||
msgstr "Font"
|
||||
|
||||
#. i18n: file: configwindow.ui:299
|
||||
#. i18n: ectx: property (toolTip), widget (QFontComboBox, fontComboBox_font)
|
||||
#: po/rc.cpp:42 rc.cpp:42
|
||||
msgid "Set font family"
|
||||
msgstr "Set font family"
|
||||
|
||||
#. i18n: file: configwindow.ui:316
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_fontSize)
|
||||
#: po/rc.cpp:45 rc.cpp:45
|
||||
msgid "Font size"
|
||||
msgstr "Font size"
|
||||
|
||||
#. i18n: file: configwindow.ui:348
|
||||
#. i18n: ectx: property (toolTip), widget (QSpinBox, spinBox_fontSize)
|
||||
#: po/rc.cpp:48 rc.cpp:48
|
||||
msgid "Set font size"
|
||||
msgstr "Set font size"
|
||||
|
||||
#. i18n: file: configwindow.ui:377
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_fontColor)
|
||||
#: po/rc.cpp:51 rc.cpp:51
|
||||
msgid "Font color"
|
||||
msgstr "Font color"
|
||||
|
||||
#. i18n: file: configwindow.ui:409
|
||||
#. i18n: ectx: property (toolTip), widget (KColorCombo, kcolorcombo_fontColor)
|
||||
#: po/rc.cpp:54 rc.cpp:54
|
||||
msgid "Set font color"
|
||||
msgstr "Set font color"
|
||||
|
||||
#. i18n: file: configwindow.ui:426
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_fontWeight)
|
||||
#: po/rc.cpp:57 rc.cpp:57
|
||||
msgid "Font weight"
|
||||
msgstr "Font weight"
|
||||
|
||||
#. i18n: file: configwindow.ui:458
|
||||
#. i18n: ectx: property (toolTip), widget (QSpinBox, spinBox_fontWeight)
|
||||
#: po/rc.cpp:60 rc.cpp:60
|
||||
msgid "Set font weight"
|
||||
msgstr "Set font weight"
|
||||
|
||||
#. i18n: file: configwindow.ui:490
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_fontStyle)
|
||||
#: po/rc.cpp:63 rc.cpp:63
|
||||
msgid "Font style"
|
||||
msgstr "Font style"
|
||||
|
||||
#. i18n: file: configwindow.ui:522
|
||||
#. i18n: ectx: property (toolTip), widget (QComboBox, comboBox_fontStyle)
|
||||
#: po/rc.cpp:66 rc.cpp:66
|
||||
msgid "Set font style"
|
||||
msgstr "Set font style"
|
||||
|
||||
#. i18n: file: configwindow.ui:526
|
||||
#. i18n: ectx: property (text), item, widget (QComboBox, comboBox_fontStyle)
|
||||
#: po/rc.cpp:69 rc.cpp:69
|
||||
msgid "normal"
|
||||
msgstr "normal"
|
||||
|
||||
#. i18n: file: configwindow.ui:531
|
||||
#. i18n: ectx: property (text), item, widget (QComboBox, comboBox_fontStyle)
|
||||
#: po/rc.cpp:72 rc.cpp:72
|
||||
msgid "italic"
|
||||
msgstr "italic"
|
||||
|
||||
#. i18n: file: configwindow.ui:562
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_activeIcon)
|
||||
#: po/rc.cpp:75 rc.cpp:75
|
||||
msgid "Active icon"
|
||||
msgstr "Active icon"
|
||||
|
||||
#. i18n: file: configwindow.ui:598
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_inactiveIcon)
|
||||
#: po/rc.cpp:81 rc.cpp:81
|
||||
msgid "Inactive icon"
|
||||
msgstr "Inactive icon"
|
||||
|
||||
#: po/rc.cpp:85 rc.cpp:85
|
||||
msgctxt "NAME OF TRANSLATORS"
|
||||
msgid "Your names"
|
||||
msgstr "Evgeniy Alekseev"
|
||||
|
||||
#: po/rc.cpp:86 rc.cpp:86
|
||||
msgctxt "EMAIL OF TRANSLATORS"
|
||||
msgid "Your emails"
|
||||
msgstr "esalexeev@gmail.com"
|
||||
|
81
sources/plasmoid/po/extract_messages.sh
Executable file
81
sources/plasmoid/po/extract_messages.sh
Executable file
@ -0,0 +1,81 @@
|
||||
#!/bin/sh
|
||||
BASEDIR="../" # root of translatable sources
|
||||
PROJECT="plasma_applet_netctl" # project name
|
||||
BUGADDR="http://kde-look.org/content/show.php?content=98925" # MSGID-Bugs
|
||||
WDIR=`pwd` # working dir
|
||||
SATELLITE_LIST=satellite.list
|
||||
BACKGROUND_LIST=background.list
|
||||
|
||||
add_list()
|
||||
{
|
||||
LIST=$1
|
||||
|
||||
if [ -z "$LIST" ]
|
||||
then
|
||||
echo ">>ERR<< add_list() - missing parameter LIST - exiting"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ -f "$LIST" ]
|
||||
then
|
||||
cat $LIST | while read ROW
|
||||
do
|
||||
echo "tr2i18n(\"${ROW}\")" >> ${WDIR}/rc.cpp
|
||||
done
|
||||
else
|
||||
echo ">>ERR<< add_list() - file $LIST does not exist."
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
echo "Preparing rc files"
|
||||
cd ${BASEDIR}
|
||||
# we use simple sorting to make sure the lines do not jump around too much from system to system
|
||||
find . -name '*.rc' -o -name '*.ui' -o -name '*.kcfg' | sort > ${WDIR}/rcfiles.list
|
||||
xargs --arg-file=${WDIR}/rcfiles.list extractrc > ${WDIR}/rc.cpp
|
||||
|
||||
# additional string for KAboutData
|
||||
echo 'i18nc("NAME OF TRANSLATORS","Your names");' >> ${WDIR}/rc.cpp
|
||||
echo 'i18nc("EMAIL OF TRANSLATORS","Your emails");' >> ${WDIR}/rc.cpp
|
||||
|
||||
cd ${WDIR}
|
||||
|
||||
# Add Satellite list
|
||||
add_list "$SATELLITE_LIST"
|
||||
|
||||
# Add Background list
|
||||
add_list "$BACKGROUND_LIST"
|
||||
|
||||
echo "Done preparing rc files"
|
||||
|
||||
|
||||
echo "Extracting messages"
|
||||
cd ${BASEDIR}
|
||||
# see above on sorting
|
||||
find . -name '*.cpp' -o -name '*.h' -o -name '*.c' | sort > ${WDIR}/infiles.list
|
||||
echo "rc.cpp" >> ${WDIR}/infiles.list
|
||||
cd ${WDIR}
|
||||
xgettext --from-code=UTF-8 -C -kde -ci18n -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 -ktr2i18n:1 \
|
||||
-kI18N_NOOP:1 -kI18N_NOOP2:1c,2 -kaliasLocale -kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 \
|
||||
--msgid-bugs-address="${BUGADDR}" \
|
||||
--files-from=infiles.list -D ${BASEDIR} -D ${WDIR} -o ${PROJECT}.pot || { echo "error while calling xgettext. aborting."; exit 1; }
|
||||
echo "Done extracting messages"
|
||||
|
||||
|
||||
echo "Merging translations"
|
||||
catalogs=`find . -name '*.po'`
|
||||
for cat in $catalogs; do
|
||||
echo $cat
|
||||
msgmerge -o $cat.new $cat ${PROJECT}.pot
|
||||
mv $cat.new $cat
|
||||
done
|
||||
echo "Done merging translations"
|
||||
|
||||
|
||||
echo "Cleaning up"
|
||||
cd ${WDIR}
|
||||
rm rcfiles.list
|
||||
rm infiles.list
|
||||
rm rc.cpp
|
||||
echo "Done"
|
||||
|
197
sources/plasmoid/po/plasma_applet_netctl.pot
Normal file
197
sources/plasmoid/po/plasma_applet_netctl.pot
Normal file
@ -0,0 +1,197 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: http://kde-look.org/content/show.php?content=98925\n"
|
||||
"POT-Creation-Date: 2014-03-25 10:52+0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=CHARSET\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: netctl.cpp:398
|
||||
msgid "Netctl plasmoid"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:30
|
||||
#. i18n: ectx: attribute (title), widget (QWidget, tabConfiguration)
|
||||
#: po/rc.cpp:3 rc.cpp:3
|
||||
msgid "Configuration"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:54
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_autoUpdate)
|
||||
#: po/rc.cpp:6 rc.cpp:6
|
||||
msgid "Auto update interval, msec"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:112
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_gui)
|
||||
#: po/rc.cpp:9 rc.cpp:9
|
||||
msgid "Path to GUI"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:128
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_gui)
|
||||
#. i18n: file: configwindow.ui:164
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_netctl)
|
||||
#. i18n: file: configwindow.ui:578
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_activeIcon)
|
||||
#. i18n: file: configwindow.ui:614
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_inactiveIcon)
|
||||
#. i18n: file: configwindow.ui:128
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_gui)
|
||||
#. i18n: file: configwindow.ui:164
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_netctl)
|
||||
#. i18n: file: configwindow.ui:578
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_activeIcon)
|
||||
#. i18n: file: configwindow.ui:614
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_inactiveIcon)
|
||||
#: po/rc.cpp:12 po/rc.cpp:18 po/rc.cpp:78 po/rc.cpp:84 rc.cpp:12 rc.cpp:18
|
||||
#: rc.cpp:78 rc.cpp:84
|
||||
msgid "Browse"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:148
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_netctl)
|
||||
#: po/rc.cpp:15 rc.cpp:15
|
||||
msgid "Path to netctl"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:184
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_sudo)
|
||||
#: po/rc.cpp:21 rc.cpp:21
|
||||
msgid "Use sudo for netctl"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:199
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showBigInterface)
|
||||
#: po/rc.cpp:24 rc.cpp:24
|
||||
msgid "Show more detailed interface"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:209
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showNetDev)
|
||||
#: po/rc.cpp:27 rc.cpp:27
|
||||
msgid "Show network devices"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:219
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showExtIp)
|
||||
#: po/rc.cpp:30 rc.cpp:30
|
||||
msgid "Show external IP"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:229
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showIntIp)
|
||||
#: po/rc.cpp:33 rc.cpp:33
|
||||
msgid "Show internal IP"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:253
|
||||
#. i18n: ectx: attribute (title), widget (QWidget, tabAppearance)
|
||||
#: po/rc.cpp:36 rc.cpp:36
|
||||
msgid "Appearance"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:267
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_font)
|
||||
#: po/rc.cpp:39 rc.cpp:39
|
||||
msgid "Font"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:299
|
||||
#. i18n: ectx: property (toolTip), widget (QFontComboBox, fontComboBox_font)
|
||||
#: po/rc.cpp:42 rc.cpp:42
|
||||
msgid "Set font family"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:316
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_fontSize)
|
||||
#: po/rc.cpp:45 rc.cpp:45
|
||||
msgid "Font size"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:348
|
||||
#. i18n: ectx: property (toolTip), widget (QSpinBox, spinBox_fontSize)
|
||||
#: po/rc.cpp:48 rc.cpp:48
|
||||
msgid "Set font size"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:377
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_fontColor)
|
||||
#: po/rc.cpp:51 rc.cpp:51
|
||||
msgid "Font color"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:409
|
||||
#. i18n: ectx: property (toolTip), widget (KColorCombo, kcolorcombo_fontColor)
|
||||
#: po/rc.cpp:54 rc.cpp:54
|
||||
msgid "Set font color"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:426
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_fontWeight)
|
||||
#: po/rc.cpp:57 rc.cpp:57
|
||||
msgid "Font weight"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:458
|
||||
#. i18n: ectx: property (toolTip), widget (QSpinBox, spinBox_fontWeight)
|
||||
#: po/rc.cpp:60 rc.cpp:60
|
||||
msgid "Set font weight"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:490
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_fontStyle)
|
||||
#: po/rc.cpp:63 rc.cpp:63
|
||||
msgid "Font style"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:522
|
||||
#. i18n: ectx: property (toolTip), widget (QComboBox, comboBox_fontStyle)
|
||||
#: po/rc.cpp:66 rc.cpp:66
|
||||
msgid "Set font style"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:526
|
||||
#. i18n: ectx: property (text), item, widget (QComboBox, comboBox_fontStyle)
|
||||
#: po/rc.cpp:69 rc.cpp:69
|
||||
msgid "normal"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:531
|
||||
#. i18n: ectx: property (text), item, widget (QComboBox, comboBox_fontStyle)
|
||||
#: po/rc.cpp:72 rc.cpp:72
|
||||
msgid "italic"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:562
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_activeIcon)
|
||||
#: po/rc.cpp:75 rc.cpp:75
|
||||
msgid "Active icon"
|
||||
msgstr ""
|
||||
|
||||
#. i18n: file: configwindow.ui:598
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_inactiveIcon)
|
||||
#: po/rc.cpp:81 rc.cpp:81
|
||||
msgid "Inactive icon"
|
||||
msgstr ""
|
||||
|
||||
#: po/rc.cpp:85 rc.cpp:85
|
||||
msgctxt "NAME OF TRANSLATORS"
|
||||
msgid "Your names"
|
||||
msgstr ""
|
||||
|
||||
#: po/rc.cpp:86 rc.cpp:86
|
||||
msgctxt "EMAIL OF TRANSLATORS"
|
||||
msgid "Your emails"
|
||||
msgstr ""
|
200
sources/plasmoid/po/ru.po
Normal file
200
sources/plasmoid/po/ru.po
Normal file
@ -0,0 +1,200 @@
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
#
|
||||
# Evgeniy Alekseev <esalexeev@gmail.com>, 2014.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: http://kde-look.org/content/show.php?content=98925\n"
|
||||
"POT-Creation-Date: 2014-03-25 10:52+0400\n"
|
||||
"PO-Revision-Date: 2014-03-25 10:58+0400\n"
|
||||
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
|
||||
"Language-Team: Russian <kde-russian@lists.kde.ru>\n"
|
||||
"Language: ru\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<"
|
||||
"=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
|
||||
"X-Generator: Lokalize 1.5\n"
|
||||
|
||||
#: netctl.cpp:398
|
||||
msgid "Netctl plasmoid"
|
||||
msgstr "Netctl plasmoid"
|
||||
|
||||
#. i18n: file: configwindow.ui:30
|
||||
#. i18n: ectx: attribute (title), widget (QWidget, tabConfiguration)
|
||||
#: po/rc.cpp:3 rc.cpp:3
|
||||
msgid "Configuration"
|
||||
msgstr "Настройка"
|
||||
|
||||
#. i18n: file: configwindow.ui:54
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_autoUpdate)
|
||||
#: po/rc.cpp:6 rc.cpp:6
|
||||
msgid "Auto update interval, msec"
|
||||
msgstr "Интервал автообновления, мсек"
|
||||
|
||||
#. i18n: file: configwindow.ui:112
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_gui)
|
||||
#: po/rc.cpp:9 rc.cpp:9
|
||||
msgid "Path to GUI"
|
||||
msgstr "Путь к GUI"
|
||||
|
||||
#. i18n: file: configwindow.ui:128
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_gui)
|
||||
#. i18n: file: configwindow.ui:164
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_netctl)
|
||||
#. i18n: file: configwindow.ui:578
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_activeIcon)
|
||||
#. i18n: file: configwindow.ui:614
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_inactiveIcon)
|
||||
#. i18n: file: configwindow.ui:128
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_gui)
|
||||
#. i18n: file: configwindow.ui:164
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_netctl)
|
||||
#. i18n: file: configwindow.ui:578
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_activeIcon)
|
||||
#. i18n: file: configwindow.ui:614
|
||||
#. i18n: ectx: property (text), widget (QPushButton, pushButton_inactiveIcon)
|
||||
#: po/rc.cpp:12 po/rc.cpp:18 po/rc.cpp:78 po/rc.cpp:84 rc.cpp:12 rc.cpp:18
|
||||
#: rc.cpp:78 rc.cpp:84
|
||||
msgid "Browse"
|
||||
msgstr "Обзор"
|
||||
|
||||
#. i18n: file: configwindow.ui:148
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_netctl)
|
||||
#: po/rc.cpp:15 rc.cpp:15
|
||||
msgid "Path to netctl"
|
||||
msgstr "Путь к netctl"
|
||||
|
||||
#. i18n: file: configwindow.ui:184
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_sudo)
|
||||
#: po/rc.cpp:21 rc.cpp:21
|
||||
msgid "Use sudo for netctl"
|
||||
msgstr "Использовать sudo для netctl"
|
||||
|
||||
#. i18n: file: configwindow.ui:199
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showBigInterface)
|
||||
#: po/rc.cpp:24 rc.cpp:24
|
||||
msgid "Show more detailed interface"
|
||||
msgstr "Показать более детальный интерфейс"
|
||||
|
||||
#. i18n: file: configwindow.ui:209
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showNetDev)
|
||||
#: po/rc.cpp:27 rc.cpp:27
|
||||
msgid "Show network devices"
|
||||
msgstr "Показать сетевые устройства"
|
||||
|
||||
#. i18n: file: configwindow.ui:219
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showExtIp)
|
||||
#: po/rc.cpp:30 rc.cpp:30
|
||||
msgid "Show external IP"
|
||||
msgstr "Показать внешний IP"
|
||||
|
||||
#. i18n: file: configwindow.ui:229
|
||||
#. i18n: ectx: property (text), widget (QCheckBox, checkBox_showIntIp)
|
||||
#: po/rc.cpp:33 rc.cpp:33
|
||||
msgid "Show internal IP"
|
||||
msgstr "Показать внутренний IP"
|
||||
|
||||
#. i18n: file: configwindow.ui:253
|
||||
#. i18n: ectx: attribute (title), widget (QWidget, tabAppearance)
|
||||
#: po/rc.cpp:36 rc.cpp:36
|
||||
msgid "Appearance"
|
||||
msgstr "Внешний вид"
|
||||
|
||||
#. i18n: file: configwindow.ui:267
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_font)
|
||||
#: po/rc.cpp:39 rc.cpp:39
|
||||
msgid "Font"
|
||||
msgstr "Шрифт"
|
||||
|
||||
#. i18n: file: configwindow.ui:299
|
||||
#. i18n: ectx: property (toolTip), widget (QFontComboBox, fontComboBox_font)
|
||||
#: po/rc.cpp:42 rc.cpp:42
|
||||
msgid "Set font family"
|
||||
msgstr "Укажите шрифт"
|
||||
|
||||
#. i18n: file: configwindow.ui:316
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_fontSize)
|
||||
#: po/rc.cpp:45 rc.cpp:45
|
||||
msgid "Font size"
|
||||
msgstr "Размер шрифта"
|
||||
|
||||
#. i18n: file: configwindow.ui:348
|
||||
#. i18n: ectx: property (toolTip), widget (QSpinBox, spinBox_fontSize)
|
||||
#: po/rc.cpp:48 rc.cpp:48
|
||||
msgid "Set font size"
|
||||
msgstr "Укажите размер шрифта"
|
||||
|
||||
#. i18n: file: configwindow.ui:377
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_fontColor)
|
||||
#: po/rc.cpp:51 rc.cpp:51
|
||||
msgid "Font color"
|
||||
msgstr "Цвет шрифта"
|
||||
|
||||
#. i18n: file: configwindow.ui:409
|
||||
#. i18n: ectx: property (toolTip), widget (KColorCombo, kcolorcombo_fontColor)
|
||||
#: po/rc.cpp:54 rc.cpp:54
|
||||
msgid "Set font color"
|
||||
msgstr "Укажите цвет шрифта"
|
||||
|
||||
#. i18n: file: configwindow.ui:426
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_fontWeight)
|
||||
#: po/rc.cpp:57 rc.cpp:57
|
||||
msgid "Font weight"
|
||||
msgstr "Толщина шрифта"
|
||||
|
||||
#. i18n: file: configwindow.ui:458
|
||||
#. i18n: ectx: property (toolTip), widget (QSpinBox, spinBox_fontWeight)
|
||||
#: po/rc.cpp:60 rc.cpp:60
|
||||
msgid "Set font weight"
|
||||
msgstr "Укажите ширину шрифта"
|
||||
|
||||
#. i18n: file: configwindow.ui:490
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_fontStyle)
|
||||
#: po/rc.cpp:63 rc.cpp:63
|
||||
msgid "Font style"
|
||||
msgstr "Стиль шрифта"
|
||||
|
||||
#. i18n: file: configwindow.ui:522
|
||||
#. i18n: ectx: property (toolTip), widget (QComboBox, comboBox_fontStyle)
|
||||
#: po/rc.cpp:66 rc.cpp:66
|
||||
msgid "Set font style"
|
||||
msgstr "Укажите стиль шрифта"
|
||||
|
||||
#. i18n: file: configwindow.ui:526
|
||||
#. i18n: ectx: property (text), item, widget (QComboBox, comboBox_fontStyle)
|
||||
#: po/rc.cpp:69 rc.cpp:69
|
||||
msgid "normal"
|
||||
msgstr "normal"
|
||||
|
||||
#. i18n: file: configwindow.ui:531
|
||||
#. i18n: ectx: property (text), item, widget (QComboBox, comboBox_fontStyle)
|
||||
#: po/rc.cpp:72 rc.cpp:72
|
||||
msgid "italic"
|
||||
msgstr "italic"
|
||||
|
||||
#. i18n: file: configwindow.ui:562
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_activeIcon)
|
||||
#: po/rc.cpp:75 rc.cpp:75
|
||||
msgid "Active icon"
|
||||
msgstr "Иконка активного подключения"
|
||||
|
||||
#. i18n: file: configwindow.ui:598
|
||||
#. i18n: ectx: property (text), widget (QLabel, label_inactiveIcon)
|
||||
#: po/rc.cpp:81 rc.cpp:81
|
||||
msgid "Inactive icon"
|
||||
msgstr "Иконка неактивного подключения"
|
||||
|
||||
#: po/rc.cpp:85 rc.cpp:85
|
||||
msgctxt "NAME OF TRANSLATORS"
|
||||
msgid "Your names"
|
||||
msgstr "Evgeniy Alekseev"
|
||||
|
||||
#: po/rc.cpp:86 rc.cpp:86
|
||||
msgctxt "EMAIL OF TRANSLATORS"
|
||||
msgid "Your emails"
|
||||
msgstr "esalexeev@gmail.com"
|
||||
|
||||
|
0
sources/plasmoid/po/satellite.list
Normal file
0
sources/plasmoid/po/satellite.list
Normal file
Reference in New Issue
Block a user