|
|
|
@ -36,10 +36,10 @@
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#include <qfileinfo.h>
|
|
|
|
|
#include <qlayout.h>
|
|
|
|
|
#include <qlabel.h>
|
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
|
#include <tqfileinfo.h>
|
|
|
|
|
#include <tqlayout.h>
|
|
|
|
|
#include <tqlabel.h>
|
|
|
|
|
#include <tqpushbutton.h>
|
|
|
|
|
|
|
|
|
|
#include <kdebug.h>
|
|
|
|
|
#include <kapplication.h>
|
|
|
|
@ -64,9 +64,9 @@
|
|
|
|
|
#include <ksvgiconengine.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <qdir.h>
|
|
|
|
|
#include <qpainter.h>
|
|
|
|
|
#include <qregexp.h>
|
|
|
|
|
#include <tqdir.h>
|
|
|
|
|
#include <tqpainter.h>
|
|
|
|
|
#include <tqregexp.h>
|
|
|
|
|
|
|
|
|
|
#include "themes.h"
|
|
|
|
|
#include <kurlrequester.h>
|
|
|
|
@ -77,7 +77,7 @@
|
|
|
|
|
// ----------
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
IconThemesConfig::IconThemesConfig( QWidget *parent, KListView *themesView /*, QPushButton *removethemeBtn*/ )
|
|
|
|
|
IconThemesConfig::IconThemesConfig( TQWidget *parent, KListView *themesView /*, TQPushButton *removethemeBtn*/ )
|
|
|
|
|
{
|
|
|
|
|
parent_ = parent;
|
|
|
|
|
themesView_ = themesView;
|
|
|
|
@ -99,9 +99,9 @@ IconThemesConfig::~IconThemesConfig()
|
|
|
|
|
// ----------
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
QListViewItem *IconThemesConfig::iconThemeItem( const QString &name )
|
|
|
|
|
TQListViewItem *IconThemesConfig::iconThemeItem( const TQString &name )
|
|
|
|
|
{
|
|
|
|
|
QListViewItem * item;
|
|
|
|
|
TQListViewItem * item;
|
|
|
|
|
for ( item = themesView_->firstChild(); item ; item = item->nextSibling() )
|
|
|
|
|
if ( item->text( 0 ) == name ) return item;
|
|
|
|
|
|
|
|
|
@ -118,38 +118,38 @@ void IconThemesConfig::loadThemes()
|
|
|
|
|
{
|
|
|
|
|
themesView_->clear();
|
|
|
|
|
m_themeNames.clear();
|
|
|
|
|
QStringList themelist;
|
|
|
|
|
QString name;
|
|
|
|
|
QString place;
|
|
|
|
|
QStringList::Iterator it, itj;
|
|
|
|
|
QStringList themesDirs;
|
|
|
|
|
TQStringList themelist;
|
|
|
|
|
TQString name;
|
|
|
|
|
TQString place;
|
|
|
|
|
TQStringList::Iterator it, itj;
|
|
|
|
|
TQStringList themesDirs;
|
|
|
|
|
|
|
|
|
|
// if no local deKorator folders
|
|
|
|
|
if ( ! QDir( QDir::homeDirPath() + "/.kde/share/apps/" ).exists( "deKorator" ) )
|
|
|
|
|
if ( ! TQDir( TQDir::homeDirPath() + "/.kde/share/apps/" ).exists( "deKorator" ) )
|
|
|
|
|
{
|
|
|
|
|
qWarning( "no dirs, will make them..." );
|
|
|
|
|
KIO::mkdir( QDir::homeDirPath() + "/.kde/share/apps/deKorator/" );
|
|
|
|
|
KIO::mkdir( QDir::homeDirPath() + "/.kde/share/apps/deKorator/themes/" );
|
|
|
|
|
tqWarning( "no dirs, will make them..." );
|
|
|
|
|
KIO::mkdir( TQDir::homeDirPath() + "/.kde/share/apps/deKorator/" );
|
|
|
|
|
KIO::mkdir( TQDir::homeDirPath() + "/.kde/share/apps/deKorator/themes/" );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
qWarning( "exist" );
|
|
|
|
|
tqWarning( "exist" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
themesDirs = KGlobal::dirs() ->findDirs( "data", "deKorator/themes" ) ;
|
|
|
|
|
|
|
|
|
|
for ( it = themesDirs.begin(); it != themesDirs.end(); ++it )
|
|
|
|
|
{
|
|
|
|
|
QDir dir = QDir( *it );
|
|
|
|
|
TQDir dir = TQDir( *it );
|
|
|
|
|
themelist = dir.entryList( "*-theme" );
|
|
|
|
|
|
|
|
|
|
for ( itj = themelist.begin(); itj != themelist.end(); ++itj )
|
|
|
|
|
{
|
|
|
|
|
place = *it;
|
|
|
|
|
|
|
|
|
|
name = ( QString ) * itj;
|
|
|
|
|
name = ( TQString ) * itj;
|
|
|
|
|
|
|
|
|
|
themesView_->insertItem( new QListViewItem( themesView_, name ) );
|
|
|
|
|
themesView_->insertItem( new TQListViewItem( themesView_, name ) );
|
|
|
|
|
|
|
|
|
|
m_themeNames.insert( name, place );
|
|
|
|
|
}
|
|
|
|
@ -164,7 +164,7 @@ void IconThemesConfig::loadThemes()
|
|
|
|
|
void IconThemesConfig::installNewTheme()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
KURL themeURL = KURLRequesterDlg::getURL( QString::null, parent_,
|
|
|
|
|
KURL themeURL = KURLRequesterDlg::getURL( TQString::null, parent_,
|
|
|
|
|
i18n( "Drag or Type Theme URL" ) );
|
|
|
|
|
kdDebug() << themeURL.prettyURL() << endl;
|
|
|
|
|
|
|
|
|
@ -172,11 +172,11 @@ void IconThemesConfig::installNewTheme()
|
|
|
|
|
return ;
|
|
|
|
|
|
|
|
|
|
// themeTmpFile contains the name of the downloaded file
|
|
|
|
|
QString themeTmpFile;
|
|
|
|
|
TQString themeTmpFile;
|
|
|
|
|
|
|
|
|
|
if ( !KIO::NetAccess::download( themeURL, themeTmpFile, parent_ ) )
|
|
|
|
|
{
|
|
|
|
|
QString sorryText;
|
|
|
|
|
TQString sorryText;
|
|
|
|
|
if ( themeURL.isLocalFile() )
|
|
|
|
|
sorryText = i18n( "Unable to find the deKorator theme archive %1." );
|
|
|
|
|
else
|
|
|
|
@ -187,10 +187,10 @@ void IconThemesConfig::installNewTheme()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
QStringList themesNames = findThemeDirs( themeTmpFile );
|
|
|
|
|
TQStringList themesNames = findThemeDirs( themeTmpFile );
|
|
|
|
|
if ( themesNames.isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
QString invalidArch( i18n( "The file is not a valid deKorator theme archive." ) );
|
|
|
|
|
TQString invalidArch( i18n( "The file is not a valid deKorator theme archive." ) );
|
|
|
|
|
KMessageBox::error( parent_, invalidArch );
|
|
|
|
|
|
|
|
|
|
KIO::NetAccess::removeTempFile( themeTmpFile );
|
|
|
|
@ -200,8 +200,8 @@ void IconThemesConfig::installNewTheme()
|
|
|
|
|
if ( !installThemes( themesNames, themeTmpFile ) )
|
|
|
|
|
{
|
|
|
|
|
//FIXME: make me able to know what is wrong....
|
|
|
|
|
// QStringList instead of bool?
|
|
|
|
|
QString somethingWrong =
|
|
|
|
|
// TQStringList instead of bool?
|
|
|
|
|
TQString somethingWrong =
|
|
|
|
|
i18n( "A problem occurred during the installation process; "
|
|
|
|
|
"however, most of the themes in the archive have been installed" );
|
|
|
|
|
KMessageBox::error( parent_, somethingWrong );
|
|
|
|
@ -211,9 +211,9 @@ void IconThemesConfig::installNewTheme()
|
|
|
|
|
|
|
|
|
|
loadThemes();
|
|
|
|
|
|
|
|
|
|
QStringList::Iterator cur = themesNames.at( 0 );
|
|
|
|
|
TQStringList::Iterator cur = themesNames.at( 0 );
|
|
|
|
|
|
|
|
|
|
QListViewItem *item = iconThemeItem( *cur );
|
|
|
|
|
TQListViewItem *item = iconThemeItem( *cur );
|
|
|
|
|
themesView_->setSelected( item, true );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -222,14 +222,14 @@ void IconThemesConfig::installNewTheme()
|
|
|
|
|
// ----------
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
bool IconThemesConfig::installThemes( const QStringList &themes, const QString &archiveName )
|
|
|
|
|
bool IconThemesConfig::installThemes( const TQStringList &themes, const TQString &archiveName )
|
|
|
|
|
{
|
|
|
|
|
bool everythingOk = true;
|
|
|
|
|
QString localThemesDir = QDir::homeDirPath() + "/.kde/share/apps/deKorator/themes/";
|
|
|
|
|
TQString localThemesDir = TQDir::homeDirPath() + "/.kde/share/apps/deKorator/themes/";
|
|
|
|
|
//
|
|
|
|
|
KProgressDialog progressDiag( parent_, "themeinstallprogress",
|
|
|
|
|
i18n( "Installing icon themes" ),
|
|
|
|
|
QString::null,
|
|
|
|
|
TQString::null,
|
|
|
|
|
true );
|
|
|
|
|
progressDiag.setAutoClose( true );
|
|
|
|
|
progressDiag.progressBar() ->setTotalSteps( themes.count() );
|
|
|
|
@ -242,7 +242,7 @@ bool IconThemesConfig::installThemes( const QStringList &themes, const QString &
|
|
|
|
|
const KArchiveDirectory* rootDir = archive.directory();
|
|
|
|
|
|
|
|
|
|
KArchiveDirectory* currentTheme;
|
|
|
|
|
for ( QStringList::ConstIterator it = themes.begin(); it != themes.end(); ++it )
|
|
|
|
|
for ( TQStringList::ConstIterator it = themes.begin(); it != themes.end(); ++it )
|
|
|
|
|
{
|
|
|
|
|
progressDiag.setLabel(
|
|
|
|
|
i18n( "<qt>Installing <strong>%1</strong> theme</qt>" )
|
|
|
|
@ -276,9 +276,9 @@ bool IconThemesConfig::installThemes( const QStringList &themes, const QString &
|
|
|
|
|
// ----------
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
QStringList IconThemesConfig::findThemeDirs( const QString &archiveName )
|
|
|
|
|
TQStringList IconThemesConfig::findThemeDirs( const TQString &archiveName )
|
|
|
|
|
{
|
|
|
|
|
QStringList foundThemes;
|
|
|
|
|
TQStringList foundThemes;
|
|
|
|
|
|
|
|
|
|
KTar archive( archiveName );
|
|
|
|
|
archive.open( IO_ReadOnly );
|
|
|
|
@ -288,11 +288,11 @@ QStringList IconThemesConfig::findThemeDirs( const QString &archiveName )
|
|
|
|
|
KArchiveDirectory* subDir = 0L;
|
|
|
|
|
|
|
|
|
|
// iterate all the dirs looking for an index.theme or index.desktop file
|
|
|
|
|
QStringList entries = themeDir->entries();
|
|
|
|
|
for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
|
|
|
|
|
TQStringList entries = themeDir->entries();
|
|
|
|
|
for ( TQStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
|
|
|
|
|
{
|
|
|
|
|
QString name = ( QString ) * it;
|
|
|
|
|
QRegExp rxp = QRegExp( "*-theme", TRUE, TRUE );
|
|
|
|
|
TQString name = ( TQString ) * it;
|
|
|
|
|
TQRegExp rxp = TQRegExp( "*-theme", TRUE, TRUE );
|
|
|
|
|
int i = name.contains( rxp );
|
|
|
|
|
if ( !i )
|
|
|
|
|
{
|
|
|
|
@ -306,7 +306,7 @@ QStringList IconThemesConfig::findThemeDirs( const QString &archiveName )
|
|
|
|
|
if ( subDir && ( subDir->entry( "deco" ) != NULL && subDir->entry( "buttons" ) != NULL && subDir->entry( "masks" ) != NULL ) )
|
|
|
|
|
{
|
|
|
|
|
foundThemes.append( subDir->name() );
|
|
|
|
|
//qWarning( "found" );
|
|
|
|
|
//tqWarning( "found" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -323,11 +323,11 @@ QStringList IconThemesConfig::findThemeDirs( const QString &archiveName )
|
|
|
|
|
|
|
|
|
|
void IconThemesConfig::removeSelectedTheme()
|
|
|
|
|
{
|
|
|
|
|
QListViewItem * selected = themesView_->selectedItem();
|
|
|
|
|
TQListViewItem * selected = themesView_->selectedItem();
|
|
|
|
|
if ( !selected )
|
|
|
|
|
return ;
|
|
|
|
|
|
|
|
|
|
QString question = i18n( "<qt>Are you sure you want to remove the "
|
|
|
|
|
TQString question = i18n( "<qt>Are you sure you want to remove the "
|
|
|
|
|
"<strong>%1</strong> theme?<br>"
|
|
|
|
|
"<br>"
|
|
|
|
|
"This will delete the files installed by this theme.</qt>" ).
|
|
|
|
@ -336,9 +336,9 @@ void IconThemesConfig::removeSelectedTheme()
|
|
|
|
|
int r = KMessageBox::warningContinueCancel( parent_, question, i18n( "Confirmation" ), KStdGuiItem::del() );
|
|
|
|
|
if ( r != KMessageBox::Continue ) return ;
|
|
|
|
|
|
|
|
|
|
QString delTheme = selected->text( 0 );
|
|
|
|
|
QString deldirStr = QDir::homeDirPath() + "/.kde/share/apps/deKorator/themes/" + delTheme;
|
|
|
|
|
QDir dir = QDir( deldirStr );
|
|
|
|
|
TQString delTheme = selected->text( 0 );
|
|
|
|
|
TQString deldirStr = TQDir::homeDirPath() + "/.kde/share/apps/deKorator/themes/" + delTheme;
|
|
|
|
|
TQDir dir = TQDir( deldirStr );
|
|
|
|
|
dir.rename( deldirStr, deldirStr + "del" );
|
|
|
|
|
|
|
|
|
|
KIO::del( KURL( deldirStr + "del" ) );
|
|
|
|
@ -351,25 +351,25 @@ void IconThemesConfig::removeSelectedTheme()
|
|
|
|
|
// ----------
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void IconThemesConfig::themeSelected( QListViewItem *item, QLabel *previewLabel, QPushButton *btn )
|
|
|
|
|
void IconThemesConfig::themeSelected( TQListViewItem *item, TQLabel *previewLabel, TQPushButton *btn )
|
|
|
|
|
{
|
|
|
|
|
QPixmap previewPix, topLeftCornerBg, leftButtonsBg, leftTitleBg, midTitleBg, rightTitleBg, rightButtonsBg, topRightCornerBg;
|
|
|
|
|
QPainter painter;
|
|
|
|
|
TQPixmap previewPix, topLeftCornerBg, leftButtonsBg, leftTitleBg, midTitleBg, rightTitleBg, rightButtonsBg, topRightCornerBg;
|
|
|
|
|
TQPainter painter;
|
|
|
|
|
int w, h, x;
|
|
|
|
|
QString dirName( m_themeNames[ item->text( 0 ) ] );
|
|
|
|
|
TQString dirName( m_themeNames[ item->text( 0 ) ] );
|
|
|
|
|
|
|
|
|
|
if ( dirName.contains( "home" ) )
|
|
|
|
|
{
|
|
|
|
|
//qWarning("true");
|
|
|
|
|
//tqWarning("true");
|
|
|
|
|
btn->setEnabled( true );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btn->setEnabled( false );
|
|
|
|
|
//qWarning("false");
|
|
|
|
|
//tqWarning("false");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString dirNameStr = dirName + item->text( 0 ) + "/deco/" ;
|
|
|
|
|
TQString dirNameStr = dirName + item->text( 0 ) + "/deco/" ;
|
|
|
|
|
topLeftCornerBg.load( dirNameStr + "topLeftCornerBg.png" );
|
|
|
|
|
leftButtonsBg.load( dirNameStr + "leftButtonsBg" );
|
|
|
|
|
leftTitleBg.load( dirNameStr + "leftTitleBg.png" );
|
|
|
|
@ -381,23 +381,23 @@ void IconThemesConfig::themeSelected( QListViewItem *item, QLabel *previewLabel,
|
|
|
|
|
w = topLeftCornerBg.width() + leftButtonsBg.width() + leftTitleBg.width() + midTitleBg.width() + rightTitleBg.width() + rightButtonsBg.width() + topRightCornerBg.width() + 8;
|
|
|
|
|
h = midTitleBg.height() + 8;
|
|
|
|
|
previewPix.resize( w, h );
|
|
|
|
|
//qWarning("%d",w);
|
|
|
|
|
//tqWarning("%d",w);
|
|
|
|
|
painter.begin( &previewPix );
|
|
|
|
|
|
|
|
|
|
// paint outer rect
|
|
|
|
|
painter.fillRect( 0, 0, w, h, QColor( 20, 20, 20 ) );
|
|
|
|
|
painter.fillRect( 0, 0, w, h, TQColor( 20, 20, 20 ) );
|
|
|
|
|
|
|
|
|
|
painter.setPen( QColor( 60, 60, 60 ) );
|
|
|
|
|
painter.setPen( TQColor( 60, 60, 60 ) );
|
|
|
|
|
painter.drawRect( 0, 0, w , h );
|
|
|
|
|
|
|
|
|
|
painter.setPen( QColor( 80, 80, 80 ) );
|
|
|
|
|
painter.setPen( TQColor( 80, 80, 80 ) );
|
|
|
|
|
painter.drawRect( 1, 1, w - 2 , h - 2 );
|
|
|
|
|
|
|
|
|
|
painter.setPen( QColor( 180, 180, 180 ) );
|
|
|
|
|
painter.setPen( TQColor( 180, 180, 180 ) );
|
|
|
|
|
painter.drawLine( w - 1, 1, w - 1, h - 1 );
|
|
|
|
|
painter.drawLine( 1, h - 1, w - 2, h - 1 );
|
|
|
|
|
|
|
|
|
|
painter.setPen( QColor( 150, 150, 150 ) );
|
|
|
|
|
painter.setPen( TQColor( 150, 150, 150 ) );
|
|
|
|
|
painter.drawLine( w - 2, 2, w - 2, h - 2 );
|
|
|
|
|
painter.drawLine( 2, h - 2, w - 3, h - 2 );
|
|
|
|
|
|
|
|
|
@ -424,7 +424,7 @@ void IconThemesConfig::themeSelected( QListViewItem *item, QLabel *previewLabel,
|
|
|
|
|
x += rightButtonsBg.width();
|
|
|
|
|
painter.drawPixmap( x, 4, topRightCornerBg );
|
|
|
|
|
|
|
|
|
|
painter.setPen( QColor( 0, 0, 0 ) );
|
|
|
|
|
painter.setPen( TQColor( 0, 0, 0 ) );
|
|
|
|
|
painter.drawLine( 4, h - 5, w - 4 , h - 5 );
|
|
|
|
|
|
|
|
|
|
painter.end();
|
|
|
|
@ -440,14 +440,14 @@ void IconThemesConfig::themeSelected( QListViewItem *item, QLabel *previewLabel,
|
|
|
|
|
|
|
|
|
|
void IconThemesConfig::setTheme( KURLRequester *framesPath, KURLRequester *buttonsPath, KURLRequester *masksPath )
|
|
|
|
|
{
|
|
|
|
|
QListViewItem * selected = themesView_->selectedItem();
|
|
|
|
|
TQListViewItem * selected = themesView_->selectedItem();
|
|
|
|
|
if ( !selected )
|
|
|
|
|
return ;
|
|
|
|
|
|
|
|
|
|
QString dirName( m_themeNames[ selected->text( 0 ) ] );
|
|
|
|
|
TQString dirName( m_themeNames[ selected->text( 0 ) ] );
|
|
|
|
|
|
|
|
|
|
QString setTheme = selected->text( 0 );
|
|
|
|
|
QString setThemeStr = dirName + setTheme;
|
|
|
|
|
TQString setTheme = selected->text( 0 );
|
|
|
|
|
TQString setThemeStr = dirName + setTheme;
|
|
|
|
|
|
|
|
|
|
framesPath->setURL( setThemeStr + "/deco" );
|
|
|
|
|
buttonsPath->setURL( setThemeStr + "/buttons" );
|
|
|
|
|