Merge "Merge remote-tracking branch 'origin/5.11' into dev" into refs/staging/dev

bb10
Liang Qi 2018-06-08 07:46:35 +00:00 committed by The Qt Project
commit 49c9377421
183 changed files with 102479 additions and 977 deletions

View File

@ -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

View File

@ -62,7 +62,7 @@ class TorrentView : public QTreeWidget
public:
TorrentView(QWidget *parent = 0);
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
signals:
void fileDropped(const QString &fileName);
@ -702,12 +702,12 @@ void MainWindow::closeEvent(QCloseEvent *)
TorrentView::TorrentView(QWidget *parent)
: QTreeWidget(parent)
{
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
setAcceptDrops(true);
#endif
}
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
void TorrentView::dragMoveEvent(QDragMoveEvent *event)
{
// Accept file actions with a '.torrent' extension.

View File

@ -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;
}

View File

@ -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;

View File

@ -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());
}

View File

@ -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>&lt;b>Title:&lt;/b></string>
<layout class="QFormLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>&lt;b&gt;Title:&lt;/b&gt;</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>&lt;b>Author: &lt;/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>&lt;b>Genre:&lt;/b></string>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;b&gt;Author: &lt;/b&gt;</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>&lt;b>Year:&lt;/b></string>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;b&gt;Genre:&lt;/b&gt;</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>&lt;b&gt;Year:&lt;/b&gt;</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>&lt;b>Rating:&lt;/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>&lt;b&gt;Rating:&lt;/b&gt;</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>

View File

@ -13,7 +13,7 @@ SUBDIRS = \
simpleanchorlayout \
weatheranchorlayout
contains(DEFINES, QT_NO_CURSOR)|contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= dragdroprobot
contains(DEFINES, QT_NO_CURSOR)|!qtConfig(draganddrop): SUBDIRS -= dragdroprobot
qtHaveModule(opengl):!qtConfig(opengles.):!qtConfig(dynamicgl) {
SUBDIRS += boxes

View File

@ -20,5 +20,5 @@ SUBDIRS = addressbook \
spreadsheet \
stardelegate \
storageview
contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= puzzle
!qtConfig(draganddrop): SUBDIRS -= puzzle
!qtHaveModule(xml): SUBDIRS -= simpledommodel

View File

@ -50,8 +50,9 @@
//! [0]
#include "mainwindow.h"
#include <QtPlugin>
#include <QApplication>
#include <QtPlugin>
Q_IMPORT_PLUGIN(BasicToolsPlugin)

View File

@ -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) {

View File

@ -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

View File

@ -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);

View File

@ -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;
};

View File

@ -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);
}

View File

@ -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;
};

View File

@ -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));

View File

@ -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,

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

View File

@ -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"));
}

View File

@ -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;

View File

@ -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>

View File

@ -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"/>

View File

@ -26,5 +26,5 @@ qtHaveModule(gui):qtConfig(opengl): \
SUBDIRS += windowcontainer
contains(DEFINES, QT_NO_CURSOR): SUBDIRS -= mainwindows
contains(DEFINES, QT_NO_DRAGANDDROP): SUBDIRS -= draganddrop
!qtConfig(draganddrop): SUBDIRS -= draganddrop
mac:SUBDIRS += mac

View File

@ -1978,7 +1978,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
@ -2009,7 +2010,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}.")

View File

@ -39,26 +39,16 @@ exists($$_PRO_FILE_PWD_/examples/examples.pro) {
sub_examples.subdir = examples
sub_examples.target = sub-examples
contains(SUBDIRS, sub_src): sub_examples.depends = sub_src
examples_need_tools: sub_examples.depends += sub_tools
contains(SUBDIRS, sub_tools): sub_examples.depends += sub_tools
!contains(QT_BUILD_PARTS, examples): sub_examples.CONFIG = no_default_target no_default_install
SUBDIRS += sub_examples
}
# Some modules still have these
exists($$_PRO_FILE_PWD_/demos/demos.pro) {
sub_demos.subdir = demos
sub_demos.target = sub-demos
contains(SUBDIRS, sub_src): sub_demos.depends = sub_src
examples_need_tools: sub_demos.depends += sub_tools
!contains(QT_BUILD_PARTS, examples): sub_demos.CONFIG = no_default_target no_default_install
SUBDIRS += sub_demos
}
exists($$_PRO_FILE_PWD_/tests/tests.pro) {
sub_tests.subdir = tests
sub_tests.target = sub-tests
contains(SUBDIRS, sub_src): sub_tests.depends = sub_src # The tests may have a run-time only dependency on other parts
tests_need_tools: sub_tests.depends += sub_tools
contains(SUBDIRS, sub_tools): sub_tests.depends += sub_tools
sub_tests.CONFIG = no_default_install
!contains(QT_BUILD_PARTS, tests) {
sub_tests.CONFIG += no_default_target

View File

@ -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++) {

View File

@ -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;

View File

@ -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);

View File

@ -283,6 +283,7 @@ static void notifyAndFreeInfo(Header *header, ProcessInfo *entry,
freeInfo(header, entry);
}
static void reapChildProcesses();
static void sigchld_handler(int signum, siginfo_t *handler_info, void *handler_context)
{
/*
@ -307,19 +308,25 @@ static void sigchld_handler(int signum, siginfo_t *handler_info, void *handler_c
}
if (ffd_atomic_load(&forkfd_status, FFD_ATOMIC_RELAXED) == 1) {
/* is this one of our children? */
BigArray *array;
siginfo_t info;
struct pipe_payload payload;
int i;
int saved_errno = errno;
reapChildProcesses();
errno = saved_errno;
}
}
memset(&info, 0, sizeof info);
memset(&payload, 0, sizeof payload);
static inline void reapChildProcesses()
{
/* is this one of our children? */
BigArray *array;
siginfo_t info;
struct pipe_payload payload;
int i;
memset(&info, 0, sizeof info);
memset(&payload, 0, sizeof payload);
#ifdef HAVE_WAITID
if (!waitid_works)
goto search_arrays;
if (waitid_works) {
/* be optimistic: try to see if we can get the child that exited */
search_next_child:
/* waitid returns -1 ECHILD if there are no further children at all;
@ -371,12 +378,34 @@ search_next_child:
* belongs to one of the chained SIGCHLD handlers. However, there might be another
* child that exited and does belong to us, so we need to check each one individually.
*/
search_arrays:
}
#endif
for (i = 0; i < (int)sizeofarray(children.entries); ++i) {
int pid = ffd_atomic_load(&children.entries[i].pid, FFD_ATOMIC_ACQUIRE);
for (i = 0; i < (int)sizeofarray(children.entries); ++i) {
int pid = ffd_atomic_load(&children.entries[i].pid, FFD_ATOMIC_ACQUIRE);
if (pid <= 0)
continue;
#ifdef HAVE_WAITID
if (waitid_works) {
/* The child might have been reaped by the block above in another thread,
* so first check if it's ready and, if it is, lock it */
if (!isChildReady(pid, &info) ||
!ffd_atomic_compare_exchange(&children.entries[i].pid, &pid, -1,
FFD_ATOMIC_RELAXED, FFD_ATOMIC_RELAXED))
continue;
}
#endif
if (tryReaping(pid, &payload)) {
/* this is our child, send notification and free up this entry */
notifyAndFreeInfo(&children.header, &children.entries[i], &payload);
}
}
/* try the arrays */
array = ffd_atomic_load(&children.header.nextArray, FFD_ATOMIC_ACQUIRE);
while (array != NULL) {
for (i = 0; i < (int)sizeofarray(array->entries); ++i) {
int pid = ffd_atomic_load(&array->entries[i].pid, FFD_ATOMIC_ACQUIRE);
if (pid <= 0)
continue;
#ifdef HAVE_WAITID
@ -384,42 +413,18 @@ search_arrays:
/* The child might have been reaped by the block above in another thread,
* so first check if it's ready and, if it is, lock it */
if (!isChildReady(pid, &info) ||
!ffd_atomic_compare_exchange(&children.entries[i].pid, &pid, -1,
!ffd_atomic_compare_exchange(&array->entries[i].pid, &pid, -1,
FFD_ATOMIC_RELAXED, FFD_ATOMIC_RELAXED))
continue;
}
#endif
if (tryReaping(pid, &payload)) {
/* this is our child, send notification and free up this entry */
notifyAndFreeInfo(&children.header, &children.entries[i], &payload);
notifyAndFreeInfo(&array->header, &array->entries[i], &payload);
}
}
/* try the arrays */
array = ffd_atomic_load(&children.header.nextArray, FFD_ATOMIC_ACQUIRE);
while (array != NULL) {
for (i = 0; i < (int)sizeofarray(array->entries); ++i) {
int pid = ffd_atomic_load(&array->entries[i].pid, FFD_ATOMIC_ACQUIRE);
if (pid <= 0)
continue;
#ifdef HAVE_WAITID
if (waitid_works) {
/* The child might have been reaped by the block above in another thread,
* so first check if it's ready and, if it is, lock it */
if (!isChildReady(pid, &info) ||
!ffd_atomic_compare_exchange(&array->entries[i].pid, &pid, -1,
FFD_ATOMIC_RELAXED, FFD_ATOMIC_RELAXED))
continue;
}
#endif
if (tryReaping(pid, &payload)) {
/* this is our child, send notification and free up this entry */
notifyAndFreeInfo(&array->header, &array->entries[i], &payload);
}
}
array = ffd_atomic_load(&array->header.nextArray, FFD_ATOMIC_ACQUIRE);
}
array = ffd_atomic_load(&array->header.nextArray, FFD_ATOMIC_ACQUIRE);
}
}

View File

@ -940,6 +940,8 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
Rounds \a d to the nearest integer.
Rounds half up (e.g. 0.5 -> 1, -0.5 -> 0).
Example:
\snippet code/src_corelib_global_qglobal.cpp 11A
@ -950,6 +952,8 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
Rounds \a d to the nearest integer.
Rounds half up (e.g. 0.5f -> 1, -0.5f -> 0).
Example:
\snippet code/src_corelib_global_qglobal.cpp 11B
@ -960,6 +964,8 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
Rounds \a d to the nearest 64-bit integer.
Rounds half up (e.g. 0.5 -> 1, -0.5 -> 0).
Example:
\snippet code/src_corelib_global_qglobal.cpp 12A
@ -970,6 +976,8 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
Rounds \a d to the nearest 64-bit integer.
Rounds half up (e.g. 0.5f -> 1, -0.5f -> 0).
Example:
\snippet code/src_corelib_global_qglobal.cpp 12B
@ -4048,7 +4056,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);
@ -4059,7 +4067,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);

