[PC-BSD Commits] r2165 - pcbsd/trunk/NetworkTray
svn at pcbsd.org
svn at pcbsd.org
Tue Jun 24 08:28:07 PDT 2008
Author: kris
Date: 2008-06-24 08:28:06 -0700 (Tue, 24 Jun 2008)
New Revision: 2165
Modified:
pcbsd/trunk/NetworkTray/NetworkTray.cpp
pcbsd/trunk/NetworkTray/NetworkTray.h
pcbsd/trunk/NetworkTray/NetworkTray.pro
pcbsd/trunk/NetworkTray/main.cpp
Log:
Updated the NetworkTray application to KDE4
Modified: pcbsd/trunk/NetworkTray/NetworkTray.cpp
===================================================================
--- pcbsd/trunk/NetworkTray/NetworkTray.cpp 2008-06-24 03:43:40 UTC (rev 2164)
+++ pcbsd/trunk/NetworkTray/NetworkTray.cpp 2008-06-24 15:28:06 UTC (rev 2165)
@@ -2,15 +2,15 @@
/* Qt */
#include <qtimer.h>
-#include <qprocess.h>
+#include <Q3Process>
#include <qtooltip.h>
#include <qimage.h>
#include <qtranslator.h>
+#include <qtextstream.h>
+#include <qmenu.h>
/* KDE */
#include <kiconloader.h>
-#include <kapp.h>
-#include <kpopupmenu.h>
#include <kpassivepopup.h>
#include <kmessagebox.h>
#include <iostream>
@@ -39,15 +39,10 @@
QString username;
-NetworkTray::NetworkTray() {
-
-}
-
-
void NetworkTray::programInit(QString Type, QString Device)
{
QString tmp;
- QImage Icon;
+ QIcon Icon;
DeviceName = Device;
DeviceType = Type;
@@ -72,16 +67,16 @@
{
if ( (DeviceStatus == "active" || DeviceStatus == "") && DeviceUpStatus == "UP" )
{
- Icon.load("/PCBSD/networkmanager/pics/tray_local.png");
+ Icon.addFile("/PCBSD/networkmanager/pics/tray_local.png");
} else {
- Icon.load("/PCBSD/networkmanager/pics/tray_local_dis.png");
+ Icon.addFile("/PCBSD/networkmanager/pics/tray_local_dis.png");
}
} else {
if ( DeviceStatus == "associated" && DeviceUpStatus == "UP" )
{
- Icon.load("/PCBSD/networkmanager/pics/tray_wifi.png");
+ Icon.addFile("/PCBSD/networkmanager/pics/tray_wifi.png");
} else {
- Icon.load("/PCBSD/networkmanager/pics/tray_wifi_dis.png");
+ Icon.addFile("/PCBSD/networkmanager/pics/tray_wifi_dis.png");
}
DeviceSSID = getSSIDForIdent(DeviceName);
if (! DeviceSSID.isEmpty() )
@@ -93,11 +88,8 @@
// Add configuration button to the context menu
- QPixmap PixmapIcon;
- PixmapIcon.convertFromImage(Icon.scale(22,22));
- setPixmap(PixmapIcon);
+ setIcon(Icon);
contextMenu()->clear();
- contextMenu()->insertTitle(PixmapIcon, tr("Device ") + DeviceName);
contextMenu()->insertSeparator();
contextMenu()->insertItem( tr("Configure ") + DeviceName, this, SLOT(openConfigDlg()));
contextMenu()->insertItem( tr("Device Information "), this, SLOT(openDeviceInfo()));
@@ -344,13 +336,13 @@
if ( DeviceType == "Ethernet" )
{
- QProcess process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton -d /PCBSD/networkmanager/bin/ethernetconfig " + DeviceName));
+ Q3Process process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton -d /PCBSD/networkmanager/bin/ethernetconfig " + DeviceName));
if(!process.start())
- KMessageBox::error(this, tr("Can not start network configuration utility."));
+ KMessageBox::error(this->parentWidget(), tr("Can not start network configuration utility."));
} else {
- QProcess process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton -d /PCBSD/networkmanager/bin/wificonfig " + DeviceName));
+ Q3Process process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton -d /PCBSD/networkmanager/bin/wificonfig " + DeviceName));
if(!process.start())
- KMessageBox::error(this, tr("Can not start network configuration utility."));
+ KMessageBox::error(this->parentWidget(), tr("Can not start network configuration utility."));
}
}
@@ -404,7 +396,7 @@
}
// Update the tooltop
- QToolTip::add(this, tooltipStr);
+ setToolTip(tooltipStr);
}
@@ -414,8 +406,8 @@
QString tmp;
int updateTooltip = 0;
int displayPassivePopup = 0;
- QImage Icon;
- QImage Icon2;
+ QIcon Icon;
+ QIcon Icon2;
QString NotifyText = "";
QString filename = "/home/" + username + "/.kde/Autostart/tray-" + DeviceName + ".desktop";
@@ -467,24 +459,22 @@
if ( DeviceType == "Ethernet" )
{
if ( (DeviceStatus == "active" || DeviceStatus == "") && tmp == "UP") {
- Icon.load("/PCBSD/networkmanager/pics/tray_local.png");
+ Icon.addFile("/PCBSD/networkmanager/pics/tray_local.png");
} else {
- Icon.load("/PCBSD/networkmanager/pics/tray_local_dis.png");
+ Icon.addFile("/PCBSD/networkmanager/pics/tray_local_dis.png");
}
} else {
if ( DeviceStatus == "associated" && tmp == "UP" ) {
- Icon.load("/PCBSD/networkmanager/pics/tray_wifi.png");
+ Icon.addFile("/PCBSD/networkmanager/pics/tray_wifi.png");
} else {
- Icon.load("/PCBSD/networkmanager/pics/tray_wifi_dis.png");
+ Icon.addFile("/PCBSD/networkmanager/pics/tray_wifi_dis.png");
}
}
- QPixmap PixmapIcon;
- PixmapIcon.convertFromImage(Icon.scale(22,22));
- setPixmap(PixmapIcon);
+ setIcon(Icon);
// Save the status as the new status now
@@ -503,23 +493,22 @@
if ( DeviceType == "Ethernet" )
{
if ( (tmp == "active" || tmp == "") && DeviceUpStatus == "UP") {
- Icon.load("/PCBSD/networkmanager/pics/tray_local.png");
+ Icon.addFile("/PCBSD/networkmanager/pics/tray_local.png");
} else {
- Icon.load("/PCBSD/networkmanager/pics/tray_local_dis.png");
+ Icon.addFile("/PCBSD/networkmanager/pics/tray_local_dis.png");
}
} else {
if ( tmp == "associated" && DeviceUpStatus == "UP" ) {
- Icon.load("/PCBSD/networkmanager/pics/tray_wifi.png");
+ Icon.addFile("/PCBSD/networkmanager/pics/tray_wifi.png");
} else {
- Icon.load("/PCBSD/networkmanager/pics/tray_wifi_dis.png");
+ Icon.addFile("/PCBSD/networkmanager/pics/tray_wifi_dis.png");
DeviceSavedStrength = 0;
}
}
- QPixmap PixmapIcon;
- PixmapIcon.convertFromImage(Icon.scale(22,22));
- setPixmap(PixmapIcon);
+ // Set the tray icon now
+ setIcon(Icon);
NotifyText+="Link status changed to: " + tmp + "<br>";
@@ -595,13 +584,11 @@
// If the strength has changed enough, change the loaded icon
if ( DeviceSavedStrength != iconStrength )
{
- QImage Icon3;
+ QIcon Icon3;
DeviceSavedStrength = iconStrength;
- Icon3.load(FileLoad);
- QPixmap PixmapIcon3;
- PixmapIcon3.convertFromImage(Icon3.scale(22,22));
- setPixmap(PixmapIcon3);
+ Icon3.addFile(FileLoad);
+ setIcon(Icon3);
}
}
@@ -621,11 +608,9 @@
// Show the notification that something important changed
if ( displayPassivePopup == 1) {
- Icon2.load("/PCBSD/networkmanager/pics/info.png");
- QPixmap PixmapIcon2;
- PixmapIcon2.convertFromImage(Icon2.scale(22,22));
+ Icon2.addFile("/PCBSD/networkmanager/pics/info.png");
- KPassivePopup::message("Device " + DeviceName + ":", NotifyText, PixmapIcon2, this);
+ KPassivePopup::message("Device " + DeviceName + ":", NotifyText, Icon2.pixmap(22,22), this);
}
displayTooltip();
@@ -643,31 +628,31 @@
// If the user wants to restart the network, do so
void NetworkTray::slotRestartNetwork() {
- QProcess process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton -d /etc/rc.d/netif restart ; /etc/rc.d/routing restart ; /etc/rc.d/ppp restart"));
+ Q3Process process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton -d /etc/rc.d/netif restart ; /etc/rc.d/routing restart ; /etc/rc.d/ppp restart"));
if(!process.start())
- KMessageBox::error(this, tr("Can not restart the network!"));
+ KMessageBox::error(this->parentWidget(), tr("Can not restart the network!"));
}
void NetworkTray::slotEnablePPPOE() {
QString ProfileName = "internet";
// Run the enable PPPOE command
- QProcess process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton ppp -background " + ProfileName));
+ Q3Process process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton ppp -background " + ProfileName));
if(!process.start())
- KMessageBox::error(this, tr("Can not restart the network!"));
+ KMessageBox::error(this->parentWidget(), tr("Can not restart the network!"));
}
void NetworkTray::slotDisablePPPOE() {
// Run the command to stop PPPOE
- QProcess process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton -d killall ppp"));
+ Q3Process process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton -d killall ppp"));
if(!process.start())
- KMessageBox::error(this, tr("Can not restart the network!"));
+ KMessageBox::error(this->parentWidget(), tr("Can not restart the network!"));
}
void NetworkTray::openNetManager() {
// Run the command to start the network manager
- QProcess process(QStringList::split(' ', "kcmshell pcbsdnetwork"));
+ Q3Process process(QStringList::split(' ', "kcmshell4 pcbsdnetwork"));
if(!process.start())
- KMessageBox::error(this, tr("Can not open the network manager!"));
+ KMessageBox::error(this->parentWidget(), tr("Can not open the network manager!"));
}
QString NetworkTray::getValue( QString File, QString Key, int occur ) {
@@ -722,13 +707,13 @@
if ( DeviceType == "Ethernet" )
{
- QProcess process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton -d /PCBSD/networkmanager/bin/ethernetconfig info " + DeviceName));
+ Q3Process process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton -d /PCBSD/networkmanager/bin/ethernetconfig info " + DeviceName));
if(!process.start())
- KMessageBox::error(this, tr("Can not start network configuration utility."));
+ KMessageBox::error(this->parentWidget(), tr("Can not start network configuration utility."));
} else {
- QProcess process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton -d /PCBSD/networkmanager/bin/wificonfig info " + DeviceName));
+ Q3Process process(QStringList::split(' ', "/usr/local/bin/kdesu --noignorebutton -d /PCBSD/networkmanager/bin/wificonfig info " + DeviceName));
if(!process.start())
- KMessageBox::error(this, tr("Can not start network configuration utility."));
+ KMessageBox::error(this->parentWidget(), tr("Can not start network configuration utility."));
}
Modified: pcbsd/trunk/NetworkTray/NetworkTray.h
===================================================================
--- pcbsd/trunk/NetworkTray/NetworkTray.h 2008-06-24 03:43:40 UTC (rev 2164)
+++ pcbsd/trunk/NetworkTray/NetworkTray.h 2008-06-24 15:28:06 UTC (rev 2165)
@@ -1,17 +1,19 @@
#include <qpair.h>
-#include <qptrlist.h>
-#include <ksystemtray.h>
+#include <ksystemtrayicon.h>
class QString;
class QPixmap;
-class NetworkTray : public KSystemTray {
+class NetworkTray : public KSystemTrayIcon {
Q_OBJECT
public:
- NetworkTray();
+ NetworkTray() : KSystemTrayIcon()
+ {
+
+ }
void programInit(QString, QString);
virtual ~NetworkTray() {};
Modified: pcbsd/trunk/NetworkTray/NetworkTray.pro
===================================================================
--- pcbsd/trunk/NetworkTray/NetworkTray.pro 2008-06-24 03:43:40 UTC (rev 2164)
+++ pcbsd/trunk/NetworkTray/NetworkTray.pro 2008-06-24 15:28:06 UTC (rev 2165)
@@ -5,10 +5,12 @@
TARGET = NetworkTray
DESTDIR = /PCBSD/networkmanager/bin/
-LIBS += -lkdeui -lkdeinit_kcmshell
+LIBS += -lkdecore -lkdeui -lkio -Ikdelibs
HEADERS += NetworkTray.h
SOURCES += main.cpp \
NetworkTray.cpp
+QT += qt3support
+
Modified: pcbsd/trunk/NetworkTray/main.cpp
===================================================================
--- pcbsd/trunk/NetworkTray/main.cpp 2008-06-24 03:43:40 UTC (rev 2164)
+++ pcbsd/trunk/NetworkTray/main.cpp 2008-06-24 15:28:06 UTC (rev 2165)
@@ -5,43 +5,44 @@
#include <qtimer.h>
#include <kcmdlineargs.h>
#include <kuniqueapplication.h>
+#include <qtranslator.h>
#include <qtextcodec.h>
#include <NetworkTray.h>
+static const char description[] = I18N_NOOP("PC-BSD Network Tray Icon");
-
int main(int argc, char *argv[]) {
-
-KCmdLineArgs::init(argc, argv, "PC-BSD Network Monitor", "PC-BSD Network Monitor", "Monitors network status", "1.0");
-static KCmdLineOptions options[] =
- {
- { "ethernet <device>", "Start the Network Tray application on specified ethernet device.", 0 },
- { "wireless <device>", "Start the Network Tray application on specified wireless device.", 0 },
- KCmdLineLastOption
- };
+ KAboutData aboutData("NetworkTray", 0, ki18n("NetworkTray"),
+ "1.0", ki18n(description),
+ KAboutData::License_BSD,
+ ki18n("(c) 2008, Kris Moore(c)"));
+ aboutData.addAuthor(ki18n("Kris Moore"), ki18n("Current maintainer"), "kris at pcbsd.org");
+
+ KCmdLineArgs::init(argc, argv, &aboutData);
+
+ KCmdLineOptions options;
+ options.add("ethernet <device>", ki18n("Start the tray application on the specified ethernet device"));
+ options.add("wireless <device>", ki18n("Start the tray application on the specified wireless device"));
+
+
// Tell which options are supported
- KCmdLineArgs::addCmdLineOptions( options );
+ KCmdLineArgs::addCmdLineOptions( options );
-/*
-KUniqueApplication::addCmdLineOptions();
- if(!KUniqueApplication::start())
- errx(0, "already running.");
-*/
+ KApplication a;
- KApplication a;
- NetworkTray tray;
+ NetworkTray tray;
QTranslator translator( 0 );
translator.load( QString("NetworkTray_") + QTextCodec::locale(), "/PCBSD/LANGS/" );
a.installTranslator( &translator );
- a.setMainWidget(&tray);
+ //a.setMainWidget(tray.contextMenu());
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
More information about the Commits
mailing list