38 #include <KGlobalSettings>
46 QVector<QPixmap*> *TrayIcon::icons = 0;
51 setObjectName(
"Ktimetracker Tray" );
53 _taskActiveTimer =
new QTimer(
this);
54 connect( _taskActiveTimer, SIGNAL(timeout()),
this,
59 icons =
new QVector<QPixmap*>(8);
60 for (
int i=0; i<8; ++i)
62 QPixmap *icon =
new QPixmap();
64 name.sprintf(
"active-icon-%d.xpm",i);
65 *icon = UserIcon(name);
66 icons->insert(i,icon);
70 if ( timetrackerWidget )
72 KAction *action = timetrackerWidget->
action(
"configure_ktimetracker" );
73 if ( action ) contextMenu()->addAction( action );
74 action = timetrackerWidget->
action(
"stopAll" );
75 if ( action ) contextMenu()->addAction( action );
84 setObjectName(
"Ktimetracker Tray" );
93 setObjectName(
"Ktimetracker Tray" );
103 kDebug(5970) <<
"Entering function";
104 if ( _taskActiveTimer )
106 _taskActiveTimer->start(1000);
107 setIconByPixmap( *(*icons)[_activeIcon] );
109 kDebug(5970) <<
"Leaving function";
114 kDebug(5970) <<
"Entering function";
115 if ( _taskActiveTimer )
117 _taskActiveTimer->stop();
119 kDebug(5970) <<
"Leaving function";
124 _activeIcon = (_activeIcon+1) % 8;
125 setIconByPixmap( *(*icons)[_activeIcon]);
131 setIconByPixmap( *(*icons)[_activeIcon]);
141 if ( activeTasks.isEmpty() )
143 this->setToolTip(
"ktimetracker",
"ktimetracker", i18n(
"No active tasks") );
147 QFontMetrics fm( QToolTip::font() );
148 const QString continued = i18n(
", ..." );
149 const int buffer = fm.boundingRect( continued ).width();
150 const int desktopWidth = KGlobalSettings::desktopGeometry(associatedWidget()).width();
151 const int maxWidth = desktopWidth - buffer;
160 for (
int i = 0; i < activeTasks.count(); ++i )
162 Task* task = activeTasks.at( i );
164 s += i18n(
", " ) + task->
name();
167 int width = fm.boundingRect( s ).width();
168 if ( width > maxWidth )
175 this->setToolTip(
"ktimetracker",
"ktimetracker", qTip );
QString name() const
returns the name of this task.
void updateToolTip(QList< Task * > activeTasks)
A class representing a task.
Main window to tie the application together.