[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/utils/rsibreak/src
From: Aurélien Gâteau <agateau () kde ! org>
Date: 2011-04-03 22:05:57
Message-ID: 20110403220557.EAB9CAC8CE () svn ! kde ! org
[Download RAW message or body]
SVN commit 1226998 by gateau:
Started porting to KStatusNotifierItem
M +3 -7 passivepopup.cpp
M +1 -1 passivepopup.h
M +1 -6 popupeffect.cpp
M +0 -3 popupeffect.h
M +17 -47 rsidock.cpp
M +3 -31 rsidock.h
M +3 -4 rsirelaxpopup.cpp
M +1 -3 rsirelaxpopup.h
M +1 -1 rsitooltip.h
M +10 -13 rsiwidget.cpp
--- trunk/extragear/utils/rsibreak/src/passivepopup.cpp #1226997:1226998
@@ -21,19 +21,15 @@
#include <QMouseEvent>
-#include <KSystemTrayIcon>
#include <KDebug>
PassivePopup::PassivePopup( QWidget *parent )
: KPassivePopup( parent ) {}
-void PassivePopup::show( const QSystemTrayIcon* icon )
+void PassivePopup::show()
{
- /* To place it properly near the icon, first show it off-screen, then
- move it to the correct position. If you know something better, please,
- please let me know */
- KPassivePopup::show( icon->geometry().bottomRight() );
- moveNear( icon->geometry() );
+#warning FIXME
+ KPassivePopup::show( QPoint( 10, 10 ) );
}
void PassivePopup::mouseReleaseEvent( QMouseEvent * event )
--- trunk/extragear/utils/rsibreak/src/passivepopup.h #1226997:1226998
@@ -27,7 +27,7 @@
{
public:
explicit PassivePopup( QWidget *parent = 0 );
- void show( const QSystemTrayIcon* icon );
+ void show();
protected:
virtual void mouseReleaseEvent( QMouseEvent * event );
};
--- trunk/extragear/utils/rsibreak/src/popupeffect.cpp #1226997:1226998
@@ -43,7 +43,7 @@
void PopupEffect::activate()
{
- m_popup->show( m_tray );
+ m_popup->show();
}
void PopupEffect::deactivate()
@@ -51,11 +51,6 @@
m_popup->hide();
}
-void PopupEffect::setTray( QSystemTrayIcon* tray )
-{
- m_tray = tray;
-}
-
void PopupEffect::setLabel( const QString& text )
{
// text is a time string like '2 minutes 42 seconds'
--- trunk/extragear/utils/rsibreak/src/popupeffect.h #1226997:1226998
@@ -25,7 +25,6 @@
class PassivePopup;
class QLabel;
-class QSystemTrayIcon;
class PopupEffect : public BreakBase
{
@@ -34,7 +33,6 @@
public:
PopupEffect( QObject* );
~PopupEffect();
- void setTray( QSystemTrayIcon* );
void setLabel( const QString& );
public slots:
@@ -44,7 +42,6 @@
private:
PassivePopup* m_popup;
QLabel* m_label;
- QSystemTrayIcon* m_tray;
};
#endif // POPUPEFFECT_H
--- trunk/extragear/utils/rsibreak/src/rsidock.cpp #1226997:1226998
@@ -24,26 +24,31 @@
#include "rsistatwidget.h"
#include "rsistats.h"
-#include <QMenu>
-#include <QSystemTrayIcon>
#include <QPointer>
+#include <KAboutData>
#include <KComponentData>
#include <KLocale>
+#include <KMenu>
#include <KNotifyConfigWidget>
#include <KHelpMenu>
#include <KStandardShortcut>
-#include <KSystemTrayIcon>
#include <KMessageBox>
#include <KWindowSystem>
-RSIDock::RSIDock( QWidget *parent )
- : QSystemTrayIcon( parent ), m_suspended( false )
+RSIDock::RSIDock( QObject *parent )
+ : KStatusNotifierItem( parent ), m_suspended( false )
, m_statsDialog( 0 ), m_statsWidget( 0 )
{
- m_help = new KHelpMenu( parent, KGlobal::mainComponent().aboutData() );
+ setCategory(ApplicationStatus);
+ setStatus(Active);
- QMenu* menu = new QMenu( parent );
+ const KAboutData* aboutData = KGlobal::mainComponent().aboutData();
+ setTitle( aboutData->appName() );
+
+ m_help = new KHelpMenu( 0, aboutData );
+
+ KMenu* menu = contextMenu();
menu->addAction( KIcon( "kde" ), i18n( "About &KDE" ), m_help,
SLOT( aboutKDE() ) );
menu->addAction( i18n( "&About RSIBreak" ), m_help,
@@ -70,30 +75,18 @@
menu->addAction( KIcon( "configure" ), i18n( "&Configure RSIBreak..." ),
this, SLOT( slotConfigure() ) );
- menu->addSeparator();
- menu->addAction( KIcon( "application-exit" ), i18n( "Quit" ), this, SLOT( slotQuit() ),
- KStandardShortcut::shortcut( KStandardShortcut::Quit ).primary() );
-
-
- setContextMenu( menu );
-
- connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ),
- SLOT( slotActivated( QSystemTrayIcon::ActivationReason ) ) );
+ connect( this, SIGNAL( activateRequested(bool,QPoint) ),
+ SLOT( slotShowStatistics() ) );
}
RSIDock::~RSIDock()
{
+ delete m_help;
delete m_statsWidget;
delete m_statsDialog;
m_statsWidget = 0;
}
-void RSIDock::slotActivated( QSystemTrayIcon::ActivationReason reason )
-{
- if ( reason == QSystemTrayIcon::Trigger )
- slotShowStatistics();
-}
-
void RSIDock::slotConfigureNotifications()
{
KNotifyConfigWidget::configure( 0 );
@@ -123,13 +116,13 @@
if ( m_suspended ) {
emit suspend( false );
- setIcon( KSystemTrayIcon::loadIcon( "rsibreak0" ) );
+ setIconByName( "rsibreak0" );
m_suspendItem->setIcon( SmallIcon( "media-playback-pause" ) );
m_suspendItem->setText( i18n( "&Suspend RSIBreak" ) );
} else {
emit suspend( true );
- setIcon( KSystemTrayIcon::loadIcon( "rsibreakx" ) );
+ setIconByName( "rsibreakx" );
m_suspendItem->setIcon( SmallIcon( "media-playback-start" ) );
m_suspendItem->setText( i18n( "&Resume RSIBreak" ) );
}
@@ -137,24 +130,6 @@
m_suspended = !m_suspended;
}
-void RSIDock::mousePressEvent( QMouseEvent *e )
-{
- if ( e->button() == Qt::RightButton )
- contextMenu()->exec( e->globalPos() );
-
- if ( e->button() == Qt::LeftButton )
- slotShowStatistics();
-}
-
-bool RSIDock::event( QEvent * event )
-{
- if ( event->type() == QEvent::ToolTip ) {
- emit showToolTip();
- return true;
- }
- return false;
-}
-
void RSIDock::slotShowStatistics()
{
if ( !m_statsDialog ) {
@@ -199,9 +174,4 @@
RSIGlobals::instance()->stats()->reset();
}
-void RSIDock::slotQuit()
-{
- exit( 0 );
-}
-
#include "rsidock.moc"
--- trunk/extragear/utils/rsibreak/src/rsidock.h #1226997:1226998
@@ -25,13 +25,8 @@
#define RSIDOCK_H
#include <kdialog.h>
-#include <qsystemtrayicon.h>
-//Added by qt3to4:
-#include <QMouseEvent>
-#include <QShowEvent>
-#include <QEvent>
+#include <kstatusnotifieritem.h>
-
class KHelpMenu;
class RSIStatWidget;
@@ -45,17 +40,12 @@
* @author Nadeem Hasan <nhasan@kde.org>
* @author Tom Albers <toma.org>
*/
-class RSIDock : public QSystemTrayIcon
+class RSIDock : public KStatusNotifierItem
{
Q_OBJECT
public:
- /**
- * Contructor
- * @param parent Parent Widget
- * @param name Name
- */
- RSIDock( QWidget *parent );
+ RSIDock( QObject *parent );
/**
* Destructor
@@ -102,31 +92,13 @@
*/
void suspend( bool );
- /**
- Shows the tooltip.
- */
- void showToolTip();
-
-protected:
- /**
- * Reimplemented because we do not want an action on left click
- */
- void mousePressEvent( QMouseEvent *e );
-
- /**
- * Reimplemented to catch the tooltip event.
- */
- virtual bool event( QEvent * event );
-
private slots:
- void slotActivated( QSystemTrayIcon::ActivationReason );
void slotConfigure();
void slotConfigureNotifications();
void slotSuspend();
void slotBreakRequest();
void slotShowStatistics();
void slotResetStats();
- void slotQuit();
private:
KHelpMenu* m_help;
--- trunk/extragear/utils/rsibreak/src/rsirelaxpopup.cpp #1226997:1226998
@@ -31,10 +31,9 @@
#include <KDebug>
#include <KConfigGroup>
#include <KIconLoader>
-#include <QSystemTrayIcon>
-RSIRelaxPopup::RSIRelaxPopup( QWidget *parent, QSystemTrayIcon* icon )
- : QWidget( parent ), m_systray( icon )
+RSIRelaxPopup::RSIRelaxPopup( QWidget *parent )
+ : QWidget( parent )
{
m_popup = new PassivePopup( parent );
@@ -103,7 +102,7 @@
m_progress->setValue( n );
if ( resetcount == 1 )
- m_popup->show( m_systray );
+ m_popup->show();
} else {
m_popup->setVisible( false );
resetcount = 0;
--- trunk/extragear/utils/rsibreak/src/rsirelaxpopup.h #1226997:1226998
@@ -27,7 +27,6 @@
class QLabel;
class QPushButton;
class QProgressBar;
-class QSystemTrayIcon;
/**
* @class RSIRelaxPopup
@@ -40,7 +39,7 @@
Q_OBJECT
public:
/** Constructor */
- explicit RSIRelaxPopup( QWidget *parent, QSystemTrayIcon* );
+ explicit RSIRelaxPopup( QWidget *parent );
/** Destructor */
~RSIRelaxPopup();
@@ -92,7 +91,6 @@
void readSettings();
bool m_usePopup;
bool m_useFlash;
- QSystemTrayIcon* m_systray;
PassivePopup* m_popup;
QLabel *m_message;
QProgressBar *m_progress;
--- trunk/extragear/utils/rsibreak/src/rsitooltip.h #1226997:1226998
@@ -49,7 +49,7 @@
m_popup->setTimeout( i );
};
void showToolTip() {
- m_popup->show( m_icon );
+ m_popup->show();
};
--- trunk/extragear/utils/rsibreak/src/rsiwidget.cpp #1226997:1226998
@@ -42,7 +42,6 @@
#include <KMessageBox>
#include <KIconLoader>
#include <KNotification>
-#include <KSystemTrayIcon>
#include <KTemporaryFile>
#include <KConfigGroup>
#include <KDebug>
@@ -54,20 +53,21 @@
: QObject( parent ), m_effect( 0 ),
m_useImages( false ), m_usePlasma( false ), m_usePlasmaRO( false )
{
- // Keep these 3 lines _above_ the messagebox, so the text actually is right.
- m_tray = new RSIDock( parent );
- m_tray->setIcon( KSystemTrayIcon::loadIcon( "rsibreak0" ) );
- m_tray->show();
+ // Keep these 2 lines _above_ the messagebox, so the text actually is right.
+ m_tray = new RSIDock( this );
+ m_tray->setIconByName( "rsibreak0" );
// D-Bus
new RsiwidgetAdaptor( this );
QDBusConnection dbus = QDBusConnection::sessionBus();
dbus.registerObject( "/rsibreak", this );
- m_tooltip = new RSIToolTip( 0, m_tray );
- connect( m_tray, SIGNAL( showToolTip() ), m_tooltip, SLOT( showToolTip() ) );
+#warning FIXME
+ m_tooltip = 0;
+ //m_tooltip = new RSIToolTip( 0, m_tray );
+ //connect( m_tray, SIGNAL( showToolTip() ), m_tooltip, SLOT( showToolTip() ) );
- m_relaxpopup = new RSIRelaxPopup( 0, m_tray );
+ m_relaxpopup = new RSIRelaxPopup( 0 );
connect( m_relaxpopup, SIGNAL( lock() ), SLOT( slotLock() ) );
connect( m_tray, SIGNAL( configChanged( bool ) ), SLOT( readConfig() ) );
@@ -90,7 +90,6 @@
RSIObject::~RSIObject()
{
- delete m_tray;
delete m_effect;
delete RSIGlobals::instance();
}
@@ -159,12 +158,11 @@
( m_timer->isSuspended() ? QString( "x" ) : QString::number( level ) );
if ( newIcon != m_currentIcon ) {
- QIcon dockIcon = KSystemTrayIcon::loadIcon( newIcon );
- m_tray->setIcon( dockIcon );
+ m_tray->setIconByName( newIcon );
QPixmap toolPixmap = KIconLoader::global()->loadIcon( newIcon, KIconLoader::Desktop );
m_currentIcon = newIcon;
- m_tooltip->setPixmap( toolPixmap );
+ //m_tooltip->setPixmap( toolPixmap );
}
}
@@ -290,7 +288,6 @@
}
case Popup: {
PopupEffect* effect = new PopupEffect( 0 );
- effect->setTray( m_tray );
m_effect = effect;
break;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic