You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWATI/Include/iBase/iUtils/ZxResolutionHelper.h

99 lines
2.7 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include "LlUtils_global.h"
#include "Defines.h"
// 本类的目的主要是实现分辨率适配相关的内容
// 主要为了速度
class I_UTILSSHARED_EXPORT ZxResolutionHelper
{
public:
// 获取对象,单例模式
static ZxResolutionHelper* getInstance();
// 关闭消耗
static void release();
// 根据屏幕分辨率对大小进行调整
// 为了代码速度以及保密需要不再启用模版模版版本可以参见20240920之前版本//
// template<typename T> T adjustSize(T v, bool bHori = true, QWidget* pWx = NULL)
int adjustSizeW(int v, QWidget* pWx = NULL);
int adjustSizeH(int v, QWidget* pWx = NULL);
double adjustSizeW(double v, QWidget* pWx = NULL);
double adjustSizeH(double v, QWidget* pWx = NULL);
// 获取实际分辨率
int getResoRealW();
int getResoRealH();
// 获取基准分辨率内部ini设定的分辨率通常很少调用该函数
int getResoBaseW();
int getResoBaseH();
// 当前软件运行的屏幕分辨率与基准分辨率的比值
double getResoRatioW();
double getResoRatioH();
enum Icon_Size_Mode
{
ISM_Small = 0, //小
ISM_Mid,
ISM_Large,
ISM_Super,
ISM_Auto //其实就是ISM_Mid
};
// 根据当前屏幕分辨率获取图标适合的大小通常是16,24,32等
int getProperIconSize(Icon_Size_Mode ism = ISM_Mid);
private:
ZxResolutionHelper();
~ZxResolutionHelper();
private:
// 显示器相关
void makesureRatioWH(int nIndex);
int getScrnIndexOf(QWidget* pWx);
void makesureIconSizes();
// 根据屏幕分辨率对大小进行调整
// 为了代码速度以及保密需要不再启用模版模版版本可以参见20240920之前版本//
int adjustSize(int v, bool bHori = true, QWidget* pWx = NULL);
double adjustSize(double v, bool bHori = true, QWidget* pWx = NULL);
private:
static ZxResolutionHelper* spResoHelper;
// 软件研发时,研发人员默认参照的显示,权宜之计
int m_nBaseW;
int m_nBaseH;
// 实际的
int m_nRealW;
int m_nRealH;
// 当前软件运行的屏幕分辨率与基准分辨率的比值
double m_dRatioW;
double m_dRatioH;
// 当前屏幕分辨率下,图标比较合适的大小,只是为了方便
VecInt m_vecIconSizes;
// 选用的屏幕索引,对于多显示器模式
int m_nScrnIndex;
// 临时,暂未启用
bool m_bVerified;
// Error
QString m_sError;
};
#define _resoHelper ZxResolutionHelper::getInstance()
#define _resoSizeW ZxResolutionHelper::getInstance()->adjustSizeW
#define _resoSizeH ZxResolutionHelper::getInstance()->adjustSizeH