mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
OpenGL: add option in settings on Windows to specify OpenGL implementation
This commit is contained in:
parent
c606069c1c
commit
1951b30b11
@ -331,6 +331,12 @@ VGeneralTab::VGeneralTab(QWidget *p_parent)
|
||||
m_keyboardLayoutCombo = VUtils::getComboBox(this);
|
||||
m_keyboardLayoutCombo->setToolTip(tr("Choose the keyboard layout mapping to use in shortcuts"));
|
||||
|
||||
// OpenGL option.
|
||||
#if defined(Q_OS_WIN)
|
||||
m_openGLCombo = VUtils::getComboBox(this);
|
||||
m_openGLCombo->setToolTip(tr("Choose the OpenGL implementation to load (restart VNote to make it work)"));
|
||||
#endif
|
||||
|
||||
QPushButton *editLayoutBtn = new QPushButton(tr("Edit"), this);
|
||||
connect(editLayoutBtn, &QPushButton::clicked,
|
||||
this, [this]() {
|
||||
@ -351,6 +357,10 @@ VGeneralTab::VGeneralTab(QWidget *p_parent)
|
||||
optionLayout->addRow(tr("Quick access:"), qaLayout);
|
||||
optionLayout->addRow(tr("Keyboard layout mapping:"), klLayout);
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
optionLayout->addRow(tr("OpenGL:"), m_openGLCombo);
|
||||
#endif
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
mainLayout->addLayout(optionLayout);
|
||||
|
||||
@ -434,6 +444,10 @@ bool VGeneralTab::loadConfiguration()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!loadOpenGL()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -459,6 +473,10 @@ bool VGeneralTab::saveConfiguration()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!saveOpenGL()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -589,6 +607,34 @@ bool VGeneralTab::saveKeyboardLayoutMapping()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VGeneralTab::loadOpenGL()
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
m_openGLCombo->clear();
|
||||
|
||||
m_openGLCombo->addItem(tr("System"), OpenGLDefault);
|
||||
m_openGLCombo->addItem(tr("DesktopOpenGL"), OpenGLDesktop);
|
||||
m_openGLCombo->addItem(tr("OpenGLES"), OpenGLAngle);
|
||||
m_openGLCombo->addItem(tr("SoftwareOpenGL"), OpenGLSoftware);
|
||||
|
||||
int opt = VConfigManager::getWindowsOpenGL();
|
||||
int idx = m_openGLCombo->findData(opt);
|
||||
if (idx == -1) {
|
||||
idx = 0;
|
||||
}
|
||||
m_openGLCombo->setCurrentIndex(idx);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VGeneralTab::saveOpenGL()
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
VConfigManager::setWindowsOpenGL(m_openGLCombo->currentData().toInt());
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
VLookTab::VLookTab(QWidget *p_parent)
|
||||
: QWidget(p_parent)
|
||||
{
|
||||
|
@ -46,6 +46,9 @@ private:
|
||||
bool loadKeyboardLayoutMapping();
|
||||
bool saveKeyboardLayoutMapping();
|
||||
|
||||
bool loadOpenGL();
|
||||
bool saveOpenGL();
|
||||
|
||||
// Language
|
||||
QComboBox *m_langCombo;
|
||||
|
||||
@ -67,6 +70,11 @@ private:
|
||||
// Keyboard layout mappings.
|
||||
QComboBox *m_keyboardLayoutCombo;
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
// Windows OpenGL.
|
||||
QComboBox *m_openGLCombo;
|
||||
#endif
|
||||
|
||||
static const QVector<QString> c_availableLangs;
|
||||
};
|
||||
|
||||
|
33
src/main.cpp
33
src/main.cpp
@ -127,15 +127,38 @@ int main(int argc, char *argv[])
|
||||
QTextCodec::setCodecForLocale(codec);
|
||||
}
|
||||
|
||||
// Set openGL version.
|
||||
// Or set environment QT_OPENGL to "angle/desktop/software".
|
||||
// QCoreApplication::setAttribute(Qt::AA_UseOpenGLES, true);
|
||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
|
||||
// This only takes effect on Win, X11 and Android.
|
||||
// It will disturb original scaling. Just disable it for now.
|
||||
// QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||
|
||||
// Set openGL version.
|
||||
// Or set environment QT_OPENGL to "angle/desktop/software".
|
||||
// QCoreApplication::setAttribute(Qt::AA_UseOpenGLES, true);
|
||||
#if defined(Q_OS_WIN)
|
||||
int winOpenGL = VConfigManager::getWindowsOpenGL();
|
||||
qInfo() << "OpenGL option" << winOpenGL;
|
||||
switch (winOpenGL) {
|
||||
case 1:
|
||||
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
|
||||
break;
|
||||
|
||||
case 0:
|
||||
V_FALLTHROUGH;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
// The file path passed via command line arguments.
|
||||
@ -186,8 +209,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
// Check the openSSL.
|
||||
if (checkSSL) {
|
||||
qDebug() << "openGL" << QOpenGLContext::openGLModuleType();
|
||||
qDebug() << "openSSL"
|
||||
qInfo() << "openGL" << QOpenGLContext::openGLModuleType();
|
||||
qInfo() << "openSSL"
|
||||
<< QSslSocket::sslLibraryBuildVersionString()
|
||||
<< QSslSocket::sslLibraryVersionNumber();
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
; Theme name
|
||||
theme=v_pure
|
||||
|
||||
welcome_page_path=:/resources/welcome.html
|
||||
|
||||
; CSS style name for Markdown template
|
||||
; Empty to use theme's css style
|
||||
css_style=
|
||||
@ -278,6 +276,13 @@ split_file_list=false
|
||||
; Whether split file list out of the tag explorer
|
||||
split_tag_file_list=false
|
||||
|
||||
; OpenGL option for Windows
|
||||
; 0 - no set;
|
||||
; 1 - desktop;
|
||||
; 2 - angle;
|
||||
; 3 - software;
|
||||
windows_opengl=0
|
||||
|
||||
[editor]
|
||||
; Auto indent as previous line
|
||||
auto_indent=true
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <QTextEdit>
|
||||
#include <QStandardPaths>
|
||||
#include <QCoreApplication>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#include "utils/vutils.h"
|
||||
#include "vstyleparser.h"
|
||||
#include "vpalette.h"
|
||||
@ -86,8 +88,6 @@ void VConfigManager::initialize()
|
||||
|
||||
m_defaultEditPalette = QTextEdit().palette();
|
||||
|
||||
welcomePagePath = getConfigFromSettings("global", "welcome_page_path").toString();
|
||||
|
||||
markdownExtensions = hoedown_extensions(HOEDOWN_EXT_TABLES | HOEDOWN_EXT_FENCED_CODE |
|
||||
HOEDOWN_EXT_HIGHLIGHT | HOEDOWN_EXT_AUTOLINK |
|
||||
HOEDOWN_EXT_QUOTE | HOEDOWN_EXT_MATH | HOEDOWN_EXT_MATH_EXPLICIT);
|
||||
@ -1680,3 +1680,40 @@ void VConfigManager::checkVersion()
|
||||
setConfigToSettings("global", key, c_version);
|
||||
}
|
||||
}
|
||||
|
||||
int VConfigManager::getWindowsOpenGL()
|
||||
{
|
||||
const char *codecForIni = "UTF-8";
|
||||
|
||||
QScopedPointer<QSettings> userSet(new QSettings(QSettings::IniFormat,
|
||||
QSettings::UserScope,
|
||||
orgName,
|
||||
appName));
|
||||
userSet->setIniCodec(codecForIni);
|
||||
|
||||
QString fullKey("global/windows_opengl");
|
||||
QVariant val = userSet->value(fullKey);
|
||||
if (!val.isNull()) {
|
||||
return val.toInt();
|
||||
}
|
||||
|
||||
// Default vnote.ini from resource file.
|
||||
QScopedPointer<QSettings> defaultSet(new QSettings(c_defaultConfigFilePath,
|
||||
QSettings::IniFormat));
|
||||
defaultSet->setIniCodec(codecForIni);
|
||||
return defaultSet->value(fullKey).toInt();
|
||||
}
|
||||
|
||||
void VConfigManager::setWindowsOpenGL(int p_openGL)
|
||||
{
|
||||
const char *codecForIni = "UTF-8";
|
||||
|
||||
QScopedPointer<QSettings> userSet(new QSettings(QSettings::IniFormat,
|
||||
QSettings::UserScope,
|
||||
orgName,
|
||||
appName));
|
||||
userSet->setIniCodec(codecForIni);
|
||||
|
||||
QString fullKey("global/windows_opengl");
|
||||
userSet->setValue(fullKey, p_openGL);
|
||||
}
|
||||
|
@ -74,6 +74,14 @@ enum
|
||||
AutoScrollAlways = 2
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
OpenGLDefault = 0,
|
||||
OpenGLDesktop = 1,
|
||||
OpenGLAngle = 2,
|
||||
OpenGLSoftware = 3
|
||||
};
|
||||
|
||||
class VConfigManager : public QObject
|
||||
{
|
||||
public:
|
||||
@ -101,6 +109,12 @@ public:
|
||||
|
||||
static QString getDocumentPathOrHomePath();
|
||||
|
||||
// Get windows_opengl config.
|
||||
// Because we may call this before QApplication initialization, we only
|
||||
// read/write the config to the user folder.
|
||||
static int getWindowsOpenGL();
|
||||
static void setWindowsOpenGL(int p_openGL);
|
||||
|
||||
// Constants
|
||||
static const QString orgName;
|
||||
static const QString appName;
|
||||
@ -126,8 +140,6 @@ public:
|
||||
|
||||
QHash<QString, QTextCharFormat> getCodeBlockStyles() const;
|
||||
|
||||
QString getWelcomePagePath() const;
|
||||
|
||||
QString getLogFilePath() const;
|
||||
|
||||
// Get the css style URL for web view.
|
||||
@ -711,8 +723,6 @@ private:
|
||||
QVector<HighlightingStyle> mdHighlightingStyles;
|
||||
QHash<QString, QTextCharFormat> m_codeBlockStyles;
|
||||
|
||||
QString welcomePagePath;
|
||||
|
||||
// Index of current notebook.
|
||||
int curNotebookIndex;
|
||||
|
||||
@ -1164,11 +1174,6 @@ inline QHash<QString, QTextCharFormat> VConfigManager::getCodeBlockStyles() cons
|
||||
return m_codeBlockStyles;
|
||||
}
|
||||
|
||||
inline QString VConfigManager::getWelcomePagePath() const
|
||||
{
|
||||
return welcomePagePath;
|
||||
}
|
||||
|
||||
inline QFont VConfigManager::getBaseEditFont() const
|
||||
{
|
||||
return baseEditFont;
|
||||
|
Loading…
x
Reference in New Issue
Block a user