mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-13 12:22:05 +08:00
feat: adapt to Qt6
adapt to Qt6; fix a few bugs Log: adapt to Qt6; bump version to 4.2.14
This commit is contained in:
40
src/CMakeLists.txt
Normal file
40
src/CMakeLists.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network Svg WebEngineWidgets)
|
||||
find_package(Dtk6 REQUIRED COMPONENTS Core Gui Widget)
|
||||
|
||||
include(src.cmake)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES} ${QRC_FILE})
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
Qt6::Concurrent
|
||||
Qt6::Network
|
||||
Qt6::Svg
|
||||
Qt6::WebEngineWidgets
|
||||
Dtk6::Core
|
||||
Dtk6::Gui
|
||||
Dtk6::Widget
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
Qt6::Concurrent
|
||||
Qt6::Network
|
||||
Qt6::Svg
|
||||
Qt6::WebEngineWidgets
|
||||
Dtk6::Core
|
||||
Dtk6::Gui
|
||||
Dtk6::Widget
|
||||
)
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION /opt/durapps/${PROJECT_NAME}/bin)
|
||||
|
||||
install(DIRECTORY ${CMAKE_SOURCE_DIR}/tool/ DESTINATION /opt/durapps/${PROJECT_NAME}/bin USE_SOURCE_PERMISSIONS)
|
||||
install(DIRECTORY ${CMAKE_SOURCE_DIR}/pkg/${CMAKE_INSTALL_SYSCONFDIR}/aptss DESTINATION ${CMAKE_INSTALL_SYSCONFDIR} USE_SOURCE_PERMISSIONS)
|
||||
install(DIRECTORY ${CMAKE_SOURCE_DIR}/pkg/lib/ DESTINATION /lib USE_SOURCE_PERMISSIONS)
|
||||
install(DIRECTORY ${CMAKE_SOURCE_DIR}/pkg/tmp/ DESTINATION /tmp USE_SOURCE_PERMISSIONS)
|
||||
install(DIRECTORY ${CMAKE_SOURCE_DIR}/pkg/usr/ DESTINATION ${CMAKE_INSTALL_PREFIX} USE_SOURCE_PERMISSIONS)
|
||||
@@ -25,7 +25,6 @@ Application::Application(int &argc, char **argv)
|
||||
if (!DPlatformWindowHandle::pluginVersion().isEmpty()) {
|
||||
setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
|
||||
}
|
||||
setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
setQuitOnLastWindowClosed(false); // 启用托盘图标时,关闭窗口程序仍然运行
|
||||
|
||||
|
||||
17
src/main.cpp
17
src/main.cpp
@@ -12,7 +12,6 @@
|
||||
#include <execinfo.h>
|
||||
|
||||
#include <DSysInfo>
|
||||
#include <DApplicationSettings>
|
||||
#include <DWidgetUtil>
|
||||
|
||||
#include <QDate>
|
||||
@@ -146,13 +145,10 @@ int main(int argc, char *argv[])
|
||||
// 浏览器开启 GPU 支持
|
||||
// qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-features=UseModernMediaControls");
|
||||
// qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--disable-web-security");
|
||||
#ifdef __sw_64__
|
||||
#if defined (__sw_64__) || defined (__loongarch__)
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--no-sandbox");
|
||||
#endif
|
||||
|
||||
#ifdef __loongarch__
|
||||
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--no-sandbox");
|
||||
#endif
|
||||
/**
|
||||
* NOTE: https://zhuanlan.zhihu.com/p/550285855
|
||||
* 避免 wayland 环境下从 QtWebEngine 后退回到 QWidget 时黑屏闪烁
|
||||
@@ -162,15 +158,6 @@ int main(int argc, char *argv[])
|
||||
DApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
|
||||
// 开启 Hidpi 支持
|
||||
qDebug() << "Enable HiDPI Support.";
|
||||
DApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
DApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
#endif
|
||||
|
||||
// 强制使用 DTK 平台插件
|
||||
QVector<char *> fakeArgs(argc + 2);
|
||||
fakeArgs[0] = argv[0];
|
||||
@@ -192,8 +179,6 @@ int main(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
DApplicationSettings settings; // 定义 DApplicationSettings,自动保存主题设置
|
||||
|
||||
MainWindow w;
|
||||
a.setMainWindow(&w); // 设置应用程序主窗口,用于初始化关于对话框
|
||||
// 让打开时界面显示在正中
|
||||
|
||||
@@ -134,7 +134,7 @@ void SettingsPage::on_pushButton_updateServer_clicked()
|
||||
ui->comboBox_server->setCurrentIndex(0); });
|
||||
}
|
||||
|
||||
void SettingsPage::on_comboBox_server_currentIndexChanged(const QString &arg1)
|
||||
void SettingsPage::on_comboBox_server_currentTextChanged(const QString &arg1)
|
||||
{
|
||||
SparkAPI::setServerUrl(arg1); // 服务器信息更新
|
||||
qDebug() << arg1;
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
private slots:
|
||||
void on_pushButton_updateServer_clicked();
|
||||
|
||||
void on_comboBox_server_currentIndexChanged(const QString &arg1);
|
||||
void on_comboBox_server_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_pushButton_updateApt_clicked();
|
||||
|
||||
|
||||
18
src/src.cmake
Normal file
18
src/src.cmake
Normal file
@@ -0,0 +1,18 @@
|
||||
include_directories(backend)
|
||||
include_directories(dbus)
|
||||
include_directories(pages)
|
||||
include_directories(utils)
|
||||
include_directories(widgets)
|
||||
|
||||
# https://cmake.org/cmake/help/v3.12/command/file.html#glob-recurse
|
||||
file(GLOB_RECURSE HEADERS CONFIGURE_DEPENDS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.hpp"
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/*.ui"
|
||||
)
|
||||
|
||||
qt6_add_resources(QRC_FILE ${CMAKE_CURRENT_SOURCE_DIR}/assets/assets.qrc)
|
||||
@@ -41,8 +41,7 @@ QString HttpRequest::postRequest(QString url, QString jsondata)
|
||||
QEventLoop eventLoop;
|
||||
connect(naManager, SIGNAL(finished(QNetworkReply *)), &eventLoop, SLOT(quit()));
|
||||
eventLoop.exec();
|
||||
QTextCodec *codec = QTextCodec::codecForName("utf8");
|
||||
QString strReply = codec->toUnicode(reply->readAll());
|
||||
QString strReply(reply->readAll());
|
||||
reply->deleteLater();
|
||||
return strReply;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QEventLoop>
|
||||
#include <QTextCodec>
|
||||
class HttpRequest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -17,7 +17,7 @@ big_image::big_image(DBlurEffectWidget *parent) : DBlurEffectWidget(parent),
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
setLayout(layout);
|
||||
layout->addWidget(m_image);
|
||||
layout->setMargin(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
// Make sure the image has a parent so that it will be freed.
|
||||
m_image->setParent(this);
|
||||
|
||||
@@ -158,7 +158,7 @@ void DownloadItem::on_pushButton_3_clicked()
|
||||
output_w->setMinimumHeight(600);
|
||||
output_w->setAttribute(Qt::WA_TranslucentBackground);
|
||||
output_w->setTitle(ui->label->text());
|
||||
output_w->layout()->setMargin(20);
|
||||
output_w->layout()->setContentsMargins(20, 20, 20, 20);
|
||||
output_w->layout()->addWidget(textbrowser);
|
||||
output_w->show();
|
||||
}
|
||||
@@ -198,7 +198,7 @@ void DownloadItem::slotAsyncInstall(int t)
|
||||
for (int i = 0; i < everyOut.size(); i++)
|
||||
{
|
||||
tempOutput = everyOut[i];
|
||||
if (everyOut[i].left(2) == tempOutput.contains("OMG-IT-GOES-WRONG"))
|
||||
if (tempOutput.contains("OMG-IT-GOES-WRONG"))
|
||||
{
|
||||
haveError = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user