mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
* add info instrument * implement needToBeConfigured() slot, see #29 * fix (#30) some improvements
This commit is contained in:
parent
9033c51bb4
commit
a73968f98b
4
.gitignore
vendored
4
.gitignore
vendored
@ -27,7 +27,3 @@ usr/
|
|||||||
|
|
||||||
# temporary bckps
|
# temporary bckps
|
||||||
*~
|
*~
|
||||||
|
|
||||||
# kdevelop files
|
|
||||||
.kdev4
|
|
||||||
*.kdev4
|
|
||||||
|
@ -9,7 +9,7 @@ pkgdesc="Qt4/Qt5 GUI for netctl. Also provides a widget for KDE"
|
|||||||
arch=('i686' 'x86_64')
|
arch=('i686' 'x86_64')
|
||||||
url="http://arcanis.name/projects/netctl-gui"
|
url="http://arcanis.name/projects/netctl-gui"
|
||||||
license=('GPL3')
|
license=('GPL3')
|
||||||
makedepends=('automoc4' 'cmake' 'extra-cmake-modules' 'plasma-framework' 'qt5-tools')
|
makedepends=('cmake' 'extra-cmake-modules' 'plasma-framework' 'qt5-tools')
|
||||||
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgbase}-${pkgver}-src.tar.xz")
|
||||||
md5sums=('172fff4b59c15c991b016db35971eca1')
|
md5sums=('172fff4b59c15c991b016db35971eca1')
|
||||||
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ARCHIVE="netctl-gui"
|
|
||||||
SRCDIR="sources"
|
SRCDIR="sources"
|
||||||
|
MAJOR=$(grep -m1 PROJECT_VERSION_MAJOR ${SRCDIR}/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
||||||
|
MINOR=$(grep -m1 PROJECT_VERSION_MINOR ${SRCDIR}/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
||||||
|
PATCH=$(grep -m1 PROJECT_VERSION_PATCH ${SRCDIR}/CMakeLists.txt | awk '{print $3}' | sed 's/.$//g')
|
||||||
|
VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
||||||
|
|
||||||
|
ARCHIVE="netctl-gui"
|
||||||
FILES="AUTHORS CHANGELOG COPYING README.md"
|
FILES="AUTHORS CHANGELOG COPYING README.md"
|
||||||
IGNORELIST="build *.qm *.cppcheck .git*"
|
IGNORELIST="build *.qm *.cppcheck .git* .kdev4 sources.kdev4"
|
||||||
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)
|
|
||||||
# update submodules
|
# update submodules
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
# create archive
|
# create archive
|
||||||
@ -18,6 +20,7 @@ for FILE in ${IGNORELIST[*]}; do find "${ARCHIVE}" -name "${FILE}" -exec rm -rf
|
|||||||
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
|
tar cJf "${ARCHIVE}-${VERSION}-src.tar.xz" "${ARCHIVE}"
|
||||||
ln -sf "../${ARCHIVE}-${VERSION}-src.tar.xz" arch
|
ln -sf "../${ARCHIVE}-${VERSION}-src.tar.xz" arch
|
||||||
rm -rf "${ARCHIVE}"
|
rm -rf "${ARCHIVE}"
|
||||||
|
|
||||||
# update md5sum
|
# update md5sum
|
||||||
MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
|
MD5SUMS=$(md5sum ${ARCHIVE}-${VERSION}-src.tar.xz | awk '{print $1}')
|
||||||
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" arch/PKGBUILD{,-qt4}
|
sed -i "/md5sums=('[0-9A-Fa-f]*/s/[^'][^)]*/md5sums=('${MD5SUMS}'/" arch/PKGBUILD{,-qt4}
|
||||||
|
23
sources/.kdev4/sources.kdev4
Normal file
23
sources/.kdev4/sources.kdev4
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
[Buildset]
|
||||||
|
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x14\x00n\x00e\x00t\x00c\x00t\x00l\x00-\x00g\x00u\x00i)
|
||||||
|
|
||||||
|
[CMake]
|
||||||
|
Build Directory Count=1
|
||||||
|
Current Build Directory Index=0
|
||||||
|
ProjectRootRelative=./
|
||||||
|
|
||||||
|
[CMake][CMake Build Directory 0]
|
||||||
|
Build Directory Path=file:///home/arcanis/Documents/github/netctl-gui/build
|
||||||
|
Build Type=Debug
|
||||||
|
CMake Binary=file:///usr/bin/cmake
|
||||||
|
Environment Profile=
|
||||||
|
Extra Arguments=
|
||||||
|
Install Directory=file:///usr
|
||||||
|
|
||||||
|
[Defines And Includes][Compiler]
|
||||||
|
Name=GCC
|
||||||
|
Path=gcc
|
||||||
|
Type=GCC
|
||||||
|
|
||||||
|
[Project]
|
||||||
|
VersionControlSupport=kdevgit
|
@ -47,10 +47,7 @@ Netctl::Netctl(QObject *parent, const QVariantList &args)
|
|||||||
// debug
|
// debug
|
||||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||||
if (debugEnv == QString("yes"))
|
debug = (debugEnv == QString("yes"));
|
||||||
debug = true;
|
|
||||||
else
|
|
||||||
debug = false;
|
|
||||||
|
|
||||||
setMinimumPollingInterval(333);
|
setMinimumPollingInterval(333);
|
||||||
readConfiguration();
|
readConfiguration();
|
||||||
@ -73,6 +70,7 @@ QStringList Netctl::sources() const
|
|||||||
sources.append(QString("current"));
|
sources.append(QString("current"));
|
||||||
sources.append(QString("extip4"));
|
sources.append(QString("extip4"));
|
||||||
sources.append(QString("extip6"));
|
sources.append(QString("extip6"));
|
||||||
|
sources.append(QString("info"));
|
||||||
sources.append(QString("interfaces"));
|
sources.append(QString("interfaces"));
|
||||||
sources.append(QString("intip4"));
|
sources.append(QString("intip4"));
|
||||||
sources.append(QString("intip6"));
|
sources.append(QString("intip6"));
|
||||||
@ -96,18 +94,18 @@ void Netctl::readConfiguration()
|
|||||||
#endif /* BUILD_KDE4 */
|
#endif /* BUILD_KDE4 */
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
if (debug) qDebug() << PDEBUG << ":" << "Configuration file" << fileName;
|
||||||
QSettings settings(fileName, QSettings::IniFormat);
|
QSettings settings(fileName, QSettings::IniFormat);
|
||||||
|
|
||||||
settings.beginGroup(QString("Netctl commands"));
|
settings.beginGroup(QString("Netctl commands"));
|
||||||
configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("/usr/bin/netctl")).toString();
|
configuration[QString("NETCTLCMD")] = settings.value(QString("NETCTLCMD"), QString("/usr/bin/netctl")).toString();
|
||||||
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("/usr/bin/netctl-auto")).toString();
|
configuration[QString("NETCTLAUTOCMD")] = settings.value(QString("NETCTLAUTOCMD"), QString("/usr/bin/netctl-auto")).toString();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
settings.beginGroup(QString("External IP"));
|
settings.beginGroup(QString("External IP"));
|
||||||
configuration[QString("EXTIP4")] = settings.value(QString("EXTIP4"), QString("false")).toString();
|
configuration[QString("EXTIP4")] = settings.value(QString("EXTIP4"), QString("false")).toString();
|
||||||
configuration[QString("EXTIP4CMD")] = settings.value(QString("EXTIP4CMD"), QString("curl ip4.telize.com")).toString();
|
configuration[QString("EXTIP4CMD")] = settings.value(QString("EXTIP4CMD"), QString("curl ip4.telize.com")).toString();
|
||||||
configuration[QString("EXTIP6")] = settings.value(QString("EXTIP6"), QString("false")).toString();
|
configuration[QString("EXTIP6")] = settings.value(QString("EXTIP6"), QString("false")).toString();
|
||||||
configuration[QString("EXTIP6CMD")] = settings.value(QString("EXTIP6CMD"), QString("curl ip6.telize.com")).toString();
|
configuration[QString("EXTIP6CMD")] = settings.value(QString("EXTIP6CMD"), QString("curl ip6.telize.com")).toString();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -138,9 +136,10 @@ QStringList Netctl::getCurrentProfile(const QString cmdNetctl, const QString cmd
|
|||||||
QStringList currentProfile;
|
QStringList currentProfile;
|
||||||
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(process.output);
|
||||||
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
|
QStringList profileList = cmdOutput.split(QChar('\n'), QString::SkipEmptyParts);
|
||||||
for (int i=0; i<profileList.count(); i++)
|
for (int i=0; i<profileList.count(); i++) {
|
||||||
if (profileList[i][0] == QChar('*'))
|
if (profileList[i][0] != QChar('*')) continue;
|
||||||
currentProfile.append(profileList[i]);
|
currentProfile.append(profileList[i]);
|
||||||
|
}
|
||||||
for (int i=0; i<currentProfile.count(); i++)
|
for (int i=0; i<currentProfile.count(); i++)
|
||||||
currentProfile[i].remove(0, 2);
|
currentProfile[i].remove(0, 2);
|
||||||
|
|
||||||
@ -165,6 +164,20 @@ QString Netctl::getExtIp(const QString cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString Netctl::getInfo()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (current.split(QChar('|')).count() != status.split(QChar('|')).count()) return QString("N\\A");
|
||||||
|
|
||||||
|
QStringList profiles;
|
||||||
|
for (int i=0; i<current.split(QChar('|')).count(); i++)
|
||||||
|
profiles.append(QString("%1 (%2)").arg(current.split(QChar('|'))[i]).arg(status.split(QChar('|'))[i]));
|
||||||
|
if (profiles.isEmpty()) profiles.append(QString("N\\A"));
|
||||||
|
|
||||||
|
return profiles.join(QString(" | "));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList Netctl::getInterfaceList()
|
QStringList Netctl::getInterfaceList()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@ -191,11 +204,10 @@ QString Netctl::getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol)
|
|||||||
for (int i=0; i<rawList.count(); i++) {
|
for (int i=0; i<rawList.count(); i++) {
|
||||||
if(rawList[i] == QHostAddress(QHostAddress::LocalHost)) continue;
|
if(rawList[i] == QHostAddress(QHostAddress::LocalHost)) continue;
|
||||||
if(rawList[i] == QHostAddress(QHostAddress::LocalHostIPv6)) continue;
|
if(rawList[i] == QHostAddress(QHostAddress::LocalHostIPv6)) continue;
|
||||||
if (rawList[i].protocol() == protocol) {
|
if (rawList[i].protocol() != protocol) continue;
|
||||||
intIp = rawList[i].toString();
|
intIp = rawList[i].toString();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return intIp;
|
return intIp;
|
||||||
}
|
}
|
||||||
@ -306,10 +318,7 @@ bool Netctl::isNetworkActive()
|
|||||||
TaskResult process = runTask(cmd);
|
TaskResult process = runTask(cmd);
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
if (debug) qDebug() << PDEBUG << ":" << "Cmd returns" << process.exitCode;
|
||||||
|
|
||||||
if (process.exitCode == 0)
|
return (process.exitCode == 0);
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -326,12 +335,15 @@ bool Netctl::updateSourceEvent(const QString &source)
|
|||||||
value = getCurrentProfile(configuration[QString("NETCTLCMD")],
|
value = getCurrentProfile(configuration[QString("NETCTLCMD")],
|
||||||
configuration[QString("NETCTLAUTOCMD")])
|
configuration[QString("NETCTLAUTOCMD")])
|
||||||
.join(QChar('|'));
|
.join(QChar('|'));
|
||||||
|
current = value;
|
||||||
} else if (source == QString("extip4")) {
|
} else if (source == QString("extip4")) {
|
||||||
if (configuration[QString("EXTIP4")] == QString("true"))
|
if (configuration[QString("EXTIP4")] == QString("true"))
|
||||||
value = getExtIp(configuration[QString("EXTIP4CMD")]);
|
value = getExtIp(configuration[QString("EXTIP4CMD")]);
|
||||||
} else if (source == QString("extip6")) {
|
} else if (source == QString("extip6")) {
|
||||||
if (configuration[QString("EXTIP6")] == QString("true"))
|
if (configuration[QString("EXTIP6")] == QString("true"))
|
||||||
value = getExtIp(configuration[QString("EXTIP6CMD")]);
|
value = getExtIp(configuration[QString("EXTIP6CMD")]);
|
||||||
|
} else if (source == QString("info")) {
|
||||||
|
value = getInfo();
|
||||||
} else if (source == QString("interfaces")) {
|
} else if (source == QString("interfaces")) {
|
||||||
value = getInterfaceList().join(QChar(','));
|
value = getInterfaceList().join(QChar(','));
|
||||||
} else if (source == QString("intip4")) {
|
} else if (source == QString("intip4")) {
|
||||||
@ -348,6 +360,7 @@ bool Netctl::updateSourceEvent(const QString &source)
|
|||||||
value = getProfileStringStatus(configuration[QString("NETCTLCMD")],
|
value = getProfileStringStatus(configuration[QString("NETCTLCMD")],
|
||||||
configuration[QString("NETCTLAUTOCMD")])
|
configuration[QString("NETCTLAUTOCMD")])
|
||||||
.join(QChar('|'));
|
.join(QChar('|'));
|
||||||
|
status = value;
|
||||||
}
|
}
|
||||||
setData(source, QString("value"), value);
|
setData(source, QString("value"), value);
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ public:
|
|||||||
~Netctl();
|
~Netctl();
|
||||||
QStringList getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto);
|
QStringList getCurrentProfile(const QString cmdNetctl, const QString cmdNetctlAuto);
|
||||||
QString getExtIp(const QString cmd);
|
QString getExtIp(const QString cmd);
|
||||||
|
QString getInfo();
|
||||||
QStringList getInterfaceList();
|
QStringList getInterfaceList();
|
||||||
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol);
|
QString getIntIp(const QAbstractSocket::NetworkLayerProtocol protocol);
|
||||||
QString getNetctlAutoStatus(const QString cmdNetctlAuto);
|
QString getNetctlAutoStatus(const QString cmdNetctlAuto);
|
||||||
@ -52,6 +53,8 @@ private:
|
|||||||
QString currentProfile;
|
QString currentProfile;
|
||||||
// configuration
|
// configuration
|
||||||
bool debug;
|
bool debug;
|
||||||
|
QString current = QString("");
|
||||||
|
QString status = QString("");
|
||||||
QMap<QString, QString> configuration;
|
QMap<QString, QString> configuration;
|
||||||
void readConfiguration();
|
void readConfiguration();
|
||||||
};
|
};
|
||||||
|
@ -196,5 +196,4 @@ void ErrorWindow::showWindow(const int mess, const QString sender, const QString
|
|||||||
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
|
layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, layout->columnCount());
|
||||||
|
|
||||||
messageBox.exec();
|
messageBox.exec();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
@ -186,8 +186,11 @@ void MainWindow::updateToolBars()
|
|||||||
void MainWindow::updateMainTab()
|
void MainWindow::updateMainTab()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (!checkExternalApps(QString("netctl")))
|
if (!checkExternalApps(QString("netctl"))) {
|
||||||
return errorWin->showWindow(1, QString(PDEBUG));
|
errorWin->showWindow(1, QString(PDEBUG));
|
||||||
|
emit(needToBeConfigured());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
QList<netctlProfileInfo> profiles;
|
QList<netctlProfileInfo> profiles;
|
||||||
@ -281,8 +284,11 @@ void MainWindow::updateWifiTab()
|
|||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
wifiTabSetEnabled(checkExternalApps(QString("wpasup")));
|
wifiTabSetEnabled(checkExternalApps(QString("wpasup")));
|
||||||
if (!checkExternalApps(QString("wpasup")))
|
if (!checkExternalApps(QString("wpasup"))) {
|
||||||
return errorWin->showWindow(1, QString(PDEBUG));
|
errorWin->showWindow(1, QString(PDEBUG));
|
||||||
|
emit(needToBeConfigured());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
QList<netctlWifiInfo> scanResults;
|
QList<netctlWifiInfo> scanResults;
|
||||||
@ -436,8 +442,11 @@ void MainWindow::mainTabEditProfile()
|
|||||||
void MainWindow::mainTabEnableProfile()
|
void MainWindow::mainTabEnableProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (!checkExternalApps(QString("netctl")))
|
if (!checkExternalApps(QString("netctl"))) {
|
||||||
return errorWin->showWindow(1, QString(PDEBUG));
|
errorWin->showWindow(1, QString(PDEBUG));
|
||||||
|
emit(needToBeConfigured());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ui->tableWidget_main->currentItem() == 0) return;
|
if (ui->tableWidget_main->currentItem() == 0) return;
|
||||||
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
@ -493,8 +502,11 @@ void MainWindow::mainTabRemoveProfile()
|
|||||||
void MainWindow::mainTabRestartProfile()
|
void MainWindow::mainTabRestartProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (!checkExternalApps(QString("netctl")))
|
if (!checkExternalApps(QString("netctl"))) {
|
||||||
return errorWin->showWindow(1, QString(PDEBUG));
|
errorWin->showWindow(1, QString(PDEBUG));
|
||||||
|
emit(needToBeConfigured());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ui->tableWidget_main->currentItem() == 0) return;
|
if (ui->tableWidget_main->currentItem() == 0) return;
|
||||||
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
@ -512,8 +524,11 @@ void MainWindow::mainTabRestartProfile()
|
|||||||
void MainWindow::mainTabStartProfile()
|
void MainWindow::mainTabStartProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (!checkExternalApps(QString("netctl")))
|
if (!checkExternalApps(QString("netctl"))) {
|
||||||
return errorWin->showWindow(1, QString(PDEBUG));
|
errorWin->showWindow(1, QString(PDEBUG));
|
||||||
|
emit(needToBeConfigured());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ui->tableWidget_main->currentItem() == 0) return;
|
if (ui->tableWidget_main->currentItem() == 0) return;
|
||||||
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
@ -532,8 +547,11 @@ void MainWindow::mainTabStartProfile()
|
|||||||
void MainWindow::mainTabStopAllProfiles()
|
void MainWindow::mainTabStopAllProfiles()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (!checkExternalApps(QString("netctl")))
|
if (!checkExternalApps(QString("netctl"))) {
|
||||||
return errorWin->showWindow(1, QString(PDEBUG));
|
errorWin->showWindow(1, QString(PDEBUG));
|
||||||
|
emit(needToBeConfigured());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
bool status;
|
bool status;
|
||||||
@ -555,8 +573,11 @@ void MainWindow::mainTabStopAllProfiles()
|
|||||||
void MainWindow::mainTabSwitchToProfile()
|
void MainWindow::mainTabSwitchToProfile()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (!checkExternalApps(QString("netctl")))
|
if (!checkExternalApps(QString("netctl"))) {
|
||||||
return errorWin->showWindow(1, QString(PDEBUG));
|
errorWin->showWindow(1, QString(PDEBUG));
|
||||||
|
emit(needToBeConfigured());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ui->tableWidget_main->currentItem() == 0) return;
|
if (ui->tableWidget_main->currentItem() == 0) return;
|
||||||
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
@ -1056,8 +1077,11 @@ void MainWindow::wifiTabSetEnabled(const bool state)
|
|||||||
void MainWindow::wifiTabStart()
|
void MainWindow::wifiTabStart()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (!checkExternalApps(QString("wpasup")))
|
if (!checkExternalApps(QString("wpasup"))) {
|
||||||
return errorWin->showWindow(1, QString(PDEBUG));
|
errorWin->showWindow(1, QString(PDEBUG));
|
||||||
|
emit(needToBeConfigured());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (ui->tableWidget_wifi->currentItem() == 0) return;
|
if (ui->tableWidget_wifi->currentItem() == 0) return;
|
||||||
|
|
||||||
ui->tabWidget->setDisabled(true);
|
ui->tabWidget->setDisabled(true);
|
||||||
|
@ -268,6 +268,7 @@ bool MainWindow::forceStartHelper()
|
|||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (!checkExternalApps(QString("helper"))) {
|
if (!checkExternalApps(QString("helper"))) {
|
||||||
errorWin->showWindow(1, QString(PDEBUG));
|
errorWin->showWindow(1, QString(PDEBUG));
|
||||||
|
emit(needToBeConfigured());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,18 +278,23 @@ bool MainWindow::checkExternalApps(const QString apps = QString("all"))
|
|||||||
if (configuration[QString("SKIPCOMPONENTS")] == QString("true")) return true;
|
if (configuration[QString("SKIPCOMPONENTS")] == QString("true")) return true;
|
||||||
QStringList cmd;
|
QStringList cmd;
|
||||||
cmd.append("which");
|
cmd.append("which");
|
||||||
cmd.append(configuration[QString("SUDO_PATH")]);
|
|
||||||
if ((apps == QString("helper")) || (apps == QString("all"))) {
|
if ((apps == QString("helper")) || (apps == QString("all"))) {
|
||||||
cmd.append(configuration[QString("HELPER_PATH")]);
|
cmd.append(configuration[QString("HELPER_PATH")]);
|
||||||
}
|
}
|
||||||
if ((apps == QString("netctl")) || (apps == QString("all"))) {
|
if ((apps == QString("netctl")) || (apps == QString("all"))) {
|
||||||
cmd.append(configuration[QString("NETCTL_PATH")]);
|
cmd.append(configuration[QString("NETCTL_PATH")]);
|
||||||
cmd.append(configuration[QString("NETCTLAUTO_PATH")]);
|
cmd.append(configuration[QString("NETCTLAUTO_PATH")]);
|
||||||
|
cmd.append(configuration[QString("SUDO_PATH")]);
|
||||||
|
}
|
||||||
|
if ((apps == QString("sudo")) || (apps == QString("all"))) {
|
||||||
|
cmd.append(configuration[QString("SUDO_PATH")]);
|
||||||
}
|
}
|
||||||
if ((apps == QString("systemctl")) || (apps == QString("all"))) {
|
if ((apps == QString("systemctl")) || (apps == QString("all"))) {
|
||||||
cmd.append(configuration[QString("SYSTEMCTL_PATH")]);
|
cmd.append(configuration[QString("SYSTEMCTL_PATH")]);
|
||||||
|
cmd.append(configuration[QString("SUDO_PATH")]);
|
||||||
}
|
}
|
||||||
if ((apps == QString("wpasup")) || (apps == QString("all"))) {
|
if ((apps == QString("wpasup")) || (apps == QString("all"))) {
|
||||||
|
cmd.append(configuration[QString("SUDO_PATH")]);
|
||||||
cmd.append(configuration[QString("WPACLI_PATH")]);
|
cmd.append(configuration[QString("WPACLI_PATH")]);
|
||||||
cmd.append(configuration[QString("WPASUP_PATH")]);
|
cmd.append(configuration[QString("WPASUP_PATH")]);
|
||||||
}
|
}
|
||||||
@ -349,6 +354,7 @@ void MainWindow::createActions()
|
|||||||
connect(ui->pushButton_menu, SIGNAL(clicked(bool)), this, SLOT(updateToolBars()));
|
connect(ui->pushButton_menu, SIGNAL(clicked(bool)), this, SLOT(updateToolBars()));
|
||||||
connect(ui->pushButton_action, SIGNAL(clicked(bool)), this, SLOT(updateToolBars()));
|
connect(ui->pushButton_action, SIGNAL(clicked(bool)), this, SLOT(updateToolBars()));
|
||||||
connect(ui->pushButton_help, SIGNAL(clicked(bool)), this, SLOT(updateToolBars()));
|
connect(ui->pushButton_help, SIGNAL(clicked(bool)), this, SLOT(updateToolBars()));
|
||||||
|
connect(this, SIGNAL(needToBeConfigured()), this, SLOT(showSettingsWindow()));
|
||||||
|
|
||||||
// main tab events
|
// main tab events
|
||||||
connect(ui->pushButton_netctlAuto, SIGNAL(clicked(bool)), this, SLOT(showNetctlAutoWindow()));
|
connect(ui->pushButton_netctlAuto, SIGNAL(clicked(bool)), this, SLOT(showNetctlAutoWindow()));
|
||||||
|
@ -99,6 +99,9 @@ public slots:
|
|||||||
void connectToUnknownEssid(const QString passwd);
|
void connectToUnknownEssid(const QString passwd);
|
||||||
void setHiddenName(const QString name);
|
void setHiddenName(const QString name);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void needToBeConfigured();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void reportABug();
|
void reportABug();
|
||||||
// menu update slots
|
// menu update slots
|
||||||
|
@ -68,10 +68,7 @@ Netctl::Netctl(QObject *parent, const QVariantList &args)
|
|||||||
// debug
|
// debug
|
||||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||||
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
QString debugEnv = environment.value(QString("DEBUG"), QString("no"));
|
||||||
if (debugEnv == QString("yes"))
|
debug = (debugEnv == QString("yes"));
|
||||||
debug = true;
|
|
||||||
else
|
|
||||||
debug = false;
|
|
||||||
|
|
||||||
setBackgroundHints(DefaultBackground);
|
setBackgroundHints(DefaultBackground);
|
||||||
setAspectRatioMode(Plasma::IgnoreAspectRatio);
|
setAspectRatioMode(Plasma::IgnoreAspectRatio);
|
||||||
|
@ -2,10 +2,13 @@
|
|||||||
set (SUBPROJECT plasma_applet_netctl)
|
set (SUBPROJECT plasma_applet_netctl)
|
||||||
message (STATUS "Subproject ${SUBPROJECT}")
|
message (STATUS "Subproject ${SUBPROJECT}")
|
||||||
|
|
||||||
|
# prepare
|
||||||
|
configure_file (metadata.desktop ${CMAKE_CURRENT_SOURCE_DIR}/package/metadata.desktop)
|
||||||
|
|
||||||
find_package (ECM 0.0.12 REQUIRED NO_MODULE)
|
find_package (ECM 0.0.12 REQUIRED NO_MODULE)
|
||||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
|
||||||
|
|
||||||
find_package (Qt5 REQUIRED COMPONENTS Core DBus Qml Quick)
|
find_package (Qt5 REQUIRED COMPONENTS Core DBus Qml)
|
||||||
find_package (KF5 REQUIRED COMPONENTS I18n Notifications Plasma)
|
find_package (KF5 REQUIRED COMPONENTS I18n Notifications Plasma)
|
||||||
|
|
||||||
include (KDEInstallDirs)
|
include (KDEInstallDirs)
|
||||||
|
@ -46,26 +46,13 @@ Item {
|
|||||||
// external
|
// external
|
||||||
property variant iconPath: {
|
property variant iconPath: {
|
||||||
"true": plasmoid.configuration.activeIconPath,
|
"true": plasmoid.configuration.activeIconPath,
|
||||||
"false": plasmoid.configuration.inactiveIconPath
|
"false": plasmoid.configuration.inactiveIconPath,
|
||||||
|
"N\\A": plasmoid.configuration.inactiveIconPath
|
||||||
}
|
}
|
||||||
property variant info: {
|
|
||||||
"active": "false",
|
|
||||||
"current": "N\\A",
|
|
||||||
"extip4": "127.0.0.1",
|
|
||||||
"extip6": "::1",
|
|
||||||
"info": "N\\A",
|
|
||||||
"intip4": "127.0.0.1",
|
|
||||||
"intip6": "::1",
|
|
||||||
"interfaces": "lo",
|
|
||||||
"profiles": "",
|
|
||||||
"status": "N\\A"
|
|
||||||
}
|
|
||||||
property string pattern: plasmoid.configuration.textPattern
|
|
||||||
property bool status: false
|
|
||||||
property string sudoPath: plasmoid.configuration.useSudo ? plasmoid.configuration.sudoPath : ""
|
property string sudoPath: plasmoid.configuration.useSudo ? plasmoid.configuration.sudoPath : ""
|
||||||
// signals
|
// signals
|
||||||
signal needUpdate
|
signal needUpdate
|
||||||
signal netctlStateChanged
|
signal needMenuUpdate
|
||||||
|
|
||||||
// init
|
// init
|
||||||
Plasmoid.icon: iconPath["false"]
|
Plasmoid.icon: iconPath["false"]
|
||||||
@ -76,27 +63,14 @@ Item {
|
|||||||
PlasmaCore.DataSource {
|
PlasmaCore.DataSource {
|
||||||
id: mainData
|
id: mainData
|
||||||
engine: "netctl"
|
engine: "netctl"
|
||||||
connectedSources: ["active", "current", "extip4", "extip6", "interfaces", "intip4", "intip6", "profiles", "status"]
|
connectedSources: ["active", "current", "extip4", "extip6", "info",
|
||||||
|
"interfaces", "intip4", "intip6", "profiles", "status"]
|
||||||
interval: plasmoid.configuration.autoUpdateInterval
|
interval: plasmoid.configuration.autoUpdateInterval
|
||||||
|
|
||||||
onNewData: {
|
onNewData: {
|
||||||
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
if (debug) console.log("[main::onNewData] : Update source " + sourceName)
|
||||||
|
|
||||||
var needToBeUpdated = false
|
NetctlAdds.setDataBySource(sourceName, data)
|
||||||
if (data.value == "N\\A") return
|
|
||||||
if (info[sourceName] != data.value) needToBeUpdated = true
|
|
||||||
if (sourceName == "active") {
|
|
||||||
if (info[sourceName] != data.value)
|
|
||||||
// inverterd status
|
|
||||||
NetctlAdds.sendNotification("Info", i18n("Network status has been changed to '%1'",
|
|
||||||
status ? i18n("inactive") : i18n("active")))
|
|
||||||
status = data.value == "true"
|
|
||||||
} else if (sourceName == "current") {
|
|
||||||
info["info"] = NetctlAdds.getInfo(data.value, info["status"])
|
|
||||||
}
|
|
||||||
// update
|
|
||||||
info[sourceName] = data.value
|
|
||||||
if (needToBeUpdated) needUpdate()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,22 +107,25 @@ Item {
|
|||||||
plasmoid.setAction("switchToProfile", i18n("Switch to profile"))
|
plasmoid.setAction("switchToProfile", i18n("Switch to profile"))
|
||||||
plasmoid.setAction("restartProfile", i18n("Restart profile"), "stock-refresh")
|
plasmoid.setAction("restartProfile", i18n("Restart profile"), "stock-refresh")
|
||||||
plasmoid.setAction("enableProfile", i18n("Enable profile"))
|
plasmoid.setAction("enableProfile", i18n("Enable profile"))
|
||||||
plasmoid.setAction("startWifi", i18n("Show WiFi menu"), "image://netctl/wifi.png")
|
plasmoid.setAction("startWifi", i18n("Show WiFi menu"), "netctl-gui-wifi")
|
||||||
// helper
|
// helper
|
||||||
if (plasmoid.configuration.useHelper) {
|
if (plasmoid.configuration.useHelper) {
|
||||||
NetctlAdds.runCmd(plasmoid.configuration.helperPath)
|
NetctlAdds.runCmd(plasmoid.configuration.helperPath)
|
||||||
plasmoid.configuration.useHelper = NetctlAdds.checkHelperStatus()
|
plasmoid.configuration.useHelper = NetctlAdds.checkHelperStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetctlAdds.needToBeUpdated.connect(needUpdate)
|
||||||
}
|
}
|
||||||
|
|
||||||
onNeedUpdate: {
|
onNeedUpdate: {
|
||||||
if (debug) console.log("[main::onNeedUpdate]")
|
if (debug) console.log("[main::onNeedUpdate]")
|
||||||
|
|
||||||
icon.source = iconPath[info["active"]]
|
var iconStatus = NetctlAdds.valueByKey("active")
|
||||||
Plasmoid.icon = iconPath[info["active"]]
|
icon.source = iconPath[iconStatus]
|
||||||
text.text = NetctlAdds.parsePattern(pattern, info)
|
Plasmoid.icon = iconPath[iconStatus]
|
||||||
Plasmoid.toolTipSubText = info["info"]
|
text.text = NetctlAdds.parsePattern(plasmoid.configuration.textPattern)
|
||||||
netctlStateChanged()
|
Plasmoid.toolTipSubText = NetctlAdds.valueByKey("info")
|
||||||
|
needMenuUpdate()
|
||||||
// updae geometry
|
// updae geometry
|
||||||
text.update()
|
text.update()
|
||||||
icon.height = text.contentHeight
|
icon.height = text.contentHeight
|
||||||
@ -160,7 +137,7 @@ Item {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onNetctlStateChanged: {
|
onNeedMenuUpdate: {
|
||||||
if (debug) console.log("[main::onNetctlStateChanged]")
|
if (debug) console.log("[main::onNetctlStateChanged]")
|
||||||
|
|
||||||
var titleAction = plasmoid.action("titleAction")
|
var titleAction = plasmoid.action("titleAction")
|
||||||
@ -172,10 +149,14 @@ Item {
|
|||||||
var enableAction = plasmoid.action("enableProfile")
|
var enableAction = plasmoid.action("enableProfile")
|
||||||
var wifiAction = plasmoid.action("startWifi")
|
var wifiAction = plasmoid.action("startWifi")
|
||||||
|
|
||||||
titleAction.iconSource = plasmoid.icon
|
var current = NetctlAdds.valueByKey("current")
|
||||||
titleAction.text = info["current"] + " " + info["status"]
|
var status = NetctlAdds.valueByKey("active") == "true"
|
||||||
|
var stringStatus = NetctlAdds.valueByKey("status")
|
||||||
|
|
||||||
if (info["status"] == "(netctl-auto)") {
|
titleAction.iconSource = plasmoid.icon
|
||||||
|
titleAction.text = current + " " + stringStatus
|
||||||
|
|
||||||
|
if (stringStatus == "(netctl-auto)") {
|
||||||
startAction.visible = false
|
startAction.visible = false
|
||||||
stopAction.visible = false
|
stopAction.visible = false
|
||||||
stopAllAction.visible = false
|
stopAllAction.visible = false
|
||||||
@ -183,7 +164,7 @@ Item {
|
|||||||
restartAction.visible = false
|
restartAction.visible = false
|
||||||
enableAction.visible = false
|
enableAction.visible = false
|
||||||
} else {
|
} else {
|
||||||
if (info["current"].indexOf("|") > -1) {
|
if (current.indexOf("|") > -1) {
|
||||||
startAction.visible = true
|
startAction.visible = true
|
||||||
stopAction.visible = false
|
stopAction.visible = false
|
||||||
stopAllAction.visible = true
|
stopAllAction.visible = true
|
||||||
@ -200,12 +181,12 @@ Item {
|
|||||||
}
|
}
|
||||||
if (status) {
|
if (status) {
|
||||||
startAction.text = i18n("Start another profile")
|
startAction.text = i18n("Start another profile")
|
||||||
stopAction.text = i18n("Stop %1", info["current"])
|
stopAction.text = i18n("Stop %1", current)
|
||||||
restartAction.text = i18n("Restart %1", info["current"])
|
restartAction.text = i18n("Restart %1", current)
|
||||||
if (info["status"].indexOf("enabled") > -1)
|
if (stringStatus.indexOf("enabled") > -1)
|
||||||
enableAction.text = i18n("Disable %1", info["current"])
|
enableAction.text = i18n("Disable %1", current)
|
||||||
else
|
else
|
||||||
enableAction.text = i18n("Enable %1", info["current"])
|
enableAction.text = i18n("Enable %1", current)
|
||||||
} else
|
} else
|
||||||
startAction.text = i18n("Start profile")
|
startAction.text = i18n("Start profile")
|
||||||
}
|
}
|
||||||
@ -222,8 +203,7 @@ Item {
|
|||||||
function action_startProfile() {
|
function action_startProfile() {
|
||||||
if (debug) console.log("[main::action_startProfile]")
|
if (debug) console.log("[main::action_startProfile]")
|
||||||
|
|
||||||
NetctlAdds.startProfileSlot(info["profiles"].split(","), status,
|
NetctlAdds.startProfileSlot(plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.useHelper,
|
|
||||||
plasmoid.configuration.netctlPath,
|
plasmoid.configuration.netctlPath,
|
||||||
sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
@ -231,7 +211,7 @@ Item {
|
|||||||
function action_stopProfile() {
|
function action_stopProfile() {
|
||||||
if (debug) console.log("[main::action_stopProfile]")
|
if (debug) console.log("[main::action_stopProfile]")
|
||||||
|
|
||||||
NetctlAdds.stopProfileSlot(info, plasmoid.configuration.useHelper,
|
NetctlAdds.stopProfileSlot(plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.netctlPath,
|
plasmoid.configuration.netctlPath,
|
||||||
sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
@ -247,15 +227,14 @@ Item {
|
|||||||
function action_switchToProfile() {
|
function action_switchToProfile() {
|
||||||
if (debug) console.log("[main::action_switchToProfile]")
|
if (debug) console.log("[main::action_switchToProfile]")
|
||||||
|
|
||||||
NetctlAdds.switchToProfileSlot(info["profiles"].split(","),
|
NetctlAdds.switchToProfileSlot(plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.useHelper,
|
|
||||||
plasmoid.configuration.netctlAutoPath)
|
plasmoid.configuration.netctlAutoPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
function action_restartProfile() {
|
function action_restartProfile() {
|
||||||
if (debug) console.log("[main::action_restartProfile]")
|
if (debug) console.log("[main::action_restartProfile]")
|
||||||
|
|
||||||
NetctlAdds.restartProfileSlot(info, plasmoid.configuration.useHelper,
|
NetctlAdds.restartProfileSlot(plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.netctlPath,
|
plasmoid.configuration.netctlPath,
|
||||||
sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
@ -263,7 +242,7 @@ Item {
|
|||||||
function action_enableProfile() {
|
function action_enableProfile() {
|
||||||
if (debug) console.log("[main::action_enableProfile]")
|
if (debug) console.log("[main::action_enableProfile]")
|
||||||
|
|
||||||
NetctlAdds.enableProfileSlot(info, plasmoid.configuration.useHelper,
|
NetctlAdds.enableProfileSlot(plasmoid.configuration.useHelper,
|
||||||
plasmoid.configuration.netctlPath,
|
plasmoid.configuration.netctlPath,
|
||||||
sudoPath)
|
sudoPath)
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,10 @@ set (PLUGIN_NAME netctlplugin)
|
|||||||
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Qml_DEFINITIONS})
|
add_definitions (${Qt5Core_DEFINITIONS} ${Qt5DBus_DEFINITIONS} ${Qt5Qml_DEFINITIONS})
|
||||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
||||||
${Qt5DBus_INCLUDE_DIRS}
|
${Qt5DBus_INCLUDE_DIRS}
|
||||||
${Qt5Qml_INCLUDE_DIRS}
|
${Qt5Qml_INCLUDE_DIRS})
|
||||||
${Qt5Quick_INCLUDE_DIRS})
|
|
||||||
set (Qt_LIBRARIES ${Qt5Core_LIBRARIES}
|
set (Qt_LIBRARIES ${Qt5Core_LIBRARIES}
|
||||||
${Qt5DBus_LIBRARIES}
|
${Qt5DBus_LIBRARIES}
|
||||||
${Qt5Qml_LIBRARIES}
|
${Qt5Qml_LIBRARIES})
|
||||||
${Qt5Quick_LIBRARIES})
|
|
||||||
set (Kf5_INCLUDE ${I18n_INCLUDE_DIR}
|
set (Kf5_INCLUDE ${I18n_INCLUDE_DIR}
|
||||||
${Notifications_INCLUDE_DIR})
|
${Notifications_INCLUDE_DIR})
|
||||||
set (Kf5_LIBRARIES KF5::I18n
|
set (Kf5_LIBRARIES KF5::I18n
|
||||||
@ -24,10 +22,8 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||||||
|
|
||||||
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||||
set (RESOURCES ${PROJECT_RESOURCE_DIR}/resources-plasmoid.qrc)
|
|
||||||
|
|
||||||
qt5_add_resources (QRC_SOURCES ${RESOURCES})
|
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE})
|
||||||
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE} ${QRC_SOURCES})
|
|
||||||
target_link_libraries (${PLUGIN_NAME} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
|
target_link_libraries (${PLUGIN_NAME} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
|
||||||
|
|
||||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/netctl)
|
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/netctl)
|
||||||
|
@ -30,14 +30,6 @@ static QObject *netctl_singletontype_provider(QQmlEngine *engine, QJSEngine *scr
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
|
|
||||||
{
|
|
||||||
Q_UNUSED(uri);
|
|
||||||
|
|
||||||
engine->addImageProvider("netctl", new NetctlAddsIconProvider());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void NetctlPlugin::registerTypes(const char *uri)
|
void NetctlPlugin::registerTypes(const char *uri)
|
||||||
{
|
{
|
||||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.netctl"));
|
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.netctl"));
|
||||||
|
@ -30,7 +30,6 @@ class NetctlPlugin : public QQmlExtensionPlugin
|
|||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void initializeEngine(QQmlEngine *engine, const char *uri);
|
|
||||||
void registerTypes(const char *uri);
|
void registerTypes(const char *uri);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,21 +32,6 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
|
||||||
NetctlAddsIconProvider::NetctlAddsIconProvider()
|
|
||||||
: QQuickImageProvider(QQmlImageProviderBase::Pixmap)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QPixmap NetctlAddsIconProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
|
|
||||||
{
|
|
||||||
Q_UNUSED(size);
|
|
||||||
Q_UNUSED(requestedSize);
|
|
||||||
|
|
||||||
return QPixmap(QString("qrc:/") + id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NetctlAdds::NetctlAdds(QObject *parent)
|
NetctlAdds::NetctlAdds(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
@ -127,22 +112,6 @@ QString NetctlAdds::getAboutText(const QString type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString NetctlAdds::getInfo(const QString current, const QString status)
|
|
||||||
{
|
|
||||||
if (debug) qDebug() << PDEBUG;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Current profiles" << current;
|
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Statuses" << status;
|
|
||||||
|
|
||||||
QStringList profiles;
|
|
||||||
for (int i=0; i<current.split(QChar('|')).count(); i++)
|
|
||||||
profiles.append(current.split(QChar('|'))[i] +
|
|
||||||
QString(" (") + status.split(QChar('|'))[i] + QString(")"));
|
|
||||||
if (profiles.isEmpty()) profiles.append(QString("N\\A"));
|
|
||||||
|
|
||||||
return profiles.join(QString(" | "));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool NetctlAdds::isDebugEnabled()
|
bool NetctlAdds::isDebugEnabled()
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
@ -151,14 +120,13 @@ bool NetctlAdds::isDebugEnabled()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString NetctlAdds::parsePattern(const QString pattern, const QMap<QString, QVariant> dict)
|
QString NetctlAdds::parsePattern(const QString pattern)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Dictionary" << dict;
|
|
||||||
|
|
||||||
QString parsed = pattern;
|
QString parsed = pattern;
|
||||||
for (int i=0; i<dict.keys().count(); i++)
|
for (int i=0; i<values.keys().count(); i++)
|
||||||
parsed.replace(QString("$") + dict.keys()[i], dict[dict.keys()[i]].toString());
|
parsed.replace(QString("$") + values.keys()[i], valueByKey(values.keys()[i]));
|
||||||
// fix newline
|
// fix newline
|
||||||
parsed.replace(QString("\n"), QString("<br>"));
|
parsed.replace(QString("\n"), QString("<br>"));
|
||||||
|
|
||||||
@ -178,67 +146,88 @@ void NetctlAdds::runCmd(const QString cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::sendNotification(const QString eventId, const QString message)
|
void NetctlAdds::setDataBySource(const QString sourceName, const QMap<QString, QVariant> data)
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Event" << eventId;
|
if (debug) qDebug() << PDEBUG << ":" << "Source" << sourceName;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Message" << message;
|
if (debug) qDebug() << PDEBUG << ":" << "Data" << data;
|
||||||
|
|
||||||
|
bool needUpdate = (values[sourceName] != data[QString("value")].toString());
|
||||||
|
values[sourceName] = data[QString("value")].toString();
|
||||||
|
if ((needUpdate) && (sourceName == QString("active"))) {
|
||||||
|
if (values[sourceName] == QString("true"))
|
||||||
|
sendNotification(QString("Info"), i18n("Network status has been changed to active"));
|
||||||
|
else
|
||||||
|
sendNotification(QString("Info"), i18n("Network status has been changed to inactive"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needUpdate) emit(needToBeUpdated());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NetctlAdds::sendNotification(const QString eventId, const QString message)
|
||||||
|
{
|
||||||
KNotification *notification = KNotification::event(eventId, QString("Netctl ::: ") + eventId, message);
|
KNotification *notification = KNotification::event(eventId, QString("Netctl ::: ") + eventId, message);
|
||||||
notification->setComponentName(QString("plasma-applet-org.kde.plasma.netctl"));
|
notification->setComponentName(QString("plasma-applet-org.kde.plasma.netctl"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString NetctlAdds::valueByKey(const QString key)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
if (debug) qDebug() << PDEBUG << ":" << "Key" << key;
|
||||||
|
|
||||||
|
return values[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// context menu
|
// context menu
|
||||||
void NetctlAdds::enableProfileSlot(const QMap<QString, QVariant> dict, const bool useHelper,
|
void NetctlAdds::enableProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
||||||
const QString cmd, const QString sudoCmd)
|
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
QString enableStatus = QString("");
|
QString enableStatus = QString("");
|
||||||
if (dict[QString("status")].toString().contains(QString("enabled"))) {
|
if (values[QString("status")].contains(QString("enabled"))) {
|
||||||
enableStatus = QString(" disable ");
|
enableStatus = QString(" disable ");
|
||||||
sendNotification(QString("Info"), i18n("Set profile %1 disabled", dict[QString("current")].toString()));
|
sendNotification(QString("Info"), i18n("Set profile %1 disabled", values[QString("current")]));
|
||||||
} else {
|
} else {
|
||||||
enableStatus = QString(" enable ");
|
enableStatus = QString(" enable ");
|
||||||
sendNotification(QString("Info"), i18n("Set profile %1 enabled", dict[QString("current")].toString()));
|
sendNotification(QString("Info"), i18n("Set profile %1 enabled", values[QString("current")]));
|
||||||
}
|
}
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(dict[QString("current")].toString());
|
args.append(values[QString("current")]);
|
||||||
sendDBusRequest(QString("Enable"), args);
|
sendDBusRequest(QString("Enable"), args);
|
||||||
} else {
|
} else {
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandLine = sudoCmd + QString(" ") + cmd + enableStatus + dict[QString("current")].toString();
|
QString commandLine = sudoCmd + QString(" ") + cmd + enableStatus + values[QString("current")];
|
||||||
command.startDetached(commandLine);
|
command.startDetached(commandLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::restartProfileSlot(const QMap<QString, QVariant> dict, const bool useHelper,
|
void NetctlAdds::restartProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
||||||
const QString cmd, const QString sudoCmd)
|
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
sendNotification(QString("Info"), i18n("Restart profile %1", dict[QString("current")].toString()));
|
sendNotification(QString("Info"), i18n("Restart profile %1", values[QString("current")]));
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(dict[QString("current")].toString());
|
args.append(values[QString("current")]);
|
||||||
sendDBusRequest(QString("Restart"), args);
|
sendDBusRequest(QString("Restart"), args);
|
||||||
} else {
|
} else {
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandLine = sudoCmd + QString(" ") + cmd + QString(" restart ") + dict[QString("current")].toString();
|
QString commandLine = sudoCmd + QString(" ") + cmd + QString(" restart ") + values[QString("current")];
|
||||||
command.startDetached(commandLine);
|
command.startDetached(commandLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::startProfileSlot(const QStringList profiles, const bool status,
|
void NetctlAdds::startProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
||||||
const bool useHelper, const QString cmd, const QString sudoCmd)
|
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profiles" << profiles;
|
|
||||||
|
|
||||||
|
QStringList profiles = values[QString("profiles")].split(QChar(','));
|
||||||
bool ok;
|
bool ok;
|
||||||
QString profile = QInputDialog::getItem(0, i18n("Select profile"), i18n("Profile:"),
|
QString profile = QInputDialog::getItem(0, i18n("Select profile"), i18n("Profile:"),
|
||||||
profiles, 0, false, &ok);
|
profiles, 0, false, &ok);
|
||||||
@ -248,14 +237,14 @@ void NetctlAdds::startProfileSlot(const QStringList profiles, const bool status,
|
|||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(profile);
|
args.append(profile);
|
||||||
if (status)
|
if (values[QString("active")] == QString("true"))
|
||||||
sendDBusRequest(QString("SwitchTo"), args);
|
sendDBusRequest(QString("SwitchTo"), args);
|
||||||
else
|
else
|
||||||
sendDBusRequest(QString("Start"), args);
|
sendDBusRequest(QString("Start"), args);
|
||||||
} else {
|
} else {
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandLine = sudoCmd + QString(" ") + cmd;
|
QString commandLine = sudoCmd + QString(" ") + cmd;
|
||||||
if (status)
|
if (values[QString("active")] == QString("true"))
|
||||||
commandLine += QString(" switch-to ") + profile;
|
commandLine += QString(" switch-to ") + profile;
|
||||||
else
|
else
|
||||||
commandLine += QString(" start ") + profile;
|
commandLine += QString(" start ") + profile;
|
||||||
@ -264,19 +253,18 @@ void NetctlAdds::startProfileSlot(const QStringList profiles, const bool status,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::stopProfileSlot(const QMap<QString, QVariant> dict, const bool useHelper,
|
void NetctlAdds::stopProfileSlot(const bool useHelper, const QString cmd, const QString sudoCmd)
|
||||||
const QString cmd, const QString sudoCmd)
|
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
|
|
||||||
sendNotification(QString("Info"), i18n("Stop profile %1", dict[QString("current")].toString()));
|
sendNotification(QString("Info"), i18n("Stop profile %1", values[QString("current")]));
|
||||||
if (useHelper) {
|
if (useHelper) {
|
||||||
QList<QVariant> args;
|
QList<QVariant> args;
|
||||||
args.append(dict[QString("current")].toString());
|
args.append(values[QString("current")]);
|
||||||
sendDBusRequest(QString("Start"), args);
|
sendDBusRequest(QString("Start"), args);
|
||||||
} else {
|
} else {
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandLine = sudoCmd + QString(" ") + cmd + QString(" stop ") + dict[QString("current")].toString();
|
QString commandLine = sudoCmd + QString(" ") + cmd + QString(" stop ") + values[QString("current")];
|
||||||
command.startDetached(commandLine);
|
command.startDetached(commandLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,12 +285,11 @@ void NetctlAdds::stopAllProfilesSlot(const bool useHelper, const QString cmd, co
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetctlAdds::switchToProfileSlot(const QStringList profiles, const bool useHelper,
|
void NetctlAdds::switchToProfileSlot(const bool useHelper, const QString cmd)
|
||||||
const QString cmd)
|
|
||||||
{
|
{
|
||||||
if (debug) qDebug() << PDEBUG;
|
if (debug) qDebug() << PDEBUG;
|
||||||
if (debug) qDebug() << PDEBUG << ":" << "Profiles" << profiles;
|
|
||||||
|
|
||||||
|
QStringList profiles = values[QString("profiles")].split(QChar(','));
|
||||||
bool ok;
|
bool ok;
|
||||||
QString profile = QInputDialog::getItem(0, i18n("Select profile"), i18n("Profile:"),
|
QString profile = QInputDialog::getItem(0, i18n("Select profile"), i18n("Profile:"),
|
||||||
profiles, 0, false, &ok);
|
profiles, 0, false, &ok);
|
||||||
|
@ -19,22 +19,11 @@
|
|||||||
#ifndef NETCTLADDS_H
|
#ifndef NETCTLADDS_H
|
||||||
#define NETCTLADDS_H
|
#define NETCTLADDS_H
|
||||||
|
|
||||||
#include <QImage>
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QQuickImageProvider>
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
|
||||||
class NetctlAddsIconProvider : public QQuickImageProvider
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NetctlAddsIconProvider();
|
|
||||||
|
|
||||||
virtual QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class NetctlAdds : public QObject
|
class NetctlAdds : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -45,41 +34,41 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE bool checkHelperStatus();
|
Q_INVOKABLE bool checkHelperStatus();
|
||||||
Q_INVOKABLE QString getAboutText(const QString type = "header");
|
Q_INVOKABLE QString getAboutText(const QString type = "header");
|
||||||
Q_INVOKABLE QString getInfo(const QString current, const QString status);
|
|
||||||
Q_INVOKABLE bool isDebugEnabled();
|
Q_INVOKABLE bool isDebugEnabled();
|
||||||
Q_INVOKABLE QString parsePattern(const QString pattern, const QMap<QString, QVariant> dict);
|
Q_INVOKABLE QString parsePattern(const QString pattern);
|
||||||
Q_INVOKABLE void runCmd(const QString cmd);
|
Q_INVOKABLE void runCmd(const QString cmd);
|
||||||
Q_INVOKABLE void sendNotification(const QString eventId, const QString message);
|
Q_INVOKABLE void setDataBySource(const QString sourceName, const QMap<QString, QVariant> data);
|
||||||
|
Q_INVOKABLE static void sendNotification(const QString eventId, const QString message);
|
||||||
|
Q_INVOKABLE QString valueByKey(const QString key);
|
||||||
// context menu
|
// context menu
|
||||||
Q_INVOKABLE void enableProfileSlot(const QMap<QString, QVariant> dict,
|
Q_INVOKABLE void enableProfileSlot(const bool useHelper = true,
|
||||||
const bool useHelper = true,
|
|
||||||
const QString cmd = QString("/usr/bin/netctl"),
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString(""));
|
||||||
Q_INVOKABLE void restartProfileSlot(const QMap<QString, QVariant> dict,
|
Q_INVOKABLE void restartProfileSlot(const bool useHelper = true,
|
||||||
const bool useHelper = true,
|
|
||||||
const QString cmd = QString("/usr/bin/netctl"),
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString(""));
|
||||||
Q_INVOKABLE void startProfileSlot(const QStringList profiles, const bool status,
|
Q_INVOKABLE void startProfileSlot(const bool useHelper = true,
|
||||||
const bool useHelper = true,
|
|
||||||
const QString cmd = QString("/usr/bin/netctl"),
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString(""));
|
||||||
Q_INVOKABLE void stopProfileSlot(const QMap<QString, QVariant> dict,
|
Q_INVOKABLE void stopProfileSlot(const bool useHelper = true,
|
||||||
const bool useHelper = true,
|
|
||||||
const QString cmd = QString("/usr/bin/netctl"),
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString(""));
|
||||||
Q_INVOKABLE void stopAllProfilesSlot(const bool useHelper = true,
|
Q_INVOKABLE void stopAllProfilesSlot(const bool useHelper = true,
|
||||||
const QString cmd = QString("/usr/bin/netctl"),
|
const QString cmd = QString("/usr/bin/netctl"),
|
||||||
const QString sudoCmd = QString(""));
|
const QString sudoCmd = QString(""));
|
||||||
Q_INVOKABLE void switchToProfileSlot(const QStringList profiles,
|
Q_INVOKABLE void switchToProfileSlot(const bool useHelper = true,
|
||||||
const bool useHelper = true,
|
|
||||||
const QString cmd = QString("/usr/bin/netctl-auto"));
|
const QString cmd = QString("/usr/bin/netctl-auto"));
|
||||||
// dataengine
|
// dataengine
|
||||||
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
Q_INVOKABLE QMap<QString, QVariant> readDataEngineConfiguration();
|
||||||
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
Q_INVOKABLE void writeDataEngineConfiguration(const QMap<QString, QVariant> configuration);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void needToBeUpdated();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
QList<QVariant> sendDBusRequest(const QString cmd, const QList<QVariant> args = QList<QVariant>());
|
QList<QVariant> sendDBusRequest(const QString cmd, const QList<QVariant> args = QList<QVariant>());
|
||||||
|
QMap<QString, QString> values;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ if (BUILD_GUI)
|
|||||||
endif ()
|
endif ()
|
||||||
if (BUILD_PLASMOID)
|
if (BUILD_PLASMOID)
|
||||||
install (FILES icon-plasmoid.png DESTINATION share/pixmaps RENAME netctl-gui-widget.png)
|
install (FILES icon-plasmoid.png DESTINATION share/pixmaps RENAME netctl-gui-widget.png)
|
||||||
|
install (FILES wifi.png DESTINATION share/pixmaps RENAME netctl-gui-wifi.png)
|
||||||
install (FILES network-idle-64x64.png DESTINATION share/icons/hicolor/64x64/apps RENAME netctl-idle.png)
|
install (FILES network-idle-64x64.png DESTINATION share/icons/hicolor/64x64/apps RENAME netctl-idle.png)
|
||||||
install (FILES network-offline-64x64.png DESTINATION share/icons/hicolor/64x64/apps RENAME netctl-offline.png)
|
install (FILES network-offline-64x64.png DESTINATION share/icons/hicolor/64x64/apps RENAME netctl-offline.png)
|
||||||
add_subdirectory (translations-plasmoid)
|
add_subdirectory (translations-plasmoid)
|
||||||
|
3
sources/sources.kdev4
Normal file
3
sources/sources.kdev4
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[Project]
|
||||||
|
Manager=KDevCMakeManager
|
||||||
|
Name=netctl-gui
|
Loading…
Reference in New Issue
Block a user