You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
3.2 KiB
104 lines
3.2 KiB
/*************************************************************************** |
|
* Copyright (C) 2006 by Roy Marples * |
|
* roy@marples.name * |
|
* * |
|
* This program is free software; you can redistribute it and/or modify * |
|
* it under the terms of the GNU General Public License as published by * |
|
* the Free Software Foundation; either version 2 of the License, or * |
|
* (at your option) any later version. * |
|
* * |
|
* This program is distributed in the hope that it will be useful, * |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
|
* GNU General Public License for more details. * |
|
* * |
|
* You should have received a copy of the GNU General Public License * |
|
* along with this program; if not, write to the * |
|
* Free Software Foundation, Inc., * |
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
|
***************************************************************************/ |
|
|
|
#include <kaboutapplication.h> |
|
#include <kapplication.h> |
|
#include <klocale.h> |
|
#include <kpopupmenu.h> |
|
|
|
#include <qtooltip.h> |
|
|
|
#include "khdapsmonitorsystray.h" |
|
|
|
KHDAPSMonitorSysTray::KHDAPSMonitorSysTray(QWidget * parent, const char * name) |
|
: KSystemTray(parent, name) |
|
{ |
|
contextMenu()->insertItem(I18N_NOOP("About KHDAPS Monitor"), this, SLOT(about()), CTRL+Key_A); |
|
connect(this, SIGNAL(quitSelected()), kapp, SLOT(quit())); |
|
update(); |
|
|
|
timer = new QTimer(this); |
|
connect(timer, SIGNAL(timeout()), this, SLOT(update())); |
|
timer->start(UPDATE_INTERVAL); |
|
} |
|
|
|
KHDAPSMonitorSysTray::~KHDAPSMonitorSysTray() |
|
{ |
|
timer->stop(); |
|
delete timer; |
|
} |
|
|
|
void KHDAPSMonitorSysTray::about() |
|
{ |
|
KAboutApplication(this,"kaboutapplication",TRUE).exec(); |
|
} |
|
|
|
void KHDAPSMonitorSysTray::update() |
|
{ |
|
QStringList dList = sysFS.deviceList(); |
|
QString newPixmap = KHDAPS_ICON_ERROR; |
|
QString newToolTip; |
|
|
|
if (! sysFS.hasHDAPS()) |
|
{ |
|
newToolTip = I18N_NOOP("error: Kernel does not support HDAPS or "); |
|
} |
|
else if (dList.count() == 0) |
|
{ |
|
newToolTip = I18N_NOOP("error: No devices found that use HDAPS"); |
|
} |
|
else |
|
|
|
newPixmap = KHDAPS_ICON_PLAY; |
|
if (dList.count() == 1) |
|
newToolTip = I18N_NOOP("Monitoring device "); |
|
else |
|
newToolTip = I18N_NOOP("Monitoring devices "); |
|
unsigned int i; |
|
for (i = 0; i < dList.count(); i++) |
|
{ |
|
if (i > 0) |
|
newToolTip += ", "; |
|
newToolTip += dList[i]; |
|
if (sysFS.queueProtected(dList[i])) |
|
{ |
|
newPixmap = KHDAPS_ICON_PAUSE; |
|
newToolTip = I18N_NOOP("Device paused ") + dList[i]; |
|
break; |
|
} |
|
} |
|
|
|
|
|
if (oldPixmap != newPixmap) |
|
{ |
|
oldPixmap = newPixmap; |
|
setPixmap(loadIcon(newPixmap)); |
|
} |
|
|
|
if (oldToolTip != newToolTip) |
|
{ |
|
if (oldToolTip != "") |
|
QToolTip::remove(this); |
|
oldToolTip = newToolTip; |
|
QToolTip::add(this, newToolTip); |
|
} |
|
} |
|
|
|
#include "khdapsmonitorsystray.moc"
|
|
|