• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

Plasma

  • Plasma
  • IconWidget
Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | List of all members
Plasma::IconWidget Class Reference

#include <iconwidget.h>

Inheritance diagram for Plasma::IconWidget:
QGraphicsWidget

Public Slots

void setPressed (bool pressed=true)
 
void setUnpressed ()
 

Signals

void activated ()
 
void changed ()
 
void clicked ()
 
void doubleClicked ()
 
void pressed (bool down)
 

Public Member Functions

 IconWidget (const QIcon &icon, const QString &text, QGraphicsItem *parent=0)
 
 IconWidget (const QString &text, QGraphicsItem *parent=0)
 
 IconWidget (QGraphicsItem *parent=0)
 
virtual ~IconWidget ()
 
QAction * action () const
 
void addIconAction (QAction *action)
 
void drawActionButtonBase (QPainter *painter, const QSize &size, int element)
 
bool drawBackground () const
 
QIcon icon () const
 
QSizeF iconSize () const
 
QString infoText () const
 
bool invertedLayout () const
 
void invertLayout (bool invert)
 
QSizeF maximumIconSize () const
 
QSizeF minimumIconSize () const
 
int numDisplayLines ()
 
Qt::Orientation orientation () const
 
QSizeF preferredIconSize () const
 
void removeIconAction (QAction *action)
 
void setAction (QAction *action)
 
void setDrawBackground (bool draw)
 
void setIcon (const QIcon &icon)
 
Q_INVOKABLE void setIcon (const QString &icon)
 
void setInfoText (const QString &text)
 
void setMaximumIconSize (const QSizeF &size)
 
void setMinimumIconSize (const QSizeF &size)
 
void setNumDisplayLines (int numLines)
 
void setOrientation (Qt::Orientation orientation)
 
void setPreferredIconSize (const QSizeF &size)
 
void setSvg (const QString &svgFilePath, const QString &svgIconElement=QString())
 
void setText (const QString &text)
 
void setTextBackgroundColor (const QColor &color)
 
QPainterPath shape () const
 
Q_INVOKABLE QSizeF sizeFromIconSize (const qreal iconWidth) const
 
QString svg () const
 
QString text () const
 
QColor textBackgroundColor () const
 

Protected Member Functions

void changeEvent (QEvent *event)
 
void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 
void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 
bool isDown ()
 
void mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event)
 
void mouseMoveEvent (QGraphicsSceneMouseEvent *event)
 
void mousePressEvent (QGraphicsSceneMouseEvent *event)
 
void mouseReleaseEvent (QGraphicsSceneMouseEvent *event)
 
void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
 
bool sceneEventFilter (QGraphicsItem *watched, QEvent *event)
 
QSizeF sizeHint (Qt::SizeHint which, const QSizeF &constraint=QSizeF()) const
 

Properties

QAction * action
 
bool drawBackground
 
QIcon icon
 
QSizeF iconSize
 
QString infoText
 
QSizeF maximumIconSize
 
QSizeF minimumIconSize
 
int numDisplayLines
 
Qt::Orientation orientation
 
QSizeF preferredIconSize
 
QString svg
 
QString text
 
QColor textBackgroundColor
 

Detailed Description

Definition at line 56 of file iconwidget.h.

Constructor & Destructor Documentation

◆ IconWidget() [1/3]

IconWidget::IconWidget ( QGraphicsItem *  parent = 0)
explicit

Creates a new Plasma::IconWidget.

Parameters
parentthe QGraphicsItem this icon is parented to.

Definition at line 351 of file iconwidget.cpp.

◆ IconWidget() [2/3]

IconWidget::IconWidget ( const QString &  text,
QGraphicsItem *  parent = 0 
)
explicit

Convenience constructor to create a Plasma::IconWidget with text.

Parameters
textthe text that will be displayed with this icon.
parentthe QGraphicsItem this icon is parented to.

Definition at line 358 of file iconwidget.cpp.

◆ IconWidget() [3/3]

IconWidget::IconWidget ( const QIcon &  icon,
const QString &  text,
QGraphicsItem *  parent = 0 
)

Creates a new Plasma::IconWidget with text and an icon.

Parameters
iconthe icon that will be displayed with this icon.
textthe text that will be displayed with this icon.
parentThe QGraphicsItem this icon is parented to.

Definition at line 366 of file iconwidget.cpp.

◆ ~IconWidget()

IconWidget::~IconWidget ( )
virtual