View File

@ -377,7 +377,7 @@ QStringList QFseventsFileSystemWatcherEngine::addPaths(const QStringList &paths,
for (PathRefCounts::const_iterator i = watchingState.watchedPaths.begin(),
ei = watchingState.watchedPaths.end(); i != ei; ++i) {
if (watchedPath.startsWith(i.key())) {
if (watchedPath.startsWith(i.key() % QDir::separator())) {
watchedPath = i.key();
break;
}

View File

@ -925,6 +925,8 @@ bool QProcessPrivate::startDetached(qint64 *pid)
closeChannel(&stdinChannel);
closeChannel(&stdoutChannel);
closeChannel(&stderrChannel);
qt_safe_close(pidPipe[0]);
qt_safe_close(pidPipe[1]);
qt_safe_close(startedPipe[0]);
qt_safe_close(startedPipe[1]);
return false;

View File

@ -162,6 +162,34 @@ QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool)
}
#endif // !QT_NO_DEBUG_STREAM
bool qt_apple_isApplicationExtension()
{
static bool isExtension = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSExtension"];
return isExtension;
}
#if !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WATCHOS)
AppleApplication *qt_apple_sharedApplication()
{
// Application extensions are not allowed to access the shared application
if (qt_apple_isApplicationExtension()) {
qWarning() << "accessing the shared" << [AppleApplication class]
<< "is not allowed in application extensions";
// In practice the application is actually available, but the the App
// review process will likely catch uses of it, so we return nil just
// in case, unless we don't care about being App Store compliant.
#if QT_CONFIG(appstore_compliant)
return nil;
#endif
}
// We use performSelector so that building with -fapplication-extension will
// not mistakenly think we're using the shared application in extensions.
return [[AppleApplication class] performSelector:@selector(sharedApplication)];
}
#endif
#ifdef Q_OS_MACOS
/*
Ensure that Objective-C objects auto-released in main(), directly or indirectly,

View File

@ -190,6 +190,20 @@ QDebug operator<<(QDebug debug, const QMacAutoReleasePool *pool);
#endif
Q_CORE_EXPORT void qt_apple_check_os_version();
Q_CORE_EXPORT bool qt_apple_isApplicationExtension();
#if !defined(QT_BOOTSTRAPPED) && !defined(Q_OS_WATCHOS)
QT_END_NAMESPACE
# if defined(Q_OS_MACOS)
Q_FORWARD_DECLARE_OBJC_CLASS(NSApplication);
using AppleApplication = NSApplication;
# else
Q_FORWARD_DECLARE_OBJC_CLASS(UIApplication);
using AppleApplication = UIApplication;
# endif
QT_BEGIN_NAMESPACE
Q_CORE_EXPORT AppleApplication *qt_apple_sharedApplication();
#endif
// --------------------------------------------------------------------------

View File

@ -90,17 +90,12 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(RunLoopModeTracker);
if ((self = [super init])) {
m_runLoopModes.push(kCFRunLoopDefaultMode);
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(receivedNotification:)
name:nil
#ifdef Q_OS_OSX
object:NSApplication.sharedApplication];
#elif defined(Q_OS_WATCHOS)
object:WKExtension.sharedExtension];
#else
// Use performSelector so this can work in an App Extension
object:[UIApplication.class performSelector:@selector(sharedApplication)]];
#if !defined(Q_OS_WATCHOS)
if (!qt_apple_isApplicationExtension()) {
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(receivedNotification:)
name:nil object:qt_apple_sharedApplication()];
}
#endif
}

View File

@ -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;

View 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

View File

@ -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

View File

@ -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.

View File

@ -53,6 +53,8 @@ qtConfig(future) {
}
win32 {
HEADERS += thread/qatomic_msvc.h
SOURCES += \
thread/qmutex_win.cpp \
thread/qthread_win.cpp \

View File

@ -107,7 +107,7 @@ Q_GLOBAL_STATIC(QSystemLocaleData, qSystemLocaleData)
#ifndef QT_NO_SYSTEMLOCALE
static bool contradicts(const QByteArray &maybe, const QByteArray &known)
static bool contradicts(const QString &maybe, const QString &known)
{
if (maybe.isEmpty())
return false;
@ -137,25 +137,25 @@ static bool contradicts(const QByteArray &maybe, const QByteArray &known)
QLocale QSystemLocale::fallbackUiLocale() const
{
// See man 7 locale for precedence - LC_ALL beats LC_MESSAGES beats LANG:
QByteArray lang = qgetenv("LC_ALL");
QString lang = qEnvironmentVariable("LC_ALL");
if (lang.isEmpty())
lang = qgetenv("LC_MESSAGES");
lang = qEnvironmentVariable("LC_MESSAGES");
if (lang.isEmpty())
lang = qgetenv("LANG");
lang = qEnvironmentVariable("LANG");
// if the locale is the "C" locale, then we can return the language we found here:
if (lang.isEmpty() || lang == QByteArray("C") || lang == QByteArray("POSIX"))
return QLocale(QString::fromLatin1(lang));
if (lang.isEmpty() || lang == QLatin1String("C") || lang == QLatin1String("POSIX"))
return QLocale(lang);
// ... otherwise, if the first part of LANGUAGE says more than or
// contradicts what we have, use that:
QByteArray language = qgetenv("LANGUAGE");
QString language = qEnvironmentVariable("LANGUAGE");
if (!language.isEmpty()) {
language = language.split(':').constFirst();
language = language.split(QLatin1Char(':')).constFirst();
if (contradicts(language, lang))
return QLocale(QString::fromLatin1(language));
return QLocale(language);
}
return QLocale(QString::fromLatin1(lang));
return QLocale(lang);
}
QVariant QSystemLocale::query(QueryType type, QVariant in) const

View File

@ -345,16 +345,24 @@ Q_DECL_RELAXED_CONSTEXPR inline QPointF &QPointF::operator*=(qreal c)
xp*=c; yp*=c; return *this;
}
QT_WARNING_PUSH
QT_WARNING_DISABLE_CLANG("-Wfloat-equal")
QT_WARNING_DISABLE_GCC("-Wfloat-equal")
Q_DECL_CONSTEXPR inline bool operator==(const QPointF &p1, const QPointF &p2)
{
return qFuzzyIsNull(p1.xp - p2.xp) && qFuzzyIsNull(p1.yp - p2.yp);
return ((!p1.xp && !p1.yp) || (!p2.xp && !p2.yp))
? (qFuzzyIsNull(p1.xp - p2.xp) && qFuzzyIsNull(p1.yp - p2.yp))
: (qFuzzyCompare(p1.xp, p2.xp) && qFuzzyCompare(p1.yp, p2.yp));
}
Q_DECL_CONSTEXPR inline bool operator!=(const QPointF &p1, const QPointF &p2)
{
return !qFuzzyIsNull(p1.xp - p2.xp) || !qFuzzyIsNull(p1.yp - p2.yp);
return !(p1 == p2);
}
QT_WARNING_POP
Q_DECL_CONSTEXPR inline const QPointF operator+(const QPointF &p1, const QPointF &p2)
{
return QPointF(p1.xp+p2.xp, p1.yp+p2.yp);

View File

@ -1414,7 +1414,7 @@ void QStandardItem::setTristate(bool tristate)
}
#endif
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
/*!
Sets whether the item is drag enabled. If \a dragEnabled is true, the item
@ -1472,7 +1472,7 @@ void QStandardItem::setDropEnabled(bool dropEnabled)
\sa setDropEnabled(), isDragEnabled(), flags()
*/
#endif // QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
/*!
Returns the row where the item is located in its parent's child table, or

View File

@ -179,7 +179,7 @@ public:
QT_DEPRECATED void setTristate(bool tristate);
#endif
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
inline bool isDragEnabled() const {
return (flags() & Qt::ItemIsDragEnabled) != 0;
}
@ -189,7 +189,7 @@ public:
return (flags() & Qt::ItemIsDropEnabled) != 0;
}
void setDropEnabled(bool dropEnabled);
#endif // QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
QStandardItem *parent() const;
int row() const;

View File

@ -13,7 +13,6 @@ HEADERS += \
kernel/qwindowsysteminterface.h \
kernel/qwindowsysteminterface_p.h \
kernel/qplatformintegration.h \
kernel/qplatformdrag.h \
kernel/qplatformscreen.h \
kernel/qplatformscreen_p.h \
kernel/qplatforminputcontext.h \
@ -33,8 +32,6 @@ HEADERS += \
kernel/qplatformclipboard.h \
kernel/qplatformnativeinterface.h \
kernel/qplatformmenu.h \
kernel/qshapedpixmapdndwindow_p.h \
kernel/qsimpledrag_p.h \
kernel/qsurfaceformat.h \
kernel/qguiapplication.h \
kernel/qguiapplication_p.h \
@ -46,12 +43,11 @@ HEADERS += \
kernel/qclipboard.h \
kernel/qcursor.h \
kernel/qcursor_p.h \
kernel/qdrag.h \
kernel/qdnd_p.h \
kernel/qevent.h \
kernel/qevent_p.h \
kernel/qinputmethod.h \
kernel/qinputmethod_p.h \
kernel/qinternalmimedata_p.h \
kernel/qkeysequence.h \
kernel/qkeysequence_p.h \
kernel/qkeymapper_p.h \
@ -89,7 +85,6 @@ SOURCES += \
kernel/qplatforminputcontextplugin.cpp \
kernel/qplatforminputcontext.cpp \
kernel/qplatformintegration.cpp \
kernel/qplatformdrag.cpp \
kernel/qplatformscreen.cpp \
kernel/qplatformintegrationfactory.cpp \
kernel/qplatformintegrationplugin.cpp \
@ -102,8 +97,6 @@ SOURCES += \
kernel/qplatformclipboard.cpp \
kernel/qplatformnativeinterface.cpp \
kernel/qsessionmanager.cpp \
kernel/qshapedpixmapdndwindow.cpp \
kernel/qsimpledrag.cpp \
kernel/qsurfaceformat.cpp \
kernel/qguiapplication.cpp \
kernel/qwindow.cpp \
@ -112,10 +105,9 @@ SOURCES += \
kernel/qsurface.cpp \
kernel/qclipboard.cpp \
kernel/qcursor.cpp \
kernel/qdrag.cpp \
kernel/qdnd.cpp \
kernel/qevent.cpp \
kernel/qinputmethod.cpp \
kernel/qinternalmimedata.cpp \
kernel/qkeysequence.cpp \
kernel/qkeymapper.cpp \
kernel/qpalette.cpp \
@ -138,6 +130,21 @@ SOURCES += \
kernel/qinputdevicemanager.cpp \
kernel/qhighdpiscaling.cpp
qtConfig(draganddrop) {
HEADERS += \
kernel/qdnd_p.h \
kernel/qdrag.h \
kernel/qplatformdrag.h \
kernel/qshapedpixmapdndwindow_p.h \
kernel/qsimpledrag_p.h
SOURCES += \
kernel/qdnd.cpp \
kernel/qdrag.cpp \
kernel/qplatformdrag.cpp \
kernel/qshapedpixmapdndwindow.cpp \
kernel/qsimpledrag.cpp
}
qtConfig(opengl) {
HEADERS += \

View File

@ -37,39 +37,19 @@
**
****************************************************************************/
#include "qplatformdefs.h"
#include "qbitmap.h"
#include "qdrag.h"
#include "qpixmap.h"
#include "qevent.h"
#include "qfile.h"
#include "qtextcodec.h"
#include "qguiapplication.h"
#include "qpoint.h"
#include "qbuffer.h"
#include "qimage.h"
#include "qpainter.h"
#include "qregexp.h"
#include "qdir.h"
#include "qdnd_p.h"
#include "qimagereader.h"
#include "qimagewriter.h"
#include "qdebug.h"
#include "qguiapplication.h"
#include <ctype.h>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformdrag.h>
#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
#ifndef QT_NO_DRAGANDDROP
QT_BEGIN_NAMESPACE
// the universe's only drag manager
QDragManager *QDragManager::m_instance = 0;
QDragManager::QDragManager()
: QObject(qApp), m_currentDropTarget(0),
m_platformDrag(QGuiApplicationPrivate::platformIntegration()->drag()),
@ -78,7 +58,6 @@ QDragManager::QDragManager()
Q_ASSERT(!m_instance);
}
QDragManager::~QDragManager()
{
m_instance = 0;
@ -142,196 +121,4 @@ Qt::DropAction QDragManager::drag(QDrag *o)
return result;
}
#endif // QT_NO_DRAGANDDROP
#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
static QStringList imageMimeFormats(const QList<QByteArray> &imageFormats)
{
QStringList formats;
formats.reserve(imageFormats.size());
for (const auto &format : imageFormats)
formats.append(QLatin1String("image/") + QLatin1String(format.toLower()));
//put png at the front because it is best
int pngIndex = formats.indexOf(QLatin1String("image/png"));
if (pngIndex != -1 && pngIndex != 0)
formats.move(pngIndex, 0);
return formats;
}
static inline QStringList imageReadMimeFormats()
{
return imageMimeFormats(QImageReader::supportedImageFormats());
}
static inline QStringList imageWriteMimeFormats()
{
return imageMimeFormats(QImageWriter::supportedImageFormats());
}
QInternalMimeData::QInternalMimeData()
: QMimeData()
{
}
QInternalMimeData::~QInternalMimeData()
{
}
bool QInternalMimeData::hasFormat(const QString &mimeType) const
{
bool foundFormat = hasFormat_sys(mimeType);
if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) {
QStringList imageFormats = imageReadMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
if ((foundFormat = hasFormat_sys(imageFormats.at(i))))
break;
}
}
return foundFormat;
}
QStringList QInternalMimeData::formats() const
{
QStringList realFormats = formats_sys();
if (!realFormats.contains(QLatin1String("application/x-qt-image"))) {
QStringList imageFormats = imageReadMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
if (realFormats.contains(imageFormats.at(i))) {
realFormats += QLatin1String("application/x-qt-image");
break;
}
}
}
return realFormats;
}
QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const
{
QVariant data = retrieveData_sys(mimeType, type);
if (mimeType == QLatin1String("application/x-qt-image")) {
if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) {
// try to find an image
QStringList imageFormats = imageReadMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
data = retrieveData_sys(imageFormats.at(i), type);
if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty()))
continue;
break;
}
}
// we wanted some image type, but all we got was a byte array. Convert it to an image.
if (data.type() == QVariant::ByteArray
&& (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap))
data = QImage::fromData(data.toByteArray());
} else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) {
QColor c;
QByteArray ba = data.toByteArray();
if (ba.size() == 8) {
ushort * colBuf = (ushort *)ba.data();
c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF),
qreal(colBuf[1]) / qreal(0xFFFF),
qreal(colBuf[2]) / qreal(0xFFFF),
qreal(colBuf[3]) / qreal(0xFFFF));
data = c;
} else {
qWarning("Qt: Invalid color format");
}
} else if (data.type() != type && data.type() == QVariant::ByteArray) {
// try to use mime data's internal conversion stuf.
QInternalMimeData *that = const_cast<QInternalMimeData *>(this);
that->setData(mimeType, data.toByteArray());
data = QMimeData::retrieveData(mimeType, type);
that->clear();
}
return data;
}
bool QInternalMimeData::canReadData(const QString &mimeType)
{
return imageReadMimeFormats().contains(mimeType);
}
// helper functions for rendering mimedata to the system, this is needed because QMimeData is in core.
QStringList QInternalMimeData::formatsHelper(const QMimeData *data)
{
QStringList realFormats = data->formats();
if (realFormats.contains(QLatin1String("application/x-qt-image"))) {
// add all supported image formats
QStringList imageFormats = imageWriteMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
if (!realFormats.contains(imageFormats.at(i)))
realFormats.append(imageFormats.at(i));
}
}
return realFormats;
}
bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data)
{
bool foundFormat = data->hasFormat(mimeType);
if (!foundFormat) {
if (mimeType == QLatin1String("application/x-qt-image")) {
// check all supported image formats
QStringList imageFormats = imageWriteMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
if ((foundFormat = data->hasFormat(imageFormats.at(i))))
break;
}
} else if (mimeType.startsWith(QLatin1String("image/"))) {
return data->hasImage() && imageWriteMimeFormats().contains(mimeType);
}
}
return foundFormat;
}
QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data)
{
QByteArray ba;
if (mimeType == QLatin1String("application/x-color")) {
/* QMimeData can only provide colors as QColor or the name
of a color as a QByteArray or a QString. So we need to do
the conversion to application/x-color here.
The application/x-color format is :
type: application/x-color
format: 16
data[0]: red
data[1]: green
data[2]: blue
data[3]: opacity
*/
ba.resize(8);
ushort * colBuf = (ushort *)ba.data();
QColor c = qvariant_cast<QColor>(data->colorData());
colBuf[0] = ushort(c.redF() * 0xFFFF);
colBuf[1] = ushort(c.greenF() * 0xFFFF);
colBuf[2] = ushort(c.blueF() * 0xFFFF);
colBuf[3] = ushort(c.alphaF() * 0xFFFF);
} else {
ba = data->data(mimeType);
if (ba.isEmpty()) {
if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) {
QImage image = qvariant_cast<QImage>(data->imageData());
QBuffer buf(&ba);
buf.open(QBuffer::WriteOnly);
// would there not be PNG ??
image.save(&buf, "PNG");
} else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) {
QImage image = qvariant_cast<QImage>(data->imageData());
QBuffer buf(&ba);
buf.open(QBuffer::WriteOnly);
image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper());
}
}
}
return ba;
}
#endif // QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD
QT_END_NAMESPACE

