[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kopete-devel
Subject:    [kopete-devel] emoticons manager
From:       Carlo <brandon.ml () gmail ! com>
Date:       2007-08-17 1:33:52
Message-ID: 3262b6180708161833v4c0b78cbj1b44a59ba1979366 () mail ! gmail ! com
[Download RAW message or body]

Hi,
i've ported my emoticons manager
(http://www.kde-apps.org/content/show.php/Kopete+Emoticons+Manager?content=54968)
to kopete4, the only problem for now is that i've used QFileDialog
instead of KFileDialog because it crashes, i think for the same bug
that crashes kopete when you close a chat window

["kopete-emoticons.patch" (text/x-patch)]

Index: kopete/config/appearance/appearanceconfig_emoticons.ui
===================================================================
--- kopete/config/appearance/appearanceconfig_emoticons.ui	(revisione 700971)
+++ kopete/config/appearance/appearanceconfig_emoticons.ui	(copia locale)
@@ -143,6 +143,19 @@
     </widget>
    </item>
    <item row="4" column="1" >
+    <widget class="QPushButton" name="btnEditThemes">
+    <property name="sizePolicy" >
+      <sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="text">
+      <string>&amp;Edit Theme...</string>
+     </property>
+    </widget>
+   </item>
+   <item row="4" column="2" >
     <widget class="QPushButton" name="btnInstallTheme" >
      <property name="sizePolicy" >
       <sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
@@ -155,7 +168,7 @@
      </property>
     </widget>
    </item>
-   <item row="4" column="2" >
+   <item row="4" column="3" >
     <widget class="QPushButton" name="btnRemoveTheme" >
      <property name="sizePolicy" >
       <sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
@@ -168,7 +181,7 @@
      </property>
     </widget>
    </item>
-   <item row="4" column="3" >
+   <item row="4" column="4" >
     <spacer>
      <property name="orientation" >
       <enum>Qt::Horizontal</enum>
Index: kopete/config/appearance/emoticonseditwidget.ui
===================================================================
--- kopete/config/appearance/emoticonseditwidget.ui	(revisione 0)
+++ kopete/config/appearance/emoticonseditwidget.ui	(revisione 0)
@@ -0,0 +1,74 @@
+<ui version="4.0" >
+ <class>EmoticonsEditWidget</class>
+ <widget class="QWidget" name="EmoticonsEditWidget" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>535</width>
+    <height>378</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string>EmoticonsEditWidget</string>
+  </property>
+  <layout class="QGridLayout" >
+   <item row="0" column="1" >
+    <layout class="QVBoxLayout" >
+     <item>
+      <widget class="KPushButton" name="btnAdd" >
+       <property name="text" >
+        <string>Add...</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="KPushButton" name="btnEdit" >
+       <property name="text" >
+        <string>Edit...</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="KPushButton" name="btnRemove" >
+       <property name="text" >
+        <string>Remove</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer>
+       <property name="orientation" >
+        <enum>Qt::Vertical</enum>
+       </property>
+       <property name="sizeType" >
+        <enum>QSizePolicy::Expanding</enum>
+       </property>
+       <property name="sizeHint" >
+        <size>
+         <width>20</width>
+         <height>40</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+    </layout>
+   </item>
+   <item row="0" column="0" >
+    <widget class="QListWidget" name="qlvEmoticons" />
+   </item>
+  </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11" />
+ <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
+ <customwidgets>
+  <customwidget>
+   <class>KPushButton</class>
+   <extends>QPushButton</extends>
+   <header>kpushbutton.h</header>
+  </customwidget>
+ </customwidgets>
+ <includes/>
+ <resources/>
+ <connections/>
+</ui>
Index: kopete/config/appearance/appearanceconfig.cpp
===================================================================
--- kopete/config/appearance/appearanceconfig.cpp	(revisione 700971)
+++ kopete/config/appearance/appearanceconfig.cpp	(copia locale)
@@ -22,6 +22,7 @@
 #include "appearanceconfig_contactlist.h"
 
 #include "tooltipeditdialog.h"
+#include "emoticonseditdialog.h"
 
 #include <QCheckBox>
 #include <QDir>
@@ -122,6 +123,8 @@
 		this, SLOT(slotGetEmoticonThemes()));
 	connect(d->mPrfsEmoticons->btnRemoveTheme, SIGNAL(clicked()),
 		this, SLOT(removeSelectedEmoticonTheme()));
+    connect(d->mPrfsEmoticons->btnEditThemes, SIGNAL(clicked()),
+        this, SLOT(editSelectedEmoticonTheme()));
 
 	d->mAppearanceTabCtl->addTab(d->mPrfsEmoticons, i18n("&Emoticons"));
 
@@ -204,7 +207,9 @@
 			if ( themeQDir[y] != "." && themeQDir[y] != ".." )
 			{
 				// Add ourselves to the list, using our directory name  FIXME:  use the first \
                emoticon of the theme.
-				QPixmap previewPixmap = QPixmap(KStandardDirs::locate("emoticons", \
themeQDir[y]+"/smile.png")); +                Kopete::Emoticons emoticons( \
QDir(themeQDir[y]).dirName() ); +                QPixmap previewPixmap = \
QPixmap(emoticons.emoticonAndPicList().keys().value(0)); +// 				QPixmap \
previewPixmap = QPixmap(KStandardDirs::locate("emoticons", \
                themeQDir[y]+"/smile.png"));
 				d->mPrfsEmoticons->icon_theme_list->insertItem(previewPixmap,themeQDir[y]);
 			}
 		}
