SVN: toys/kernelupdatenotifier: kernelupdatenotifier.cpp kernelupdatenotifier.h main.cpp

vip vip at pld-linux.org
Mon Mar 23 20:07:57 CET 2009


Author: vip
Date: Mon Mar 23 20:07:56 2009
New Revision: 10238

Modified:
   toys/kernelupdatenotifier/kernelupdatenotifier.cpp
   toys/kernelupdatenotifier/kernelupdatenotifier.h
   toys/kernelupdatenotifier/main.cpp
Log:
- use UTF8
- use QApplication instead of (WTF) QCoreApplication - fixes requestShutDown()
- use tabs, not spaces
- TODO: exit after notification

Modified: toys/kernelupdatenotifier/kernelupdatenotifier.cpp
==============================================================================
--- toys/kernelupdatenotifier/kernelupdatenotifier.cpp	(original)
+++ toys/kernelupdatenotifier/kernelupdatenotifier.cpp	Mon Mar 23 20:07:56 2009
@@ -1,5 +1,5 @@
 /* PLD Linux Kernel Update Notifier
- * author: Bartosz 'shadzik' ¦wi±tek (shadzik at pld-linux.org)
+ * author: Bartosz 'shadzik' ÅšwiÄ…tek (shadzik at pld-linux.org)
  * license: GPLv2+
  * (c) 2009
  *
@@ -9,21 +9,22 @@
 
 #include <QObject>
 #include <QProcess>
-#include <QCoreApplication>
+
 #include <knotification.h>
 #include <klocale.h>
 #include <kdebug.h>
 #include <qdebug.h>
-#include <kapplication.h>
 #include <kworkspace/kworkspace.h>
 
 #include "kernelupdatenotifier.h"
 
-void KernelUpdateNotifier::handleRebootAction(uint action){
+void KernelUpdateNotifier::handleRebootAction(uint action)
+{
 	KNotification *notify = (KNotification *) sender();
 	notify->close();
-        qDebug()<<"Reboot"<<action;
-	switch(action) {
+	qDebug()<<"Reboot"<<action;
+	switch(action)
+	{
 		case 1:
 			KWorkSpace::ShutdownConfirm confirm = KWorkSpace::ShutdownConfirmYes;
 			KWorkSpace::ShutdownType type = KWorkSpace::ShutdownTypeReboot;
@@ -32,34 +33,33 @@
 			break;
 	}
 	qDebug()<<"Seems to be done";
-	//QProcess *reboot = new QProcess;
-	//reboot->start("sudo reboot");
 }
 
-void KernelUpdateNotifier::handleRebootActionClosed(){
-        kDebug("Don't Reboot");
+void KernelUpdateNotifier::handleRebootActionClosed()
+{
+	kDebug("Don't Reboot");
 }
 
-void KernelUpdateNotifier::sendNotify(const QString &version) {
-
-    //KNotification::Persistent - still doesn't work in 4.2
-    KNotification *notify = new KNotification("KernelWasUpgraded", 0, KNotification::CloseOnTimeout);
-
-    QString text;
-    text =  i18n("The Kernel was upgraded to version:") + "<br/>";
-    text += "<b>" + version + "</b><br/>";
-    text += i18n("Please reboot the machine.");
-    notify->setText(text);
-
-    QStringList actions;
-    actions << i18n("Reboot Now!");
-    //notify->setActions(actions);
-    connect(notify, SIGNAL(activated(uint)),
-            this, SLOT(handleRebootAction(uint)));
-    connect(notify, SIGNAL(closed()),
-            this , SLOT(handleRebootActionClosed()));
-    notify->sendEvent();
+void KernelUpdateNotifier::sendNotify(const QString &version)
+{
+	//KNotification::Persistent - still doesn't work in 4.2
+	KNotification *notify = new KNotification("KernelWasUpgraded", 0, KNotification::CloseOnTimeout);
+
+	QString text;
+	text =  i18n("The Kernel was upgraded to version:") + "<br/>";
+	text += "<b>" + version + "</b><br/>";
+	text += i18n("Please reboot the machine.");
+	notify->setText(text);
+
+	QStringList actions;
+	actions << i18n("Reboot Now!");
+	notify->setActions(actions);
+
+	connect(notify, SIGNAL(activated(uint)),
+		this, SLOT(handleRebootAction(uint)));
+	connect(notify, SIGNAL(closed()),
+		this , SLOT(handleRebootActionClosed()));
 
+	notify->sendEvent();
 }
 
-

Modified: toys/kernelupdatenotifier/kernelupdatenotifier.h
==============================================================================
--- toys/kernelupdatenotifier/kernelupdatenotifier.h	(original)
+++ toys/kernelupdatenotifier/kernelupdatenotifier.h	Mon Mar 23 20:07:56 2009
@@ -1,5 +1,5 @@
 /* PLD Linux Kernel Update Notifier
- * author: Bartosz 'shadzik' ¦wi±tek (shadzik at pld-linux.org)
+ * author: Bartosz 'shadzik' ÅšwiÄ…tek (shadzik at pld-linux.org)
  * license: GPLv2+
  * (c) 2009
  *
@@ -8,23 +8,20 @@
  */
 
 #include <QObject>
-#include <QCoreApplication>
-#include <knotification.h>
-#include <klocale.h>
-#include <kdebug.h>
 
 #ifndef KERNELUPDATENOTIFIER_H
 #define KERNELUPDATENOTIFIER_H
 
-class KernelUpdateNotifier: public QObject {
-        Q_OBJECT
+class KernelUpdateNotifier: public QObject
+{
+	Q_OBJECT
+
+	private slots:
+		void handleRebootAction(uint action);
+		void handleRebootActionClosed();
 
-private slots:
-        void handleRebootAction(uint action);
-        void handleRebootActionClosed();
-
-public:
-	void sendNotify(const QString &version);
+	public:
+		void sendNotify(const QString &version);
 
 //private:
 //        KNotification *notify;

Modified: toys/kernelupdatenotifier/main.cpp
==============================================================================
--- toys/kernelupdatenotifier/main.cpp	(original)
+++ toys/kernelupdatenotifier/main.cpp	Mon Mar 23 20:07:56 2009
@@ -1,5 +1,5 @@
 /* PLD Linux Kernel Update Notifier
- * author: Bartosz 'shadzik' ¦wi±tek (shadzik at pld-linux.org)
+ * author: Bartosz 'shadzik' ÅšwiÄ…tek (shadzik at pld-linux.org)
  * license: GPLv2+
  * (c) 2009
  *
@@ -8,16 +8,16 @@
  */
 
 #include <QObject>
-#include <QCoreApplication>
+#include <QApplication>
 
 #include "kernelupdatenotifier.h"
 
 int main(int argc, char *argv[])
 {
-	QCoreApplication app(argc, argv);
+	QApplication app(argc, argv);
+
 	KernelUpdateNotifier *aps = new KernelUpdateNotifier();
 	aps->sendNotify(argv[1]);
-	//return app.exec();
-	return 0;
+	return app.exec();
 }
 


More information about the pld-cvs-commit mailing list