View File

@ -62,42 +62,17 @@
#include "QtCore/qpoint.h"
#include "private/qobject_p.h"
#include "QtGui/qbackingstore.h"
// ### Remove the following include, once everybody includes
// qinternalmimedata_p.h for QInternalMimeData.
#include "qinternalmimedata_p.h"
QT_REQUIRE_CONFIG(draganddrop);
QT_BEGIN_NAMESPACE
class QEventLoop;
class QMouseEvent;
class QPlatformDrag;
#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
class Q_GUI_EXPORT QInternalMimeData : public QMimeData
{
Q_OBJECT
public:
QInternalMimeData();
~QInternalMimeData();
bool hasFormat(const QString &mimeType) const override;
QStringList formats() const override;
static bool canReadData(const QString &mimeType);
static QStringList formatsHelper(const QMimeData *data);
static bool hasFormatHelper(const QString &mimeType, const QMimeData *data);
static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data);
protected:
QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override;
virtual bool hasFormat_sys(const QString &mimeType) const = 0;
virtual QStringList formats_sys() const = 0;
virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0;
};
#endif // !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
#ifndef QT_NO_DRAGANDDROP
class QDragPrivate : public QObjectPrivate
{
public:
@ -142,10 +117,6 @@ private:
Q_DISABLE_COPY(QDragManager)
};
#endif // !QT_NO_DRAGANDDROP
QT_END_NAMESPACE
#endif // QDND_P_H

