Fix some deprecation warnings in basic plugins

Fix warnings apppearing in 5.13, for example:
warning: ‘QDir& QDir::operator=(const QString&)’ is deprecated: Use QDir::setPath() instead [-Wdeprecated-declarations]
...
warning: ‘static QRgb QColorDialog::getRgba(QRgb, bool*, QWidget*)’ is deprecated: Use getColor() [-Wdeprecated-declarations]
warning: ‘Qt::DropAction QDrag::start(Qt::DropActions)’ is deprecated: Use QDrag::exec() instead [-Wdeprecated-declarations]
warning: ‘void QProcess::finished(int)’ is deprecated: Use QProcess::finished(int, QProcess::ExitStatus) instead [-Wdeprecated-declarations]
...
warning: ‘const QRect QDesktopWidget::availableGeometry(int) const’ is deprecated: Use QGuiApplication::screens() [-Wdeprecated-declarations]
...
warning: ‘const QBrush& QPalette::background() const’ is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
...
warning: ‘const QBrush& QPalette::foreground() const’ is deprecated: Use QPalette::windowText() instead [-Wdeprecated-declarations]
...
warning: ‘void QTextOption::setTabStop(qreal)’ is deprecated [-Wdeprecated-declarations]
warning: ‘void QList<T>::swap(int, int) [with T = ProjectExplorer::BuildStep*]’ is deprecated: Use QList<T>::swapItemsAt() [-Wdeprecated-declarations]
warning: ‘void QProcess::setReadChannelMode(QProcess::ProcessChannelMode)’ is deprecated: Use QProcess::setProcessChannelMode() instead [-Wdeprecated-declarations]
...
warning: ‘QString QFileInfo::readLink() const’ is deprecated: Use QFileInfo::symLinkTarget() instead [-Wdeprecated-declarations]

Change-Id: I1d893d42d372245892f2de8406f52dbe7bbd552a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Friedemann Kleint
2019-02-11 10:17:53 +01:00
parent 77392c7dea
commit 963dc84cc5
29 changed files with 60 additions and 58 deletions

View File