Destroys this Plasma::IconWidget.

Definition at line 375 of file iconwidget.cpp.

Member Function Documentation

◆ action()

QAction * IconWidget::action ( ) const
Returns
the currently associated action, if any.

Definition at line 463 of file iconwidget.cpp.

◆ activated

void Plasma::IconWidget::activated ( )
signal

Indicates when the icon has been activated following the single or doubleclick settings.

◆ addIconAction()

void IconWidget::addIconAction ( QAction *  action)

Plasma::IconWidget allows the user to specify a number of actions (currently four) to be displayed around the widget.

This method allows for a created QAction to be added to the Plasma::IconWidget.

Parameters
actionthe QAction to associate with this icon.

Definition at line 415 of file iconwidget.cpp.

◆ changed

void Plasma::IconWidget::changed ( )
signal

Indicates that something about the icon may have changed (image, text, etc) only actually works for icons associated with an action.

◆ changeEvent()

void IconWidget::changeEvent ( QEvent *  event)
protected

Definition at line 1629 of file iconwidget.cpp.

◆ clicked

void Plasma::IconWidget::clicked ( )
signal

Indicates when the icon has been clicked.

◆ doubleClicked

void Plasma::IconWidget::doubleClicked ( )
signal

Indicates when the icon has been double-clicked.

◆ drawActionButtonBase()

void IconWidget::drawActionButtonBase ( QPainter *  painter,
const QSize &  size,
int  element 
)

Definition at line 1242 of file iconwidget.cpp.

◆ drawBackground()

bool IconWidget::drawBackground ( ) const
Returns
true if a background area is to be drawn for the icon

Definition at line 510 of file iconwidget.cpp.

◆ hoverEnterEvent()

void IconWidget::hoverEnterEvent ( QGraphicsSceneHoverEvent *  event)
protected

Definition at line 1484 of file iconwidget.cpp.

◆ hoverLeaveEvent()

void IconWidget::hoverLeaveEvent ( QGraphicsSceneHoverEvent *  event)
protected

Definition at line 1498 of file iconwidget.cpp.

◆ icon()

QIcon IconWidget::icon ( ) const
Returns
the icon associated with this icon.

Definition at line 1309 of file iconwidget.cpp.

◆ iconSize()

QSizeF IconWidget::iconSize ( ) const
Returns
the size of this Plasma::IconWidget's graphical icon.

Definition at line 1343 of file iconwidget.cpp.

◆ infoText()

QString IconWidget::infoText ( ) const

Returns the meta text associated with this icon.

Definition at line 1304 of file iconwidget.cpp.

◆ invertedLayout()

bool IconWidget::invertedLayout ( ) const
Returns
if the layout of the icons should appear inverted or not

Definition at line 1566 of file iconwidget.cpp.

◆ invertLayout()

void IconWidget::invertLayout ( bool  invert)

inverts the layout of the icons if the orientation is horizontal, normally we get icon on the left with left-to-right languages

Parameters
invertif we want to invert the layout of icons

Definition at line 1561 of file iconwidget.cpp.

◆ isDown()

bool IconWidget::isDown ( )
protected

Definition at line 1381 of file iconwidget.cpp.

◆ maximumIconSize()

QSizeF IconWidget::maximumIconSize ( ) const
Returns
The size that should be the maximum beyond the icon shouldn't scale when the icon will be when positioned in a layout. The default is QSizeF(-1, -1); an invalid size means the icon will attempt to be at its default and "optimal" size
Since
4.5

Definition at line 1376 of file iconwidget.cpp.

◆ minimumIconSize()

QSizeF IconWidget::minimumIconSize ( ) const
Returns
The size that should be the minimum beyond the icon shouldn't scale when the icon will be when positioned in a layout. The default is QSizeF(-1, -1); an invalid size means the icon will attempt to be at its default and "optimal" size
Since
4.5

Definition at line 1365 of file iconwidget.cpp.

◆ mouseDoubleClickEvent()

void IconWidget::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *  event)
protected

Definition at line 1470 of file iconwidget.cpp.

◆ mouseMoveEvent()

void IconWidget::mouseMoveEvent ( QGraphicsSceneMouseEvent *  event)
protected

Definition at line 1413 of file iconwidget.cpp.

◆ mousePressEvent()

void IconWidget::mousePressEvent ( QGraphicsSceneMouseEvent *  event)
protected

