Prevent using deprecated Qt features
This commit is contained in:
parent
4de0685c84
commit
2ae98f8ba4
|
@ -65,10 +65,10 @@ AboutDialog::AboutDialog(QWidget *parent, const QString &applicationName, const
|
|||
m_ui->creatorLabel->setText(tr("developed by %1").arg(creator.isEmpty() ? QApplication::organizationName() : creator));
|
||||
}
|
||||
m_ui->versionLabel->setText(version.isEmpty() ? QApplication::applicationVersion() : version);
|
||||
const auto &deps(dependencyVersions.size() ? dependencyVersions : ApplicationUtilities::dependencyVersions2);
|
||||
if (deps.size()) {
|
||||
const auto &deps(dependencyVersions.size() ? dependencyVersions : ApplicationUtilities::dependencyVersions);
|
||||
if (!deps.empty()) {
|
||||
QStringList linkedAgainst;
|
||||
linkedAgainst.reserve(deps.size());
|
||||
linkedAgainst.reserve(static_cast<int>(deps.size()));
|
||||
for (const auto &dependencyVersion : deps) {
|
||||
linkedAgainst << QString::fromUtf8(dependencyVersion);
|
||||
}
|
||||
|
@ -86,8 +86,7 @@ AboutDialog::AboutDialog(QWidget *parent, const QString &applicationName, const
|
|||
: new QGraphicsPixmapItem(QPixmap::fromImage(image));
|
||||
m_iconScene->addItem(item);
|
||||
m_ui->graphicsView->setScene(m_iconScene);
|
||||
setGeometry(QStyle::alignedRect(
|
||||
Qt::LeftToRight, Qt::AlignCenter, size(), parentWidget() ? parentWidget()->geometry() : QApplication::desktop()->availableGeometry()));
|
||||
centerWidget(this, parentWidget());
|
||||
}
|
||||
|
||||
AboutDialog::AboutDialog(QWidget *parent, const QString &applicationName, const QString &creator, const QString &version, const QString &website,
|
||||
|
|
|
@ -30,6 +30,9 @@ set(QT_REPOS ${ADDITIONAL_QT_REPOS} base)
|
|||
set(QT_MODULES ${ADDITIONAL_QT_MODULES} Core)
|
||||
set(KF_MODULES ${ADDITIONAL_KF_MODULES})
|
||||
|
||||
# disable deprecated features
|
||||
list(APPEND META_PRIVATE_COMPILE_DEFINITIONS QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000)
|
||||
|
||||
# allow specifying a custom directory for Qt plugins
|
||||
set(QT_PLUGIN_DIR "" CACHE STRING "specifies the directory to install Qt plugins")
|
||||
|
||||
|
|
|
@ -109,7 +109,11 @@ inline NotificationImage::NotificationImage(const QImage &image)
|
|||
, hasAlpha(image.hasAlphaChannel())
|
||||
, channels(image.isGrayscale() ? 1 : hasAlpha ? 4 : 3)
|
||||
, bitsPerSample(image.depth() / channels)
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
, data(reinterpret_cast<const char *>(image.bits()), static_cast<int>(image.sizeInBytes()))
|
||||
#else
|
||||
, data(reinterpret_cast<const char *>(image.bits()), image.byteCount())
|
||||
#endif
|
||||
, isValid(!image.isNull())
|
||||
{
|
||||
if (isValid) {
|
||||
|
|
|
@ -1,20 +1,22 @@
|
|||
#include "./dialogutils.h"
|
||||
|
||||
#if !defined(QT_UTILITIES_GUI_QTWIDGETS) && !defined(QT_UTILITIES_GUI_QTQUICK)
|
||||
#include <QCoreApplication>
|
||||
#else
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
#if defined(QT_UTILITIES_GUI_QTWIDGETS) || defined(QT_UTILITIES_GUI_QTQUICK)
|
||||
#include <QGuiApplication>
|
||||
#include <QPalette>
|
||||
#include <QStyle>
|
||||
#include <QWidget>
|
||||
#ifdef QT_UTILITIES_GUI_QTWIDGETS
|
||||
#endif
|
||||
|
||||
#if defined(QT_UTILITIES_GUI_QTWIDGETS)
|
||||
#include <QApplication>
|
||||
#include <QCursor>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
#include <QStyle>
|
||||
#include <QWidget>
|
||||
#endif
|
||||
#endif
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
namespace Dialogs {
|
||||
|
||||
|
@ -97,29 +99,44 @@ const QString &dialogStyle()
|
|||
|
||||
#ifdef QT_UTILITIES_GUI_QTWIDGETS
|
||||
|
||||
QRect availableScreenGeometryAtPoint(const QPoint &point)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
QScreen *const screen = QGuiApplication::screenAt(point);
|
||||
if (!screen) {
|
||||
return QRect();
|
||||
}
|
||||
return screen->availableGeometry();
|
||||
#else
|
||||
return QApplication::desktop()->availableGeometry(point);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Moves the specified \a widget in the middle of the (available) screen
|
||||
* area. If there are multiple
|
||||
* screens available, the screen where the cursor currently is located is
|
||||
* chosen.
|
||||
* area or \a parent if specified.
|
||||
*
|
||||
* If there are multiple screens available, the screen where the cursor currently
|
||||
* is located is chosen.
|
||||
*/
|
||||
void centerWidget(QWidget *widget)
|
||||
void centerWidget(QWidget *widget, const QWidget *parent)
|
||||
{
|
||||
widget->setGeometry(
|
||||
QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, widget->size(), QApplication::desktop()->availableGeometry(QCursor::pos())));
|
||||
widget->setGeometry(QStyle::alignedRect(
|
||||
Qt::LeftToRight, Qt::AlignCenter, widget->size(), parent ? parent->geometry() : availableScreenGeometryAtPoint(QCursor::pos())));
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Moves the specified \a widget to the corner which is closest to the
|
||||
* current cursor position.
|
||||
* If there are multiple screens available, the screen where the cursor
|
||||
* currently is located is chosen.
|
||||
*
|
||||
* If there are multiple screens available, the screen where the cursor currently
|
||||
* is located is chosen.
|
||||
*/
|
||||
void cornerWidget(QWidget *widget)
|
||||
{
|
||||
const QPoint cursorPos(QCursor::pos());
|
||||
const QRect availableGeometry(QApplication::desktop()->availableGeometry(cursorPos));
|
||||
Qt::Alignment alignment = 0;
|
||||
const QRect availableGeometry(availableScreenGeometryAtPoint(cursorPos));
|
||||
Qt::Alignment alignment = nullptr;
|
||||
alignment |= (cursorPos.x() - availableGeometry.left() < availableGeometry.right() - cursorPos.x() ? Qt::AlignLeft : Qt::AlignRight);
|
||||
alignment |= (cursorPos.y() - availableGeometry.top() < availableGeometry.bottom() - cursorPos.y() ? Qt::AlignTop : Qt::AlignBottom);
|
||||
widget->setGeometry(QStyle::alignedRect(Qt::LeftToRight, alignment, widget->size(), availableGeometry));
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
QT_FORWARD_DECLARE_CLASS(QString)
|
||||
QT_FORWARD_DECLARE_CLASS(QWidget)
|
||||
QT_FORWARD_DECLARE_CLASS(QColor)
|
||||
QT_FORWARD_DECLARE_CLASS(QPoint)
|
||||
QT_FORWARD_DECLARE_CLASS(QRect)
|
||||
|
||||
namespace Dialogs {
|
||||
|
||||
|
@ -33,7 +35,8 @@ QColor QT_UTILITIES_EXPORT instructionTextColor();
|
|||
#endif
|
||||
const QString QT_UTILITIES_EXPORT &dialogStyle();
|
||||
#ifdef QT_UTILITIES_GUI_QTWIDGETS
|
||||
void QT_UTILITIES_EXPORT centerWidget(QWidget *widget);
|
||||
QRect QT_UTILITIES_EXPORT availableScreenGeometryAtPoint(const QPoint &point);
|
||||
void QT_UTILITIES_EXPORT centerWidget(QWidget *widget, const QWidget *parent = nullptr);
|
||||
void QT_UTILITIES_EXPORT cornerWidget(QWidget *widget);
|
||||
void QT_UTILITIES_EXPORT makeHeading(QWidget *widget);
|
||||
void QT_UTILITIES_EXPORT updateStyle(QWidget *widget);
|
||||
|
|
Loading…
Reference in New Issue