@@ -482,7 +482,7 @@ void PluginDumper::runQmlDump(const QmlJS::ModelManagerInterface::ProjectInfo &i
process->setEnvironment(info.qmlDumpEnvironment.toStringList());
QString workingDir = wd.canonicalPath();
process->setWorkingDirectory(workingDir);
connect(process, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, &PluginDumper::qmlPluginTypeDumpDone);
connect(process, &QProcess::errorOccurred, this, &PluginDumper::qmlPluginTypeDumpError);
process->start(info.qmlDumpPath, arguments);

View File

@@ -119,7 +119,7 @@ SftpSession::SftpSession(const QStringList &connectionArgs) : d(new SftpSessionP
emit done(tr("sftp failed to start: %1").arg(d->sftpProc.errorString()));
}
});
connect(&d->sftpProc, static_cast<void (QProcess::*)(int)>(&QProcess::finished), [this] {
connect(&d->sftpProc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [this] {
d->state = State::Inactive;
if (d->sftpProc.exitStatus() != QProcess::NormalExit) {
emit done(tr("sftp crashed."));

View File

@@ -114,7 +114,7 @@ SftpTransfer::SftpTransfer(const FilesToTransfer &files, Internal::FileTransferT
if (error == QProcess::FailedToStart)
emitError(tr("sftp failed to start: %1").arg(d->sftpProc.errorString()));
});
connect(&d->sftpProc, static_cast<void (QProcess::*)(int)>(&QProcess::finished), [this] {
connect(&d->sftpProc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [this] {
if (d->sftpProc.exitStatus() != QProcess::NormalExit) {
emitError(tr("sftp crashed."));
return;

View File

@@ -202,7 +202,7 @@ SshConnection::SshConnection(const SshConnectionParameters &serverInfo, QObject
break; // Cannot happen.
}
});
connect(&d->masterProcess, static_cast<void (QProcess::*)(int)>(&QProcess::finished), [this] {
connect(&d->masterProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [this] {
if (d->state == Disconnecting) {
emitDisconnected();
return;

View File

@@ -93,7 +93,7 @@ static QPixmap segmentPixmap(CrumblePathButton::SegmentType type, QStyle::State
const QString pixmapKey = QStringLiteral("crumblePath-segment-%1-iconMode-%2-hover-%3")
.arg(segmentName).arg(iconMode).arg(hover);
QPixmap pixmap;
if (!QPixmapCache::find(pixmapKey, pixmap)) {
if (!QPixmapCache::find(pixmapKey, &pixmap)) {
const QString maskFileName = QStringLiteral(":/utils/images/crumblepath-segment-%1%2.png")
.arg(segmentName).arg(QLatin1String(hover ? "-hover" : ""));
pixmap = Icon({{maskFileName, Theme::IconsBaseColor}}).pixmap(iconMode);

View File

@@ -82,7 +82,7 @@ bool FileUtils::removeRecursively(const FileName &filePath, QString *error)
QFile::setPermissions(filePath.toString(), fileInfo.permissions() | QFile::WriteUser);
if (fileInfo.isDir()) {
QDir dir(filePath.toString());
dir = dir.canonicalPath();
dir.setPath(dir.canonicalPath());
if (dir.isRoot()) {
if (error) {
*error = QCoreApplication::translate("Utils::FileUtils",

View File

@@ -58,19 +58,11 @@ public:
void QtColorButtonPrivate::slotEditColor()
{
QColor newColor;
if (m_alphaAllowed) {
bool ok;
const QRgb rgba = QColorDialog::getRgba(m_color.rgba(), &ok, q_ptr);
if (!ok)
return;
newColor = QColor::fromRgba(rgba);
} else {
newColor = QColorDialog::getColor(m_color, q_ptr);
if (!newColor.isValid())
return;
}
if (newColor == q_ptr->color())
QColorDialog::ColorDialogOptions options;
if (m_alphaAllowed)
options |= QColorDialog::ShowAlphaChannel;
const QColor newColor = QColorDialog::getColor(m_color, q_ptr, QString(), options);
if (!newColor.isValid() || newColor == q_ptr->color())
return;
q_ptr->setColor(newColor);
emit q_ptr->colorChanged(m_color);
@@ -243,7 +235,7 @@ void QtColorButton::mouseMoveEvent(QMouseEvent *event)
drg->setPixmap(d_ptr->generatePixmap());
setDown(false);
event->accept();
drg->start();
drg->exec(Qt::CopyAction);
return;
}
#endif

View File

@@ -216,7 +216,7 @@ void StyleHelper::verticalGradient(QPainter *painter, const QRect &spanRect, con
clipRect.height(), keyColor.rgb());
QPixmap pixmap;
if (!QPixmapCache::find(key, pixmap)) {
if (!QPixmapCache::find(key, &pixmap)) {
pixmap = QPixmap(clipRect.size());
QPainter p(&pixmap);
QRect rect(0, 0, clipRect.width(), clipRect.height());
@@ -274,7 +274,7 @@ void StyleHelper::horizontalGradient(QPainter *painter, const QRect &spanRect, c
clipRect.height(), keyColor.rgb(), spanRect.x());
QPixmap pixmap;
if (!QPixmapCache::find(key, pixmap)) {
if (!QPixmapCache::find(key, &pixmap)) {
pixmap = QPixmap(clipRect.size());
QPainter p(&pixmap);
QRect rect = QRect(0, 0, clipRect.width(), clipRect.height());
@@ -312,7 +312,7 @@ void StyleHelper::drawArrow(QStyle::PrimitiveElement element, QPainter *painter,
QString pixmapName;
pixmapName.sprintf("StyleHelper::drawArrow-%d-%d-%d-%f",
element, size, enabled, devicePixelRatio);
if (!QPixmapCache::find(pixmapName, pixmap)) {
if (!QPixmapCache::find(pixmapName, &pixmap)) {
QImage image(size * devicePixelRatio, size * devicePixelRatio, QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::transparent);
QPainter painter(&image);
@@ -357,7 +357,7 @@ void StyleHelper::menuGradient(QPainter *painter, const QRect &spanRect, const Q
clipRect.height(), StyleHelper::baseColor().rgb());
QPixmap pixmap;
if (!QPixmapCache::find(key, pixmap)) {
if (!QPixmapCache::find(key, &pixmap)) {
pixmap = QPixmap(clipRect.size());
QPainter p(&pixmap);
QRect rect = QRect(0, 0, clipRect.width(), clipRect.height());
@@ -396,7 +396,7 @@ void StyleHelper::drawIconWithShadow(const QIcon &icon, const QRect &rect,
QString pixmapName = QString::fromLatin1("icon %0 %1 %2 %3")
.arg(icon.cacheKey()).arg(iconMode).arg(rect.height()).arg(devicePixelRatio);
if (!QPixmapCache::find(pixmapName, cache)) {
if (!QPixmapCache::find(pixmapName, &cache)) {
// High-dpi support: The in parameters (rect, radius, offset) are in
// device-independent pixels. The call to QIcon::pixmap() below might
// return a high-dpi pixmap, which will in that case have a devicePixelRatio

View File

@@ -132,8 +132,8 @@ void BookmarkDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
if (!m_selectedPixmap)
generateGradientPixmap(lwidth, fm.height()+1, backgroundColor, selected);
} else {
painter->setBrush(opt.palette.background().color());
backgroundColor = opt.palette.background().color();
backgroundColor = opt.palette.window().color();
painter->setBrush(backgroundColor);
if (!m_normalPixmap)
generateGradientPixmap(lwidth, fm.height(), backgroundColor, selected);
}

View File

@@ -385,7 +385,10 @@ private:
static int widthLimit()
{
return QApplication::desktop()->availableGeometry(QCursor::pos()).width() / 2;
auto screen = QGuiApplication::screenAt(QCursor::pos());
if (!screen)
screen = QGuiApplication::primaryScreen();
return screen->availableGeometry().width() / 2;
}
private:

View File

@@ -552,7 +552,7 @@ bool ShortcutSettingsWidget::markCollisions(ShortcutItem *item)
}
item->m_item->setForeground(2, hasCollision
? Utils::creatorTheme()->color(Utils::Theme::TextColorError)
: commandList()->palette().foreground());
: commandList()->palette().window());
return hasCollision;
}

View File

@@ -53,7 +53,7 @@ CppcheckRunner::CppcheckRunner(CppcheckTool &tool) :
this, &CppcheckRunner::readError);
connect(m_process, &QProcess::started,
this, &CppcheckRunner::handleStarted);
connect(m_process, QOverload<int>::of(&QProcess::finished),
connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, &CppcheckRunner::handleFinished);
m_queueTimer.setSingleShot(true);

View File

@@ -203,7 +203,7 @@ CdbEngine::CdbEngine() :
connect(action(CreateFullBacktrace), &QAction::triggered,
this, &CdbEngine::createFullBacktrace);
connect(&m_process, static_cast<void(QProcess::*)(int)>(&QProcess::finished),
connect(&m_process, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
this, &CdbEngine::processFinished);
connect(&m_process, &QProcess::errorOccurred, this, &CdbEngine::processError);
connect(&m_process, &QProcess::readyReadStandardOutput,

View File

@@ -105,7 +105,7 @@ public:
this, &LocalProcessRunner::handleStandardOutput);
connect(&m_proc, &QProcess::readyReadStandardError,
this, &LocalProcessRunner::handleStandardError);
connect(&m_proc, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
connect(&m_proc, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, &LocalProcessRunner::handleFinished);
}
@@ -213,7 +213,7 @@ private:
}
m_coreUnpackProcess.setWorkingDirectory(TemporaryDirectory::masterDirectoryPath());
connect(&m_coreUnpackProcess, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
connect(&m_coreUnpackProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, &CoreUnpacker::reportStarted);
const QString msg = DebuggerRunTool::tr("Unpacking core file to %1");

View File

@@ -62,6 +62,7 @@
#include <QDesktopWidget>
#include <QFileInfo>
#include <QLabel>
#include <QScreen>
#include <QScrollBar>
#include <QSortFilterProxyModel>
#include <QStack>
@@ -624,7 +625,10 @@ void DebuggerToolTipWidget::computeSize()
// touch the border of the screen.
QPoint pos(x(), y());
QTC_ASSERT(QApplication::desktop(), return);
QRect desktopRect = QApplication::desktop()->availableGeometry(pos);
auto screen = QGuiApplication::screenAt(pos);
if (!screen)
screen = QGuiApplication::primaryScreen();
QRect desktopRect = screen->availableGeometry();
const int maxWidth = desktopRect.right() - pos.x() - 5 - 5;
const int maxHeight = desktopRect.bottom() - pos.y() - 5 - 5;

View File

@@ -396,7 +396,7 @@ void SideDiffEditorWidget::paintSeparator(QPainter &painter,
if (!foreground.isValid())
foreground = m_textForeground;
if (!foreground.isValid())
foreground = palette().foreground().color();
foreground = palette().windowText().color();
painter.setPen(foreground);

View File

@@ -248,7 +248,7 @@ void ChangeSelectionDialog::recalculateDetails()
m_process->setWorkingDirectory(workingDir);
m_process->setProcessEnvironment(m_gitEnvironment);
connect(m_process, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, &ChangeSelectionDialog::setDetails);
m_process->start(m_gitExecutable.toString(), {"show", "--decorate", "--stat=80", ref});

View File

@@ -2386,7 +2386,7 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
process->start(binary, arguments);
success = process->waitForStarted();
if (success)
connect(process, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
connect(process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
process, &QProcess::deleteLater);
else
delete process;

View File

@@ -60,12 +60,13 @@ bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
m_process = new QProcess(this);
m_process->setWorkingDirectory(workingDirectory);
m_process->setProcessEnvironment(env);
m_process->setReadChannelMode(QProcess::MergedChannels);
m_process->setProcessChannelMode(QProcess::MergedChannels);
const Utils::FileName binary = GitPlugin::client()->vcsBinary();
VcsOutputWindow::appendCommand(workingDirectory, binary, arguments);
m_process->start(binary.toString(), arguments);
if (m_process->waitForStarted()) {
connect(m_process, static_cast<void (QProcess::*)(int)>(&QProcess::finished), this, &MergeTool::done);
connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, &MergeTool::done);
connect(m_process, &QIODevice::readyRead, this, &MergeTool::readData);
} else {
delete m_process;

View File

@@ -127,9 +127,9 @@ ApplicationLauncherPrivate::ApplicationLauncherPrivate(ApplicationLauncher *pare
: q(parent), m_outputCodec(QTextCodec::codecForLocale())
{
if (ProjectExplorerPlugin::projectExplorerSettings().mergeStdErrAndStdOut){
m_guiProcess.setReadChannelMode(QProcess::MergedChannels);
m_guiProcess.setProcessChannelMode(QProcess::MergedChannels);
} else {
m_guiProcess.setReadChannelMode(QProcess::SeparateChannels);
m_guiProcess.setProcessChannelMode(QProcess::SeparateChannels);
connect(&m_guiProcess, &QProcess::readyReadStandardError,
this, &ApplicationLauncherPrivate::readLocalStandardError);
}

View File

@@ -185,7 +185,7 @@ bool BuildStepList::removeStep(int position)
void BuildStepList::moveStepUp(int position)
{
m_steps.swap(position - 1, position);
m_steps.swapItemsAt(position - 1, position);
emit stepMoved(position, position - 1);
}

View File

@@ -40,7 +40,7 @@ DesktopDeviceProcess::DesktopDeviceProcess(const QSharedPointer<const IDevice> &
: DeviceProcess(device, parent)
{
connect(&m_process, &QProcess::errorOccurred, this, &DeviceProcess::error);
connect(&m_process, static_cast<void (QProcess::*)(int)>(&QProcess::finished),
connect(&m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
this, &DeviceProcess::finished);
connect(&m_process, &QProcess::readyReadStandardOutput,
this, &DeviceProcess::readyReadStandardOutput);

View File

@@ -758,8 +758,8 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
painter->setBrush(opt.palette.highlight().color());
backgroundColor = opt.palette.highlight().color();
} else {
painter->setBrush(opt.palette.background().color());
backgroundColor = opt.palette.background().color();
painter->setBrush(opt.palette.window().color());
backgroundColor = opt.palette.window().color();
}
painter->setPen(Qt::NoPen);
painter->drawRect(opt.rect);

View File

@@ -1098,7 +1098,7 @@ QString InternalLibraryDetailsController::snippet() const
QDir rootBuildDir = rootDir; // If the project is unconfigured use the project dir
if (ProjectExplorer::Target *t = project->activeTarget())
if (ProjectExplorer::BuildConfiguration *bc = t->activeBuildConfiguration())
rootBuildDir = bc->buildDirectory().toString();
rootBuildDir.setPath(bc->buildDirectory().toString());
// the project for which we insert the snippet inside build tree
QFileInfo pfi(rootBuildDir.filePath(proRelavitePath));

View File

@@ -1634,7 +1634,7 @@ FileName BaseQtVersion::mkspecFromVersionInfo(const QHash<ProKey, ProString> &ve
}
if (!qt5) {
//resolve mkspec link
QString rspec = mkspecFullPath.toFileInfo().readLink();
QString rspec = mkspecFullPath.toFileInfo().symLinkTarget();
if (!rspec.isEmpty())
mkspecFullPath = FileName::fromUserInput(
QDir(baseMkspecDir.toString()).absoluteFilePath(rspec));

View File

@@ -40,6 +40,7 @@
#include <QDesktopWidget>
#include <QKeyEvent>
#include <QPointer>
#include <QScreen>
namespace TextEditor {
@@ -366,9 +367,10 @@ void FunctionHintProposalWidget::updateContent()
void FunctionHintProposalWidget::updatePosition()
{
const QDesktopWidget *desktop = QApplication::desktop();
const int screenNumber = desktop->screenNumber(d->m_underlyingWidget);
auto widgetScreen = QGuiApplication::screens().value(screenNumber, QGuiApplication::primaryScreen());
const QRect &screen = Utils::HostOsInfo::isMacHost()
? desktop->availableGeometry(desktop->screenNumber(d->m_underlyingWidget))
: desktop->screenGeometry(desktop->screenNumber(d->m_underlyingWidget));
? widgetScreen->availableGeometry() : widgetScreen->geometry();
d->m_pager->setFixedWidth(d->m_pager->minimumSizeHint().width());

View File

@@ -254,16 +254,16 @@ QColor FormatDescription::defaultForeground(TextStyle id)
{
if (id == C_LINE_NUMBER) {
const QPalette palette = Utils::Theme::initialPalette();
const QColor bg = palette.background().color();
const QColor bg = palette.window().color();
if (bg.value() < 128)
return palette.foreground().color();
return palette.windowText().color();
else
return palette.dark().color();
} else if (id == C_CURRENT_LINE_NUMBER) {
const QPalette palette = Utils::Theme::initialPalette();
const QColor bg = palette.background().color();
const QColor bg = palette.window().color();
if (bg.value() < 128)
return palette.foreground().color();
return palette.windowText().color();
else
return QColor();
} else if (id == C_PARENTHESES) {
@@ -279,7 +279,7 @@ QColor FormatDescription::defaultBackground(TextStyle id)
if (id == C_TEXT) {
return Qt::white;
} else if (id == C_LINE_NUMBER) {
return Utils::Theme::initialPalette().background().color();
return Utils::Theme::initialPalette().window().color();
} else if (id == C_SEARCH_RESULT) {
return QColor(0xffef0b);
} else if (id == C_PARENTHESES) {

View File

@@ -431,7 +431,7 @@ struct PaintEventData
, searchResultFormat(fontSettings.toTextCharFormat(C_SEARCH_RESULT))
, visualWhitespaceFormat(fontSettings.toTextCharFormat(C_VISUAL_WHITESPACE))
, ifdefedOutFormat(fontSettings.toTextCharFormat(C_DISABLED_CODE))
, suppressSyntaxInIfdefedOutBlock(ifdefedOutFormat.foreground() != editor->palette().foreground())
, suppressSyntaxInIfdefedOutBlock(ifdefedOutFormat.foreground() != editor->palette().windowText())
{ }
QPointF offset;
const QRect viewportRect;
@@ -4719,7 +4719,7 @@ void TextEditorWidgetPrivate::paintWidgetBackground(const PaintEventData &data,
&& (q->centerOnScroll() || q->verticalScrollBar()->maximum() == q->verticalScrollBar()->minimum())) {
const QRect backGroundRect(QPoint(data.eventRect.left(), int(data.offset.y())),
data.eventRect.bottomRight());
painter.fillRect(backGroundRect, q->palette().background());
painter.fillRect(backGroundRect, q->palette().window());
}
}
@@ -8236,7 +8236,7 @@ void TextEditorWidgetPrivate::updateTabStops()
// to be set as an int. A work around is to access directly the QTextOption.
qreal charWidth = QFontMetricsF(q->font()).width(QLatin1Char(' '));
QTextOption option = q->document()->defaultTextOption();
option.setTabStop(charWidth * m_document->tabSettings().m_tabSize);
option.setTabStopDistance(charWidth * m_document->tabSettings().m_tabSize);
q->document()->setDefaultTextOption(option);
}

View File

@@ -346,7 +346,7 @@ void Visualization::setText(const QString &message)
d->m_scene.clear();
QGraphicsSimpleTextItem *textItem = d->m_scene.addSimpleText(message);
textItem->setBrush(palette().foreground());
textItem->setBrush(palette().windowText());
textItem->setPos((d->sceneWidth() - textItem->boundingRect().width()) / 2,
(d->sceneHeight() - textItem->boundingRect().height()) / 2);
textItem->setFlag(QGraphicsItem::ItemIgnoresTransformations);