View File

@ -45,8 +45,6 @@
#include <qpoint.h>
#include "qdnd_p.h"
#ifndef QT_NO_DRAGANDDROP
QT_BEGIN_NAMESPACE
/*!
@ -420,5 +418,3 @@ void QDrag::cancel()
*/
QT_END_NAMESPACE
#endif // QT_NO_DRAGANDDROP

View File

@ -43,10 +43,10 @@
#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
QT_REQUIRE_CONFIG(draganddrop);
QT_BEGIN_NAMESPACE
#ifndef QT_NO_DRAGANDDROP
class QMimeData;
class QDragPrivate;
class QPixmap;
@ -95,8 +95,6 @@ private:
Q_DISABLE_COPY(QDrag)
};
#endif // QT_NO_DRAGANDDROP
QT_END_NAMESPACE
#endif // QDRAG_H

View File

@ -42,16 +42,19 @@
#include "private/qguiapplication_p.h"
#include "private/qtouchdevice_p.h"
#include "qpa/qplatformintegration.h"
#include "qpa/qplatformdrag.h"
#include "private/qevent_p.h"
#include "qfile.h"
#include "qhashfunctions.h"
#include "qmetaobject.h"
#include "qmimedata.h"
#include "private/qdnd_p.h"
#include "qevent_p.h"
#include "qmath.h"
#if QT_CONFIG(draganddrop)
#include <qpa/qplatformdrag.h>
#include <private/qdnd_p.h>
#endif
#include <private/qdebug_p.h>
QT_BEGIN_NAMESPACE
@ -2920,7 +2923,7 @@ const QTouchDevice *QNativeGestureEvent::device() const
*/
#endif // QT_NO_GESTURES
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
/*!
Creates a QDragMoveEvent of the required \a type indicating
that the mouse is at position \a pos given within a widget.
@ -3264,7 +3267,7 @@ QDragLeaveEvent::QDragLeaveEvent()
QDragLeaveEvent::~QDragLeaveEvent()
{
}
#endif // QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
/*!
\class QHelpEvent
@ -3939,7 +3942,7 @@ static const char *eventClassName(QEvent::Type t)
return "QEvent";
}
# ifndef QT_NO_DRAGANDDROP
# if QT_CONFIG(draganddrop)
static void formatDropEvent(QDebug d, const QDropEvent *e)
{
@ -3960,7 +3963,7 @@ static void formatDropEvent(QDebug d, const QDropEvent *e)
QtDebugUtils::formatQFlags(d, e->mouseButtons());
}
# endif // !QT_NO_DRAGANDDROP
# endif // QT_CONFIG(draganddrop)
# if QT_CONFIG(tabletevent)
@ -4123,13 +4126,13 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
dbg << ')';
}
break;
# ifndef QT_NO_DRAGANDDROP
# if QT_CONFIG(draganddrop)
case QEvent::DragEnter:
case QEvent::DragMove:
case QEvent::Drop:
formatDropEvent(dbg, static_cast<const QDropEvent *>(e));
break;
# endif // !QT_NO_DRAGANDDROP
# endif // QT_CONFIG(draganddrop)
case QEvent::InputMethod:
formatInputMethodEvent(dbg, static_cast<const QInputMethodEvent *>(e));
break;

View File

@ -602,7 +602,7 @@ Q_DECLARE_TYPEINFO(QInputMethodQueryEvent::QueryPair, Q_MOVABLE_TYPE);
#endif // QT_NO_INPUTMETHOD
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
class QMimeData;
@ -675,7 +675,7 @@ public:
QDragLeaveEvent();
~QDragLeaveEvent();
};
#endif // QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
class Q_GUI_EXPORT QHelpEvent : public QEvent

View File

@ -50,7 +50,6 @@
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformtheme.h>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformdrag.h>
#include <QtCore/QAbstractEventDispatcher>
#include <QtCore/QStandardPaths>
@ -87,9 +86,13 @@
#include "private/qinputdevicemanager_p.h"
#include "private/qtouchdevice_p.h"
#include "private/qdnd_p.h"
#include <qpa/qplatformthemefactory_p.h>
#if QT_CONFIG(draganddrop)
#include <qpa/qplatformdrag.h>
#include <private/qdnd_p.h>
#endif
#ifndef QT_NO_CURSOR
#include <qpa/qplatformcursor.h>
#endif
@ -3037,7 +3040,7 @@ void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::E
QCoreApplication::sendSpontaneousEvent(window, &exposeEvent);
}
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
/*! \internal
@ -3146,7 +3149,7 @@ QPlatformDropQtResponse QGuiApplicationPrivate::processDrop(QWindow *w, const QM
return response;
}
#endif // QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
#ifndef QT_NO_CLIPBOARD
/*!
@ -3962,7 +3965,7 @@ void QGuiApplicationPrivate::notifyThemeChanged()
}
}
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag)
{
Q_UNUSED(drag)

View File

@ -70,9 +70,9 @@ class QColorProfile;
class QPlatformIntegration;
class QPlatformTheme;
class QPlatformDragQtResponse;
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
class QDrag;
#endif // QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
class QInputDeviceManager;
class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
@ -162,7 +162,7 @@ public:
static void processContextMenuEvent(QWindowSystemInterfacePrivate::ContextMenuEvent *e);
#endif
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
static QPlatformDragQtResponse processDrag(QWindow *w, const QMimeData *dropData,
const QPoint &p, Qt::DropActions supportedActions,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
@ -313,9 +313,9 @@ public:
protected:
virtual void notifyThemeChanged();
bool tryCloseRemainingWindows(QWindowList processedWindows);
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
virtual void notifyDragStarted(const QDrag *);
#endif // QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
private:
friend class QDragManager;

View File

@ -0,0 +1,234 @@
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtGui 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$
**
****************************************************************************/
#include "qinternalmimedata_p.h"
#include <QtCore/qbuffer.h>
#include <QtGui/qimage.h>
#include <QtGui/qimagereader.h>
#include <QtGui/qimagewriter.h>
QT_BEGIN_NAMESPACE
static QStringList imageMimeFormats(const QList<QByteArray> &imageFormats)
{
QStringList formats;
formats.reserve(imageFormats.size());
for (const auto &format : imageFormats)
formats.append(QLatin1String("image/") + QLatin1String(format.toLower()));
//put png at the front because it is best
int pngIndex = formats.indexOf(QLatin1String("image/png"));
if (pngIndex != -1 && pngIndex != 0)
formats.move(pngIndex, 0);
return formats;
}
static inline QStringList imageReadMimeFormats()
{
return imageMimeFormats(QImageReader::supportedImageFormats());
}
static inline QStringList imageWriteMimeFormats()
{
return imageMimeFormats(QImageWriter::supportedImageFormats());
}
QInternalMimeData::QInternalMimeData()
: QMimeData()
{
}
QInternalMimeData::~QInternalMimeData()
{
}
bool QInternalMimeData::hasFormat(const QString &mimeType) const
{
bool foundFormat = hasFormat_sys(mimeType);
if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) {
QStringList imageFormats = imageReadMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
if ((foundFormat = hasFormat_sys(imageFormats.at(i))))
break;
}
}
return foundFormat;
}
QStringList QInternalMimeData::formats() const
{
QStringList realFormats = formats_sys();
if (!realFormats.contains(QLatin1String("application/x-qt-image"))) {
QStringList imageFormats = imageReadMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
if (realFormats.contains(imageFormats.at(i))) {
realFormats += QLatin1String("application/x-qt-image");
break;
}
}
}
return realFormats;
}
QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const
{
QVariant data = retrieveData_sys(mimeType, type);
if (mimeType == QLatin1String("application/x-qt-image")) {
if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) {
// try to find an image
QStringList imageFormats = imageReadMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
data = retrieveData_sys(imageFormats.at(i), type);
if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty()))
continue;
break;
}
}
// we wanted some image type, but all we got was a byte array. Convert it to an image.
if (data.type() == QVariant::ByteArray
&& (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap))
data = QImage::fromData(data.toByteArray());
} else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) {
QColor c;
QByteArray ba = data.toByteArray();
if (ba.size() == 8) {
ushort * colBuf = (ushort *)ba.data();
c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF),
qreal(colBuf[1]) / qreal(0xFFFF),
qreal(colBuf[2]) / qreal(0xFFFF),
qreal(colBuf[3]) / qreal(0xFFFF));
data = c;
} else {
qWarning("Qt: Invalid color format");
}
} else if (data.type() != type && data.type() == QVariant::ByteArray) {
// try to use mime data's internal conversion stuf.
QInternalMimeData *that = const_cast<QInternalMimeData *>(this);
that->setData(mimeType, data.toByteArray());
data = QMimeData::retrieveData(mimeType, type);
that->clear();
}
return data;
}
bool QInternalMimeData::canReadData(const QString &mimeType)
{
return imageReadMimeFormats().contains(mimeType);
}
// helper functions for rendering mimedata to the system, this is needed because QMimeData is in core.
QStringList QInternalMimeData::formatsHelper(const QMimeData *data)
{
QStringList realFormats = data->formats();
if (realFormats.contains(QLatin1String("application/x-qt-image"))) {
// add all supported image formats
QStringList imageFormats = imageWriteMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
if (!realFormats.contains(imageFormats.at(i)))
realFormats.append(imageFormats.at(i));
}
}
return realFormats;
}
bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data)
{
bool foundFormat = data->hasFormat(mimeType);
if (!foundFormat) {
if (mimeType == QLatin1String("application/x-qt-image")) {
// check all supported image formats
QStringList imageFormats = imageWriteMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
if ((foundFormat = data->hasFormat(imageFormats.at(i))))
break;
}
} else if (mimeType.startsWith(QLatin1String("image/"))) {
return data->hasImage() && imageWriteMimeFormats().contains(mimeType);
}
}
return foundFormat;
}
QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data)
{
QByteArray ba;
if (mimeType == QLatin1String("application/x-color")) {
/* QMimeData can only provide colors as QColor or the name
of a color as a QByteArray or a QString. So we need to do
the conversion to application/x-color here.
The application/x-color format is :
type: application/x-color
format: 16
data[0]: red
data[1]: green
data[2]: blue
data[3]: opacity
*/
ba.resize(8);
ushort * colBuf = (ushort *)ba.data();
QColor c = qvariant_cast<QColor>(data->colorData());
colBuf[0] = ushort(c.redF() * 0xFFFF);
colBuf[1] = ushort(c.greenF() * 0xFFFF);
colBuf[2] = ushort(c.blueF() * 0xFFFF);
colBuf[3] = ushort(c.alphaF() * 0xFFFF);
} else {
ba = data->data(mimeType);
if (ba.isEmpty()) {
if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) {
QImage image = qvariant_cast<QImage>(data->imageData());
QBuffer buf(&ba);
buf.open(QBuffer::WriteOnly);
// would there not be PNG ??
image.save(&buf, "PNG");
} else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) {
QImage image = qvariant_cast<QImage>(data->imageData());
QBuffer buf(&ba);
buf.open(QBuffer::WriteOnly);
image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper());
}
}
}
return ba;
}
QT_END_NAMESPACE

View File

@ -0,0 +1,93 @@
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtGui 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 QINTERNALMIMEDATA_P_H
#define QINTERNALMIMEDATA_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtCore/qbytearray.h>
#include <QtCore/qmimedata.h>
#include <QtCore/qstring.h>
#include <QtCore/qstringlist.h>
#include <QtCore/qvariant.h>
#include <QtGui/private/qtguiglobal_p.h>
QT_BEGIN_NAMESPACE
class QEventLoop;
class QMouseEvent;
class QPlatformDrag;
class Q_GUI_EXPORT QInternalMimeData : public QMimeData
{
Q_OBJECT
public:
QInternalMimeData();
~QInternalMimeData();
bool hasFormat(const QString &mimeType) const override;
QStringList formats() const override;
static bool canReadData(const QString &mimeType);
static QStringList formatsHelper(const QMimeData *data);
static bool hasFormatHelper(const QString &mimeType, const QMimeData *data);
static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data);
protected:
QVariant retrieveData(const QString &mimeType, QVariant::Type type) const override;
virtual bool hasFormat_sys(const QString &mimeType) const = 0;
virtual QStringList formats_sys() const = 0;
virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0;
};
QT_END_NAMESPACE
#endif // QINTERNALMIMEDATA_P_H

View File

@ -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];

View File

@ -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

View File

@ -46,7 +46,6 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_DRAGANDDROP
#ifdef QDND_DEBUG
# include <QtCore/QDebug>
#endif
@ -222,6 +221,4 @@ bool QPlatformDrag::ownsDragObject() const
return false;
}
#endif // QT_NO_DRAGANDDROP
QT_END_NAMESPACE

