small changes before work on plasmoid

This commit is contained in:
arcan1s
2014-03-21 19:11:47 +04:00
parent 028b636d22
commit 80e4b3e3d3
5 changed files with 21 additions and 32 deletions

View File

@ -71,34 +71,31 @@ void Netctl::init()
iconFrame = new Plasma::Frame();
QGraphicsLinearLayout *iconLayout = new QGraphicsLinearLayout();
iconWidget = new Plasma::IconWidget(KIcon(""), QString(), this);
iconWidget->setPreferredWidth(30);
iconWidget->setPreferredHeight(30);
iconWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
connect(iconWidget, SIGNAL(doubleClicked()), this, SLOT(showGui()));
iconFrame->setLayout(iconLayout);
iconLayout->addItem(iconWidget);
fullSpaceLayout->addItem(iconFrame);
// text
textFrame = new Plasma::Frame();
QGraphicsLinearLayout *textLayout = new QGraphicsLinearLayout();
textLabel = new Plasma::Label();
textLabel->setPreferredHeight(30);
textLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
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();
@ -251,7 +248,7 @@ void Netctl::connectToEngine()
netctlEngine->connectSource(QString("intIp"), this, autoUpdateInterval);
if (showNetDev)
netctlEngine->connectSource(QString("interfaces"), this, autoUpdateInterval);
addTextFrame(true);
textFrame->show();
}
updateWidget();
}
@ -270,7 +267,7 @@ void Netctl::disconnectFromEngine()
netctlEngine->disconnectSource(QString("intIp"), this);
if (showNetDev)
netctlEngine->disconnectSource(QString("interfaces"), this);
addTextFrame(false);
textFrame->hide();
}
updateWidget();
}