Fix manual lance test: avoid using deprecated api
...and other slight modernizations and minor fixes. Change-Id: Ide587d9fe59ca9113ae775882c99a50debaf9000 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
parent
0dff40adf8
commit
ecfda0d523
@ -1200,7 +1200,10 @@ void PaintCommands::command_drawRoundRect(QRegularExpressionMatch re)
|
||||
if (m_verboseMode)
|
||||
printf(" -(lance) drawRoundRect(%d, %d, %d, %d, [%d, %d])\n", x, y, w, h, xs, ys);
|
||||
|
||||
QT_WARNING_PUSH
|
||||
QT_WARNING_DISABLE_DEPRECATED
|
||||
m_painter->drawRoundRect(x, y, w, h, xs, ys);
|
||||
QT_WARNING_POP
|
||||
}
|
||||
|
||||
/***************************************************************************************************/
|
||||
|
@ -45,7 +45,7 @@ InteractiveWidget::InteractiveWidget()
|
||||
|
||||
// create and populate the command toolbox
|
||||
m_commandsToolBox = new QToolBox();
|
||||
QListWidget *currentListWidget = 0;
|
||||
QListWidget *currentListWidget = nullptr;
|
||||
foreach (PaintCommands::PaintCommandInfos paintCommandInfo, PaintCommands::s_commandInfoTable) {
|
||||
if (paintCommandInfo.isSectionHeader()) {
|
||||
currentListWidget = new QListWidget();
|
||||
|
@ -185,7 +185,7 @@ static void displayCommands()
|
||||
" pixmap_load filename name_in_script\n"
|
||||
" image_load filename name_in_script\n");
|
||||
}
|
||||
static InteractiveWidget *interactive_widget = 0;
|
||||
static InteractiveWidget *interactive_widget = nullptr;
|
||||
|
||||
static void runInteractive()
|
||||
{
|
||||
@ -350,15 +350,15 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
scaledWidth = width * scalefactor;
|
||||
scaledHeight = height * scalefactor;
|
||||
scaledWidth = int(width * scalefactor);
|
||||
scaledHeight = int(height * scalefactor);
|
||||
|
||||
PaintCommands pcmd(QStringList(), 800, 800, imageFormat);
|
||||
pcmd.setVerboseMode(verboseMode);
|
||||
pcmd.setType(type);
|
||||
pcmd.setCheckersBackground(checkers_background);
|
||||
|
||||
QWidget *activeWidget = 0;
|
||||
QWidget *activeWidget = nullptr;
|
||||
|
||||
if (interactive) {
|
||||
runInteractive();
|
||||
@ -610,7 +610,7 @@ int main(int argc, char **argv)
|
||||
|
||||
QPrinter p(highres ? QPrinter::HighResolution : QPrinter::ScreenResolution);
|
||||
if (printdlg) {
|
||||
QPrintDialog printDialog(&p, 0);
|
||||
QPrintDialog printDialog(&p, nullptr);
|
||||
if (printDialog.exec() != QDialog::Accepted)
|
||||
break;
|
||||
} else {
|
||||
|
@ -45,31 +45,12 @@
|
||||
#include <QPaintEngine>
|
||||
#include <QSignalMapper>
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
|
||||
#include <qmath.h>
|
||||
|
||||
const int CP_RADIUS = 10;
|
||||
|
||||
class StupidWorkaround : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
StupidWorkaround(QWidget *widget, int *value)
|
||||
: QObject(widget), w(widget), mode(value)
|
||||
{
|
||||
}
|
||||
|
||||
public slots:
|
||||
void setViewMode(int m) {
|
||||
*mode = m;
|
||||
w->update();
|
||||
}
|
||||
|
||||
private:
|
||||
QWidget *w;
|
||||
int *mode;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class OnScreenWidget : public T
|
||||
{
|
||||
@ -81,7 +62,7 @@ public:
|
||||
DifferenceView
|
||||
};
|
||||
|
||||
OnScreenWidget(const QString &file, QWidget *parent = 0)
|
||||
OnScreenWidget(const QString &file, QWidget *parent = nullptr)
|
||||
: T(parent),
|
||||
m_filename(file),
|
||||
m_view_mode(RenderView)
|
||||
@ -108,33 +89,20 @@ public:
|
||||
} else {
|
||||
T::setWindowTitle("Rendering: '" + file + "'. Shortcuts: 1=render, 2=baseline, 3=difference");
|
||||
|
||||
StupidWorkaround *workaround = new StupidWorkaround(this, &m_view_mode);
|
||||
|
||||
QSignalMapper *mapper = new QSignalMapper(this);
|
||||
T::connect(mapper, SIGNAL(mapped(int)), workaround, SLOT(setViewMode(int)));
|
||||
T::connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setWindowTitle(QString)));
|
||||
|
||||
QAction *renderViewAction = new QAction("Render View", this);
|
||||
renderViewAction->setShortcut(Qt::Key_1);
|
||||
T::connect(renderViewAction, SIGNAL(triggered()), mapper, SLOT(map()));
|
||||
mapper->setMapping(renderViewAction, RenderView);
|
||||
mapper->setMapping(renderViewAction, "Render View: " + file);
|
||||
T::connect(renderViewAction, &QAction::triggered, [&] { setMode(RenderView); });
|
||||
T::addAction(renderViewAction);
|
||||
|
||||
QAction *baselineAction = new QAction("Baseline", this);
|
||||
baselineAction->setShortcut(Qt::Key_2);
|
||||
T::connect(baselineAction, SIGNAL(triggered()), mapper, SLOT(map()));
|
||||
mapper->setMapping(baselineAction, BaselineView);
|
||||
mapper->setMapping(baselineAction, "Baseline View: " + file);
|
||||
T::connect(baselineAction, &QAction::triggered, [&] { setMode(BaselineView); });
|
||||
T::addAction(baselineAction);
|
||||
|
||||
QAction *differenceAction = new QAction("Differenfe View", this);
|
||||
QAction *differenceAction = new QAction("Difference View", this);
|
||||
differenceAction->setShortcut(Qt::Key_3);
|
||||
T::connect(differenceAction, SIGNAL(triggered()), mapper, SLOT(map()));
|
||||
mapper->setMapping(differenceAction, DifferenceView);
|
||||
mapper->setMapping(differenceAction, "Difference View" + file);
|
||||
T::connect(differenceAction, &QAction::triggered, [&] { setMode(DifferenceView); });
|
||||
T::addAction(differenceAction);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -148,6 +116,18 @@ public:
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
void setMode(ViewMode mode) {
|
||||
m_view_mode = mode;
|
||||
QString title;
|
||||
switch (m_view_mode) {
|
||||
case RenderView: title = "Render"; break;
|
||||
case BaselineView: title = "Baseline"; break;
|
||||
case DifferenceView: title = "Difference"; break;
|
||||
}
|
||||
T::setWindowTitle(title + " View: " + m_filename);
|
||||
T::update();
|
||||
}
|
||||
|
||||
void setVerboseMode(bool v) { m_verboseMode = v; }
|
||||
void setCheckersBackground(bool b) { m_checkersBackground = b; }
|
||||
void setType(DeviceType t) { m_deviceType = t; }
|
||||
@ -205,7 +185,7 @@ public:
|
||||
pt.begin(this);
|
||||
pt.setRenderHint(QPainter::Antialiasing);
|
||||
pt.setFont(this->font());
|
||||
pt.resetMatrix();
|
||||
pt.resetTransform();
|
||||
pt.setPen(QColor(127, 127, 127, 191));
|
||||
pt.setBrush(QColor(191, 191, 255, 63));
|
||||
for (int i=0; i<m_controlPoints.size(); ++i) {
|
||||
@ -239,7 +219,7 @@ public:
|
||||
|
||||
p.drawPixmap(0, 0, m_baseline);
|
||||
|
||||
p.setPen(QColor::fromRgb(0, 0, 0, 0.1));
|
||||
p.setPen(QColor::fromRgbF(0, 0, 0, 0.1));
|
||||
p.setFont(QFont("Arial", 128));
|
||||
p.rotate(45);
|
||||
p.drawText(100, 0, "BASELINE");
|
||||
@ -251,7 +231,7 @@ public:
|
||||
img.fill(0);
|
||||
|
||||
QPainter p(&img);
|
||||
p.drawPixmap(0, 0, m_render_view);
|
||||
p.drawImage(0, 0, m_image);
|
||||
|
||||
p.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
|
||||
p.drawPixmap(0, 0, m_baseline);
|
||||
|
Loading…
x
Reference in New Issue
Block a user