@@ -326,5 +331,20 @@
 	delete dlg;
 }
 
+void AppearanceConfig::editSelectedEmoticonTheme()
+{
+    Q3ListBoxItem *selected = d->mPrfsEmoticons->icon_theme_list->selectedItem();
+    if(selected==0)
+        return;
+
+    QString themeName = selected->text();
+    
+    EmoticonsEditDialog *dlg = new EmoticonsEditDialog(this, themeName);
+    dlg->exec();
+    delete dlg;
+
+    updateEmoticonlist();
+}
+
 #include "appearanceconfig.moc"
 // vim: set noet ts=4 sts=4 sw=4:
Index: kopete/config/appearance/emoticonseditdialog.cpp
===================================================================
--- kopete/config/appearance/emoticonseditdialog.cpp	(revisione 0)
+++ kopete/config/appearance/emoticonseditdialog.cpp	(revisione 0)
@@ -0,0 +1,259 @@
+#include "emoticonseditdialog.h"
+
+#include "kopeteglobal.h"
+#include "kopeteemoticons.h"
+
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <kfiledialog.h>
+#include <kio/copyjob.h>
+#include <kio/netaccess.h>
+#include <QFileDialog>
+#include <QPixmap>
+#include <QLayout>
+#include <QLabel>
+
+EditDialog::EditDialog(QWidget *parent, const char* name)
+    : KDialog(parent)
+{
+    setCaption(i18n(name));
+    setupDlg();
+}
+
+EditDialog::EditDialog(QWidget *parent, const char* name, QListWidgetItem *itm, \
QString file) +    : KDialog(parent)
+{
+    setCaption(i18n(name));
+    setupDlg();
+    leText->setText(itm->text());
+    btnIcon->setIcon(itm->icon());
+    emoticon = file;
+}
+
+void EditDialog::setupDlg()
+{
+    setButtons(KDialog::Ok | KDialog::Cancel);
+    wdg = new QWidget(this);
+    QVBoxLayout *vl = new QVBoxLayout(wdg);
+    QHBoxLayout *hb = new QHBoxLayout(wdg);
+    leText = new QLineEdit();
+    btnIcon = new QPushButton();
+    btnIcon->setFixedSize(QSize(64, 64));
+
+    vl->addWidget(new QLabel(i18n("Insert the string for the emoticon\nseparated by \
space if you want multiple strings"), wdg)); +    hb->addWidget(btnIcon);
+    hb->addWidget(leText);
+    vl->addLayout(hb);
+    setMainWidget(wdg);
+    connect(btnIcon, SIGNAL(clicked()), this, SLOT(btnIconClicked()));
+}
+
+void EditDialog::btnIconClicked()
+{
+//     KUrl url =  KFileDialog::getImageOpenUrl(); //KFileDialog crashes kopete so \
i'll use QFileDialog for now +    
+    KUrl url = KUrl(QFileDialog::getOpenFileName(this, i18n("Choose an emoticon"), \
"", i18n("Images (*.png *.mng *.gif)"))); +    
+    if(!url.isLocalFile())
+        return;
+
+    emoticon = url.path();
+
+    if(emoticon.isEmpty())
+        return;
+
+    btnIcon->setIcon(QPixmap(emoticon));
+}
+
+EmoticonsEditDialog::EmoticonsEditDialog(QWidget *parent, QString theme)
+    : KDialog(parent)
+{
+    setCaption(i18n("Emoticons Editor"));
+    setButtons(KDialog::Ok | KDialog::Cancel);
+    
+    themeName = theme;
+
+    mMainWidget = new QWidget(this);
+    mMainWidget->setObjectName("EmoticonsEditDialog::mMainWidget");
+    setMainWidget(mMainWidget);
+    setupUi(mMainWidget);
+    
+    btnAdd->setGuiItem(KStandardGuiItem::add());
+    btnEdit->setGuiItem(KStandardGuiItem::configure());
+    btnEdit->setText(i18n("Edit..."));
+    btnRemove->setGuiItem(KStandardGuiItem::remove());
+
+    qlvEmoticons->setIconSize(QSize(22, 22));
+    Kopete::Emoticons emoticons( theme );
+    themeMap = emoticons.emoticonAndPicList();
+    
+    QMapIterator<QString, QStringList> it(themeMap);
+    while(it.hasNext())
+    {
+        it.next();
+        QString text;
+        if(it.value().size()) {
+            text = it.value().at(0);
+            for(int i = 1; i < it.value().size(); i++) {
+                text += " " + it.value().at(i);
+            }
+        }
+        new QListWidgetItem(QIcon(it.key()), text, qlvEmoticons);
+    }
+
+    QFile *fp = new QFile(KGlobal::dirs()->saveLocation( "emoticons",  themeName, \
false ) +  "/emoticons.xml"); +
+    if( !fp->exists() ) {
+        kWarning() << "EmoticonsEditDialog::EmoticonsEditDialog() " << \
fp->fileName() << " doesn't exist!" << endl; +        return;
+    }
+
+    if(!fp->open( IO_ReadOnly )) {
+        kWarning() << "EmoticonsEditDialog::EmoticonsEditDialog() " << \
fp->fileName() << " can't open ReadOnly!" << endl; +        return;
+    }
+
+    if(!themeXml.setContent(fp)) {
+        kWarning() << "EmoticonsEditDialog::EmoticonsEditDialog() " << \
fp->fileName() << " can't copy to xml!" << endl; +        fp->close();
+        return;
+    }
+
+    fp->close();
+
+    connect(this, SIGNAL(okClicked()), this, SLOT(slotOkClicked()));
+    connect(btnAdd, SIGNAL(clicked()), this, SLOT(slotAddClicked()));
+    connect(btnEdit, SIGNAL(clicked()), this, SLOT(slotEditClicked()));
+    connect(btnRemove, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
+}
+
+void EmoticonsEditDialog::slotOkClicked()
+{
+    QFile *fp = new QFile(KGlobal::dirs()->saveLocation( "emoticons",  themeName, \
false ) +  "/emoticons.xml"); +
+    if( !fp->exists() ) {
+        kWarning() << "EmoticonsEditDialog::slotOkClicked() " << fp->fileName() << " \
doesn't exist!" << endl; +        return;
+    }
+
+    if(!fp->open( IO_WriteOnly )) {
+        kWarning() << "EmoticonsEditDialog::slotOkClicked() " << fp->fileName() << " \
can't open WriteOnly!" << endl; +        return;
+    }
+
+    QTextStream emoStream(fp);
+    emoStream << themeXml.toString(4);
+    fp->close();
+}
+
+void EmoticonsEditDialog::slotAddClicked()
+{
+    EditDialog *dlg = new EditDialog(this, "Add emoticon");
+
+    if(dlg->exec() == QDialog::Rejected)
+        return;
+
+    if(dlg->getText().isEmpty() || dlg->getEmoticon().isNull())
+        return;
+
+    addEmoticon(dlg->getEmoticon(), dlg->getText(), true);
+
+
+    delete dlg;
+}
+
+void EmoticonsEditDialog::slotEditClicked()
+{
+    if(!qlvEmoticons->selectedItems().size())
+        return;
+
+    QString path = themeMap.key(qlvEmoticons->selectedItems()[0]->text().split(" \
")); +    QString f = QFileInfo(path).baseName();
+    
+    dlg = new EditDialog(this, "Edit emoticon", qlvEmoticons->selectedItems()[0], \
path); +
+    if(dlg->exec() == QDialog::Rejected)
+        return;
+
+    if(dlg->getText().isEmpty() || dlg->getEmoticon().isNull())
+        return;
+
+    bool copy;
+    QString emo = dlg->getEmoticon();
+    if(path != dlg->getEmoticon()) {
+        copy = true;
+    } else {
+        copy = false;
+        
+        KStandardDirs *dir = KGlobal::dirs();
+        emo = dir->findResource( "emoticons", themeName + QString::fromLatin1( "/" ) \
+ f); +
+        if( emo.isNull() )
+            emo = dir->findResource( "emoticons", themeName + QString::fromLatin1( \
"/" ) + f + QString::fromLatin1( ".mng" ) ); +        if ( emo.isNull() )
+            emo = dir->findResource( "emoticons", themeName + QString::fromLatin1( \
"/" ) + f + QString::fromLatin1( ".png" ) ); +        if ( emo.isNull() )
+            emo = dir->findResource( "emoticons", themeName + QString::fromLatin1( \
"/" ) + f + QString::fromLatin1( ".gif" ) ); +        if ( emo.isNull() )
+            return;
+    }
+
+    removeEmoticon(f);
+    addEmoticon(emo, dlg->getText(), copy);
+
+    delete dlg;
+}
+
+void EmoticonsEditDialog::slotRemoveClicked()
+{
+    if(!qlvEmoticons->selectedItems().size())
+        return;
+
+    removeEmoticon(QFileInfo(themeMap.key(qlvEmoticons->selectedItems()[0]->text().split(" \
"))).baseName()); +}
+
+void EmoticonsEditDialog::addEmoticon(QString emo, QString text, bool copy)
+{
+    if(copy) {
+        KIO::NetAccess::dircopy(KUrl(emo), KUrl(KGlobal::dirs()->saveLocation( \
"emoticons",  themeName, false ))); +    }
+
+    new QListWidgetItem(QPixmap(emo), text, qlvEmoticons);
+    QStringList splitted = text.split(" ");
+    themeMap[QFileInfo(emo).baseName()] = splitted;
+    QDomNode lc = themeXml.lastChild();
+    if(lc.isNull())
+        return;
+
+    QDomElement emoticon = themeXml.createElement("emoticon");
+    emoticon.setAttribute("file", QFileInfo(emo).baseName());
+    lc.appendChild(emoticon);
+    QStringList::const_iterator constIterator;
+    for(constIterator = splitted.begin(); constIterator != splitted.end(); \
constIterator++) +    {
+        QDomElement emotext = themeXml.createElement("string");
+        QDomText txt = themeXml.createTextNode((*constIterator).trimmed());
+        emotext.appendChild(txt);
+        emoticon.appendChild(emotext);
+    }
+}
+
+void EmoticonsEditDialog::removeEmoticon(QString emo)
+{
+    QDomNode lc = themeXml.lastChild();
+    if(lc.isNull())
+        return;
+
+    QDomNodeList nl = lc.childNodes();
+
+    for(uint i = 0; i < nl.length(); i++) {
+        QDomElement de = nl.item(i).toElement();
+        kWarning() << "tag: "<<de.tagName() << " attr: "<<de.attribute("file") << " \
emo: " << emo <<endl; +        if(!de.isNull() && de.tagName() == "emoticon" && \
de.attribute("file") == emo) { +            lc.removeChild(de);
+            delete qlvEmoticons->selectedItems()[0];
+            return;
+        }
+    }
+}
+
Index: kopete/config/appearance/appearanceconfig.h
===================================================================
--- kopete/config/appearance/appearanceconfig.h	(revisione 700971)
+++ kopete/config/appearance/appearanceconfig.h	(copia locale)
@@ -47,6 +47,7 @@
 	void removeSelectedEmoticonTheme();
 	void slotGetEmoticonThemes();
 	void updateEmoticonsButton(bool);
+    void editSelectedEmoticonTheme();
 private:
 	void updateEmoticonlist();
 	
Index: kopete/config/appearance/emoticonseditdialog.h
===================================================================
--- kopete/config/appearance/emoticonseditdialog.h	(revisione 0)
+++ kopete/config/appearance/emoticonseditdialog.h	(revisione 0)
@@ -0,0 +1,54 @@
+#ifndef EMOTICONSEDITDIALOG_H
+#define EMOTICONSEDITDIALOG_H
+
+#include <kdebug.h>
+#include <kdialog.h>
+#include <QLineEdit>
+#include <QFile>
+#include <QDomDocument>
+
+#include "ui_emoticonseditwidget.h"
+
+class EditDialog : public KDialog
+{
+    Q_OBJECT
+
+    public:
+        EditDialog(QWidget *parent, const char* name);
+        EditDialog(QWidget *parent, const char* name, QListWidgetItem *itm, QString \
file); +        const QString getText() { return leText->text(); };
+        const QString getEmoticon() { return emoticon; };
+    private slots:
+        void btnIconClicked();
+    private:
+        void setupDlg();
+        QWidget *wdg;
+        QLineEdit *leText;
+        QPushButton *btnIcon;
+        QString emoticon;
+};
+
+class EmoticonsEditDialog : public KDialog, private Ui::EmoticonsEditWidget
+{
+    Q_OBJECT
+
+    public:
+        EmoticonsEditDialog(QWidget *parent=0, QString theme = QString::null);
+        void addEmoticon(QString emo, QString text, bool copy);
+
+    private slots:
+        void slotOkClicked();
+        void slotAddClicked();
+        void slotEditClicked();
+        void slotRemoveClicked();
+
+    private:
+        void removeEmoticon(QString emo);
+        QWidget *mMainWidget;
+        QString themeName;
+        EditDialog *dlg;
+        QMap<QString, QStringList> themeMap;
+        QDomDocument themeXml;
+};
+
+#endif
Index: kopete/config/appearance/CMakeLists.txt
===================================================================
--- kopete/config/appearance/CMakeLists.txt	(revisione 700971)
+++ kopete/config/appearance/CMakeLists.txt	(copia locale)
@@ -12,13 +12,15 @@
    appearanceconfig_colors.cpp 
    appearanceconfig_contactlist.cpp 
    appearanceconfig_emoticons.cpp 
-   tooltipeditdialog.cpp )
+   tooltipeditdialog.cpp 
+   emoticonseditdialog.cpp )
 
 kde4_add_ui_files(kcm_kopete_appearanceconfig_PART_SRCS 
    appearanceconfig_colors.ui
    appearanceconfig_contactlist.ui 
    appearanceconfig_emoticons.ui 
-   tooltipeditwidget.ui )
+   tooltipeditwidget.ui 
+   emoticonseditwidget.ui )
 
 kde4_add_plugin(kcm_kopete_appearanceconfig \
${kcm_kopete_appearanceconfig_PART_SRCS})  
Index: kopete/chatwindow/chatmessagepart.cpp
===================================================================
--- kopete/chatwindow/chatmessagepart.cpp	(revisione 700971)
+++ kopete/chatwindow/chatmessagepart.cpp	(copia locale)
@@ -64,12 +64,14 @@
 #include <kstringhandler.h>
 #include <ktemporaryfile.h>
 #include <kio/copyjob.h>
