KIconThemes

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

KDE's Doxygen guidelines are available online.