RTL layout support

This commit is contained in:
arm64v8a
2023-01-02 08:49:13 +09:00
parent 78bf639b51
commit 98ce9d64df
9 changed files with 73 additions and 5 deletions

View File

@@ -119,9 +119,9 @@ namespace NekoRay {
QString ProxyEntity::DisplayLatency() const {
if (latency < 0) {
return QObject::tr("Unavailable");
return UNICODE_LRO + QObject::tr("Unavailable");
} else if (latency > 0) {
return QString("%1 ms").arg(latency);
return UNICODE_LRO + QString("%1 ms").arg(latency);
} else {
return "";
}

View File

@@ -29,12 +29,12 @@ namespace NekoRay::traffic {
}
[[nodiscard]] QString DisplaySpeed() const {
return QString("%1↑ %2↓").arg(ReadableSize(uplink_rate), ReadableSize(downlink_rate));
return UNICODE_LRO + QString("%1↑ %2↓").arg(ReadableSize(uplink_rate), ReadableSize(downlink_rate));
}
[[nodiscard]] QString DisplayTraffic() const {
if (downlink + uplink == 0) return "";
return QString("%1↑ %2↓").arg(ReadableSize(uplink), ReadableSize(downlink));
return UNICODE_LRO + QString("%1↑ %2↓").arg(ReadableSize(uplink), ReadableSize(downlink));
}
};
} // namespace NekoRay::traffic

View File

@@ -25,6 +25,8 @@ inline std::function<void(QString, QString)> MW_dialog_message;
// String
inline const QString UNICODE_LRO = QString::fromUtf8(QByteArray::fromHex("E280AD"));
#define Int2String(num) QString::number(num)
inline QString SubStrBefore(QString str, const QString &sub) {

View File

@@ -170,6 +170,9 @@ int main(int argc, char *argv[]) {
default:
locale = QLocale().name();
}
QGuiApplication::tr("QT_LAYOUT_DIRECTION");
QLocale::setDefault(QLocale(locale));
//
QTranslator trans;
if (trans.load(":/translations/" + locale + ".qm")) {
QCoreApplication::installTranslator(&trans);

View File

@@ -1216,6 +1216,13 @@ End: %2</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QGuiApplication</name>
<message>
<source>QT_LAYOUT_DIRECTION</source>
<translation>RTL</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
@@ -1337,6 +1344,14 @@ Direct: %2</source>
<source>Request with proxy but no profile started.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Enable VPN</source>
<translation type="obsolete">فعال کردن vpn</translation>
</message>
<message>
<source>Enable System Proxy</source>
<translation type="obsolete">پروکسی سیستم را فعال کنید</translation>
</message>
</context>
<context>
<name>Qv2ray::ui::widgets::AutoCompleteTextEdit</name>

View File

@@ -1219,6 +1219,13 @@ Split by line.</source>
<translation> %1 ?</translation>
</message>
</context>
<context>
<name>QGuiApplication</name>
<message>
<source>QT_LAYOUT_DIRECTION</source>
<translation>LTR</translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
@@ -1351,6 +1358,14 @@ As of January 1, 2022, compatibility with MD5 authentication information will be
<source>Clearing servers...</source>
<translation>...</translation>
</message>
<message>
<source>Enable VPN</source>
<translation type="obsolete"> VPN</translation>
</message>
<message>
<source>Enable System Proxy</source>
<translation type="obsolete"></translation>
</message>
</context>
<context>
<name>Qv2ray::ui::widgets::AutoCompleteTextEdit</name>

View File

@@ -43,6 +43,7 @@ QString ParseSubInfo(const QString &info) {
GroupItem::GroupItem(QWidget *parent, const QSharedPointer<NekoRay::Group> &ent, QListWidgetItem *item) : QWidget(parent), ui(new Ui::GroupItem) {
ui->setupUi(this);
this->setLayoutDirection(Qt::LeftToRight);
this->ent = ent;
this->item = item;

View File

@@ -6,6 +6,8 @@
ProxyItem::ProxyItem(QWidget *parent, const QSharedPointer<NekoRay::ProxyEntity> &ent, QListWidgetItem *item)
: QWidget(parent), ui(new Ui::ProxyItem) {
ui->setupUi(this);
this->setLayoutDirection(Qt::LeftToRight);
this->item = item;
this->ent = ent;
if (ent == nullptr) return;

View File

@@ -24,6 +24,12 @@
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="name">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">名称</string>
</property>
@@ -48,6 +54,12 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="address">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(102, 102, 102);</string>
</property>
@@ -58,6 +70,12 @@
</item>
<item>
<widget class="QLabel" name="test_result">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">测试结果</string>
</property>
@@ -72,6 +90,12 @@
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="type">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(251, 114, 153);</string>
</property>
@@ -82,6 +106,12 @@
</item>
<item>
<widget class="QLabel" name="traffic">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">流量</string>
</property>