summaryrefslogtreecommitdiffstats
path: root/examples/widgets/tools
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-06-07 19:10:53 +0200
committerLiang Qi <liang.qi@qt.io>2018-06-07 19:10:53 +0200
commit096e37910d93f9c52976600e985c615ea36fe291 (patch)
tree713d020f4a04f03d8ca6e111055e7eebe85953a8 /examples/widgets/tools
parent88eda007a3b5046999dd0b287634765efcd8934d (diff)
parenta14a943f9ac3d1e85514d7fb6688c84e624ac850 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Conflicts: .qmake.conf src/corelib/kernel/qeventdispatcher_cf.mm src/gui/kernel/qguiapplication_p.h src/gui/kernel/qwindowsysteminterface.cpp src/gui/kernel/qwindowsysteminterface.h src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/cocoa/qnswindowdelegate.mm src/plugins/platforms/ios/qioseventdispatcher.mm src/plugins/platforms/windows/qwindowsdrag.h src/plugins/platforms/windows/qwindowsinternalmimedata.h src/plugins/platforms/windows/qwindowsmime.cpp src/plugins/platforms/winrt/qwinrtscreen.cpp Change-Id: Ic817f265c2386e83839d2bb9ef7419cb29705246
Diffstat (limited to 'examples/widgets/tools')
-rw-r--r--examples/widgets/tools/plugandpaint/app/main.cpp3
-rw-r--r--examples/widgets/tools/plugandpaint/app/mainwindow.cpp83
-rw-r--r--examples/widgets/tools/plugandpaint/app/mainwindow.h36
-rw-r--r--examples/widgets/tools/plugandpaint/app/paintarea.cpp9
-rw-r--r--examples/widgets/tools/plugandpaint/app/paintarea.h12
-rw-r--r--examples/widgets/tools/plugandpaint/app/plugindialog.cpp31
-rw-r--r--examples/widgets/tools/plugandpaint/app/plugindialog.h8
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp16
-rw-r--r--examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp24
9 files changed, 108 insertions, 114 deletions
diff --git a/examples/widgets/tools/plugandpaint/app/main.cpp b/examples/widgets/tools/plugandpaint/app/main.cpp
index f157957da5..f50fd86b97 100644
--- a/examples/widgets/tools/plugandpaint/app/main.cpp
+++ b/examples/widgets/tools/plugandpaint/app/main.cpp
@@ -50,8 +50,9 @@
//! [0]
#include "mainwindow.h"
-#include <QtPlugin>
+
#include <QApplication>
+#include <QtPlugin>
Q_IMPORT_PLUGIN(BasicToolsPlugin)
diff --git a/examples/widgets/tools/plugandpaint/app/mainwindow.cpp b/examples/widgets/tools/plugandpaint/app/mainwindow.cpp
index 12c65e9364..ebe1150eea 100644
--- a/examples/widgets/tools/plugandpaint/app/mainwindow.cpp
+++ b/examples/widgets/tools/plugandpaint/app/mainwindow.cpp
@@ -54,19 +54,18 @@
#include "paintarea.h"
#include "plugindialog.h"
-#include <QPluginLoader>
-#include <QTimer>
-
-#include <QScrollArea>
-#include <QMessageBox>
-#include <QActionGroup>
#include <QAction>
-#include <QMenu>
-#include <QMenuBar>
-#include <QFileDialog>
+#include <QActionGroup>
+#include <QApplication>
#include <QColorDialog>
+#include <QFileDialog>
#include <QInputDialog>
-#include <QApplication>
+#include <QMenu>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QPluginLoader>
+#include <QScrollArea>
+#include <QTimer>
MainWindow::MainWindow() :
paintArea(new PaintArea),
@@ -85,7 +84,7 @@ MainWindow::MainWindow() :
if (!brushActionGroup->actions().isEmpty())
brushActionGroup->actions().first()->trigger();
- QTimer::singleShot(500, this, SLOT(aboutPlugins()));
+ QTimer::singleShot(500, this, &MainWindow::aboutPlugins);
}
void MainWindow::open()
@@ -109,11 +108,10 @@ bool MainWindow::saveAs()
const QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"),
initialPath);
- if (fileName.isEmpty()) {
+ if (fileName.isEmpty())
return false;
- } else {
- return paintArea->saveImage(fileName, "png");
- }
+
+ return paintArea->saveImage(fileName, "png");
}
void MainWindow::brushColor()
@@ -137,8 +135,8 @@ void MainWindow::brushWidth()
//! [0]
void MainWindow::changeBrush()
{
- QAction *action = qobject_cast<QAction *>(sender());
- BrushInterface *iBrush = qobject_cast<BrushInterface *>(action->parent());
+ auto action = qobject_cast<QAction *>(sender());
+ auto iBrush = qobject_cast<BrushInterface *>(action->parent());
const QString brush = action->text();
paintArea->setBrush(iBrush, brush);
@@ -148,8 +146,8 @@ void MainWindow::changeBrush()
//! [1]
void MainWindow::insertShape()
{
- QAction *action = qobject_cast<QAction *>(sender());
- ShapeInterface *iShape = qobject_cast<ShapeInterface *>(action->parent());
+ auto action = qobject_cast<QAction *>(sender());
+ auto iShape = qobject_cast<ShapeInterface *>(action->parent());
const QPainterPath path = iShape->generateShape(action->text(), this);
if (!path.isEmpty())
@@ -160,9 +158,8 @@ void MainWindow::insertShape()
//! [2]
void MainWindow::applyFilter()
{
- QAction *action = qobject_cast<QAction *>(sender());
- FilterInterface *iFilter =
- qobject_cast<FilterInterface *>(action->parent());
+ auto action = qobject_cast<QAction *>(sender());
+ auto iFilter = qobject_cast<FilterInterface *>(action->parent());
const QImage image = iFilter->filterImage(action->text(), paintArea->image(),
this);
@@ -189,32 +186,32 @@ void MainWindow::createActions()
{
openAct = new QAction(tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open);
- connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
+ connect(openAct, &QAction::triggered, this, &MainWindow::open);
saveAsAct = new QAction(tr("&Save As..."), this);
saveAsAct->setShortcuts(QKeySequence::SaveAs);
- connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
+ connect(saveAsAct, &QAction::triggered, this, &MainWindow::saveAs);
exitAct = new QAction(tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit);
- connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
+ connect(exitAct, &QAction::triggered, this, &MainWindow::close);
brushColorAct = new QAction(tr("&Brush Color..."), this);
- connect(brushColorAct, SIGNAL(triggered()), this, SLOT(brushColor()));
+ connect(brushColorAct, &QAction::triggered, this, &MainWindow::brushColor);
brushWidthAct = new QAction(tr("&Brush Width..."), this);
- connect(brushWidthAct, SIGNAL(triggered()), this, SLOT(brushWidth()));
+ connect(brushWidthAct, &QAction::triggered, this, &MainWindow::brushWidth);
brushActionGroup = new QActionGroup(this);
aboutAct = new QAction(tr("&About"), this);
- connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
+ connect(aboutAct, &QAction::triggered, this, &MainWindow::about);
aboutQtAct = new QAction(tr("About &Qt"), this);
- connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+ connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt);
aboutPluginsAct = new QAction(tr("About &Plugins"), this);
- connect(aboutPluginsAct, SIGNAL(triggered()), this, SLOT(aboutPlugins()));
+ connect(aboutPluginsAct, &QAction::triggered, this, &MainWindow::aboutPlugins);
}
void MainWindow::createMenus()
@@ -245,7 +242,8 @@ void MainWindow::createMenus()
//! [4]
void MainWindow::loadPlugins()
{
- foreach (QObject *plugin, QPluginLoader::staticInstances())
+ const auto staticInstances = QPluginLoader::staticInstances();
+ for (QObject *plugin : staticInstances)
populateMenus(plugin);
//! [4] //! [5]
@@ -265,7 +263,8 @@ void MainWindow::loadPlugins()
//! [5]
//! [6]
- foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
+ const auto entryList = pluginsDir.entryList(QDir::Files);
+ for (const QString &fileName : entryList) {
QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
QObject *plugin = loader.instance();
if (plugin) {
@@ -287,28 +286,28 @@ void MainWindow::loadPlugins()
//! [10]
void MainWindow::populateMenus(QObject *plugin)
{
- BrushInterface *iBrush = qobject_cast<BrushInterface *>(plugin);
+ auto iBrush = qobject_cast<BrushInterface *>(plugin);
if (iBrush)
- addToMenu(plugin, iBrush->brushes(), brushMenu, SLOT(changeBrush()),
+ addToMenu(plugin, iBrush->brushes(), brushMenu, &MainWindow::changeBrush,
brushActionGroup);
- ShapeInterface *iShape = qobject_cast<ShapeInterface *>(plugin);
+ auto iShape = qobject_cast<ShapeInterface *>(plugin);
if (iShape)
- addToMenu(plugin, iShape->shapes(), shapesMenu, SLOT(insertShape()));
+ addToMenu(plugin, iShape->shapes(), shapesMenu, &MainWindow::insertShape);
- FilterInterface *iFilter = qobject_cast<FilterInterface *>(plugin);
+ auto iFilter = qobject_cast<FilterInterface *>(plugin);
if (iFilter)
- addToMenu(plugin, iFilter->filters(), filterMenu, SLOT(applyFilter()));
+ addToMenu(plugin, iFilter->filters(), filterMenu, &MainWindow::applyFilter);
}
//! [10]
void MainWindow::addToMenu(QObject *plugin, const QStringList &texts,
- QMenu *menu, const char *member,
+ QMenu *menu, Member member,
QActionGroup *actionGroup)
{
- foreach (QString text, texts) {
- QAction *action = new QAction(text, plugin);
- connect(action, SIGNAL(triggered()), this, member);
+ for (const QString &text : texts) {
+ auto action = new QAction(text, plugin);
+ connect(action, &QAction::triggered, this, member);
menu->addAction(action);
if (actionGroup) {
diff --git a/examples/widgets/tools/plugandpaint/app/mainwindow.h b/examples/widgets/tools/plugandpaint/app/mainwindow.h
index 398759fecf..2b54264893 100644
--- a/examples/widgets/tools/plugandpaint/app/mainwindow.h
+++ b/examples/widgets/tools/plugandpaint/app/mainwindow.h
@@ -82,32 +82,34 @@ private slots:
void aboutPlugins();
private:
+ typedef void (MainWindow::*Member)();
+
void createActions();
void createMenus();
void loadPlugins();
void populateMenus(QObject *plugin);
void addToMenu(QObject *plugin, const QStringList &texts, QMenu *menu,
- const char *member, QActionGroup *actionGroup = 0);
+ Member member, QActionGroup *actionGroup = nullptr);
- PaintArea *paintArea;
- QScrollArea *scrollArea;
+ PaintArea *paintArea = nullptr;
+ QScrollArea *scrollArea = nullptr;
QDir pluginsDir;
QStringList pluginFileNames;
- QMenu *fileMenu;
- QMenu *brushMenu;
- QMenu *shapesMenu;
- QMenu *filterMenu;
- QMenu *helpMenu;
- QActionGroup *brushActionGroup;
- QAction *openAct;
- QAction *saveAsAct;
- QAction *exitAct;
- QAction *brushWidthAct;
- QAction *brushColorAct;
- QAction *aboutAct;
- QAction *aboutQtAct;
- QAction *aboutPluginsAct;
+ QMenu *fileMenu = nullptr;
+ QMenu *brushMenu = nullptr;
+ QMenu *shapesMenu = nullptr;
+ QMenu *filterMenu = nullptr;
+ QMenu *helpMenu = nullptr;
+ QActionGroup *brushActionGroup = nullptr;
+ QAction *openAct = nullptr;
+ QAction *saveAsAct = nullptr;
+ QAction *exitAct = nullptr;
+ QAction *brushWidthAct = nullptr;
+ QAction *brushColorAct = nullptr;
+ QAction *aboutAct = nullptr;
+ QAction *aboutQtAct = nullptr;
+ QAction *aboutPluginsAct = nullptr;
};
#endif
diff --git a/examples/widgets/tools/plugandpaint/app/paintarea.cpp b/examples/widgets/tools/plugandpaint/app/paintarea.cpp
index 5d2170bfd4..4295e04cc0 100644
--- a/examples/widgets/tools/plugandpaint/app/paintarea.cpp
+++ b/examples/widgets/tools/plugandpaint/app/paintarea.cpp
@@ -52,16 +52,11 @@
#include "interfaces.h"
#include "paintarea.h"
-#include <QPainter>
#include <QMouseEvent>
+#include <QPainter>
PaintArea::PaintArea(QWidget *parent) :
- QWidget(parent),
- theImage(500, 400, QImage::Format_RGB32),
- color(Qt::blue),
- thickness(3),
- brushInterface(0),
- lastPos(-1, -1)
+ QWidget(parent)
{
setAttribute(Qt::WA_StaticContents);
setAttribute(Qt::WA_NoBackground);
diff --git a/examples/widgets/tools/plugandpaint/app/paintarea.h b/examples/widgets/tools/plugandpaint/app/paintarea.h
index 1c8ee1ee1b..1d1e6006c8 100644
--- a/examples/widgets/tools/plugandpaint/app/paintarea.h
+++ b/examples/widgets/tools/plugandpaint/app/paintarea.h
@@ -63,7 +63,7 @@ class PaintArea : public QWidget
Q_OBJECT
public:
- PaintArea(QWidget *parent = 0);
+ PaintArea(QWidget *parent = nullptr);
bool openImage(const QString &fileName);
bool saveImage(const QString &fileName, const char *fileFormat);
@@ -87,13 +87,13 @@ protected:
private:
void setupPainter(QPainter &painter);
- QImage theImage;
- QColor color;
- int thickness;
+ QImage theImage = {500, 400, QImage::Format_RGB32};
+ QColor color = Qt::blue;
+ int thickness = 3;
- BrushInterface *brushInterface;
+ BrushInterface *brushInterface = nullptr;
QString brush;
- QPoint lastPos;
+ QPoint lastPos = {-1, -1};
QPainterPath pendingPath;
};
diff --git a/examples/widgets/tools/plugandpaint/app/plugindialog.cpp b/examples/widgets/tools/plugandpaint/app/plugindialog.cpp
index 00c2498bd5..af5828f67e 100644
--- a/examples/widgets/tools/plugandpaint/app/plugindialog.cpp
+++ b/examples/widgets/tools/plugandpaint/app/plugindialog.cpp
@@ -52,16 +52,15 @@
#include "interfaces.h"
#include "plugindialog.h"
-#include <QPluginLoader>
-#include <QStringList>
#include <QDir>
-
-#include <QLabel>
#include <QGridLayout>
+#include <QHeaderView>
+#include <QLabel>
+#include <QPluginLoader>
#include <QPushButton>
+#include <QStringList>
#include <QTreeWidget>
#include <QTreeWidgetItem>
-#include <QHeaderView>
PluginDialog::PluginDialog(const QString &path, const QStringList &fileNames,
QWidget *parent) :
@@ -77,7 +76,7 @@ PluginDialog::PluginDialog(const QString &path, const QStringList &fileNames,
okButton->setDefault(true);
- connect(okButton, SIGNAL(clicked()), this, SLOT(close()));
+ connect(okButton, &QAbstractButton::clicked, this, &QWidget::close);
QGridLayout *mainLayout = new QGridLayout;
mainLayout->setColumnStretch(0, 1);
@@ -107,11 +106,12 @@ void PluginDialog::findPlugins(const QString &path,
const QDir dir(path);
- foreach (QObject *plugin, QPluginLoader::staticInstances())
+ const auto staticInstances = QPluginLoader::staticInstances();
+ for (QObject *plugin : staticInstances)
populateTreeWidget(plugin, tr("%1 (Static Plugin)")
.arg(plugin->metaObject()->className()));
- foreach (QString fileName, fileNames) {
+ for (const QString &fileName : fileNames) {
QPluginLoader loader(dir.absoluteFilePath(fileName));
QObject *plugin = loader.instance();
if (plugin)
@@ -123,7 +123,7 @@ void PluginDialog::findPlugins(const QString &path,
//! [1]
void PluginDialog::populateTreeWidget(QObject *plugin, const QString &text)
{
- QTreeWidgetItem *pluginItem = new QTreeWidgetItem(treeWidget);
+ auto pluginItem = new QTreeWidgetItem(treeWidget);
pluginItem->setText(0, text);
treeWidget->setItemExpanded(pluginItem, true);
@@ -132,16 +132,15 @@ void PluginDialog::populateTreeWidget(QObject *plugin, const QString &text)
pluginItem->setFont(0, boldFont);
if (plugin) {
- BrushInterface *iBrush = qobject_cast<BrushInterface *>(plugin);
+ auto iBrush = qobject_cast<BrushInterface *>(plugin);
if (iBrush)
addItems(pluginItem, "BrushInterface", iBrush->brushes());
- ShapeInterface *iShape = qobject_cast<ShapeInterface *>(plugin);
+ auto iShape = qobject_cast<ShapeInterface *>(plugin);
if (iShape)
addItems(pluginItem, "ShapeInterface", iShape->shapes());
- FilterInterface *iFilter =
- qobject_cast<FilterInterface *>(plugin);
+ auto iFilter = qobject_cast<FilterInterface *>(plugin);
if (iFilter)
addItems(pluginItem, "FilterInterface", iFilter->filters());
}
@@ -152,14 +151,14 @@ void PluginDialog::addItems(QTreeWidgetItem *pluginItem,
const char *interfaceName,
const QStringList &features)
{
- QTreeWidgetItem *interfaceItem = new QTreeWidgetItem(pluginItem);
+ auto interfaceItem = new QTreeWidgetItem(pluginItem);
interfaceItem->setText(0, interfaceName);
interfaceItem->setIcon(0, interfaceIcon);
- foreach (QString feature, features) {
+ for (QString feature : features) {
if (feature.endsWith("..."))
feature.chop(3);
- QTreeWidgetItem *featureItem = new QTreeWidgetItem(interfaceItem);
+ auto featureItem = new QTreeWidgetItem(interfaceItem);
featureItem->setText(0, feature);
featureItem->setIcon(0, featureIcon);
}
diff --git a/examples/widgets/tools/plugandpaint/app/plugindialog.h b/examples/widgets/tools/plugandpaint/app/plugindialog.h
index f8e5bcda24..b18b30e62c 100644
--- a/examples/widgets/tools/plugandpaint/app/plugindialog.h
+++ b/examples/widgets/tools/plugandpaint/app/plugindialog.h
@@ -68,7 +68,7 @@ class PluginDialog : public QDialog
public:
PluginDialog(const QString &path, const QStringList &fileNames,
- QWidget *parent = 0);
+ QWidget *parent = nullptr);
private:
void findPlugins(const QString &path, const QStringList &fileNames);
@@ -76,9 +76,9 @@ private:
void addItems(QTreeWidgetItem *pluginItem, const char *interfaceName,
const QStringList &features);
- QLabel *label;
- QTreeWidget *treeWidget;
- QPushButton *okButton;
+ QLabel *label = nullptr;
+ QTreeWidget *treeWidget = nullptr;
+ QPushButton *okButton = nullptr;
QIcon interfaceIcon;
QIcon featureIcon;
};
diff --git a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp b/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp
index 92620ddd8c..3b465565ba 100644
--- a/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp
+++ b/examples/widgets/tools/plugandpaint/plugins/basictools/basictoolsplugin.cpp
@@ -48,18 +48,17 @@
**
****************************************************************************/
+#include "basictoolsplugin.h"
+
+#include <QtMath>
#include <QtWidgets>
-#include <qmath.h>
#include <stdlib.h>
-#include "basictoolsplugin.h"
-
//! [0]
QStringList BasicToolsPlugin::brushes() const
{
- return QStringList() << tr("Pencil") << tr("Air Brush")
- << tr("Random Letters");
+ return {tr("Pencil"), tr("Air Brush"), tr("Random Letters")};
}
//! [0]
@@ -132,7 +131,7 @@ QRect BasicToolsPlugin::mouseRelease(const QString & /* brush */,
//! [5]
QStringList BasicToolsPlugin::shapes() const
{
- return QStringList() << tr("Circle") << tr("Star") << tr("Text...");
+ return {tr("Circle"), tr("Star"), tr("Text...")};
}
//! [5]
@@ -169,8 +168,7 @@ QPainterPath BasicToolsPlugin::generateShape(const QString &shape,
//! [7]
QStringList BasicToolsPlugin::filters() const
{
- return QStringList() << tr("Invert Pixels") << tr("Swap RGB")
- << tr("Grayscale");
+ return {tr("Invert Pixels"), tr("Swap RGB"), tr("Grayscale")};
}
//! [7]
@@ -187,7 +185,7 @@ QImage BasicToolsPlugin::filterImage(const QString &filter, const QImage &image,
} else if (filter == tr("Grayscale")) {
for (int y = 0; y < result.height(); ++y) {
for (int x = 0; x < result.width(); ++x) {
- int pixel = result.pixel(x, y);
+ QRgb pixel = result.pixel(x, y);
int gray = qGray(pixel);
int alpha = qAlpha(pixel);
result.setPixel(x, y, qRgba(gray, gray, gray, alpha));
diff --git a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp b/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp
index 8f59afa759..48717e34f6 100644
--- a/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp
+++ b/examples/widgets/tools/plugandpaint/plugins/extrafilters/extrafiltersplugin.cpp
@@ -48,17 +48,17 @@
**
****************************************************************************/
+#include "extrafiltersplugin.h"
+
#include <QtWidgets>
#include <math.h>
#include <stdlib.h>
-#include "extrafiltersplugin.h"
-
QStringList ExtraFiltersPlugin::filters() const
{
- return QStringList() << tr("Flip Horizontally") << tr("Flip Vertically")
- << tr("Smudge...") << tr("Threshold...");
+ return {tr("Flip Horizontally"), tr("Flip Vertically"),
+ tr("Smudge..."), tr("Threshold...")};
}
QImage ExtraFiltersPlugin::filterImage(const QString &filter,
@@ -70,14 +70,14 @@ QImage ExtraFiltersPlugin::filterImage(const QString &filter,
if (filter == tr("Flip Horizontally")) {
for (int y = 0; y < original.height(); ++y) {
for (int x = 0; x < original.width(); ++x) {
- int pixel = original.pixel(original.width() - x - 1, y);
+ QRgb pixel = original.pixel(original.width() - x - 1, y);
result.setPixel(x, y, pixel);
}
}
} else if (filter == tr("Flip Vertically")) {
for (int y = 0; y < original.height(); ++y) {
for (int x = 0; x < original.width(); ++x) {
- int pixel = original.pixel(x, original.height() - y - 1);
+ QRgb pixel = original.pixel(x, original.height() - y - 1);
result.setPixel(x, y, pixel);
}
}
@@ -90,11 +90,11 @@ QImage ExtraFiltersPlugin::filterImage(const QString &filter,
for (int i = 0; i < numIters; ++i) {
for (int y = 1; y < original.height() - 1; ++y) {
for (int x = 1; x < original.width() - 1; ++x) {
- int p1 = original.pixel(x, y);
- int p2 = original.pixel(x, y + 1);
- int p3 = original.pixel(x, y - 1);
- int p4 = original.pixel(x + 1, y);
- int p5 = original.pixel(x - 1, y);
+ QRgb p1 = original.pixel(x, y);
+ QRgb p2 = original.pixel(x, y + 1);
+ QRgb p3 = original.pixel(x, y - 1);
+ QRgb p4 = original.pixel(x + 1, y);
+ QRgb p5 = original.pixel(x - 1, y);
int red = (qRed(p1) + qRed(p2) + qRed(p3) + qRed(p4)
+ qRed(p5)) / 5;
@@ -119,7 +119,7 @@ QImage ExtraFiltersPlugin::filterImage(const QString &filter,
int factor = 256 / threshold;
for (int y = 0; y < original.height(); ++y) {
for (int x = 0; x < original.width(); ++x) {
- int pixel = original.pixel(x, y);
+ QRgb pixel = original.pixel(x, y);
result.setPixel(x, y, qRgba(qRed(pixel) / factor * factor,
qGreen(pixel) / factor * factor,
qBlue(pixel) / factor * factor,