introduce koIcon

* fixes for the wrong usage of K/QIcon vs. pixmap (from incomplete Qt3->Qt4 porting):
  Q/KIcon does not have a real size, it's more kind of a factory for whatever
  pixmap size it is asked for, so just loading a certain icon pixmap and setting that
  to a KIcon/QIcon is useless, as the widget which takes the icon might request a
  different size. So e.g. passing a SmallIcon("icon-foo") to a button which takes a
  QIcon can result in badly scaled icons instead of loading the most perfect size
  match from the icon-set.
* removes lots of unneeded includes, usually kiconloader.h
* makes the API consistent for some classes, with
 "iconName" for a QString-based icon name and
 "icon" for a KIcon/QIcon type property
* use consistently "IconSize" everywhere instead of "KIconLoader::global()->currentSize"
* removes unused "KPrFactory::iconLoader()"
* adds a simple script tools/iconcheck/iconcheck.py to find iconnames without existing icons

REVIEW: 105289
parent 759213c9
/* This file is part of the Calligra project, made within the KDE community.
Copyright 2012 Friedrich W. H. Kossebau <kossebau@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KOICON_H
#define KOICON_H
// KDE
#include <KIcon>
#include <KIconLoader>
/**
* Macros to support collecting the icons in use.
*
* After any change to this list of macros the file /CheckIcons.sh needs to be
* updated accordingly, to ensure that the icon names of the affected macros are
* still considered in the extraction.
*
* The naming pattern of the macros is like this:
* * koIcon* returns a KIcon object
* * koIconName* returns a QLatin1String (aligned with usual API where "iconName" property is of type QString)
* * koIconNameCStr* returns a const char*
*/
/// Use these macros for icons without any issues
#define koIcon(name) (KIcon(QLatin1String(name)))
#define koIconName(name) (QLatin1String(name))
#define koIconNameCStr(name) (name)
#define koSmallIcon(name) (SmallIcon(QLatin1String(name)))
#define koDesktopIcon(name) (DesktopIcon(QLatin1String(name)))
/// Use these macros if there is a proper icon missing
#define koIconNeeded(comment, neededName) (KIcon(QLatin1String(neededName)))
#define koIconNeededWithSubs(comment, neededName, substituteName) (KIcon(QLatin1String(substituteName)))
#define koIconNameNeeded(comment, neededName) (QLatin1String(neededName))
#define koIconNameNeededWithSubs(comment, neededName, substituteName) (QLatin1String(substituteName))
#define koIconNameCStrNeeded(comment, neededName) (neededName)
#define koIconNameCStrNeededWithSubs(comment, neededName, substituteName) (substituteName)
/// Use these macros if the UI is okay without any icon, but would be better with one.
#define koIconWanted(comment, wantedName) (KIcon())
#endif
......@@ -21,6 +21,7 @@
#include <klocale.h>
#include "kis_debug.h"
#include <KoIcon.h>
#include "kis_selection.h"
#include "filter/kis_filter_configuration.h"
#include "kis_processing_information.h"
......@@ -109,7 +110,7 @@ void KisGeneratorLayer::accept(KisProcessingVisitor &visitor, KisUndoAdapter *un
QIcon KisGeneratorLayer::icon() const
{
return KIcon("view-filter");
return koIcon("view-filter");
}
KoDocumentSectionModel::PropertyList KisGeneratorLayer::sectionModelProperties() const
......
......@@ -22,6 +22,8 @@
#include <klocale.h>
#include "kis_debug.h"
#include <KoIcon.h>
#include "kis_image.h"
#include "kis_selection.h"
#include "filter/kis_filter_configuration.h"
......@@ -123,7 +125,7 @@ void KisAdjustmentLayer::accept(KisProcessingVisitor &visitor, KisUndoAdapter *u
QIcon KisAdjustmentLayer::icon() const
{
return KIcon("view-filter");
return koIcon("view-filter");
}
KoDocumentSectionModel::PropertyList KisAdjustmentLayer::sectionModelProperties() const
......
......@@ -19,6 +19,7 @@
#include "kis_base_node.h"
#include <klocale.h>
#include <KoIcon.h>
#include <KoProperties.h>
#include <KoColorSpace.h>
#include <KoCompositeOp.h>
......@@ -137,8 +138,8 @@ void KisBaseNode::setCompositeOp(const QString& compositeOp)
KoDocumentSectionModel::PropertyList KisBaseNode::sectionModelProperties() const
{
KoDocumentSectionModel::PropertyList l;
l << KoDocumentSectionModel::Property(i18n("Visible"), KIcon("visible"), KIcon("novisible"), visible(), m_d->hack_visible.isInStasis, m_d->hack_visible.stateInStasis);
l << KoDocumentSectionModel::Property(i18n("Locked"), KIcon("locked"), KIcon("unlocked"), userLocked());
l << KoDocumentSectionModel::Property(i18n("Visible"), koIcon("visible"), koIcon("novisible"), visible(), m_d->hack_visible.isInStasis, m_d->hack_visible.stateInStasis);
l << KoDocumentSectionModel::Property(i18n("Locked"), koIcon("locked"), koIcon("unlocked"), userLocked());
return l;
}
......
......@@ -23,8 +23,6 @@
#include <QUuid>
#include <QString>
#include <kicon.h>
#include "KoDocumentSectionModel.h"
#include "kis_shared.h"
......
......@@ -21,6 +21,8 @@
#include <kis_debug.h>
#include <klocale.h>
#include <KoIcon.h>
#include <KoColorSpace.h>
#include <KoCompositeOp.h>
......@@ -240,7 +242,7 @@ void KisCloneLayer::setCopyFromInfo(KisCloneInfo info)
QIcon KisCloneLayer::icon() const
{
return KIcon("edit-copy");
return koIcon("edit-copy");
}
KoDocumentSectionModel::PropertyList KisCloneLayer::sectionModelProperties() const
......
......@@ -19,6 +19,8 @@
#include "kis_effect_mask.h"
#include <KoIcon.h>
KisEffectMask::KisEffectMask()
: KisMask("effect")
......@@ -34,4 +36,9 @@ KisEffectMask::KisEffectMask(const KisEffectMask& rhs)
{
}
QIcon KisEffectMask::icon() const
{
return koIcon("bookmarks");
}
#include "kis_effect_mask.moc"
......@@ -19,8 +19,6 @@
#ifndef _KIS_EFFECT_MASK_
#define _KIS_EFFECT_MASK_
#include "kicon.h"
#include "kis_types.h"
#include "kis_mask.h"
/**
......@@ -46,13 +44,9 @@ public:
virtual ~KisEffectMask();
KisEffectMask(const KisEffectMask& rhs);
QIcon icon() const {
return KIcon("bookmarks");
}
QIcon icon() const;
using KisMask::apply;
};
#endif //_KIS_EFFECT_MASK_
......@@ -19,7 +19,7 @@
#ifndef KIS_EXTERNAL_LAYER_IFACE_
#define KIS_EXTERNAL_LAYER_IFACE_
#include "kicon.h"
#include "KoIcon.h"
#include "kis_types.h"
......@@ -44,7 +44,7 @@ public:
: KisLayer(image, name, opacity) {}
virtual QIcon icon() const {
return KIcon("system-run");
return koIcon("system-run");
}
virtual void resetCache() {
......
......@@ -17,6 +17,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <KoIcon.h>
#include <KoColorSpace.h>
#include <KoColorSpaceRegistry.h>
#include <KoCompositeOp.h>
......@@ -81,7 +82,7 @@ KisFilterConfiguration * KisFilterMask::filter() const
QIcon KisFilterMask::icon() const
{
return KIcon("view-filter");
return koIcon("view-filter");
}
void KisFilterMask::setFilter(KisFilterConfiguration * filterConfig)
......
......@@ -20,6 +20,7 @@
#include "kis_group_layer.h"
#include <KoIcon.h>
#include <KoCompositeOp.h>
#include <KoColorSpace.h>
......@@ -123,7 +124,7 @@ const KoColorSpace * KisGroupLayer::colorSpace() const
QIcon KisGroupLayer::icon() const
{
return KIcon("folder");
return koIcon("folder");
}
void KisGroupLayer::setImage(KisImageWSP image)
......
......@@ -21,9 +21,7 @@
#include "kis_layer.h"
#include <kicon.h>
#include <klocale.h>
#include <QIcon>
#include <QImage>
#include <QBitArray>
#include <QStack>
......
......@@ -24,6 +24,7 @@
#include <kis_debug.h>
#include <klocale.h>
#include <KoIcon.h>
#include <KoColorSpace.h>
#include <KoColorProfile.h>
#include <KoCompositeOp.h>
......@@ -154,8 +155,8 @@ KoDocumentSectionModel::PropertyList KisPaintLayer::sectionModelProperties() con
KoDocumentSectionModel::PropertyList l = KisLayer::sectionModelProperties();
// XXX: get right icons
l << KoDocumentSectionModel::Property(i18n("Alpha Channel Locked"), KIcon("transparency-locked"), KIcon("transparency-unlocked"), alphaLocked());
l << KoDocumentSectionModel::Property(i18n("Alpha Channel Disabled"), KIcon("transparency-disabled"), KIcon("transparency-enabled"), alphaChannelDisabled());
l << KoDocumentSectionModel::Property(i18n("Alpha Channel Locked"), koIcon("transparency-locked"), koIcon("transparency-unlocked"), alphaLocked());
l << KoDocumentSectionModel::Property(i18n("Alpha Channel Disabled"), koIcon("transparency-disabled"), koIcon("transparency-enabled"), alphaChannelDisabled());
return l;
}
......
......@@ -21,8 +21,6 @@
#include <QRect>
#include <QPainterPath>
#include <kicon.h>
#include "kis_types.h"
#include "kis_paint_device.h"
#include "kis_selection_component.h"
......
......@@ -30,6 +30,7 @@
#include "kis_processing_visitor.h"
#include "kis_pixel_selection.h"
#include "kis_undo_adapter.h"
#include <KoIcon.h>
struct KisSelectionMask::Private
{
......@@ -58,6 +59,10 @@ KisSelectionMask::~KisSelectionMask()
delete m_d;
}
QIcon KisSelectionMask::icon() const {
return koIcon("edit-paste");
}
bool KisSelectionMask::allowAsChild(KisNodeSP node) const
{
Q_UNUSED(node);
......@@ -98,7 +103,7 @@ void KisSelectionMask::accept(KisProcessingVisitor &visitor, KisUndoAdapter *und
KoDocumentSectionModel::PropertyList KisSelectionMask::sectionModelProperties() const
{
KoDocumentSectionModel::PropertyList l = KisBaseNode::sectionModelProperties();
l << KoDocumentSectionModel::Property(i18n("Active"), KIcon("local_selection_active"),KIcon("local_selection_inactive"),active());
l << KoDocumentSectionModel::Property(i18n("Active"), koIcon("local_selection_active"), koIcon("local_selection_inactive"), active());
return l;
}
......
......@@ -19,7 +19,6 @@
#define _KIS_SELECTION_MASK_
#include <QRect>
#include "kicon.h"
#include "KoDocumentSectionModel.h"
#include <KoProperties.h>
......@@ -48,9 +47,7 @@ public:
bool allowAsChild(KisNodeSP) const;
QIcon icon() const {
return KIcon("edit-paste");
}
QIcon icon() const;
KisNodeSP clone() const {
return KisNodeSP(new KisSelectionMask(*this));
......
......@@ -20,6 +20,7 @@
#include "kis_debug.h"
#include <KoIcon.h>
#include <KoColor.h>
#include <KoColorSpace.h>
#include <KoCompositeOp.h>
......@@ -93,7 +94,7 @@ QRect KisTransparencyMask::needRect(const QRect &rect, PositionToFilthy pos) con
QIcon KisTransparencyMask::icon() const
{
return KIcon("view-filter");
return koIcon("view-filter");
}
bool KisTransparencyMask::accept(KisNodeVisitor &v)
......
......@@ -30,6 +30,8 @@
#include <kio/netaccess.h>
#include <kio/jobuidelegate.h>
#include <KoIcon.h>
#include <KoViewConverter.h>
#include <KoPointerEvent.h>
......@@ -273,8 +275,8 @@ void KisRulerAssistantTool::paint(QPainter& _gc, const KoViewConverter &_convert
KisPaintingAssistant::drawPath(_gc, path);
}
QPixmap iconDelete = KIcon("edit-delete").pixmap(16, 16);
QPixmap iconMove = KIcon("transform-move").pixmap(32, 32);
QPixmap iconDelete = koIcon("edit-delete").pixmap(16, 16);
QPixmap iconMove = koIcon("transform-move").pixmap(32, 32);
foreach(const KisPaintingAssistant* assistant, m_canvas->view()->paintingAssistantManager()->assistants()) {
QPointF iconDeletePos = _converter.documentToView(assistant->buttonPosition());
_gc.drawPixmap(iconDeletePos - QPointF(32, 32), iconDelete);
......@@ -442,9 +444,9 @@ QWidget *KisRulerAssistantTool::createOptionWidget()
if (!m_optionsWidget) {
m_optionsWidget = new QWidget;
m_options.setupUi(m_optionsWidget);
m_options.loadButton->setIcon(KIcon("document-open"));
m_options.saveButton->setIcon(KIcon("document-save"));
m_options.deleteButton->setIcon(KIcon("edit-delete"));
m_options.loadButton->setIcon(koIcon("document-open"));
m_options.saveButton->setIcon(koIcon("document-save"));
m_options.deleteButton->setIcon(koIcon("edit-delete"));
foreach(const QString& key, KisPaintingAssistantFactoryRegistry::instance()->keys()) {
QString name = KisPaintingAssistantFactoryRegistry::instance()->get(key)->name();
m_options.comboBox->addItem(name, key);
......
......@@ -22,6 +22,8 @@
#include <KoToolFactoryBase.h>
#include "kis_painting_assistant.h"
#include "ui_AssistantsToolOptions.h"
#include <KoIcon.h>
class RulerDecoration;
class KisCanvas2;
......@@ -81,7 +83,7 @@ public:
: KoToolFactoryBase("KisRulerAssistantTool") {
setToolTip(i18n("Ruler assistant editor tool"));
setToolType(TOOL_TYPE_VIEW);
setIcon("krita_tool_ruler_assistant");
setIconName(koIconNameCStr("krita_tool_ruler_assistant"));
setPriority(0);
setActivationShapeId(KRITA_TOOL_ACTIVATION_ID);
};
......
......@@ -26,19 +26,23 @@
#include <recorder/kis_macro.h>
#include <recorder/kis_recorded_action_editor_factory_registry.h>
#include <recorder/kis_recorded_action_creator_factory_registry.h>
#include <QMenu>
#include <QSignalMapper>
#include <recorder/kis_recorded_action_creator_factory.h>
#include <recorder/kis_recorded_action_creator.h>
#include <KoIcon.h>
#include <KMessageBox>
#include <QMenu>
#include <QSignalMapper>
KisActionsEditor::KisActionsEditor(QWidget* parent) : QWidget(parent), m_currentEditor(0), m_form(new Ui::ActionsEditor), m_macro(0), m_model(0), m_widgetLayout(0)
{
m_form->setupUi(this);
// Setup buttons
m_form->bnAdd->setIcon(SmallIcon("list-add"));
m_form->bnAdd->setIcon(koIcon("list-add"));
QSignalMapper* mapper = new QSignalMapper(this);
connect(mapper, SIGNAL(mapped(QString)), SLOT(slotCreateAction(QString)));
QMenu* addMenu = new QMenu;
......@@ -50,16 +54,16 @@ KisActionsEditor::KisActionsEditor(QWidget* parent) : QWidget(parent), m_current
m_form->bnAdd->setMenu(addMenu);
m_form->bnDelete->setIcon(SmallIcon("list-remove"));
m_form->bnDelete->setIcon(koIcon("list-remove"));
connect(m_form->bnDelete, SIGNAL(released()), SLOT(slotBtnDelete()));
m_form->bnRaise->setIcon(SmallIcon("go-up"));
m_form->bnRaise->setIcon(koIcon("go-up"));
connect(m_form->bnRaise, SIGNAL(released()), SLOT(slotBtnRaise()));
m_form->bnLower->setIcon(SmallIcon("go-down"));
m_form->bnLower->setIcon(koIcon("go-down"));
connect(m_form->bnLower, SIGNAL(released()), SLOT(slotBtnLower()));
m_form->bnDuplicate->setIcon(SmallIcon("edit-copy"));
m_form->bnDuplicate->setIcon(koIcon("edit-copy"));
connect(m_form->bnDuplicate, SIGNAL(released()), SLOT(slotBtnDuplicate()));
// Setup actions list
......
......@@ -27,6 +27,7 @@
#include <klocale.h>
#include <kstandarddirs.h>
#include <KoIcon.h>
#include <KoUpdater.h>
#include <recorder/kis_action_recorder.h>
......@@ -82,11 +83,11 @@ BigBrotherPlugin::BigBrotherPlugin(QObject *parent, const QVariantList &)
KAction* action = 0;
// Open and play action
action = new KAction(KIcon("media-playback-start"), i18n("Open and play..."), this);
action = new KAction(koIcon("media-playback-start"), i18n("Open and play..."), this);
actionCollection()->addAction("Macro_Open_Play", action);
connect(action, SIGNAL(triggered()), this, SLOT(slotOpenPlay()));
// Open and edit action
action = new KAction(KIcon("document-edit"), i18n("Open and edit..."), this);
action = new KAction(koIcon("document-edit"), i18n("Open and edit..."), this);
actionCollection()->addAction("Macro_Open_Edit", action);
connect(action, SIGNAL(triggered()), this, SLOT(slotOpenEdit()));
// Save recorded action
......@@ -94,11 +95,11 @@ BigBrotherPlugin::BigBrotherPlugin(QObject *parent, const QVariantList &)
actionCollection()->addAction("Recording_Global_Save", action);
connect(action, SIGNAL(triggered()), this, SLOT(slotSave()));
// Start recording action
m_startRecordingMacroAction = new KAction(KIcon("media-record"), i18n("Start recording macro"), this);
m_startRecordingMacroAction = new KAction(koIcon("media-record"), i18n("Start recording macro"), this);
actionCollection()->addAction("Recording_Start_Recording_Macro", m_startRecordingMacroAction);
connect(m_startRecordingMacroAction, SIGNAL(triggered()), this, SLOT(slotStartRecordingMacro()));
// Save recorded action
m_stopRecordingMacroAction = new KAction(KIcon("media-playback-stop"), i18n("Stop recording actions"), this);
m_stopRecordingMacroAction = new KAction(koIcon("media-playback-stop"), i18n("Stop recording actions"), this);
actionCollection()->addAction("Recording_Stop_Recording_Macro", m_stopRecordingMacroAction);
connect(m_stopRecordingMacroAction, SIGNAL(triggered()), this, SLOT(slotStopRecordingMacro()));
m_stopRecordingMacroAction->setEnabled(false);
......
......@@ -29,7 +29,6 @@
#include <QPoint>
#include <klocale.h>
#include <kiconloader.h>
#include <kcomponentdata.h>
#include <kmessagebox.h>
#include <kstandarddirs.h>
......
......@@ -29,7 +29,6 @@
#include <QCursor>
#include <klocale.h>
#include <kiconloader.h>
#include <kcomponentdata.h>
#include <kmessagebox.h>
#include <kstandarddirs.h>
......
......@@ -18,7 +18,6 @@
#include "kis_layer_compose_plugin.h"
#include <klocale.h>
#include <kiconloader.h>
#include <kcomponentdata.h>
#include <kmessagebox.h>
#include <kstandarddirs.h>
......
......@@ -30,10 +30,10 @@
#include <KConfigGroup>
#include <KComponentData>
#include <KGlobal>
#include <KIcon>
#include <KDebug>
#include <KoCanvasResourceManager.h>
#include <KoIcon.h>
#include "kis_color_selector_ring.h"
#include "kis_color_selector_triangle.h"
......@@ -311,7 +311,7 @@ void KisColorSelector::init()
if(displaySettingsButton()) {
m_button = new QPushButton(this);
m_button->setIcon(KIcon("configure"));
m_button->setIcon(koIcon("configure"));
connect(m_button, SIGNAL(clicked()), SIGNAL(settingsButtonClicked()));
}
......
......@@ -24,7 +24,6 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <KIcon>
#include <KConfig>
#include <KConfigGroup>
......
......@@ -24,8 +24,8 @@
#include <QPushButton>
#include <KConfigGroup>
#include <KIcon>
#include <KoIcon.h>
#include "KoColorSpace.h"
#include "KoColorSpaceRegistry.h"
#include "KoColorProfile.h"
......@@ -92,7 +92,7 @@ QString KisColorSelectorSettings::header()
KIcon KisColorSelectorSettings::icon()
{
return KIcon("extended_color_selector");
return koIcon("extended_color_selector");
}
......
......@@ -29,6 +29,7 @@
#include <KComponentData>
#include <KGlobal>
#include <KoIcon.h>
#include "KoColor.h"
#include "KoColorSpaceRegistry.h"
#include "kis_canvas2.h"
......@@ -42,9 +43,9 @@ KisCommonColors::KisCommonColors(QWidget *parent) :
KisColorPatches("commonColors", parent)
{
m_reloadButton = new QPushButton();
m_reloadButton->setIcon(KIcon("view-refresh"));
m_reloadButton->setIcon(koIcon("view-refresh"));
connect(m_reloadButton, SIGNAL(clicked()), this, SLOT(recalculate()));
QList<QWidget*> tmpList;
tmpList.append(m_reloadButton);
setAdditionalButtons(tmpList);
......
......@@ -29,6 +29,8 @@
#include <klocale.h>
#include <KActionCollection>
#include <KoIcon.h>
#include <KoCanvasBase.h>
#include <kis_view2.h>
#include <kis_canvas2.h>
......@@ -40,8 +42,8 @@ CompositionDockerDock::CompositionDockerDock( ) : QDockWidget(i18n("Compositions
setupUi(widget);
m_model = new CompositionModel(this);
compositionView->setModel(m_model);
deleteButton->setIcon(KIcon("edit-delete"));
saveButton->setIcon(KIcon("document-save"));
deleteButton->setIcon(koIcon("edit-delete"));
saveButton->setIcon(koIcon("document-save"));
setWidget(widget);
......
......@@ -17,9 +17,10 @@
#include "compositionmodel.h"
#include <KoIcon.h>