Bug 60967 - KDockWidget: no way to set the pixmap (except constructor)
Summary: KDockWidget: no way to set the pixmap (except constructor)
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR wishlist
Target Milestone: ---
Assignee: Joseph Wenninger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-09 09:18 UTC by esigra
Modified: 2006-02-15 20:37 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description esigra 2003-07-09 09:18:24 UTC
Version:           3.1.2 (using KDE KDE 3.1.2)
Installed from:    Compiled From Sources

There does not seem to be a way to set the pixmap of a KDockWidget, except for the constructor, which is of course not usable for this purpouse when the KDockWidget is already constructed.
Comment 1 Joseph Wenninger 2003-07-26 22:10:11 UTC
Subject: kdelibs/kdeui

CVS commit by jowenn: 

Fix bug / implement wishlist item  #60967. The dockwidgets are going to have setPixmap/pixmap functions in KDE 3.2.

CCMAIL: 60967-done@bugs.kde.org


  M +19 -0     kdockwidget.cpp   1.127
  M +14 -0     kdockwidget.h   1.78
  M +1 -0      kdockwidget_p.h   1.10
  M +21 -0     tests/kdockwidgettest.cpp   1.12
  M +2 -0      tests/kdockwidgettest.h   1.4


--- kdelibs/kdeui/kdockwidget.cpp  #1.126:1.127
@@ -476,4 +476,22 @@ KDockWidget::KDockWidget( KDockManager* 
 }
 
+void KDockWidget::setPixmap(const QPixmap& pixmap) {
+        delete pix;
+        pix=new QPixmap(pixmap);
+        setIcon(*pix);
+        KDockTabGroup *dtg=parentDockTabGroup();
+        if (dtg) 
+                dtg->changeTab(this,pixmap,dtg->tabLabel(this));
+         QWidget *contWid=parentDockContainer();
+         if (contWid)
+                ((KDockContainer*)contWid->qt_cast("KDockContainer"))->setPixmap(this,pixmap);
+
+
+}
+
+const QPixmap& KDockWidget::pixmap() const {
+        return *pix;
+}
+
 KDockWidget::~KDockWidget()
 {
@@ -2849,4 +2867,5 @@ void KDockContainer::removeWidget (KDock
 void KDockContainer::undockWidget (KDockWidget *){;}
 void KDockContainer::setToolTip(KDockWidget *, QString &){;}
+void KDockContainer::setPixmap(KDockWidget*,const QPixmap&){;}
 void KDockContainer::load (KConfig*){;}
 void KDockContainer::save (KConfig*){;}

--- kdelibs/kdeui/kdockwidget.h  #1.77:1.78
@@ -648,4 +648,18 @@ public:
   KDockWidget *findNearestDockWidget(DockPosition pos);
 
+  /**
+   * Allows changing the pixmap which is used for the caption or dock tabs
+   *
+   * @param pixmap is the pixmap to set
+   * @since 3.2
+   */
+   void setPixmap(const QPixmap& pixmap=QPixmap());
+   
+  /**
+   * Returns the dockwidget's associated caption/dock tab pixmap
+   *
+   * @since 3.2
+   */
+   const QPixmap& pixmap() const;
 public slots:
   /**

--- kdelibs/kdeui/kdockwidget_p.h  #1.9:1.10
@@ -53,4 +53,5 @@ public:
   virtual void load(KConfig *cfg);
   virtual void setToolTip (KDockWidget *, QString &);
+  virtual void  setPixmap(KDockWidget*,const QPixmap&);
   QStringList containedWidgets() const;
 protected:

--- kdelibs/kdeui/tests/kdockwidgettest.cpp  #1.11:1.12
@@ -132,4 +132,14 @@ DockApplication::DockApplication( const 
   m_bname->setEnabled( false );
 
+  QPushButton *b3 = new QPushButton(mainW);
+  b3->setGeometry(10,95,250,25);
+  b3->setText("change the icon of the green widget");
+  connect(b3,SIGNAL(clicked()), SLOT(gSetPix1()));
+
+  QPushButton *b4 = new QPushButton(mainW);
+  b4->setGeometry(10,130,250,25);
+  b4->setText("remove icon ");
+  connect(b4,SIGNAL(clicked()), SLOT(gSetPix2()));
+
   setGeometry(200, 100, 500, 300);
 
@@ -222,4 +232,14 @@ void DockApplication::updateButton()
 }
 
+void DockApplication::gSetPix1() {
+        dock->setPixmap(SmallIcon("agent"));
+        
+}
+
+void DockApplication::gSetPix2() {
+        dock->setPixmap();
+        
+}
+
 int main(int argc, char* argv[]) {
   KApplication a(argc,argv, "kdockdemoapp1");

--- kdelibs/kdeui/tests/kdockwidgettest.h  #1.3:1.4
@@ -35,4 +35,6 @@ public slots:
   void blueMain();
   void nullMain();
+  void gSetPix1();
+  void gSetPix2();
 
 protected:


Comment 2 esigra 2006-02-15 20:37:52 UTC
Thanks for fixing!