Definition at line 1386 of file iconwidget.cpp.

◆ mouseReleaseEvent()

void IconWidget::mouseReleaseEvent ( QGraphicsSceneMouseEvent *  event)
protected

Definition at line 1433 of file iconwidget.cpp.

◆ numDisplayLines()

int Plasma::IconWidget::numDisplayLines ( )
Returns
the number of lines allowed to display

◆ orientation()

Qt::Orientation IconWidget::orientation ( ) const
Returns
the orientation of the icon

Definition at line 1556 of file iconwidget.cpp.

◆ paint()

void IconWidget::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget = 0 
)
protected

Definition at line 1136 of file iconwidget.cpp.

◆ preferredIconSize()

QSizeF IconWidget::preferredIconSize ( ) const
Returns
The size you prefer the icon will be when positioned in a layout. The default is QSizeF(-1, -1); an invalid size means the icon will attempt to be at its default and "optimal" size
Since
4.5

Definition at line 1354 of file iconwidget.cpp.

◆ pressed

void Plasma::IconWidget::pressed ( bool  down)
signal

Indicates when the icon has been pressed.

◆ removeIconAction()

void IconWidget::removeIconAction ( QAction *  action)

Removes a previously set iconAction.

The action will be removed from the widget but will not be deleted.

Parameters
theQAction to be removed, if 0 all actions will be removed

Definition at line 430 of file iconwidget.cpp.

◆ sceneEventFilter()

bool IconWidget::sceneEventFilter ( QGraphicsItem *  watched,
QEvent *  event 
)
protected

Definition at line 1514 of file iconwidget.cpp.

◆ setAction()

void IconWidget::setAction ( QAction *  action)

Associate an action with this IconWidget this makes the IconWidget follow the state of the action, using its icon, text, etc.

when the IconWidget is clicked, it will also trigger the action. Unlike addIconAction, there can be only one associated action.

Definition at line 458 of file iconwidget.cpp.

◆ setDrawBackground()

void IconWidget::setDrawBackground ( bool  draw)

Sets whether or not to draw a background area for the icon.

Parameters
drawtrue if a background should be drawn or not

Definition at line 482 of file iconwidget.cpp.

◆ setIcon() [1/2]

void IconWidget::setIcon ( const QIcon &  icon)

Sets the graphical icon for this Plasma::IconWidget.

Parameters
iconthe KIcon to associate with this icon.

Definition at line 1324 of file iconwidget.cpp.

◆ setIcon() [2/2]

void IconWidget::setIcon ( const QString &  icon)

Convenience method to set the icon of this Plasma::IconWidget using a QString path to the icon.

Parameters
iconthe path to the icon to associate with this Plasma::IconWidget.

Definition at line 1314 of file iconwidget.cpp.

◆ setInfoText()

void IconWidget::setInfoText ( const QString &  text)

Sets the additional information to be displayed by this icon.

Parameters
textadditional meta text associated with this icon.

Definition at line 1288 of file iconwidget.cpp.

◆ setMaximumIconSize()

void IconWidget::setMaximumIconSize ( const QSizeF &  size)

Set the size that should be the maximum beyond the icon shouldn't scale when the icon will be when positioned in a layout.

Parameters
preferredicon size, pass an invalid size to unset this value
Since
4.5

Definition at line 1370 of file iconwidget.cpp.

◆ setMinimumIconSize()

void IconWidget::setMinimumIconSize ( const QSizeF &  size)

Set the size that should be the minimum beyond the icon shouldn't scale when the icon will be when positioned in a layout.

Parameters
preferredicon size, pass an invalid size to unset this value
Since
4.5

Definition at line 1359 of file iconwidget.cpp.

◆ setNumDisplayLines()

void IconWidget::setNumDisplayLines ( int  numLines)
Parameters
numLinesthe number of lines to show in the display.

Definition at line 473 of file iconwidget.cpp.

◆ setOrientation()

void IconWidget::setOrientation ( Qt::Orientation  orientation)

let set the orientation of the icon Qt::Vertical: text under the icon Qt::Horizontal text at a side of the icon depending by the direction of the language

Parameters
orientationthe orientation we want

Definition at line 1550 of file iconwidget.cpp.

◆ setPreferredIconSize()

void IconWidget::setPreferredIconSize ( const QSizeF &  size)

Set the size you prefer the icon will be when positioned in a layout.

Parameters
preferredicon size, pass an invalid size to unset this value
Since
4.5