View File

@ -52,9 +52,9 @@
#include <QtGui/qtguiglobal.h>
#include <QtGui/QPixmap>
QT_BEGIN_NAMESPACE
QT_REQUIRE_CONFIG(draganddrop);
#ifndef QT_NO_DRAGANDDROP
QT_BEGIN_NAMESPACE
class QMimeData;
class QMouseEvent;
@ -112,8 +112,6 @@ private:
Q_DISABLE_COPY(QPlatformDrag)
};
#endif // QT_NO_DRAGANDDROP
QT_END_NAMESPACE
#endif

View File

@ -45,8 +45,11 @@
#include <qpa/qplatformtheme.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qpixmap_raster_p.h>
#if QT_CONFIG(draganddrop)
#include <private/qdnd_p.h>
#include <private/qsimpledrag_p.h>
#endif
#ifndef QT_NO_SESSIONMANAGER
# include <qpa/qplatformsessionmanager.h>
@ -92,7 +95,7 @@ QPlatformClipboard *QPlatformIntegration::clipboard() const
#endif
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
/*!
Accessor for the platform integration's drag object.
@ -107,7 +110,7 @@ QPlatformDrag *QPlatformIntegration::drag() const
}
return drag;
}
#endif
#endif // QT_CONFIG(draganddrop)
QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
{

View File

@ -130,7 +130,7 @@ public:
#ifndef QT_NO_CLIPBOARD
virtual QPlatformClipboard *clipboard() const;
#endif
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
virtual QPlatformDrag *drag() const;
#endif
virtual QPlatformInputContext *inputContext() const;

View File

@ -55,6 +55,8 @@
#include <QtGui/QRasterWindow>
#include <QtGui/QPixmap>
QT_REQUIRE_CONFIG(draganddrop);
QT_BEGIN_NAMESPACE
class QShapedPixmapWindow : public QRasterWindow

View File

@ -68,8 +68,6 @@
QT_BEGIN_NAMESPACE
#ifndef QT_NO_DRAGANDDROP
Q_LOGGING_CATEGORY(lcDnd, "qt.gui.dnd")
static QWindow* topLevelAt(const QPoint &pos)
@ -449,6 +447,4 @@ void QSimpleDrag::drop(const QPoint &nativeGlobalPos, Qt::MouseButtons buttons,
}
}
#endif // QT_NO_DRAGANDDROP
QT_END_NAMESPACE

View File

@ -56,9 +56,9 @@
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
QT_REQUIRE_CONFIG(draganddrop);
#ifndef QT_NO_DRAGANDDROP
QT_BEGIN_NAMESPACE
class QMouseEvent;
class QWindow;
@ -136,8 +136,6 @@ protected:
virtual void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
};
#endif // QT_NO_DRAGANDDROP
QT_END_NAMESPACE
#endif

View File

@ -55,7 +55,9 @@
# include "qaccessible.h"
#endif
#include "qhighdpiscaling_p.h"
#if QT_CONFIG(draganddrop)
#include "qshapedpixmapdndwindow_p.h"
#endif // QT_CONFIG(draganddrop)
#include <private/qevent_p.h>
@ -383,7 +385,11 @@ void QWindowPrivate::setVisible(bool visible)
QGuiApplicationPrivate::hideModalWindow(q);
// QShapedPixmapWindow is used on some platforms for showing a drag pixmap, so don't block
// input to this window as it is performing a drag - QTBUG-63846
} else if (visible && QGuiApplication::modalWindow() && !qobject_cast<QShapedPixmapWindow *>(q)) {
} else if (visible && QGuiApplication::modalWindow()
#if QT_CONFIG(draganddrop)
&& !qobject_cast<QShapedPixmapWindow *>(q)
#endif // QT_CONFIG(draganddrop)
) {
QGuiApplicationPrivate::updateBlockedStatus(q);
}

View File

@ -43,12 +43,15 @@
#include "private/qevent_p.h"
#include "private/qtouchdevice_p.h"
#include <QAbstractEventDispatcher>
#include <qpa/qplatformdrag.h>
#include <qpa/qplatformintegration.h>
#include <qdebug.h>
#include "qhighdpiscaling_p.h"
#include <QtCore/qscopedvaluerollback.h>
#if QT_CONFIG(draganddrop)
#include <qpa/qplatformdrag.h>
#endif
QT_BEGIN_NAMESPACE
@ -791,7 +794,7 @@ void QWindowSystemInterface::handleThemeChange(QWindow *window)
QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
}
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
#if QT_DEPRECATED_SINCE(5, 11)
QPlatformDragQtResponse QWindowSystemInterface::handleDrag(QWindow *window, const QMimeData *dropData,
const QPoint &p, Qt::DropActions supportedActions)
@ -831,7 +834,7 @@ QPlatformDropQtResponse QWindowSystemInterface::handleDrop(QWindow *window, cons
auto pos = QHighDpi::fromNativeLocalPosition(p, window);
return QGuiApplicationPrivate::processDrop(window, dropData, pos, supportedActions, buttons, modifiers);
}
#endif // QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
/*!
\fn static QWindowSystemInterface::handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result)

View File

@ -215,7 +215,7 @@ public:
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
static void handleApplicationStateChanged(Qt::ApplicationState newState, bool forcePropagate = false);
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
#if QT_DEPRECATED_SINCE(5, 11)
QT_DEPRECATED static QPlatformDragQtResponse handleDrag(QWindow *window, const QMimeData *dropData,
const QPoint &p, Qt::DropActions supportedActions);
@ -228,7 +228,7 @@ public:
static QPlatformDropQtResponse handleDrop(QWindow *window, const QMimeData *dropData,
const QPoint &p, Qt::DropActions supportedActions,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
#endif // QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
static bool handleNativeEvent(QWindow *window, const QByteArray &eventType, void *message, long *result);

View File

@ -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);
}

View File

@ -188,6 +188,12 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
TexBufferRange = 0;
TextureView = 0;
// OpenGL ES 3.1+ has TexStorage2DMultisample
if (ctx->format().version() >= qMakePair(3, 1)) {
QOpenGLExtraFunctionsPrivate *extra = static_cast<QOpenGLExtensions *>(context->extraFunctions())->d();
TexStorage2DMultisample = extra->f.TexStorage2DMultisample;
}
#endif
if (context->isOpenGLES() && context->hasExtension(QByteArrayLiteral("GL_OES_texture_3D"))) {

View File

@ -3216,8 +3216,8 @@ static const QRgba64 *QT_FASTCALL fetchTransformedBilinear64(QRgba64 *buffer, co
int y1 = qFloor(py);
int y2;
distxs[i] = qFloor((px - x1) * (1<<16));
distys[i] = qFloor((py - y1) * (1<<16));
distxs[i] = int((px - x1) * (1<<16));
distys[i] = int((py - y1) * (1<<16));
fetchTransformedBilinear_pixelBounds<blendType>(image.width, image.x1, image.x2 - 1, x1, x2);
fetchTransformedBilinear_pixelBounds<blendType>(image.height, image.y1, image.y2 - 1, y1, y2);

View File

@ -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) {

View File

@ -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;
}

View File

@ -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));
}

View File

@ -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());

View File

@ -1026,7 +1026,7 @@ void QSslConfiguration::setDtlsCookieVerificationEnabled(bool enable)
\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

View File

@ -46,6 +46,7 @@
#include <private/qsimpledrag_p.h>
#include <QtGui/private/qdnd_p.h>
#include <QtGui/private/qinternalmimedata_p.h>
QT_BEGIN_NAMESPACE

View File

@ -567,7 +567,7 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask));
if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) {
NSWindowCollectionBehavior behavior = m_view.window.collectionBehavior;
if (flags & Qt::WindowFullscreenButtonHint) {
if ((flags & Qt::WindowFullscreenButtonHint) || m_view.window.qt_fullScreen) {
behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
behavior &= ~NSWindowCollectionBehaviorFullScreenAuxiliary;
} else {

View File

@ -40,6 +40,7 @@
#include "qnswindowdelegate.h"
#include "qcocoahelpers.h"
#include "qcocoawindow.h"
#include "qcocoascreen.h"
#include <QDebug>
#include <QtCore/private/qcore_mac_p.h>
@ -72,15 +73,24 @@ static QRegExp whitespaceRegex = QRegExp(QStringLiteral("\\s*"));
Overridden to ensure that the zoomed state always results in a maximized
window, which would otherwise not be the case for borderless windows.
*/
- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)newFrame
- (NSRect)windowWillUseStandardFrame:(NSWindow *)window defaultFrame:(NSRect)proposedFrame
{
Q_UNUSED(newFrame);
// We explicitly go through the QScreen API here instead of just using
// window.screen.visibleFrame directly, as that ensures we have the same
// behavior for both use-cases/APIs.
Q_UNUSED(proposedFrame);
Q_ASSERT(window == m_cocoaWindow->nativeWindow());
return NSRectFromCGRect(m_cocoaWindow->screen()->availableGeometry().toCGRect());
// We compute the maximized state based on the maximum size, and
// the current position of the window. This may result in the window
// geometry falling outside of the current screen's available geometry,
// e.g. when there is not maximize size set, but this is okey, AppKit
// will then shift and possibly clip the geometry for us.
const QWindow *w = m_cocoaWindow->window();
QRect maximizedRect = QRect(w->framePosition(), w->maximumSize());
// QWindow::maximumSize() refers to the client size,
// but AppKit expects the full frame size.
maximizedRect.adjust(0, 0, 0, w->frameMargins().top());
return QCocoaScreen::mapToNative(maximizedRect);
}
- (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu

View File

@ -44,6 +44,7 @@
#include <qpa/qwindowsysteminterface.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/private/qcore_mac_p.h>
#include <QtGui/private/qguiapplication_p.h>
@ -57,7 +58,13 @@ static void qRegisterApplicationStateNotifications()
// Map between notifications and corresponding application state. Note that
// there's no separate notification for moving to UIApplicationStateInactive,
// so we use UIApplicationWillResignActiveNotification as an intermediate.
static QMap<NSNotificationName, UIApplicationState> notifications {
using NotificationMap = QMap<NSNotificationName, UIApplicationState>;
static auto notifications = qt_apple_isApplicationExtension() ? NotificationMap{
{ NSExtensionHostWillEnterForegroundNotification, UIApplicationStateInactive },
{ NSExtensionHostDidBecomeActiveNotification, UIApplicationStateActive },
{ NSExtensionHostWillResignActiveNotification, UIApplicationStateInactive },
{ NSExtensionHostDidEnterBackgroundNotification, UIApplicationStateBackground },
} : NotificationMap{
{ UIApplicationWillEnterForegroundNotification, UIApplicationStateInactive },
{ UIApplicationDidBecomeActiveNotification, UIApplicationStateActive },
{ UIApplicationWillResignActiveNotification, UIApplicationStateInactive },
@ -73,16 +80,24 @@ static void qRegisterApplicationStateNotifications()
}];
}
// Initialize correct startup state, which may not be the Qt default (inactive)
UIApplicationState startupState = [UIApplication sharedApplication].applicationState;
QIOSApplicationState::handleApplicationStateChanged(startupState, QLatin1String("Application loaded"));
if (qt_apple_isApplicationExtension()) {
// Extensions are not allowed to access UIApplication, so we assume the state is active
QIOSApplicationState::handleApplicationStateChanged(UIApplicationStateActive,
QLatin1String("Extension loaded, assuming state is active"));
} else {
// Initialize correct startup state, which may not be the Qt default (inactive)
UIApplicationState startupState = [UIApplication sharedApplication].applicationState;
QIOSApplicationState::handleApplicationStateChanged(startupState, QLatin1String("Application loaded"));
}
}
Q_CONSTRUCTOR_FUNCTION(qRegisterApplicationStateNotifications)
QIOSApplicationState::QIOSApplicationState()
{
UIApplicationState startupState = [UIApplication sharedApplication].applicationState;
QIOSApplicationState::handleApplicationStateChanged(startupState, QLatin1String("Application launched"));
if (!qt_apple_isApplicationExtension()) {
UIApplicationState startupState = [UIApplication sharedApplication].applicationState;
QIOSApplicationState::handleApplicationStateChanged(startupState, QLatin1String("Application launched"));
}
}
void QIOSApplicationState::handleApplicationStateChanged(UIApplicationState uiState, const QString &reason)

