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,14 +206,11 @@ bool Netctl::updateSourceEvent(const QString &source)
QStringList profile = cmdOutput.split(QString("\n"), QString::SkipEmptyParts);
for (int i=0; i<profile.count(); i++)
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");
break;
}
else if (profile[i].indexOf(QString("static")) > -1) {
else if (profile[i].indexOf(QString("static")) > -1)
value = QString("static");
break;
}
break;
}
}
setData(source, QString("value"), value);

View File

@ -75,22 +75,37 @@ void Netctl::init()
iconFrame->setLayout(iconLayout);
iconLayout->addItem(iconWidget);
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
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
void Netctl::startProfileSlot(QAction *profile)
{
@ -100,9 +115,10 @@ void Netctl::startProfileSlot(QAction *profile)
if (status)
commandLine = netctlPath + QString(" stop ") + profileName + QString(" && ");
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
commandLine = commandLine + netctlPath + QString(" start ") + profile->text().mid(1);
commandLine = commandLine + netctlPath + QString(" start ") + profile->text().remove(QString("&"));
command.startDetached(commandLine);
}
@ -135,10 +151,10 @@ void Netctl::enableProfileAutoloadSlot()
{
QProcess command;
QString commandLine, enableStatus;
if (profileStatus == QString("(enable"))
enableStatus = QString("disable");
if (profileStatus.contains(QString("enabled")))
enableStatus = QString(" disable ");
else
enableStatus = QString("enable");
enableStatus = QString(" enable ");
if (useSudo)
commandLine = sudoPath + QString(" \"") + netctlPath + enableStatus + profileName + QString("\"");
else
@ -180,7 +196,7 @@ QList<QAction*> Netctl::contextualActions()
restartProfile->setVisible(true);
restartProfile->setText(QString("Restart ") + profileName);
enableProfileAutoload->setVisible(true);
if (profileStatus == QString("(enable"))
if (profileStatus.contains(QString("enabled")))
enableProfileAutoload->setText(QString("Disable ") + profileName);
else
enableProfileAutoload->setText(QString("Enable ") + profileName);
@ -235,8 +251,9 @@ void Netctl::connectToEngine()
netctlEngine->connectSource(QString("intIp"), this, autoUpdateInterval);
if (showNetDev)
netctlEngine->connectSource(QString("interfaces"), this, autoUpdateInterval);
textFrame->show();
addTextFrame(true);
}
updateWidget();
}
@ -253,9 +270,9 @@ void Netctl::disconnectFromEngine()
netctlEngine->disconnectSource(QString("intIp"), this);
if (showNetDev)
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)
return;
QString value = data[QString("value")].toString();;
QString value = data[QString("value")].toString();
if (value.isEmpty())
value = QString("N\\A");
@ -280,6 +297,7 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
if (showNetDev)
text.append(interfaces);
textLabel->setText(formatLine[0] + text.join(QString("<br>")) + formatLine[1]);
updateWidget();
}
else if (sourceName == QString("extIp")) {
extIp = value;

View File

@ -52,6 +52,9 @@ public slots:
void setSudo();
private slots:
// main interface
void addTextFrame(const bool state = true);
void updateWidget();
// configuration interface
void selectGuiExe();
void selectNetctlExe();