+#include <kio/netaccess.h>
 #include <kstandarddirs.h>
 #include <kstandardaction.h>
 #include <kiconloader.h>
 #include <kcodecs.h>
 #include <kstandardaction.h>
 #include <kicon.h>
+#include <kinputdialog.h>
 
 // Kopete includes
 #include "chatmemberslistwidget.h"
@@ -100,7 +102,7 @@
 	Private()
 	 : /*tt(0L),*/ manager(0), scrollPressed(false),
 	   copyAction(0), saveAction(0), printAction(0),
-	   closeAction(0),copyURLAction(0), currentChatStyle(0),
+	   closeAction(0),copyURLAction(0), importEmoticonAction(0), currentChatStyle(0),
 	   latestDirection(Kopete::Message::Inbound), \
latestType(Kopete::Message::TypeNormal)  {}
 
@@ -126,6 +128,7 @@
 	KAction *printAction;
 	KAction *closeAction;
 	KAction *copyURLAction;
+    KAction *importEmoticonAction;
 
 	// We can't use QPointer because ChatWindowStyle is not a QObject
 	ChatWindowStyle *currentChatStyle;
@@ -242,6 +245,9 @@
 	d->saveAction = KStandardAction::saveAs( this, SLOT(save()), actionCollection() );
 	d->printAction = KStandardAction::print( this, SLOT(print()),actionCollection() );
 	d->closeAction = KStandardAction::close( this, \
SLOT(slotCloseView()),actionCollection() ); +    d->importEmoticonAction = new \
KAction( i18n( "Import Emoticon"), actionCollection() ); +    \
actionCollection()->addAction( "importemot", d->importEmoticonAction ); +    connect( \
d->importEmoticonAction, SIGNAL( triggered(bool) ), this, SLOT( slotImportEmoticon() \
) );  d->copyURLAction = new KAction( KIcon("edit-copy"), i18n( "Copy Link Address" \
), actionCollection() );  actionCollection()->addAction( "editcopy", d->copyURLAction \
);  connect( d->copyURLAction, SIGNAL( triggered(bool) ), this, SLOT( slotCopyURL() ) \
); @@ -664,6 +670,7 @@
 		chatWindowPopup->addAction( d->copyAction );
 		chatWindowPopup->addAction( d->saveAction );
 		chatWindowPopup->addAction( d->printAction );
