Merge 5.11 into 5.11.1
Change-Id: I28f48e980a9e23ddde5251608dd9d1d83df65392
This commit is contained in:
commit
fc5da399c3
@ -4,4 +4,4 @@ CONFIG += warning_clean
|
||||
QT_SOURCE_TREE = $$PWD
|
||||
QT_BUILD_TREE = $$shadowed($$PWD)
|
||||
|
||||
MODULE_VERSION = 5.11.0
|
||||
MODULE_VERSION = 5.11.1
|
||||
|
@ -8,7 +8,8 @@ dita.metadata.default.copyrholder = The Qt Company Ltd
|
||||
dita.metadata.default.audience = programmer
|
||||
|
||||
#Set the main Qt index.html
|
||||
navigation.homepage = "Qt $QT_VER"
|
||||
navigation.homepage = index.html
|
||||
navigation.hometitle = "Qt $QT_VER"
|
||||
|
||||
sourcedirs += includes $$BUILDDIR
|
||||
|
||||
|
@ -62,15 +62,21 @@ void BookDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
{
|
||||
if (index.column() != 5) {
|
||||
QStyleOptionViewItem opt = option;
|
||||
opt.rect.adjust(0, 0, -1, -1); // since we draw the grid ourselves
|
||||
// Since we draw the grid ourselves:
|
||||
opt.rect.adjust(0, 0, -1, -1);
|
||||
QSqlRelationalDelegate::paint(painter, opt, index);
|
||||
} else {
|
||||
const QAbstractItemModel *model = index.model();
|
||||
QPalette::ColorGroup cg = (option.state & QStyle::State_Enabled) ?
|
||||
(option.state & QStyle::State_Active) ? QPalette::Normal : QPalette::Inactive : QPalette::Disabled;
|
||||
(option.state & QStyle::State_Active) ?
|
||||
QPalette::Normal :
|
||||
QPalette::Inactive :
|
||||
QPalette::Disabled;
|
||||
|
||||
if (option.state & QStyle::State_Selected)
|
||||
painter->fillRect(option.rect, option.palette.color(cg, QPalette::Highlight));
|
||||
painter->fillRect(
|
||||
option.rect,
|
||||
option.palette.color(cg, QPalette::Highlight));
|
||||
|
||||
int rating = model->data(index, Qt::DisplayRole).toInt();
|
||||
int width = star.width();
|
||||
@ -81,7 +87,8 @@ void BookDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
painter->drawPixmap(x, y, star);
|
||||
x += width;
|
||||
}
|
||||
drawFocus(painter, option, option.rect.adjusted(0, 0, -1, -1)); // since we draw the grid ourselves
|
||||
// Since we draw the grid ourselves:
|
||||
drawFocus(painter, option, option.rect.adjusted(0, 0, -1, -1));
|
||||
}
|
||||
|
||||
QPen pen = painter->pen();
|
||||
@ -96,8 +103,8 @@ QSize BookDelegate::sizeHint(const QStyleOptionViewItem &option,
|
||||
{
|
||||
if (index.column() == 5)
|
||||
return QSize(5 * star.width(), star.height()) + QSize(1, 1);
|
||||
|
||||
return QSqlRelationalDelegate::sizeHint(option, index) + QSize(1, 1); // since we draw the grid ourselves
|
||||
// Since we draw the grid ourselves:
|
||||
return QSqlRelationalDelegate::sizeHint(option, index) + QSize(1, 1);
|
||||
}
|
||||
|
||||
bool BookDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||
@ -112,19 +119,21 @@ bool BookDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||
int stars = qBound(0, int(0.7 + qreal(mouseEvent->pos().x()
|
||||
- option.rect.x()) / star.width()), 5);
|
||||
model->setData(index, QVariant(stars));
|
||||
return false; //so that the selection can change
|
||||
// So that the selection can change:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QWidget *BookDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
QWidget *BookDelegate::createEditor(QWidget *parent,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
if (index.column() != 4)
|
||||
return QSqlRelationalDelegate::createEditor(parent, option, index);
|
||||
|
||||
// for editing the year, return a spinbox with a range from -1000 to 2100.
|
||||
// For editing the year, return a spinbox with a range from -1000 to 2100.
|
||||
QSpinBox *sb = new QSpinBox(parent);
|
||||
sb->setFrame(false);
|
||||
sb->setMaximum(2100);
|
||||
@ -132,4 +141,3 @@ QWidget *BookDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem
|
||||
|
||||
return sb;
|
||||
}
|
||||
|
||||
|
@ -66,14 +66,15 @@ public:
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
|
||||
bool editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) override;
|
||||
|
||||
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const override;
|
||||
const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
QPixmap star;
|
||||
|
@ -59,53 +59,61 @@ BookWindow::BookWindow()
|
||||
ui.setupUi(this);
|
||||
|
||||
if (!QSqlDatabase::drivers().contains("QSQLITE"))
|
||||
QMessageBox::critical(this, "Unable to load database", "This demo needs the SQLITE driver");
|
||||
QMessageBox::critical(
|
||||
this,
|
||||
"Unable to load database",
|
||||
"This demo needs the SQLITE driver"
|
||||
);
|
||||
|
||||
// initialize the database
|
||||
// Initialize the database:
|
||||
QSqlError err = initDb();
|
||||
if (err.type() != QSqlError::NoError) {
|
||||
showError(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the data model
|
||||
// Create the data model:
|
||||
model = new QSqlRelationalTableModel(ui.bookTable);
|
||||
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||
model->setTable("books");
|
||||
|
||||
// Remember the indexes of the columns
|
||||
// Remember the indexes of the columns:
|
||||
authorIdx = model->fieldIndex("author");
|
||||
genreIdx = model->fieldIndex("genre");
|
||||
|
||||
// Set the relations to the other database tables
|
||||
// Set the relations to the other database tables:
|
||||
model->setRelation(authorIdx, QSqlRelation("authors", "id", "name"));
|
||||
model->setRelation(genreIdx, QSqlRelation("genres", "id", "name"));
|
||||
|
||||
// Set the localized header captions
|
||||
// Set the localized header captions:
|
||||
model->setHeaderData(authorIdx, Qt::Horizontal, tr("Author Name"));
|
||||
model->setHeaderData(genreIdx, Qt::Horizontal, tr("Genre"));
|
||||
model->setHeaderData(model->fieldIndex("title"), Qt::Horizontal, tr("Title"));
|
||||
model->setHeaderData(model->fieldIndex("title"),
|
||||
Qt::Horizontal, tr("Title"));
|
||||
model->setHeaderData(model->fieldIndex("year"), Qt::Horizontal, tr("Year"));
|
||||
model->setHeaderData(model->fieldIndex("rating"), Qt::Horizontal, tr("Rating"));
|
||||
model->setHeaderData(model->fieldIndex("rating"),
|
||||
Qt::Horizontal, tr("Rating"));
|
||||
|
||||
// Populate the model
|
||||
// Populate the model:
|
||||
if (!model->select()) {
|
||||
showError(model->lastError());
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the model and hide the ID column
|
||||
// Set the model and hide the ID column:
|
||||
ui.bookTable->setModel(model);
|
||||
ui.bookTable->setItemDelegate(new BookDelegate(ui.bookTable));
|
||||
ui.bookTable->setColumnHidden(model->fieldIndex("id"), true);
|
||||
ui.bookTable->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
||||
// Initialize the Author combo box
|
||||
// Initialize the Author combo box:
|
||||
ui.authorEdit->setModel(model->relationModel(authorIdx));
|
||||
ui.authorEdit->setModelColumn(model->relationModel(authorIdx)->fieldIndex("name"));
|
||||
ui.authorEdit->setModelColumn(
|
||||
model->relationModel(authorIdx)->fieldIndex("name"));
|
||||
|
||||
ui.genreEdit->setModel(model->relationModel(genreIdx));
|
||||
ui.genreEdit->setModelColumn(model->relationModel(genreIdx)->fieldIndex("name"));
|
||||
ui.genreEdit->setModelColumn(
|
||||
model->relationModel(genreIdx)->fieldIndex("name"));
|
||||
|
||||
QDataWidgetMapper *mapper = new QDataWidgetMapper(this);
|
||||
mapper->setModel(model);
|
||||
@ -116,8 +124,11 @@ BookWindow::BookWindow()
|
||||
mapper->addMapping(ui.genreEdit, genreIdx);
|
||||
mapper->addMapping(ui.ratingEdit, model->fieldIndex("rating"));
|
||||
|
||||
connect(ui.bookTable->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
|
||||
mapper, SLOT(setCurrentModelIndex(QModelIndex)));
|
||||
connect(ui.bookTable->selectionModel(),
|
||||
&QItemSelectionModel::currentRowChanged,
|
||||
mapper,
|
||||
&QDataWidgetMapper::setCurrentModelIndex
|
||||
);
|
||||
|
||||
ui.bookTable->setCurrentIndex(model->index(0, 0));
|
||||
}
|
||||
@ -127,4 +138,3 @@ void BookWindow::showError(const QSqlError &err)
|
||||
QMessageBox::critical(this, "Unable to initialize Database",
|
||||
"Error initializing database: " + err.text());
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,8 @@
|
||||
<ui version="4.0" >
|
||||
<author></author>
|
||||
<comment></comment>
|
||||
<exportmacro></exportmacro>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BookWindow</class>
|
||||
<widget class="QMainWindow" name="BookWindow" >
|
||||
<property name="geometry" >
|
||||
<widget class="QMainWindow" name="BookWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
@ -12,117 +10,135 @@
|
||||
<height>420</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string>Books</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget" >
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox" >
|
||||
<property name="title" >
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Books</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTableView" name="bookTable" >
|
||||
<property name="selectionBehavior" >
|
||||
<widget class="QTableView" name="bookTable">
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2" >
|
||||
<property name="title" >
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Details</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="label_5" >
|
||||
<property name="text" >
|
||||
<string><b>Title:</b></string>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string><b>Title:</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QLineEdit" name="titleEdit" >
|
||||
<property name="enabled" >
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="titleEdit">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="label_2_2_2_2" >
|
||||
<property name="text" >
|
||||
<string><b>Author: </b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QComboBox" name="authorEdit" >
|
||||
<property name="enabled" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="label_3" >
|
||||
<property name="text" >
|
||||
<string><b>Genre:</b></string>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><b>Author: </b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QComboBox" name="genreEdit" >
|
||||
<property name="enabled" >
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="authorEdit">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QLabel" name="label_4" >
|
||||
<property name="text" >
|
||||
<string><b>Year:</b></string>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string><b>Genre:</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<widget class="QSpinBox" name="yearEdit" >
|
||||
<property name="enabled" >
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="genreEdit">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefix" >
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string><b>Year:</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="yearEdit">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="prefix">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>2100</number>
|
||||
</property>
|
||||
<property name="minimum" >
|
||||
<property name="minimum">
|
||||
<number>-1000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<widget class="QLabel" name="label" >
|
||||
<property name="text" >
|
||||
<string><b>Rating:</b></string>
|
||||
<property name="maximum">
|
||||
<number>2100</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" >
|
||||
<widget class="QSpinBox" name="ratingEdit" >
|
||||
<property name="maximum" >
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string><b>Rating:</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="ratingEdit">
|
||||
<property name="maximum">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
@ -136,7 +152,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<tabstops>
|
||||
<tabstop>bookTable</tabstop>
|
||||
<tabstop>titleEdit</tabstop>
|
||||
|
@ -50,8 +50,9 @@
|
||||
|
||||
//! [0]
|
||||
#include "mainwindow.h"
|
||||
#include <QtPlugin>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QtPlugin>
|
||||
|
||||
Q_IMPORT_PLUGIN(BasicToolsPlugin)
|
||||
|
||||
|
@ -54,19 +54,18 @@
|
||||
#include "paintarea.h"
|
||||
#include "plugindialog.h"
|
||||
|
||||
#include <QPluginLoader>
|
||||
#include <QTimer>
|
||||
|
||||
#include <QScrollArea>
|
||||
#include <QMessageBox>
|
||||
#include <QActionGroup>
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
#include <QApplication>
|
||||
#include <QColorDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QFileDialog>
|
||||
#include <QColorDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QApplication>
|
||||
#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) {
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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));
|
||||
|
@ -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,
|
||||
|
BIN
examples/widgets/tutorials/notepad/images/bold.png
Normal file
BIN
examples/widgets/tutorials/notepad/images/bold.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 724 B |
BIN
examples/widgets/tutorials/notepad/images/italic.png
Normal file
BIN
examples/widgets/tutorials/notepad/images/italic.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 471 B |
BIN
examples/widgets/tutorials/notepad/images/underline.png
Normal file
BIN
examples/widgets/tutorials/notepad/images/underline.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 520 B |
@ -191,3 +191,27 @@ void Notepad::on_actionFont_triggered()
|
||||
if (fontSelected)
|
||||
ui->textEdit->setFont(font);
|
||||
}
|
||||
|
||||
void Notepad::on_actionUnderline_triggered()
|
||||
{
|
||||
ui->textEdit->setFontUnderline(ui->actionUnderline->isChecked());
|
||||
}
|
||||
|
||||
void Notepad::on_actionItalic_triggered()
|
||||
{
|
||||
ui->textEdit->setFontItalic(ui->actionItalic->isChecked());
|
||||
}
|
||||
|
||||
void Notepad::on_actionBold_triggered()
|
||||
{
|
||||
ui->actionBold->isChecked() ? ui->textEdit->setFontWeight(QFont::Bold) :
|
||||
ui->textEdit->setFontWeight(QFont::Normal);
|
||||
}
|
||||
|
||||
void Notepad::on_actionAbout_triggered()
|
||||
{
|
||||
QMessageBox::about(this, tr("About MDI"),
|
||||
tr("The <b>Notepad</b> example demonstrates how to code a basic "
|
||||
"text editor using QtWidgets"));
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2017 The Qt Company Ltd.
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the documentation of the Qt Toolkit.
|
||||
@ -103,6 +103,14 @@ private slots:
|
||||
|
||||
void on_actionFont_triggered();
|
||||
|
||||
void on_actionBold_triggered();
|
||||
|
||||
void on_actionUnderline_triggered();
|
||||
|
||||
void on_actionItalic_triggered();
|
||||
|
||||
void on_actionAbout_triggered();
|
||||
|
||||
//! [6]
|
||||
private:
|
||||
Ui::Notepad *ui;
|
||||
|
@ -1,12 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>images/copy.png</file>
|
||||
<file>images/create.png</file>
|
||||
<file>images/cut.png</file>
|
||||
<file>images/edit_redo.png</file>
|
||||
<file>images/edit_undo.png</file>
|
||||
<file>images/exit.png</file>
|
||||
<file>images/font.png</file>
|
||||
<file>images/info.png</file>
|
||||
<file>images/new.png</file>
|
||||
<file>images/open.png</file>
|
||||
@ -15,5 +8,15 @@
|
||||
<file>images/print.png</file>
|
||||
<file>images/save.png</file>
|
||||
<file>images/save_as.png</file>
|
||||
<file>images/exit.png</file>
|
||||
<file>images/font.png</file>
|
||||
<file>images/copy.png</file>
|
||||
<file>images/create.png</file>
|
||||
<file>images/cut.png</file>
|
||||
<file>images/edit_redo.png</file>
|
||||
<file>images/edit_undo.png</file>
|
||||
<file>images/bold.png</file>
|
||||
<file>images/italic.png</file>
|
||||
<file>images/underline.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>524</width>
|
||||
<height>300</height>
|
||||
<width>800</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -25,7 +25,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>524</width>
|
||||
<width>800</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -74,7 +74,13 @@
|
||||
<addaction name="actionPaste"/>
|
||||
<addaction name="actionUndo"/>
|
||||
<addaction name="actionRedo"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionFont"/>
|
||||
<addaction name="actionBold"/>
|
||||
<addaction name="actionItalic"/>
|
||||
<addaction name="actionUnderline"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAbout"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
@ -87,105 +93,224 @@
|
||||
<property name="text">
|
||||
<string>New</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>New text document</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOpen">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/open.png</normaloff>:/images/open.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Open file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/save.png</normaloff>:/images/save.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_as">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/save_as.png</normaloff>:/images/save_as.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save as</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Save file as</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Alt+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPrint">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/print.png</normaloff>:/images/print.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Print</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Print file</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+P</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExit">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset theme="exit.png" resource="notepad.qrc">
|
||||
<normaloff>:/images/exit.png</normaloff>:/images/exit.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Exit</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Exit notepad</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCopy">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/copy.png</normaloff>:/images/copy.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Copy</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+C</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCut">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/cut.png</normaloff>:/images/cut.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Cut</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+X</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPaste">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/paste.png</normaloff>:/images/paste.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Paste</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+V</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUndo">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/edit_undo.png</normaloff>:/images/edit_undo.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Undo</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Z</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRedo">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/edit_redo.png</normaloff>:/images/edit_redo.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Redo</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Y</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionFont">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/font.png</normaloff>:/images/font.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+F</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionItalic">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/italic.png</normaloff>:/images/italic.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Italic</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Italic font</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+I</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionBold">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/bold.png</normaloff>:/images/bold.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>actionBold</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Bold</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+B</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUnderline">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/underline.png</normaloff>:/images/underline.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Underline</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Underline</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+U</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="icon">
|
||||
<iconset resource="notepad.qrc">
|
||||
<normaloff>:/images/info.png</normaloff>:/images/info.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>About</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>About Notepad</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
|
@ -1951,7 +1951,8 @@ for(ever) {
|
||||
isEmpty(configsToProcess): \
|
||||
break()
|
||||
|
||||
currentConfig = config.$$take_first(configsToProcess)
|
||||
thisConfig = $$take_first(configsToProcess)
|
||||
currentConfig = config.$$thisConfig
|
||||
thisDir = $$eval($${currentConfig}.dir)
|
||||
jsonFile = $$thisDir/configure.json
|
||||
priFile = $$thisDir/configure.pri
|
||||
@ -1982,7 +1983,7 @@ for(ever) {
|
||||
subconfigs =
|
||||
for(n, $${currentConfig}.subconfigs._KEYS_) {
|
||||
subconfig = $$eval($${currentConfig}.subconfigs.$${n})
|
||||
name = $$basename(subconfig)
|
||||
name = $${thisConfig}_$$basename(subconfig)
|
||||
ex = $$eval(config.$${name}.dir)
|
||||
!isEmpty(ex): \
|
||||
error("Basename clash between $$thisDir/$$subconfig and $${ex}.")
|
||||
|
@ -738,7 +738,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinExpand(
|
||||
const QString &sep = (args.count() == 2) ? args.at(1).toQString(m_tmp1) : statics.field_sep;
|
||||
const auto vars = values(map(args.at(0)));
|
||||
for (const ProString &var : vars) {
|
||||
const auto splits = var.toQStringRef().split(sep);
|
||||
// FIXME: this is inconsistent with the "there are no empty strings" dogma.
|
||||
const auto splits = var.toQStringRef().split(sep, QString::KeepEmptyParts);
|
||||
for (const auto &splt : splits)
|
||||
ret << ProString(splt).setSource(var);
|
||||
}
|
||||
@ -1445,7 +1446,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
|
||||
}
|
||||
if (args.count() == 1)
|
||||
return returnBool(isActiveConfig(args.at(0).toQStringRef()));
|
||||
const auto mutuals = args.at(1).toQStringRef().split(QLatin1Char('|'));
|
||||
const auto mutuals = args.at(1).toQStringRef().split(QLatin1Char('|'),
|
||||
QString::SkipEmptyParts);
|
||||
const ProStringList &configs = values(statics.strCONFIG);
|
||||
|
||||
for (int i = configs.size() - 1; i >= 0; i--) {
|
||||
@ -1477,7 +1479,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateBuiltinConditional(
|
||||
return ReturnTrue;
|
||||
}
|
||||
} else {
|
||||
const auto mutuals = args.at(2).toQStringRef().split(QLatin1Char('|'));
|
||||
const auto mutuals = args.at(2).toQStringRef().split(QLatin1Char('|'),
|
||||
QString::SkipEmptyParts);
|
||||
for (int i = l.size() - 1; i >= 0; i--) {
|
||||
const ProString val = l[i];
|
||||
for (int mut = 0; mut < mutuals.count(); mut++) {
|
||||
|
@ -297,6 +297,7 @@ ProStringList QMakeEvaluator::split_value_list(const QStringRef &vals, int sourc
|
||||
case '\'':
|
||||
if (!quote)
|
||||
quote = unicode;
|
||||
// FIXME: this is inconsistent with the "there are no empty strings" dogma.
|
||||
hadWord = true;
|
||||
break;
|
||||
case ' ':
|
||||
@ -879,7 +880,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable(
|
||||
return ReturnTrue;
|
||||
}
|
||||
QChar sep = val.at(1);
|
||||
auto func = val.split(sep);
|
||||
auto func = val.split(sep, QString::KeepEmptyParts);
|
||||
if (func.count() < 3 || func.count() > 4) {
|
||||
evalError(fL1S("The s/// function expects 3 or 4 arguments."));
|
||||
return ReturnTrue;
|
||||
@ -1018,7 +1019,7 @@ static ProString msvcArchitecture(const QString &vcInstallDir, const QString &pa
|
||||
QString vcBinDir = vcInstallDir;
|
||||
if (vcBinDir.endsWith(QLatin1Char('\\')))
|
||||
vcBinDir.chop(1);
|
||||
const auto dirs = pathVar.split(QLatin1Char(';'));
|
||||
const auto dirs = pathVar.split(QLatin1Char(';'), QString::SkipEmptyParts);
|
||||
for (const QString &dir : dirs) {
|
||||
if (!dir.startsWith(vcBinDir, Qt::CaseInsensitive))
|
||||
continue;
|
||||
|
@ -261,7 +261,7 @@ QStringList QMakeGlobals::splitPathList(const QString &val) const
|
||||
QStringList ret;
|
||||
if (!val.isEmpty()) {
|
||||
QString cwd(QDir::currentPath());
|
||||
const QStringList vals = val.split(dirlist_sep);
|
||||
const QStringList vals = val.split(dirlist_sep, QString::SkipEmptyParts);
|
||||
ret.reserve(vals.length());
|
||||
for (const QString &it : vals)
|
||||
ret << IoUtils::resolvePath(cwd, it);
|
||||
|
@ -3990,7 +3990,7 @@ Q_GLOBAL_STATIC(QInternal_CallBackTable, global_callback_table)
|
||||
|
||||
bool QInternal::registerCallback(Callback cb, qInternalCallback callback)
|
||||
{
|
||||
if (cb >= 0 && cb < QInternal::LastCallback) {
|
||||
if (unsigned(cb) < unsigned(QInternal::LastCallback)) {
|
||||
QInternal_CallBackTable *cbt = global_callback_table();
|
||||
cbt->callbacks.resize(cb + 1);
|
||||
cbt->callbacks[cb].append(callback);
|
||||
@ -4001,7 +4001,7 @@ bool QInternal::registerCallback(Callback cb, qInternalCallback callback)
|
||||
|
||||
bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback)
|
||||
{
|
||||
if (cb >= 0 && cb < QInternal::LastCallback) {
|
||||
if (unsigned(cb) < unsigned(QInternal::LastCallback)) {
|
||||
if (global_callback_table.exists()) {
|
||||
QInternal_CallBackTable *cbt = global_callback_table();
|
||||
return (bool) cbt->callbacks[cb].removeAll(callback);
|
||||
|
@ -315,18 +315,14 @@ QMimeMagicRule::QMimeMagicRule(const QString &type,
|
||||
break;
|
||||
case Big32:
|
||||
case Little32:
|
||||
if (m_number <= quint32(-1)) {
|
||||
m_number = m_type == Little32 ? qFromLittleEndian<quint32>(m_number) : qFromBigEndian<quint32>(m_number);
|
||||
if (m_numberMask != 0)
|
||||
m_numberMask = m_type == Little32 ? qFromLittleEndian<quint32>(m_numberMask) : qFromBigEndian<quint32>(m_numberMask);
|
||||
}
|
||||
m_number = m_type == Little32 ? qFromLittleEndian<quint32>(m_number) : qFromBigEndian<quint32>(m_number);
|
||||
if (m_numberMask != 0)
|
||||
m_numberMask = m_type == Little32 ? qFromLittleEndian<quint32>(m_numberMask) : qFromBigEndian<quint32>(m_numberMask);
|
||||
Q_FALLTHROUGH();
|
||||
case Host32:
|
||||
if (m_number <= quint32(-1)) {
|
||||
if (m_numberMask == 0)
|
||||
m_numberMask = quint32(-1);
|
||||
m_matchFunction = &QMimeMagicRule::matchNumber<quint32>;
|
||||
}
|
||||
if (m_numberMask == 0)
|
||||
m_numberMask = quint32(-1);
|
||||
m_matchFunction = &QMimeMagicRule::matchNumber<quint32>;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
485
src/corelib/thread/qatomic_msvc.h
Normal file
485
src/corelib/thread/qatomic_msvc.h
Normal file
@ -0,0 +1,485 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Intel Corporation.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtCore module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL3 included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 3 requirements
|
||||
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 2.0 or (at your option) the GNU General
|
||||
** Public license version 3 or any later version approved by the KDE Free
|
||||
** Qt Foundation. The licenses are as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
|
||||
** https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QATOMIC_MSVC_H
|
||||
#define QATOMIC_MSVC_H
|
||||
|
||||
#include <QtCore/qgenericatomic.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// use compiler intrinsics for all atomic functions
|
||||
# define QT_INTERLOCKED_PREFIX _
|
||||
# define QT_INTERLOCKED_PROTOTYPE
|
||||
# define QT_INTERLOCKED_DECLARE_PROTOTYPES
|
||||
# define QT_INTERLOCKED_INTRINSIC
|
||||
# define Q_ATOMIC_INT16_IS_SUPPORTED
|
||||
|
||||
# ifdef _WIN64
|
||||
# define Q_ATOMIC_INT64_IS_SUPPORTED
|
||||
# endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Prototype declaration
|
||||
|
||||
#define QT_INTERLOCKED_CONCAT_I(prefix, suffix) \
|
||||
prefix ## suffix
|
||||
#define QT_INTERLOCKED_CONCAT(prefix, suffix) \
|
||||
QT_INTERLOCKED_CONCAT_I(prefix, suffix)
|
||||
|
||||
// MSVC intrinsics prefix function names with an underscore. Also, if platform
|
||||
// SDK headers have been included, the Interlocked names may be defined as
|
||||
// macros.
|
||||
// To avoid double underscores, we paste the prefix with Interlocked first and
|
||||
// then the remainder of the function name.
|
||||
#define QT_INTERLOCKED_FUNCTION(name) \
|
||||
QT_INTERLOCKED_CONCAT( \
|
||||
QT_INTERLOCKED_CONCAT(QT_INTERLOCKED_PREFIX, Interlocked), name)
|
||||
|
||||
#ifndef QT_INTERLOCKED_VOLATILE
|
||||
# define QT_INTERLOCKED_VOLATILE volatile
|
||||
#endif
|
||||
|
||||
#ifndef QT_INTERLOCKED_PREFIX
|
||||
#define QT_INTERLOCKED_PREFIX
|
||||
#endif
|
||||
|
||||
#ifndef QT_INTERLOCKED_PROTOTYPE
|
||||
#define QT_INTERLOCKED_PROTOTYPE
|
||||
#endif
|
||||
|
||||
#ifdef QT_INTERLOCKED_DECLARE_PROTOTYPES
|
||||
#undef QT_INTERLOCKED_DECLARE_PROTOTYPES
|
||||
|
||||
extern "C" {
|
||||
|
||||
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment )(long QT_INTERLOCKED_VOLATILE *);
|
||||
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement )(long QT_INTERLOCKED_VOLATILE *);
|
||||
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange )(long QT_INTERLOCKED_VOLATILE *, long, long);
|
||||
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange )(long QT_INTERLOCKED_VOLATILE *, long);
|
||||
long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long);
|
||||
|
||||
# if !defined(__i386__) && !defined(_M_IX86)
|
||||
void * QT_INTERLOCKED_FUNCTION( CompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *);
|
||||
void * QT_INTERLOCKED_FUNCTION( ExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *);
|
||||
__int64 QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64);
|
||||
# endif
|
||||
|
||||
# ifdef Q_ATOMIC_INT16_IS_SUPPORTED
|
||||
short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment16 )(short QT_INTERLOCKED_VOLATILE *);
|
||||
short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement16 )(short QT_INTERLOCKED_VOLATILE *);
|
||||
short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange16 )(short QT_INTERLOCKED_VOLATILE *, short, short);
|
||||
short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange16 )(short QT_INTERLOCKED_VOLATILE *, short);
|
||||
short QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd16 )(short QT_INTERLOCKED_VOLATILE *, short);
|
||||
# endif
|
||||
# ifdef Q_ATOMIC_INT64_IS_SUPPORTED
|
||||
__int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment64 )(__int64 QT_INTERLOCKED_VOLATILE *);
|
||||
__int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement64 )(__int64 QT_INTERLOCKED_VOLATILE *);
|
||||
__int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64, __int64);
|
||||
__int64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64);
|
||||
//above already: qint64 QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(qint64 QT_INTERLOCKED_VOLATILE *, qint64);
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif // QT_INTERLOCKED_DECLARE_PROTOTYPES
|
||||
|
||||
#undef QT_INTERLOCKED_PROTOTYPE
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef QT_INTERLOCKED_INTRINSIC
|
||||
#undef QT_INTERLOCKED_INTRINSIC
|
||||
|
||||
# pragma intrinsic (_InterlockedIncrement)
|
||||
# pragma intrinsic (_InterlockedDecrement)
|
||||
# pragma intrinsic (_InterlockedExchange)
|
||||
# pragma intrinsic (_InterlockedCompareExchange)
|
||||
# pragma intrinsic (_InterlockedExchangeAdd)
|
||||
|
||||
# if !defined(_M_IX86)
|
||||
# pragma intrinsic (_InterlockedCompareExchangePointer)
|
||||
# pragma intrinsic (_InterlockedExchangePointer)
|
||||
# pragma intrinsic (_InterlockedExchangeAdd64)
|
||||
# endif
|
||||
|
||||
#endif // QT_INTERLOCKED_INTRINSIC
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Interlocked* replacement macros
|
||||
|
||||
#if defined(__i386__) || defined(_M_IX86)
|
||||
|
||||
# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \
|
||||
reinterpret_cast<void *>( \
|
||||
QT_INTERLOCKED_FUNCTION(CompareExchange)( \
|
||||
reinterpret_cast<long QT_INTERLOCKED_VOLATILE *>(value), \
|
||||
long(newValue), \
|
||||
long(expectedValue)))
|
||||
|
||||
# define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \
|
||||
QT_INTERLOCKED_FUNCTION(Exchange)( \
|
||||
reinterpret_cast<long QT_INTERLOCKED_VOLATILE *>(value), \
|
||||
long(newValue))
|
||||
|
||||
# define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \
|
||||
QT_INTERLOCKED_FUNCTION(ExchangeAdd)( \
|
||||
reinterpret_cast<long QT_INTERLOCKED_VOLATILE *>(value), \
|
||||
(valueToAdd))
|
||||
|
||||
#else // !defined(__i386__) && !defined(_M_IX86)
|
||||
|
||||
# define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \
|
||||
QT_INTERLOCKED_FUNCTION(CompareExchangePointer)( \
|
||||
(void * QT_INTERLOCKED_VOLATILE *)(value), \
|
||||
(void *) (newValue), \
|
||||
(void *) (expectedValue))
|
||||
|
||||
# define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \
|
||||
QT_INTERLOCKED_FUNCTION(ExchangePointer)( \
|
||||
(void * QT_INTERLOCKED_VOLATILE *)(value), \
|
||||
(void *) (newValue))
|
||||
|
||||
# define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \
|
||||
QT_INTERLOCKED_FUNCTION(ExchangeAdd64)( \
|
||||
reinterpret_cast<qint64 QT_INTERLOCKED_VOLATILE *>(value), \
|
||||
(valueToAdd))
|
||||
|
||||
#endif // !defined(__i386__) && !defined(_M_IX86)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#if 0
|
||||
// silence syncqt warnings
|
||||
QT_END_NAMESPACE
|
||||
#pragma qt_sync_skip_header_check
|
||||
#pragma qt_sync_stop_processing
|
||||
#endif
|
||||
|
||||
#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
|
||||
#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_WAIT_FREE
|
||||
|
||||
#define Q_ATOMIC_INT_TEST_AND_SET_IS_ALWAYS_NATIVE
|
||||
#define Q_ATOMIC_INT_TEST_AND_SET_IS_WAIT_FREE
|
||||
|
||||
#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_ALWAYS_NATIVE
|
||||
#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_WAIT_FREE
|
||||
|
||||
#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_ALWAYS_NATIVE
|
||||
#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_WAIT_FREE
|
||||
|
||||
#define Q_ATOMIC_INT32_IS_SUPPORTED
|
||||
|
||||
#define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
|
||||
#define Q_ATOMIC_INT32_REFERENCE_COUNTING_IS_WAIT_FREE
|
||||
|
||||
#define Q_ATOMIC_INT32_TEST_AND_SET_IS_ALWAYS_NATIVE
|
||||
#define Q_ATOMIC_INT32_TEST_AND_SET_IS_WAIT_FREE
|
||||
|
||||
#define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_ALWAYS_NATIVE
|
||||
#define Q_ATOMIC_INT32_FETCH_AND_STORE_IS_WAIT_FREE
|
||||
|
||||
#define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_ALWAYS_NATIVE
|
||||
#define Q_ATOMIC_INT32_FETCH_AND_ADD_IS_WAIT_FREE
|
||||
|
||||
#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE
|
||||
#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_WAIT_FREE
|
||||
|
||||
#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_ALWAYS_NATIVE
|
||||
#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_WAIT_FREE
|
||||
|
||||
#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_ALWAYS_NATIVE
|
||||
#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_WAIT_FREE
|
||||
|
||||
#ifdef Q_ATOMIC_INT16_IS_SUPPORTED
|
||||
# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
|
||||
# define Q_ATOMIC_INT16_REFERENCE_COUNTING_IS_WAIT_FREE
|
||||
|
||||
# define Q_ATOMIC_INT16_TEST_AND_SET_IS_ALWAYS_NATIVE
|
||||
# define Q_ATOMIC_INT16_TEST_AND_SET_IS_WAIT_FREE
|
||||
|
||||
# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_ALWAYS_NATIVE
|
||||
# define Q_ATOMIC_INT16_FETCH_AND_STORE_IS_WAIT_FREE
|
||||
|
||||
# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_ALWAYS_NATIVE
|
||||
# define Q_ATOMIC_INT16_FETCH_AND_ADD_IS_WAIT_FREE
|
||||
|
||||
template<> struct QAtomicOpsSupport<2> { enum { IsSupported = 1 }; };
|
||||
#endif
|
||||
|
||||
#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
|
||||
# define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
|
||||
# define Q_ATOMIC_INT64_REFERENCE_COUNTING_IS_WAIT_FREE
|
||||
|
||||
# define Q_ATOMIC_INT64_TEST_AND_SET_IS_ALWAYS_NATIVE
|
||||
# define Q_ATOMIC_INT64_TEST_AND_SET_IS_WAIT_FREE
|
||||
|
||||
# define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_ALWAYS_NATIVE
|
||||
# define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_WAIT_FREE
|
||||
|
||||
# define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_ALWAYS_NATIVE
|
||||
# define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_WAIT_FREE
|
||||
|
||||
template<> struct QAtomicOpsSupport<8> { enum { IsSupported = 1 }; };
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <int N> struct QAtomicWindowsType { typedef typename QIntegerForSize<N>::Signed Type; };
|
||||
template <> struct QAtomicWindowsType<4> { typedef long Type; };
|
||||
|
||||
|
||||
template <int N> struct QAtomicOpsBySize : QGenericAtomicOps<QAtomicOpsBySize<N> >
|
||||
{
|
||||
static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
|
||||
static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return true; }
|
||||
template <typename T> static bool ref(T &_q_value) Q_DECL_NOTHROW;
|
||||
template <typename T> static bool deref(T &_q_value) Q_DECL_NOTHROW;
|
||||
|
||||
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
|
||||
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
|
||||
template <typename T> static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW;
|
||||
template <typename T>
|
||||
static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW;
|
||||
|
||||
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
|
||||
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; }
|
||||
template <typename T> static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW;
|
||||
|
||||
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
|
||||
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; }
|
||||
template <typename T> static T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW;
|
||||
|
||||
private:
|
||||
typedef typename QAtomicWindowsType<N>::Type Type;
|
||||
template <typename T> static inline Type *atomic(T *t)
|
||||
{ Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return reinterpret_cast<Type *>(t); }
|
||||
template <typename T> static inline Type value(T t)
|
||||
{ Q_STATIC_ASSERT(sizeof(T) == sizeof(Type)); return Type(t); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct QAtomicOps : QAtomicOpsBySize<sizeof(T)>
|
||||
{
|
||||
typedef T Type;
|
||||
};
|
||||
|
||||
template<> template<typename T>
|
||||
inline bool QAtomicOpsBySize<4>::ref(T &_q_value) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(Increment)(atomic(&_q_value)) != 0;
|
||||
}
|
||||
|
||||
template<> template<typename T>
|
||||
inline bool QAtomicOpsBySize<4>::deref(T &_q_value) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(Decrement)(atomic(&_q_value)) != 0;
|
||||
}
|
||||
|
||||
template<> template<typename T>
|
||||
inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(CompareExchange)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue);
|
||||
}
|
||||
|
||||
template<> template <typename T>
|
||||
inline bool QAtomicOpsBySize<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW
|
||||
{
|
||||
*currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange)(atomic(&_q_value), newValue, expectedValue));
|
||||
return *currentValue == expectedValue;
|
||||
}
|
||||
|
||||
template<> template<typename T>
|
||||
inline T QAtomicOpsBySize<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(Exchange)(atomic(&_q_value), value(newValue));
|
||||
}
|
||||
|
||||
template<> template<typename T>
|
||||
inline T QAtomicOpsBySize<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(ExchangeAdd)(atomic(&_q_value), value<T>(valueToAdd * QAtomicAdditiveType<T>::AddScale));
|
||||
}
|
||||
|
||||
#ifdef Q_ATOMIC_INT16_IS_SUPPORTED
|
||||
template<> template<typename T>
|
||||
inline bool QAtomicOpsBySize<2>::ref(T &_q_value) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(Increment16)(atomic(&_q_value)) != 0;
|
||||
}
|
||||
|
||||
template<> template<typename T>
|
||||
inline bool QAtomicOpsBySize<2>::deref(T &_q_value) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(Decrement16)(atomic(&_q_value)) != 0;
|
||||
}
|
||||
|
||||
template<> template<typename T>
|
||||
inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(CompareExchange16)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue);
|
||||
}
|
||||
|
||||
template<> template <typename T>
|
||||
inline bool QAtomicOpsBySize<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW
|
||||
{
|
||||
*currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange16)(atomic(&_q_value), newValue, expectedValue));
|
||||
return *currentValue == expectedValue;
|
||||
}
|
||||
|
||||
template<> template<typename T>
|
||||
inline T QAtomicOpsBySize<2>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(Exchange16)(atomic(&_q_value), value(newValue));
|
||||
}
|
||||
|
||||
template<> template<typename T>
|
||||
inline T QAtomicOpsBySize<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(ExchangeAdd16)(atomic(&_q_value), value<T>(valueToAdd * QAtomicAdditiveType<T>::AddScale));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_ATOMIC_INT64_IS_SUPPORTED
|
||||
template<> template<typename T>
|
||||
inline bool QAtomicOpsBySize<8>::ref(T &_q_value) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(Increment64)(atomic(&_q_value)) != 0;
|
||||
}
|
||||
|
||||
template<> template<typename T>
|
||||
inline bool QAtomicOpsBySize<8>::deref(T &_q_value) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(Decrement64)(atomic(&_q_value)) != 0;
|
||||
}
|
||||
|
||||
template<> template<typename T>
|
||||
inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(CompareExchange64)(atomic(&_q_value), value(newValue), value(expectedValue)) == value(expectedValue);
|
||||
}
|
||||
|
||||
template<> template <typename T>
|
||||
inline bool QAtomicOpsBySize<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue, T *currentValue) Q_DECL_NOTHROW
|
||||
{
|
||||
*currentValue = T(QT_INTERLOCKED_FUNCTION(CompareExchange64)(atomic(&_q_value), newValue, expectedValue));
|
||||
return *currentValue == expectedValue;
|
||||
}
|
||||
|
||||
template<> template<typename T>
|
||||
inline T QAtomicOpsBySize<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(Exchange64)(atomic(&_q_value), value(newValue));
|
||||
}
|
||||
|
||||
template<> template<typename T>
|
||||
inline T QAtomicOpsBySize<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_FUNCTION(ExchangeAdd64)(atomic(&_q_value), value<T>(valueToAdd * QAtomicAdditiveType<T>::AddScale));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Specialization for pointer types, since we have Interlocked*Pointer() variants in some configurations
|
||||
template <typename T>
|
||||
struct QAtomicOps<T *> : QGenericAtomicOps<QAtomicOps<T *> >
|
||||
{
|
||||
typedef T *Type;
|
||||
|
||||
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return true; }
|
||||
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return true; }
|
||||
static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW;
|
||||
static bool testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) Q_DECL_NOTHROW;
|
||||
|
||||
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return true; }
|
||||
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return true; }
|
||||
static T *fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW;
|
||||
|
||||
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return true; }
|
||||
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return true; }
|
||||
static T *fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline bool QAtomicOps<T *>::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue) Q_DECL_NOTHROW
|
||||
{
|
||||
return QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue) == expectedValue;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool QAtomicOps<T *>::testAndSetRelaxed(T *&_q_value, T *expectedValue, T *newValue, T **currentValue) Q_DECL_NOTHROW
|
||||
{
|
||||
*currentValue = reinterpret_cast<T *>(QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(&_q_value, newValue, expectedValue));
|
||||
return *currentValue == expectedValue;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T *QAtomicOps<T *>::fetchAndStoreRelaxed(T *&_q_value, T *newValue) Q_DECL_NOTHROW
|
||||
{
|
||||
return reinterpret_cast<T *>(QT_INTERLOCKED_EXCHANGE_POINTER(&_q_value, newValue));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T *QAtomicOps<T *>::fetchAndAddRelaxed(T *&_q_value, qptrdiff valueToAdd) Q_DECL_NOTHROW
|
||||
{
|
||||
return reinterpret_cast<T *>(QT_INTERLOCKED_EXCHANGE_ADD_POINTER(&_q_value, valueToAdd * sizeof(T)));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Cleanup
|
||||
|
||||
#undef QT_INTERLOCKED_CONCAT_I
|
||||
#undef QT_INTERLOCKED_CONCAT
|
||||
#undef QT_INTERLOCKED_FUNCTION
|
||||
#undef QT_INTERLOCKED_PREFIX
|
||||
|
||||
#undef QT_INTERLOCKED_VOLATILE
|
||||
|
||||
#undef QT_INTERLOCKED_INCREMENT
|
||||
#undef QT_INTERLOCKED_DECREMENT
|
||||
#undef QT_INTERLOCKED_COMPARE_EXCHANGE
|
||||
#undef QT_INTERLOCKED_EXCHANGE
|
||||
#undef QT_INTERLOCKED_EXCHANGE_ADD
|
||||
#undef QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER
|
||||
#undef QT_INTERLOCKED_EXCHANGE_POINTER
|
||||
#undef QT_INTERLOCKED_EXCHANGE_ADD_POINTER
|
||||
|
||||
QT_END_NAMESPACE
|
||||
#endif // QATOMIC_MSVC_H
|
@ -45,8 +45,20 @@
|
||||
|
||||
#if defined(QT_BOOTSTRAPPED)
|
||||
# include <QtCore/qatomic_bootstrap.h>
|
||||
#else
|
||||
|
||||
// If C++11 atomics are supported, use them!
|
||||
// Note that constexpr support is sometimes disabled in QNX builds but its
|
||||
// library has <atomic>.
|
||||
#elif defined(Q_COMPILER_ATOMICS) && (defined(Q_COMPILER_CONSTEXPR) || defined(Q_OS_QNX))
|
||||
# include <QtCore/qatomic_cxx11.h>
|
||||
|
||||
// We only support one fallback: MSVC, because even on version 2015, it lacks full constexpr support
|
||||
#elif defined(Q_CC_MSVC)
|
||||
# include <QtCore/qatomic_msvc.h>
|
||||
|
||||
// No fallback
|
||||
#else
|
||||
# error "Qt requires C++11 support"
|
||||
#endif
|
||||
|
||||
QT_WARNING_PUSH
|
||||
|
@ -219,14 +219,17 @@ QThreadPrivate::~QThreadPrivate()
|
||||
It is important to remember that a QThread instance \l{QObject#Thread
|
||||
Affinity}{lives in} the old thread that instantiated it, not in the
|
||||
new thread that calls run(). This means that all of QThread's queued
|
||||
slots will execute in the old thread. Thus, a developer who wishes to
|
||||
invoke slots in the new thread must use the worker-object approach; new
|
||||
slots should not be implemented directly into a subclassed QThread.
|
||||
slots and \l {QMetaObject::invokeMethod()}{invoked methods} will execute
|
||||
in the old thread. Thus, a developer who wishes to invoke slots in the
|
||||
new thread must use the worker-object approach; new slots should not be
|
||||
implemented directly into a subclassed QThread.
|
||||
|
||||
When subclassing QThread, keep in mind that the constructor executes in
|
||||
the old thread while run() executes in the new thread. If a member
|
||||
variable is accessed from both functions, then the variable is accessed
|
||||
from two different threads. Check that it is safe to do so.
|
||||
Unlike queued slots or invoked methods, methods called directly on the
|
||||
QThread object will execute in the thread that calls the method. When
|
||||
subclassing QThread, keep in mind that the constructor executes in the
|
||||
old thread while run() executes in the new thread. If a member variable
|
||||
is accessed from both functions, then the variable is accessed from two
|
||||
different threads. Check that it is safe to do so.
|
||||
|
||||
\note Care must be taken when interacting with objects across different
|
||||
threads. See \l{Synchronizing Threads} for details.
|
||||
|
@ -53,6 +53,8 @@ qtConfig(future) {
|
||||
}
|
||||
|
||||
win32 {
|
||||
HEADERS += thread/qatomic_msvc.h
|
||||
|
||||
SOURCES += \
|
||||
thread/qmutex_win.cpp \
|
||||
thread/qthread_win.cpp \
|
||||
|
@ -549,7 +549,7 @@ void QPlatformCursorImage::createSystemCursor(int id)
|
||||
void QPlatformCursorImage::set(Qt::CursorShape id)
|
||||
{
|
||||
QPlatformCursorImage *cursor = 0;
|
||||
if (id >= 0 && id <= Qt::LastCursor) {
|
||||
if (unsigned(id) <= unsigned(Qt::LastCursor)) {
|
||||
if (!systemCursorTable[id])
|
||||
createSystemCursor(id);
|
||||
cursor = systemCursorTable[id];
|
||||
|
@ -664,18 +664,18 @@ QStringList QFileDialogOptions::history() const
|
||||
|
||||
void QFileDialogOptions::setLabelText(QFileDialogOptions::DialogLabel label, const QString &text)
|
||||
{
|
||||
if (label >= 0 && label < DialogLabelCount)
|
||||
if (unsigned(label) < unsigned(DialogLabelCount))
|
||||
d->labels[label] = text;
|
||||
}
|
||||
|
||||
QString QFileDialogOptions::labelText(QFileDialogOptions::DialogLabel label) const
|
||||
{
|
||||
return (label >= 0 && label < DialogLabelCount) ? d->labels[label] : QString();
|
||||
return (unsigned(label) < unsigned(DialogLabelCount)) ? d->labels[label] : QString();
|
||||
}
|
||||
|
||||
bool QFileDialogOptions::isLabelExplicitlySet(DialogLabel label)
|
||||
{
|
||||
return label >= 0 && label < DialogLabelCount && !d->labels[label].isEmpty();
|
||||
return unsigned(label) < unsigned(DialogLabelCount) && !d->labels[label].isEmpty();
|
||||
}
|
||||
|
||||
QUrl QFileDialogOptions::initialDirectory() const
|
||||
|
@ -1424,14 +1424,17 @@ QImage QOpenGLFramebufferObject::toImage(bool flipped, int colorAttachmentIndex)
|
||||
// qt_gl_read_framebuffer doesn't work on a multisample FBO
|
||||
if (format().samples() != 0) {
|
||||
QRect rect(QPoint(0, 0), size());
|
||||
QOpenGLFramebufferObjectFormat fmt;
|
||||
if (extraFuncs->hasOpenGLFeature(QOpenGLFunctions::MultipleRenderTargets)) {
|
||||
QOpenGLFramebufferObject temp(d->colorAttachments[colorAttachmentIndex].size, QOpenGLFramebufferObjectFormat());
|
||||
fmt.setInternalTextureFormat(d->colorAttachments[colorAttachmentIndex].internalFormat);
|
||||
QOpenGLFramebufferObject temp(d->colorAttachments[colorAttachmentIndex].size, fmt);
|
||||
blitFramebuffer(&temp, rect, const_cast<QOpenGLFramebufferObject *>(this), rect,
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST,
|
||||
colorAttachmentIndex, 0);
|
||||
image = temp.toImage(flipped);
|
||||
} else {
|
||||
QOpenGLFramebufferObject temp(size(), QOpenGLFramebufferObjectFormat());
|
||||
fmt.setInternalTextureFormat(d->colorAttachments[0].internalFormat);
|
||||
QOpenGLFramebufferObject temp(size(), fmt);
|
||||
blitFramebuffer(&temp, rect, const_cast<QOpenGLFramebufferObject *>(this), rect);
|
||||
image = temp.toImage(flipped);
|
||||
}
|
||||
|
@ -762,7 +762,7 @@ QPageSizePrivate::QPageSizePrivate(QPageSize::PageSizeId pageSizeId)
|
||||
m_windowsId(0),
|
||||
m_units(QPageSize::Point)
|
||||
{
|
||||
if (pageSizeId >= QPageSize::PageSizeId(0) && pageSizeId <= QPageSize::LastPageSize)
|
||||
if (unsigned(pageSizeId) <= unsigned(QPageSize::LastPageSize))
|
||||
init(pageSizeId, QString());
|
||||
}
|
||||
|
||||
@ -1478,7 +1478,7 @@ QRect QPageSize::rectPixels(int resolution) const
|
||||
|
||||
QString QPageSize::key(PageSizeId pageSizeId)
|
||||
{
|
||||
if (pageSizeId < PageSizeId(0) || pageSizeId > LastPageSize)
|
||||
if (unsigned(pageSizeId) > unsigned(LastPageSize))
|
||||
return QString();
|
||||
return QString::fromUtf8(qt_pageSizes[pageSizeId].mediaOption);
|
||||
}
|
||||
@ -1497,7 +1497,7 @@ static QString msgImperialPageSizeInch(int width, int height)
|
||||
|
||||
QString QPageSize::name(PageSizeId pageSizeId)
|
||||
{
|
||||
if (pageSizeId < PageSizeId(0) || pageSizeId > LastPageSize)
|
||||
if (unsigned(pageSizeId) > unsigned(LastPageSize))
|
||||
return QString();
|
||||
|
||||
switch (pageSizeId) {
|
||||
|
@ -352,8 +352,6 @@ QTransform QTransform::transposed() const
|
||||
QTransform t(affine._m11, affine._m21, affine._dx,
|
||||
affine._m12, affine._m22, affine._dy,
|
||||
m_13, m_23, m_33, true);
|
||||
t.m_type = m_type;
|
||||
t.m_dirty = m_dirty;
|
||||
return t;
|
||||
}
|
||||
|
||||
|
@ -64,8 +64,6 @@ HeaderSize entry_size(const QByteArray &name, const QByteArray &value)
|
||||
const unsigned sum = unsigned(name.size()) + value.size();
|
||||
if (std::numeric_limits<unsigned>::max() - 32 < sum)
|
||||
return HeaderSize();
|
||||
if (sum + 32 > std::numeric_limits<quint32>::max())
|
||||
return HeaderSize();
|
||||
return HeaderSize(true, quint32(sum + 32));
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,7 @@ bool QNetmask::setAddress(const QHostAddress &address)
|
||||
int netmask = 0;
|
||||
quint8 *ptr = ip.v6;
|
||||
quint8 *end;
|
||||
length = -1;
|
||||
length = 255;
|
||||
|
||||
if (address.protocol() == QAbstractSocket::IPv4Protocol) {
|
||||
ip.v4 = qToBigEndian(address.toIPv4Address());
|
||||
|
@ -1005,7 +1005,7 @@ QSslConfiguration::NextProtocolNegotiationStatus QSslConfiguration::nextProtocol
|
||||
|
||||
\list
|
||||
\li no local certificate and no private key
|
||||
\li protocol SecureProtocols (meaning either TLS 1.0 or SSL 3 will be used)
|
||||
\li protocol \l{QSsl::SecureProtocols}{SecureProtocols}
|
||||
\li the system's default CA certificate list
|
||||
\li the cipher list equal to the list of the SSL libraries'
|
||||
supported SSL ciphers that are 128 bits or more
|
||||
|
@ -278,6 +278,8 @@ QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &fun
|
||||
return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic);
|
||||
else if (function == QWindowsWindowFunctions::setHasBorderInFullScreenIdentifier())
|
||||
return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenStatic);
|
||||
else if (function == QWindowsWindowFunctions::setWindowActivationBehaviorIdentifier())
|
||||
return QFunctionPointer(QWindowsNativeInterface::setWindowActivationBehavior);
|
||||
else if (function == QWindowsWindowFunctions::isTabletModeIdentifier())
|
||||
return QFunctionPointer(QWindowsNativeInterface::isTabletMode);
|
||||
return nullptr;
|
||||
|
@ -2201,6 +2201,15 @@ void QWindowsWindow::requestActivateWindow()
|
||||
foregroundThread = GetWindowThreadProcessId(foregroundWindow, NULL);
|
||||
if (foregroundThread && foregroundThread != currentThread)
|
||||
attached = AttachThreadInput(foregroundThread, currentThread, TRUE) == TRUE;
|
||||
if (attached) {
|
||||
if (!window()->flags().testFlag(Qt::WindowStaysOnBottomHint)
|
||||
&& !window()->flags().testFlag(Qt::WindowStaysOnTopHint)
|
||||
&& window()->type() != Qt::ToolTip) {
|
||||
const UINT swpFlags = SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER;
|
||||
SetWindowPos(m_data.hwnd, HWND_TOPMOST, 0, 0, 0, 0, swpFlags);
|
||||
SetWindowPos(m_data.hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, swpFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SetForegroundWindow(m_data.hwnd);
|
||||
|
@ -1845,9 +1845,9 @@ bool QIBaseDriver::subscribeToNotification(const QString &name)
|
||||
eBuffer->bufferLength,
|
||||
eBuffer->eventBuffer,
|
||||
#if defined (FB_API_VER) && FB_API_VER >= 20
|
||||
(ISC_EVENT_CALLBACK)qEventCallback,
|
||||
reinterpret_cast<ISC_EVENT_CALLBACK>(qEventCallback),
|
||||
#else
|
||||
(isc_callback)qEventCallback,
|
||||
reinterpret_cast<isc_callback>(qEventCallback),
|
||||
#endif
|
||||
eBuffer->resultBuffer);
|
||||
|
||||
@ -1925,9 +1925,9 @@ void QIBaseDriver::qHandleEventNotification(void *updatedResultBuffer)
|
||||
eBuffer->bufferLength,
|
||||
eBuffer->eventBuffer,
|
||||
#if defined (FB_API_VER) && FB_API_VER >= 20
|
||||
(ISC_EVENT_CALLBACK)qEventCallback,
|
||||
reinterpret_cast<ISC_EVENT_CALLBACK>(qEventCallback),
|
||||
#else
|
||||
(isc_callback)qEventCallback,
|
||||
reinterpret_cast<isc_callback>(qEventCallback),
|
||||
#endif
|
||||
eBuffer->resultBuffer);
|
||||
if (Q_UNLIKELY(status[0] == 1 && status[1])) {
|
||||
|
@ -1675,13 +1675,13 @@ QRectF QMacStylePrivate::comboboxEditBounds(const QRectF &outerBounds, const Coc
|
||||
} else if (cw.type == Button_PopupButton) {
|
||||
switch (cw.size) {
|
||||
case QStyleHelper::SizeLarge:
|
||||
ret.adjust(14, 1, -23, -4);
|
||||
ret.adjust(10, 1, -23, -4);
|
||||
break;
|
||||
case QStyleHelper::SizeSmall:
|
||||
ret.adjust(13, 4, -20, -3);
|
||||
ret.adjust(10, 4, -20, -3);
|
||||
break;
|
||||
case QStyleHelper::SizeMini:
|
||||
ret.adjust(12, 0, -19, 0);
|
||||
ret.adjust(9, 0, -19, 0);
|
||||
ret.setHeight(13);
|
||||
break;
|
||||
default:
|
||||
@ -2826,7 +2826,8 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
|
||||
#if QT_CONFIG(toolbutton)
|
||||
if (const QToolButton *tb = qobject_cast<const QToolButton *>(w)) {
|
||||
// When stroking the arrow, make sure it fits in the tool button
|
||||
if (tb->arrowType() != Qt::NoArrow)
|
||||
if (tb->arrowType() != Qt::NoArrow
|
||||
|| tb->popupMode() == QToolButton::MenuButtonPopup)
|
||||
halfSize -= penWidth;
|
||||
}
|
||||
#endif
|
||||
@ -5865,11 +5866,11 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
|
||||
#endif
|
||||
case CC_ToolButton:
|
||||
ret = QCommonStyle::subControlRect(cc, opt, sc, widget);
|
||||
if (sc == SC_ToolButtonMenu
|
||||
if (sc == SC_ToolButtonMenu) {
|
||||
#ifndef QT_NO_ACCESSIBILITY
|
||||
&& !QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar)
|
||||
if (QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ToolBar))
|
||||
ret.adjust(-toolButtonArrowMargin, 0, 0, 0);
|
||||
#endif
|
||||
) {
|
||||
ret.adjust(-1, 0, 0, 0);
|
||||
}
|
||||
break;
|
||||
@ -6107,6 +6108,9 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
|
||||
case CT_ToolButton:
|
||||
sz.rwidth() += 10;
|
||||
sz.rheight() += 10;
|
||||
if (const auto *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt))
|
||||
if (tb->features & QStyleOptionToolButton::Menu)
|
||||
sz.rwidth() += toolButtonArrowMargin;
|
||||
return sz;
|
||||
case CT_ComboBox:
|
||||
if (const auto *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
|
||||
|
@ -139,7 +139,7 @@ static const int NumEntries = sizeof(entries) / sizeof(entries[0]);
|
||||
*/
|
||||
const char * QTest::benchmarkMetricName(QBenchmarkMetric metric)
|
||||
{
|
||||
if (metric >= 0 && metric < QTest::NumEntries)
|
||||
if (unsigned(metric) < unsigned(QTest::NumEntries))
|
||||
return entries[metric].name;
|
||||
|
||||
return "";
|
||||
@ -151,7 +151,7 @@ const char * QTest::benchmarkMetricName(QBenchmarkMetric metric)
|
||||
*/
|
||||
const char * QTest::benchmarkMetricUnit(QBenchmarkMetric metric)
|
||||
{
|
||||
if (metric >= 0 && metric < QTest::NumEntries)
|
||||
if (unsigned(metric) < unsigned(QTest::NumEntries))
|
||||
return entries[metric].unit;
|
||||
|
||||
return "";
|
||||
|
@ -162,6 +162,7 @@
|
||||
#if QT_CONFIG(lineedit)
|
||||
#include "QtWidgets/qlineedit.h"
|
||||
#endif
|
||||
#include "QtCore/qdir.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -619,6 +619,8 @@ void QAbstractSpinBox::stepDown()
|
||||
function. Note that this function is called even if the resulting
|
||||
value will be outside the bounds of minimum and maximum. It's this
|
||||
function's job to handle these situations.
|
||||
|
||||
\sa stepUp(), stepDown(), keyPressEvent()
|
||||
*/
|
||||
|
||||
void QAbstractSpinBox::stepBy(int steps)
|
||||
@ -970,6 +972,8 @@ void QAbstractSpinBox::paintEvent(QPaintEvent *)
|
||||
\row \li Page down
|
||||
\li This will invoke stepBy(-10)
|
||||
\endtable
|
||||
|
||||
\sa stepBy()
|
||||
*/
|
||||
|
||||
|
||||
|
@ -1005,7 +1005,7 @@ Qt::DayOfWeek QCalendarModel::dayOfWeekForColumn(int column) const
|
||||
|
||||
int QCalendarModel::columnForDayOfWeek(Qt::DayOfWeek day) const
|
||||
{
|
||||
if (day < 1 || day > 7)
|
||||
if (day < 1 || unsigned(day) > unsigned(7))
|
||||
return -1;
|
||||
int column = (int)day - (int)m_firstDay;
|
||||
if (column < 0)
|
||||
|
4594
tests/auto/bic/data/QtConcurrent.5.11.0.linux-gcc-amd64.txt
Normal file
4594
tests/auto/bic/data/QtConcurrent.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
4542
tests/auto/bic/data/QtCore.5.11.0.linux-gcc-amd64.txt
Normal file
4542
tests/auto/bic/data/QtCore.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
4881
tests/auto/bic/data/QtDBus.5.11.0.linux-gcc-amd64.txt
Normal file
4881
tests/auto/bic/data/QtDBus.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
8357
tests/auto/bic/data/QtGui.5.11.0.linux-gcc-amd64.txt
Normal file
8357
tests/auto/bic/data/QtGui.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
5379
tests/auto/bic/data/QtNetwork.5.11.0.linux-gcc-amd64.txt
Normal file
5379
tests/auto/bic/data/QtNetwork.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
19376
tests/auto/bic/data/QtOpenGL.5.11.0.linux-gcc-amd64.txt
Normal file
19376
tests/auto/bic/data/QtOpenGL.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
19627
tests/auto/bic/data/QtPrintSupport.5.11.0.linux-gcc-amd64.txt
Normal file
19627
tests/auto/bic/data/QtPrintSupport.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
4969
tests/auto/bic/data/QtSql.5.11.0.linux-gcc-amd64.txt
Normal file
4969
tests/auto/bic/data/QtSql.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
4639
tests/auto/bic/data/QtTest.5.11.0.linux-gcc-amd64.txt
Normal file
4639
tests/auto/bic/data/QtTest.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
19126
tests/auto/bic/data/QtWidgets.5.11.0.linux-gcc-amd64.txt
Normal file
19126
tests/auto/bic/data/QtWidgets.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
4982
tests/auto/bic/data/QtXml.5.11.0.linux-gcc-amd64.txt
Normal file
4982
tests/auto/bic/data/QtXml.5.11.0.linux-gcc-amd64.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -49,6 +49,8 @@ private slots:
|
||||
void matrix();
|
||||
void testOffset();
|
||||
void types();
|
||||
void types2_data();
|
||||
void types2();
|
||||
void scalarOps();
|
||||
void transform();
|
||||
void mapEmptyPath();
|
||||
@ -65,6 +67,7 @@ private:
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(QTransform)
|
||||
Q_DECLARE_METATYPE(QTransform::TransformationType)
|
||||
|
||||
void tst_QTransform::mapRect_data()
|
||||
{
|
||||
@ -568,6 +571,38 @@ void tst_QTransform::types()
|
||||
QCOMPARE(m5.type(), QTransform::TxScale);
|
||||
}
|
||||
|
||||
void tst_QTransform::types2_data()
|
||||
{
|
||||
QTest::addColumn<QTransform>("t1");
|
||||
QTest::addColumn<QTransform::TransformationType>("type");
|
||||
|
||||
QTest::newRow( "identity" ) << QTransform() << QTransform::TxNone;
|
||||
QTest::newRow( "translate" ) << QTransform().translate(10, -0.1) << QTransform::TxTranslate;
|
||||
QTest::newRow( "scale" ) << QTransform().scale(10, -0.1) << QTransform::TxScale;
|
||||
QTest::newRow( "rotate" ) << QTransform().rotate(10) << QTransform::TxRotate;
|
||||
QTest::newRow( "shear" ) << QTransform().shear(10, -0.1) << QTransform::TxShear;
|
||||
QTest::newRow( "project" ) << QTransform().rotate(10, Qt::XAxis) << QTransform::TxProject;
|
||||
QTest::newRow( "combined" ) << QTransform().translate(10, -0.1).scale(10, -0.1).rotate(10, Qt::YAxis) << QTransform::TxProject;
|
||||
}
|
||||
|
||||
void tst_QTransform::types2()
|
||||
{
|
||||
#define CHECKTXTYPE(func) { QTransform t2(func); \
|
||||
QTransform t3(t2.m11(), t2.m12(), t2.m13(), t2.m21(), t2.m22(), t2.m23(), t2.m31(), t2.m32(), t2.m33()); \
|
||||
QVERIFY2(t3.type() == t2.type(), #func); \
|
||||
}
|
||||
|
||||
QFETCH( QTransform, t1 );
|
||||
QFETCH( QTransform::TransformationType, type );
|
||||
|
||||
Q_ASSERT(t1.type() == type);
|
||||
|
||||
CHECKTXTYPE(t1.adjoint());
|
||||
CHECKTXTYPE(t1.inverted());
|
||||
CHECKTXTYPE(t1.transposed());
|
||||
|
||||
#undef CHECKTXTYPE
|
||||
}
|
||||
|
||||
void tst_QTransform::scalarOps()
|
||||
{
|
||||
|
@ -39,6 +39,10 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#ifndef GL_RGB10
|
||||
#define GL_RGB10 0x8052
|
||||
#endif
|
||||
|
||||
class tst_Lancelot : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -85,6 +89,8 @@ private slots:
|
||||
#ifndef QT_NO_OPENGL
|
||||
void testOpenGL_data();
|
||||
void testOpenGL();
|
||||
void testOpenGLBGR30_data();
|
||||
void testOpenGLBGR30();
|
||||
void testCoreOpenGL_data();
|
||||
void testCoreOpenGL();
|
||||
private:
|
||||
@ -279,6 +285,16 @@ void tst_Lancelot::testOpenGL()
|
||||
runTestSuite(OpenGL, QImage::Format_RGB32);
|
||||
}
|
||||
|
||||
void tst_Lancelot::testOpenGLBGR30_data()
|
||||
{
|
||||
tst_Lancelot::testOpenGL_data();
|
||||
}
|
||||
|
||||
void tst_Lancelot::testOpenGLBGR30()
|
||||
{
|
||||
runTestSuite(OpenGL, QImage::Format_BGR30);
|
||||
}
|
||||
|
||||
void tst_Lancelot::testCoreOpenGL_data()
|
||||
{
|
||||
if (!checkSystemCoreGLSupport())
|
||||
@ -329,6 +345,8 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
|
||||
QOpenGLFramebufferObjectFormat fmt;
|
||||
fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
|
||||
fmt.setSamples(4);
|
||||
if (format == QImage::Format_BGR30)
|
||||
fmt.setInternalTextureFormat(GL_RGB10);
|
||||
QOpenGLContext ctx;
|
||||
ctx.setFormat(contextFormat);
|
||||
QVERIFY(ctx.create());
|
||||
|
Loading…
Reference in New Issue
Block a user