mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
okay, buttons now work
This commit is contained in:
parent
71a8922ff0
commit
8a1cd25d6e
@ -27,7 +27,7 @@ configure_file (${SUBPROJECT_DESKTOP_IN} ${CMAKE_CURRENT_BINARY_DIR}/${SUBPROJEC
|
||||
# make
|
||||
kde4_add_ui_files (SUBPROJECT_SOURCE ${SUBPROJECT_UI})
|
||||
kde4_add_plugin (${PLUGIN_NAME} ${SUBPROJECT_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS})
|
||||
target_link_libraries (${PLUGIN_NAME} ${KDE4_PLASMA_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS})
|
||||
|
||||
# install
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${PLUGIN_INSTALL_DIR})
|
||||
|
@ -30,6 +30,16 @@
|
||||
<string>Configuration</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_info">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_autoUpdate">
|
||||
<item>
|
||||
@ -124,6 +134,42 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_netctl">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_netctl">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Path to netctl</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_netctl"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_netctl">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_showBigInterface">
|
||||
<property name="text">
|
||||
@ -576,6 +622,8 @@
|
||||
<tabstop>spinBox_autoUpdate</tabstop>
|
||||
<tabstop>lineEdit_gui</tabstop>
|
||||
<tabstop>pushButton_gui</tabstop>
|
||||
<tabstop>lineEdit_netctl</tabstop>
|
||||
<tabstop>pushButton_netctl</tabstop>
|
||||
<tabstop>checkBox_showBigInterface</tabstop>
|
||||
<tabstop>checkBox_showNetDev</tabstop>
|
||||
<tabstop>checkBox_showExtIp</tabstop>
|
||||
|
@ -17,9 +17,12 @@
|
||||
|
||||
#include "netctl.h"
|
||||
#include "ui_configwindow.h"
|
||||
#include <version.h>
|
||||
|
||||
#include <KConfigDialog>
|
||||
#include <KFileDialog>
|
||||
#include <KNotification>
|
||||
#include <KUrl>
|
||||
#include <Plasma/DataEngine>
|
||||
#include <plasma/theme.h>
|
||||
|
||||
@ -51,6 +54,7 @@ Netctl::~Netctl()
|
||||
|
||||
void Netctl::init()
|
||||
{
|
||||
createActions();
|
||||
// generate ui
|
||||
// main layout
|
||||
fullSpaceLayout = new QGraphicsLinearLayout();
|
||||
@ -82,6 +86,21 @@ void Netctl::init()
|
||||
}
|
||||
|
||||
|
||||
void Netctl::createActions()
|
||||
{
|
||||
// helpAction = new QAction( KIcon( "help-about" ), i18n( "Help" ), this );
|
||||
// helpAction->setMenu( ( QMenu* ) (new KHelpMenu( NULL, about, false ) )->menu() );
|
||||
}
|
||||
|
||||
|
||||
QList<QAction*> Netctl::contextualActions()
|
||||
{
|
||||
QList<QAction*> menuActions;
|
||||
|
||||
return menuActions;
|
||||
}
|
||||
|
||||
|
||||
int Netctl::showGui()
|
||||
{
|
||||
QProcess command;
|
||||
@ -150,7 +169,7 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
|
||||
QString value = data[QString("value")].toString();;
|
||||
|
||||
if (sourceName == QString("currentProfile")) {
|
||||
if (value == QString(""))
|
||||
if (value.isEmpty())
|
||||
value = QString("N\\A");
|
||||
profileName = value;
|
||||
|
||||
@ -166,17 +185,17 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
|
||||
textLabel->setText(formatLine[0] + text.join(QString("<br>")) + formatLine[1]);
|
||||
}
|
||||
else if (sourceName == QString("extIp")) {
|
||||
if (value == QString(""))
|
||||
if (value.isEmpty())
|
||||
value = QString("N\\A");
|
||||
extIp = value;
|
||||
}
|
||||
else if (sourceName == QString("intIp")) {
|
||||
if (value == QString(""))
|
||||
if (value.isEmpty())
|
||||
value = QString("N\\A");
|
||||
intIp = value;
|
||||
}
|
||||
else if (sourceName == QString("interfaces")) {
|
||||
if (value == QString(""))
|
||||
if (value.isEmpty())
|
||||
value = QString("N\\A");
|
||||
interfaces = value;
|
||||
}
|
||||
@ -198,13 +217,48 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
|
||||
|
||||
|
||||
// configuration interface
|
||||
void Netctl::selectGuiExe()
|
||||
{
|
||||
KUrl guiUrl = KFileDialog::getOpenUrl(KUrl(), "*");
|
||||
if (!guiUrl.isEmpty())
|
||||
uiConfig.lineEdit_gui->setText(guiUrl.path());
|
||||
}
|
||||
|
||||
|
||||
void Netctl::selectNetctlExe()
|
||||
{
|
||||
KUrl netctlUrl = KFileDialog::getOpenUrl(KUrl(), "*");
|
||||
if (!netctlUrl.isEmpty())
|
||||
uiConfig.lineEdit_netctl->setText(netctlUrl.path());
|
||||
}
|
||||
|
||||
|
||||
void Netctl::selectActiveIcon()
|
||||
{
|
||||
KUrl activeIconUrl = KFileDialog::getOpenUrl(KUrl(), "*");
|
||||
if (!activeIconUrl.isEmpty())
|
||||
uiConfig.lineEdit_activeIcon->setText(activeIconUrl.path());
|
||||
}
|
||||
|
||||
|
||||
void Netctl::selectInactiveIcon()
|
||||
{
|
||||
KUrl inactiveIconUrl = KFileDialog::getOpenUrl(KUrl(), "*");
|
||||
if (!inactiveIconUrl.isEmpty())
|
||||
uiConfig.lineEdit_inactiveIcon->setText(inactiveIconUrl.path());
|
||||
}
|
||||
|
||||
|
||||
void Netctl::createConfigurationInterface(KConfigDialog *parent)
|
||||
{
|
||||
QWidget *configwin = new QWidget;
|
||||
uiConfig.setupUi(configwin);
|
||||
QString text = QString(NAME) + " - " + QString(VERSION) + "\n" + "(c) " + QString(DATE) + " " + QString(AUTHOR);
|
||||
uiConfig.label_info->setText(text);
|
||||
|
||||
uiConfig.spinBox_autoUpdate->setValue(autoUpdateInterval);
|
||||
uiConfig.lineEdit_gui->setText(guiPath);
|
||||
uiConfig.lineEdit_netctl->setText(netctlPath);
|
||||
if (showBigInterface)
|
||||
uiConfig.checkBox_showBigInterface->setCheckState(Qt::Checked);
|
||||
else
|
||||
@ -236,8 +290,16 @@ void Netctl::createConfigurationInterface(KConfigDialog *parent)
|
||||
uiConfig.lineEdit_inactiveIcon->setText(inactiveIconPath);
|
||||
|
||||
parent->addPage(configwin, i18n("Netctl plasmoid"), Applet::icon());
|
||||
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
|
||||
|
||||
connect(uiConfig.checkBox_showBigInterface, SIGNAL(stateChanged(int)), this, SLOT(setBigInterface()));
|
||||
|
||||
connect(uiConfig.pushButton_gui, SIGNAL(clicked()), this, SLOT(selectGuiExe()));
|
||||
connect(uiConfig.pushButton_netctl, SIGNAL(clicked()), this, SLOT(selectNetctlExe()));
|
||||
connect(uiConfig.pushButton_activeIcon, SIGNAL(clicked()), this, SLOT(selectActiveIcon()));
|
||||
connect(uiConfig.pushButton_inactiveIcon, SIGNAL(clicked()), this, SLOT(selectInactiveIcon()));
|
||||
|
||||
connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted()));
|
||||
connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
|
||||
}
|
||||
|
||||
|
||||
@ -248,6 +310,7 @@ void Netctl::configAccepted()
|
||||
|
||||
cg.writeEntry("autoUpdateInterval", uiConfig.spinBox_autoUpdate->value());
|
||||
cg.writeEntry("guiPath", uiConfig.lineEdit_gui->text());
|
||||
cg.writeEntry("netctlPath", uiConfig.lineEdit_netctl->text());
|
||||
if (uiConfig.checkBox_showBigInterface->checkState() == 0)
|
||||
cg.writeEntry("showBigInterface", false);
|
||||
else
|
||||
@ -281,6 +344,7 @@ void Netctl::configChanged()
|
||||
|
||||
autoUpdateInterval = cg.readEntry("autoUpdateInterval", 1000);
|
||||
guiPath = cg.readEntry("guiPath", "/usr/bin/netctl-gui");
|
||||
netctlPath = cg.readEntry("netctlPath", "/usr/bin/netctl");
|
||||
showBigInterface = cg.readEntry("showBigInterface", true);
|
||||
showNetDev = cg.readEntry("showNetDev", true);
|
||||
showExtIp = cg.readEntry("showExtIp", true);
|
||||
|
@ -47,8 +47,15 @@ public slots:
|
||||
void configChanged();
|
||||
int setBigInterface();
|
||||
|
||||
private slots:
|
||||
void selectGuiExe();
|
||||
void selectNetctlExe();
|
||||
void selectActiveIcon();
|
||||
void selectInactiveIcon();
|
||||
|
||||
protected:
|
||||
void createConfigurationInterface(KConfigDialog *parent);
|
||||
QList<QAction*> contextualActions();
|
||||
|
||||
private:
|
||||
// ui
|
||||
@ -65,6 +72,11 @@ private:
|
||||
QString extIp;
|
||||
QString interfaces;
|
||||
QStringList formatLine;
|
||||
// context menu
|
||||
void createActions();
|
||||
QAction *startProfile;
|
||||
QAction *restartProfile;
|
||||
QAction *enableProfileAutoload;
|
||||
// data engine
|
||||
void connectToEngine();
|
||||
void disconnectFromEngine();
|
||||
@ -73,6 +85,7 @@ private:
|
||||
// configuration
|
||||
int autoUpdateInterval;
|
||||
QString guiPath;
|
||||
QString netctlPath;
|
||||
bool showBigInterface;
|
||||
bool showNetDev;
|
||||
bool showExtIp;
|
||||
|
@ -1,8 +1,9 @@
|
||||
#ifndef VERSION_H
|
||||
#define VERSION_H
|
||||
|
||||
#ifndef PROJ_VERSION
|
||||
#define PROJ_VERSION "@PROJECT_VERSION@"
|
||||
#endif /* PROJ_VERSION */
|
||||
#define AUTHOR "Evgeniy Alekseev"
|
||||
#define DATE "2014-2014"
|
||||
#define NAME "Netctl plasmoid"
|
||||
#define VERSION "@PROJECT_VERSION@"
|
||||
|
||||
#endif /* VERSION_H */
|
||||
|
Loading…
Reference in New Issue
Block a user