• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeio/tdefile
 

tdeio/tdefile

  • tdeio
  • tdefile
kicondialog.cpp
1 /*
2  *
3  * This file is part of the KDE project, module tdefile.
4  * Copyright (C) 2000 Geert Jansen <jansen@kde.org>
5  * (C) 2000 Kurt Granroth <granroth@kde.org>
6  * (C) 1997 Christoph Neerfeld <chris@kde.org>
7  * (C) 2002 Carsten Pfeiffer <pfeiffer@kde.org>
8  *
9  * This is free software; it comes under the GNU Library General
10  * Public License, version 2. See the file "COPYING.LIB" for the
11  * exact licensing terms.
12  */
13 
14 #include "kicondialog.h"
15 
16 #include <config.h>
17 
18 #include <assert.h>
19 #include <list>
20 
21 #include <kiconviewsearchline.h>
22 
23 #include <tdeapplication.h>
24 #include <tdelocale.h>
25 #include <tdeglobal.h>
26 #include <kstandarddirs.h>
27 #include <kiconloader.h>
28 #include <kprogress.h>
29 #include <kiconview.h>
30 #include <tdefiledialog.h>
31 #include <kimagefilepreview.h>
32 
33 #include <tqlayout.h>
34 #include <tqstring.h>
35 #include <tqstringlist.h>
36 #include <tqimage.h>
37 #include <tqpixmap.h>
38 #include <tqlabel.h>
39 #include <tqcombobox.h>
40 #include <tqtimer.h>
41 #include <tqbuttongroup.h>
42 #include <tqradiobutton.h>
43 #include <tqfileinfo.h>
44 #include <tqtoolbutton.h>
45 #include <tqwhatsthis.h>
46 
47 #ifdef HAVE_LIBART
48 #include <svgicons/ksvgiconengine.h>
49 #include <svgicons/ksvgiconpainter.h>
50 #endif
51 
52 class TDEIconCanvas::TDEIconCanvasPrivate
53 {
54  public:
55  TDEIconCanvasPrivate() { m_bLoading = false; }
56  ~TDEIconCanvasPrivate() {}
57  bool m_bLoading;
58 };
59 
63 class IconPath : public TQString
64 {
65 protected:
66  TQString m_iconName;
67 
68 public:
69  IconPath(const TQString &ip) : TQString (ip)
70  {
71  int n = findRev('/');
72  m_iconName = (n==-1) ? static_cast<TQString>(*this) : mid(n+1);
73  }
74 
75 
76  IconPath() : TQString ()
77  { }
78 
79  bool operator== (const IconPath &ip) const
80  { return m_iconName == ip.m_iconName; }
81 
82  bool operator< (const IconPath &ip) const
83  { return m_iconName < ip.m_iconName; }
84 
85 };
86 
87 /*
88  * TDEIconCanvas: Iconview for the iconloader dialog.
89  */
90 
91 TDEIconCanvas::TDEIconCanvas(TQWidget *parent, const char *name)
92  : TDEIconView(parent, name)
93 {
94  d = new TDEIconCanvasPrivate;
95  mpTimer = new TQTimer(this);
96  connect(mpTimer, TQ_SIGNAL(timeout()), TQ_SLOT(slotLoadFiles()));
97  connect(this, TQ_SIGNAL(currentChanged(TQIconViewItem *)),
98  TQ_SLOT(slotCurrentChanged(TQIconViewItem *)));
99  setGridX(80);
100  setWordWrapIconText(false);
101  setShowToolTips(true);
102 }
103 
104 TDEIconCanvas::~TDEIconCanvas()
105 {
106  delete mpTimer;
107  delete d;
108 }
109 
110 void TDEIconCanvas::loadFiles(const TQStringList& files)
111 {
112  clear();
113  mFiles = files;
114  emit startLoading(mFiles.count());
115  mpTimer->start(10, true); // #86680
116  d->m_bLoading = false;
117 }
118 
119 void TDEIconCanvas::slotLoadFiles()
120 {
121  setResizeMode(Fixed);
122  TQApplication::setOverrideCursor(TQt::waitCursor);
123 
124  // disable updates to not trigger paint events when adding child items
125  setUpdatesEnabled( false );
126 
127 #ifdef HAVE_LIBART
128  KSVGIconEngine *svgEngine = new KSVGIconEngine();
129 #endif
130 
131  d->m_bLoading = true;
132  int i;
133  TQStringList::ConstIterator it;
134  uint emitProgress = 10; // so we will emit it once in the beginning
135  TQStringList::ConstIterator end(mFiles.end());
136  for (it=mFiles.begin(), i=0; it!=end; ++it, i++)
137  {
138  // Calling kapp->processEvents() makes the iconview flicker like hell
139  // (it's being repainted once for every new item), so we don't do this.
140  // Instead, we directly repaint the progress bar without going through
141  // the event-loop. We do that just once for every 10th item so that
142  // the progress bar doesn't flicker in turn. (pfeiffer)
143  if ( emitProgress >= 10 ) {
144  emit progress(i);
145  emitProgress = 0;
146  }
147 
148  emitProgress++;
149 // kapp->processEvents();
150  if ( !d->m_bLoading ) // user clicked on a button that will load another set of icons
151  break;
152  TQImage img;
153 
154  // Use the extension as the format. Works for XPM and PNG, but not for SVG
155  TQString path= *it;
156  TQString ext = path.right(3).upper();
157 
158  if (ext != "SVG" && ext != "VGZ")
159  img.load(*it);
160 #ifdef HAVE_LIBART
161  else
162  if (svgEngine->load(60, 60, *it))
163  img = *svgEngine->painter()->image();
164 #endif
165 
166  if (img.isNull())
167  continue;
168  if (img.width() > 60 || img.height() > 60)
169  {
170  if (img.width() > img.height())
171  {
172  int height = (int) ((60.0 / img.width()) * img.height());
173  img = img.smoothScale(60, height);
174  } else
175  {
176  int width = (int) ((60.0 / img.height()) * img.width());
177  img = img.smoothScale(width, 60);
178  }
179  }
180  TQPixmap pm;
181  pm.convertFromImage(img);
182  TQFileInfo fi(*it);
183  TQIconViewItem *item = new TQIconViewItem(this, fi.baseName(true), pm);
184  item->setKey(*it);
185  item->setDragEnabled(false);
186  item->setDropEnabled(false);
187  }
188 
189 #ifdef HAVE_LIBART
190  delete svgEngine;
191 #endif
192 
193  // enable updates since we have to draw the whole view now
194  setUpdatesEnabled( true );
195 
196  TQApplication::restoreOverrideCursor();
197  d->m_bLoading = false;
198  emit finished();
199  setResizeMode(Adjust);
200 }
201 
202 TQString TDEIconCanvas::getCurrent() const
203 {
204  if (!currentItem())
205  return TQString::null;
206  return currentItem()->key();
207 }
208 
209 void TDEIconCanvas::stopLoading()
210 {
211  d->m_bLoading = false;
212 }
213 
214 void TDEIconCanvas::slotCurrentChanged(TQIconViewItem *item)
215 {
216  emit nameChanged((item != 0L) ? item->text() : TQString::null);
217 }
218 
219 class TDEIconDialog::TDEIconDialogPrivate
220 {
221  public:
222  TDEIconDialogPrivate() {
223  m_bStrictIconSize = true;
224  m_bLockUser = false;
225  m_bLockCustomDir = false;
226  searchLine = 0;
227  }
228  ~TDEIconDialogPrivate() {}
229  bool m_bStrictIconSize, m_bLockUser, m_bLockCustomDir;
230  TQString custom;
231  TQString customLocation;
232  TDEIconViewSearchLine *searchLine;
233 };
234 
235 /*
236  * TDEIconDialog: Dialog for selecting icons. Both system and user
237  * specified icons can be chosen.
238  */
239 
240 TDEIconDialog::TDEIconDialog(TQWidget *parent, const char *name)
241  : KDialogBase(parent, name, true, i18n("Select Icon"), Ok|Cancel, Ok)
242 {
243  d = new TDEIconDialogPrivate;
244  mpLoader = TDEGlobal::iconLoader();
245  init();
246 }
247 
248 TDEIconDialog::TDEIconDialog(TDEIconLoader *loader, TQWidget *parent,
249  const char *name)
250  : KDialogBase(parent, name, true, i18n("Select Icon"), Ok|Cancel, Ok)
251 {
252  d = new TDEIconDialogPrivate;
253  mpLoader = loader;
254  init();
255 }
256 
257 void TDEIconDialog::init()
258 {
259  mGroupOrSize = TDEIcon::Desktop;
260  mContext = TDEIcon::Any;
261  mType = 0;
262  mFileList = TDEGlobal::dirs()->findAllResources("appicon", TQString::fromLatin1("*.png"));
263 
264  TQWidget *main = new TQWidget( this );
265  setMainWidget(main);
266 
267  TQVBoxLayout *top = new TQVBoxLayout(main);
268  top->setSpacing( spacingHint() );
269 
270  TQButtonGroup *bgroup = new TQButtonGroup(0, TQt::Vertical, i18n("Icon Source"), main);
271  bgroup->layout()->setSpacing(KDialog::spacingHint());
272  bgroup->layout()->setMargin(KDialog::marginHint());
273  top->addWidget(bgroup);
274  connect(bgroup, TQ_SIGNAL(clicked(int)), TQ_SLOT(slotButtonClicked(int)));
275  TQGridLayout *grid = new TQGridLayout(bgroup->layout(), 3, 2);
276  mpRb1 = new TQRadioButton(i18n("S&ystem icons:"), bgroup);
277  grid->addWidget(mpRb1, 1, 0);
278  mpCombo = new TQComboBox(bgroup);
279  connect(mpCombo, TQ_SIGNAL(activated(int)), TQ_SLOT(slotContext(int)));
280  grid->addWidget(mpCombo, 1, 1);
281  mpRb2 = new TQRadioButton(i18n("O&ther icons:"), bgroup);
282  grid->addWidget(mpRb2, 2, 0);
283  mpBrowseBut = new TQPushButton(i18n("&Browse..."), bgroup);
284  grid->addWidget(mpBrowseBut, 2, 1);
285 
286  //
287  // ADD SEARCHLINE
288  //
289  TQHBoxLayout *searchLayout = new TQHBoxLayout(0, 0, KDialog::spacingHint());
290  top->addLayout(searchLayout);
291 
292  TQToolButton *clearSearch = new TQToolButton(main);
293  clearSearch->setTextLabel(i18n("Clear Search"), true);
294  clearSearch->setIconSet(SmallIconSet(TQApplication::reverseLayout() ? "clear_left" :"locationbar_erase"));
295  searchLayout->addWidget(clearSearch);
296 
297  TQLabel *searchLabel = new TQLabel(i18n("&Search:"), main);
298  searchLayout->addWidget(searchLabel);
299 
300  d->searchLine = new TDEIconViewSearchLine(main, "searchLine");
301  searchLayout->addWidget(d->searchLine);
302  searchLabel->setBuddy(d->searchLine);
303 
304 
305  // signals and slots connections
306  connect(clearSearch, TQ_SIGNAL(clicked()), d->searchLine, TQ_SLOT(clear()));
307 
308  TQString wtstr = i18n("Search interactively for icon names (e.g. folder).");
309  TQWhatsThis::add(searchLabel, wtstr);
310  TQWhatsThis::add(d->searchLine, wtstr);
311 
312 
313  mpCanvas = new TDEIconCanvas(main);
314  connect(mpCanvas, TQ_SIGNAL(executed(TQIconViewItem *)), TQ_SLOT(slotAcceptIcons()));
315  connect(mpCanvas, TQ_SIGNAL(returnPressed(TQIconViewItem *)), TQ_SLOT(slotAcceptIcons()));
316  mpCanvas->setMinimumSize(400, 125);
317  top->addWidget(mpCanvas);
318  d->searchLine->setIconView(mpCanvas);
319 
320  mpProgress = new KProgress(main);
321  top->addWidget(mpProgress);
322  connect(mpCanvas, TQ_SIGNAL(startLoading(int)), TQ_SLOT(slotStartLoading(int)));
323  connect(mpCanvas, TQ_SIGNAL(progress(int)), TQ_SLOT(slotProgress(int)));
324  connect(mpCanvas, TQ_SIGNAL(finished()), TQ_SLOT(slotFinished()));
325 
326  // When pressing Ok or Cancel, stop loading icons
327  connect(this, TQ_SIGNAL(hidden()), mpCanvas, TQ_SLOT(stopLoading()));
328 
329  static const char* const context_text[] = {
330  I18N_NOOP( "Actions" ),
331  I18N_NOOP( "Animations" ),
332  I18N_NOOP( "Applications" ),
333  I18N_NOOP( "Categories" ),
334  I18N_NOOP( "Devices" ),
335  I18N_NOOP( "Emblems" ),
336  I18N_NOOP( "Emotes" ),
337  I18N_NOOP( "Filesystems" ),
338  I18N_NOOP( "International" ),
339  I18N_NOOP( "Mimetypes" ),
340  I18N_NOOP( "Places" ),
341  I18N_NOOP( "Status" ) };
342  static const TDEIcon::Context context_id[] = {
343  TDEIcon::Action,
344  TDEIcon::Animation,
345  TDEIcon::Application,
346  TDEIcon::Category,
347  TDEIcon::Device,
348  TDEIcon::Emblem,
349  TDEIcon::Emote,
350  TDEIcon::FileSystem,
351  TDEIcon::International,
352  TDEIcon::MimeType,
353  TDEIcon::Place,
354  TDEIcon::StatusIcon };
355  mNumContext = 0;
356  int cnt = sizeof( context_text ) / sizeof( context_text[ 0 ] );
357  // check all 3 arrays have same sizes
358  assert( cnt == sizeof( context_id ) / sizeof( context_id[ 0 ] )
359  && cnt == sizeof( mContextMap ) / sizeof( mContextMap[ 0 ] ));
360  for( int i = 0;
361  i < cnt;
362  ++i )
363  {
364  if( mpLoader->hasContext( context_id[ i ] ))
365  {
366  mpCombo->insertItem(i18n( context_text[ i ] ));
367  mContextMap[ mNumContext++ ] = context_id[ i ];
368  }
369  }
370  mpCombo->setFixedSize(mpCombo->sizeHint());
371 
372  mpBrowseBut->setFixedWidth(mpCombo->width());
373 
374  // Make the dialog a little taller
375  incInitialSize(TQSize(0,100));
376 }
377 
378 
379 TDEIconDialog::~TDEIconDialog()
380 {
381  delete d;
382 }
383 
384 void TDEIconDialog::slotAcceptIcons()
385 {
386  d->custom=TQString::null;
387  slotOk();
388 }
389 
390 void TDEIconDialog::showIcons()
391 {
392  mpCanvas->clear();
393  TQStringList filelist;
394  if (mType == 0)
395  if (d->m_bStrictIconSize)
396  filelist=mpLoader->queryIcons(mGroupOrSize, mContext);
397  else
398  filelist=mpLoader->queryIconsByContext(mGroupOrSize, mContext);
399  else if ( !d->customLocation.isNull() )
400  filelist=mpLoader->queryIconsByDir( d->customLocation );
401  else
402  filelist=mFileList;
403 
404  std::list<IconPath> iconlist;
405  TQStringList::Iterator it;
406  for( it = filelist.begin(); it != filelist.end(); ++it )
407  iconlist.push_back(IconPath(*it));
408 
409  iconlist.sort();
410  filelist.clear();
411 
412  for (const IconPath &ip : iconlist)
413  filelist.append(ip);
414 
415  d->searchLine->clear();
416  mpCanvas->loadFiles(filelist);
417 }
418 
419 void TDEIconDialog::setStrictIconSize(bool b)
420 {
421  d->m_bStrictIconSize=b;
422 }
423 
424 bool TDEIconDialog::strictIconSize() const
425 {
426  return d->m_bStrictIconSize;
427 }
428 
429 void TDEIconDialog::setIconSize( int size )
430 {
431  // see TDEIconLoader, if you think this is weird
432  if ( size == 0 )
433  mGroupOrSize = TDEIcon::Desktop; // default Group
434  else
435  mGroupOrSize = -size; // yes, TDEIconLoader::queryIconsByContext is weird
436 }
437 
438 int TDEIconDialog::iconSize() const
439 {
440  // 0 or any other value ==> mGroupOrSize is a group, so we return 0
441  return (mGroupOrSize < 0) ? -mGroupOrSize : 0;
442 }
443 
444 #ifndef KDE_NO_COMPAT
445 TQString TDEIconDialog::selectIcon(TDEIcon::Group group, TDEIcon::Context context, bool user)
446 {
447  setup( group, context, false, 0, user );
448  return openDialog();
449 }
450 #endif
451 
452 void TDEIconDialog::setup(TDEIcon::Group group, TDEIcon::Context context,
453  bool strictIconSize, int iconSize, bool user )
454 {
455  d->m_bStrictIconSize = strictIconSize;
456  mGroupOrSize = (iconSize == 0) ? group : -iconSize;
457  mType = user ? 1 : 0;
458  mpRb1->setChecked(!user);
459  mpRb2->setChecked(user);
460  mpCombo->setEnabled(!user);
461  mpBrowseBut->setEnabled(user);
462  setContext( context );
463 }
464 
465 void TDEIconDialog::setup(TDEIcon::Group group, TDEIcon::Context context,
466  bool strictIconSize, int iconSize, bool user,
467  bool lockUser, bool lockCustomDir )
468 {
469  d->m_bStrictIconSize = strictIconSize;
470  d->m_bLockUser = lockUser;
471  d->m_bLockCustomDir = lockCustomDir;
472  mGroupOrSize = (iconSize == 0) ? group : -iconSize;
473  mType = user ? 1 : 0;
474  mpRb1->setChecked(!user);
475  mpRb1->setEnabled( !lockUser || !user );
476  mpRb2->setChecked(user);
477  mpRb2->setEnabled( !lockUser || user );
478  mpCombo->setEnabled(!user);
479  mpBrowseBut->setEnabled( user && !lockCustomDir );
480  setContext( context );
481 }
482 
483 void TDEIconDialog::setContext( TDEIcon::Context context )
484 {
485  mContext = context;
486  for( int i = 0;
487  i < mNumContext;
488  ++i )
489  if( mContextMap[ i ] == context )
490  {
491  mpCombo->setCurrentItem( i );
492  return;
493  }
494 }
495 
496 void TDEIconDialog::setCustomLocation( const TQString& location )
497 {
498  d->customLocation = location;
499 }
500 
501 TQString TDEIconDialog::openDialog()
502 {
503  showIcons();
504 
505  if ( exec() == Accepted )
506  {
507  if (!d->custom.isNull())
508  return d->custom;
509  TQString name = mpCanvas->getCurrent();
510  if (name.isEmpty() || (mType == 1))
511  return name;
512  TQFileInfo fi(name);
513  return fi.baseName(true);
514  }
515  return TQString::null;
516 }
517 
518 void TDEIconDialog::showDialog()
519 {
520  setModal(false);
521  showIcons();
522  show();
523 }
524 
525 void TDEIconDialog::slotOk()
526 {
527  TQString name;
528  if (!d->custom.isNull())
529  {
530  name = d->custom;
531  }
532  else
533  {
534  name = mpCanvas->getCurrent();
535  if (!name.isEmpty() && (mType != 1))
536  {
537  TQFileInfo fi(name);
538  name = fi.baseName(true);
539  }
540  }
541 
542  emit newIconName(name);
543  KDialogBase::slotOk();
544 }
545 
546 TQString TDEIconDialog::getIcon(TDEIcon::Group group, TDEIcon::Context context,
547  bool strictIconSize, int iconSize, bool user,
548  TQWidget *parent, const TQString &caption)
549 {
550  TDEIconDialog dlg(parent, "icon dialog");
551  dlg.setup( group, context, strictIconSize, iconSize, user );
552  if (!caption.isNull())
553  dlg.setCaption(caption);
554 
555  return dlg.openDialog();
556 }
557 
558 void TDEIconDialog::slotButtonClicked(int id)
559 {
560  TQString file;
561 
562  switch (id)
563  {
564  case 0:
565  if(mType!=0)
566  {
567  mType = 0;
568  mpBrowseBut->setEnabled(false);
569  mpCombo->setEnabled(true);
570  showIcons();
571  }
572  break;
573 
574  case 1:
575  if(mType!=1)
576  {
577  mType = 1;
578  mpBrowseBut->setEnabled( !d->m_bLockCustomDir );
579  mpCombo->setEnabled(false);
580  showIcons();
581  }
582  break;
583  case 2:
584  {
585  // Create a file dialog to select a PNG, XPM or SVG file,
586  // with the image previewer shown.
587  // KFileDialog::getImageOpenURL doesn't allow svg.
588  KFileDialog dlg(TQString::null, i18n("*.png *.xpm *.svg *.svgz|Icon Files (*.png *.xpm *.svg *.svgz)"),
589  this, "filedialog", true);
590  dlg.setOperationMode( KFileDialog::Opening );
591  dlg.setCaption( i18n("Open") );
592  dlg.setMode( KFile::File );
593 
594  KImageFilePreview *ip = new KImageFilePreview( &dlg );
595  dlg.setPreviewWidget( ip );
596  dlg.exec();
597 
598  file = dlg.selectedFile();
599  if (!file.isEmpty())
600  {
601  d->custom = file;
602  if ( mType == 1 )
603  d->customLocation = TQFileInfo( file ).dirPath( true );
604  slotOk();
605  }
606  }
607  break;
608  }
609 }
610 
611 void TDEIconDialog::slotContext(int id)
612 {
613  mContext = static_cast<TDEIcon::Context>( mContextMap[ id ] );
614  showIcons();
615 }
616 
617 void TDEIconDialog::slotStartLoading(int steps)
618 {
619  if (steps < 10)
620  mpProgress->hide();
621  else
622  {
623  mpProgress->setTotalSteps(steps);
624  mpProgress->setProgress(0);
625  mpProgress->show();
626  }
627 }
628 
629 void TDEIconDialog::slotProgress(int p)
630 {
631  mpProgress->setProgress(p);
632  // commented out the following since setProgress already paints ther
633  // progress bar. ->repaint() only makes it flicker
634  //mpProgress->repaint();
635 }
636 
637 void TDEIconDialog::slotFinished()
638 {
639  mpProgress->hide();
640 }
641 
642 class TDEIconButton::TDEIconButtonPrivate
643 {
644  public:
645  TDEIconButtonPrivate() {
646  m_bStrictIconSize = false;
647  iconSize = 0; // let TDEIconLoader choose the default
648  }
649  ~TDEIconButtonPrivate() {}
650  bool m_bStrictIconSize;
651  int iconSize;
652 };
653 
654 
655 /*
656  * TDEIconButton: A "choose icon" pushbutton.
657  */
658 
659 TDEIconButton::TDEIconButton(TQWidget *parent, const char *name)
660  : TQPushButton(parent, name)
661 {
662  init( TDEGlobal::iconLoader() );
663 }
664 
665 TDEIconButton::TDEIconButton(TDEIconLoader *loader,
666  TQWidget *parent, const char *name)
667  : TQPushButton(parent, name)
668 {
669  init( loader );
670 }
671 
672 void TDEIconButton::init( TDEIconLoader *loader )
673 {
674  d = new TDEIconButtonPrivate;
675  mGroup = TDEIcon::Desktop;
676  mContext = TDEIcon::Application;
677  mbUser = false;
678 
679  mpLoader = loader;
680  mpDialog = 0L;
681  connect(this, TQ_SIGNAL(clicked()), TQ_SLOT(slotChangeIcon()));
682 }
683 
684 TDEIconButton::~TDEIconButton()
685 {
686  delete mpDialog;
687  delete d;
688 }
689 
690 void TDEIconButton::setStrictIconSize(bool b)
691 {
692  d->m_bStrictIconSize=b;
693 }
694 
695 bool TDEIconButton::strictIconSize() const
696 {
697  return d->m_bStrictIconSize;
698 }
699 
700 void TDEIconButton::setIconSize( int size )
701 {
702  d->iconSize = size;
703 }
704 
705 int TDEIconButton::iconSize() const
706 {
707  return d->iconSize;
708 }
709 
710 void TDEIconButton::setIconType(TDEIcon::Group group, TDEIcon::Context context, bool user)
711 {
712  mGroup = group;
713  mContext = context;
714  mbUser = user;
715 }
716 
717 void TDEIconButton::setIcon(const TQString& icon)
718 {
719  mIcon = icon;
720  setIconSet(mpLoader->loadIconSet(mIcon, mGroup, d->iconSize));
721 
722  if (!mpDialog)
723  {
724  mpDialog = new TDEIconDialog(mpLoader, this);
725  connect(mpDialog, TQ_SIGNAL(newIconName(const TQString&)), TQ_SLOT(newIconName(const TQString&)));
726  }
727 
728  if ( mbUser )
729  mpDialog->setCustomLocation( TQFileInfo( mpLoader->iconPath(mIcon, mGroup, true) ).dirPath( true ) );
730 }
731 
732 void TDEIconButton::resetIcon()
733 {
734  mIcon = TQString::null;
735  setIconSet(TQIconSet());
736 }
737 
738 void TDEIconButton::slotChangeIcon()
739 {
740  if (!mpDialog)
741  {
742  mpDialog = new TDEIconDialog(mpLoader, this);
743  connect(mpDialog, TQ_SIGNAL(newIconName(const TQString&)), TQ_SLOT(newIconName(const TQString&)));
744  }
745 
746  mpDialog->setup( mGroup, mContext, d->m_bStrictIconSize, d->iconSize, mbUser );
747  mpDialog->showDialog();
748 }
749 
750 void TDEIconButton::newIconName(const TQString& name)
751 {
752  if (name.isEmpty())
753  return;
754 
755  TQIconSet iconset = mpLoader->loadIconSet(name, mGroup, d->iconSize);
756  setIconSet(iconset);
757  mIcon = name;
758 
759  if ( mbUser )
760  mpDialog->setCustomLocation( TQFileInfo( mpLoader->iconPath(mIcon, mGroup, true) ).dirPath( true ) );
761 
762  emit iconChanged(name);
763 }
764 
765 void TDEIconCanvas::virtual_hook( int id, void* data )
766 { TDEIconView::virtual_hook( id, data ); }
767 
768 void TDEIconDialog::virtual_hook( int id, void* data )
769 { KDialogBase::virtual_hook( id, data ); }
770 
771 #include "kicondialog.moc"
KFileDialog
Provides a user (and developer) friendly way to select files and directories.
Definition: tdefiledialog.h:77
KImageFilePreview
Image preview widget for the file dialog.
Definition: kimagefilepreview.h:32
TDEIconButton::strictIconSize
bool strictIconSize() const
Returns true if a strict icon size policy is set.
Definition: kicondialog.cpp:695
TDEIconButton::setStrictIconSize
void setStrictIconSize(bool b)
Sets a strict icon size policy for allowed icons.
Definition: kicondialog.cpp:690
TDEIconButton::icon
TQString icon() const
Returns the name of the selected icon.
Definition: kicondialog.h:309
TDEIconButton::setIconSize
void setIconSize(int size)
Sets the size of the icon to be shown / selected.
Definition: kicondialog.cpp:700
TDEIconButton::TDEIconButton
TDEIconButton(TQWidget *parent=0L, const char *name=0L)
Constructs a TDEIconButton using the global iconloader.
Definition: kicondialog.cpp:659
TDEIconButton::~TDEIconButton
~TDEIconButton()
Destructs the button.
Definition: kicondialog.cpp:684
TDEIconButton::setIcon
void setIcon(const TQString &icon)
Sets the button's initial icon.
Definition: kicondialog.cpp:717
TDEIconButton::iconSize
int iconSize() const
Returns the iconsize set via setIconSize() or 0, if the default iconsize will be used.
Definition: kicondialog.cpp:705
TDEIconButton::setIconType
void setIconType(TDEIcon::Group group, TDEIcon::Context context, bool user=false)
Sets the icon group and context.
Definition: kicondialog.cpp:710
TDEIconButton::resetIcon
void resetIcon()
Resets the icon (reverts to an empty button).
Definition: kicondialog.cpp:732
TDEIconButton::iconChanged
void iconChanged(TQString icon)
Emitted when the icon has changed.
TDEIconCanvas
Icon canvas for TDEIconDialog.
Definition: kicondialog.h:36
TDEIconCanvas::loadFiles
void loadFiles(const TQStringList &files)
Load icons into the canvas.
Definition: kicondialog.cpp:110
TDEIconCanvas::nameChanged
void nameChanged(TQString)
Emitted when the current icon has changed.
TDEIconCanvas::getCurrent
TQString getCurrent() const
Returns the current icon.
Definition: kicondialog.cpp:202
TDEIconDialog
Dialog for interactive selection of icons.
Definition: kicondialog.h:92
TDEIconDialog::iconSize
int iconSize() const
Returns the iconsize set via setIconSize() or 0, if the default iconsize will be used.
Definition: kicondialog.cpp:438
TDEIconDialog::TDEIconDialog
TDEIconDialog(TQWidget *parent=0L, const char *name=0L)
Constructs an icon selection dialog using the global iconloader.
Definition: kicondialog.cpp:240
TDEIconDialog::openDialog
TQString openDialog()
exec()utes this modal dialog and returns the name of the selected icon, or TQString::null if the dial...
Definition: kicondialog.cpp:501
TDEIconDialog::setIconSize
void setIconSize(int size)
Sets the size of the icons to be shown / selected.
Definition: kicondialog.cpp:429
TDEIconDialog::setup
void setup(TDEIcon::Group group, TDEIcon::Context context=TDEIcon::Application, bool strictIconSize=false, int iconSize=0, bool user=false)
Allows you to set the same parameters as in the class method getIcon().
Definition: kicondialog.cpp:452
TDEIconDialog::showDialog
void showDialog()
show()es this dialog and emits a newIcon(const TQString&) signal when successful.
Definition: kicondialog.cpp:518
TDEIconDialog::selectIcon
TQString selectIcon(TDEIcon::Group group=TDEIcon::Desktop, TDEIcon::Context context=TDEIcon::Application, bool user=false)
Definition: kicondialog.cpp:445
TDEIconDialog::setStrictIconSize
void setStrictIconSize(bool b)
Sets a strict icon size policy for allowed icons.
Definition: kicondialog.cpp:419
TDEIconDialog::~TDEIconDialog
~TDEIconDialog()
Destructs the dialog.
Definition: kicondialog.cpp:379
TDEIconDialog::strictIconSize
bool strictIconSize() const
Returns true if a strict icon size policy is set.
Definition: kicondialog.cpp:424
TDEIconDialog::getIcon
static TQString getIcon(TDEIcon::Group group=TDEIcon::Desktop, TDEIcon::Context context=TDEIcon::Application, bool strictIconSize=false, int iconSize=0, bool user=false, TQWidget *parent=0, const TQString &caption=TQString::null)
Pops up the dialog an lets the user select an icon.
Definition: kicondialog.cpp:546
TDEIconDialog::setCustomLocation
void setCustomLocation(const TQString &location)
sets a custom icon directory
Definition: kicondialog.cpp:496

tdeio/tdefile

Skip menu "tdeio/tdefile"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeio/tdefile

Skip menu "tdeio/tdefile"
  • 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 tdeio/tdefile by doxygen 1.9.1
This website is maintained by Timothy Pearson.