Definition at line 1348 of file iconwidget.cpp.

◆ setPressed

void IconWidget::setPressed ( bool  pressed = true)
slot

Sets the appearance of the icon to pressed or restores the appearance to normal.

This does not simulate a mouse button press.

Parameters
pressedwhether to appear as pressed (true) or as normal (false)

Definition at line 1527 of file iconwidget.cpp.

◆ setSvg()

void IconWidget::setSvg ( const QString &  svgFilePath,
const QString &  svgIconElement = QString() 
)

Convenience method to set the svg image to use when given the filepath and name of svg.

Parameters
svgFilePaththe svg filepath including name of the svg.
svgIconElementthe svg element to use when displaying the svg. Defaults to all of them.

Definition at line 634 of file iconwidget.cpp.

◆ setText()

void IconWidget::setText ( const QString &  text)

Sets the text associated with this icon.

Parameters
textthe text to associate with this icon.

Definition at line 1267 of file iconwidget.cpp.

◆ setTextBackgroundColor()

void IconWidget::setTextBackgroundColor ( const QColor &  color)

Sets the color to use behind the text of the icon.

Parameters
colorthe color, or QColor() to reset it to no background color
Since
4.3

Definition at line 1230 of file iconwidget.cpp.

◆ setUnpressed

void IconWidget::setUnpressed ( )
slot

Shortcut for setPressed(false)

Definition at line 1539 of file iconwidget.cpp.

◆ shape()

QPainterPath IconWidget::shape ( ) const

reimplemented from QGraphicsItem

Definition at line 515 of file iconwidget.cpp.

◆ sizeFromIconSize()

QSizeF IconWidget::sizeFromIconSize ( const qreal  iconWidth) const
Returns
optimal size given a size for the icon
Parameters
iconWidthdesired width of the icon

Definition at line 1571 of file iconwidget.cpp.

◆ sizeHint()

QSizeF IconWidget::sizeHint ( Qt::SizeHint  which,
const QSizeF &  constraint = QSizeF() 
) const
protected

Definition at line 681 of file iconwidget.cpp.

◆ svg()

QString IconWidget::svg ( ) const
Returns
the path to the svg file set, if any

Definition at line 668 of file iconwidget.cpp.

◆ text()

QString IconWidget::text ( ) const

Returns the text associated with this icon.

Definition at line 1283 of file iconwidget.cpp.

◆ textBackgroundColor()

QColor IconWidget::textBackgroundColor ( ) const
Returns
the color to use behind the text of the icon
Since
4.3

Definition at line 1237 of file iconwidget.cpp.

Property Documentation

◆ action

QAction * Plasma::IconWidget::action
readwrite

Definition at line 1 of file iconwidget.h.

◆ drawBackground

bool Plasma::IconWidget::drawBackground
readwrite

Definition at line 1 of file iconwidget.h.

◆ icon

QIcon Plasma::IconWidget::icon
readwrite

Definition at line 1 of file iconwidget.h.

◆ iconSize

QSizeF Plasma::IconWidget::iconSize
read

Definition at line 1 of file iconwidget.h.

◆ infoText

QString Plasma::IconWidget::infoText
readwrite

Definition at line 1 of file iconwidget.h.

◆ maximumIconSize

QSizeF Plasma::IconWidget::maximumIconSize
readwrite

Definition at line 1 of file iconwidget.h.

◆ minimumIconSize

QSizeF Plasma::IconWidget::minimumIconSize
readwrite

Definition at line 1 of file iconwidget.h.

◆ numDisplayLines

int IconWidget::numDisplayLines
readwrite

Definition at line 1 of file iconwidget.h.

◆ orientation

Qt::Orientation Plasma::IconWidget::orientation
readwrite

Definition at line 1 of file iconwidget.h.

◆ preferredIconSize

QSizeF Plasma::IconWidget::preferredIconSize
readwrite

Definition at line 1 of file iconwidget.h.

◆ svg

QString Plasma::IconWidget::svg
readwrite

Definition at line 1 of file iconwidget.h.

◆ text

QString Plasma::IconWidget::text
readwrite

Definition at line 1 of file iconwidget.h.

◆ textBackgroundColor

QColor Plasma::IconWidget::textBackgroundColor
readwrite

Definition at line 1 of file iconwidget.h.


The documentation for this class was generated from the following files:
  • iconwidget.h
  • iconwidget.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Plasma

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal