KIconThemes

kicondialog.cpp
1 /* vi: ts=8 sts=4 sw=4
2  *
3  * This file is part of the KDE project, module kfile.
4  * Copyright (C) 2000 Geert Jansen <[email protected]>
5  * (C) 2000 Kurt Granroth <[email protected]>
6  * (C) 1997 Christoph Neerfeld <[email protected]>
7  * (C) 2002 Carsten Pfeiffer <[email protected]>
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 #include "kicondialog_p.h"
16 
17 #include <klistwidgetsearchline.h>
18 #include <klocalizedstring.h>
19 #ifndef _WIN32_WCE
20 #include <QSvgRenderer>
21 #endif
22 
23 #include <QApplication>
24 #include <QComboBox>
25 #include <QDialogButtonBox>
26 #include <QGroupBox>
27 #include <QLayout>
28 #include <QLabel>
29 #include <QTimer>
30 #include <QRadioButton>
31 #include <QFileInfo>
32 #include <QProgressBar>
33 #include <QPainter>
34 #include <QScrollBar>
35 #include <QStandardPaths>
36 
42 class KIconCanvasDelegate : public QAbstractItemDelegate
43 {
44  Q_OBJECT
45 public:
46  KIconCanvasDelegate(KIconCanvas *parent, QAbstractItemDelegate *defaultDelegate);
47  ~KIconCanvasDelegate() override {}
48  void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
49  QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
50 private:
51  KIconCanvas *m_iconCanvas = nullptr;
52  QAbstractItemDelegate *m_defaultDelegate = nullptr;
53  static const int HORIZONTAL_EDGE_PAD = 3;
54 };
55 
56 KIconCanvasDelegate::KIconCanvasDelegate(KIconCanvas *parent, QAbstractItemDelegate *defaultDelegate)
57  : QAbstractItemDelegate(parent)
58 {
59  m_iconCanvas = parent;
60  m_defaultDelegate = defaultDelegate;
61 }
62 
63 void KIconCanvasDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
64 {
65  const int GRID_WIDTH = m_iconCanvas->gridSize().width();
66  QStyleOptionViewItem newOption = option;
67  // Manipulate the width available.
68  newOption.rect.setX((option.rect.x() / GRID_WIDTH) * GRID_WIDTH + HORIZONTAL_EDGE_PAD);
69  newOption.rect.setWidth(GRID_WIDTH - 2 * HORIZONTAL_EDGE_PAD);
70 
71  m_defaultDelegate->paint(painter, newOption, index);
72 }
73 
74 QSize KIconCanvasDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
75 {
76  QSize size = m_defaultDelegate->sizeHint(option, index);
77  const int GRID_WIDTH = m_iconCanvas->gridSize().width();
78  size.setWidth(GRID_WIDTH - 2 * HORIZONTAL_EDGE_PAD);
79  return size;
80 }
81 
82 /*
83  * KIconCanvas: Iconview for the iconloader dialog.
84  */
85 
86 KIconCanvas::KIconCanvas(QWidget *parent)
87  : QListWidget(parent),
88  m_loading(false),
89  m_timer(new QTimer(this)),
90  m_delegate(new KIconCanvasDelegate(this, itemDelegate()))
91 {
92  setViewMode(IconMode);
93  setUniformItemSizes(true);
94  setMovement(Static);
95  setIconSize(QSize(60, 60));
96  connect(m_timer, &QTimer::timeout, this, QOverload<>::of(&KIconCanvas::loadFiles));
98  this, &KIconCanvas::currentListItemChanged);
99  setGridSize(QSize(100, 80));
100 
101  setItemDelegate(m_delegate);
102 }
103 
104 KIconCanvas::~KIconCanvas()
105 {
106  delete m_timer;
107  delete m_delegate;
108 }
109 
110 void KIconCanvas::loadFiles(const QStringList &files)
111 {
112  clear();
113  m_files = files;
114  emit startLoading(m_files.count());
115  m_timer->setSingleShot(true);
116  m_timer->start(10);
117  m_loading = false;
118 }
119 
120 void KIconCanvas::loadFiles()
121 {
122  setResizeMode(QListWidget::Fixed);
123  QApplication::setOverrideCursor(Qt::WaitCursor);
124 
125  // disable updates to not trigger paint events when adding child items,
126  // but force an initial paint so that we do not get garbage
127  repaint();
128  setUpdatesEnabled(false);
129 
130  // Cache these as we will call them frequently.
131  const int canvasIconWidth = iconSize().width();
132  const int canvasIconHeight = iconSize().width();
133  const bool uniformIconSize = uniformItemSizes();
134 
135  m_loading = true;
136  int i;
138  uint emitProgress = 10; // so we will emit it once in the beginning
139  QStringList::ConstIterator end(m_files.constEnd());
140  for (it = m_files.constBegin(), i = 0; it != end; ++it, ++i) {
141  if (emitProgress >= 10) {
142  emit progress(i);
143  emitProgress = 0;
144  }
145 
146  emitProgress++;
147 
148  if (!m_loading) { // user clicked on a button that will load another set of icons
149  break;
150  }
151  QImage img;
152 
153  // Use the extension as the format. Works for XPM and PNG, but not for SVG
154  QString path = *it;
155  QString ext = path.right(3).toUpper();
156 
157  if (ext != QLatin1String("SVG") && ext != QLatin1String("VGZ")) {
158  img.load(*it);
159  } else {
160 #ifndef _WIN32_WCE
161  // Special stuff for SVG icons
162  img = QImage(canvasIconWidth, canvasIconHeight, QImage::Format_ARGB32_Premultiplied);
163  img.fill(0);
164  QSvgRenderer renderer(*it);
165  if (renderer.isValid()) {
166  QPainter p(&img);
167  renderer.render(&p);
168  }
169 #endif
170  }
171 
172  if (img.isNull()) {
173  continue;
174  }
175 
176  if (img.width() > canvasIconWidth || img.height() > canvasIconHeight) {
177  if (img.width() / (float)canvasIconWidth > img.height() / (float)canvasIconHeight) {
178  int height = (int)(((float)canvasIconWidth / img.width()) * img.height());
179  img = img.scaled(canvasIconWidth, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
180  } else {
181  int width = (int)(((float)canvasIconHeight / img.height()) * img.width());
182  img = img.scaled(width, canvasIconHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
183  }
184  }
185 
186  if (uniformIconSize && (img.width() != canvasIconWidth || img.height() != canvasIconHeight)) {
187  // Image is smaller than desired. Draw onto a transparent QImage of the required dimensions.
188  // (Unpleasant glitches occur if we break the uniformIconSizes() contract).
189  QImage paddedImage = QImage(canvasIconWidth, canvasIconHeight, QImage::Format_ARGB32_Premultiplied);
190  paddedImage.fill(0);
191  QPainter painter(&paddedImage);
192  painter.drawImage((canvasIconWidth - img.width()) / 2, (canvasIconHeight - img.height()) / 2, img);
193  img = paddedImage;
194  }
195 
196  QPixmap pm = QPixmap::fromImage(img);
197  QFileInfo fi(*it);
198  QListWidgetItem *item = new QListWidgetItem(pm, fi.completeBaseName(), this);
199  item->setData(Qt::UserRole, *it);
200  item->setToolTip(fi.completeBaseName());
201  }
202 
203  // enable updates since we have to draw the whole view now
204  setUpdatesEnabled(true);
205 
207  m_loading = false;
208  emit finished();
209  setResizeMode(QListWidget::Adjust);
210 }
211 
212 QString KIconCanvas::getCurrent() const
213 {
214  if (!currentItem()) {
215  return QString();
216  }
217 
218  return currentItem()->data(Qt::UserRole).toString();
219 }
220 
221 void KIconCanvas::stopLoading()
222 {
223  m_loading = false;
224 }
225 
226 void KIconCanvas::currentListItemChanged(QListWidgetItem *item)
227 {
228  emit nameChanged((item != nullptr) ? item->text() : QString());
229 }
230 
231 // TODO KF6 remove and override KIconDialog::showEvent()
232 class ShowEventFilter : public QObject
233 {
234 public:
235  explicit ShowEventFilter(QObject *parent) : QObject(parent) {}
236  ~ShowEventFilter() override {}
237 
238 private:
239  bool eventFilter(QObject *watched, QEvent *event) override
240  {
241  if (event->type() == QEvent::Show) {
242  KIconDialog *q = static_cast<KIconDialog *>(parent());
243  q->d->showIcons();
244  q->d->searchLine->setFocus();
245  }
246 
247  return QObject::eventFilter(watched, event);
248  }
249 };
250 
251 /*
252  * KIconDialog: Dialog for selecting icons. Both system and user
253  * specified icons can be chosen.
254  */
255 
257  : QDialog(parent), d(new KIconDialogPrivate(this))
258 {
259  setModal(true);
260  setWindowTitle(i18n("Select Icon"));
261 
262  d->mpLoader = KIconLoader::global();
263  d->init();
264 
265  installEventFilter(new ShowEventFilter(this));
266 }
267 
269  : QDialog(parent), d(new KIconDialogPrivate(this))
270 {
271  setModal(true);
272  setWindowTitle(i18n("Select Icon"));
273 
274  d->mpLoader = loader;
275  d->init();
276 
277  installEventFilter(new ShowEventFilter(this));
278 }
279 
280 void KIconDialog::KIconDialogPrivate::init()
281 {
282  mGroupOrSize = KIconLoader::Desktop;
283  mContext = KIconLoader::Any;
284 
285  QVBoxLayout *top = new QVBoxLayout;
286  q->setLayout(top);
287 
288  QGroupBox *bgroup = new QGroupBox(q);
289  bgroup->setTitle(i18n("Icon Source"));
290 
291  QVBoxLayout *vbox = new QVBoxLayout;
292  bgroup->setLayout(vbox);
293  top->addWidget(bgroup);
294 
295  QGridLayout *grid = new QGridLayout();
296  vbox->addLayout(grid);
297 
298  mpSystemIcons = new QRadioButton(i18n("S&ystem icons:"), bgroup);
299  connect(mpSystemIcons, SIGNAL(clicked()), q, SLOT(_k_slotSystemIconClicked()));
300  grid->addWidget(mpSystemIcons, 1, 0);
301  mpCombo = new QComboBox(bgroup);
302  connect(mpCombo, SIGNAL(activated(int)), q, SLOT(_k_slotContext(int)));
303  grid->addWidget(mpCombo, 1, 1);
304  mpOtherIcons = new QRadioButton(i18n("O&ther icons:"), bgroup);
305  connect(mpOtherIcons, SIGNAL(clicked()), q, SLOT(_k_slotOtherIconClicked()));
306  grid->addWidget(mpOtherIcons, 2, 0);
307  mpBrowseBut = new QPushButton(i18n("&Browse..."), bgroup);
308  connect(mpBrowseBut, SIGNAL(clicked()), q, SLOT(_k_slotBrowse()));
309  grid->addWidget(mpBrowseBut, 2, 1);
310 
311  //
312  // ADD SEARCHLINE
313  //
314  QHBoxLayout *searchLayout = new QHBoxLayout();
315  searchLayout->setContentsMargins(0, 0, 0, 0);
316  top->addLayout(searchLayout);
317 
318  QLabel *searchLabel = new QLabel(i18n("&Search:"), q);
319  searchLayout->addWidget(searchLabel);
320 
321  searchLine = new KListWidgetSearchLine(q);
322  searchLayout->addWidget(searchLine);
323  searchLabel->setBuddy(searchLine);
324 
325  QString wtstr = i18n("Search interactively for icon names (e.g. folder).");
326  searchLabel->setWhatsThis(wtstr);
327  searchLine->setWhatsThis(wtstr);
328 
329  mpCanvas = new KIconCanvas(q);
330  connect(mpCanvas, SIGNAL(itemActivated(QListWidgetItem*)), q, SLOT(_k_slotAcceptIcons()));
331  top->addWidget(mpCanvas);
332  searchLine->setListWidget(mpCanvas);
333 
334  // Compute width of canvas with 4 icons displayed in a row
335  QStyleOption opt;
336  opt.initFrom(mpCanvas);
337  int width = 4 * mpCanvas->gridSize().width() + 1;
338  width += mpCanvas->verticalScrollBar()->sizeHint().width();
339  width += 2 * mpCanvas->frameWidth();
340  if (mpCanvas->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, &opt, mpCanvas)) {
341  width += mpCanvas->style()->pixelMetric(QStyle::PM_ScrollView_ScrollBarSpacing, &opt, mpCanvas);
342  }
343  mpCanvas->setMinimumSize(width, 125);
344 
345  mpProgress = new QProgressBar(q);
346  top->addWidget(mpProgress);
347  connect(mpCanvas, SIGNAL(startLoading(int)), q, SLOT(_k_slotStartLoading(int)));
348  connect(mpCanvas, SIGNAL(progress(int)), q, SLOT(_k_slotProgress(int)));
349  connect(mpCanvas, SIGNAL(finished()), q, SLOT(_k_slotFinished()));
350 
351  // When pressing Ok or Cancel, stop loading icons
352  connect(q, &QDialog::finished, mpCanvas, &KIconCanvas::stopLoading);
353 
354  static const char *const context_text[] = {
355  I18N_NOOP("Actions"),
356  I18N_NOOP("Applications"),
357  I18N_NOOP("Categories"),
358  I18N_NOOP("Devices"),
359  I18N_NOOP("Emblems"),
360  I18N_NOOP("Emotes"),
361  I18N_NOOP("Mimetypes"),
362  I18N_NOOP("Places"),
363  I18N_NOOP("Status"),
364  I18N_NOOP("All")
365  };
366  static const KIconLoader::Context context_id[] = {
377  };
378  mNumContext = 0;
379  int cnt = sizeof(context_text) / sizeof(context_text[ 0 ]);
380  // check all 3 arrays have same sizes
381  Q_ASSERT(cnt == sizeof(context_id) / sizeof(context_id[ 0 ])
382  && cnt == sizeof(mContextMap) / sizeof(mContextMap[ 0 ]));
383  for (int i = 0; i < cnt; ++i) {
384  if (mpLoader->hasContext(context_id[ i ])) {
385  mpCombo->addItem(i18n(context_text[ i ]));
386  mContextMap[ mNumContext++ ] = context_id[ i ];
387  }
388  }
389  mpCombo->setMaxVisibleItems(cnt);
390  mpCombo->setFixedSize(mpCombo->sizeHint());
391 
392  mpBrowseBut->setFixedWidth(mpCombo->width());
393 
394  QDialogButtonBox *buttonBox = new QDialogButtonBox(q);
395  buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
396  connect(buttonBox, &QDialogButtonBox::accepted, q, &KIconDialog::slotOk);
398  top->addWidget(buttonBox);
399 
400  // Make the dialog a little taller
401  q->resize(q->sizeHint() + QSize(0, 100));
402  q->adjustSize();
403 }
404 
406 {
407  delete d;
408 }
409 
410 void KIconDialog::KIconDialogPrivate::_k_slotAcceptIcons()
411 {
412  custom.clear();
413  q->slotOk();
414 }
415 
416 static bool sortByFileName(const QString &path1, const QString &path2)
417 {
418  const QString fileName1 = path1.mid(path1.lastIndexOf(QLatin1Char('/')) + 1);
419  const QString fileName2 = path2.mid(path2.lastIndexOf(QLatin1Char('/')) + 1);
420  return QString::compare(fileName1, fileName2, Qt::CaseInsensitive) < 0;
421 }
422 
423 void KIconDialog::KIconDialogPrivate::showIcons()
424 {
425  mpCanvas->clear();
426  QStringList filelist;
427  if (mpSystemIcons->isChecked()) {
428  if (m_bStrictIconSize) {
429  filelist = mpLoader->queryIcons(mGroupOrSize, mContext);
430  } else {
431  filelist = mpLoader->queryIconsByContext(mGroupOrSize, mContext);
432  }
433  } else if (!customLocation.isEmpty()) {
434  filelist = mpLoader->queryIconsByDir(customLocation);
435  } else {
436  // List PNG files found directly in the kiconload search paths.
437  const QStringList pngNameFilter(QStringLiteral("*.png"));
438  for (const QString &relDir : KIconLoader::global()->searchPaths()) {
439  const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, relDir, QStandardPaths::LocateDirectory);
440  for (const QString &dir : dirs) {
441  const auto files = QDir(dir).entryList(pngNameFilter);
442  for (const QString &fileName : files) {
443  filelist << dir + QLatin1Char('/') + fileName;
444  }
445  }
446  }
447  }
448 
449  std::sort(filelist.begin(), filelist.end(), sortByFileName);
450 
451  // The KIconCanvas has uniformItemSizes set which really expects
452  // all added icons to be the same size, otherwise weirdness ensues :)
453  // Ensure all SVGs are scaled to the desired size and that as few icons
454  // need to be padded as possible by specifying a sensible size.
455  if (mGroupOrSize < -1) {
456  // mGroupOrSize can be -1 if NoGroup is chosen.
457  // Explicit size.
458  mpCanvas->setIconSize(QSize(-mGroupOrSize, -mGroupOrSize));
459  } else {
460  // Icon group.
461  int groupSize = mpLoader->currentSize(static_cast<KIconLoader::Group>(mGroupOrSize));
462  mpCanvas->setIconSize(QSize(groupSize, groupSize));
463  }
464 
465  mpCanvas->loadFiles(filelist);
466 }
467 
469 {
470  d->m_bStrictIconSize = b;
471 }
472 
474 {
475  return d->m_bStrictIconSize;
476 }
477 
479 {
480  // see KIconLoader, if you think this is weird
481  if (size == 0) {
482  d->mGroupOrSize = KIconLoader::Desktop; // default Group
483  } else {
484  d->mGroupOrSize = -size; // yes, KIconLoader::queryIconsByContext is weird
485  }
486 }
487 
489 {
490  // 0 or any other value ==> mGroupOrSize is a group, so we return 0
491  return (d->mGroupOrSize < 0) ? -d->mGroupOrSize : 0;
492 }
493 
495  bool strictIconSize, int iconSize, bool user,
496  bool lockUser, bool lockCustomDir)
497 {
498  d->m_bStrictIconSize = strictIconSize;
499  d->m_bLockUser = lockUser;
500  d->m_bLockCustomDir = lockCustomDir;
501  if (iconSize == 0) {
502  if (group == KIconLoader::NoGroup) {
503  // NoGroup has numeric value -1, which should
504  // not really be used with KIconLoader::queryIcons*(...);
505  // pick a proper group.
506  d->mGroupOrSize = KIconLoader::Small;
507  } else {
508  d->mGroupOrSize = group;
509  }
510  } else {
511  d->mGroupOrSize = -iconSize;
512  }
513 
514  d->mpSystemIcons->setChecked(!user);
515  d->mpSystemIcons->setEnabled(!lockUser || !user);
516  d->mpOtherIcons->setChecked(user);
517  d->mpOtherIcons->setEnabled(!lockUser || user);
518  d->mpCombo->setEnabled(!user);
519  d->mpBrowseBut->setEnabled(user && !lockCustomDir);
520  d->setContext(context);
521 }
522 
523 void KIconDialog::KIconDialogPrivate::setContext(KIconLoader::Context context)
524 {
525  mContext = context;
526  for (int i = 0; i < mNumContext; ++i) {
527  if (mContextMap[ i ] == context) {
528  mpCombo->setCurrentIndex(i);
529  return;
530  }
531  }
532 }
533 
535 {
536  d->customLocation = location;
537 }
538 
540 {
541  if (exec() == Accepted) {
542  if (!d->custom.isEmpty()) {
543  return d->custom;
544  }
545 
546  const QString name = d->mpCanvas->getCurrent();
547  if (name.isEmpty() || d->mpOtherIcons->isChecked()) {
548  return name;
549  }
550 
551  QFileInfo fi(name);
552  return fi.completeBaseName();
553  }
554 
555  return QString();
556 }
557 
559 {
560  setModal(false);
561  show();
562 }
563 
564 void KIconDialog::slotOk()
565 {
566  QString name;
567  if (!d->custom.isEmpty()) {
568  name = d->custom;
569  } else {
570  name = d->mpCanvas->getCurrent();
571  if (!name.isEmpty() && d->mpSystemIcons->isChecked()) {
572  const QFileInfo fi(name);
573  name = fi.completeBaseName();
574  }
575  }
576 
577  emit newIconName(name);
578  QDialog::accept();
579 }
580 
582  bool strictIconSize, int iconSize, bool user,
583  QWidget *parent, const QString &caption)
584 {
585  KIconDialog dlg(parent);
586  dlg.setup(group, context, strictIconSize, iconSize, user);
587  if (!caption.isEmpty()) {
588  dlg.setWindowTitle(caption);
589  }
590 
591  return dlg.openDialog();
592 }
593 
594 void KIconDialog::KIconDialogPrivate::_k_slotBrowse()
595 {
596  if (browseDialog) {
597  browseDialog.data()->show();
598  browseDialog.data()->raise();
599  return;
600  }
601 
602  // Create a file dialog to select an ICO, PNG, XPM or SVG file,
603  // with the image previewer shown.
604  QFileDialog *dlg = new QFileDialog(q, i18n("Select Icon"), QString(), i18n("*.ico *.png *.xpm *.svg *.svgz|Icon Files (*.ico *.png *.xpm *.svg *.svgz)"));
605  dlg->setModal(false);
606  dlg->setFileMode(QFileDialog::ExistingFile);
607  connect(dlg, SIGNAL(fileSelected(QString)), q, SLOT(_k_customFileSelected(QString)));
608  browseDialog = dlg;
609  dlg->show();
610 }
611 
612 void KIconDialog::KIconDialogPrivate::_k_customFileSelected(const QString &path)
613 {
614  if (!path.isEmpty()) {
615  custom = path;
616  if (mpSystemIcons->isChecked()) {
617  customLocation = QFileInfo(custom).absolutePath();
618  }
619  q->slotOk();
620  }
621 }
622 
623 void KIconDialog::KIconDialogPrivate::_k_slotSystemIconClicked()
624 {
625  mpBrowseBut->setEnabled(false);
626  mpCombo->setEnabled(true);
627  showIcons();
628 }
629 
630 void KIconDialog::KIconDialogPrivate::_k_slotOtherIconClicked()
631 {
632  mpBrowseBut->setEnabled(!m_bLockCustomDir);
633  mpCombo->setEnabled(false);
634  showIcons();
635 }
636 
637 void KIconDialog::KIconDialogPrivate::_k_slotContext(int id)
638 {
639  mContext = static_cast<KIconLoader::Context>(mContextMap[ id ]);
640  showIcons();
641 }
642 
643 void KIconDialog::KIconDialogPrivate::_k_slotStartLoading(int steps)
644 {
645  if (steps < 10) {
646  mpProgress->hide();
647  } else {
648  mNumOfSteps = steps;
649  mpProgress->setValue(0);
650  mpProgress->show();
651  }
652 }
653 
654 void KIconDialog::KIconDialogPrivate::_k_slotProgress(int p)
655 {
656  mpProgress->setValue(static_cast<int>(100.0 * (double)p / (double)mNumOfSteps));
657 }
658 
659 void KIconDialog::KIconDialogPrivate::_k_slotFinished()
660 {
661  mNumOfSteps = 1;
662  mpProgress->hide();
663 }
664 
665 #include "kicondialog.moc"
666 #include "moc_kicondialog.cpp"
667 #include "moc_kicondialog_p.cpp"
void setCustomLocation(const QString &location)
Sets the location of the custom icon directory.
An icon that represents a mime type (or file type).
Definition: kiconloader.h:96
An icon that represents an event.
Definition: kiconloader.h:103
QEvent::Type type() const const
void setContentsMargins(int left, int top, int right, int bottom)
bool load(QIODevice *device, const char *format)
QString toUpper() const const
virtual void reject()
int width() const const
void setModal(bool modal)
QStringList locateAll(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
void addWidget(QWidget *widget, int row, int column, Qt::Alignment alignment)
void setIconSize(int size)
Sets the size of the icons to be shown / selected.
An icon that expresses an emotion.
Definition: kiconloader.h:100
QString openDialog()
exec()utes this modal dialog and returns the name of the selected icon, or QString() if the dialog wa...
virtual int exec()
QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags)
void setup(KIconLoader::Group group, KIconLoader::Context context=KIconLoader::Application, bool strictIconSize=false, int iconSize=0, bool user=false, bool lockUser=false, bool lockCustomDir=false)
Allows you to set the same parameters as in the class method getIcon(), as well as two additional par...
void setIconSize(int size)
Sets the size of the icon to be shown / selected.
Definition: kiconbutton.cpp:97
bool isNull() const const
An icon that represents a location (e.g. &#39;home&#39;, &#39;trash&#39;).
Definition: kiconloader.h:102
void restoreOverrideCursor()
Desktop icons.
Definition: kiconloader.h:133
Dialog for interactive selection of icons.
Definition: kicondialog.h:32
static QString getIcon(KIconLoader::Group group=KIconLoader::Desktop, KIconLoader::Context context=KIconLoader::Application, bool strictIconSize=false, int iconSize=0, bool user=false, QWidget *parent=nullptr, const QString &caption=QString())
Pops up the dialog an lets the user select an icon.
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
void initFrom(const QWidget *widget)
void finished(int result)
int width() const const
void setBuddy(QWidget *buddy)
int iconSize() const
Returns the icon size set via setIconSize() or 0, if the default icon size will be used...
bool strictIconSize() const
Returns true if a strict icon size policy is set.
QSize size() const const
void timeout()
Some icon with unknown purpose.
Definition: kiconloader.h:87
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
KGuiItem clear()
void setStrictIconSize(bool policy)
Sets a strict icon size policy for allowed icons.
void setLayout(QLayout *layout)
void installEventFilter(QObject *filterObj)
int iconSize() const
Returns the icon size set via setIconSize() or 0, if the default icon size will be used...
void fill(uint pixelValue)
Small icons, e.g. for buttons.
Definition: kiconloader.h:141
An icon that represents a category.
Definition: kiconloader.h:98
Q_OBJECTQ_OBJECT
void setUpdatesEnabled(bool enable)
void setToolTip(const QString &toolTip)
int width() const const
void setWidth(int width)
bool isEmpty() const const
#define I18N_NOOP(text)
void showDialog()
show()s this dialog and emits a newIconName(const QString&) signal when successful.
virtual bool eventFilter(QObject *watched, QEvent *event)
An action icon (e.g. &#39;save&#39;, &#39;print&#39;).
Definition: kiconloader.h:88
static KIconLoader * global()
Returns the global icon loader initialized with the application name.
virtual void accept()
QString right(int n) const const
virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const const =0
void setOverrideCursor(const QCursor &cursor)
QList::iterator end()
virtual void setData(int role, const QVariant &value)
void repaint()
QString i18n(const char *text, const TYPE &arg...)
An icon that represents an application.
Definition: kiconloader.h:89
const QList< QKeySequence > & end()
void setWhatsThis(const QString &)
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, Qt::ImageConversionFlags flags)
QString mid(int position, int n) const const
An icon that represents a device.
Definition: kiconloader.h:90
void setStandardButtons(QDialogButtonBox::StandardButtons buttons)
~KIconDialog()
Destructs the dialog.
void setTitle(const QString &title)
void setFileMode(QFileDialog::FileMode mode)
QStringList entryList(QDir::Filters filters, QDir::SortFlags sort) const const
Context
Defines the context of the icon.
Definition: kiconloader.h:86
void setWindowTitle(const QString &)
Group
The group of the icon.
Definition: kiconloader.h:129
typedef ConstIterator
virtual bool event(QEvent *e) override
virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const const =0
QString completeBaseName() const const
int height() const const
KIconDialog(QWidget *parent=nullptr)
Constructs an icon selection dialog using the global icon loader.
void show()
QString absolutePath() const const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QObject * parent() const const
int compare(const QString &other, Qt::CaseSensitivity cs) const const
QChar * data()
void currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
QList::iterator begin()
QString text() const const
int height() const const
QImage scaled(int width, int height, Qt::AspectRatioMode aspectRatioMode, Qt::TransformationMode transformMode) const const
Iconloader for KDE.
Definition: kiconloader.h:78
void addLayout(QLayout *layout, int stretch)
An icon that adds information to an existing icon.
Definition: kiconloader.h:99
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed May 27 2020 22:49:17 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.