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

List:       kde-commits
Subject:    KDE/kdenetwork/kopete/kopete/config/chatwindow
From:       Urs Wolfer <uwolfer () kde ! org>
Date:       2008-04-14 19:58:26
Message-ID: 1208203106.330937.2709.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 797052 by uwolfer:

* do not display error message when open dialog got canceled
* show icons on buttons
* K3ListBox -> QListWidget
* QAbstractItemDelegate -> QStyledItemDelegate (display styled items)

 M  +21 -11    chatwindowconfig.cpp  
 M  +1 -1      chatwindowconfig.h  
 M  +10 -69    chatwindowconfig_style.ui  
 M  +4 -11     emoticonthemedelegate.cpp  
 M  +2 -2      emoticonthemedelegate.h  


--- trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/chatwindowconfig.cpp \
#797051:797052 @@ -158,8 +158,8 @@
 	m_tab->addTab(styleWidget, i18n("&Style"));
 	addConfig( KopeteChatWindowSettings::self(), styleWidget );
 
-	connect(m_styleUi.styleList, SIGNAL(selectionChanged(Q3ListBoxItem *)),
-		this, SLOT(slotChatStyleSelected()));
+	connect(m_styleUi.styleList, SIGNAL(currentTextChanged(const QString &)),
+		this, SLOT(slotChatStyleSelected(const QString &)));
 	connect(m_styleUi.variantList, SIGNAL(activated(const QString&)),
 		this, SLOT(slotChatStyleVariantSelected(const QString &)));
 	connect(m_styleUi.deleteButton, SIGNAL(clicked()),
@@ -169,6 +169,10 @@
 	connect(m_styleUi.btnGetStyles, SIGNAL(clicked()),
 		this, SLOT(slotGetChatStyles()));
 
+	m_styleUi.deleteButton->setIcon(KIcon("edit-delete"));
+	m_styleUi.installButton->setIcon(KIcon("document-import"));
+	m_styleUi.btnGetStyles->setIcon(KIcon("get-hot-new-stuff"));
+
 	// Show the available styles when the Manager has finish to load the styles.
 	connect(ChatWindowStyleManager::self(), SIGNAL(loadStylesFinished()), this, \
SLOT(slotLoadChatStyles()));  
@@ -300,24 +304,25 @@
 	foreach( const QString& styleName, availableStyles )
 	{
 		// Insert style name into the listbox
-		m_styleUi.styleList->insertItem( styleName, 0 );
+		m_styleUi.styleList->insertItem( 0, styleName );
 
 		if( styleName == KopeteChatWindowSettings::self()->styleName() )
 		{
 			kDebug(14000) << "Restoring saved style: " << styleName;
 
-			m_styleUi.styleList->setSelected( m_styleUi.styleList->firstItem(), true );
+			m_styleUi.styleList->setCurrentItem( m_styleUi.styleList->item( 0 ) );
 		}
 	}
 
-	m_styleUi.styleList->sort();
+	m_styleUi.styleList->setSortingEnabled( true );
 }
 
 
