Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: adapt to qt6 #382

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall")
option(DISABLE_SYS_UPDATE "disable sys update" OFF)

set(QT_VERSION_MAJOR 6)
set(DTK_VERSION_MAJOR 6)

# 增加安全编译参数
ADD_DEFINITIONS("-fstack-protector-strong -D_FORTITY_SOURCE=1 -z noexecstack -pie -fPIC -z lazy")

Expand Down Expand Up @@ -50,11 +53,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
find_package(PkgConfig REQUIRED)
find_package(GTest REQUIRED)
find_package(GMock REQUIRED)
find_package(Dtk REQUIRED COMPONENTS Core Widget)
find_package(Qt5 REQUIRED COMPONENTS Widgets DBus X11Extras Xml Concurrent Svg Sql Network Test)
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core Widget Tools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets DBus Xml Concurrent Svg Sql Network Test)

pkg_check_modules(GSETTINGS REQUIRED IMPORTED_TARGET gsettings-qt)
pkg_check_modules(DdeDockInterface REQUIRED dde-dock)
pkg_check_modules(XCB_EWMH REQUIRED IMPORTED_TARGET xcb-ewmh)
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(GIO REQUIRED gio-unix-2.0)
Expand All @@ -67,8 +68,6 @@ set(Test_Libraries
-lgmock
)

find_package(DtkTools REQUIRED)

# shared objects
add_subdirectory("common")
add_subdirectory("widgets")
Expand All @@ -80,7 +79,7 @@ add_subdirectory("dde-bluetooth-dialog")
add_subdirectory("dde-hints-dialog")
add_subdirectory("dde-license-dialog")
add_subdirectory("dde-lowpower")
add_subdirectory("dde-osd")
#add_subdirectory("dde-osd")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个还是要适配,在社区版的x11下面还是需要的,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v23走release分支,此修改不会合并到release分支。

add_subdirectory("dde-pixmix")
add_subdirectory("dde-suspend-dialog")
add_subdirectory("dde-switchtogreeter")
Expand Down
4 changes: 2 additions & 2 deletions common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ PUBLIC

target_link_libraries(session-ui-common-shared
PRIVATE
Qt5::Widgets
Dtk::Widget
Qt${QT_VERSION_MAJOR}::Widgets
Dtk${DTK_VERSION_MAJOR}::Widget
)
14 changes: 6 additions & 8 deletions dde-bluetooth-dialog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ file(GLOB_RECURSE Bluetooth_Dialog_SRCS
list(REMOVE_ITEM Bluetooth_Dialog_SRCS "${CMAKE_SOURCE_DIR}/dde-bluetooth-dialog/src/main.cpp")

set(Bluetooth_Dialog_Includes
${DtkWidget_INCLUDE_DIRS}
${GSETTINGS_INCLUDE_DIRS}
Qt5::Widgets
Qt5::DBus
Dtk${DTK_VERSION_MAJOR}::Widget
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::DBus
)
set(Bluetooth_Dialog_Libraries
${DtkWidget_LIBRARIES}
${GSETTINGS_LIBRARIES}
Qt5::Widgets
Qt5::DBus
Dtk${DTK_VERSION_MAJOR}::Widget
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::DBus
)

add_subdirectory("src")
Expand Down
6 changes: 3 additions & 3 deletions dde-bluetooth-dialog/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ add_executable(${Bluetooth_Dialog_Name}
${Common_SRCS}
${Bluetooth_Dialog_SRCS}
main.cpp
)
)

target_include_directories(${Bluetooth_Dialog_Name} PUBLIC
${Bluetooth_Dialog_Includes}
)
)

target_link_libraries(${Bluetooth_Dialog_Name} PRIVATE
session-ui-dbus-shared
${Bluetooth_Dialog_Libraries}
)
)

## bin
install(TARGETS ${Bluetooth_Dialog_Name} DESTINATION ${DAEMON_LIB_PATH})
5 changes: 3 additions & 2 deletions dde-bluetooth-dialog/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ int main(int argc, char *argv[])
app.setOrganizationName("deepin");
app.setApplicationName("dde-bluetooth-dialog");
QTranslator translator;
translator.load("/usr/share/dde-session-ui/translations/dde-session-ui_" + QLocale::system().name());
app.installTranslator(&translator);
if (translator.load("/usr/share/dde-session-ui/translations/dde-session-ui_" + QLocale::system().name())) {
app.installTranslator(&translator);
}

