mirror of
https://github.com/arcan1s/netctl-gui.git
synced 2025-07-06 18:45:46 +00:00
commit before editing menu
This commit is contained in:
@ -86,30 +86,86 @@ void Netctl::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// context menu
|
||||||
|
void Netctl::startProfileSlot()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Netctl::stopProfileSlot()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Netctl::restartProfileSlot()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Netctl::enableProfileAutoloadSlot()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Netctl::createActions()
|
void Netctl::createActions()
|
||||||
{
|
{
|
||||||
// helpAction = new QAction( KIcon( "help-about" ), i18n( "Help" ), this );
|
menuActions.clear();
|
||||||
// helpAction->setMenu( ( QMenu* ) (new KHelpMenu( NULL, about, false ) )->menu() );
|
|
||||||
|
startProfile = new QAction(QString("Start profile"), this);
|
||||||
|
menuActions.append(startProfile);
|
||||||
|
|
||||||
|
stopProfile = new QAction(QString("Stop profile"), this);
|
||||||
|
connect(stopProfile, SIGNAL(triggered(bool)), this, SLOT(stopProfileSlot()));
|
||||||
|
menuActions.append(stopProfile);
|
||||||
|
|
||||||
|
restartProfile = new QAction(QString("Restart profile"), this);
|
||||||
|
connect(restartProfile, SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot()));
|
||||||
|
menuActions.append(restartProfile);
|
||||||
|
|
||||||
|
enableProfileAutoload = new QAction(QString("Enable profile"), this);
|
||||||
|
connect(enableProfileAutoload, SIGNAL(triggered(bool)), this, SLOT(enableProfileAutoloadSlot()));
|
||||||
|
menuActions.append(enableProfileAutoload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QList<QAction*> Netctl::contextualActions()
|
QList<QAction*> Netctl::contextualActions()
|
||||||
{
|
{
|
||||||
QList<QAction*> menuActions;
|
if (status) {
|
||||||
|
startProfile->setText(QString("Start another profile"));
|
||||||
|
stopProfile->setVisible(true);
|
||||||
|
stopProfile->setText(QString("Stop ") + profileName);
|
||||||
|
restartProfile->setVisible(true);
|
||||||
|
restartProfile->setText(QString("Restart ") + profileName);
|
||||||
|
enableProfileAutoload->setVisible(true);
|
||||||
|
if (profileStatus == QString("(enable"))
|
||||||
|
enableProfileAutoload->setText(QString("Disable ") + profileName);
|
||||||
|
else
|
||||||
|
enableProfileAutoload->setText(QString("Enable ") + profileName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
startProfile->setText(QString("Start profile"));
|
||||||
|
stopProfile->setVisible(false);
|
||||||
|
restartProfile->setVisible(false);
|
||||||
|
enableProfileAutoload->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
return menuActions;
|
return menuActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Netctl::showGui()
|
// events
|
||||||
|
void Netctl::showGui()
|
||||||
{
|
{
|
||||||
QProcess command;
|
QProcess command;
|
||||||
command.startDetached(guiPath);
|
command.startDetached(guiPath);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Netctl::sendNotification(QString eventId, int num)
|
void Netctl::sendNotification(const QString eventId, const int num)
|
||||||
{
|
{
|
||||||
// send notification
|
// send notification
|
||||||
KNotification *notification = new KNotification(eventId);
|
KNotification *notification = new KNotification(eventId);
|
||||||
@ -118,7 +174,6 @@ int Netctl::sendNotification(QString eventId, int num)
|
|||||||
notification->setText("test");
|
notification->setText("test");
|
||||||
notification->sendEvent();
|
notification->sendEvent();
|
||||||
delete notification;
|
delete notification;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -128,9 +183,9 @@ void Netctl::connectToEngine()
|
|||||||
Plasma::DataEngine *netctlEngine = dataEngine(QString("netctl"));
|
Plasma::DataEngine *netctlEngine = dataEngine(QString("netctl"));
|
||||||
netctlEngine->connectSource(QString("profiles"), this, autoUpdateInterval);
|
netctlEngine->connectSource(QString("profiles"), this, autoUpdateInterval);
|
||||||
netctlEngine->connectSource(QString("statusBool"), this, autoUpdateInterval);
|
netctlEngine->connectSource(QString("statusBool"), this, autoUpdateInterval);
|
||||||
|
netctlEngine->connectSource(QString("currentProfile"), this, autoUpdateInterval);
|
||||||
|
netctlEngine->connectSource(QString("statusString"), this, autoUpdateInterval);
|
||||||
if (showBigInterface) {
|
if (showBigInterface) {
|
||||||
netctlEngine->connectSource(QString("currentProfile"), this, autoUpdateInterval);
|
|
||||||
netctlEngine->connectSource(QString("statusString"), this, autoUpdateInterval);
|
|
||||||
if (showExtIp)
|
if (showExtIp)
|
||||||
netctlEngine->connectSource(QString("extIp"), this, autoUpdateInterval);
|
netctlEngine->connectSource(QString("extIp"), this, autoUpdateInterval);
|
||||||
if (showIntIp)
|
if (showIntIp)
|
||||||
@ -147,9 +202,9 @@ void Netctl::disconnectFromEngine()
|
|||||||
Plasma::DataEngine *netctlEngine = dataEngine(QString("netctl"));
|
Plasma::DataEngine *netctlEngine = dataEngine(QString("netctl"));
|
||||||
netctlEngine->disconnectSource(QString("profiles"), this);
|
netctlEngine->disconnectSource(QString("profiles"), this);
|
||||||
netctlEngine->disconnectSource(QString("statusBool"), this);
|
netctlEngine->disconnectSource(QString("statusBool"), this);
|
||||||
|
netctlEngine->disconnectSource(QString("currentProfile"), this);
|
||||||
|
netctlEngine->disconnectSource(QString("statusString"), this);
|
||||||
if (showBigInterface) {
|
if (showBigInterface) {
|
||||||
netctlEngine->disconnectSource(QString("currentProfile"), this);
|
|
||||||
netctlEngine->disconnectSource(QString("statusString"), this);
|
|
||||||
if (showExtIp)
|
if (showExtIp)
|
||||||
netctlEngine->disconnectSource(QString("extIp"), this);
|
netctlEngine->disconnectSource(QString("extIp"), this);
|
||||||
if (showIntIp)
|
if (showIntIp)
|
||||||
@ -203,10 +258,14 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (sourceName == QString("statusBool")) {
|
else if (sourceName == QString("statusBool")) {
|
||||||
if (value == QString("true"))
|
if (value == QString("true")) {
|
||||||
|
status = true;
|
||||||
iconWidget->setIcon(activeIconPath);
|
iconWidget->setIcon(activeIconPath);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
iconWidget->setIcon(inactiveIconPath);
|
iconWidget->setIcon(inactiveIconPath);
|
||||||
|
status = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (sourceName == QString("statusString")) {
|
else if (sourceName == QString("statusString")) {
|
||||||
profileStatus = QString("(") + value + QString(")");
|
profileStatus = QString("(") + value + QString(")");
|
||||||
@ -369,7 +428,7 @@ void Netctl::configChanged()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Netctl::setBigInterface()
|
void Netctl::setBigInterface()
|
||||||
{
|
{
|
||||||
if (uiConfig.checkBox_showBigInterface->checkState() == 0) {
|
if (uiConfig.checkBox_showBigInterface->checkState() == 0) {
|
||||||
uiConfig.checkBox_showNetDev->setDisabled(true);
|
uiConfig.checkBox_showNetDev->setDisabled(true);
|
||||||
@ -381,9 +440,6 @@ int Netctl::setBigInterface()
|
|||||||
uiConfig.checkBox_showExtIp->setEnabled(true);
|
uiConfig.checkBox_showExtIp->setEnabled(true);
|
||||||
uiConfig.checkBox_showIntIp->setEnabled(true);
|
uiConfig.checkBox_showIntIp->setEnabled(true);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,21 +37,27 @@ public:
|
|||||||
void init();
|
void init();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// ui
|
// events
|
||||||
int showGui();
|
void showGui();
|
||||||
int sendNotification(QString eventId, int num);
|
void sendNotification(const QString eventId, const int num);
|
||||||
// for dataengine
|
// dataengine
|
||||||
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
|
void dataUpdated(const QString &sourceName, const Plasma::DataEngine::Data &data);
|
||||||
// for configuration interface
|
// configuration interface
|
||||||
void configAccepted();
|
void configAccepted();
|
||||||
void configChanged();
|
void configChanged();
|
||||||
int setBigInterface();
|
void setBigInterface();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
// configuration interface
|
||||||
void selectGuiExe();
|
void selectGuiExe();
|
||||||
void selectNetctlExe();
|
void selectNetctlExe();
|
||||||
void selectActiveIcon();
|
void selectActiveIcon();
|
||||||
void selectInactiveIcon();
|
void selectInactiveIcon();
|
||||||
|
// context menu
|
||||||
|
void startProfileSlot();
|
||||||
|
void stopProfileSlot();
|
||||||
|
void restartProfileSlot();
|
||||||
|
void enableProfileAutoloadSlot();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void createConfigurationInterface(KConfigDialog *parent);
|
void createConfigurationInterface(KConfigDialog *parent);
|
||||||
@ -66,6 +72,7 @@ private:
|
|||||||
// text
|
// text
|
||||||
Plasma::Frame *textFrame;
|
Plasma::Frame *textFrame;
|
||||||
Plasma::Label *textLabel;
|
Plasma::Label *textLabel;
|
||||||
|
bool status;
|
||||||
QString profileName;
|
QString profileName;
|
||||||
QString profileStatus;
|
QString profileStatus;
|
||||||
QString intIp;
|
QString intIp;
|
||||||
@ -74,7 +81,9 @@ private:
|
|||||||
QStringList formatLine;
|
QStringList formatLine;
|
||||||
// context menu
|
// context menu
|
||||||
void createActions();
|
void createActions();
|
||||||
|
QList<QAction*> menuActions;
|
||||||
QAction *startProfile;
|
QAction *startProfile;
|
||||||
|
QAction *stopProfile;
|
||||||
QAction *restartProfile;
|
QAction *restartProfile;
|
||||||
QAction *enableProfileAutoload;
|
QAction *enableProfileAutoload;
|
||||||
// data engine
|
// data engine
|
||||||
|
Reference in New Issue
Block a user