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

List:       kde-commits
Subject:    KDE/kdenetwork/kopete/kopete/config/chatwindow
From:       Gustavo P. Boiko <gustavo.boiko () kdemail ! net>
Date:       2007-11-07 11:56:48
Message-ID: 1194436608.795386.20707.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 733860 by boiko:

Make the emoticon theme selector more user friendly by showing a preview of
all available themes in the list of themes.


 M  +3 -1      CMakeLists.txt  
 M  +32 -26    chatwindowconfig.cpp  
 M  +3 -2      chatwindowconfig.h  
 M  +3 -86     chatwindowconfig_emoticons.ui  
 AM            emoticonthemedelegate.cpp   [License: GPL (v2+)]
 AM            emoticonthemedelegate.h   [License: GPL (v2+)]
 AM            emoticonthemeitem.cpp   [License: GPL (v2+)]
 AM            emoticonthemeitem.h   [License: GPL (v2+)]


--- trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/CMakeLists.txt \
#733859:733860 @@ -9,7 +9,9 @@
 ########### next target ###############
 
 set(kcm_kopete_chatwindowconfig_PART_SRCS
-   chatwindowconfig.cpp  )
+   chatwindowconfig.cpp  
+   emoticonthemedelegate.cpp 
+   emoticonthemeitem.cpp )
 
 kde4_add_ui_files(kcm_kopete_chatwindowconfig_PART_SRCS 
    chatwindowconfig_style.ui
--- trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/chatwindowconfig.cpp \
#733859:733860 @@ -1,10 +1,11 @@
 /*
-    appearanceconfig.cpp  -  Kopete Look Feel Config
+    chatwindowconfig.cpp  -  Kopete Look Feel Config
 
     Copyright (c) 2005-2006 by Michaël Larouche       <larouche@kde.org>
     Copyright (c) 2005-2006 by Olivier Goffart         <ogoffart at kde.org>
+    Copyright (c) 2007      by Gustavo Pichorim Boiko  <gustavo.boiko@kdemail.net>
 
-    Kopete    (c) 2005-2006 by the Kopete developers  <kopete-devel@kde.org>
+    Kopete    (c) 2005-2007 by the Kopete developers  <kopete-devel@kde.org>
 
     *************************************************************************
     *                                                                       *
@@ -17,6 +18,8 @@
 */
 
 #include "chatwindowconfig.h"
+#include "emoticonthemedelegate.h"
+#include "emoticonthemeitem.h"
 
 #include <QCheckBox>
 #include <QDir>
@@ -218,7 +221,7 @@
 	m_tab->addTab(styleWidget, i18n("&Style"));
 	addConfig( KopeteChatWindowSettings::self(), styleWidget );
 
-	connect(m_styleUi.styleList, SIGNAL(selectionChanged(Q3ListBoxItem *)),
+	connect(m_styleUi.styleList, SIGNAL(itemSelectionChanged(Q3ListBoxItem *)),
 		this, SLOT(slotChatStyleSelected()));
 	connect(m_styleUi.variantList, SIGNAL(activated(const QString&)),
 		this, SLOT(slotChatStyleVariantSelected(const QString &)));
@@ -257,9 +260,11 @@
 	QWidget *emoticonsWidget = new QWidget(m_tab);
 	m_emoticonsUi.setupUi(emoticonsWidget);
 	m_tab->addTab(emoticonsWidget, i18n("&Emoticons"));
+
+	m_emoticonsUi.icon_theme_list->setItemDelegate(new EmoticonThemeDelegate(this));
 	addConfig( Kopete::AppearanceSettings::self(), emoticonsWidget );
 
-	connect(m_emoticonsUi.icon_theme_list, SIGNAL(selectionChanged()),
+	connect(m_emoticonsUi.icon_theme_list, SIGNAL(itemSelectionChanged()),
 		this, SLOT(slotSelectedEmoticonsThemeChanged()));
 	connect(m_emoticonsUi.btnInstallTheme, SIGNAL(clicked()),
 		this, SLOT(slotInstallEmoticonTheme()));
@@ -310,7 +315,10 @@
 	}
 
 	Kopete::AppearanceSettings *appearanceSettings = \
                Kopete::AppearanceSettings::self();
-	appearanceSettings->setEmoticonTheme( m_emoticonsUi.icon_theme_list->currentText() \
); +	QListWidgetItem *item = m_emoticonsUi.icon_theme_list->currentItem();
+	
+	if (item)
+		appearanceSettings->setEmoticonTheme( item->text() );
 
 	appearanceSettings->writeConfig();
 	settings->writeConfig();
@@ -606,10 +614,13 @@
 
 void ChatWindowConfig::slotUpdateEmoticonsButton(bool _b)
 {
-    QString themeName = m_emoticonsUi.icon_theme_list->currentText();
-    QFileInfo fileInf(KGlobal::dirs()->findResource("emoticons", themeName+'/'));
-    m_emoticonsUi.btnRemoveTheme->setEnabled( _b && fileInf.isWritable());
-    m_emoticonsUi.btnGetThemes->setEnabled( false );
+	QListWidgetItem *item = m_emoticonsUi.icon_theme_list->currentItem();
+	if (!item)
+		return;
+	QString themeName = item->text();
+	QFileInfo fileInf(KGlobal::dirs()->findResource("emoticons", themeName+'/'));
+	m_emoticonsUi.btnRemoveTheme->setEnabled( _b && fileInf.isWritable());
+	m_emoticonsUi.btnGetThemes->setEnabled( false );
 }
 
 void ChatWindowConfig::updateEmoticonList()
@@ -628,41 +639,36 @@
 		for(unsigned int y = 0; y < themeQDir.count(); y++)
 		{
 			QStringList themes = themeQDir.entryList(QDir::Dirs, QDir::Name);
+
 			// We don't care for '.' and '..'
 			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"));
-				m_emoticonsUi.icon_theme_list->insertItem(previewPixmap,themeQDir[y]);
+				QListWidgetItem *item = new EmoticonThemeItem(themeQDir[y]);
+				m_emoticonsUi.icon_theme_list->addItem(item);
 			}
 		}
 	}
 
 	// Where is that theme in our big-list-o-themes?
 
