更新sui样式,鼠标乱跑问题
This commit is contained in:
parent
7fbc814d2f
commit
f9e3aa1aae
@ -39,14 +39,14 @@ MainWindow::MainWindow(QWidget* parent)
|
|||||||
|
|
||||||
// build the path to the web resource
|
// build the path to the web resource
|
||||||
QDir dir = QCoreApplication::applicationDirPath();
|
QDir dir = QCoreApplication::applicationDirPath();
|
||||||
#if defined(Q_OS_MACOS)
|
// #if defined(Q_OS_MACOS)
|
||||||
QString webResourceDir = /*QString("file://") +*/ QDir::toNativeSeparators(dir.filePath("../Resources/webres"));
|
// QString webResourceDir = /*QString("file://") +*/ QDir::toNativeSeparators(dir.filePath("../Resources/webres"));
|
||||||
#else
|
// #else
|
||||||
QString webResourceDir = /*QString("file://") +*/ QDir::toNativeSeparators(dir.filePath("webres"));
|
// QString webResourceDir = /*QString("file://") +*/ QDir::toNativeSeparators(dir.filePath("webres"));
|
||||||
#endif
|
// #endif
|
||||||
|
|
||||||
// add a local folder to URL map (global)
|
// // add a local folder to URL map (global)
|
||||||
QCefContext::instance()->addLocalFolderResource(webResourceDir, URL_ROOT);
|
// QCefContext::instance()->addLocalFolderResource(webResourceDir, URL_ROOT);
|
||||||
|
|
||||||
createLeftCefView();
|
createLeftCefView();
|
||||||
createRightCefView();
|
createRightCefView();
|
||||||
@ -64,7 +64,7 @@ MainWindow::createLeftCefView()
|
|||||||
|
|
||||||
QCefSetting setting;
|
QCefSetting setting;
|
||||||
setting.setWindowlessFrameRate(1000);
|
setting.setWindowlessFrameRate(1000);
|
||||||
setting.setHardwareAcceleration(false);
|
setting.setHardwareAcceleration(true);
|
||||||
setting.setWindowInitialSize(QSize(1000,800));
|
setting.setWindowInitialSize(QSize(1000,800));
|
||||||
// setting.setBackgroundColor(Qt::magenta);
|
// setting.setBackgroundColor(Qt::magenta);
|
||||||
m_pLeftCefViewWidget = new CefViewWidget("https://www.testufo.com/", &setting, this);
|
m_pLeftCefViewWidget = new CefViewWidget("https://www.testufo.com/", &setting, this);
|
||||||
@ -96,7 +96,7 @@ MainWindow::createRightCefView()
|
|||||||
setting.setPlugins(false);
|
setting.setPlugins(false);
|
||||||
#endif
|
#endif
|
||||||
setting.setWindowlessFrameRate(1000);
|
setting.setWindowlessFrameRate(1000);
|
||||||
setting.setHardwareAcceleration(false);
|
setting.setHardwareAcceleration(true);
|
||||||
QColor background(0, 255, 0, 255);
|
QColor background(0, 255, 0, 255);
|
||||||
setting.setBackgroundColor(background);
|
setting.setBackgroundColor(background);
|
||||||
setting.setWindowInitialSize(QSize(1000,800));
|
setting.setWindowInitialSize(QSize(1000,800));
|
||||||
|
|||||||
62
src/main.cpp
62
src/main.cpp
@ -12,7 +12,7 @@
|
|||||||
// #include <include/cef_client.h>
|
// #include <include/cef_client.h>
|
||||||
// #include <include/cef_render_handler.h>
|
// #include <include/cef_render_handler.h>
|
||||||
// #include <include/cef_browser.h>
|
// #include <include/cef_browser.h>
|
||||||
// // 自定义 CefApp 类
|
// // // 自定义 CefApp 类
|
||||||
// class CefAppQt : public CefApp, public CefBrowserProcessHandler
|
// class CefAppQt : public CefApp, public CefBrowserProcessHandler
|
||||||
// {
|
// {
|
||||||
// public:
|
// public:
|
||||||
@ -80,47 +80,25 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
QCefConfig config;
|
qputenv("QT_QPA_PLATFORM", "windows:fontengine=freetype");
|
||||||
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);
|
QTranslator qtBaseTranslator;
|
||||||
config.setBridgeObjectName("CtaiClient");
|
if (!qtBaseTranslator.load(QStringLiteral(":/res/translator/qtbase_zh_CN.qm")))
|
||||||
config.setBuiltinSchemeName("Ctai");
|
{
|
||||||
config.setWindowlessRenderingEnabled(false);
|
// 处理加载翻译文件失败的情况
|
||||||
//config.setWindowlessRenderingEnabled(true);
|
qDebug() << "Failed to load translation file.";
|
||||||
//config.addCommandLineSwitch("single-process");
|
return -1;
|
||||||
//config.addCommandLineSwitch("enable-gpu");
|
}
|
||||||
config.addCommandLineSwitchWithValue("type","");
|
a.installTranslator(&qtBaseTranslator);
|
||||||
config.addCommandLineSwitchWithValue("builtin-scheme-name","Ctai");
|
// 读取窗体的配置并初始化
|
||||||
config.addCommandLineSwitchWithValue("bridge-obj-name","CtaiClient");
|
sui_init_config();
|
||||||
//禁用沙盒
|
ctai x;
|
||||||
config.addCommandLineSwitchWithValue("no-sandbox","ture");
|
x.init_layout();
|
||||||
//禁止多线程会话循环(单进程为true,多进程为false);
|
// 仅限于windows平台
|
||||||
config.addCommandLineSwitchWithValue("external-message-pump","true");
|
#if defined(__WIN32__)
|
||||||
config.addCommandLineSwitchWithValue("multi-threaded-message-loop","false");
|
x.title()->set_type(QD_TYPE::QD_EXIT);
|
||||||
QCefContext cefContext(&a, argc, argv, &config);
|
#endif
|
||||||
MainWindow cw;
|
x.show();
|
||||||
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();
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -263,11 +263,11 @@ void sui::mouseMoveEvent(QMouseEvent *event)
|
|||||||
// 鼠标释放事件
|
// 鼠标释放事件
|
||||||
void sui::mouseReleaseEvent(QMouseEvent *event)
|
void sui::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton)
|
m_press = false;
|
||||||
{
|
if (ori!=NONE)
|
||||||
m_press = false;
|
{
|
||||||
ori = NONE; // 直接重置方向
|
ori = NONE; // 直接重置方向
|
||||||
this->setCursor(QCursor(Qt::ArrowCursor));
|
|
||||||
this->releaseMouse();
|
this->releaseMouse();
|
||||||
|
this->setCursor(QCursor(Qt::ArrowCursor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user