更新sui样式,鼠标乱跑问题

This commit is contained in:
JackLee 2025-03-28 20:41:34 +08:00
parent 7fbc814d2f
commit f9e3aa1aae
4 changed files with 33 additions and 56 deletions

View File

@ -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));

View File

@ -12,7 +12,7 @@
// #include <include/cef_client.h>
// #include <include/cef_render_handler.h>
// #include <include/cef_browser.h>
// // 自定义 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();
}

View File

@ -263,11 +263,11 @@ void sui::mouseMoveEvent(QMouseEvent *event)
// 鼠标释放事件
void sui::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
m_press = false;
if (ori!=NONE)
{
ori = NONE; // 直接重置方向
this->setCursor(QCursor(Qt::ArrowCursor));
this->releaseMouse();
this->setCursor(QCursor(Qt::ArrowCursor));
}
}

View File

@ -29,7 +29,6 @@ private:
bool m_press;
int m_border_width;
Orient ori;
sui_title *m_title;
protected:
void paintEvent(QPaintEvent *event);