mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-14 13:29:58 +01:00
Merge branch 'master' into terminal_strip
* master: (21 commits) Minor: remove spaces in filenames minor: remove capital letters Add new symbols Fibaro, thanks Bertus Update Hungarian translation, thanks Gubányi modified: lang/qet_nl.qm modified: lang/qet_nl.ts Add preprocessor to check Qt version Update *TS files Add possibility to user to choose hdpi round policy Minor improvement for function QETApp::customElementsDir() and QETApp::commonElementsDir() Add new GCE symbol Flatpak: update qet_tb_generator to version 1.3.1 Add new symbol nodemcu_v3, thanks Bertus Add new symbols ci: Build edge snaps on GitHub & release to store snap: Port to core20 Flatpak update qet_tb_generator to 1.3.0 version Fix typo in URL SNAP change Github source to https://github.com/raulroda/qet_tb_generator-plugin modified: lang/qet_nl.qm modified: lang/qet_nl.ts upgraded elements and renamed company ...
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "qetapp.h"
|
||||
#include "singleapplication.h"
|
||||
#include "utils/macosxopenevent.h"
|
||||
#include "utils/qetsettings.h"
|
||||
|
||||
#include <QStyleFactory>
|
||||
#include <QtConcurrent>
|
||||
@@ -178,7 +179,7 @@ int main(int argc, char **argv)
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
qputenv("QT_ENABLE_HIGHDPI_SCALING", "1");
|
||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(QetSettings::hdpiScaleFactorRoundingPolicy());
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -49,14 +49,17 @@
|
||||
#endif
|
||||
|
||||
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
|
||||
QString QETApp::common_elements_dir = QString();
|
||||
QString QETApp::m_overrided_common_elements_dir = QString();
|
||||
#endif
|
||||
|
||||
#ifdef QET_ALLOW_OVERRIDE_CTBTD_OPTION
|
||||
QString QETApp::common_tbt_dir_ = QString();
|
||||
#endif
|
||||
|
||||
#ifdef QET_ALLOW_OVERRIDE_CD_OPTION
|
||||
QString QETApp::config_dir = QString();
|
||||
#endif
|
||||
|
||||
QString QETApp::lang_dir = QString();
|
||||
TitleBlockTemplatesFilesCollection *QETApp::m_common_tbt_collection;
|
||||
TitleBlockTemplatesFilesCollection *QETApp::m_custom_tbt_collection;
|
||||
@@ -66,8 +69,13 @@ uint QETApp::next_project_id = 0;
|
||||
RecentFiles *QETApp::m_projects_recent_files = nullptr;
|
||||
RecentFiles *QETApp::m_elements_recent_files = nullptr;
|
||||
TitleBlockTemplate *QETApp::default_titleblock_template_ = nullptr;
|
||||
QString QETApp::m_user_common_elements_dir = QString();
|
||||
QString QETApp::m_user_custom_elements_dir = QString();
|
||||
|
||||
QString QETApp::m_common_element_dir = QString();
|
||||
bool QETApp::m_common_element_dir_is_set = false;
|
||||
|
||||
QString QETApp::m_custom_element_dir = QString();
|
||||
bool QETApp::m_custom_element_dir_is_set = false;
|
||||
|
||||
QString QETApp::m_user_custom_tbt_dir = QString();
|
||||
QETApp *QETApp::m_qetapp = nullptr;
|
||||
|
||||
@@ -488,57 +496,62 @@ TitleBlockTemplatesCollection *QETApp::titleBlockTemplatesCollection(
|
||||
*/
|
||||
QString QETApp::commonElementsDir()
|
||||
{
|
||||
if (m_user_common_elements_dir.isEmpty())
|
||||
if (m_common_element_dir_is_set)
|
||||
{
|
||||
return m_common_element_dir;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_common_element_dir_is_set = true;
|
||||
|
||||
//Check if user define a custom path
|
||||
//for the common collection
|
||||
QSettings settings;
|
||||
QString path = settings.value(
|
||||
"elements-collections/common-collection-path",
|
||||
"default").toString();
|
||||
"elements-collections/common-collection-path",
|
||||
"default").toString();
|
||||
if (path != "default" && !path.isEmpty())
|
||||
{
|
||||
QDir dir(path);
|
||||
if (dir.exists())
|
||||
{
|
||||
m_user_common_elements_dir = path;
|
||||
return m_user_common_elements_dir;
|
||||
m_common_element_dir = path;
|
||||
return m_common_element_dir;
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_user_common_elements_dir = "default";
|
||||
}
|
||||
}
|
||||
else if (m_user_common_elements_dir != "default") {
|
||||
return m_user_common_elements_dir;
|
||||
}
|
||||
|
||||
#ifdef QET_ALLOW_OVERRIDE_CED_OPTION
|
||||
if (common_elements_dir != QString()) return(common_elements_dir);
|
||||
if (m_overrided_common_elements_dir != QString()) {
|
||||
m_common_element_dir = m_overrided_common_elements_dir;
|
||||
return(m_common_element_dir);
|
||||
}
|
||||
m_common_element_dir = QCoreApplication::applicationDirPath() + "/elements";
|
||||
return m_common_element_dir;
|
||||
#endif
|
||||
#ifndef QET_COMMON_COLLECTION_PATH
|
||||
/* in the absence of a compilation option,
|
||||
* we use the elements folder, located next to the executable binary
|
||||
* en l'absence d'option de compilation,
|
||||
* on utilise le dossier elements, situe a cote du binaire executable
|
||||
*/
|
||||
return(QCoreApplication::applicationDirPath() + "/elements/");
|
||||
/* in the absence of a compilation option,
|
||||
* we use the elements folder, located next to the executable binary
|
||||
*/
|
||||
m_common_element_dir = QCoreApplication::applicationDirPath() + "/elements";
|
||||
return m_common_element_dir;
|
||||
#else
|
||||
#ifndef QET_COMMON_COLLECTION_PATH_RELATIVE_TO_BINARY_PATH
|
||||
#ifndef QET_COMMON_COLLECTION_PATH_RELATIVE_TO_BINARY_PATH
|
||||
/* the compilation option represents a classic absolute
|
||||
* or relative path
|
||||
* l'option de compilation represente un chemin absolu
|
||||
* ou relatif classique
|
||||
*/
|
||||
return(QUOTE(QET_COMMON_COLLECTION_PATH));
|
||||
#else
|
||||
m_common_element_dir = QUOTE(QET_COMMON_COLLECTION_PATH);
|
||||
return m_common_element_dir;
|
||||
#else
|
||||
/* the compilation option represents a path
|
||||
* relative to the folder containing the executable binary
|
||||
* l'option de compilation represente un chemin
|
||||
* relatif au dossier contenant le binaire executable
|
||||
*/
|
||||
return(QCoreApplication::applicationDirPath()
|
||||
+ "/" + QUOTE(QET_COMMON_COLLECTION_PATH));
|
||||
#endif
|
||||
* relative to the folder containing the executable binary
|
||||
*/
|
||||
m_common_element_dir = QCoreApplication::applicationDirPath()
|
||||
+ "/"
|
||||
+ QUOTE(QET_COMMON_COLLECTION_PATH);
|
||||
return m_common_element_dir;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -547,33 +560,34 @@ QString QETApp::commonElementsDir()
|
||||
*/
|
||||
QString QETApp::customElementsDir()
|
||||
{
|
||||
if (m_user_custom_elements_dir.isEmpty())
|
||||
if (m_custom_element_dir_is_set)
|
||||
{
|
||||
return m_custom_element_dir;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_custom_element_dir_is_set = true;
|
||||
|
||||
QSettings settings;
|
||||
QString path = settings.value(
|
||||
"elements-collections/custom-collection-path",
|
||||
"default").toString();
|
||||
"elements-collections/custom-collection-path",
|
||||
"default").toString();
|
||||
if (path != "default" && !path.isEmpty())
|
||||
{
|
||||
QDir dir(path);
|
||||
if (dir.exists())
|
||||
{
|
||||
m_user_custom_elements_dir = path;
|
||||
if(!m_user_custom_elements_dir.endsWith("/")) {
|
||||
m_user_custom_elements_dir.append("/");
|
||||
}
|
||||
return m_user_custom_elements_dir;
|
||||
{
|
||||
m_custom_element_dir = path;
|
||||
if(!m_custom_element_dir.endsWith("/")) {
|
||||
m_custom_element_dir.append("/");
|
||||
}
|
||||
return m_custom_element_dir;
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_user_custom_elements_dir = "default";
|
||||
}
|
||||
}
|
||||
else if (m_user_custom_elements_dir != "default") {
|
||||
return m_user_custom_elements_dir;
|
||||
}
|
||||
|
||||
return(configDir() + "elements/");
|
||||
m_custom_element_dir = configDir() + "elements/";
|
||||
return m_custom_element_dir;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -601,14 +615,19 @@ QString QETApp::customElementsDirN()
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETApp::resetUserElementsDir
|
||||
Reset the path of the user common and custom elements dir.
|
||||
Use this function when the user path (common and/or custom) change.
|
||||
*/
|
||||
void QETApp::resetUserElementsDir()
|
||||
* @brief QETApp::resetCollectionsPath
|
||||
* Reset the path of the user and common element collection
|
||||
* and also the user titleblock path.
|
||||
* Use this function when one of these three path change.
|
||||
*/
|
||||
void QETApp::resetCollectionsPath()
|
||||
{
|
||||
m_user_common_elements_dir.clear();
|
||||
m_user_custom_elements_dir.clear();
|
||||
m_common_element_dir.clear();
|
||||
m_common_element_dir_is_set = false;
|
||||
|
||||
m_custom_element_dir.clear();
|
||||
m_custom_element_dir_is_set = false;
|
||||
|
||||
m_user_custom_tbt_dir.clear();
|
||||
}
|
||||
|
||||
@@ -877,9 +896,9 @@ void QETApp::overrideCommonElementsDir(const QString &new_ced) {
|
||||
QFileInfo new_ced_info(new_ced);
|
||||
if (new_ced_info.isDir())
|
||||
{
|
||||
common_elements_dir = new_ced_info.absoluteFilePath();
|
||||
if (!common_elements_dir.endsWith("/"))
|
||||
common_elements_dir += "/";
|
||||
m_overrided_common_elements_dir = new_ced_info.absoluteFilePath();
|
||||
if (!m_overrided_common_elements_dir.endsWith("/"))
|
||||
m_overrided_common_elements_dir += "/";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -83,7 +83,7 @@ class QETApp : public QObject
|
||||
static QString customElementsDir();
|
||||
static QString commonElementsDirN();
|
||||
static QString customElementsDirN();
|
||||
static void resetUserElementsDir();
|
||||
static void resetCollectionsPath();
|
||||
static QString commonTitleBlockTemplatesDir();
|
||||
static QString customTitleBlockTemplatesDir();
|
||||
static bool registerProject(QETProject *);
|
||||
@@ -108,7 +108,7 @@ class QETApp : public QObject
|
||||
@brief common_elements_dir
|
||||
Directory containing the common elements collection
|
||||
*/
|
||||
static QString common_elements_dir;
|
||||
static QString m_overrided_common_elements_dir;
|
||||
#endif
|
||||
|
||||
#ifdef QET_ALLOW_OVERRIDE_CTBTD_OPTION
|
||||
@@ -208,9 +208,15 @@ class QETApp : public QObject
|
||||
static RecentFiles *m_projects_recent_files;
|
||||
static RecentFiles *m_elements_recent_files;
|
||||
static TitleBlockTemplate *default_titleblock_template_;
|
||||
static QString m_user_common_elements_dir;
|
||||
static QString m_user_custom_elements_dir;
|
||||
|
||||
static QString m_common_element_dir;
|
||||
static bool m_common_element_dir_is_set;
|
||||
|
||||
static QString m_custom_element_dir;
|
||||
static bool m_custom_element_dir_is_set;
|
||||
|
||||
static QString m_user_custom_tbt_dir;
|
||||
|
||||
|
||||
public slots:
|
||||
void systray(QSystemTrayIcon::ActivationReason);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "../../qetapp.h"
|
||||
#include "../../qeticons.h"
|
||||
#include "ui_generalconfigurationpage.h"
|
||||
#include "../../utils/qetsettings.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QFontDialog>
|
||||
@@ -37,6 +38,33 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
|
||||
QSettings settings;
|
||||
|
||||
//Appearance tab
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) // ###Qt 6:remove
|
||||
ui->m_hdpi_round_policy_widget->setDisabled(true);
|
||||
#else
|
||||
ui->m_hdpi_round_policy_cb->addItem(tr("Arrondi supérieur pour 0.5 et plus"), QLatin1String("Round"));
|
||||
ui->m_hdpi_round_policy_cb->addItem(tr("Toujours arrondi supérieur"), QLatin1String("Ceil"));
|
||||
ui->m_hdpi_round_policy_cb->addItem(tr("Toujours arrondi inférieur"), QLatin1String("Floor"));
|
||||
ui->m_hdpi_round_policy_cb->addItem(tr("Arrondi supérieur pour 0.75 et plus"), QLatin1String("RoundPreferFloor"));
|
||||
ui->m_hdpi_round_policy_cb->addItem(tr("Pas d'arrondi"), QLatin1String("PassThrough"));
|
||||
switch (QetSettings::hdpiScaleFactorRoundingPolicy()) {
|
||||
case Qt::HighDpiScaleFactorRoundingPolicy::Round:
|
||||
ui->m_hdpi_round_policy_cb->setCurrentIndex(0);
|
||||
break;
|
||||
case Qt::HighDpiScaleFactorRoundingPolicy::Ceil:
|
||||
ui->m_hdpi_round_policy_cb->setCurrentIndex(1);
|
||||
break;
|
||||
case Qt::HighDpiScaleFactorRoundingPolicy::Floor:
|
||||
ui->m_hdpi_round_policy_cb->setCurrentIndex(2);
|
||||
break;
|
||||
case Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor:
|
||||
ui->m_hdpi_round_policy_cb->setCurrentIndex(3);
|
||||
break;
|
||||
default:
|
||||
ui->m_hdpi_round_policy_cb->setCurrentIndex(4);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
ui->DiagramEditor_xGrid_sb->setValue(settings.value("diagrameditor/Xgrid", 10).toInt());
|
||||
ui->DiagramEditor_yGrid_sb->setValue(settings.value("diagrameditor/Ygrid", 10).toInt());
|
||||
ui->DiagramEditor_xKeyGrid_sb->setValue(settings.value("diagrameditor/key_Xgrid", 10).toInt());
|
||||
@@ -149,6 +177,12 @@ void GeneralConfigurationPage::applyConf()
|
||||
settings.setValue("border-columns_0",ui->m_border_0->isChecked());
|
||||
settings.setValue("lang", ui->m_lang_cb->itemData(ui->m_lang_cb->currentIndex()).toString());
|
||||
|
||||
//hdpi
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
QetSettings::setHdpiScaleFactorRoundingPolicy(ui->m_hdpi_round_policy_cb->currentData().toString());
|
||||
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(QetSettings::hdpiScaleFactorRoundingPolicy());
|
||||
#endif
|
||||
|
||||
//ELEMENT EDITOR
|
||||
settings.setValue("elementeditor/default-informations", ui->m_default_elements_info->toPlainText());
|
||||
|
||||
@@ -197,7 +231,7 @@ void GeneralConfigurationPage::applyConf()
|
||||
settings.setValue("elements-collections/common-collection-path", "default");
|
||||
}
|
||||
if (path != settings.value("elements-collections/common-collection-path").toString()) {
|
||||
QETApp::resetUserElementsDir();
|
||||
QETApp::resetCollectionsPath();
|
||||
}
|
||||
|
||||
path = settings.value("elements-collections/custom-collection-path").toString();
|
||||
@@ -212,7 +246,7 @@ void GeneralConfigurationPage::applyConf()
|
||||
settings.setValue("elements-collections/custom-collection-path", "default");
|
||||
}
|
||||
if (path != settings.value("elements-collections/custom-collection-path").toString()) {
|
||||
QETApp::resetUserElementsDir();
|
||||
QETApp::resetCollectionsPath();
|
||||
}
|
||||
|
||||
path = settings.value("elements-collections/custom-tbt-path").toString();
|
||||
@@ -227,7 +261,7 @@ void GeneralConfigurationPage::applyConf()
|
||||
settings.setValue("elements-collections/custom-tbt-path", "default");
|
||||
}
|
||||
if (path != settings.value("elements-collections/custom-tbt-path").toString()) {
|
||||
QETApp::resetUserElementsDir();
|
||||
QETApp::resetCollectionsPath();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>727</width>
|
||||
<height>510</height>
|
||||
<width>822</width>
|
||||
<height>411</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -17,7 +17,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>5</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
@@ -73,6 +73,41 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="m_hdpi_round_policy_widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Méthode de mise à l'echelle des écrans à haute densité de pixels (hdpi) (appliqué au prochain lancement de QElectroTech) :</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="m_hdpi_round_policy_cb"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
||||
110
sources/utils/qetsettings.cpp
Normal file
110
sources/utils/qetsettings.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "qetsettings.h"
|
||||
#include <QSettings>
|
||||
#include <QVariant>
|
||||
|
||||
namespace QetSettings
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
/**
|
||||
* @brief setHdpiScaleFactorRoundingPolicy
|
||||
* Write the value of HdpiScaleFactorRoundingPolicy in
|
||||
* QElectroTech settings
|
||||
* the value is in form of a string.
|
||||
* @a policy can be : Round, Ceil, Floor, RoundPreferFloor, PassThrough
|
||||
* In case of wrong policy, PassThrough is use as defaukt value.
|
||||
* The value is stored with key : hdpi_scale_factor_rounding_policy
|
||||
* @sa Qt::HighDpiScaleFactorRoundingPolicy
|
||||
* @param policy
|
||||
*/
|
||||
void setHdpiScaleFactorRoundingPolicy(const QString &policy_str)
|
||||
{
|
||||
auto policy = QString("PassThrough");
|
||||
if (policy_str == QLatin1String("Round")) {
|
||||
policy = "Round";
|
||||
} else if (policy_str == QLatin1String("Ceil")) {
|
||||
policy = "Ceil";
|
||||
} else if (policy_str == QLatin1String("Floor")) {
|
||||
policy = "Floor";
|
||||
} else if (policy_str == QLatin1String("RoundPreferFloor")) {
|
||||
policy = "RoundPreferFloor";
|
||||
}
|
||||
QSettings settings;
|
||||
settings.setValue("hdpi_scale_factor_rounding_policy", policy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief setHdpiScaleFactorRoundingPolicy
|
||||
* Overload function
|
||||
* @sa void setHdpiScaleFactorRoundingPolicy(const QString &policy_str)
|
||||
* @param policy
|
||||
*/
|
||||
void setHdpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy)
|
||||
{
|
||||
QString policy_str;
|
||||
switch (policy) {
|
||||
case Qt::HighDpiScaleFactorRoundingPolicy::Round:
|
||||
policy_str = "Round";
|
||||
break;
|
||||
case Qt::HighDpiScaleFactorRoundingPolicy::Ceil:
|
||||
policy_str = "Ceil";
|
||||
break;
|
||||
case Qt::HighDpiScaleFactorRoundingPolicy::Floor:
|
||||
policy_str = "Floor";
|
||||
break;
|
||||
case Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor:
|
||||
policy_str = "RoundPreferFloor";
|
||||
break;
|
||||
default:
|
||||
policy_str = "PassThrough";
|
||||
break;
|
||||
}
|
||||
|
||||
QSettings settings;
|
||||
settings.setValue("hdpi_scale_factor_rounding_policy", policy_str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief hdpiScaleFactorRoundingPolicy
|
||||
* @param default_policy
|
||||
* @return the hdpiScaleFactorRoundingPolicy value stored in current settings.
|
||||
* @sa setHdpiScaleFactorRoundingPolicy
|
||||
*/
|
||||
Qt::HighDpiScaleFactorRoundingPolicy hdpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy default_policy)
|
||||
{
|
||||
QSettings settings;
|
||||
auto value_ = settings.value("hdpi_scale_factor_rounding_policy");
|
||||
|
||||
if (value_ == QLatin1String("Round")) {
|
||||
return Qt::HighDpiScaleFactorRoundingPolicy::Round;
|
||||
} else if (value_ == QLatin1String("Ceil")) {
|
||||
return Qt::HighDpiScaleFactorRoundingPolicy::Ceil;
|
||||
} else if (value_ == QLatin1String("Floor")) {
|
||||
return Qt::HighDpiScaleFactorRoundingPolicy::Floor;
|
||||
} else if (value_ == QLatin1String("RoundPreferFloor")) {
|
||||
return Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor;
|
||||
} else if (value_ == QLatin1String("PassThrough")) {
|
||||
return Qt::HighDpiScaleFactorRoundingPolicy::PassThrough;
|
||||
} else {
|
||||
return default_policy;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
39
sources/utils/qetsettings.h
Normal file
39
sources/utils/qetsettings.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2006-2021 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef QETSETTINGS_H
|
||||
#define QETSETTINGS_H
|
||||
|
||||
#include <Qt>
|
||||
|
||||
/**
|
||||
*Interface to use QSettings in QElectroTech
|
||||
*Prefer use this namespace instead of directly QSettings
|
||||
*It's notably usefull when some QSettings value are use in
|
||||
*different part of QElectroTech source code
|
||||
*/
|
||||
namespace QetSettings
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
void setHdpiScaleFactorRoundingPolicy(const QString &policy_str);
|
||||
void setHdpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy);
|
||||
Qt::HighDpiScaleFactorRoundingPolicy hdpiScaleFactorRoundingPolicy(
|
||||
Qt::HighDpiScaleFactorRoundingPolicy default_policy = Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // QETSETTINGS_H
|
||||
Reference in New Issue
Block a user