View File

@ -41,7 +41,9 @@
#define QOFFSCREENCOMMON_H
#include <qpa/qplatformbackingstore.h>
#if QT_CONFIG(draganddrop)
#include <qpa/qplatformdrag.h>
#endif
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformscreen.h>
#include <qpa/qplatformwindow.h>
@ -71,7 +73,7 @@ public:
QScopedPointer<QPlatformCursor> m_cursor;
};
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
class QOffscreenDrag : public QPlatformDrag
{
public:

View File

@ -109,7 +109,7 @@ QOffscreenIntegration::QOffscreenIntegration()
m_fontDatabase.reset(new QFreeTypeFontDatabase());
#endif
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
m_drag.reset(new QOffscreenDrag);
#endif
m_services.reset(new QPlatformServices);
@ -204,7 +204,7 @@ QPlatformFontDatabase *QOffscreenIntegration::fontDatabase() const
return m_fontDatabase.data();
}
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
QPlatformDrag *QOffscreenIntegration::drag() const
{
return m_drag.data();

View File

@ -59,7 +59,7 @@ public:
QPlatformWindow *createPlatformWindow(QWindow *window) const override;
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
QPlatformDrag *drag() const override;
#endif
@ -76,7 +76,7 @@ public:
private:
QScopedPointer<QPlatformFontDatabase> m_fontDatabase;
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
QScopedPointer<QPlatformDrag> m_drag;
#endif
QScopedPointer<QPlatformInputContext> m_inputContext;

View File

@ -155,7 +155,7 @@ QQnxIntegration::QQnxIntegration(const QStringList &paramList)
, m_clipboard(0)
#endif
, m_navigator(0)
#if !defined(QT_NO_DRAGANDDROP)
#if QT_CONFIG(draganddrop)
, m_drag(new QSimpleDrag())
#endif
{
@ -232,7 +232,7 @@ QQnxIntegration::~QQnxIntegration()
qIntegrationDebug("platform plugin shutdown begin");
delete m_nativeInterface;
#if !defined(QT_NO_DRAGANDDROP)
#if QT_CONFIG(draganddrop)
// Destroy the drag object
delete m_drag;
#endif
@ -439,7 +439,7 @@ QPlatformClipboard *QQnxIntegration::clipboard() const
}
#endif
#if !defined(QT_NO_DRAGANDDROP)
#if QT_CONFIG(draganddrop)
QPlatformDrag *QQnxIntegration::drag() const
{
return m_drag;

View File

@ -113,7 +113,7 @@ public:
#if !defined(QT_NO_CLIPBOARD)
QPlatformClipboard *clipboard() const override;
#endif
#if !defined(QT_NO_DRAGANDDROP)
#if QT_CONFIG(draganddrop)
QPlatformDrag *drag() const override;
#endif
QVariant styleHint(StyleHint hint) const override;
@ -158,7 +158,7 @@ private:
mutable QQnxClipboard* m_clipboard;
#endif
QQnxAbstractNavigator *m_navigator;
#if !defined(QT_NO_DRAGANDDROP)
#if QT_CONFIG(draganddrop)
QSimpleDrag *m_drag;
#endif
static QQnxWindowMapper ms_windowMapper;

View File

@ -56,6 +56,7 @@
#include <QtGui/qrasterwindow.h>
#include <QtGui/qguiapplication.h>
#include <qpa/qwindowsysteminterface_p.h>
#include <QtGui/private/qdnd_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>

View File

@ -45,6 +45,7 @@
#include <qpa/qplatformdrag.h>
#include <QtGui/qpixmap.h>
#include <QtGui/qdrag.h>
struct IDropTargetHelper;

View File

@ -552,7 +552,7 @@ QPlatformDrag *QWindowsIntegration::drag() const
{
return &d->m_drag;
}
# endif // !QT_NO_DRAGANDDROP
# endif // QT_CONFIG(draganddrop)
#endif // !QT_NO_CLIPBOARD
QPlatformInputContext * QWindowsIntegration::inputContext() const

View File

@ -42,7 +42,7 @@
#include <QtCore/qt_windows.h>
#include <QtGui/private/qdnd_p.h> // QInternalMime
#include <QtGui/private/qinternalmimedata_p.h>
#include <QtCore/qvariant.h>
QT_BEGIN_NAMESPACE

View File

@ -40,7 +40,7 @@
#include "qwindowsmime.h"
#include "qwindowscontext.h"
#include <QtGui/private/qdnd_p.h>
#include <QtGui/private/qinternalmimedata_p.h>
#include <QtCore/qbytearraymatcher.h>
#include <QtCore/qtextcodec.h>
#include <QtCore/qmap.h>
@ -1255,7 +1255,7 @@ bool QBuiltInMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData
} else {
#if QT_CONFIG(draganddrop)
data = QInternalMimeData::renderDataHelper(outFormats.value(getCf(formatetc)), mimeData);
#endif //QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
}
return setData(data, pmedium);
}
@ -1363,7 +1363,7 @@ bool QLastResortMimes::canConvertFromMime(const FORMATETC &formatetc, const QMim
Q_UNUSED(formatetc);
return formatetc.tymed & TYMED_HGLOBAL
&& formats.contains(formatetc.cfFormat);
#endif //QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
}
bool QLastResortMimes::convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM * pmedium) const
@ -1376,7 +1376,7 @@ bool QLastResortMimes::convertFromMime(const FORMATETC &formatetc, const QMimeDa
Q_UNUSED(formatetc);
Q_UNUSED(pmedium);
return false;
#endif //QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
}
QVector<FORMATETC> QLastResortMimes::formatsForMime(const QString &mimeType, const QMimeData * /*mimeData*/) const
@ -1484,7 +1484,7 @@ QString QLastResortMimes::mimeForFormat(const FORMATETC &formatetc) const
format = clipFormat;
}
}
#endif //QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
}
return format;
@ -1559,7 +1559,7 @@ QVector<FORMATETC> QWindowsMimeConverter::allFormatsForMime(const QMimeData *mim
{
ensureInitialized();
QVector<FORMATETC> formatics;
#ifdef QT_NO_DRAGANDDROP
#if !QT_CONFIG(draganddrop)
Q_UNUSED(mimeData);
#else
formatics.reserve(20);
@ -1568,7 +1568,7 @@ QVector<FORMATETC> QWindowsMimeConverter::allFormatsForMime(const QMimeData *mim
for (int i = m_mimes.size() - 1; i >= 0; --i)
formatics += m_mimes.at(i)->formatsForMime(formats.at(f), mimeData);
}
#endif //QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
return formatics;
}

View File

@ -277,6 +277,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;

View File

@ -1278,7 +1278,7 @@ void QWindowsWindow::setDropSiteEnabled(bool dropEnabled)
RevokeDragDrop(m_data.hwnd);
m_dropTarget = 0;
}
#endif // !QT_NO_CLIPBOARD && !QT_NO_DRAGANDDROP
#endif // QT_CONFIG(clipboard) && QT_CONFIG(draganddrop)
}
// Returns topmost QWindowsWindow ancestor even if there are embedded windows in the chain.
@ -2241,6 +2241,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);