+        if( d->activeElement.tagName().lower() == "img" ) \
chatWindowPopup->addAction( d->importEmoticonAction );  \
chatWindowPopup->addSeparator();  chatWindowPopup->addAction( d->closeAction );
 
@@ -1192,6 +1199,53 @@
 #endif
 }
 
+void ChatMessagePart::slotImportEmoticon()
+{
+    QString emoticonString = KInputDialog::getText( i18n("Import Emoticon"),
+    i18n("<qt><img src=\"%1\"><br>Insert the string for the emoticon<br>separated by \
space if you want multiple strings</qt>").arg( \
d->activeElement.getAttribute("src").string() ) ); +    if (emoticonString.isNull() )
+                return;
+
+    QString emo = d->activeElement.getAttribute("src").string();
+    QString themeName = Kopete::AppearanceSettings::self()->emoticonTheme();
+
+    KIO::NetAccess::dircopy(KUrl(emo), KUrl(KGlobal::dirs()->saveLocation( \
"emoticons",  themeName, false ))); +
+    QFile *fp = new QFile(KGlobal::dirs()->saveLocation( "emoticons",  themeName, \
false ) +  "/emoticons.xml"); +
+    QDomDocument themeXml;
+
+    if(!fp->exists() || !fp->open( IO_ReadOnly ) || !themeXml.setContent(fp))
+        return;
+
+    fp->close();
+
+    QDomNode lc = themeXml.lastChild();
+    if(lc.isNull())
+        return;
+
+    QDomElement emoticon = themeXml.createElement("emoticon");
+    emoticon.setAttribute("file", QFileInfo(emo).baseName());
+    lc.appendChild(emoticon);
+    QStringList splitted = emoticonString.split(" ");
+    QStringList::const_iterator constIterator;
+    for(constIterator = splitted.begin(); constIterator != splitted.end(); \
constIterator++) +    {
+        QDomElement emotext = themeXml.createElement("string");
+        QDomText txt = themeXml.createTextNode((*constIterator).trimmed());
+        emotext.appendChild(txt);
+        emoticon.appendChild(emotext);
+    }
+
+    if(!fp->open( IO_WriteOnly ))
+        return;
+
+    QTextStream emoStream(fp);
+    emoStream << themeXml.toString(4);
+    fp->close();
+    QTimer::singleShot( 1500, Kopete::Emoticons::self(), SLOT( reload() ) );
+}
+
 #include "chatmessagepart.moc"
 
 // vim: set noet ts=4 sts=4 sw=4:
Index: kopete/chatwindow/chatmessagepart.h
===================================================================
--- kopete/chatwindow/chatmessagepart.h	(revisione 700971)
+++ kopete/chatwindow/chatmessagepart.h	(copia locale)
@@ -150,6 +150,8 @@
 	void slotCopyURL();
 
 	void slotCloseView( bool force = false );
+    
+    void slotImportEmoticon();
 
 	/**
 	 * Do the actual style change.
Index: libkopete/private/kopeteemoticons.cpp
===================================================================
--- libkopete/private/kopeteemoticons.cpp	(revisione 700971)
+++ libkopete/private/kopeteemoticons.cpp	(copia locale)
@@ -541,6 +541,13 @@
 	return result;
 }
 
+void Emoticons::reload()
+{
+    d->emoticonAndPicList.clear();
+    d->emoticonMap.clear();
+    initEmoticons( Kopete::AppearanceSettings::self()->emoticonTheme() );
+}
+
 } //END namesapce Kopete
 
 #include "kopeteemoticons.moc"
Index: libkopete/private/kopeteemoticons.h
===================================================================
--- libkopete/private/kopeteemoticons.h	(revisione 700971)
+++ libkopete/private/kopeteemoticons.h	(copia locale)
@@ -139,6 +139,11 @@
 	 */
 	QMap<QString, QStringList> emoticonAndPicList();
 
+public slots:
+    /**
+    * reload the current emoticons theme
+    */
+    void reload();
 
 private:
 	/**



_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic