added notifications

This commit is contained in:
arcan1s 2014-04-07 00:31:42 +04:00
parent cc2b3faf85
commit c4c407542f
8 changed files with 167 additions and 55 deletions

View File

@ -1,5 +1,6 @@
Ver.1.0.4: Ver.1.0.4:
+ added Qt5 gui (by default) + added Qt5 gui (by default)
+ added notifications
Ver.1.0.3: Ver.1.0.3:
+ [plasmoid] edited russian translation + [plasmoid] edited russian translation

View File

@ -8,7 +8,7 @@
pkgname=netctl-gui pkgname=netctl-gui
pkgver=1.0.4 pkgver=1.0.4
pkgrel=1 pkgrel=1
pkgdesc="Qt GUI for netctl. Provides a plasmoid for KDE4" pkgdesc="Qt4/Qt5 GUI for netctl. Provides a plasmoid for KDE4"
arch=('i686' 'x86_64') arch=('i686' 'x86_64')
url="http://arcanis.name/projects/netctl-gui" url="http://arcanis.name/projects/netctl-gui"
license=('GPLv3') license=('GPLv3')
@ -19,7 +19,7 @@ optdepends=('kdebase-runtime: sudo support'
'wpa_supplicant: wifi support') 'wpa_supplicant: wifi support')
source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgname}-${pkgver}-src.tar.xz") source=("https://github.com/arcan1s/netctl-gui/releases/download/V.${pkgver}/${pkgname}-${pkgver}-src.tar.xz")
install="${pkgname}.install" install="${pkgname}.install"
md5sums=('df44243e2dc1acf1536ab58be9af0081') md5sums=('6bb4897a9244cf5b9c2e45dff43c07b2')
# flags # flags
_cmakekeys="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release" _cmakekeys="-DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release"

View File

@ -30,6 +30,8 @@ else ()
message (STATUS "Unknown compiler") message (STATUS "Unknown compiler")
endif () endif ()
add_subdirectory (icons)
if (BUILD_PLASMOID) if (BUILD_PLASMOID)
set (BUILD_DATAENGINE ON) set (BUILD_DATAENGINE ON)
endif () endif ()

View File

@ -47,7 +47,7 @@ Netctl::~Netctl()
// delete startProfile; // delete startProfile;
// delete stopProfile; // delete stopProfile;
// delete restartProfile; // delete restartProfile;
// delete enableProfileAutoload; // delete enableProfile;
// delete iconWidget; // delete iconWidget;
@ -103,14 +103,18 @@ void Netctl::updateInterface(bool setShown)
// context menu // context menu
void Netctl::enableProfileAutoloadSlot() void Netctl::enableProfileSlot()
{ {
QProcess command; QProcess command;
QString commandLine, enableStatus; QString commandLine, enableStatus;
if (info[QString("status")].contains(QString("enabled"))) if (info[QString("status")].contains(QString("enabled"))) {
enableStatus = QString(" disable "); enableStatus = QString(" disable ");
else sendNotification(QString("Info"), i18n("Set profile %1 disabled", info[QString("name")]));
}
else {
enableStatus = QString(" enable "); enableStatus = QString(" enable ");
sendNotification(QString("Info"), i18n("Set profile %1 enabled", info[QString("name")]));
}
if (useSudo) if (useSudo)
commandLine = paths[QString("sudo")] + QString(" \"") + paths[QString("netctl")] + commandLine = paths[QString("sudo")] + QString(" \"") + paths[QString("netctl")] +
enableStatus + info[QString("name")] + QString("\""); enableStatus + info[QString("name")] + QString("\"");
@ -125,6 +129,7 @@ void Netctl::startProfileSlot(QAction *profile)
QProcess command; QProcess command;
QString commandLine; QString commandLine;
commandLine = QString(""); commandLine = QString("");
sendNotification(QString("Info"), i18n("Start profile %1", profile->text().remove(QString("&"))));
if (status) if (status)
commandLine = paths[QString("netctl")] + QString(" stop ") + commandLine = paths[QString("netctl")] + QString(" stop ") +
info[QString("name")] + QString(" && "); info[QString("name")] + QString(" && ");
@ -143,6 +148,7 @@ void Netctl::stopProfileSlot()
{ {
QProcess command; QProcess command;
QString commandLine; QString commandLine;
sendNotification(QString("Info"), i18n("Stop profile %1", info[QString("name")]));
if (useSudo) if (useSudo)
commandLine = paths[QString("sudo")] + QString(" \"") + paths[QString("netctl")] + commandLine = paths[QString("sudo")] + QString(" \"") + paths[QString("netctl")] +
QString(" stop ") + info[QString("name")] + QString("\""); QString(" stop ") + info[QString("name")] + QString("\"");
@ -156,6 +162,7 @@ void Netctl::restartProfileSlot()
{ {
QProcess command; QProcess command;
QString commandLine; QString commandLine;
sendNotification(QString("Info"), i18n("Restart profile %1", info[QString("name")]));
if (useSudo) if (useSudo)
commandLine = paths[QString("sudo")] + QString(" \"") + paths[QString("netctl")] + commandLine = paths[QString("sudo")] + QString(" \"") + paths[QString("netctl")] +
QString(" restart ") + info[QString("name")] + QString("\""); QString(" restart ") + info[QString("name")] + QString("\"");
@ -173,17 +180,17 @@ QList<QAction*> Netctl::contextualActions()
stopProfile->setText(i18n("Stop ") + info[QString("name")]); stopProfile->setText(i18n("Stop ") + info[QString("name")]);
restartProfile->setVisible(true); restartProfile->setVisible(true);
restartProfile->setText(i18n("Restart ") + info[QString("name")]); restartProfile->setText(i18n("Restart ") + info[QString("name")]);
enableProfileAutoload->setVisible(true); enableProfile->setVisible(true);
if (info[QString("status")].contains(QString("enabled"))) if (info[QString("status")].contains(QString("enabled")))
enableProfileAutoload->setText(i18n("Disable ") + info[QString("name")]); enableProfile->setText(i18n("Disable ") + info[QString("name")]);
else else
enableProfileAutoload->setText(i18n("Enable ") + info[QString("name")]); enableProfile->setText(i18n("Enable ") + info[QString("name")]);
} }
else { else {
startProfile->setText(i18n("Start profile")); startProfile->setText(i18n("Start profile"));
stopProfile->setVisible(false); stopProfile->setVisible(false);
restartProfile->setVisible(false); restartProfile->setVisible(false);
enableProfileAutoload->setVisible(false); enableProfile->setVisible(false);
} }
startProfileMenu->clear(); startProfileMenu->clear();
@ -215,10 +222,9 @@ void Netctl::createActions()
connect(restartProfile, SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot())); connect(restartProfile, SIGNAL(triggered(bool)), this, SLOT(restartProfileSlot()));
menuActions.append(restartProfile); menuActions.append(restartProfile);
enableProfileAutoload = new QAction(i18n("Enable profile"), this); enableProfile = new QAction(i18n("Enable profile"), this);
connect(enableProfileAutoload, SIGNAL(triggered(bool)), this, connect(enableProfile, SIGNAL(triggered(bool)), this, SLOT(enableProfileSlot()));
SLOT(enableProfileAutoloadSlot())); menuActions.append(enableProfile);
menuActions.append(enableProfileAutoload);
} }
@ -227,7 +233,7 @@ void Netctl::sendNotification(const QString eventId, const QString message)
{ {
KNotification *notification = new KNotification(eventId); KNotification *notification = new KNotification(eventId);
notification->setComponentData(KComponentData("plasma_applet_netctl")); notification->setComponentData(KComponentData("plasma_applet_netctl"));
notification->setTitle(eventId); notification->setTitle(QString("Netctl ::: ") + eventId);
notification->setText(message); notification->setText(message);
notification->sendEvent(); notification->sendEvent();
delete notification; delete notification;
@ -236,6 +242,7 @@ void Netctl::sendNotification(const QString eventId, const QString message)
void Netctl::showGui() void Netctl::showGui()
{ {
sendNotification(QString("Info"), i18n("Start GUI"));
QProcess command; QProcess command;
command.startDetached(paths[QString("gui")]); command.startDetached(paths[QString("gui")]);
} }
@ -298,12 +305,16 @@ void Netctl::dataUpdated(const QString &sourceName, const Plasma::DataEngine::Da
} }
else if (sourceName == QString("statusBool")) { else if (sourceName == QString("statusBool")) {
if (value == QString("true")) { if (value == QString("true")) {
if (! status)
sendNotification(QString("Info"), i18n("Network is up"));
status = true; status = true;
iconWidget->setIcon(paths[QString("active")]); iconWidget->setIcon(paths[QString("active")]);
} }
else { else {
iconWidget->setIcon(paths[QString("inactive")]); if (status)
sendNotification(QString("Info"), i18n("Network is down"));
status = false; status = false;
iconWidget->setIcon(paths[QString("inactive")]);
} }
} }
else if (sourceName == QString("statusString")) { else if (sourceName == QString("statusString")) {

View File

@ -60,7 +60,7 @@ private slots:
void selectInactiveIcon(); void selectInactiveIcon();
void selectNetctlExe(); void selectNetctlExe();
// context menu // context menu
void enableProfileAutoloadSlot(); void enableProfileSlot();
void startProfileSlot(QAction *profile); void startProfileSlot(QAction *profile);
void stopProfileSlot(); void stopProfileSlot();
void restartProfileSlot(); void restartProfileSlot();
@ -83,7 +83,7 @@ private:
void createActions(); void createActions();
QList<QAction*> menuActions; QList<QAction*> menuActions;
QMenu *startProfileMenu; QMenu *startProfileMenu;
QAction *enableProfileAutoload; QAction *enableProfile;
QAction *startProfile; QAction *startProfile;
QAction *stopProfile; QAction *stopProfile;
QAction *restartProfile; QAction *restartProfile;

View File

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: http://kde-look.org/content/show.php?content=98925\n" "Report-Msgid-Bugs-To: http://kde-look.org/content/show.php?content=98925\n"
"POT-Creation-Date: 2014-04-06 18:45+0400\n" "POT-Creation-Date: 2014-04-07 00:27+0400\n"
"PO-Revision-Date: 2014-04-06 12:33+0400\n" "PO-Revision-Date: 2014-04-07 00:28+0400\n"
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n" "Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
"Language-Team: Russian <kde-russian@lists.kde.ru>\n" "Language-Team: Russian <kde-russian@lists.kde.ru>\n"
"Language: ru\n" "Language: ru\n"
@ -18,43 +18,75 @@ msgstr ""
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Lokalize 1.5\n" "X-Generator: Lokalize 1.5\n"
#: netctl.cpp:171 #: netctl.cpp:112
msgid "Set profile %1 disabled"
msgstr "Set profile %1 disabled"
#: netctl.cpp:116
msgid "Set profile %1 enabled"
msgstr "Set profile %1 enabled"
#: netctl.cpp:132
msgid "Start profile %1"
msgstr "Start profile %1"
#: netctl.cpp:151
msgid "Stop profile %1"
msgstr "Stop profile %1"
#: netctl.cpp:165
msgid "Restart profile %1"
msgstr "Restart profile %1"
#: netctl.cpp:178
msgid "Start another profile" msgid "Start another profile"
msgstr "Start another profile" msgstr "Start another profile"
#: netctl.cpp:173 #: netctl.cpp:180
msgid "Stop " msgid "Stop "
msgstr "Stop " msgstr "Stop "
#: netctl.cpp:175 #: netctl.cpp:182
msgid "Restart " msgid "Restart "
msgstr "Restart " msgstr "Restart "
#: netctl.cpp:178 #: netctl.cpp:185
msgid "Disable " msgid "Disable "
msgstr "Disable " msgstr "Disable "
#: netctl.cpp:180 #: netctl.cpp:187
msgid "Enable " msgid "Enable "
msgstr "Enable " msgstr "Enable "
#: netctl.cpp:183 netctl.cpp:203 #: netctl.cpp:190 netctl.cpp:210
msgid "Start profile" msgid "Start profile"
msgstr "Start profile" msgstr "Start profile"
#: netctl.cpp:210 #: netctl.cpp:217
msgid "Stop profile" msgid "Stop profile"
msgstr "Stop profile" msgstr "Stop profile"
#: netctl.cpp:214 #: netctl.cpp:221
msgid "Restart profile" msgid "Restart profile"
msgstr "Restart profile" msgstr "Restart profile"
#: netctl.cpp:218 #: netctl.cpp:225
msgid "Enable profile" msgid "Enable profile"
msgstr "Enable profile" msgstr "Enable profile"
#: netctl.cpp:420 #: netctl.cpp:245
msgid "Start GUI"
msgstr "Start GUI"
#: netctl.cpp:309
msgid "Network is up"
msgstr "Network is up"
#: netctl.cpp:315
msgid "Network is down"
msgstr "Network is down"
#: netctl.cpp:431
msgid "Netctl plasmoid" msgid "Netctl plasmoid"
msgstr "Netctl plasmoid" msgstr "Netctl plasmoid"
@ -232,3 +264,4 @@ msgstr "Evgeniy Alekseev"
msgctxt "EMAIL OF TRANSLATORS" msgctxt "EMAIL OF TRANSLATORS"
msgid "Your emails" msgid "Your emails"
msgstr "esalexeev@gmail.com" msgstr "esalexeev@gmail.com"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://kde-look.org/content/show.php?content=98925\n" "Report-Msgid-Bugs-To: http://kde-look.org/content/show.php?content=98925\n"
"POT-Creation-Date: 2014-04-06 18:45+0400\n" "POT-Creation-Date: 2014-04-07 00:27+0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,43 +17,75 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: netctl.cpp:171 #: netctl.cpp:112
msgid "Start another profile" msgid "Set profile %1 disabled"
msgstr "" msgstr ""
#: netctl.cpp:173 #: netctl.cpp:116
msgid "Stop " msgid "Set profile %1 enabled"
msgstr "" msgstr ""
#: netctl.cpp:175 #: netctl.cpp:132
msgid "Restart " msgid "Start profile %1"
msgstr ""
#: netctl.cpp:151
msgid "Stop profile %1"
msgstr ""
#: netctl.cpp:165
msgid "Restart profile %1"
msgstr "" msgstr ""
#: netctl.cpp:178 #: netctl.cpp:178
msgid "Disable " msgid "Start another profile"
msgstr "" msgstr ""
#: netctl.cpp:180 #: netctl.cpp:180
msgid "Stop "
msgstr ""
#: netctl.cpp:182
msgid "Restart "
msgstr ""
#: netctl.cpp:185
msgid "Disable "
msgstr ""
#: netctl.cpp:187
msgid "Enable " msgid "Enable "
msgstr "" msgstr ""
#: netctl.cpp:183 netctl.cpp:203 #: netctl.cpp:190 netctl.cpp:210
msgid "Start profile" msgid "Start profile"
msgstr "" msgstr ""
#: netctl.cpp:210 #: netctl.cpp:217
msgid "Stop profile" msgid "Stop profile"
msgstr "" msgstr ""
#: netctl.cpp:214 #: netctl.cpp:221
msgid "Restart profile" msgid "Restart profile"
msgstr "" msgstr ""
#: netctl.cpp:218 #: netctl.cpp:225
msgid "Enable profile" msgid "Enable profile"
msgstr "" msgstr ""
#: netctl.cpp:420 #: netctl.cpp:245
msgid "Start GUI"
msgstr ""
#: netctl.cpp:309
msgid "Network is up"
msgstr ""
#: netctl.cpp:315
msgid "Network is down"
msgstr ""
#: netctl.cpp:431
msgid "Netctl plasmoid" msgid "Netctl plasmoid"
msgstr "" msgstr ""

View File

@ -6,8 +6,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: http://kde-look.org/content/show.php?content=98925\n" "Report-Msgid-Bugs-To: http://kde-look.org/content/show.php?content=98925\n"
"POT-Creation-Date: 2014-04-06 18:45+0400\n" "POT-Creation-Date: 2014-04-07 00:27+0400\n"
"PO-Revision-Date: 2014-04-06 12:32+0400\n" "PO-Revision-Date: 2014-04-07 00:28+0400\n"
"Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n" "Last-Translator: Evgeniy Alekseev <esalexeev@gmail.com>\n"
"Language-Team: Russian <kde-russian@lists.kde.ru>\n" "Language-Team: Russian <kde-russian@lists.kde.ru>\n"
"Language: ru\n" "Language: ru\n"
@ -18,43 +18,75 @@ msgstr ""
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" "%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
"X-Generator: Lokalize 1.5\n" "X-Generator: Lokalize 1.5\n"
#: netctl.cpp:171 #: netctl.cpp:112
msgid "Set profile %1 disabled"
msgstr "Выключение автозагрузки профиля %1"
#: netctl.cpp:116
msgid "Set profile %1 enabled"
msgstr "Включение автозагрузки профиля %1"
#: netctl.cpp:132
msgid "Start profile %1"
msgstr "Запуск профиля %1"
#: netctl.cpp:151
msgid "Stop profile %1"
msgstr "Остановка профиля %1"
#: netctl.cpp:165
msgid "Restart profile %1"
msgstr "Перезапуск профиля %1"
#: netctl.cpp:178
msgid "Start another profile" msgid "Start another profile"
msgstr "Запустить другой профиль" msgstr "Запустить другой профиль"
#: netctl.cpp:173 #: netctl.cpp:180
msgid "Stop " msgid "Stop "
msgstr "Остановить " msgstr "Остановить "
#: netctl.cpp:175 #: netctl.cpp:182
msgid "Restart " msgid "Restart "
msgstr "Перезапустить " msgstr "Перезапустить "
#: netctl.cpp:178 #: netctl.cpp:185
msgid "Disable " msgid "Disable "
msgstr "Отключить " msgstr "Отключить "
#: netctl.cpp:180 #: netctl.cpp:187
msgid "Enable " msgid "Enable "
msgstr "Включить " msgstr "Включить "
#: netctl.cpp:183 netctl.cpp:203 #: netctl.cpp:190 netctl.cpp:210
msgid "Start profile" msgid "Start profile"
msgstr "Запустить профиль" msgstr "Запустить профиль"
#: netctl.cpp:210 #: netctl.cpp:217
msgid "Stop profile" msgid "Stop profile"
msgstr "Остановить профиль" msgstr "Остановить профиль"
#: netctl.cpp:214 #: netctl.cpp:221
msgid "Restart profile" msgid "Restart profile"
msgstr "Перезапустить профиль" msgstr "Перезапустить профиль"
#: netctl.cpp:218 #: netctl.cpp:225
msgid "Enable profile" msgid "Enable profile"
msgstr "Включить профиль" msgstr "Включить профиль"
#: netctl.cpp:420 #: netctl.cpp:245
msgid "Start GUI"
msgstr "Запуск GUI"
#: netctl.cpp:309
msgid "Network is up"
msgstr "Сеть работает"
#: netctl.cpp:315
msgid "Network is down"
msgstr "Сеть не работает"
#: netctl.cpp:431
msgid "Netctl plasmoid" msgid "Netctl plasmoid"
msgstr "Netctl plasmoid" msgstr "Netctl plasmoid"
@ -232,3 +264,4 @@ msgstr "Evgeniy Alekseev"
msgctxt "EMAIL OF TRANSLATORS" msgctxt "EMAIL OF TRANSLATORS"
msgid "Your emails" msgid "Your emails"
msgstr "esalexeev@gmail.com" msgstr "esalexeev@gmail.com"