Get rid of latin-1 strings
Use UTF-8 strings everywhere. Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
parent
996160256e
commit
7522273331
|
@ -83,16 +83,16 @@ bool Widget::isNormal() const
|
|||
void Widget::setupUi()
|
||||
{
|
||||
contentsWidget = new ContentsWidget(this);
|
||||
contentsWidget->setObjectName(QLatin1String("contentsWidget"));
|
||||
contentsWidget->setObjectName(QString::fromUtf8("contentsWidget"));
|
||||
contentsWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
const QSize systemButtonSize = {qRound(titleBarHeight * 1.5), titleBarHeight};
|
||||
const QSize systemIconSize = {17, 17};
|
||||
titleBarWidget = new QWidget(contentsWidget);
|
||||
titleBarWidget->setObjectName(QLatin1String("titleBarWidget"));
|
||||
titleBarWidget->setObjectName(QString::fromUtf8("titleBarWidget"));
|
||||
titleBarWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
titleBarWidget->setFixedHeight(titleBarHeight);
|
||||
windowIconButton = new QPushButton(this);
|
||||
windowIconButton->setObjectName(QLatin1String("windowIconButton"));
|
||||
windowIconButton->setObjectName(QString::fromUtf8("windowIconButton"));
|
||||
windowIconButton->setFixedSize(systemIconSize);
|
||||
windowIconButton->setIconSize(systemIconSize);
|
||||
connect(this, &Widget::windowIconChanged, windowIconButton, &QPushButton::setIcon);
|
||||
|
@ -102,16 +102,16 @@ void Widget::setupUi()
|
|||
windowTitleLabel->setFont(f);
|
||||
connect(this, &Widget::windowTitleChanged, windowTitleLabel, &QLabel::setText);
|
||||
minimizeButton = new QPushButton(this);
|
||||
minimizeButton->setObjectName(QLatin1String("minimizeButton"));
|
||||
minimizeButton->setObjectName(QString::fromUtf8("minimizeButton"));
|
||||
minimizeButton->setFixedSize(systemButtonSize);
|
||||
minimizeButton->setIconSize(systemButtonSize);
|
||||
minimizeButton->setIcon(QIcon(QLatin1String(":/images/button_minimize_black.svg")));
|
||||
minimizeButton->setIcon(QIcon(QString::fromUtf8(":/images/button_minimize_black.svg")));
|
||||
connect(minimizeButton, &QPushButton::clicked, this, &Widget::showMinimized);
|
||||
maximizeButton = new QPushButton(this);
|
||||
maximizeButton->setObjectName(QLatin1String("maximizeButton"));
|
||||
maximizeButton->setObjectName(QString::fromUtf8("maximizeButton"));
|
||||
maximizeButton->setFixedSize(systemButtonSize);
|
||||
maximizeButton->setIconSize(systemButtonSize);
|
||||
maximizeButton->setIcon(QIcon(QLatin1String(":/images/button_maximize_black.svg")));
|
||||
maximizeButton->setIcon(QIcon(QString::fromUtf8(":/images/button_maximize_black.svg")));
|
||||
connect(maximizeButton, &QPushButton::clicked, this, [this]() {
|
||||
if (isMaximized()) {
|
||||
showNormal();
|
||||
|
@ -120,10 +120,10 @@ void Widget::setupUi()
|
|||
}
|
||||
});
|
||||
closeButton = new QPushButton(this);
|
||||
closeButton->setObjectName(QLatin1String("closeButton"));
|
||||
closeButton->setObjectName(QString::fromUtf8("closeButton"));
|
||||
closeButton->setFixedSize(systemButtonSize);
|
||||
closeButton->setIconSize(systemButtonSize);
|
||||
closeButton->setIcon(QIcon(QLatin1String(":/images/button_close_black.svg")));
|
||||
closeButton->setIcon(QIcon(QString::fromUtf8(":/images/button_close_black.svg")));
|
||||
connect(closeButton, &QPushButton::clicked, this, &Widget::close);
|
||||
const auto titleBarWidgetLayout = new QHBoxLayout(titleBarWidget);
|
||||
titleBarWidgetLayout->setSpacing(0);
|
||||
|
@ -149,7 +149,7 @@ void Widget::setupUi()
|
|||
backgroundWindowLayout->setSpacing(0);
|
||||
backgroundWindowLayout->addWidget(contentsWidget);
|
||||
setLayout(backgroundWindowLayout);
|
||||
setStyleSheet(QLatin1String(R"(
|
||||
setStyleSheet(QString::fromUtf8(R"(
|
||||
#contentsWidget {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
@ -236,9 +236,8 @@ bool Widget::eventFilter(QObject *object, QEvent *event)
|
|||
setFrameShadowEnabled(normal);
|
||||
framelessHelper()->setTitleBarHeight(
|
||||
titleBarHeight + (normal ? framelessHelper()->getBorderHeight() : 0));
|
||||
const QLatin1String maxIconPath = QLatin1String{":/images/button_maximize_black.svg"};
|
||||
const QLatin1String restoreIconPath = QLatin1String{
|
||||
":/images/button_restore_black.svg"};
|
||||
const QString maxIconPath = QString::fromUtf8(":/images/button_maximize_black.svg");
|
||||
const QString restoreIconPath = QString::fromUtf8(":/images/button_restore_black.svg");
|
||||
maximizeButton->setIcon(QIcon(normal ? maxIconPath : restoreIconPath));
|
||||
} break;
|
||||
case QEvent::WindowActivate: {
|
||||
|
|
|
@ -52,7 +52,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
QApplication application(argc, argv);
|
||||
|
||||
QApplication::setFont({QLatin1String("Microsoft YaHei")});
|
||||
QApplication::setFont({QString::fromUtf8("Microsoft YaHei")});
|
||||
|
||||
Widget widget;
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ const char g_sUseNativeTitleBar[] = "WNEF_USE_NATIVE_TITLE_BAR";
|
|||
const char g_sPreserveWindowFrame[] = "WNEF_FORCE_PRESERVE_WINDOW_FRAME";
|
||||
const char g_sForceUseAcrylicEffect[] = "WNEF_FORCE_ACRYLIC_ON_WIN10";
|
||||
|
||||
const QLatin1String g_sSystemButtonsStyleSheet(R"(
|
||||
const QString g_sSystemButtonsStyleSheet = QString::fromUtf8(R"(
|
||||
#iconButton, #minimizeButton, #maximizeButton, #closeButton {
|
||||
border-style: none;
|
||||
background-color: transparent;
|
||||
|
@ -90,54 +90,28 @@ const QLatin1String g_sSystemButtonsStyleSheet(R"(
|
|||
background-color: #8c0a15;
|
||||
}
|
||||
)");
|
||||
const
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
|
||||
QString
|
||||
#else
|
||||
QLatin1String
|
||||
#endif
|
||||
g_sTitleLabelStyleSheet(
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
|
||||
QString::fromLatin1(
|
||||
#endif
|
||||
R"(
|
||||
|
||||
const QString g_sTitleLabelStyleSheet = QString::fromUtf8(R"(
|
||||
#titleLabel {
|
||||
color: rgb(%1, %2, %3);
|
||||
}
|
||||
)"
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
|
||||
)
|
||||
#endif
|
||||
);
|
||||
const
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
|
||||
QString
|
||||
#else
|
||||
QLatin1String
|
||||
#endif
|
||||
g_sTitleBarStyleSheet(
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
|
||||
QString::fromLatin1(
|
||||
#endif
|
||||
R"(
|
||||
)");
|
||||
|
||||
const QString g_sTitleBarStyleSheet = QString::fromUtf8(R"(
|
||||
#titleBarWidget {
|
||||
background-color: rgba(%1, %2, %3, %4);
|
||||
border-top: 1px solid rgba(%5, %6, %7, %8);
|
||||
}
|
||||
)"
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
|
||||
)
|
||||
#endif
|
||||
);
|
||||
)");
|
||||
|
||||
const QLatin1String g_sMinimizeButtonImageDark(":/images/button_minimize_black.svg");
|
||||
const QLatin1String g_sMaximizeButtonImageDark(":/images/button_maximize_black.svg");
|
||||
const QLatin1String g_sRestoreButtonImageDark(":/images/button_restore_black.svg");
|
||||
const QLatin1String g_sCloseButtonImageDark(":/images/button_close_black.svg");
|
||||
const QLatin1String g_sMinimizeButtonImageLight(":/images/button_minimize_white.svg");
|
||||
const QLatin1String g_sMaximizeButtonImageLight(":/images/button_maximize_white.svg");
|
||||
const QLatin1String g_sRestoreButtonImageLight(":/images/button_restore_white.svg");
|
||||
const QLatin1String g_sCloseButtonImageLight(":/images/button_close_white.svg");
|
||||
const QString g_sMinimizeButtonImageDark = QString::fromUtf8(":/images/button_minimize_black.svg");
|
||||
const QString g_sMaximizeButtonImageDark = QString::fromUtf8(":/images/button_maximize_black.svg");
|
||||
const QString g_sRestoreButtonImageDark = QString::fromUtf8(":/images/button_restore_black.svg");
|
||||
const QString g_sCloseButtonImageDark = QString::fromUtf8(":/images/button_close_black.svg");
|
||||
const QString g_sMinimizeButtonImageLight = QString::fromUtf8(":/images/button_minimize_white.svg");
|
||||
const QString g_sMaximizeButtonImageLight = QString::fromUtf8(":/images/button_maximize_white.svg");
|
||||
const QString g_sRestoreButtonImageLight = QString::fromUtf8(":/images/button_restore_white.svg");
|
||||
const QString g_sCloseButtonImageLight = QString::fromUtf8(":/images/button_close_white.svg");
|
||||
|
||||
void updateQtFrame(const QWindow *window, const int tbh)
|
||||
{
|
||||
|
@ -201,7 +175,7 @@ void Widget::setupUi()
|
|||
resize(1056, 600);
|
||||
verticalLayout_3 = new QVBoxLayout(this);
|
||||
titleBarWidget = new QWidget(this);
|
||||
titleBarWidget->setObjectName(QLatin1String("titleBarWidget"));
|
||||
titleBarWidget->setObjectName(QString::fromUtf8("titleBarWidget"));
|
||||
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
sizePolicy.setHorizontalStretch(0);
|
||||
sizePolicy.setVerticalStretch(0);
|
||||
|
@ -219,12 +193,12 @@ void Widget::setupUi()
|
|||
horizontalSpacer_7 = new QSpacerItem(3, 20, QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
horizontalLayout->addSpacerItem(horizontalSpacer_7);
|
||||
iconButton = new QPushButton(titleBarWidget);
|
||||
iconButton->setObjectName(QLatin1String("iconButton"));
|
||||
iconButton->setObjectName(QString::fromUtf8("iconButton"));
|
||||
horizontalLayout->addWidget(iconButton);
|
||||
horizontalSpacer = new QSpacerItem(3, 20, QSizePolicy::Fixed, QSizePolicy::Minimum);
|
||||
horizontalLayout->addSpacerItem(horizontalSpacer);
|
||||
titleLabel = new QLabel(titleBarWidget);
|
||||
titleLabel->setObjectName(QLatin1String("titleLabel"));
|
||||
titleLabel->setObjectName(QString::fromUtf8("titleLabel"));
|
||||
QFont font;
|
||||
font.setPointSize(10);
|
||||
titleLabel->setFont(font);
|
||||
|
@ -232,7 +206,7 @@ void Widget::setupUi()
|
|||
horizontalSpacer_2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
horizontalLayout->addSpacerItem(horizontalSpacer_2);
|
||||
minimizeButton = new QPushButton(titleBarWidget);
|
||||
minimizeButton->setObjectName(QLatin1String("minimizeButton"));
|
||||
minimizeButton->setObjectName(QString::fromUtf8("minimizeButton"));
|
||||
QSizePolicy sizePolicy1(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
sizePolicy1.setHorizontalStretch(0);
|
||||
sizePolicy1.setVerticalStretch(0);
|
||||
|
@ -247,7 +221,7 @@ void Widget::setupUi()
|
|||
minimizeButton->setIconSize(systemButtonSize);
|
||||
horizontalLayout->addWidget(minimizeButton);
|
||||
maximizeButton = new QPushButton(titleBarWidget);
|
||||
maximizeButton->setObjectName(QLatin1String("maximizeButton"));
|
||||
maximizeButton->setObjectName(QString::fromUtf8("maximizeButton"));
|
||||
sizePolicy1.setHeightForWidth(maximizeButton->sizePolicy().hasHeightForWidth());
|
||||
maximizeButton->setSizePolicy(sizePolicy1);
|
||||
maximizeButton->setMinimumSize(systemButtonSize);
|
||||
|
@ -258,7 +232,7 @@ void Widget::setupUi()
|
|||
maximizeButton->setIconSize(systemButtonSize);
|
||||
horizontalLayout->addWidget(maximizeButton);
|
||||
closeButton = new QPushButton(titleBarWidget);
|
||||
closeButton->setObjectName(QLatin1String("closeButton"));
|
||||
closeButton->setObjectName(QString::fromUtf8("closeButton"));
|
||||
sizePolicy1.setHeightForWidth(closeButton->sizePolicy().hasHeightForWidth());
|
||||
closeButton->setSizePolicy(sizePolicy1);
|
||||
closeButton->setMinimumSize(systemButtonSize);
|
||||
|
|
|
@ -650,7 +650,7 @@ using WNEF_CORE_DATA = struct _WNEF_CORE_DATA
|
|||
WNEF_RESOLVE_WINAPI(User32, SetWindowLongPtrW)
|
||||
WNEF_RESOLVE_WINAPI(User32, GetClassLongPtrW)
|
||||
WNEF_RESOLVE_WINAPI(User32, SetClassLongPtrW)
|
||||
#else // Q_PROCESSOR_X86_64
|
||||
#else // Q_PROCESSOR_X86_64
|
||||
WNEF_RESOLVE_WINAPI(User32, GetWindowLongW)
|
||||
WNEF_RESOLVE_WINAPI(User32, SetWindowLongW)
|
||||
WNEF_RESOLVE_WINAPI(User32, GetClassLongW)
|
||||
|
@ -797,8 +797,9 @@ const int m_defaultBorderWidth = 8, m_defaultBorderHeight = 8, m_defaultTitleBar
|
|||
const int kAutoHideTaskbarThicknessPx = 2;
|
||||
const int kAutoHideTaskbarThicknessPy = kAutoHideTaskbarThicknessPx;
|
||||
|
||||
const QLatin1String g_sDwmRegistryKey(R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM)");
|
||||
const QLatin1String g_sPersonalizeRegistryKey(
|
||||
const QString g_sDwmRegistryKey = QString::fromUtf8(
|
||||
R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM)");
|
||||
const QString g_sPersonalizeRegistryKey = QString::fromUtf8(
|
||||
R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)");
|
||||
|
||||
const char m_framelessMode[] = "_WNEF_FRAMELESS_MODE_ENABLED";
|
||||
|
@ -1616,8 +1617,8 @@ bool WinNativeEventFilter::isColorizationEnabled()
|
|||
}
|
||||
bool ok = false;
|
||||
const QSettings registry(g_sDwmRegistryKey, QSettings::NativeFormat);
|
||||
const bool colorPrevalence = registry.value(QLatin1String("ColorPrevalence"), 0).toULongLong(&ok)
|
||||
!= 0;
|
||||
const bool colorPrevalence
|
||||
= registry.value(QString::fromUtf8("ColorPrevalence"), 0).toULongLong(&ok) != 0;
|
||||
return (ok && colorPrevalence);
|
||||
}
|
||||
|
||||
|
@ -1686,6 +1687,6 @@ bool WinNativeEventFilter::isTransparencyEffectEnabled()
|
|||
bool ok = false;
|
||||
const QSettings registry(g_sPersonalizeRegistryKey, QSettings::NativeFormat);
|
||||
const bool enableTransparency
|
||||
= registry.value(QLatin1String("EnableTransparency"), 0).toULongLong(&ok) != 0;
|
||||
= registry.value(QString::fromUtf8("EnableTransparency"), 0).toULongLong(&ok) != 0;
|
||||
return (ok && enableTransparency);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue