@ -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>
@ -34,7 +34,7 @@
# 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 : : Reading : : Reading ( ) :
dock ( 0 ) ,
@ -54,14 +54,14 @@ void StatPopup::Reading::Init(int which, StatPopup* popup)
color = popup - > defaultDockColor ( which ) ;
color = popup - > config - > readColorEntry ( colorid , & color ) ;
actColor = new KAction ( i18n ( " Color (%1)... " ) . arg( popup - > dockName ( which ) ) ,
" color " , 0 , popup , SLOT( selectColor ( ) ) , popup - > coll , colorid ) ;
actColor = new KAction ( i18n ( " Color (%1)... " ) . tq arg( popup - > dockName ( which ) ) ,
" color " , 0 , TQT_TQOBJECT( popup) , TQT_ SLOT( selectColor ( ) ) , popup - > coll , colorid ) ;
}
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 ) ;
@ -83,8 +83,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 ( ) {
@ -292,20 +292,20 @@ void StatPopup::setGrid(bool set) {
void StatPopup : : selectColor ( ) {
// which color?
int whichDock ;
if ( sscanf ( sender( ) - > name ( ) , " Color%d " , & whichDock ) ! = 1 )
if ( sscanf ( TQT_TQOBJECT( const_cast < TQT_BASE_OBJECT_NAME * > ( sender( ) ) ) - > name ( ) , " Color%d " , & whichDock ) ! = 1 )
return ;
if ( whichDock < 0 | | whichDock > = r . size ( ) )
return ;
if ( r [ whichDock ] . dock ) {
QColor ans ;
T QColor ans ;
if ( KColorDialog : : getColor ( ans , r [ whichDock ] . color , firstDock ( ) ) = =
QDialog: : Accepted ) {
T QDialog: : Accepted ) {
r [ whichDock ] . color = ans ;
r [ whichDock ] . dock - > setColor ( ans ) ;
config - > setGroup ( " General Options " ) ;
QString n ;
T QString n ;
n . sprintf ( " Color%d " , whichDock ) ;
config - > writeEntry ( n , ans ) ;
config - > sync ( ) ;
@ -334,57 +334,57 @@ 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 ) ) ) ;
}
fillStyle = 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 " ) ;
actFillLines - > setChecked ( fillStyle = = StatDock : : fillLines ) ;
actFillBars = new IconToggleAction ( i18n ( " &Bars " ) , " bars " , " barson " , 0 ,
this , SLOT( setFillBars ( ) ) , coll , " fillbars " ) ;
TQT_TQOBJECT ( this ) , TQT_ SLOT( setFillBars ( ) ) , coll , " fillbars " ) ;
actFillBars - > setChecked ( fillStyle = = StatDock : : fillBars ) ;
actFillShaded = new IconToggleAction ( i18n ( " &Shaded " ) , " shaded " , " shadedon " ,
0 , this , SLOT( setFillShaded ( ) ) , coll , " fillshaded " ) ;
0 , TQT_TQOBJECT ( this ) , TQT_ SLOT( setFillShaded ( ) ) , coll , " fillshaded " ) ;
actFillShaded - > setChecked ( fillStyle = = StatDock : : fillShaded ) ;
bVal = config - > readBoolEntry ( " Soft " , false ) ;
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 ) ) ) ;
setupCustomActions ( ) ;
}
void StatPopup : : paintEvent ( QPaintEvent* ) {
QPainter p ( this ) ;
void StatPopup : : paintEvent ( T QPaintEvent* ) {
T QPainter p ( this ) ;
// Draw the border.
p . setPen ( colorBorder ) ;
@ -399,12 +399,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 {
@ -412,38 +412,38 @@ 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 ( ) ;
@ -453,7 +453,7 @@ void StatPopup::showEvent(QShowEvent* e) {
// Window management - fix so a taskbar button doesn't appear
KWin : : setState ( winId ( ) , NET : : SkipTaskbar | NET : : SkipPager ) ;
QWidget: : showEvent ( e ) ;
T QWidget: : showEvent ( e ) ;
}
void StatPopup : : takeReading ( ) {
@ -469,17 +469,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( ) ;
}
# include "statpopup.moc"