ImageViewer: Pick up the icons from the system theme using QIcon::fromTheme

Merge-request: 2165
Reviewed-by: Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
This commit is contained in:
Denis Mingulov
2010-06-18 11:02:48 +02:00
committed by Thorbjørn Lindeijer
parent aa7d2c54d3
commit b2fabac69e
2 changed files with 36 additions and 0 deletions

View File

@@ -36,6 +36,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/uniqueidmanager.h>
#include <utils/qtcassert.h>
#include <QtCore/QMap>
#include <QtCore/QFileInfo>
@@ -69,6 +70,17 @@ ImageViewer::ImageViewer(QWidget *parent)
d_ptr->toolbar = new QWidget();
d_ptr->ui_toolbar.setupUi(d_ptr->toolbar);
// icons update - try to use system theme
updateButtonIconByTheme(d_ptr->ui_toolbar.toolButtonZoomIn, "zoom-in");
updateButtonIconByTheme(d_ptr->ui_toolbar.toolButtonZoomOut, "zoom-out");
updateButtonIconByTheme(d_ptr->ui_toolbar.toolButtonOriginalSize, "zoom-original");
updateButtonIconByTheme(d_ptr->ui_toolbar.toolButtonFitToScreen, "zoom-fit-best");
// a display - something is on the background
updateButtonIconByTheme(d_ptr->ui_toolbar.toolButtonBackground, "video-display");
// "emblem to specify the directory where the user stores photographs"
// (photograph has outline - piece of paper)
updateButtonIconByTheme(d_ptr->ui_toolbar.toolButtonOutline, "emblem-photos");
// connections
connect(d_ptr->file, SIGNAL(changed()), this, SIGNAL(changed()));
@@ -190,5 +202,18 @@ void ImageViewer::scaleFactorUpdate(qreal factor)
d_ptr->ui_toolbar.labelInfo->setText(info);
}
bool ImageViewer::updateButtonIconByTheme(QAbstractButton *button, const QString &name)
{
QTC_ASSERT(button, return false);
QTC_ASSERT(!name.isEmpty(), return false);
if (QIcon::hasThemeIcon(name)) {
button->setIcon(QIcon::fromTheme(name));
return true;
}
return false;
}
} // namespace Internal
} // namespace ImageViewer