-	Q3ListBoxItem *item = m_emoticonsUi.icon_theme_list->findItem( \
Kopete::AppearanceSettings::self()->emoticonTheme() ); +	QList<QListWidgetItem*> \
items = m_emoticonsUi.icon_theme_list->findItems( \
Kopete::AppearanceSettings::self()->emoticonTheme(), Qt::MatchExactly );  
-	if (item) // found it... make it the currently selected theme
-		m_emoticonsUi.icon_theme_list->setCurrentItem( item );
+	if (items.count()) // found it... make it the currently selected theme
+		m_emoticonsUi.icon_theme_list->setCurrentItem( items.first() );
 	else // Er, it's not there... select the current item
 		m_emoticonsUi.icon_theme_list->setCurrentItem( 0 );
 }
 
 void ChatWindowConfig::slotSelectedEmoticonsThemeChanged()
 {
-	QString themeName = m_emoticonsUi.icon_theme_list->currentText();
+	QListWidgetItem *item = m_emoticonsUi.icon_theme_list->currentItem();
+	if (!item)
+		return;
+	QString themeName = item->text();
 	QFileInfo fileInf(KGlobal::dirs()->findResource("emoticons", themeName+'/'));
 	m_emoticonsUi.btnRemoveTheme->setEnabled( fileInf.isWritable() );
 
-	Kopete::Emoticons emoticons( themeName );
-	QStringList smileys = emoticons.emoticonAndPicList().keys();
-	QString newContentText = "<qt>";
-
-	for(QStringList::Iterator it = smileys.begin(); it != smileys.end(); ++it )
-		newContentText += QString::fromLatin1("<img src=\"%1\"> ").arg(*it);
-
-	newContentText += QLatin1String("</qt>");
-	m_emoticonsUi.icon_theme_preview->setHtml(newContentText);
 	emitChanged();
 }
 