View File

@ -41,7 +41,8 @@
#include <QtCore/QLoggingCategory>
#include <QtCore/QMimeData>
#include <QtGui/private/qdnd_p.h> // QInternalMime
#include <QtGui/private/qdnd_p.h>
#include <QtGui/private/qinternalmimedata_p.h>
#include <wrl.h>

View File

@ -47,7 +47,7 @@
#include "qwinrteglcontext.h"
#include "qwinrttheme.h"
#include "qwinrtclipboard.h"
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
#include "qwinrtdrag.h"
#endif
#if QT_CONFIG(accessibility)
@ -317,12 +317,12 @@ QPlatformClipboard *QWinRTIntegration::clipboard() const
return d->clipboard;
}
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
QPlatformDrag *QWinRTIntegration::drag() const
{
return QWinRTDrag::instance();
}
#endif // QT_NO_DRAGANDDROP
#endif // QT_CONFIG(draganddrop)
#if QT_CONFIG(accessibility)
QPlatformAccessibility *QWinRTIntegration::accessibility() const

View File

@ -97,7 +97,7 @@ public:
QPlatformInputContext *inputContext() const override;
QPlatformServices *services() const override;
QPlatformClipboard *clipboard() const override;
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
QPlatformDrag *drag() const override;
#endif
#if QT_CONFIG(accessibility)

View File

@ -42,7 +42,7 @@
#include "qwinrtbackingstore.h"
#include "qwinrtinputcontext.h"
#include "qwinrtcursor.h"
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
#include "qwinrtdrag.h"
#endif
#include "qwinrtwindow.h"
@ -568,7 +568,7 @@ QWinRTScreen::QWinRTScreen()
hr = d->canvas.As(&uiElement);
Q_ASSERT_SUCCEEDED(hr);
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
QWinRTDrag::instance()->setUiElement(uiElement);
#endif
hr = window->put_Content(uiElement.Get());
@ -852,7 +852,7 @@ void QWinRTScreen::addWindow(QWindow *window)
handleExpose();
QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
QWinRTDrag::instance()->setDropTarget(window);
#endif
}
@ -872,7 +872,7 @@ void QWinRTScreen::removeWindow(QWindow *window)
if (wasTopWindow && type != Qt::Popup && type != Qt::ToolTip && type != Qt::Tool)
QWindowSystemInterface::handleWindowActivated(nullptr, Qt::OtherFocusReason);
QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ExcludeUserInputEvents);
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
if (wasTopWindow)
QWinRTDrag::instance()->setDropTarget(topWindow());
#endif

View File

@ -16,7 +16,6 @@ SOURCES = \
qwinrtcanvas.cpp \
qwinrtclipboard.cpp \
qwinrtcursor.cpp \
qwinrtdrag.cpp \
qwinrteglcontext.cpp \
qwinrteventdispatcher.cpp \
qwinrtfiledialoghelper.cpp \
@ -35,7 +34,6 @@ HEADERS = \
qwinrtcanvas.h \
qwinrtclipboard.h \
qwinrtcursor.h \
qwinrtdrag.h \
qwinrteglcontext.h \
qwinrteventdispatcher.h \
qwinrtfiledialoghelper.h \
@ -55,9 +53,9 @@ WINRT_SDK_VERSION = $$member($$list($$split(WINRT_SDK_VERSION_STRING, .)), 2)
lessThan(WINRT_SDK_VERSION, 14322): DEFINES += QT_WINRT_LIMITED_DRAGANDDROP
greaterThan(WINRT_SDK_VERSION, 14393): DEFINES += QT_WINRT_DISABLE_PHONE_COLORS
contains(DEFINES, QT_NO_DRAGANDDROP) {
SOURCES -= qwinrtdrag.cpp
HEADERS -= qwinrtdrag.h
qtConfig(draganddrop) {
SOURCES += qwinrtdrag.cpp
HEADERS += qwinrtdrag.h
}
qtConfig(accessibility): include($$PWD/uiautomation/uiautomation.pri)

View File

@ -46,7 +46,9 @@
#include "qxcbscreen.h"
#include "qxcbwindow.h"
#include "qxcbclipboard.h"
#if QT_CONFIG(draganddrop)
#include "qxcbdrag.h"
#endif
#include "qxcbwmsupport.h"
#include "qxcbnativeinterface.h"
#include "qxcbintegration.h"
@ -608,7 +610,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra
#ifndef QT_NO_CLIPBOARD
m_clipboard = new QXcbClipboard(this);
#endif
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
m_drag = new QXcbDrag(this);
#endif
@ -652,7 +654,7 @@ QXcbConnection::~QXcbConnection()
#ifndef QT_NO_CLIPBOARD
delete m_clipboard;
#endif
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
delete m_drag;
#endif
if (m_reader && m_reader->isRunning()) {
@ -1143,7 +1145,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
#if QT_CONFIG(draganddrop) || QT_CONFIG(clipboard)
xcb_selection_request_event_t *sr = reinterpret_cast<xcb_selection_request_event_t *>(event);
#endif
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
if (sr->selection == atom(QXcbAtom::XdndSelection))
m_drag->handleSelectionRequest(sr);
else
@ -1779,7 +1781,7 @@ void QXcbConnection::handleClientMessageEvent(const xcb_client_message_event_t *
if (event->format != 32)
return;
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
if (event->type == atom(QXcbAtom::XdndStatus)) {
drag()->handleStatus(event);
} else if (event->type == atom(QXcbAtom::XdndFinished)) {

View File

@ -411,7 +411,7 @@ public:
#ifndef QT_NO_CLIPBOARD
QXcbClipboard *clipboard() const { return m_clipboard; }
#endif
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
QXcbDrag *drag() const { return m_drag; }
#endif
@ -653,7 +653,7 @@ private:
#ifndef QT_NO_CLIPBOARD
QXcbClipboard *m_clipboard = nullptr;
#endif
#ifndef QT_NO_DRAGANDDROP
#if QT_CONFIG(draganddrop)
QXcbDrag *m_drag = nullptr;
#endif
QScopedPointer<QXcbWMSupport> m_wmSupport;

Some files were not shown because too many files have changed in this diff Show More