mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-04-24 15:37:23 +00:00
add click event, remove button
TODO: refactoring (including removal of unneeded pointers) and normal resize event
This commit is contained in:
parent
c1e23d38a9
commit
eefe196b69
@ -28,13 +28,36 @@
|
|||||||
#include <plasma/theme.h>
|
#include <plasma/theme.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QGraphicsLinearLayout>
|
#include <QGraphicsSceneMouseEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
|
||||||
|
|
||||||
|
IconLabel::IconLabel(Netctl *wid, const bool debugCmd)
|
||||||
|
: QLabel(),
|
||||||
|
debug(debugCmd),
|
||||||
|
widget(wid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
IconLabel::~IconLabel()
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[PLASMOID]" << "[IconLabel]";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void IconLabel::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
if (debug) qDebug() << "[PLASMOID]" << "[mousePressEvent]";
|
||||||
|
|
||||||
|
if (event->button() == Qt::LeftButton)
|
||||||
|
widget->showGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Netctl::Netctl(QObject *parent, const QVariantList &args)
|
Netctl::Netctl(QObject *parent, const QVariantList &args)
|
||||||
: Plasma::PopupApplet(parent, args)
|
: Plasma::PopupApplet(parent, args)
|
||||||
{
|
{
|
||||||
@ -48,6 +71,7 @@ Netctl::Netctl(QObject *parent, const QVariantList &args)
|
|||||||
|
|
||||||
this->setBackgroundHints(DefaultBackground);
|
this->setBackgroundHints(DefaultBackground);
|
||||||
this->setHasConfigurationInterface(true);
|
this->setHasConfigurationInterface(true);
|
||||||
|
connect(this, SIGNAL(activate()), this, SLOT(showGui()));
|
||||||
// text format init
|
// text format init
|
||||||
formatLine.append(QString(""));
|
formatLine.append(QString(""));
|
||||||
formatLine.append(QString(""));
|
formatLine.append(QString(""));
|
||||||
@ -81,23 +105,15 @@ void Netctl::init()
|
|||||||
netctlEngine = dataEngine(QString("netctl"));
|
netctlEngine = dataEngine(QString("netctl"));
|
||||||
createActions();
|
createActions();
|
||||||
// generate ui
|
// generate ui
|
||||||
graphicsWidget = new QGraphicsWidget();
|
graphicsWidget = new QWidget();
|
||||||
this->setGraphicsWidget(graphicsWidget);
|
graphicsWidget->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||||
// main layout
|
this->setWidget(graphicsWidget);
|
||||||
fullSpaceLayout = new QGraphicsLinearLayout(graphicsWidget);
|
// layouts
|
||||||
fullSpaceLayout->setContentsMargins(1, 1, 1, 1);
|
layout = new QHBoxLayout(graphicsWidget);
|
||||||
graphicsWidget->setLayout(fullSpaceLayout);
|
layout->setContentsMargins(1, 1, 1, 1);
|
||||||
|
iconLabel = new IconLabel(this, debug);
|
||||||
// frames
|
layout->addWidget(iconLabel);
|
||||||
// icon
|
layout->addWidget(&textLabel);
|
||||||
iconWidget = new Plasma::IconWidget(KIcon(""), QString(), this);
|
|
||||||
iconWidget->setPreferredSize(30, 30);
|
|
||||||
connect(iconWidget, SIGNAL(clicked()), this, SLOT(showGui()));
|
|
||||||
fullSpaceLayout->addItem(iconWidget);
|
|
||||||
// text
|
|
||||||
textLabel = new Plasma::Label();
|
|
||||||
textLabel->setPreferredHeight(30);
|
|
||||||
fullSpaceLayout->addItem(textLabel);
|
|
||||||
|
|
||||||
// read variables
|
// read variables
|
||||||
configChanged();
|
configChanged();
|
||||||
@ -198,8 +214,10 @@ void Netctl::updateIcon()
|
|||||||
else
|
else
|
||||||
icon = paths[QString("inactive")];
|
icon = paths[QString("inactive")];
|
||||||
|
|
||||||
iconWidget->setIcon(icon);
|
|
||||||
this->setPopupIcon(KIcon(icon));
|
this->setPopupIcon(KIcon(icon));
|
||||||
|
QPixmap iconPixmap;
|
||||||
|
iconPixmap.load(icon);
|
||||||
|
iconLabel->setPixmap(iconPixmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -208,16 +226,9 @@ void Netctl::updateInterface(bool setShown)
|
|||||||
if (debug) qDebug() << "[PLASMOID]" << "[updateInterface]";
|
if (debug) qDebug() << "[PLASMOID]" << "[updateInterface]";
|
||||||
if (debug) qDebug() << "[PLASMOID]" << "[updateInterface]" << ":" << "State" << setShown;
|
if (debug) qDebug() << "[PLASMOID]" << "[updateInterface]" << ":" << "State" << setShown;
|
||||||
|
|
||||||
if (setShown) {
|
textLabel.setHidden(!setShown);
|
||||||
textLabel->show();
|
layout->setSizeConstraint(QLayout::SetMinimumSize);
|
||||||
fullSpaceLayout->updateGeometry();
|
graphicsWidget->resize(1, 1);
|
||||||
updateGeometry();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
textLabel->hide();
|
|
||||||
fullSpaceLayout->updateGeometry();
|
|
||||||
updateGeometry();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -523,7 +534,7 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
|
|||||||
if (bigInterface[QString("netDev")])
|
if (bigInterface[QString("netDev")])
|
||||||
text.append(info[QString("interfaces")]);
|
text.append(info[QString("interfaces")]);
|
||||||
if (bigInterface[QString("main")])
|
if (bigInterface[QString("main")])
|
||||||
textLabel->setText(formatLine[0] + text.join(QString("<br>")) + formatLine[1]);
|
textLabel.setText(formatLine[0] + text.join(QString("<br>")) + formatLine[1]);
|
||||||
}
|
}
|
||||||
else if (sourceName == QString("extIp")) {
|
else if (sourceName == QString("extIp")) {
|
||||||
info[QString("extIp")] = value;
|
info[QString("extIp")] = value;
|
||||||
|
@ -18,11 +18,7 @@
|
|||||||
#ifndef NETCTL_PLASMOID_H
|
#ifndef NETCTL_PLASMOID_H
|
||||||
#define NETCTL_PLASMOID_H
|
#define NETCTL_PLASMOID_H
|
||||||
|
|
||||||
#include <Plasma/Applet>
|
|
||||||
#include <Plasma/DataEngine>
|
#include <Plasma/DataEngine>
|
||||||
#include <Plasma/Frame>
|
|
||||||
#include <Plasma/IconWidget>
|
|
||||||
#include <Plasma/Label>
|
|
||||||
#include <Plasma/PopupApplet>
|
#include <Plasma/PopupApplet>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
@ -33,6 +29,23 @@
|
|||||||
|
|
||||||
|
|
||||||
class QGraphicsLinearLayout;
|
class QGraphicsLinearLayout;
|
||||||
|
class Netctl;
|
||||||
|
|
||||||
|
class IconLabel : public QLabel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
IconLabel(Netctl *wid, const bool debugCmd);
|
||||||
|
~IconLabel();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool debug;
|
||||||
|
Netctl *widget;
|
||||||
|
};
|
||||||
|
|
||||||
class Netctl : public Plasma::PopupApplet
|
class Netctl : public Plasma::PopupApplet
|
||||||
{
|
{
|
||||||
@ -92,12 +105,11 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// ui
|
// ui
|
||||||
QGraphicsWidget *graphicsWidget;
|
QWidget *graphicsWidget;
|
||||||
QGraphicsLinearLayout *fullSpaceLayout;
|
QHBoxLayout *layout;
|
||||||
// icon
|
IconLabel *iconLabel;
|
||||||
Plasma::IconWidget *iconWidget;
|
QLabel textLabel;
|
||||||
// text
|
// information
|
||||||
Plasma::Label *textLabel;
|
|
||||||
bool status;
|
bool status;
|
||||||
QMap<QString, QString> info;
|
QMap<QString, QString> info;
|
||||||
QStringList profileList;
|
QStringList profileList;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>480</width>
|
<width>480</width>
|
||||||
<height>339</height>
|
<height>337</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@ -20,16 +20,6 @@
|
|||||||
<string notr="true">Configuration Window</string>
|
<string notr="true">Configuration Window</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_info">
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="layout_autoUpdate">
|
<layout class="QHBoxLayout" name="layout_autoUpdate">
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
Reference in New Issue
Block a user