font size list for each operation system

This commit is contained in:
dreamsourcelabTAI 2024-01-17 14:49:51 +08:00
parent abcab0949b
commit 3312a13906
3 changed files with 46 additions and 3 deletions

View File

@ -123,13 +123,23 @@ static void _loadApp(AppOptions &o, QSettings &st)
getFiled("swapBackBufferAlways", st, o.swapBackBufferAlways, false);
getFiled("fontSize", st, o.fontSize, 9.0);
getFiled("autoScrollLatestData", st, o.autoScrollLatestData, true);
getFiled("version", st, o.version, 1);
o.warnofMultiTrig = true;
QString fmt;
getFiled("protocalFormats", st, fmt, "");
if (fmt != ""){
StringToFormatArray(fmt, o.m_protocolFormats);
StringToFormatArray(fmt, o.m_protocolFormats);
}
float minSize = 0;
float maxSize = 0;
AppConfig::GetFontSizeRange(&minSize, &maxSize);
if (o.version == 1 || o.fontSize < minSize || o.fontSize > maxSize)
{
o.fontSize = (maxSize + minSize) / 2;
}
st.endGroup();
@ -150,6 +160,7 @@ static void _saveApp(AppOptions &o, QSettings &st)
setFiled("swapBackBufferAlways", st, o.swapBackBufferAlways);
setFiled("fontSize", st, o.fontSize);
setFiled("autoScrollLatestData", st, o.autoScrollLatestData);
setFiled("version", st, APP_CONFIG_VERSION);
QString fmt = FormatArrayToString(o.m_protocolFormats);
setFiled("protocalFormats", st, fmt);
@ -392,6 +403,28 @@ std::string AppConfig::GetProtocolFormat(const std::string &protocolName)
return "";
}
void AppConfig::GetFontSizeRange(float *minSize, float *maxSize)
{
assert(minSize);
assert(maxSize);
#ifdef _WIN32
*minSize = 7;
*maxSize = 12;
#endif
#ifdef Q_OS_LINUX
*minSize = 8;
*maxSize = 14;
#endif
#ifdef Q_OS_DARWIN
*minSize = 9;
*maxSize = 15;
#endif
}
//-------------api
QString GetIconPath()
{
@ -493,4 +526,4 @@ QString GetProfileDir()
#else
return QStandardPaths::writableLocation(QStandardPaths::DataLocation);
#endif
}
}

View File

@ -53,8 +53,11 @@ public:
};
#define APP_CONFIG_VERSION 3
struct AppOptions
{
bool version;
bool quickScroll;
bool warnofMultiTrig;
bool originalData;
@ -149,6 +152,8 @@ public:
return frameOptions.language == LAN_CN;
}
static void GetFontSizeRange(float *minSize, float *maxSize);
public:
AppOptions appOptions;
UserHistory userHistory;

View File

@ -87,7 +87,12 @@ void ApplicationParamDlg::bind_font_size_list(QComboBox *box, float size)
{
int selDex = -1;
for(int i=7; i<=12; i++)
float minSize = 0;
float maxSize = 0;
AppConfig::GetFontSizeRange(&minSize, &maxSize);
for(int i=minSize; i<=maxSize; i++)
{
box->addItem(QString::number(i));
if (i == size){