116
116
KMessageBox::sorry( this,
117
117
i18nc( "Dialog box text",
118
118
"You can only use 7 characters for the emoticon shortcuts." ),
119
i18nc( "Dialog box title", "Invalid emoticon name" ) );
119
i18nc( "Dialog box title", "Invalid Emoticon Name" ) );
121
121
// Opening the editor on the item again fails here, probably because this
122
122
// method is called as a slot by the editor itself; so only cut down the
220
220
void EmoticonsPage::removeCustomEmoticon()
222
QList<QListWidgetItem *> selectedItems = customEmoticonsView_->selectedItems();
222
const QList<QListWidgetItem *>& selectedItems( customEmoticonsView_->selectedItems() );
224
224
if( selectedItems.isEmpty() )
229
QListWidgetItem *item = selectedItems.first();
229
const QListWidgetItem *item = selectedItems.first();
231
231
// Request confirmation
232
232
int result = KMessageBox::questionYesNo( this,
345
345
customEmoticonsView_->clear();
347
347
// Add all emoticons to the list
348
const QList<Emoticon*> &emoticons = emoticonTheme_->getEmoticons();
348
const QList<Emoticon*>& emoticons( emoticonTheme_->getEmoticons() );
349
349
foreach( Emoticon *emoticon, emoticons )
351
351
if( ! emoticon->isValid() )
371
371
emoticonThemesList_->clear();
373
373
// Browse all emoticon dirs, to get all emoticons
374
QStringList themeDirs = KGlobal::dirs()->findDirs("emoticons", "");
374
const QStringList& themesDirs( KGlobal::dirs()->findDirs("emoticons", "") );
376
376
#ifdef KMESSDEBUG_EMOTICONS_SETTINGS
377
kDebug() << "Theme dirs: " << themeDirs;
377
kDebug() << "Theme dirs: " << themesDirs;
380
for( int x = 0; x < themeDirs.count(); x++ )
381
foreach( const QString& themesPath, themesDirs )
382
383
// Browse for all themes in the emoticon dir
383
QDir themeDir(themeDirs[x]);
384
QStringList themes = themeDir.entryList( QDir::Dirs, QDir::Name | QDir::IgnoreCase );
385
for( QStringList::Iterator it = themes.begin(); it != themes.end(); ++it )
384
themesDir.setPath( themesPath );
386
// Grep all themes in current dir
387
const QStringList& themes( themesDir.entryList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name | QDir::IgnoreCase ) );
389
foreach( const QString& themePath, themes )
387
QString dirName( *it );
389
// Ignore '.' and '..'
390
if( dirName == "." || dirName == ".." )
395
391
#ifdef KMESSDEBUG_EMOTICONS_SETTINGS
396
kDebug() << "Folder: " << themeDirs[x] << " - Theme: " << dirName;
392
kDebug() << "Folder: " << themesPath << " - Theme: " << themePath;
399
394
// Add the theme to the list, using the directory name; its first valid emoticon is used as a preview
400
QPixmap previewPixmap( EmoticonTheme::getThemeIcon( themeDirs[x] + dirName ) );
401
new QListWidgetItem( previewPixmap, dirName, emoticonThemesList_ );
395
const QPixmap previewPixmap( EmoticonTheme::getThemeIcon( themesPath + themePath ) );
396
new QListWidgetItem( previewPixmap, themePath, emoticonThemesList_ );
405
400
// Highlight the selected emoticon
406
401
QListWidgetItem* item = 0;
407
QList<QListWidgetItem*> items = emoticonThemesList_->findItems( emoticonStyle_, Qt::MatchExactly | Qt::MatchCaseSensitive );
402
QList<QListWidgetItem*> items( emoticonThemesList_->findItems( emoticonStyle_, Qt::MatchExactly | Qt::MatchCaseSensitive ) );
408
404
if( items.isEmpty() )
410
406
kWarning() << "Current emoticon style was not found, attempting to revert to the default setting.";
411
407
items = emoticonThemesList_->findItems( "KMess-new", Qt::MatchExactly | Qt::MatchCaseSensitive );
414
if( ! items.isEmpty() )
416
411
item = items.first();
419
414
// If there is an item, select it
422
417
emoticonThemesList_->setCurrentItem( item );