@ -16,8 +16,8 @@
# include "statdock.h"
# include "statpopup.h"
# include < qpainter.h>
# include < qtimer.h>
# include < t qpainter.h>
# include < t qtimer.h>
# include <kaction.h>
# include <kcolordialog.h>
# include <kconfig.h>
@ -33,11 +33,11 @@
# define TEXT_EXPANSION_HORIZONTAL 10
# define TEXT_EXPANSION_VERTICAL 3
const QColor StatPopup : : colorBorder ( 0 , 0 , 0 ) ;
const T QColor StatPopup : : colorBorder ( 0 , 0 , 0 ) ;
StatPopup : : StatPopup ( bool useSupportSplit , QWidget * parent, const char * name ) :
QWidget( parent, name , Qt: : WStyle_Customize | Qt: : WStyle_NoBorder |
Qt: : WStyle_StaysOnTop | Qt: : WDestructiveClose | Qt: : WType_TopLevel ) ,
StatPopup : : StatPopup ( bool useSupportSplit , T QWidget * tq parent, const char * name ) :
T QWidget( tq parent, name , T Qt: : WStyle_Customize | T Qt: : WStyle_NoBorder |
T Qt: : WStyle_StaysOnTop | T Qt: : WDestructiveClose | T Qt: : WType_TopLevel ) ,
supportSplit ( useSupportSplit ) {
// Window management.
KWin : : setState ( winId ( ) , NET : : SkipTaskbar | NET : : SkipPager ) ;
@ -60,8 +60,8 @@ StatPopup::StatPopup(bool useSupportSplit, QWidget *parent, const char *name) :
coll = new KActionCollection ( this ) ;
// Set up a timer for our periodic updates.
timer = new QTimer( this ) ;
connect ( timer , SIGNAL( timeout ( ) ) , this , SLOT( takeReading ( ) ) ) ;
timer = new T QTimer( this ) ;
connect ( timer , TQT_ SIGNAL( timeout ( ) ) , TQT_TQOBJECT ( this ) , TQT_ SLOT( takeReading ( ) ) ) ;
}
StatPopup : : ~ StatPopup ( ) {
@ -291,9 +291,9 @@ void StatPopup::setGrid(bool set) {
void StatPopup : : selectColor0 ( ) {
if ( dock [ 0 ] ) {
QColor ans ;
T QColor ans ;
if ( KColorDialog : : getColor ( ans , color [ 0 ] , firstDock ( ) ) = =
QDialog: : Accepted ) {
T QDialog: : Accepted ) {
color [ 0 ] = ans ;
dock [ 0 ] - > setColor ( ans ) ;
@ -306,9 +306,9 @@ void StatPopup::selectColor0() {
void StatPopup : : selectColor1 ( ) {
if ( dock [ 1 ] ) {
QColor ans ;
T QColor ans ;
if ( KColorDialog : : getColor ( ans , color [ 1 ] , firstDock ( ) ) = =
QDialog: : Accepted ) {
T QDialog: : Accepted ) {
color [ 1 ] = ans ;
dock [ 1 ] - > setColor ( ans ) ;
@ -344,30 +344,30 @@ void StatPopup::setupActions() {
bVal = config - > readBoolEntry ( " Active " , true ) ;
actActive = new KToggleAction ( i18n ( " &Active " ) , 0 , coll , " active " ) ;
actActive - > setChecked ( bVal ) ;
connect ( actActive , SIGNAL( toggled ( bool ) ) , this , SLOT( setActive ( bool ) ) ) ;
connect ( actActive , TQT_ SIGNAL( toggled ( bool ) ) , TQT_TQOBJECT ( this ) , TQT_ SLOT( setActive ( bool ) ) ) ;
actClearHistory = new KAction ( i18n ( " &Clear " ) , " editdelete " , 0 ,
this , SLOT( clearHistory ( ) ) , coll , " clear " ) ;
TQT_TQOBJECT ( this ) , TQT_ SLOT( clearHistory ( ) ) , coll , " clear " ) ;
speed = config - > readNumEntry ( " Speed " , DEFAULT_SPEED ) ;
actSpeed = new KAction ( i18n ( " &Speed... " ) , " speedarrow " , 0 ,
this , SLOT( selectSpeed ( ) ) , coll , " speed " ) ;
TQT_TQOBJECT ( this ) , TQT_ SLOT( selectSpeed ( ) ) , coll , " speed " ) ;
if ( supportSplit ) {
bVal = config - > readBoolEntry ( " Split " , true ) ;
actSplit = new IconToggleAction ( i18n ( " Sp&lit Graph " ) , " split " ,
i18n ( " Graph Sp&litting Enabled " ) , " spliton " , 0 , coll , " split " ) ;
actSplit - > setChecked ( bVal ) ;
connect ( actSplit , SIGNAL( toggled ( bool ) ) , this , SLOT( setSplit ( bool ) ) ) ;
connect ( actSplit , TQT_ SIGNAL( toggled ( bool ) ) , TQT_TQOBJECT ( this ) , TQT_ SLOT( setSplit ( bool ) ) ) ;
}
iVal = config - > readNumEntry ( " StyleID " , StatDock : : fillShaded ) ;
actFillLines = new IconToggleAction ( i18n ( " &Lines " ) , " lines " , " lineson " , 0 ,
this , SLOT( setFillLines ( ) ) , coll , " filllines " ) ;
TQT_TQOBJECT ( this ) , TQT_ SLOT( setFillLines ( ) ) , coll , " filllines " ) ;
actFillBars = new IconToggleAction ( i18n ( " &Bars " ) , " bars " , " barson " , 0 ,
this , SLOT( setFillBars ( ) ) , coll , " fillbars " ) ;
TQT_TQOBJECT ( this ) , TQT_ SLOT( setFillBars ( ) ) , coll , " fillbars " ) ;
actFillShaded = new IconToggleAction ( i18n ( " &Shaded " ) , " shaded " , " shadedon " ,
0 , this , SLOT( setFillShaded ( ) ) , coll , " fillshaded " ) ;
0 , TQT_TQOBJECT ( this ) , TQT_ SLOT( setFillShaded ( ) ) , coll , " fillshaded " ) ;
if ( iVal = = StatDock : : fillLines )
setFillLines ( ) ;
else if ( iVal = = StatDock : : fillBars )
@ -379,37 +379,37 @@ void StatPopup::setupActions() {
actSoft = new IconToggleAction ( i18n ( " So&ft Curves " ) , " soft " ,
i18n ( " So&ft Curves Enabled " ) , " softon " , 0 , coll , " soft " ) ;
actSoft - > setChecked ( bVal ) ;
connect ( actSoft , SIGNAL( toggled ( bool ) ) , this , SLOT( setSoft ( bool ) ) ) ;
connect ( actSoft , TQT_ SIGNAL( toggled ( bool ) ) , TQT_TQOBJECT ( this ) , TQT_ SLOT( setSoft ( bool ) ) ) ;
bVal = config - > readBoolEntry ( " Labelled " , true ) ;
actLabelled = new IconToggleAction ( i18n ( " Show &Labels " ) , " labels " ,
i18n ( " &Labels Enabled " ) , " labelson " , 0 , coll , " labelled " ) ;
actLabelled - > setChecked ( bVal ) ;
connect ( actLabelled , SIGNAL( toggled ( bool ) ) , this , SLOT( setLabelled ( bool ) ) ) ;
connect ( actLabelled , TQT_ SIGNAL( toggled ( bool ) ) , TQT_TQOBJECT ( this ) , TQT_ SLOT( setLabelled ( bool ) ) ) ;
bVal = config - > readBoolEntry ( " Grid " , true ) ;
actGrid = new IconToggleAction ( i18n ( " Show &Grid " ) , " grid " ,
i18n ( " &Grid Enabled " ) , " gridon " , 0 , coll , " grid " ) ;
actGrid - > setChecked ( bVal ) ;
connect ( actGrid , SIGNAL( toggled ( bool ) ) , this , SLOT( setGrid ( bool ) ) ) ;
connect ( actGrid , TQT_ SIGNAL( toggled ( bool ) ) , TQT_TQOBJECT ( this ) , TQT_ SLOT( setGrid ( bool ) ) ) ;
color [ 0 ] = defaultDockColor ( 0 ) ;
color [ 0 ] = config - > readColorEntry ( " Color0 " , color ) ;
actColor0 = new KAction ( QString( i18n ( " Color (%1)... " ) ) . arg( dockName ( 0 ) ) ,
" color0 " , 0 , this , SLOT( selectColor0 ( ) ) , coll , " color0 " ) ;
actColor0 = new KAction ( T QString( i18n ( " Color (%1)... " ) ) . tq arg( dockName ( 0 ) ) ,
" color0 " , 0 , TQT_TQOBJECT ( this ) , TQT_ SLOT( selectColor0 ( ) ) , coll , " color0 " ) ;
actColor0 - > setEnabled ( false ) ;
color [ 1 ] = defaultDockColor ( 1 ) ;
color [ 1 ] = config - > readColorEntry ( " Color1 " , color + 1 ) ;
actColor1 = new KAction ( QString( i18n ( " Color (%1)... " ) ) . arg( dockName ( 1 ) ) ,
" color1 " , 0 , this , SLOT( selectColor1 ( ) ) , coll , " color1 " ) ;
actColor1 = new KAction ( T QString( i18n ( " Color (%1)... " ) ) . tq arg( dockName ( 1 ) ) ,
" color1 " , 0 , TQT_TQOBJECT ( this ) , TQT_ SLOT( selectColor1 ( ) ) , coll , " color1 " ) ;
actColor1 - > setEnabled ( false ) ;
setupCustomActions ( ) ;
}
void StatPopup : : paintEvent ( QPaintEvent* ) {
QPainter p ( this ) ;
void StatPopup : : paintEvent ( T QPaintEvent* ) {
T QPainter p ( this ) ;
// Draw the border.
p . setPen ( colorBorder ) ;
@ -424,12 +424,12 @@ void StatPopup::paintEvent(QPaintEvent*) {
// Draw the text.
p . setFont ( font ( ) ) ;
p . setPen ( colorGroup( ) . foreground ( ) ) ;
p . setPen ( tq colorGroup( ) . foreground ( ) ) ;
p . drawText ( rect ( ) , AlignHCenter | AlignVCenter , fullReading ) ;
}
void StatPopup : : mousePressEvent ( QMouseEvent* e ) {
if ( e - > button ( ) = = RightButton) {
void StatPopup : : mousePressEvent ( T QMouseEvent* e ) {
if ( e - > button ( ) = = Qt: : RightButton) {
// Hide the pop-up.
hide ( ) ;
} else {
@ -437,45 +437,45 @@ void StatPopup::mousePressEvent(QMouseEvent* e) {
isDragged = true ;
relX = e - > x ( ) ;
relY = e - > y ( ) ;
repaint( ) ;
tq repaint( ) ;
}
}
void StatPopup : : mouseMoveEvent ( QMouseEvent* e ) {
void StatPopup : : mouseMoveEvent ( T QMouseEvent* e ) {
// In the middle of a drag operation.
move ( e - > globalX ( ) - relX , e - > globalY ( ) - relY ) ;
}
void StatPopup : : mouseReleaseEvent ( QMouseEvent* e ) {
void StatPopup : : mouseReleaseEvent ( T QMouseEvent* e ) {
// The end of a drag operation.
move ( e - > globalX ( ) - relX , e - > globalY ( ) - relY ) ;
isDragged = false ;
repaint( ) ;
tq repaint( ) ;
}
void StatPopup : : closeEvent ( QCloseEvent* e ) {
void StatPopup : : closeEvent ( T QCloseEvent* e ) {
// We're about to close. Save the current state for the last time.
savePopupState ( ) ;
closing = true ;
QWidget: : closeEvent ( e ) ;
T QWidget: : closeEvent ( e ) ;
}
void StatPopup : : hideEvent ( QHideEvent* e ) {
void StatPopup : : hideEvent ( T QHideEvent* e ) {
// We're about to hide. Save the current state if we're not
// closing altogether.
if ( ! closing )
savePopupState ( ) ;
QWidget: : hideEvent ( e ) ;
T QWidget: : hideEvent ( e ) ;
}
void StatPopup : : showEvent ( QShowEvent* e ) {
void StatPopup : : showEvent ( T QShowEvent* e ) {
// Make sure we're up-to-date and properly resized.
if ( isActive ( ) )
takeReading ( ) ;
else
resizeToText ( ) ;
QWidget: : showEvent ( e ) ;
T QWidget: : showEvent ( e ) ;
}
void StatPopup : : takeReading ( ) {
@ -492,17 +492,17 @@ void StatPopup::takeReading() {
if ( resizeRequested )
resizeToText ( ) ;
repaint( ) ;
tq repaint( ) ;
}
}
void StatPopup : : resizeToText ( ) {
resizeRequested = false ;
QSize size = fontMetrics ( ) . size ( 0 , fullReading ) ;
T QSize size = fontMetrics ( ) . size ( 0 , fullReading ) ;
resize ( size . width ( ) + 2 * TEXT_EXPANSION_HORIZONTAL ,
size . height ( ) + 2 * TEXT_EXPANSION_VERTICAL ) ;
repaint( ) ;
tq repaint( ) ;
}