diff --git a/DSView/pv/config/appconfig.cpp b/DSView/pv/config/appconfig.cpp index 2cabb2b4..60263498 100644 --- a/DSView/pv/config/appconfig.cpp +++ b/DSView/pv/config/appconfig.cpp @@ -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 -} +} \ No newline at end of file diff --git a/DSView/pv/config/appconfig.h b/DSView/pv/config/appconfig.h index aba12640..ae5da985 100644 --- a/DSView/pv/config/appconfig.h +++ b/DSView/pv/config/appconfig.h @@ -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; diff --git a/DSView/pv/dialogs/applicationpardlg.cpp b/DSView/pv/dialogs/applicationpardlg.cpp index fb0a24cb..4d429061 100644 --- a/DSView/pv/dialogs/applicationpardlg.cpp +++ b/DSView/pv/dialogs/applicationpardlg.cpp @@ -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){