@ -21,16 +21,16 @@
# include "mainwindow.h"
# include <kstdaction.h>
# include < qwhatsthis.h>
# include < qlabel.h>
# include < qvbox.h>
# include < t qwhatsthis.h>
# include < t qlabel.h>
# include < t qvbox.h>
# include <kaction.h>
# include < qtoolbutton.h>
# include < t qtoolbutton.h>
# include <klocale.h>
# include <kservicegroup.h>
# include < qlayout.h>
# include < qwidgetstack.h>
# include < qtimer.h>
# include < t qlayout.h>
# include < t qwidgetstack.h>
# include < t qtimer.h>
# include <kiconloader.h>
# include <kcmoduleloader.h>
# include <kdialogbase.h>
@ -43,7 +43,7 @@
# include <kmenubar.h>
# include <kactionclasses.h>
# include <ktoolbarbutton.h>
# include < qtabbar.h>
# include < t qtabbar.h>
# include "kcmsearch.h"
# include "modulesview.h"
@ -51,19 +51,19 @@
# include "kcmodulemenu.h"
# include "kcmultiwidget.h"
MainWindow : : MainWindow ( bool embed , const QString & menuFile ,
QWidget * parent, const char * name ) :
KMainWindow ( parent, name ) , menu ( NULL ) , embeddedWindows ( embed ) ,
MainWindow : : MainWindow ( bool embed , const T QString & menuFile ,
T QWidget * tq parent, const char * name ) :
KMainWindow ( tq parent, name ) , menu ( NULL ) , embeddedWindows ( embed ) ,
groupWidget ( NULL ) , selectedPage ( 0 ) , dummyAbout ( NULL ) {
// Load the menu structure in from disk.
menu = new KCModuleMenu ( menuFile ) ;
moduleTabs = new KTabWidget ( this , " moduletabs " ,
QTabWidget: : Top | QTabWidget: : Rounded ) ;
T QTabWidget: : Top | T QTabWidget: : Rounded ) ;
buildMainWidget ( ) ;
buildActions ( ) ;
setupGUI ( ToolBar | Save | Create , QString: : null ) ;
setupGUI ( ToolBar | Save | Create , TQString( ) ) ;
widgetChange ( ) ;
}
@ -77,11 +77,11 @@ MainWindow::~MainWindow()
void MainWindow : : buildMainWidget ( )
{
windowStack = new QWidgetStack( this , " widgetstack " ) ;
windowStack = new T QWidgetStack( this , " widgetstack " ) ;
// Top level pages.
QValueList< MenuItem > subMenus = menu - > menuList ( ) ;
QValueList< MenuItem > : : iterator it ;
T QValueList< MenuItem > subMenus = menu - > menuList ( ) ;
T QValueList< MenuItem > : : iterator it ;
KCScrollView * modulesScroller ;
moduleTabs - > show ( ) ;
for ( it = subMenus . begin ( ) ; it ! = subMenus . end ( ) ; + + it ) {
@ -89,7 +89,7 @@ void MainWindow::buildMainWidget()
modulesScroller = new KCScrollView ( moduleTabs ) ;
ModulesView * modulesView = new ModulesView ( menu , ( * it ) . subMenu , modulesScroller - > viewport ( ) , " modulesView " ) ;
modulesViewList . append ( modulesView ) ;
connect ( modulesView , SIGNAL( itemSelected ( QIconViewItem* ) ) , this , SLOT( slotItemSelected ( QIconViewItem* ) ) ) ;
connect ( modulesView , TQT_ SIGNAL( itemSelected ( T QIconViewItem* ) ) , TQT_TQOBJECT ( this ) , TQT_ SLOT( slotItemSelected ( T QIconViewItem* ) ) ) ;
modulesScroller - > addChild ( modulesView ) ;
moduleTabs - > addTab ( modulesScroller , ( * it ) . caption ) ;
overviewPages . append ( modulesScroller ) ;
@ -103,43 +103,43 @@ void MainWindow::buildMainWidget()
void MainWindow : : buildActions ( )
{
KStdAction : : quit ( this , SLOT( close ( ) ) , actionCollection ( ) ) ;
KStdAction : : quit ( TQT_TQOBJECT ( this ) , TQT_ SLOT( close ( ) ) , actionCollection ( ) ) ;
resetModule = new KAction ( i18n ( " Undo Changes " ) , 0 , this ,
SLOT( showAllModules ( ) ) , actionCollection ( ) , " resetModule " ) ;
resetModule = new KAction ( i18n ( " Undo Changes " ) , 0 , TQT_TQOBJECT ( this ) ,
TQT_ SLOT( showAllModules ( ) ) , actionCollection ( ) , " resetModule " ) ;
resetModule - > setEnabled ( false ) ;
defaultModule = new KAction ( i18n ( " Reset to Defaults " ) , 0 , this ,
SLOT( showAllModules ( ) ) , actionCollection ( ) , " defaultModule " ) ;
defaultModule = new KAction ( i18n ( " Reset to Defaults " ) , 0 , TQT_TQOBJECT ( this ) ,
TQT_ SLOT( showAllModules ( ) ) , actionCollection ( ) , " defaultModule " ) ;
defaultModule - > setEnabled ( false ) ;
if ( embeddedWindows ) {
showAllAction = new KAction ( i18n ( " Overview " ) , QApplication: : reverseLayout ( ) ? " forward " : " back " , 0 , this ,
SLOT( showAllModules ( ) ) , actionCollection ( ) , " showAll " ) ;
showAllAction = new KAction ( i18n ( " Overview " ) , T QApplication: : reverseLayout ( ) ? " forward " : " back " , 0 , TQT_TQOBJECT ( this ) ,
TQT_ SLOT( showAllModules ( ) ) , actionCollection ( ) , " showAll " ) ;
showAllAction - > setEnabled ( false ) ;
}
aboutModuleAction = new KAction ( i18n ( " About Current Module " ) , 0 , this , SLOT( aboutCurrentModule ( ) ) , actionCollection ( ) , " help_about_module " ) ;
aboutModuleAction = new KAction ( i18n ( " About Current Module " ) , 0 , TQT_TQOBJECT ( this ) , TQT_ SLOT( aboutCurrentModule ( ) ) , actionCollection ( ) , " help_about_module " ) ;
resetModuleHelp ( ) ;
// Search
QHBox * hbox = new QHBox( 0 ) ;
T QHBox * hbox = new T QHBox( 0 ) ;
hbox - > setMaximumWidth ( 400 ) ;
KcmSearch * search = new KcmSearch ( & modulesViewList , hbox , " search " ) ;
hbox - > setStretchFactor ( search , 1 ) ;
connect ( search , SIGNAL( searchHits ( const QString & , int * , int ) ) , this , SLOT( slotSearchHits ( const QString & , int * , int ) ) ) ;
connect ( search , TQT_ SIGNAL( searchHits ( const T QString & , int * , int ) ) , TQT_TQOBJECT ( this ) , TQT_ SLOT( slotSearchHits ( const T QString & , int * , int ) ) ) ;
QVBox * vbox = new QVBox( hbox ) ;
generalHitLabel = new QLabel( vbox ) ;
T QVBox * vbox = new T QVBox( hbox ) ;
generalHitLabel = new T QLabel( vbox ) ;
vbox - > setStretchFactor ( generalHitLabel , 1 ) ;
advancedHitLabel = new QLabel( vbox ) ;
advancedHitLabel = new T QLabel( vbox ) ;
vbox - > setStretchFactor ( advancedHitLabel , 1 ) ;
hbox - > setStretchFactor ( vbox , 1 ) ;
// "Search:" label
QLabel * searchLabel = new QLabel( this , " SearchLabel " ) ;
T QLabel * searchLabel = new T QLabel( this , " SearchLabel " ) ;
searchLabel - > setText ( i18n ( " &Search: " ) ) ;
searchLabel - > setFont ( KGlobalSettings : : toolBarFont ( ) ) ;
searchLabel - > setMargin ( 2 ) ;
@ -151,21 +151,21 @@ void MainWindow::buildActions()
0 , 0 , actionCollection ( ) , " search " ) ;
searchAction - > setShortcutConfigurable ( false ) ;
searchAction - > setAutoSized ( true ) ;
QWhatsThis: : add ( search , i18n ( " Search Bar<p>Enter a search term. " ) ) ;
T QWhatsThis: : add ( search , i18n ( " Search Bar<p>Enter a search term. " ) ) ;
// The Clear search box button.
KToolBarButton * clearWidget = new KToolBarButton ( QApplication: : reverseLayout ( ) ? " clear_left " : " locationbar_erase " ,
KToolBarButton * clearWidget = new KToolBarButton ( T QApplication: : reverseLayout ( ) ? " clear_left " : " locationbar_erase " ,
0 , this ) ;
searchClear = new KWidgetAction ( clearWidget , QString( " " ) , CTRL + Key_L , search , SLOT( clear ( ) ) ,
searchClear = new KWidgetAction ( clearWidget , T QString( " " ) , CTRL + Key_L , TQT_TQOBJECT( search) , TQT_ SLOT( clear ( ) ) ,
actionCollection ( ) , " searchReset " ) ;
connect ( clearWidget , SIGNAL( clicked ( ) ) , searchClear , SLOT( activate ( ) ) ) ;
connect ( clearWidget , TQT_ SIGNAL( clicked ( ) ) , searchClear , TQT_ SLOT( activate ( ) ) ) ;
searchClear - > setWhatsThis ( i18n ( " Reset Search \n "
" Resets the search so that "
" all items are shown again. " ) ) ;
// Top level pages.
QValueList< MenuItem > subMenus = menu - > menuList ( ) ;
QValueList< MenuItem > : : iterator it ;
T QValueList< MenuItem > subMenus = menu - > menuList ( ) ;
T QValueList< MenuItem > : : iterator it ;
for ( it = subMenus . begin ( ) ; it ! = subMenus . end ( ) ; + + it ) {
if ( ( * it ) . menu ) {
KServiceGroup : : Ptr group = KServiceGroup : : group ( ( * it ) . subMenu ) ;
@ -174,8 +174,8 @@ void MainWindow::buildActions()
continue ;
}
KRadioAction * newAction = new KRadioAction ( group - > caption ( ) , group - > icon ( ) , KShortcut ( ) , this ,
SLOT( slotTopPage ( ) ) , actionCollection ( ) , group - > relPath ( ) ) ;
KRadioAction * newAction = new KRadioAction ( group - > caption ( ) , group - > icon ( ) , KShortcut ( ) , TQT_TQOBJECT ( this ) ,
TQT_ SLOT( slotTopPage ( ) ) , actionCollection ( ) , group - > relPath ( ) ) ;
pageActions . append ( newAction ) ;
kdDebug ( ) < < " relpath is : " < < group - > relPath ( ) < < endl ;
}
@ -225,17 +225,17 @@ void MainWindow::showAllModules()
resetModuleHelp ( ) ;
}
void MainWindow : : slotItemSelected ( QIconViewItem * item ) {
void MainWindow : : slotItemSelected ( T QIconViewItem * item ) {
ModuleIconItem * mItem = ( ModuleIconItem * ) item ;
if ( ! mItem )
return ;
groupWidget = moduleItemToWidgetDict . find( mItem ) ;
scrollView = moduleItemToScrollerDict . find( mItem ) ;
groupWidget = moduleItemToWidgetDict . tq find( mItem ) ;
scrollView = moduleItemToScrollerDict . tq find( mItem ) ;
if ( groupWidget = = 0 ) {
QValueList< KCModuleInfo > list = mItem - > modules ;
T QValueList< KCModuleInfo > list = mItem - > modules ;
KDialogBase : : DialogType type = KDialogBase : : IconList ;
if ( list . count ( ) = = 1 ) {
type = KDialogBase : : Plain ;
@ -248,18 +248,18 @@ void MainWindow::slotItemSelected( QIconViewItem *item ){
moduleItemToScrollerDict . insert ( mItem , scrollView ) ;
moduleItemToWidgetDict . insert ( mItem , groupWidget ) ;
connect ( groupWidget , SIGNAL( aboutToShow ( KCModuleProxy * ) ) , this , SLOT( updateModuleHelp ( KCModuleProxy * ) ) ) ;
connect ( groupWidget , SIGNAL( aboutToShowPage ( QWidget* ) ) , this , SLOT( widgetChange ( ) ) ) ;
connect ( groupWidget , SIGNAL( finished ( ) ) , this , SLOT( groupModulesFinished ( ) ) ) ;
connect ( groupWidget , SIGNAL( close ( ) ) , this , SLOT( showAllModules ( ) ) ) ;
connect ( groupWidget , TQT_ SIGNAL( aboutToShow ( KCModuleProxy * ) ) , TQT_TQOBJECT ( this ) , TQT_ SLOT( updateModuleHelp ( KCModuleProxy * ) ) ) ;
connect ( groupWidget , TQT_ SIGNAL( aboutToShowPage ( T QWidget* ) ) , TQT_TQOBJECT ( this ) , TQT_ SLOT( widgetChange ( ) ) ) ;
connect ( groupWidget , TQT_ SIGNAL( finished ( ) ) , TQT_TQOBJECT ( this ) , TQT_ SLOT( groupModulesFinished ( ) ) ) ;
connect ( groupWidget , TQT_ SIGNAL( close ( ) ) , TQT_TQOBJECT ( this ) , TQT_ SLOT( showAllModules ( ) ) ) ;
QValueList< KCModuleInfo > : : iterator it ;
T QValueList< KCModuleInfo > : : iterator it ;
for ( it = list . begin ( ) ; it ! = list . end ( ) ; + + it ) {
qDebug ( " adding %s %s " , ( * it ) . moduleName ( ) . latin1 ( ) , ( * it ) . fileName ( ) . latin1 ( ) ) ;
groupWidget - > addModule ( * it ) ;
}
groupWidget - > reparent ( scrollView - > viewport ( ) , 0 , QPoint( ) ) ;
scrollView - > reparent ( windowStack , 0 , QPoint( ) ) ;
groupWidget - > reparent ( scrollView - > viewport ( ) , 0 , T QPoint( ) ) ;
scrollView - > reparent ( windowStack , 0 , T QPoint( ) ) ;
}
if ( embeddedWindows ) {
@ -284,12 +284,12 @@ void MainWindow::slotItemSelected( QIconViewItem *item ){
// We resize and expand the window if neccessary, but only once the window has been updated.
// Some modules seem to dynamically change thier size. The new size is only available
// once the dialog is updated. :-/ -SBE
QTimer: : singleShot ( 0 , this , SLOT( timerResize ( ) ) ) ;
T QTimer: : singleShot ( 0 , this , TQT_ SLOT( timerResize ( ) ) ) ;
}
void MainWindow : : timerResize ( ) {
QSize currentSize = size ( ) ;
QSize newSize = currentSize . expandedTo ( sizeHint( ) ) ;
T QSize currentSize = size ( ) ;
T QSize newSize = currentSize . expandedTo ( tq sizeHint( ) ) ;
// Avoid resizing if possible.
if ( newSize ! = currentSize ) {
resize ( newSize ) ;
@ -298,8 +298,8 @@ void MainWindow::timerResize() {
void MainWindow : : updateModuleHelp ( KCModuleProxy * currentModule ) {
if ( currentModule - > aboutData ( ) ) {
aboutModuleAction - > setText ( i18n ( " Help menu->about <modulename> " , " About %1 " ) . arg(
currentModule - > moduleInfo ( ) . moduleName ( ) . replace( " & " , " && " ) ) ) ;
aboutModuleAction - > setText ( i18n ( " Help menu->about <modulename> " , " About %1 " ) . tq arg(
currentModule - > moduleInfo ( ) . moduleName ( ) . tq replace( " & " , " && " ) ) ) ;
aboutModuleAction - > setIcon ( currentModule - > moduleInfo ( ) . icon ( ) ) ;
aboutModuleAction - > setEnabled ( true ) ;
}
@ -310,12 +310,12 @@ void MainWindow::updateModuleHelp( KCModuleProxy *currentModule ) {
void MainWindow : : resetModuleHelp ( ) {
aboutModuleAction - > setText ( i18n ( " About Current Module " ) ) ;
aboutModuleAction - > setIconSet ( QIconSet( ) ) ;
aboutModuleAction - > setIconSet ( T QIconSet( ) ) ;
aboutModuleAction - > setEnabled ( false ) ;
}
void MainWindow : : widgetChange ( ) {
QString name ;
T QString name ;
if ( groupWidget & & groupWidget - > currentModule ( ) ) {
name = groupWidget - > currentModule ( ) - > moduleInfo ( ) . moduleName ( ) ;
}
@ -332,7 +332,7 @@ void MainWindow::widgetChange() {
void MainWindow : : slotTopPage ( ) {
KRadioAction * clickedRadioAction = ( KRadioAction * ) sender ( ) ;
selectedPage = pageActions . find( clickedRadioAction ) ;
selectedPage = pageActions . tq find( clickedRadioAction ) ;
KRadioAction * currentRadioAction ;
for ( currentRadioAction = pageActions . first ( ) ; currentRadioAction ; currentRadioAction = pageActions . next ( ) ) {
@ -342,18 +342,18 @@ void MainWindow::slotTopPage() {
windowStack - > raiseWidget ( overviewPages . at ( selectedPage ) ) ;
}
void MainWindow : : slotSearchHits ( const QString & query , int * hitList , int length ) {
void MainWindow : : slotSearchHits ( const T QString & query , int * hitList , int length ) {
if ( query = = " " ) {
generalHitLabel - > setText ( " " ) ;
advancedHitLabel - > setText ( " " ) ;
} else {
if ( length > = 1 ) {
generalHitLabel - > setText ( i18n ( " %1 hit in General " , " %1 hits in General " , hitList [ 0 ] ) . arg( hitList [ 0 ] ) ) ;
generalHitLabel - > setText ( i18n ( " %1 hit in General " , " %1 hits in General " , hitList [ 0 ] ) . tq arg( hitList [ 0 ] ) ) ;
}
if ( length > = 2 ) {
advancedHitLabel - > setText ( i18n ( " %1 hit in Advanced " , " %1 hits in Advanced " , hitList [ 1 ] ) . arg( hitList [ 1 ] ) ) ;
advancedHitLabel - > setText ( i18n ( " %1 hit in Advanced " , " %1 hits in Advanced " , hitList [ 1 ] ) . tq arg( hitList [ 1 ] ) ) ;
}
}