QStringList arguslist = app.arguments();
if (arguslist.size() < 4) {
Expand Down
21 changes: 11 additions & 10 deletions dde-bluetooth-dialog/src/pincodedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@

#include "pincodedialog.h"
#include "largelabel.h"
#include "org_deepin_dde_bluetooth1.h"

#include <QDateTime>
#include <QTimer>
#include <QGSettings>

#include <DConfig>

using DBusBluetooth = org::deepin::dde::Bluetooth1;

PinCodeDialog::PinCodeDialog(const QString &pinCode, const QString &devicepath, const QString &starttime, const bool &cancelable) :
DDialog(),
m_pinCodeLabel(new LargeLabel(this)),
m_titileLabel(new LargeLabel(this)),
m_bluetoothInter(new DBusBluetooth("org.deepin.dde.Bluetooth1", "/org/deepin/dde/Bluetooth1", QDBusConnection::sessionBus(), this))
m_titileLabel(new LargeLabel(this))
{
auto bluetoothInter = new DBusBluetooth("org.deepin.dde.Bluetooth1", "/org/deepin/dde/Bluetooth1", QDBusConnection::sessionBus(), this);

setAccessibleName("PinCodeDialog");
QString titilestr = tr("The PIN for connecting to the Bluetooth device is:");
setIcon(QIcon::fromTheme("notification-bluetooth-connected"));
Expand All @@ -41,10 +46,6 @@ PinCodeDialog::PinCodeDialog(const QString &pinCode, const QString &devicepath,
m_pinCodeLabel->setText(pinCode);

uint pinsectime = 60;
QGSettings setting("com.deepin.dde.osd", "/com/deepin/dde/osd/");
if (setting.keys().contains("pindialogTimeSec"))
pinsectime = setting.get("pindialog-time-sec").toUInt();

qint64 msec = pinsectime * 1000 - QDateTime::currentMSecsSinceEpoch() + starttime.toLongLong();
if (msec < 0){
qDebug() << "timeout";
Expand All @@ -54,13 +55,13 @@ PinCodeDialog::PinCodeDialog(const QString &pinCode, const QString &devicepath,
close();
});

connect(m_bluetoothInter, &DBusBluetooth::AdapterPropertiesChanged, this, &PinCodeDialog::HandleBlutoothPower);
connect(bluetoothInter, &DBusBluetooth::AdapterPropertiesChanged, this, &PinCodeDialog::HandleBlutoothPower);
connect(this, &PinCodeDialog::buttonClicked, this, [ = ](int index, const QString & text) {
Q_UNUSED(text)
m_bluetoothInter->Confirm(QDBusObjectPath(devicepath), index == 1 ? true : false);
bluetoothInter->Confirm(QDBusObjectPath(devicepath), index == 1 ? true : false);
});
connect(this, &PinCodeDialog::closed, this, [ = ]() {
m_bluetoothInter->Confirm(QDBusObjectPath(devicepath), false);
bluetoothInter->Confirm(QDBusObjectPath(devicepath), false);
qApp->quit();
});
}
Expand Down
10 changes: 1 addition & 9 deletions dde-bluetooth-dialog/src/pincodedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@
#ifndef DCC_BLUETOOTH_PINCODEDIALOG_H
#define DCC_BLUETOOTH_PINCODEDIALOG_H

#include <ddialog.h>
#include "org_deepin_dde_bluetooth1.h"

#include <QJsonDocument>
#include <QJsonParseError>
#include <DDialog>

DWIDGET_USE_NAMESPACE

using DBusBluetooth = org::deepin::dde::Bluetooth1;

class LargeLabel;

class PinCodeDialog : public DDialog
{
Q_OBJECT
Expand All @@ -31,7 +24,6 @@ private Q_SLOTS:
private:
LargeLabel *m_pinCodeLabel;
LargeLabel *m_titileLabel;
DBusBluetooth *m_bluetoothInter;
};

#endif // DCC_BLUETOOTH_PINCODEDIALOG_H
8 changes: 4 additions & 4 deletions dde-bluetooth-dialog/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ set(UT_Bluetooth_Dialog_Name ut-dde-bluetooth-dialog)

file(GLOB_RECURSE UT_Bluetooth_Dialog_SRCS
"*.cpp"
)
)

add_executable(${UT_Bluetooth_Dialog_Name}
${Common_SRCS}
${Bluetooth_Dialog_SRCS}
${UT_Bluetooth_Dialog_SRCS}
)
)

# 用于测试覆盖率的编译条件
target_compile_options(${UT_Bluetooth_Dialog_Name} PRIVATE -fprofile-arcs -ftest-coverage)

target_include_directories(${UT_Bluetooth_Dialog_Name} PUBLIC
${Bluetooth_Dialog_Includes}
../src/
)
)

target_link_libraries(${UT_Bluetooth_Dialog_Name} PRIVATE
session-ui-dbus-shared
${Bluetooth_Dialog_Libraries}
${Test_Libraries}
)
)
2 changes: 2 additions & 0 deletions dde-bluetooth-dialog/tests/ut_pincodedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include <QDateTime>

