TQt4 port kdmtheme

This enables compilation under both Qt3 and Qt4


git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kdmtheme@1239295 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
v3.5.13-sru
tpearson 13 years ago
parent 215dff2396
commit 2b68fbb800

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

@ -24,20 +24,21 @@
#include <kconfig.h> #include <kconfig.h>
#include <kcmodule.h> #include <kcmodule.h>
#include <qwidget.h> #include <tqwidget.h>
class ThemeData; class ThemeData;
class QLabel; class TQLabel;
class QPushButton; class TQPushButton;
class QListView; class TQListView;
class QCheckBox; class TQCheckBox;
class KDMThemeWidget : public KCModule { class KDMThemeWidget : public KCModule {
Q_OBJECT Q_OBJECT
TQ_OBJECT
public: public:
KDMThemeWidget( QWidget *parent = 0, const char *name=0, const QStringList& = QStringList() ); KDMThemeWidget( TQWidget *tqparent = 0, const char *name=0, const TQStringList& = TQStringList() );
virtual void load(); virtual void load();
virtual void save(); virtual void save();
@ -45,19 +46,19 @@ class KDMThemeWidget : public KCModule {
void setReadOnly( bool ); void setReadOnly( bool );
private: private:
void selectTheme( const QString & ); void selectTheme( const TQString & );
void insertTheme( const QString & ); void insertTheme( const TQString & );
void updateInfoView( ThemeData * ); void updateInfoView( ThemeData * );
QListView *themeWidget; TQListView *themeWidget;
QLabel *preview; TQLabel *preview;
QLabel *info; TQLabel *info;
QPushButton *bInstallTheme; TQPushButton *bInstallTheme;
QPushButton *bRemoveTheme; TQPushButton *bRemoveTheme;
QCheckBox *cUseTheme; TQCheckBox *cUseTheme;
ThemeData *defaultTheme; ThemeData *defaultTheme;
QString themeDir; TQString themeDir;
KConfig *config; KConfig *config;
protected slots: protected slots:

Loading…
Cancel
Save