mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
Fixing deprecation for future Qt 6 support (#3962)
* Replace foreach * Replace QRegExp with QRegularExpression * Replace QApplication::fontMetrics * Replace QColor::isValidColor * Replace canConvert(QVariant) * Replace QString::midRef and QCharRef * Add TODO for replacing QDesktopWidget for Qt 6 * Add TODO for replacing QTextCodec for Qt 6 * Fix QWidget::enterEvent for Qt 6 * qRegisterMetaTypeStreamOperators done automatically in Qt 6 * Fix QWidget::mapToGlobal for Qt 6 * Migrate QDesktopWidget replacement from old qt6 branch * Drop Qt 5 support
This commit is contained in:
@@ -36,6 +36,15 @@ set(PROJECT_NAME_CAPITALIZED "Flameshot")
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
#Must be set before fetching external content
|
||||
#QT_DEFAULT_MAJOR_VERSION used by "SingleApplication"
|
||||
#QT_VERSION_MAJOR used by Flameshot and "QtColorWidgets"
|
||||
set(QT_DEFAULT_MAJOR_VERSION 6 CACHE STRING "")
|
||||
set(QT_VERSION_MAJOR 6 CACHE STRING "")
|
||||
|
||||
#Needed due to linker error with QtColorWidget
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
FetchContent_Declare(
|
||||
qtColorWidgets
|
||||
GIT_REPOSITORY https://gitlab.com/mattbas/Qt-Color-Widgets.git
|
||||
@@ -120,7 +129,7 @@ if(USE_EXTERNAL_SINGLEAPPLICATION)
|
||||
# package dev-qt/qtsingleapplication provides no symlink to current version
|
||||
set(qtsingleapplication_libs libQt5Solutions_SingleApplication-2.6 Qt5Solutions_SingleApplication-2.6)
|
||||
find_library(QTSINGLEAPPLICATION_LIBRARY NAMES ${qtsingleapplication_libs})
|
||||
message(STATUS "Using external SingleApplication library")
|
||||
message(STATUS "Using external QtSingleApplication library")
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
singleApplication
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
find_package(
|
||||
Qt5
|
||||
Qt${QT_VERSION_MAJOR}
|
||||
CONFIG
|
||||
REQUIRED
|
||||
Core
|
||||
Core5Compat
|
||||
Gui
|
||||
Widgets
|
||||
Network
|
||||
Svg
|
||||
DBus
|
||||
LinguistTools)
|
||||
LinguistTools
|
||||
Core5Compat #To be removed once QTextCodec has been replaced with the equivalent in Qt 6
|
||||
)
|
||||
|
||||
if (USE_WAYLAND_CLIPBOARD)
|
||||
find_package(KF5GuiAddons)
|
||||
@@ -136,9 +139,9 @@ set(FLAMESHOT_TS_FILES
|
||||
)
|
||||
|
||||
if (GENERATE_TS)
|
||||
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${FLAMESHOT_TS_FILES})
|
||||
qt6_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${FLAMESHOT_TS_FILES})
|
||||
else ()
|
||||
qt5_add_translation(QM_FILES ${FLAMESHOT_TS_FILES})
|
||||
qt6_add_translation(QM_FILES ${FLAMESHOT_TS_FILES})
|
||||
endif ()
|
||||
|
||||
target_sources(
|
||||
@@ -210,13 +213,13 @@ target_link_libraries(
|
||||
flameshot
|
||||
project_warnings
|
||||
project_options
|
||||
Qt5::Svg
|
||||
Qt5::DBus
|
||||
Qt5::Network
|
||||
Qt5::Widgets
|
||||
Qt${QT_VERSION_MAJOR}::Svg
|
||||
Qt${QT_VERSION_MAJOR}::DBus
|
||||
Qt${QT_VERSION_MAJOR}::Network
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
Qt${QT_VERSION_MAJOR}::Core5Compat #To be removed once QTextCodec has been replaced with the equivalent in Qt 6
|
||||
${QTSINGLEAPPLICATION_LIBRARY}
|
||||
QtColorWidgets
|
||||
|
||||
)
|
||||
|
||||
if (USE_WAYLAND_CLIPBOARD)
|
||||
|
||||
@@ -170,7 +170,11 @@ void ColorPickerEditor::updatePreset()
|
||||
|
||||
void ColorPickerEditor::onAddPreset()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
||||
if (QColor::isValidColor(m_colorInput->text())) {
|
||||
#else
|
||||
if (QColor::isValidColorName(m_colorInput->text())) {
|
||||
#endif
|
||||
m_color = QColor(m_colorInput->text());
|
||||
m_colorInput->setText(m_color.name(QColor::HexRgb));
|
||||
} else {
|
||||
@@ -196,7 +200,11 @@ void ColorPickerEditor::onDeletePreset()
|
||||
|
||||
void ColorPickerEditor::onUpdatePreset()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
||||
if (QColor::isValidColor(m_colorEdit->text())) {
|
||||
#else
|
||||
if (QColor::isValidColorName(m_colorEdit->text())) {
|
||||
#endif
|
||||
QColor c = QColor(m_colorEdit->text());
|
||||
m_colorEdit->setText(c.name(QColor::HexRgb));
|
||||
} else {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <QSizePolicy>
|
||||
#include <QSpinBox>
|
||||
#include <QStandardPaths>
|
||||
#include <QTextCodec>
|
||||
#include <QTextCodec> // TODO: Qt 6 - Replace QTextCodec with Qt 6 solution; temporary include Core5Compat
|
||||
#include <QVBoxLayout>
|
||||
|
||||
GeneralConf::GeneralConf(QWidget* parent)
|
||||
@@ -188,6 +188,8 @@ void GeneralConf::importConfiguration()
|
||||
return;
|
||||
}
|
||||
QFile file(fileName);
|
||||
// TODO: Qt 6 - Replace QTextCodec with Qt 6 solution
|
||||
// Temporary: Include Core5Compat when compiling with Qt 6
|
||||
QTextCodec* codec = QTextCodec::codecForLocale();
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
QMessageBox::about(this, tr("Error"), tr("Unable to read file."));
|
||||
@@ -566,7 +568,7 @@ void GeneralConf::initSaveAfterCopy()
|
||||
m_setSaveAsFileExtension = new QComboBox(this);
|
||||
|
||||
QStringList imageFormatList;
|
||||
foreach (auto mimeType, QImageWriter::supportedImageFormats())
|
||||
for (const auto& mimeType : QImageWriter::supportedImageFormats())
|
||||
imageFormatList.append(mimeType);
|
||||
|
||||
m_setSaveAsFileExtension->addItems(imageFormatList);
|
||||
|
||||
@@ -7,21 +7,18 @@
|
||||
#include "src/core/qguiappcurrentscreen.h"
|
||||
#include "src/utils/globalvalues.h"
|
||||
#include "toolfactory.h"
|
||||
#include <QCursor>
|
||||
#include <QHeaderView>
|
||||
#include <QIcon>
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QRect>
|
||||
#include <QScreen>
|
||||
#include <QStringList>
|
||||
#include <QTableWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QVector>
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
#include <QCursor>
|
||||
#include <QRect>
|
||||
#include <QScreen>
|
||||
#endif
|
||||
|
||||
ShortcutsWidget::ShortcutsWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
@@ -29,12 +26,10 @@ ShortcutsWidget::ShortcutsWidget(QWidget* parent)
|
||||
setWindowIcon(QIcon(GlobalValues::iconPath()));
|
||||
setWindowTitle(tr("Hot Keys"));
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
QRect position = frameGeometry();
|
||||
QScreen* screen = QGuiAppCurrentScreen().currentScreen();
|
||||
position.moveCenter(screen->availableGeometry().center());
|
||||
move(position.topLeft());
|
||||
#endif
|
||||
|
||||
m_layout = new QVBoxLayout(this);
|
||||
m_layout->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
|
||||
@@ -19,7 +19,7 @@ UIcolorEditor::UIcolorEditor(QWidget* parent)
|
||||
m_hLayout = new QHBoxLayout;
|
||||
m_vLayout = new QVBoxLayout;
|
||||
|
||||
const int space = QApplication::fontMetrics().lineSpacing();
|
||||
const int space = QFontMetrics(qApp->font()).lineSpacing();
|
||||
m_hLayout->addItem(new QSpacerItem(space, space, QSizePolicy::Expanding));
|
||||
m_vLayout->setAlignment(Qt::AlignVCenter);
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <QBuffer>
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QThread>
|
||||
@@ -53,6 +52,7 @@ Flameshot::Flameshot()
|
||||
// permissions on the first run. Otherwise it will be hidden under the
|
||||
// CaptureWidget
|
||||
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
|
||||
// TODO: Qt 6 - QApplication::desktop() not avialable
|
||||
currentScreen->grabWindow(QApplication::desktop()->winId(), 0, 0, 1, 1);
|
||||
|
||||
// set global shortcuts for MacOS
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "qguiappcurrentscreen.h"
|
||||
#include <QCursor>
|
||||
#include <QDesktopWidget>
|
||||
#include <QGuiApplication>
|
||||
#include <QPoint>
|
||||
#include <QScreen>
|
||||
@@ -49,15 +48,6 @@ QScreen* QGuiAppCurrentScreen::currentScreen(const QPoint& pos)
|
||||
|
||||
QScreen* QGuiAppCurrentScreen::screenAt(const QPoint& pos)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
m_currentScreen = qGuiApp->screenAt(pos);
|
||||
#else
|
||||
for (QScreen* const screen : QGuiApplication::screens()) {
|
||||
m_currentScreen = screen;
|
||||
if (screen->geometry().contains(pos)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return m_currentScreen;
|
||||
}
|
||||
|
||||
@@ -153,9 +153,6 @@ int main(int argc, char* argv[])
|
||||
wayland_hacks();
|
||||
#endif
|
||||
|
||||
// required for the button serialization
|
||||
// TODO: change to QVector in v1.0
|
||||
qRegisterMetaTypeStreamOperators<QList<int>>("QList<int>");
|
||||
QCoreApplication::setApplicationVersion(APP_VERSION);
|
||||
QCoreApplication::setApplicationName(QStringLiteral("flameshot"));
|
||||
QCoreApplication::setOrganizationName(QStringLiteral("flameshot"));
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QPixmap>
|
||||
#include <QProcess>
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
#include <QTabWidget>
|
||||
|
||||
@@ -128,11 +129,12 @@ void AppLauncherWidget::launch(const QModelIndex& index)
|
||||
QStringList prog_args = command.split(" ");
|
||||
#endif
|
||||
// no quotes because it is going in an array!
|
||||
static const QRegularExpression regexp("(\\%.)");
|
||||
if (command.contains("%")) {
|
||||
// but that means we need to substitute IN the array not the string!
|
||||
for (auto& i : prog_args) {
|
||||
if (i.contains("%"))
|
||||
i.replace(QRegExp("(\\%.)"), m_tempFile);
|
||||
i.replace(regexp, m_tempFile);
|
||||
}
|
||||
} else {
|
||||
// we really should append the file name if there
|
||||
@@ -174,7 +176,9 @@ void AppLauncherWidget::searchChanged(const QString& text)
|
||||
m_tabWidget->hide();
|
||||
m_filterList->show();
|
||||
m_filterList->clear();
|
||||
QRegExp regexp(text, Qt::CaseInsensitive, QRegExp::Wildcard);
|
||||
const QRegularExpression regexp(
|
||||
QRegularExpression::wildcardToRegularExpression(text),
|
||||
QRegularExpression::CaseInsensitiveOption);
|
||||
QVector<DesktopAppData> apps;
|
||||
|
||||
for (auto const& i : catIconNames.toStdMap()) {
|
||||
|
||||
@@ -135,7 +135,7 @@ bool PinWidget::scrollEvent(QWheelEvent* event)
|
||||
return true;
|
||||
}
|
||||
|
||||
void PinWidget::enterEvent(QEvent*)
|
||||
void PinWidget::enterEvent(QEnterEvent*)
|
||||
{
|
||||
m_shadowEffect->setColor(m_hoverColor);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ protected:
|
||||
void mousePressEvent(QMouseEvent*) override;
|
||||
void mouseMoveEvent(QMouseEvent*) override;
|
||||
void keyPressEvent(QKeyEvent*) override;
|
||||
void enterEvent(QEvent*) override;
|
||||
void enterEvent(QEnterEvent*) override;
|
||||
void leaveEvent(QEvent*) override;
|
||||
|
||||
bool event(QEvent* event) override;
|
||||
|
||||
@@ -52,7 +52,7 @@ AbstractLogger& AbstractLogger::sendMessage(const QString& msg, Channel channel)
|
||||
msg, messageHeader(channel, Notification), m_notificationPath);
|
||||
}
|
||||
if (!m_textStreams.isEmpty()) {
|
||||
foreach (auto* stream, m_textStreams) {
|
||||
for (auto* stream : m_textStreams) {
|
||||
*stream << messageHeader(channel, String) << msg << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ QString ConfigHandler::filenamePatternDefault()
|
||||
|
||||
void ConfigHandler::setDefaultSettings()
|
||||
{
|
||||
foreach (const QString& key, m_settings.allKeys()) {
|
||||
for (const auto& key : m_settings.allKeys()) {
|
||||
if (isShortcut(key)) {
|
||||
// Do not reset Shortcuts
|
||||
continue;
|
||||
@@ -486,25 +486,15 @@ void ConfigHandler::resetValue(const QString& key)
|
||||
|
||||
QSet<QString>& ConfigHandler::recognizedGeneralOptions()
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
auto keys = ::recognizedGeneralOptions.keys();
|
||||
static QSet<QString> options = QSet<QString>(keys.begin(), keys.end());
|
||||
#else
|
||||
static QSet<QString> options =
|
||||
QSet<QString>::fromList(::recognizedGeneralOptions.keys());
|
||||
#endif
|
||||
return options;
|
||||
}
|
||||
|
||||
QSet<QString>& ConfigHandler::recognizedShortcutNames()
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
auto keys = recognizedShortcuts.keys();
|
||||
static QSet<QString> names = QSet<QString>(keys.begin(), keys.end());
|
||||
#else
|
||||
static QSet<QString> names =
|
||||
QSet<QString>::fromList(recognizedShortcuts.keys());
|
||||
#endif
|
||||
return names;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
int GlobalValues::buttonBaseSize()
|
||||
{
|
||||
return QApplication::fontMetrics().lineSpacing() * 2.2;
|
||||
return QFontMetrics(qApp->font()).lineSpacing() * 2.2;
|
||||
}
|
||||
|
||||
QString GlobalValues::versionInfo()
|
||||
|
||||
@@ -60,7 +60,7 @@ const QList<QString>& History::history()
|
||||
int cnt = 0;
|
||||
int max = ConfigHandler().uploadHistoryMax();
|
||||
m_thumbs.clear();
|
||||
foreach (QString fileName, images) {
|
||||
for (const auto& fileName : images) {
|
||||
if (++cnt <= max) {
|
||||
m_thumbs.append(fileName);
|
||||
} else {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "src/utils/filenamehandler.h"
|
||||
#include "src/utils/systemnotification.h"
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QGuiApplication>
|
||||
#include <QPixmap>
|
||||
#include <QProcess>
|
||||
@@ -141,10 +140,12 @@ void ScreenGrabber::freeDesktopPortal(bool& ok, QPixmap& res)
|
||||
QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
|
||||
{
|
||||
ok = true;
|
||||
int wid = 0;
|
||||
|
||||
#if defined(Q_OS_MACOS)
|
||||
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
|
||||
QPixmap screenPixmap(
|
||||
currentScreen->grabWindow(QApplication::desktop()->winId(),
|
||||
currentScreen->grabWindow(wid,
|
||||
currentScreen->geometry().x(),
|
||||
currentScreen->geometry().y(),
|
||||
currentScreen->geometry().width(),
|
||||
@@ -205,13 +206,8 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX) || defined(Q_OS_WIN)
|
||||
QRect geometry = desktopGeometry();
|
||||
QPixmap p(QApplication::primaryScreen()->grabWindow(
|
||||
QApplication::desktop()->winId(),
|
||||
geometry.x(),
|
||||
geometry.y(),
|
||||
geometry.width(),
|
||||
geometry.height()));
|
||||
auto screenNumber = QApplication::desktop()->screenNumber();
|
||||
QScreen* screen = QApplication::screens()[screenNumber];
|
||||
wid, geometry.x(), geometry.y(), geometry.width(), geometry.height()));
|
||||
QScreen* screen = qApp->screenAt(QCursor::pos());
|
||||
p.setDevicePixelRatio(screen->devicePixelRatio());
|
||||
return p;
|
||||
#endif
|
||||
@@ -251,11 +247,8 @@ QPixmap ScreenGrabber::grabScreen(QScreen* screen, bool& ok)
|
||||
}
|
||||
} else {
|
||||
ok = true;
|
||||
return screen->grabWindow(QApplication::desktop()->winId(),
|
||||
geometry.x(),
|
||||
geometry.y(),
|
||||
geometry.width(),
|
||||
geometry.height());
|
||||
return screen->grabWindow(
|
||||
0, geometry.x(), geometry.y(), geometry.width(), geometry.height());
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ QString ShowSaveFileDialog(const QString& title, const QString& directory)
|
||||
|
||||
// Build string list of supported image formats
|
||||
QStringList mimeTypeList;
|
||||
foreach (auto mimeType, QImageWriter::supportedMimeTypes()) {
|
||||
for (const auto& mimeType : QImageWriter::supportedMimeTypes()) {
|
||||
// image/heif has several aliases and they cause glitch in save dialog
|
||||
// It is necessary to keep the image/heif (otherwise HEIF plug-in from
|
||||
// kimageformats will not work) but the aliases could be filtered out.
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QImageWriter>
|
||||
#include <QKeySequence>
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
#include <QVariant>
|
||||
|
||||
@@ -96,8 +97,13 @@ Color::Color(QColor def)
|
||||
bool Color::check(const QVariant& val)
|
||||
{
|
||||
QString str = val.toString();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
||||
bool validColor = QColor::isValidColor(str);
|
||||
#else
|
||||
bool validColor = QColor::isValidColorName(str);
|
||||
#endif
|
||||
// Disable #RGB, #RRRGGGBBB and #RRRRGGGGBBBB formats that QColor supports
|
||||
return QColor::isValidColor(str) &&
|
||||
return validColor &&
|
||||
(str[0] != '#' ||
|
||||
(str.length() != 4 && str.length() != 10 && str.length() != 13));
|
||||
}
|
||||
@@ -235,8 +241,7 @@ QVariant KeySequence::process(const QVariant& val)
|
||||
}
|
||||
if (str.length() > 0) {
|
||||
// Make the "main" key in sequence (last one) lower-case.
|
||||
const QCharRef& lastChar = str[str.length() - 1];
|
||||
str.replace(str.length() - 1, 1, lastChar.toLower());
|
||||
str[str.length() - 1] = str[str.length() - 1].toLower();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
@@ -245,7 +250,7 @@ QVariant KeySequence::process(const QVariant& val)
|
||||
|
||||
bool ExistingDir::check(const QVariant& val)
|
||||
{
|
||||
if (!val.canConvert(QVariant::String) || val.toString().isEmpty()) {
|
||||
if (!val.canConvert<QString>() || val.toString().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
QFileInfo info(val.toString());
|
||||
@@ -396,11 +401,15 @@ bool UserColors::check(const QVariant& val)
|
||||
if (!val.isValid()) {
|
||||
return false;
|
||||
}
|
||||
if (!val.canConvert(QVariant::StringList)) {
|
||||
if (!val.canConvert<QStringList>()) {
|
||||
return false;
|
||||
}
|
||||
for (const QString& str : val.toStringList()) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
||||
if (!QColor::isValidColor(str) && str != "picker") {
|
||||
#else
|
||||
if (!QColor::isValidColorName(str) && str != "picker") {
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -470,7 +479,7 @@ QVariant UserColors::representation(const QVariant& val)
|
||||
|
||||
bool SaveFileExtension::check(const QVariant& val)
|
||||
{
|
||||
if (!val.canConvert(QVariant::String) || val.toString().isEmpty()) {
|
||||
if (!val.canConvert<QString>() || val.toString().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -481,7 +490,7 @@ bool SaveFileExtension::check(const QVariant& val)
|
||||
}
|
||||
|
||||
QStringList imageFormatList;
|
||||
foreach (auto imageFormat, QImageWriter::supportedImageFormats())
|
||||
for (const auto& imageFormat : QImageWriter::supportedImageFormats())
|
||||
imageFormatList.append(imageFormat);
|
||||
|
||||
if (!imageFormatList.contains(extension)) {
|
||||
@@ -533,14 +542,15 @@ QVariant Region::process(const QVariant& val)
|
||||
return ScreenGrabber().desktopGeometry();
|
||||
} else if (str.startsWith("screen")) {
|
||||
bool ok;
|
||||
int number = str.midRef(6).toInt(&ok);
|
||||
int number = str.mid(6).toInt(&ok);
|
||||
if (!ok || number < 0) {
|
||||
return {};
|
||||
}
|
||||
return ScreenGrabber().screenGeometry(qApp->screens()[number]);
|
||||
}
|
||||
|
||||
QRegExp regex("(-{,1}\\d+)" // number (any sign)
|
||||
static const QRegularExpression regex(
|
||||
"(-{,1}\\d+)" // number (any sign)
|
||||
"[x,\\.\\s]" // separator ('x', ',', '.', or whitespace)
|
||||
"(-{,1}\\d+)" // number (any sign)
|
||||
"[\\+,\\.\\s]*" // separator ('+',',', '.', or whitespace)
|
||||
@@ -549,16 +559,16 @@ QVariant Region::process(const QVariant& val)
|
||||
"(-{,1}\\d+)" // number (non-negative)
|
||||
);
|
||||
|
||||
if (!regex.exactMatch(str)) {
|
||||
if (!regex.match(str).hasMatch()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
int w, h, x, y;
|
||||
bool w_ok, h_ok, x_ok, y_ok;
|
||||
w = regex.cap(1).toInt(&w_ok);
|
||||
h = regex.cap(2).toInt(&h_ok);
|
||||
x = regex.cap(3).toInt(&x_ok);
|
||||
y = regex.cap(4).toInt(&y_ok);
|
||||
w = regex.match(str).captured(1).toInt(&w_ok);
|
||||
h = regex.match(str).captured(2).toInt(&h_ok);
|
||||
x = regex.match(str).captured(3).toInt(&x_ok);
|
||||
y = regex.match(str).captured(4).toInt(&y_ok);
|
||||
|
||||
if (!(w_ok && h_ok && x_ok && y_ok)) {
|
||||
return {};
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <QCheckBox>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFontMetrics>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
@@ -1221,10 +1220,6 @@ void CaptureWidget::showAppUpdateNotification(const QString& appLatestVersion,
|
||||
}
|
||||
#if defined(Q_OS_MACOS)
|
||||
int ax = (width() - m_updateNotificationWidget->width()) / 2;
|
||||
#elif (defined(Q_OS_LINUX) && QT_VERSION < QT_VERSION_CHECK(5, 10, 0))
|
||||
QRect helpRect = QGuiApplication::primaryScreen()->geometry();
|
||||
int ax = helpRect.left() +
|
||||
((helpRect.width() - m_updateNotificationWidget->width()) / 2);
|
||||
#else
|
||||
QRect helpRect;
|
||||
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
|
||||
@@ -1279,7 +1274,7 @@ void CaptureWidget::initSelection()
|
||||
if (!initialSelection.isNull()) {
|
||||
const qreal scale = m_context.screenshot.devicePixelRatio();
|
||||
initialSelection.moveTopLeft(initialSelection.topLeft() -
|
||||
mapToGlobal({}));
|
||||
mapToGlobal(QPoint(0, 0)));
|
||||
initialSelection.setTop(initialSelection.top() / scale);
|
||||
initialSelection.setBottom(initialSelection.bottom() / scale);
|
||||
initialSelection.setLeft(initialSelection.left() / scale);
|
||||
|
||||
@@ -26,7 +26,7 @@ NotifierBox::NotifierBox(QWidget* parent)
|
||||
setFixedSize(QSize(size, size));
|
||||
}
|
||||
|
||||
void NotifierBox::enterEvent(QEvent*)
|
||||
void NotifierBox::enterEvent(QEnterEvent*)
|
||||
{
|
||||
hide();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public:
|
||||
explicit NotifierBox(QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
virtual void enterEvent(QEvent*) override;
|
||||
void enterEvent(QEnterEvent*) override;
|
||||
virtual void paintEvent(QPaintEvent*) override;
|
||||
|
||||
signals:
|
||||
|
||||
@@ -31,7 +31,7 @@ OverlayMessage::OverlayMessage(QWidget* parent, const QRect& targetArea)
|
||||
setStyleSheet(
|
||||
QStringLiteral("QLabel { color: %1; }").arg(m_textColor.name()));
|
||||
|
||||
setMargin(QApplication::fontMetrics().height() / 2);
|
||||
setMargin(QFontMetrics(qApp->font()).height() / 2);
|
||||
QWidget::hide();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,10 @@ InfoWindow::InfoWindow(QWidget* parent)
|
||||
connect(
|
||||
ui->CopyInfoButton, &QPushButton::clicked, this, &InfoWindow::copyInfo);
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||
QRect position = frameGeometry();
|
||||
QScreen* screen = QGuiAppCurrentScreen().currentScreen();
|
||||
position.moveCenter(screen->availableGeometry().center());
|
||||
move(position.topLeft());
|
||||
#endif
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ LoadSpinner::LoadSpinner(QWidget* parent)
|
||||
, m_growing(true)
|
||||
{
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
const int size = QApplication::fontMetrics().height() * 8;
|
||||
const int size = QFontMetrics(qApp->font()).height() * 8;
|
||||
setFixedSize(size, size);
|
||||
updateFrame();
|
||||
// init timer
|
||||
|
||||
@@ -108,7 +108,11 @@ SidePanelWidget::SidePanelWidget(QPixmap* p, QWidget* parent)
|
||||
&SidePanelWidget::onToolSizeChanged);
|
||||
// color hex editor sigslots
|
||||
connect(m_colorHex, &QLineEdit::editingFinished, this, [=]() {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
||||
if (!QColor::isValidColor(m_colorHex->text())) {
|
||||
#else
|
||||
if (!QColor::isValidColorName(m_colorHex->text())) {
|
||||
#endif
|
||||
m_colorHex->setText(m_color.name(QColor::HexRgb));
|
||||
} else {
|
||||
emit colorChanged(m_colorHex->text());
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "uploadlineitem.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDesktopWidget>
|
||||
#include <QFileInfo>
|
||||
#include <QPixmap>
|
||||
|
||||
@@ -37,7 +36,6 @@ UploadHistory::UploadHistory(QWidget* parent)
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
resize(QDesktopWidget().availableGeometry(this).size() * 0.5);
|
||||
}
|
||||
|
||||
void UploadHistory::loadHistory()
|
||||
@@ -50,7 +48,7 @@ void UploadHistory::loadHistory()
|
||||
if (historyFiles.isEmpty()) {
|
||||
setEmptyMessage();
|
||||
} else {
|
||||
foreach (QString fileName, historyFiles) {
|
||||
for (const auto& fileName : historyFiles) {
|
||||
addLine(history.path(), fileName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user