mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-17 07:40:00 +00:00
some configuration interface changes
This commit is contained in:
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user