@ -33,93 +33,93 @@
# include <kurlrequesterdlg.h>
# include <kparts/genericfactory.h>
# include < qcheckbox.h>
# include < qdir.h>
# include < qlayout.h>
# include < qlabel.h>
# include < qptrlist.h>
# include < qpixmap.h>
# include < qpushbutton.h>
# include < qlistview.h>
# include < qwhatsthis.h>
# include < qwidget.h>
# include < t qcheckbox.h>
# include < t qdir.h>
# include < t qlayout.h>
# include < t qlabel.h>
# include < t qptrlist.h>
# include < t qpixmap.h>
# include < t qpushbutton.h>
# include < t qlistview.h>
# include < t qwhatsthis.h>
# include < t qwidget.h>
# include <unistd.h>
class ThemeData : public QListViewItem {
class ThemeData : public T QListViewItem {
public :
ThemeData ( QListView * parent = 0 ) : QListViewItem( parent ) { }
ThemeData ( T QListView * tq parent = 0 ) : T QListViewItem( tq parent ) { }
QString name ;
QString path ;
QString screenShot ;
QString copyright ;
QString description ;
T QString name ;
T QString path ;
T QString screenShot ;
T QString copyright ;
T QString description ;
} ;
typedef KGenericFactory < KDMThemeWidget , QWidget> kdmthemeFactory ;
typedef KGenericFactory < KDMThemeWidget , T QWidget> kdmthemeFactory ;
K_EXPORT_COMPONENT_FACTORY ( kcm_kdmtheme , kdmthemeFactory ( " kcmkdmtheme " ) )
KDMThemeWidget : : KDMThemeWidget ( QWidget * parent, const char * name , const QStringList& )
: KCModule ( parent, name ) , config ( 0L )
KDMThemeWidget : : KDMThemeWidget ( T QWidget * tq parent, const char * name , const T QStringList& )
: KCModule ( tq parent, name ) , config ( 0L )
{
QGridLayout * ml = new QGridLayout( this ) ;
T QGridLayout * ml = new T QGridLayout( this ) ;
ml - > setSpacing ( KDialog : : spacingHint ( ) ) ;
ml - > setMargin ( KDialog : : marginHint ( ) ) ;
cUseTheme = new QCheckBox( this ) ;
cUseTheme = new T QCheckBox( this ) ;
cUseTheme - > setText ( i18n ( " En&able KDM Themes " ) ) ;
ml - > addMultiCellWidget ( cUseTheme , 0 , 0 , 0 , 2 ) ;
themeWidget = new QListView( this ) ;
themeWidget = new T QListView( this ) ;
themeWidget - > addColumn ( i18n ( " Theme " ) ) ;
themeWidget - > addColumn ( i18n ( " Author " ) ) ;
themeWidget - > setAllColumnsShowFocus ( true ) ;
themeWidget - > setShowSortIndicator ( true ) ;
themeWidget - > setRootIsDecorated ( false ) ;
QWhatsThis: : add ( themeWidget , i18n ( " This is a list of installed themes. \n "
T QWhatsThis: : add ( themeWidget , i18n ( " This is a list of installed themes. \n "
" Click the one to be used. " ) ) ;
ml - > addMultiCellWidget ( themeWidget , 1 , 3 , 0 , 1 ) ;
preview = new QLabel( this ) ;
preview - > setFixedSize ( QSize( 200 , 150 ) ) ;
preview = new T QLabel( this ) ;
preview - > setFixedSize ( T QSize( 200 , 150 ) ) ;
preview - > setScaledContents ( true ) ;
QWhatsThis: : add ( preview , i18n ( " This is a screen shot of what KDM will look like. " ) ) ;
T QWhatsThis: : add ( preview , i18n ( " This is a screen shot of what KDM will look like. " ) ) ;
ml - > addWidget ( preview , 1 , 2 ) ;
info = new QLabel( this ) ;
info = new T QLabel( this ) ;
info - > setMaximumWidth ( 200 ) ;
info - > setAlignment( int ( QLabel: : AlignTop | QLabel: : WordBreak ) ) ;
QWhatsThis: : add ( info , i18n ( " This contains information about the selected theme. " ) ) ;
info - > tq setAlignment( int ( T QLabel: : AlignTop | T QLabel: : WordBreak ) ) ;
T QWhatsThis: : add ( info , i18n ( " This contains information about the selected theme. " ) ) ;
ml - > addMultiCellWidget ( info , 3 , 4 , 2 , 2 ) ;
bInstallTheme = new QPushButton( i18n ( " Install &new theme " ) , this ) ;
QWhatsThis: : add ( bInstallTheme , i18n ( " This will install a theme into the theme directory. " ) ) ;
bInstallTheme = new T QPushButton( i18n ( " Install &new theme " ) , this ) ;
T QWhatsThis: : add ( bInstallTheme , i18n ( " This will install a theme into the theme directory. " ) ) ;
ml - > addWidget ( bInstallTheme , 4 , 0 ) ;
bRemoveTheme = new QPushButton( i18n ( " &Remove theme " ) , this ) ;
QWhatsThis: : add ( bRemoveTheme , i18n ( " This will remove the selected theme. " ) ) ;
bRemoveTheme = new T QPushButton( i18n ( " &Remove theme " ) , this ) ;
T QWhatsThis: : add ( bRemoveTheme , i18n ( " This will remove the selected theme. " ) ) ;
ml - > addWidget ( bRemoveTheme , 4 , 1 ) ;
connect ( themeWidget , SIGNAL( selectionChanged ( ) ) , SLOT( themeSelected ( ) ) ) ;
connect ( bInstallTheme , SIGNAL( clicked ( ) ) , SLOT( installNewTheme ( ) ) ) ;
connect ( bRemoveTheme , SIGNAL( clicked ( ) ) , SLOT( removeSelectedThemes ( ) ) ) ;
connect ( cUseTheme , SIGNAL( toggled ( bool ) ) , SLOT( toggleUseTheme ( bool ) ) ) ;
connect ( themeWidget , TQT_ SIGNAL( selectionChanged ( ) ) , TQT_ SLOT( themeSelected ( ) ) ) ;
connect ( bInstallTheme , TQT_ SIGNAL( clicked ( ) ) , TQT_ SLOT( installNewTheme ( ) ) ) ;
connect ( bRemoveTheme , TQT_ SIGNAL( clicked ( ) ) , TQT_ SLOT( removeSelectedThemes ( ) ) ) ;
connect ( cUseTheme , TQT_ SIGNAL( toggled ( bool ) ) , TQT_ SLOT( toggleUseTheme ( bool ) ) ) ;
QStringList themeDirs = KGlobal : : dirs ( ) - > findDirs ( " data " , " kdm/ " ) ;
T QStringList themeDirs = KGlobal : : dirs ( ) - > findDirs ( " data " , " kdm/ " ) ;
themeDir = KGlobal : : dirs ( ) - > findDirs ( " data " , " kdm/ " ) . last ( ) ;
QDir d ;
for ( QStringList: : Iterator dirs = themeDirs . begin ( ) ; dirs ! = themeDirs . end ( ) ; + + dirs ) {
T QDir d ;
for ( T QStringList: : Iterator dirs = themeDirs . begin ( ) ; dirs ! = themeDirs . end ( ) ; + + dirs ) {
kdDebug ( ) < < " Loading themes... ( " + * dirs + " themes/ " + " ) " < < endl ;
d . setPath ( * dirs + " themes/ " ) ;
d . setFilter ( QDir: : Dirs ) ;
QStringList list = d . entryList ( ) ;
for ( QStringList: : Iterator it = list . begin ( ) ; it ! = list . end ( ) ; + + it ) {
d . setFilter ( T QDir: : Dirs ) ;
T QStringList list = d . entryList ( ) ;
for ( T QStringList: : Iterator it = list . begin ( ) ; it ! = list . end ( ) ; + + it ) {
if ( * it = = " . " | | * it = = " .. " ) continue ;
insertTheme ( * dirs + " themes/ " + * it ) ;
}
@ -133,9 +133,9 @@ KDMThemeWidget::KDMThemeWidget( QWidget *parent, const char *name, const QString
}
}
void KDMThemeWidget : : selectTheme ( const QString & path )
void KDMThemeWidget : : selectTheme ( const T QString & path )
{
for ( QListViewItemIterator tdi ( themeWidget ) ; tdi . current ( ) ; tdi + + ) {
for ( T QListViewItemIterator tdi ( themeWidget ) ; tdi . current ( ) ; tdi + + ) {
ThemeData * td = ( ( ThemeData * ) * tdi ) ;
if ( td - > path = = path ) {
themeWidget - > clearSelection ( ) ;
@ -147,7 +147,7 @@ void KDMThemeWidget::selectTheme( const QString &path )
void KDMThemeWidget : : load ( )
{
QString kdmrc = KGlobal : : dirs ( ) - > findResource ( " config " , " kdm/kdmrc " ) ;
T QString kdmrc = KGlobal : : dirs ( ) - > findResource ( " config " , " kdm/kdmrc " ) ;
if ( kdmrc . isEmpty ( ) ) {
kdError ( ) < < " Failed to find kdm resource file kdmrc! " < < endl ;
@ -195,10 +195,10 @@ void KDMThemeWidget::setReadOnly(bool ro)
bRemoveTheme - > setEnabled ( ro ) ;
}
void KDMThemeWidget : : insertTheme ( const QString & _theme )
void KDMThemeWidget : : insertTheme ( const T QString & _theme )
{
KConfig * themeConfig ;
QString name ;
T QString name ;
kdDebug ( ) < < " Looking for " < < _theme < < " /KdmGreeterTheme.desktop " < < endl ;
themeConfig = new KConfig ( _theme + " /KdmGreeterTheme.desktop " ) ;
@ -214,7 +214,7 @@ void KDMThemeWidget::insertTheme( const QString &_theme )
return ;
}
for ( QListViewItemIterator tdi ( themeWidget ) ; tdi . current ( ) ; tdi + + ) {
for ( T QListViewItemIterator tdi ( themeWidget ) ; tdi . current ( ) ; tdi + + ) {
ThemeData * td = ( ( ThemeData * ) * tdi ) ;
if ( td - > name = = name )
return ;
@ -242,21 +242,21 @@ void KDMThemeWidget::updateInfoView( ThemeData *theme )
theme - > description ) : " " ) ) ;
preview - > setPixmap ( theme - > path + ' / ' + theme - > screenShot ) ;
preview - > setText ( theme - > screenShot . isEmpty ( ) ?
" Screenshot not available " : QString( ) ) ;
" Screenshot not available " : T QString( ) ) ;
}
void KDMThemeWidget : : installNewTheme ( )
{
KURLRequesterDlg fileRequester ( QString: : null , this , i18n ( " Drag or Type Theme URL " ) ) ;
KURLRequesterDlg fileRequester ( TQString( ) , this , i18n ( " Drag or Type Theme URL " ) ) ;
fileRequester . urlRequester ( ) - > setMode ( KFile : : File | KFile : : Directory | KFile : : ExistingOnly ) ;
KURL themeURL = fileRequester . getURL ( ) ;
if ( themeURL . isEmpty ( ) )
return ;
QString themeTmpFile ;
T QString themeTmpFile ;
if ( ! KIO : : NetAccess : : download ( themeURL , themeTmpFile , this ) ) {
QString sorryText ;
T QString sorryText ;
if ( themeURL . isLocalFile ( ) )
sorryText = i18n ( " Unable to find the KDM theme archive %1. " , themeURL . prettyURL ( ) ) ;
else
@ -266,14 +266,14 @@ void KDMThemeWidget::installNewTheme()
return ;
}
QList< KArchiveDirectory > foundThemes ;
T QList< KArchiveDirectory > foundThemes ;
KTar archive ( themeTmpFile ) ;
archive . open ( IO_ReadOnly ) ;
const KArchiveDirectory * archDir = archive . directory ( ) ;
QStringList entries = archDir - > entries ( ) ;
for ( QStringList: : Iterator ent = entries . begin ( ) ; ent ! = entries . end ( ) ; + + ent ) {
T QStringList entries = archDir - > entries ( ) ;
for ( T QStringList: : Iterator ent = entries . begin ( ) ; ent ! = entries . end ( ) ; + + ent ) {
const KArchiveEntry * possibleDir = archDir - > entry ( * ent ) ;
if ( possibleDir - > isDirectory ( ) ) {
const KArchiveDirectory * subDir =
@ -289,7 +289,7 @@ void KDMThemeWidget::installNewTheme()
KMessageBox : : error ( this , i18n ( " The file is not a valid KDM theme archive. " ) ) ;
else {
KProgressDialog progressDiag ( this ,
i18n ( " Installing KDM themes " ) , QString( ) ) ;
i18n ( " Installing KDM themes " ) , T QString( ) ) ;
progressDiag . setModal ( true ) ;
progressDiag . setAutoClose ( true ) ;
progressDiag . progressBar ( ) - > setTotalSteps ( foundThemes . count ( ) ) ;
@ -299,10 +299,10 @@ void KDMThemeWidget::installNewTheme()
progressDiag . setLabel (
i18n ( " <qt>Installing <strong>%1</strong> theme</qt> " , ard - > name ( ) ) ) ;
QString path = themeDir + " themes/ " + ard - > name ( ) ;
T QString path = themeDir + " themes/ " + ard - > name ( ) ;
kdDebug ( ) < < " Unpacking new theme to " < < path < < endl ;
ard - > copyTo ( path , true ) ;
if ( QDir( path ) . exists ( ) )
if ( T QDir( path ) . exists ( ) )
insertTheme ( path ) ;
progressDiag . progressBar ( ) - > setValue ( progressDiag . progressBar ( ) - > value ( ) + 1 ) ;
@ -329,7 +329,7 @@ void KDMThemeWidget::themeSelected()
void KDMThemeWidget : : removeSelectedThemes ( )
{
QListViewItem * themes = themeWidget - > selectedItem ( ) ;
T QListViewItem * themes = themeWidget - > selectedItem ( ) ;
if ( ! themes )
return ;
if ( KMessageBox : : questionYesNoList ( this ,