Skip to content

Commit

Permalink
fix: Unified modification of predefined macros
Browse files Browse the repository at this point in the history
Unified modification of predefined macros
  • Loading branch information
JWWTSL authored and deepin-bot[bot] committed Dec 27, 2024
1 parent 4d5d91d commit 36a909d
Show file tree
Hide file tree
Showing 23 changed files with 59 additions and 63 deletions.
2 changes: 1 addition & 1 deletion screen_shot_recorder.pro
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ QT6_LRELEASE = /usr/lib/qt6/bin/lrelease
DEFAULT_LUPDATE = lupdate
DEFAULT_LRELEASE = lrelease

equals(QT_MAJOR_VERSION, 6) {
equals(QT_VERSION_MAJOR, 6) {
CONFIG(update_translations) {
isEmpty(lupdate):lupdate=$$QT6_LUPDATE
system($$lupdate -no-obsolete -locations none $$_PRO_FILE_)
Expand Down
4 changes: 2 additions & 2 deletions src/camera/devnummonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#include <QDebug>

#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
#include <QCameraInfo>
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
#include <QMediaDevices>
#endif

Expand Down
8 changes: 4 additions & 4 deletions src/camera_process.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@


//Qt6
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
#include <QCameraViewfinder>
#include <QCameraImageCapture>
#include <QCameraInfo>
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
#include <QMediaCaptureSession>
#include <QImageCapture>
#include <QVideoWidget>
Expand All @@ -42,11 +42,11 @@ public slots:
//void displayImage(int, QImage image);

private:
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
QCamera *camera; // 摄像头
QCameraViewfinder *viewfinder; // 摄像头取景器部件
QCameraImageCapture *imageCapture; // 截图部件
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
QCamera *camera;
QVideoWidget *viewfinder; // 摄像头取景器部件
QImageCapture *imageCapture; // 截图部件
Expand Down
4 changes: 2 additions & 2 deletions src/event_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ void EventMonitor::handleEvent(XRecordInterceptData *data)
//鼠标按压
emit mousePress(event->u.keyButtonPointer.rootX, event->u.keyButtonPointer.rootY);
} else if (event->u.u.detail == WheelUp || event->u.u.detail == WheelDown) {
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
//qt6中的写法只有较新版本的qt5才适用,5.11.3不支持
int time = int (QDateTime::currentDateTime().toTime_t());
//鼠标滚动
emit mouseScroll(static_cast<int>(event->u.enterLeave.time), event->u.u.detail, event->u.keyButtonPointer.rootX, event->u.keyButtonPointer.rootY);
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
int time = int(QDateTime::currentDateTime().toSecsSinceEpoch());
//鼠标滚动
emit mouseScroll(time, event->u.u.detail, event->u.keyButtonPointer.rootX, event->u.keyButtonPointer.rootY);
Expand Down
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ int main(int argc, char *argv[])
setenv("XDG_CURRENT_DESKTOP", "Deepin", 1);
}

// qt6中缺少这个接口
#if (QT_MAJOR_VERSION == 5)
DGuiApplicationHelper::setUseInactiveColorGroup(false);t->u.keyButtonPointer.rootY);
#if (QT_VERSION_MAJOR == 5)
DGuiApplicationHelper::setUseInactiveColorGroup(false);
#endif

QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

QDBusInterface scaleFactor("com.deepin.daemon.Display", "/com/deepin/XSettings", "com.deepin.XSettings");
Expand Down Expand Up @@ -151,7 +151,7 @@ int main(int argc, char *argv[])
app->setApplicationName("deepin-screen-recorder");
app->setApplicationVersion("1.0");

#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
app->setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
// static const QDate buildDate = QLocale(QLocale::English).
Expand Down
20 changes: 9 additions & 11 deletions src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ extern "C" {
#include <QFileDialog>
#include <QShortcut>

#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
#include <QDesktopWidget>
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
#include <QScreen>
#endif

Expand Down Expand Up @@ -983,9 +983,10 @@ void MainWindow::initShortcut()
// 截图模式/录屏模式(未做穿透)/滚动模式 退出
QShortcut *escSC = new QShortcut(QKeySequence("Escape"), this);
// 截图模式/录屏模式(未做穿透)/滚动模式 帮助快捷面板
QShortcut *shortCutSC = new QShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Slash), this);
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
QShortcut *shortCutSC = new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Slash), this);
#elif (QT_VERSION_MAJOR == 6)
QShortcut *shortCutSC = new QShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_Slash), this);
#endif
// 截图模式/滚动模式 贴图应用内快捷键
connect(pinScreenshotsSC, &QShortcut::activated, this, [=] {
Expand Down Expand Up @@ -2348,12 +2349,10 @@ void MainWindow::wheelEvent(QWheelEvent *event)
if (!recordRect.contains(mouseMovePoint))
return;
if (m_scrollShot) {
int time = 0;
float len = 0.0f;
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
int time = int(QDateTime::currentDateTime().toTime_t());
float len = (event->delta() > 15.0) ? -15.0 : 15.0; // 获取滚轮方向
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
int time = int(QDateTime::currentDateTime().toSecsSinceEpoch());
float len = (event->angleDelta().y() > 15) ? -15.0 : 15.0; // 获取滚轮方向
#endif
Expand Down Expand Up @@ -5860,10 +5859,9 @@ void MainWindow::shotCurrentImg()
// 当存在编辑模式且编辑的内容有文本时,需要再截图一次
if (m_shapesWidget && m_shapesWidget->isExistsText()) {
int eventTime = 60;
QRect rect = QRect();
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
QRect rect = QApplication::desktop()->screenGeometry();
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
QRect rect = QGuiApplication::primaryScreen()->geometry();
#endif
if (rect.width() * rect.height() > 1920 * 1080) {
Expand Down
2 changes: 1 addition & 1 deletion src/pin_screenshots/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ int main(int argc, char *argv[])
app->setApplicationName("deepin-screen-recorder");
app->setProductName(QObject::tr("Pin Screenshots"));
app->setApplicationVersion("1.0");
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
app->setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
QString logFilePath = Dtk::Core::DLogManager::getlogFilePath();
Expand Down
5 changes: 2 additions & 3 deletions src/pin_screenshots/ui/menucontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ void MenuController::showMenu(QPoint pos)
m_menu->popup(pos);
}


#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
void MenuController::enterEvent(QEvent *e)
{
Q_UNUSED(e);
qApp->setOverrideCursor(Qt::ArrowCursor);
}
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
void MenuController::enterEvent(QEnterEvent *e)
{
Q_UNUSED(e);
Expand Down
4 changes: 2 additions & 2 deletions src/pin_screenshots/ui/menucontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public slots:
* @param e
*/
// qt6 接口有变动
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
void enterEvent(QEvent *e);
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
void enterEvent(QEnterEvent *e);;
#endif
private:
Expand Down
4 changes: 2 additions & 2 deletions src/pin_screenshots/ui/toolbutton.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ class ToolButton : public DPushButton
}
~ToolButton() {}
protected:
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
void enterEvent(QEvent *e) override
{
if (this->isEnabled() && m_hasHoverState) {
setFlat(false);
}
DPushButton::enterEvent(e);
}
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
void enterEvent(QEnterEvent *e) override
{
if (this->isEnabled() && m_hasHoverState) {
Expand Down
8 changes: 4 additions & 4 deletions src/record_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,20 @@ void RecordProcess::onStartTranscode()
qInfo() << __LINE__ << __func__ << "正在转码视频(mp4 to gif)...";
QProcess *transcodeProcess = new QProcess(this);

#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
connect(transcodeProcess, QOverload<QProcess::ProcessError>::of(&QProcess::error),
[ = ](QProcess::ProcessError processError) {
qDebug() << "processError: " << processError;
});
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
// Qt6 syntax for error signal
connect(transcodeProcess, &QProcess::errorOccurred,
[ = ](QProcess::ProcessError processError) {
qDebug() << "processError: " << processError;
});
#endif

#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
// Qt6 syntax for finished signal
connect(transcodeProcess, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
[ = ](int exitCode, QProcess::ExitStatus exitStatus) {
Expand All @@ -153,7 +153,7 @@ void RecordProcess::onStartTranscode()
qDebug() << "m_pTranscodeProcess is CrashExit:!";
}
});
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
// Qt6 syntax for finished signal
connect(transcodeProcess, &QProcess::finished,
[ = ](int exitCode, QProcess::ExitStatus exitStatus) {
Expand Down
7 changes: 3 additions & 4 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "utils_interface.h"

// TODO: qtx11extras-opensource-src没进行qt6适配,后续会补充上
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
#include <QtX11Extras/QX11Info>
#endif

Expand Down Expand Up @@ -208,14 +208,13 @@ void Utils::setAccessibility(DPushButton *button, const QString name)
button->setAccessibleName(name);
}

#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
void Utils::setAccessibility(DImageButton *button, const QString name)
{
button->setObjectName(name);
button->setAccessibleName(name);
}

#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
void Utils::setAccessibility(DIconButton *button, const QString name)
{
button->setObjectName(name);
Expand Down
6 changes: 3 additions & 3 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <QScreen>

// TODO: Qt6中找不到DImageButton这个头文件,后续会找dtk对齐继续处理
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
#include <DImageButton>
#endif

Expand Down Expand Up @@ -68,9 +68,9 @@ class Utils : public utils_interface
static void passInputEvent(int wid);
static void setFontSize(QPainter &painter, int textSize);
static void setAccessibility(DPushButton *button, const QString name);
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
static void setAccessibility(DImageButton *button, const QString name);
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
static void setAccessibility(DIconButton *button, const QString name);
#endif
static void setAccessibility(QAction *action, const QString name);
Expand Down
4 changes: 2 additions & 2 deletions src/utils/pixmergethread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const int PixMergeThread::TEMPLATE_HEIGHT = 50;

PixMergeThread::PixMergeThread(QObject *parent) : QThread(parent)
{
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
m_lastTime = int(QDateTime::currentDateTime().toTime_t());
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
m_lastTime = int(QDateTime::currentDateTime().toSecsSinceEpoch());m_lastTime = int(QDateTime::currentDateTime().toSecsSinceEpoch());
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/scrollScreenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ void ScrollScreenshot::addPixmap(const QPixmap &piximg, int wheelDirection)

void ScrollScreenshot::addLastPixmap(const QPixmap &piximg)
{
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
setTimeAndCalculateTimeDiff(static_cast<int>(QDateTime::currentDateTime().toTime_t()));
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
setTimeAndCalculateTimeDiff(static_cast<int>(QDateTime::currentDateTime().toSecsSinceEpoch()));
#endif
m_PixMerageThread->setIsLastImg(true); //添加最后一张图片标记
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/camerawidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

#include <QObject>
#include <QCamera>
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
#include <QCameraViewfinder>
#include <QCameraImageCapture>
#include <QCameraInfo>
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
#include <QMediaDevices>
#include <QImageCapture>
#include <QVideoWidget>
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/sidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ void SideBar::paintEvent(QPaintEvent *e)
DLabel::paintEvent(e);
}

#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
void SideBar::enterEvent(QEvent *e)
{
// qApp->setOverrideCursor(Qt::ArrowCursor);
QApplication::setOverrideCursor(Qt::OpenHandCursor);
DLabel::enterEvent(e);
}
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
void SideBar::enterEvent(QEnterEvent *e)
{
// qApp->setOverrideCursor(Qt::ArrowCursor);
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/sidebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ public slots:

protected:
void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
void enterEvent(QEvent *e) Q_DECL_OVERRIDE;
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
void enterEvent(QEnterEvent *e) Q_DECL_OVERRIDE;
#endif
bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/toolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ void ToolBar::paintEvent(QPaintEvent *e)
DLabel::paintEvent(e);
}

#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
void ToolBar::enterEvent(QEvent *e)
{
// qApp->setOverrideCursor(Qt::ArrowCursor);
QApplication::setOverrideCursor(Qt::OpenHandCursor);
DLabel::enterEvent(e);
}
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
void ToolBar::enterEvent(QEnterEvent *e)
{
// qApp->setOverrideCursor(Qt::ArrowCursor);
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/toolbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ public slots:
void setCameraDeviceEnable(bool status);
protected:
void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
void enterEvent(QEvent *e) Q_DECL_OVERRIDE;
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
void enterEvent(QEnterEvent *e) Q_DECL_OVERRIDE;
#endif
bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/tooltips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ ToolTips::~ToolTips()
}
}

#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
void ToolTips::enterEvent(QEvent *e)
{
Q_UNUSED(e);
hide();
}
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
void ToolTips::enterEvent(QEnterEvent *e)
{
Q_UNUSED(e);
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/tooltips.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public slots:

protected:
virtual void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
#if (QT_MAJOR_VERSION == 5)
#if (QT_VERSION_MAJOR == 5)
void enterEvent(QEvent *e) override;
#elif (QT_MAJOR_VERSION == 6)
#elif (QT_VERSION_MAJOR == 6)
void enterEvent(QEnterEvent *e) override;
#endif
virtual void resizeEvent(QResizeEvent *ev) Q_DECL_OVERRIDE;
Expand Down
Loading

0 comments on commit 36a909d

Please sign in to comment.