-void ChatWindowConfig::slotChatStyleSelected()
+void ChatWindowConfig::slotChatStyleSelected(const QString &styleName)
 {
+	if (styleName.isEmpty())
+		return;
 	// Retrieve variant list.
-	QString styleName = m_styleUi.styleList->selectedItem()->text();
 	m_currentStyle = ChatWindowStyleManager::self()->getStyleFromPool( styleName );
 
 	if(m_currentStyle)
@@ -366,7 +371,7 @@
 
 	// enable the 'Use compact' checkbox depending on whether the selected variant \
exists in compact  // form
-	QString styleName = m_styleUi.styleList->selectedItem()->text();
+	QString styleName = m_styleUi.styleList->currentItem()->text();
 	m_currentStyle = ChatWindowStyleManager::self()->getStyleFromPool( styleName );
 	if ( m_styleUi.variantList->currentIndex() == 0 ) {
 		m_styleUi.kcfg_useCompact->setEnabled(m_currentStyle->hasCompact( "" ) );
@@ -381,8 +386,13 @@
 
 void ChatWindowConfig::slotInstallChatStyle()
 {
-	int styleInstallReturn = installChatStyle(KFileDialog::getOpenUrl( KUrl(), \
QString::fromUtf8("application/zip application/x-compressed-tar \
application/x-bzip-compressed-tar"), this, i18n("Choose Chat Window Style to \
install.") )); +	KUrl styleUrl = KFileDialog::getOpenUrl( KUrl(), \
QString::fromUtf8("application/zip application/x-compressed-tar \
application/x-bzip-compressed-tar"), this, i18n("Choose a Chat Window Style to \
install") );  
+	if ( styleUrl.isEmpty() ) // dialog got canceled
+		return;
+
+	int styleInstallReturn = installChatStyle( styleUrl );
+
 	switch(styleInstallReturn)
 	{
 		case ChatWindowStyleManager::StyleCannotOpen:
@@ -433,12 +443,12 @@
 
 void ChatWindowConfig::slotDeleteChatStyle()
 {
-	if (!m_styleUi.styleList->selectedItem())
+	if (!m_styleUi.styleList->currentItem())
 	{
 		return; // nothing selected
 	}
 
-	QString styleName = m_styleUi.styleList->selectedItem()->text();
+	QString styleName = m_styleUi.styleList->currentItem()->text();
 	if( ChatWindowStyleManager::self()->removeStyle(styleName) )
 	{
 		KMessageBox::queuedMessageBox(this, KMessageBox::Information, i18nc("@info", "The \
                Chat Window Style <resource>%1</resource> was successfully deleted.", \
                styleName));
--- trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/chatwindowconfig.h \
#797051:797052 @@ -54,7 +54,7 @@
 	void slotInstallChatStyle();
 	int installChatStyle(const KUrl &styleToInstall);
 	void slotDeleteChatStyle();
-	void slotChatStyleSelected();
+	void slotChatStyleSelected(const QString &styleName);
 	void slotChatStyleVariantSelected(const QString &variantName);
 	void emitChanged();
 	void slotGetChatStyles();
--- trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/chatwindowconfig_style.ui \
#797051:797052 @@ -6,7 +6,7 @@
     <x>0</x>
     <y>0</y>
     <width>488</width>
-    <height>284</height>
+    <height>409</height>
    </rect>
   </property>
   <property name="sizePolicy" >
@@ -19,44 +19,20 @@
    <string>Chat Window Appearance</string>
   </property>
   <layout class="QGridLayout" >
-   <property name="leftMargin" >
+   <property name="margin" >
     <number>9</number>
    </property>
-   <property name="topMargin" >
-    <number>9</number>
-   </property>
-   <property name="rightMargin" >
-    <number>9</number>
-   </property>
-   <property name="bottomMargin" >
-    <number>9</number>
-   </property>
-   <property name="horizontalSpacing" >
+   <property name="spacing" >
     <number>6</number>
    </property>
-   <property name="verticalSpacing" >
-    <number>6</number>
-   </property>
    <item row="0" column="0" >
     <layout class="QGridLayout" >
-     <property name="leftMargin" >
+     <property name="margin" >
       <number>0</number>
      </property>
-     <property name="topMargin" >
-      <number>0</number>
-     </property>
-     <property name="rightMargin" >
-      <number>0</number>
-     </property>
-     <property name="bottomMargin" >
-      <number>0</number>
-     </property>
-     <property name="horizontalSpacing" >
+     <property name="spacing" >
       <number>6</number>
      </property>
-     <property name="verticalSpacing" >
-      <number>6</number>
-     </property>
      <item row="1" column="0" >
       <widget class="QGroupBox" name="groupBox" >
        <property name="title" >
@@ -92,41 +68,20 @@
         <string>Styles</string>
        </property>
        <layout class="QGridLayout" >
-        <property name="leftMargin" >
+        <property name="margin" >
          <number>9</number>
         </property>
-        <property name="topMargin" >
-         <number>9</number>
-        </property>
-        <property name="rightMargin" >
-         <number>9</number>
-        </property>
-        <property name="bottomMargin" >
-         <number>9</number>
-        </property>
-        <property name="horizontalSpacing" >
+        <property name="spacing" >
          <number>6</number>
         </property>
-        <property name="verticalSpacing" >
-         <number>6</number>
-        </property>
         <item row="1" column="0" >
          <layout class="QHBoxLayout" >
           <property name="spacing" >
            <number>6</number>
           </property>
-          <property name="leftMargin" >
+          <property name="margin" >
            <number>0</number>
           </property>
-          <property name="topMargin" >
-           <number>0</number>
-          </property>
-          <property name="rightMargin" >
-           <number>0</number>
-          </property>
-          <property name="bottomMargin" >
-           <number>0</number>
-          </property>
           <item>
            <widget class="QLabel" name="textLabel1" >
             <property name="text" >
@@ -160,7 +115,7 @@
           <property name="childrenCollapsible" >
            <bool>false</bool>
           </property>
-          <widget class="K3ListBox" name="styleList" />
+          <widget class="QListWidget" name="styleList" />
           <widget class="QFrame" name="htmlFrame" >
            <property name="sizePolicy" >
             <sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
@@ -182,18 +137,9 @@
           <property name="spacing" >
            <number>6</number>
           </property>
-          <property name="leftMargin" >
+          <property name="margin" >
            <number>0</number>
           </property>
-          <property name="topMargin" >
-           <number>0</number>
-          </property>
-          <property name="rightMargin" >
-           <number>0</number>
-          </property>
-          <property name="bottomMargin" >
-           <number>0</number>
-          </property>
           <item>
            <widget class="KPushButton" name="btnGetStyles" >
             <property name="enabled" >
@@ -236,11 +182,6 @@
    <extends>QPushButton</extends>
    <header>kpushbutton.h</header>
   </customwidget>
-  <customwidget>
-   <class>K3ListBox</class>
-   <extends>Q3ListBox</extends>
-   <header>k3listbox.h</header>
-  </customwidget>
  </customwidgets>
  <tabstops>
   <tabstop>styleList</tabstop>
--- trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/emoticonthemedelegate.cpp \
#797051:797052 @@ -19,29 +19,22 @@
 #include "emoticonthemeitem.h" // for the enum
 #include <QModelIndex>
 #include <QPainter>
+#include <QApplication>
 
 EmoticonThemeDelegate::EmoticonThemeDelegate(QObject *parent)
-: QAbstractItemDelegate(parent)
+: QStyledItemDelegate(parent)
 {
 }
 
 void EmoticonThemeDelegate::paint(QPainter *painter, const QStyleOptionViewItem \
&option, const QModelIndex &index) const  {
+	QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, \
painter); +
 	QString theme = index.data().toString();
 
 	QVariant v = index.data(EmoticonThemeItem::EmoticonPixmaps);
 	QList<QVariant> pixmapList = qvariant_cast<QList<QVariant> >(v);
 
-	if (option.state & QStyle::State_Selected)
-		painter->fillRect(option.rect, option.palette.brush(QPalette::Normal, \
                QPalette::Highlight));
-	else
-	{
-		QVariant value = index.data(Qt::BackgroundRole);
-		QPointF oldBO = painter->brushOrigin();
-		painter->setBrushOrigin(option.rect.topLeft());
-		painter->fillRect(option.rect, qvariant_cast<QBrush>(value));
-		painter->setBrushOrigin(oldBO);
-	}
 	painter->save();
 		painter->translate(option.rect.topLeft());
 		if (option.state & QStyle::State_Selected)
--- trunk/KDE/kdenetwork/kopete/kopete/config/chatwindow/emoticonthemedelegate.h \
#797051:797052 @@ -18,9 +18,9 @@
     *************************************************************************
 */
 
-#include <QAbstractItemDelegate>
+#include <QStyledItemDelegate>
 
-class EmoticonThemeDelegate : public QAbstractItemDelegate
+class EmoticonThemeDelegate : public QStyledItemDelegate
 {
 	Q_OBJECT
 public:


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

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