@@ -687,8 +693,8 @@
 
 void ChatWindowConfig::slotRemoveEmoticonTheme()
 {
-	Q3ListBoxItem *selected = m_emoticonsUi.icon_theme_list->selectedItem();
-	if(selected==0)
+	QListWidgetItem *selected = m_emoticonsUi.icon_theme_list->currentItem();
+	if(!selected)
 		return;
 
 	QString themeName = selected->text();
--- trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/chatwindowconfig.h \
#733859:733860 @@ -1,10 +1,11 @@
 /*
-    appearanceconfig.h  -  Kopete Look Feel Config
+    chatwindowconfig.h  -  Kopete Look Feel Config
 
     Copyright (c) 2005-2006 by Michaël Larouche       <larouche@kde.org>
     Copyright (c) 2005-2006 by Olivier Goffart         <ogoffart at kde.org>
+    Copyright (c) 2007      by Gustavo Pichorim Boiko  <gustavo.boiko@kdemail.net>
 
-    Kopete    (c) 2005-2006 by the Kopete developers  <kopete-devel@kde.org>
+    Kopete    (c) 2005-2007 by the Kopete developers  <kopete-devel@kde.org>
 
     *************************************************************************
     *                                                                       *
--- trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/chatwindowconfig_emoticons.ui \
#733859:733860 @@ -65,65 +65,10 @@
     </widget>
    </item>
    <item row="3" column="0" colspan="4" >
-    <widget class="QSplitter" name="splitter" >
-     <property name="orientation" >
-      <enum>Qt::Vertical</enum>
+    <widget class="QListWidget" name="icon_theme_list" >
+     <property name="alternatingRowColors" >
+      <bool>true</bool>
      </property>
-     <widget class="K3ListBox" name="icon_theme_list" >
-      <property name="sizePolicy" >
-       <sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
-        <horstretch>0</horstretch>
-        <verstretch>10</verstretch>
-       </sizepolicy>
-      </property>
-     </widget>
-     <widget class="QGroupBox" name="previewBox" >
-      <property name="sizePolicy" >
-       <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
-        <horstretch>0</horstretch>
-        <verstretch>1</verstretch>
-       </sizepolicy>
-      </property>
-      <property name="title" >
-       <string>Preview</string>
-      </property>
-      <property name="flat" >
-       <bool>true</bool>
-      </property>
-      <layout class="QHBoxLayout" >
-       <property name="leftMargin" >
-        <number>1</number>
-       </property>
-       <property name="topMargin" >
-        <number>1</number>
-       </property>
-       <property name="rightMargin" >
-        <number>1</number>
-       </property>
-       <property name="bottomMargin" >
-        <number>1</number>
-       </property>
-       <item>
-        <widget class="KTextEdit" name="icon_theme_preview" >
-         <property name="sizePolicy" >
-          <sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="maximumSize" >
-          <size>
-           <width>32767</width>
-           <height>32767</height>
-          </size>
-         </property>
-         <property name="readOnly" >
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-      </layout>
-     </widget>
     </widget>
    </item>
    <item row="4" column="0" >
@@ -188,18 +133,6 @@
  </widget>
  <layoutdefault spacing="6" margin="11" />
  <pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
- <customwidgets>
-  <customwidget>
-   <class>KTextEdit</class>
-   <extends>QTextEdit</extends>
-   <header>ktextedit.h</header>
-  </customwidget>
-  <customwidget>
-   <class>K3ListBox</class>
-   <extends>Q3ListBox</extends>
-   <header>k3listbox.h</header>
-  </customwidget>
- </customwidgets>
  <resources/>
  <connections>
   <connection>
@@ -221,22 +154,6 @@
   <connection>
    <sender>kcfg_useEmoticons</sender>
    <signal>toggled(bool)</signal>
-   <receiver>icon_theme_list</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel" >
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel" >
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>kcfg_useEmoticons</sender>
-   <signal>toggled(bool)</signal>
    <receiver>textLabel1</receiver>
    <slot>setEnabled(bool)</slot>
    <hints>
** trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/emoticonthemedelegate.cpp \
#property svn:eol-style  + native
** trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/emoticonthemedelegate.h \
#property svn:eol-style  + native
** trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/emoticonthemeitem.cpp \
#property svn:eol-style  + native
** trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/emoticonthemeitem.h #property \
svn:eol-style  + native


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

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