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

tdeprint

  • tdeprint
  • management
kiconselectaction.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001 Michael Goffioul <tdeprint@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 <tdetoolbar.h>
26 #include <tdetoolbarbutton.h>
27 
28 class TDEIconSelectActionPrivate
29 {
30 public:
31  TDEIconSelectActionPrivate()
32  {
33  m_menu = 0;
34  }
35  TQStringList m_iconlst;
36  TQPopupMenu* m_menu;
37 };
38 
39 TDEIconSelectAction::TDEIconSelectAction(const TQString& text, int accel, TQObject* parent, const char* name)
40 : TDESelectAction(text, accel, parent, name)
41 {
42  d = new TDEIconSelectActionPrivate;
43 }
44 
45 TDEIconSelectAction::~TDEIconSelectAction()
46 {
47  delete d;
48 }
49 
50 void TDEIconSelectAction::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 TDEIconSelectAction::createPopupMenu()
61 {
62  if (!d->m_menu)
63  {
64  d->m_menu = popupMenu();
65  updateIcons();
66  }
67 }
68 
69 void TDEIconSelectAction::setItems(const TQStringList& lst, const TQStringList& iconlst)
70 {
71  TDESelectAction::setItems(lst);
72  d->m_iconlst = iconlst;
73  updateIcons();
74 }
75 
76 int TDEIconSelectAction::plug(TQWidget* widget, int index)
77 {
78  int value(-1);
79  if (widget->inherits("TQPopupMenu"))
80  {
81  createPopupMenu();
82  value = TDESelectAction::plug(widget, index);
83  }
84  else if (widget->inherits("TDEToolBar"))
85  {
86  TDEToolBar* bar = static_cast<TDEToolBar*>(widget);
87  int id = TDEAction::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, TQ_SIGNAL(destroyed()), TQ_SLOT(slotDestroyed()));
98 
99  value = containerCount()-1;
100  }
101  return value;
102 }
103 
104 void TDEIconSelectAction::updateCurrentItem(int id)
105 {
106  TQWidget* w = container(id);
107  if (w->inherits("TDEToolBar"))
108  static_cast<TDEToolBar*>(w)->getButton(itemId(id))->setIcon(d->m_iconlst[currentItem()]);
109  else
110  TDESelectAction::updateCurrentItem(id);
111 }
112 
113 void TDEIconSelectAction::setCurrentItem(int index)
114 {
115  TDESelectAction::setCurrentItem(index);
116 }
117 
118 #include "kiconselectaction.moc"

tdeprint

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

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.9.1
This website is maintained by Timothy Pearson.