mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
starting work on plasmoid
This commit is contained in:
parent
b243a4d324
commit
4428b8a087
@ -1,7 +1,7 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Netctl DataEngine
|
||||
Comment=data engine for netctl
|
||||
Comment=Data engine for netctl
|
||||
ServiceTypes=Plasma/DataEngine
|
||||
Type=Service
|
||||
Icon=netctl-gui
|
||||
@ -14,6 +14,7 @@ X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=netctl
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=http://arcan1s.github.io/projects/netctlplasmoid
|
||||
X-KDE-PluginInfo-Category=Network
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
|
557
sources/plasmoid/configwindow.ui
Normal file
557
sources/plasmoid/configwindow.ui
Normal file
@ -0,0 +1,557 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigWindow</class>
|
||||
<widget class="QWidget" name="ConfigWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>480</width>
|
||||
<height>320</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>480</width>
|
||||
<height>320</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Configuration Window</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabConfiguration">
|
||||
<attribute name="title">
|
||||
<string>Configuration</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_autoUpdate">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_autoUpdate">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Auto update interval, msec</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_autoUpdate">
|
||||
<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="QSpinBox" name="spinBox_autoUpdate">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::LeftToRight</enum>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>333</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>500</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_showBigInterface">
|
||||
<property name="text">
|
||||
<string>Show big interface</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_showNetDev">
|
||||
<property name="text">
|
||||
<string>Show network devices</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_showExtIp">
|
||||
<property name="text">
|
||||
<string>Show external IP</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBox_showIntIp">
|
||||
<property name="text">
|
||||
<string>Show internal IP</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_configuration">
|
||||
<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="tabAppearance">
|
||||
<attribute name="title">
|
||||
<string>Appearance</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_font">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_font">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_font">
|
||||
<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="QFontComboBox" name="fontComboBox_font">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set font family</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontSize">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontSize">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font size</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_fontSize">
|
||||
<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="QSpinBox" name="spinBox_fontSize">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set font size</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>7</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>48</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>12</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontColor">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontColor">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_fontColor">
|
||||
<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="KColorCombo" name="kcolorcombo_fontColor">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set font color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontWeight">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontWeight">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font weight</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_fontWeight">
|
||||
<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="QSpinBox" name="spinBox_fontWeight">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set font weight</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>300</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>600</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>400</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_fontStyle">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_fontStyle">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_fontStyle">
|
||||
<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="QComboBox" name="comboBox_fontStyle">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Set font style</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>normal</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>italic</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_appearance">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_activeIcon">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_activeIcon">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Active icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_activeIcon"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_activeIcon">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_inactiveIcon">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_inactiveIcon">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>23</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Inactive icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_inactiveIcon"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_inactiveIcon">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Browse</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_appearance">
|
||||
<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>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KColorCombo</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header>kcolorcombo.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
<tabstop>spinBox_autoUpdate</tabstop>
|
||||
<tabstop>checkBox_showBigInterface</tabstop>
|
||||
<tabstop>checkBox_showNetDev</tabstop>
|
||||
<tabstop>checkBox_showExtIp</tabstop>
|
||||
<tabstop>checkBox_showIntIp</tabstop>
|
||||
<tabstop>fontComboBox_font</tabstop>
|
||||
<tabstop>spinBox_fontSize</tabstop>
|
||||
<tabstop>kcolorcombo_fontColor</tabstop>
|
||||
<tabstop>spinBox_fontWeight</tabstop>
|
||||
<tabstop>comboBox_fontStyle</tabstop>
|
||||
<tabstop>lineEdit_activeIcon</tabstop>
|
||||
<tabstop>pushButton_activeIcon</tabstop>
|
||||
<tabstop>lineEdit_inactiveIcon</tabstop>
|
||||
<tabstop>pushButton_inactiveIcon</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
204
sources/plasmoid/netctl.cpp
Normal file
204
sources/plasmoid/netctl.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 Foobar. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "netctl.h"
|
||||
#include "ui_configwindow.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <KConfigDialog>
|
||||
#include <KNotification>
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <plasma/theme.h>
|
||||
|
||||
|
||||
Netctl::Netctl(QObject *parent, const QVariantList &args) :
|
||||
Plasma::Applet(parent, args)
|
||||
{
|
||||
setBackgroundHints(DefaultBackground);
|
||||
setHasConfigurationInterface(true);
|
||||
}
|
||||
|
||||
|
||||
Netctl::~Netctl()
|
||||
{
|
||||
delete main_label;
|
||||
}
|
||||
|
||||
|
||||
void Netctl::init()
|
||||
{
|
||||
// generate ui
|
||||
// layout
|
||||
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(this);
|
||||
layout->setOrientation(Qt::Vertical);
|
||||
// label
|
||||
layout->addStretch(1);
|
||||
main_label = new Plasma::Label(this);
|
||||
main_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
main_label->setToolTip(qApp->translate("tooltip", "Click here to update message"));
|
||||
layout->addItem(main_label);
|
||||
layout->addStretch(1);
|
||||
// read variables
|
||||
configChanged();
|
||||
}
|
||||
|
||||
|
||||
void Netctl::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
// mouse double click event
|
||||
// add gui support
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int Netctl::sendNotification(QString eventId, int num)
|
||||
{
|
||||
// send notification
|
||||
KNotification *notification = new KNotification(eventId);
|
||||
notification->setComponentData(KComponentData("plasma_applet_netctl"));
|
||||
notification->setTitle(QString(i18n("Netctl plasmoid")));
|
||||
notification->setText("test");
|
||||
notification->sendEvent();
|
||||
delete notification;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// configuration interface
|
||||
void Netctl::createConfigurationInterface(KConfigDialog *parent)
|
||||
{
|
||||
QWidget *configwin = new QWidget;
|
||||
uiConfig.setupUi(configwin);
|
||||
|
||||
uiConfig.spinBox_autoUpdate->setValue(autoUpdateInterval);
|
||||
if (showBigInterface)
|
||||
uiConfig.checkBox_showBigInterface->setCheckState(Qt::Checked);
|
||||
else
|
||||
uiConfig.checkBox_showBigInterface->setCheckState(Qt::Unchecked);
|
||||
if (showNetDev)
|
||||
uiConfig.checkBox_showNetDev->setCheckState(Qt::Checked);
|
||||
else
|
||||
uiConfig.checkBox_showNetDev->setCheckState(Qt::Unchecked);
|
||||
if (showExtIp)
|
||||
uiConfig.checkBox_showExtIp->setCheckState(Qt::Checked);
|
||||
else
|
||||
uiConfig.checkBox_showExtIp->setCheckState(Qt::Unchecked);
|
||||
if (showIntIp)
|
||||
uiConfig.checkBox_showIntIp->setCheckState(Qt::Checked);
|
||||
else
|
||||
uiConfig.checkBox_showIntIp->setCheckState(Qt::Unchecked);
|
||||
setBigInterface();
|
||||
|
||||
QFont font = QFont(fontFamily, 12, 400, FALSE);
|
||||
uiConfig.fontComboBox_font->setCurrentFont(font);
|
||||
uiConfig.spinBox_fontSize->setValue(fontSize);
|
||||
uiConfig.kcolorcombo_fontColor->setColor(fontColor);
|
||||
uiConfig.spinBox_fontWeight->setValue(fontWeight);
|
||||
if (fontStyle == "normal")
|
||||
uiConfig.comboBox_fontStyle->setCurrentIndex(0);
|
||||
else if (fontStyle == "italic")
|
||||
uiConfig.comboBox_fontStyle->setCurrentIndex(1);
|
||||
uiConfig.lineEdit_activeIcon->setText(activeIconPath);
|
||||
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()));
|
||||
}
|
||||
|
||||
|
||||
void Netctl::configAccepted()
|
||||
{
|
||||
KConfigGroup cg = config();
|
||||
|
||||
cg.writeEntry("autoUpdateInterval", uiConfig.spinBox_autoUpdate->value());
|
||||
if (uiConfig.checkBox_showBigInterface->checkState() == 0)
|
||||
cg.writeEntry("showBigInterface", false);
|
||||
else
|
||||
cg.writeEntry("showBigInterface", true);
|
||||
if (uiConfig.checkBox_showNetDev->checkState() == 0)
|
||||
cg.writeEntry("showNetDev", false);
|
||||
else
|
||||
cg.writeEntry("showNetDev", true);
|
||||
if (uiConfig.checkBox_showExtIp->checkState() == 0)
|
||||
cg.writeEntry("showExtIp", false);
|
||||
else
|
||||
cg.writeEntry("showExtIp", true);
|
||||
if (uiConfig.checkBox_showIntIp->checkState() == 0)
|
||||
cg.writeEntry("showIntIp", false);
|
||||
else
|
||||
cg.writeEntry("showIntIp", true);
|
||||
|
||||
cg.writeEntry("fontFamily", uiConfig.fontComboBox_font->currentFont().family());
|
||||
cg.writeEntry("fontSize", uiConfig.spinBox_fontSize->value());
|
||||
cg.writeEntry("fontColor", uiConfig.kcolorcombo_fontColor->color().name());
|
||||
cg.writeEntry("fontWeight", uiConfig.spinBox_fontWeight->value());
|
||||
cg.writeEntry("fontStyle", uiConfig.comboBox_fontStyle->currentText());
|
||||
cg.writeEntry("activeIconPath", uiConfig.lineEdit_activeIcon->text());
|
||||
cg.writeEntry("inactiveIconPath", uiConfig.lineEdit_inactiveIcon->text());
|
||||
}
|
||||
|
||||
|
||||
void Netctl::configChanged()
|
||||
{
|
||||
KConfigGroup cg = config();
|
||||
|
||||
autoUpdateInterval = cg.readEntry("autoUpdateInterval", 1000);
|
||||
showBigInterface = cg.readEntry("showBigInterface", true);
|
||||
showNetDev = cg.readEntry("showNetDev", true);
|
||||
showExtIp = cg.readEntry("showExtIp", true);
|
||||
showIntIp = cg.readEntry("showIntIp", true);
|
||||
|
||||
fontFamily = cg.readEntry("fontFamily", "Terminus");
|
||||
fontSize = cg.readEntry("fontSize", 12);
|
||||
fontColor = cg.readEntry("fontColor", "#000000");
|
||||
fontWeight = cg.readEntry("fontWeight", 400);
|
||||
fontStyle = cg.readEntry("fontStyle", "normal");
|
||||
activeIconPath = cg.readEntry("activeIconPath", "/usr/share/icons/hicolor/48x48/apps/network-idle-64x64.png");
|
||||
inactiveIconPath = cg.readEntry("inactiveIconPath", "/usr/share/icons/hicolor/48x48/apps/network-offline-64x64.png");
|
||||
|
||||
formatLine[0] = ("<p align=\"justify\"><span style=\" font-family:'" + fontFamily + \
|
||||
"'; font-style:" + fontStyle + \
|
||||
"; font-size:" + QString::number(fontSize) + \
|
||||
"pt; font-weight:" + QString::number(fontWeight) + \
|
||||
"; color:" + fontColor + \
|
||||
";\">");
|
||||
formatLine[1] = ("</span></p>");
|
||||
}
|
||||
|
||||
|
||||
int Netctl::setBigInterface()
|
||||
{
|
||||
if (uiConfig.checkBox_showBigInterface->checkState() == 0) {
|
||||
uiConfig.checkBox_showNetDev->setDisabled(true);
|
||||
uiConfig.checkBox_showExtIp->setDisabled(true);
|
||||
uiConfig.checkBox_showIntIp->setDisabled(true);
|
||||
}
|
||||
else if (uiConfig.checkBox_showBigInterface->checkState() == 2) {
|
||||
uiConfig.checkBox_showNetDev->setEnabled(true);
|
||||
uiConfig.checkBox_showExtIp->setEnabled(true);
|
||||
uiConfig.checkBox_showIntIp->setEnabled(true);
|
||||
}
|
||||
else
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#include "netctl.moc"
|
71
sources/plasmoid/netctl.h
Normal file
71
sources/plasmoid/netctl.h
Normal file
@ -0,0 +1,71 @@
|
||||
/***************************************************************************
|
||||
* 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 Foobar. If not, see <http://www.gnu.org/licenses/>. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef NETCTL_PLASMOID_H
|
||||
#define NETCTL_PLASMOID_H
|
||||
|
||||
#include <Plasma/Applet>
|
||||
#include <Plasma/Label>
|
||||
|
||||
#include <ui_configwindow.h>
|
||||
|
||||
class QGraphicsLinearLayout;
|
||||
|
||||
class Netctl : public Plasma::Applet
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Netctl(QObject *parent, const QVariantList &args);
|
||||
~Netctl();
|
||||
void init();
|
||||
|
||||
public slots:
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
||||
int sendNotification(QString eventId, int num);
|
||||
// for configuration interface
|
||||
void configAccepted();
|
||||
void configChanged();
|
||||
int setBigInterface();
|
||||
|
||||
protected:
|
||||
void createConfigurationInterface(KConfigDialog *parent);
|
||||
|
||||
private:
|
||||
// ui
|
||||
Plasma::Label *main_label;
|
||||
QStringList formatLine;
|
||||
// configuration
|
||||
int autoUpdateInterval;
|
||||
bool showBigInterface;
|
||||
bool showNetDev;
|
||||
bool showExtIp;
|
||||
bool showIntIp;
|
||||
QString fontFamily;
|
||||
int fontSize;
|
||||
QString fontColor;
|
||||
int fontWeight;
|
||||
QString fontStyle;
|
||||
QString activeIconPath;
|
||||
QString inactiveIconPath;
|
||||
// configuration interface
|
||||
Ui::ConfigWindow uiConfig;
|
||||
};
|
||||
|
||||
K_EXPORT_PLASMA_APPLET(netctl, Netctl)
|
||||
|
||||
#endif /* NETCTL_PLASMOID_H */
|
19
sources/plasmoid/plasma-applet-netctl.desktop
Normal file
19
sources/plasmoid/plasma-applet-netctl.desktop
Normal file
@ -0,0 +1,19 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Netctl
|
||||
Comment=Plasmoid for netctl
|
||||
Type=Service
|
||||
Icon=netctl-gui
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/Applet
|
||||
X-KDE-Library=plasma_applet_netctl
|
||||
|
||||
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
|
||||
X-KDE-PluginInfo-Email=esalexeev@gmail.com
|
||||
X-KDE-PluginInfo-Name=netctl
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=http://arcan1s.github.io/projects/netctlplasmoid
|
||||
X-KDE-PluginInfo-Category=Network
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPLv3
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
9
sources/plasmoid/plasma_applet_netctl.notifyrc
Normal file
9
sources/plasmoid/plasma_applet_netctl.notifyrc
Normal file
@ -0,0 +1,9 @@
|
||||
[Global]
|
||||
IconName=netctl-gui
|
||||
Name=Netctl plasmoid
|
||||
Comment=Netctl plasmoid
|
||||
|
||||
[Event/NewEvent]
|
||||
Name=New event
|
||||
Comment=Comment
|
||||
Action=Popup
|
Loading…
Reference in New Issue
Block a user