• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kdeprint
 

kdeprint

  • kdeprint
  • management
kiconselectaction.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License version 2 as published by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  **/
19 
20 #include "kiconselectaction.h"
21 
22 #include <tqpopupmenu.h>
23 #include <kiconloader.h>
24 #include <kdebug.h>
25 #include <ktoolbar.h>
26 #include <ktoolbarbutton.h>
27 
28 class KIconSelectActionPrivate
29 {
30 public:
31  KIconSelectActionPrivate()
32  {
33  m_menu = 0;
34  }
35  TQStringList m_iconlst;
36  TQPopupMenu* m_menu;
37 };
38 
39 KIconSelectAction::KIconSelectAction(const TQString& text, int accel, TQObject* parent, const char* name)
40 : KSelectAction(text, accel, parent, name)
41 {
42  d = new KIconSelectActionPrivate;
43 }
44 
45 KIconSelectAction::~KIconSelectAction()
46 {
47  delete d;
48 }
49 
50 void KIconSelectAction::updateIcons()
51 {
52  if (d->m_menu)
53  {
54  TQStringList lst = items();
55  for (uint id=0; id<lst.count(); ++id)
56  d->m_menu->changeItem(id, SmallIconSet(d->m_iconlst[id]), lst[id]);
57  }
58 }
59 
60 void KIconSelectAction::createPopupMenu()
61 {
62  if (!d->m_menu)
63  {
64  d->m_menu = popupMenu();
65  updateIcons();
66  }
67 }
68 
69 void KIconSelectAction::setItems(const TQStringList& lst, const TQStringList& iconlst)
70 {
71  KSelectAction::setItems(lst);
72  d->m_iconlst = iconlst;
73  updateIcons();
74 }
75 
76 int KIconSelectAction::plug(TQWidget* widget, int index)
77 {
78  int value(-1);
79  if (widget->inherits(TQPOPUPMENU_OBJECT_NAME_STRING))
80  {
81  createPopupMenu();
82  value = KSelectAction::plug(widget, index);
83  }
84  else if (widget->inherits("KToolBar"))
85  {
86  KToolBar* bar = static_cast<KToolBar*>(widget);
87  int id = KAction::getToolButtonID();
88  // To have a correct layout in the toolbar, a non
89  // empty icon has to be used. Use "unknown" by default.
90  TQString iconName = (currentItem() != -1 ? d->m_iconlst[currentItem()] : "unknown");
91 
92  createPopupMenu();
93  bar->insertButton(iconName, id, true, plainText(), index);
94  bar->getButton(id)->setPopup(d->m_menu, true);
95  bar->setItemEnabled(id, isEnabled());
96  addContainer(bar, id);
97  connect(bar, TQT_SIGNAL(destroyed()), TQT_SLOT(slotDestroyed()));
98 
99  value = containerCount()-1;
100  }
101  return value;
102 }
103 
104 void KIconSelectAction::updateCurrentItem(int id)
105 {
106  TQWidget* w = container(id);
107  if (w->inherits("KToolBar"))
108  static_cast<KToolBar*>(w)->getButton(itemId(id))->setIcon(d->m_iconlst[currentItem()]);
109  else
110  KSelectAction::updateCurrentItem(id);
111 }
112 
113 void KIconSelectAction::setCurrentItem(int index)
114 {
115  KSelectAction::setCurrentItem(index);
116 }
117 
118 #include "kiconselectaction.moc"

kdeprint

Skip menu "kdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kdeprint

Skip menu "kdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdeprint by doxygen 1.9.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |