mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
some configuration interface changes
This commit is contained in:
parent
afed94745a
commit
7972f2d6d3
@ -58,8 +58,8 @@ IPv6: $intip6</default>
|
||||
<entry name="fontColor" type="string">
|
||||
<default>#000000</default>
|
||||
</entry>
|
||||
<entry name="fontWeight" type="int">
|
||||
<default>400</default>
|
||||
<entry name="fontWeight" type="string">
|
||||
<default>normal</default>
|
||||
</entry>
|
||||
<entry name="fontStyle" type="string">
|
||||
<default>normal</default>
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.0 as QtControls
|
||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||
import QtQuick.Layouts 1.0 as QtLayouts
|
||||
|
||||
@ -26,10 +27,18 @@ Item {
|
||||
width: childrenRect.width
|
||||
height: childrenRect.height
|
||||
|
||||
property variant weight: {
|
||||
25: 0,
|
||||
50: 1,
|
||||
63: 3,
|
||||
75: 4,
|
||||
87: 5
|
||||
}
|
||||
|
||||
property string cfg_textAlign: textAlign.currentText
|
||||
property alias cfg_fontFamily: selectFont.text
|
||||
property alias cfg_fontSize: fontSize.value
|
||||
property alias cfg_fontWeight: fontWeight.value
|
||||
property string cfg_fontWeight: fontWeight.currentText
|
||||
property string cfg_fontStyle: fontStyle.currentText
|
||||
property alias cfg_fontColor: selectColor.text
|
||||
property alias cfg_activeIconPath: activeIcon.text
|
||||
@ -101,12 +110,39 @@ Item {
|
||||
QtControls.Label {
|
||||
text: i18n("Font weight")
|
||||
}
|
||||
QtControls.SpinBox {
|
||||
QtControls.ComboBox {
|
||||
id: fontWeight
|
||||
minimumValue: 100
|
||||
maximumValue: 900
|
||||
stepSize: 100
|
||||
value: plasmoid.configuration.fontWeight
|
||||
textRole: "label"
|
||||
model: [
|
||||
{
|
||||
'label': i18n("light"),
|
||||
'name': "light"
|
||||
},
|
||||
{
|
||||
'label': i18n("normal"),
|
||||
'name': "normal"
|
||||
},
|
||||
{
|
||||
'label': i18n("demi bold"),
|
||||
'name': "demibold"
|
||||
},
|
||||
{
|
||||
'label': i18n("bold"),
|
||||
'name': "bold"
|
||||
},
|
||||
{
|
||||
'label': i18n("black"),
|
||||
'name': "black"
|
||||
}
|
||||
]
|
||||
onCurrentIndexChanged: cfg_fontWeight = model[currentIndex]["name"]
|
||||
Component.onCompleted: {
|
||||
for (var i = 0; i < model.length; i++) {
|
||||
if (model[i]["name"] == plasmoid.configuration.fontWeight) {
|
||||
fontWeight.currentIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,6 +180,11 @@ Item {
|
||||
}
|
||||
QtControls.Button {
|
||||
id: selectColor
|
||||
style: QtStyles.ButtonStyle {
|
||||
background: Rectangle {
|
||||
color: plasmoid.configuration.fontColor
|
||||
}
|
||||
}
|
||||
text: plasmoid.configuration.fontColor
|
||||
onClicked: colorDialog.visible = true
|
||||
}
|
||||
@ -224,6 +265,8 @@ Item {
|
||||
onAccepted: {
|
||||
selectFont.text = fontDialog.font.family
|
||||
fontSize.value = fontDialog.font.pointSize
|
||||
fontStyle.currentIndex = fontDialog.font.italic ? 1 : 0
|
||||
fontWeight.currentIndex = weight[fontDialog.font.weight]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,25 @@ Item {
|
||||
id: main
|
||||
|
||||
// variables
|
||||
// internal
|
||||
property variant weight: {
|
||||
"light": Font.Light,
|
||||
"normal": Font.Normal,
|
||||
"demibold": Font.DemiBold,
|
||||
"bold": Font.Bold,
|
||||
"black": Font.Black
|
||||
}
|
||||
property variant align: {
|
||||
"left": Text.AlignLeft,
|
||||
"center": Text.AlignHCenter,
|
||||
"right": Text.AlignRight,
|
||||
"justify": Text.AlignJustify
|
||||
}
|
||||
// external
|
||||
property variant iconPath: {
|
||||
"true": plasmoid.configuration.activeIconPath,
|
||||
"false": plasmoid.configuration.inactiveIconPath
|
||||
}
|
||||
property variant info: {
|
||||
"current": "N\\A",
|
||||
"extip4": "127.0.0.1",
|
||||
@ -37,12 +56,8 @@ Item {
|
||||
"profiles": "",
|
||||
"status": "N\\A"
|
||||
}
|
||||
Text {
|
||||
id: iconPath
|
||||
property string active: plasmoid.configuration.activeIconPath
|
||||
property string inactive: plasmoid.configuration.inactiveIconPath
|
||||
}
|
||||
property int interval: plasmoid.configuration.autoUpdateInterval
|
||||
property string pattern: plasmoid.configuration.textPattern
|
||||
property bool status: false
|
||||
|
||||
// init
|
||||
@ -57,19 +72,13 @@ Item {
|
||||
onNewData: {
|
||||
if (data.isEmpty) return
|
||||
if (sourceName == "active") {
|
||||
if (data.value == "true") {
|
||||
main.status = true
|
||||
icon.source = iconPath.active
|
||||
} else {
|
||||
main.status = false
|
||||
icon.source = iconPath.inactive
|
||||
}
|
||||
main.status = data.value == "true" ? true : false
|
||||
icon.source = iconPath[data.value]
|
||||
} else if (sourceName == "current") {
|
||||
info["current"] = data.value
|
||||
// text update
|
||||
for (var prop in info) {
|
||||
console.log(prop + " = " + info[prop])
|
||||
}
|
||||
info["info"] = NetctlAdds.getInfo(info["current"], info["status"])
|
||||
text.text = NetctlAdds.parsePattern(pattern, info)
|
||||
} else if (sourceName == "extip4") {
|
||||
info["extip4"] = data.value
|
||||
} else if (sourceName == "extip6") {
|
||||
@ -94,10 +103,17 @@ Item {
|
||||
|
||||
Image {
|
||||
id: icon
|
||||
source: iconPath.inactive
|
||||
source: iconPath["inactive"]
|
||||
}
|
||||
Text {
|
||||
id: text
|
||||
color: plasmoid.configuration.fontColor
|
||||
font.family: plasmoid.configuration.fontFamily
|
||||
font.italic: plasmoid.configuration.fontStyle == "italic" ? true : false
|
||||
font.pointSize: plasmoid.configuration.fontSize
|
||||
font.weight: weight[plasmoid.configuration.fontWeight]
|
||||
horizontalAlignment: align[plasmoid.configuration.textAlign]
|
||||
textFormat: Text.RichText
|
||||
text: "N\\A"
|
||||
}
|
||||
}
|
||||
|
@ -17,18 +17,22 @@
|
||||
|
||||
#include <QtQml>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "netctl.h"
|
||||
#include "netctladds.h"
|
||||
#include "version.h"
|
||||
|
||||
|
||||
static QObject *netctl_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
|
||||
{
|
||||
Q_UNUSED(engine)
|
||||
Q_UNUSED(scriptEngine)
|
||||
|
||||
return new NetctlAdds();
|
||||
}
|
||||
|
||||
|
||||
void NetctlPlugin::registerTypes(const char *uri)
|
||||
{
|
||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.netctl"));
|
||||
|
||||
qmlRegisterType<NetctlAdds>(uri, 1, 0, "NetctlAdds");
|
||||
// qmlRegisterType<TimeZoneModel>(uri, 1, 0, "TimeZoneModel");
|
||||
// qmlRegisterSingletonType<TimezonesI18n>(uri, 1, 0, "TimezonesI18n", timezonesi18n_singletontype_provider);
|
||||
qmlRegisterSingletonType<NetctlAdds>(uri, 1, 0, "NetctlAdds", netctl_singletontype_provider);
|
||||
}
|
||||
|
@ -15,7 +15,10 @@
|
||||
* along with netctl-gui. If not, see http://www.gnu.org/licenses/ *
|
||||
***************************************************************************/
|
||||
|
||||
//#include <pdebug/pdebug.h>
|
||||
#include <QDebug>
|
||||
#include <QProcessEnvironment>
|
||||
|
||||
#include <pdebug/pdebug.h>
|
||||
|
||||
#include "netctladds.h"
|
||||
#include "version.h"
|
||||
@ -24,19 +27,45 @@
|
||||
NetctlAdds::NetctlAdds(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
// debug
|
||||
QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
|
||||
QString debugEnv = environment.value(QString("NETCTLGUI_DEBUG"), QString("no"));
|
||||
debug = (debugEnv == QString("yes"));
|
||||
}
|
||||
|
||||
|
||||
NetctlAdds::~NetctlAdds()
|
||||
{
|
||||
// if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAdds::parsePattern(QString pattern, const QString key, const QString value)
|
||||
QString NetctlAdds::getInfo(const QString current, const QString status)
|
||||
{
|
||||
// if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Current profiles" << current;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Statuses" << status;
|
||||
|
||||
return pattern.replace(QString("$") + key, value);
|
||||
QStringList profiles;
|
||||
for (int i=0; i<current.split(QChar('|')).count(); i++)
|
||||
profiles.append(current.split(QChar('|'))[i] +
|
||||
QString(" (") + status.split(QChar('|'))[i] + QString(")"));
|
||||
|
||||
return profiles.join(QString(" | "));
|
||||
}
|
||||
|
||||
|
||||
QString NetctlAdds::parsePattern(const QString pattern, const QMap<QString, QVariant> dict)
|
||||
{
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Dictionary" << dict;
|
||||
|
||||
QString parsed = pattern;
|
||||
for (int i=0; i<dict.keys().count(); i++)
|
||||
parsed.replace(QString("$") + dict.keys()[i], dict[dict.keys()[i]].toString());
|
||||
// fix newline
|
||||
parsed.replace(QString("\n"), QString("<br>"));
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,11 @@
|
||||
#ifndef NETCTLADDS_H
|
||||
#define NETCTLADDS_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
class QQmlEngine;
|
||||
|
||||
class NetctlAdds : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -32,7 +32,11 @@ public:
|
||||
NetctlAdds(QObject *parent = 0);
|
||||
~NetctlAdds();
|
||||
|
||||
Q_INVOKABLE QString parsePattern(QString pattern, const QString key, const QString value);
|
||||
Q_INVOKABLE QString getInfo(const QString current, const QString status);
|
||||
Q_INVOKABLE QString parsePattern(const QString pattern, const QMap<QString, QVariant> dict);
|
||||
|
||||
private:
|
||||
bool debug = false;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user