changes before renaming

This commit is contained in:
arcan1s 2014-03-06 22:10:27 +04:00
parent 682b6c5b4f
commit 028b636d22
3 changed files with 44 additions and 26 deletions

View File

@ -206,16 +206,13 @@ 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);
} }

View File

@ -75,19 +75,34 @@ void Netctl::init()
iconFrame->setLayout(iconLayout); iconFrame->setLayout(iconLayout);
iconLayout->addItem(iconWidget); iconLayout->addItem(iconWidget);
fullSpaceLayout->addItem(iconFrame); fullSpaceLayout->addItem(iconFrame);
// text
// read variables
configChanged();
}
void Netctl::addTextFrame(const bool state)
{
if (state) {
textFrame = new Plasma::Frame(); textFrame = new Plasma::Frame();
QGraphicsLinearLayout *textLayout = new QGraphicsLinearLayout(); QGraphicsLinearLayout *textLayout = new QGraphicsLinearLayout();
textLabel = new Plasma::Label(); textLabel = new Plasma::Label();
textLayout->addItem(textLabel); textLayout->addItem(textLabel);
textFrame->setLayout(textLayout); textFrame->setLayout(textLayout);
fullSpaceLayout->addItem(textFrame); fullSpaceLayout->addItem(textFrame);
textFrame->hide(); }
// stretch else {
fullSpaceLayout->addStretch(1); fullSpaceLayout->removeItem(textFrame);
delete textLabel;
delete textFrame;
}
}
// read variables
configChanged(); void Netctl::updateWidget()
{
update();
resize(0, 0);
} }
@ -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,7 +151,7 @@ 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 ");
@ -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;

View File

@ -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();