From f9e3aa1aaebc53cead48c33cab97377a33aa8a65 Mon Sep 17 00:00:00 2001 From: JackLee <809262979@qq.com> Date: Fri, 28 Mar 2025 20:41:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0sui=E6=A0=B7=E5=BC=8F,?= =?UTF-8?q?=E9=BC=A0=E6=A0=87=E4=B9=B1=E8=B7=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/QCefWidget/MainWindow.cpp | 18 +++++----- src/main.cpp | 62 +++++++++++------------------------ src/sui.cpp | 8 ++--- src/sui.h | 1 - 4 files changed, 33 insertions(+), 56 deletions(-) diff --git a/src/QCefWidget/MainWindow.cpp b/src/QCefWidget/MainWindow.cpp index 53c539b..d98d205 100644 --- a/src/QCefWidget/MainWindow.cpp +++ b/src/QCefWidget/MainWindow.cpp @@ -39,14 +39,14 @@ MainWindow::MainWindow(QWidget* parent) // build the path to the web resource QDir dir = QCoreApplication::applicationDirPath(); -#if defined(Q_OS_MACOS) - QString webResourceDir = /*QString("file://") +*/ QDir::toNativeSeparators(dir.filePath("../Resources/webres")); -#else - QString webResourceDir = /*QString("file://") +*/ QDir::toNativeSeparators(dir.filePath("webres")); -#endif +// #if defined(Q_OS_MACOS) +// QString webResourceDir = /*QString("file://") +*/ QDir::toNativeSeparators(dir.filePath("../Resources/webres")); +// #else +// QString webResourceDir = /*QString("file://") +*/ QDir::toNativeSeparators(dir.filePath("webres")); +// #endif - // add a local folder to URL map (global) - QCefContext::instance()->addLocalFolderResource(webResourceDir, URL_ROOT); +// // add a local folder to URL map (global) +// QCefContext::instance()->addLocalFolderResource(webResourceDir, URL_ROOT); createLeftCefView(); createRightCefView(); @@ -64,7 +64,7 @@ MainWindow::createLeftCefView() QCefSetting setting; setting.setWindowlessFrameRate(1000); - setting.setHardwareAcceleration(false); + setting.setHardwareAcceleration(true); setting.setWindowInitialSize(QSize(1000,800)); // setting.setBackgroundColor(Qt::magenta); m_pLeftCefViewWidget = new CefViewWidget("https://www.testufo.com/", &setting, this); @@ -96,7 +96,7 @@ MainWindow::createRightCefView() setting.setPlugins(false); #endif setting.setWindowlessFrameRate(1000); - setting.setHardwareAcceleration(false); + setting.setHardwareAcceleration(true); QColor background(0, 255, 0, 255); setting.setBackgroundColor(background); setting.setWindowInitialSize(QSize(1000,800)); diff --git a/src/main.cpp b/src/main.cpp index 82a8b66..f21a999 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -12,7 +12,7 @@ // #include // #include // #include -// // 自定义 CefApp 类 +// // // 自定义 CefApp 类 // class CefAppQt : public CefApp, public CefBrowserProcessHandler // { // public: @@ -80,47 +80,25 @@ int main(int argc, char *argv[]) { - QApplication a(argc, argv); - QCefConfig config; - config.setUserAgent("Mozilla/5.0 (Windows NT 10.0; CEF/3.2272.2035) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 SoftwareInformer/1.6.1400"); - config.setLogLevel(QCefConfig::LOGSEVERITY_VERBOSE); - config.setBridgeObjectName("CtaiClient"); - config.setBuiltinSchemeName("Ctai"); - config.setWindowlessRenderingEnabled(false); - //config.setWindowlessRenderingEnabled(true); - //config.addCommandLineSwitch("single-process"); - //config.addCommandLineSwitch("enable-gpu"); - config.addCommandLineSwitchWithValue("type",""); - config.addCommandLineSwitchWithValue("builtin-scheme-name","Ctai"); - config.addCommandLineSwitchWithValue("bridge-obj-name","CtaiClient"); - //禁用沙盒 - config.addCommandLineSwitchWithValue("no-sandbox","ture"); - //禁止多线程会话循环(单进程为true,多进程为false); - config.addCommandLineSwitchWithValue("external-message-pump","true"); - config.addCommandLineSwitchWithValue("multi-threaded-message-loop","false"); - QCefContext cefContext(&a, argc, argv, &config); - MainWindow cw; - cw.show(); - -// qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype"); -// // 加载语言包 -// QTranslator qtBaseTranslator; -// if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm"))) -// { -// // 处理加载翻译文件失败的情况 -// qDebug() << "Failed to load translation file."; -// return -1; -// } -// a.installTranslator(&qtBaseTranslator); -// // 读取窗体的配置并初始化 -// sui_init_config(); -// ctai x; -// x.init_layout(); -// // 仅限于windows平台 -// #if defined(__WIN32__) -// x.title()->set_type(QD_TYPE::QD_EXIT); -// #endif -// x.show(); + qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype"); + // 加载语言包 + QTranslator qtBaseTranslator; + if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm"))) + { + // 处理加载翻译文件失败的情况 + qDebug() << "Failed to load translation file."; + return -1; + } + a.installTranslator(&qtBaseTranslator); + // 读取窗体的配置并初始化 + sui_init_config(); + ctai x; + x.init_layout(); + // 仅限于windows平台 +#if defined(__WIN32__) + x.title()->set_type(QD_TYPE::QD_EXIT); +#endif + x.show(); return a.exec(); } diff --git a/src/sui.cpp b/src/sui.cpp index 0dea31d..7583f9a 100644 --- a/src/sui.cpp +++ b/src/sui.cpp @@ -263,11 +263,11 @@ void sui::mouseMoveEvent(QMouseEvent *event) // 鼠标释放事件 void sui::mouseReleaseEvent(QMouseEvent *event) { - if (event->button() == Qt::LeftButton) - { - m_press = false; + m_press = false; + if (ori!=NONE) + { ori = NONE; // 直接重置方向 - this->setCursor(QCursor(Qt::ArrowCursor)); this->releaseMouse(); + this->setCursor(QCursor(Qt::ArrowCursor)); } } \ No newline at end of file diff --git a/src/sui.h b/src/sui.h index 87c43a2..9727a9f 100644 --- a/src/sui.h +++ b/src/sui.h @@ -29,7 +29,6 @@ private: bool m_press; int m_border_width; Orient ori; - sui_title *m_title; protected: void paintEvent(QPaintEvent *event);