#define private public
#include "pincodedialog.h"
#undef private
Expand Down
14 changes: 7 additions & 7 deletions dde-hints-dialog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
file(GLOB_RECURSE Hints_Dialog_SRCS
"src/*.h"
"src/*.cpp"
)
)

list(REMOVE_ITEM Hints_Dialog_SRCS "${CMAKE_SOURCE_DIR}/dde-hints-dialog/src/main.cpp")

set(Hints_Dialog_Includes
${DtkWidget_INCLUDE_DIRS}
Qt5::Widgets
)
Dtk${DTK_VERSION_MAJOR}::Widget
Qt${QT_VERSION_MAJOR}::Widgets
)

set(Hints_Dialog_Libraries
${DtkWidget_LIBRARIES}
Qt5::Widgets
)
Dtk${DTK_VERSION_MAJOR}::Widget
Qt${QT_VERSION_MAJOR}::Widgets
)

add_subdirectory("src")
#add_subdirectory("tests")
6 changes: 3 additions & 3 deletions dde-hints-dialog/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ set(Hints_Dialog_Name dde-hints-dialog)
add_executable(${Hints_Dialog_Name}
${Hints_Dialog_SRCS}
main.cpp
)
)

target_include_directories(${Hints_Dialog_Name} PUBLIC
${Hints_Dialog_Includes}
)
)

target_link_libraries(${Hints_Dialog_Name} PRIVATE
${Hints_Dialog_Libraries}
)
)

## bin
install(TARGETS ${Hints_Dialog_Name} DESTINATION ${CMAKE_INSTALL_BINDIR})
4 changes: 2 additions & 2 deletions dde-hints-dialog/src/hintsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ HintsDialog::HintsDialog(QWidget *parent)
m_content->setWordWrap(true);

QHBoxLayout *titlelayout = new QHBoxLayout;
titlelayout->setMargin(0);
titlelayout->setContentsMargins(0, 0, 0, 0);
titlelayout->setSpacing(0);
titlelayout->addWidget(m_title, 1, Qt::AlignLeft | Qt::AlignVCenter);
titlelayout->addWidget(m_closeButton, 0, Qt::AlignRight | Qt::AlignVCenter);
Expand All @@ -48,7 +48,7 @@ HintsDialog::HintsDialog(QWidget *parent)
HorizontalSeperator * seperator = new HorizontalSeperator(this);

QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(15);
layout->setContentsMargins(15, 15, 15, 15);
layout->setSpacing(0);
layout->addWidget(widget);
layout->addSpacing(10);
Expand Down
1 change: 0 additions & 1 deletion dde-hints-dialog/src/horizontalseperator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "horizontalseperator.h"

#include <DApplicationHelper>

#include <QPainter>

Expand Down
5 changes: 3 additions & 2 deletions dde-hints-dialog/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ int main(int argc, char *argv[])
a.setQuitOnLastWindowClosed(true);

QTranslator translator;
translator.load("/usr/share/dde-session-ui/translations/dde-session-ui_" + QLocale::system().name());
a.installTranslator(&translator);
if (translator.load("/usr/share/dde-session-ui/translations/dde-session-ui_" + QLocale::system().name())) {
a.installTranslator(&translator);
}

QStringList arguslist = a.arguments();
if (arguslist.size() < 3) {
Expand Down
18 changes: 9 additions & 9 deletions dde-license-dialog/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
file(GLOB_RECURSE License_Dialog_SRCS
"src/*.h"
"src/*.cpp"
)
)

list(REMOVE_ITEM License_Dialog_SRCS "${CMAKE_SOURCE_DIR}/dde-license-dialog/src/main.cpp")

set(License_Dialog_Includes
${DtkWidget_INCLUDE_DIRS}
Qt5::Widgets
Qt5::Concurrent
)
Dtk${DTK_VERSION_MAJOR}::Widget
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Concurrent
)

set(License_Dialog_Libraries
${DtkWidget_LIBRARIES}
Qt5::Widgets
Qt5::Concurrent
)
Dtk${DTK_VERSION_MAJOR}::Widget
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Concurrent
)

add_subdirectory("src")
add_subdirectory("tests")
6 changes: 3 additions & 3 deletions dde-license-dialog/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ add_executable(${License_Dialog_Name}
${Common_SRCS}
${License_Dialog_SRCS}
main.cpp
)
)

target_include_directories(${License_Dialog_Name} PUBLIC
${License_Dialog_Includes}
)
)

target_link_libraries(${License_Dialog_Name} PRIVATE
${License_Dialog_Libraries}
)
)

## bin
install(TARGETS ${License_Dialog_Name} DESTINATION ${CMAKE_INSTALL_BINDIR})
Loading
Loading