mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 23:47:21 +00:00
changes before renaming
This commit is contained in:
parent
682b6c5b4f
commit
028b636d22
@ -206,14 +206,11 @@ bool Netctl::updateSourceEvent(const QString &source)
|
|||||||
QStringList profile = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
QStringList profile = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
|
||||||
for (int i=0; i<profile.count(); i++)
|
for (int i=0; i<profile.count(); i++)
|
||||||
if (profile[i].split(QString(" "), QString::SkipEmptyParts)[0] == QString("Loaded:")) {
|
if (profile[i].split(QString(" "), QString::SkipEmptyParts)[0] == QString("Loaded:")) {
|
||||||
if (profile[i].indexOf(QString("enabled")) > -1) {
|
if (profile[i].indexOf(QString("enabled")) > -1)
|
||||||
value = QString("enabled");
|
value = QString("enabled");
|
||||||
break;
|
else if (profile[i].indexOf(QString("static")) > -1)
|
||||||
}
|
|
||||||
else if (profile[i].indexOf(QString("static")) > -1) {
|
|
||||||
value = QString("static");
|
value = QString("static");
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setData(source, QString("value"), value);
|
setData(source, QString("value"), value);
|
||||||
|
@ -75,22 +75,37 @@ void Netctl::init()
|
|||||||
iconFrame->setLayout(iconLayout);
|
iconFrame->setLayout(iconLayout);
|
||||||
iconLayout->addItem(iconWidget);
|
iconLayout->addItem(iconWidget);
|
||||||
fullSpaceLayout->addItem(iconFrame);
|
fullSpaceLayout->addItem(iconFrame);
|
||||||
// text
|
|
||||||
textFrame = new Plasma::Frame();
|
|
||||||
QGraphicsLinearLayout *textLayout = new QGraphicsLinearLayout();
|
|
||||||
textLabel = new Plasma::Label();
|
|
||||||
textLayout->addItem(textLabel);
|
|
||||||
textFrame->setLayout(textLayout);
|
|
||||||
fullSpaceLayout->addItem(textFrame);
|
|
||||||
textFrame->hide();
|
|
||||||
// stretch
|
|
||||||
fullSpaceLayout->addStretch(1);
|
|
||||||
|
|
||||||
// read variables
|
// read variables
|
||||||
configChanged();
|
configChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Netctl::addTextFrame(const bool state)
|
||||||
|
{
|
||||||
|
if (state) {
|
||||||
|
textFrame = new Plasma::Frame();
|
||||||
|
QGraphicsLinearLayout *textLayout = new QGraphicsLinearLayout();
|
||||||
|
textLabel = new Plasma::Label();
|
||||||
|
textLayout->addItem(textLabel);
|
||||||
|
textFrame->setLayout(textLayout);
|
||||||
|
fullSpaceLayout->addItem(textFrame);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fullSpaceLayout->removeItem(textFrame);
|
||||||
|
delete textLabel;
|
||||||
|
delete textFrame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Netctl::updateWidget()
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
resize(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// context menu
|
// context menu
|
||||||
void Netctl::startProfileSlot(QAction *profile)
|
void Netctl::startProfileSlot(QAction *profile)
|
||||||
{
|
{
|
||||||
@ -100,9 +115,10 @@ void Netctl::startProfileSlot(QAction *profile)
|
|||||||
if (status)
|
if (status)
|
||||||
commandLine = netctlPath + QString(" stop ") + profileName + QString(" && ");
|
commandLine = netctlPath + QString(" stop ") + profileName + QString(" && ");
|
||||||
if (useSudo)
|
if (useSudo)
|
||||||
commandLine = sudoPath + QString(" \"") + commandLine + netctlPath + QString(" start ") + profile->text().mid(1) + QString("\"");
|
commandLine = sudoPath + QString(" \"") + commandLine +
|
||||||
|
netctlPath + QString(" start ") + profile->text().remove(QString("&")) + QString("\"");
|
||||||
else
|
else
|
||||||
commandLine = commandLine + netctlPath + QString(" start ") + profile->text().mid(1);
|
commandLine = commandLine + netctlPath + QString(" start ") + profile->text().remove(QString("&"));
|
||||||
command.startDetached(commandLine);
|
command.startDetached(commandLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,10 +151,10 @@ void Netctl::enableProfileAutoloadSlot()
|
|||||||
{
|
{
|
||||||
QProcess command;
|
QProcess command;
|
||||||
QString commandLine, enableStatus;
|
QString commandLine, enableStatus;
|
||||||
if (profileStatus == QString("(enable"))
|
if (profileStatus.contains(QString("enabled")))
|
||||||
enableStatus = QString("disable");
|
enableStatus = QString(" disable ");
|
||||||
else
|
else
|
||||||
enableStatus = QString("enable");
|
enableStatus = QString(" enable ");
|
||||||
if (useSudo)
|
if (useSudo)
|
||||||
commandLine = sudoPath + QString(" \"") + netctlPath + enableStatus + profileName + QString("\"");
|
commandLine = sudoPath + QString(" \"") + netctlPath + enableStatus + profileName + QString("\"");
|
||||||
else
|
else
|
||||||
@ -180,7 +196,7 @@ QList<QAction*> Netctl::contextualActions()
|
|||||||
restartProfile->setVisible(true);
|
restartProfile->setVisible(true);
|
||||||
restartProfile->setText(QString("Restart ") + profileName);
|
restartProfile->setText(QString("Restart ") + profileName);
|
||||||
enableProfileAutoload->setVisible(true);
|
enableProfileAutoload->setVisible(true);
|
||||||
if (profileStatus == QString("(enable"))
|
if (profileStatus.contains(QString("enabled")))
|
||||||
enableProfileAutoload->setText(QString("Disable ") + profileName);
|
enableProfileAutoload->setText(QString("Disable ") + profileName);
|
||||||
else
|
else
|
||||||
enableProfileAutoload->setText(QString("Enable ") + profileName);
|
enableProfileAutoload->setText(QString("Enable ") + profileName);
|
||||||
@ -235,8 +251,9 @@ void Netctl::connectToEngine()
|
|||||||
netctlEngine->connectSource(QString("intIp"), this, autoUpdateInterval);
|
netctlEngine->connectSource(QString("intIp"), this, autoUpdateInterval);
|
||||||
if (showNetDev)
|
if (showNetDev)
|
||||||
netctlEngine->connectSource(QString("interfaces"), this, autoUpdateInterval);
|
netctlEngine->connectSource(QString("interfaces"), this, autoUpdateInterval);
|
||||||
textFrame->show();
|
addTextFrame(true);
|
||||||
}
|
}
|
||||||
|
updateWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -253,9 +270,9 @@ void Netctl::disconnectFromEngine()
|
|||||||
netctlEngine->disconnectSource(QString("intIp"), this);
|
netctlEngine->disconnectSource(QString("intIp"), this);
|
||||||
if (showNetDev)
|
if (showNetDev)
|
||||||
netctlEngine->disconnectSource(QString("interfaces"), this);
|
netctlEngine->disconnectSource(QString("interfaces"), this);
|
||||||
textFrame->hide();
|
addTextFrame(false);
|
||||||
}
|
}
|
||||||
update();
|
updateWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -263,7 +280,7 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
|
|||||||
{
|
{
|
||||||
if (data.keys().count() == 0)
|
if (data.keys().count() == 0)
|
||||||
return;
|
return;
|
||||||
QString value = data[QString("value")].toString();;
|
QString value = data[QString("value")].toString();
|
||||||
if (value.isEmpty())
|
if (value.isEmpty())
|
||||||
value = QString("N\\A");
|
value = QString("N\\A");
|
||||||
|
|
||||||
@ -280,6 +297,7 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
|
|||||||
if (showNetDev)
|
if (showNetDev)
|
||||||
text.append(interfaces);
|
text.append(interfaces);
|
||||||
textLabel->setText(formatLine[0] + text.join(QString("<br>")) + formatLine[1]);
|
textLabel->setText(formatLine[0] + text.join(QString("<br>")) + formatLine[1]);
|
||||||
|
updateWidget();
|
||||||
}
|
}
|
||||||
else if (sourceName == QString("extIp")) {
|
else if (sourceName == QString("extIp")) {
|
||||||
extIp = value;
|
extIp = value;
|
||||||
|
@ -52,6 +52,9 @@ public slots:
|
|||||||
void setSudo();
|
void setSudo();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
// main interface
|
||||||
|
void addTextFrame(const bool state = true);
|
||||||
|
void updateWidget();
|
||||||
// configuration interface
|
// configuration interface
|
||||||
void selectGuiExe();
|
void selectGuiExe();
|
||||||
void selectNetctlExe();
|
void selectNetctlExe();
|
||||||
|
Loading…
Reference in New Issue
Block a user