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 { QString ProxyEntity::DisplayLatency() const {
if (latency < 0) { if (latency < 0) {
return QObject::tr("Unavailable"); return UNICODE_LRO + QObject::tr("Unavailable");
} else if (latency > 0) { } else if (latency > 0) {
return QString("%1 ms").arg(latency); return UNICODE_LRO + QString("%1 ms").arg(latency);
} else { } else {
return ""; return "";
} }

View File

@@ -29,12 +29,12 @@ namespace NekoRay::traffic {
} }
[[nodiscard]] QString DisplaySpeed() const { [[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 { [[nodiscard]] QString DisplayTraffic() const {
if (downlink + uplink == 0) return ""; 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 } // namespace NekoRay::traffic

View File

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

View File

@@ -165,11 +165,14 @@ int main(int argc, char *argv[]) {
locale = "zh_CN"; locale = "zh_CN";
break; break;
case 3: case 3:
locale = "fa_IR"; //farsi(iran) locale = "fa_IR"; // farsi(iran)
break; break;
default: default:
locale = QLocale().name(); locale = QLocale().name();
} }
QGuiApplication::tr("QT_LAYOUT_DIRECTION");
QLocale::setDefault(QLocale(locale));
//
QTranslator trans; QTranslator trans;
if (trans.load(":/translations/" + locale + ".qm")) { if (trans.load(":/translations/" + locale + ".qm")) {
QCoreApplication::installTranslator(&trans); QCoreApplication::installTranslator(&trans);

View File

@@ -1216,6 +1216,13 @@ End: %2</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>QGuiApplication</name>
<message>
<source>QT_LAYOUT_DIRECTION</source>
<translation>RTL</translation>
</message>
</context>
<context> <context>
<name>QObject</name> <name>QObject</name>
<message> <message>
@@ -1337,6 +1344,14 @@ Direct: %2</source>
<source>Request with proxy but no profile started.</source> <source>Request with proxy but no profile started.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </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>
<context> <context>
<name>Qv2ray::ui::widgets::AutoCompleteTextEdit</name> <name>Qv2ray::ui::widgets::AutoCompleteTextEdit</name>

View File

@@ -1219,6 +1219,13 @@ Split by line.</source>
<translation> %1 ?</translation> <translation> %1 ?</translation>
</message> </message>
</context> </context>
<context>
<name>QGuiApplication</name>
<message>
<source>QT_LAYOUT_DIRECTION</source>
<translation>LTR</translation>
</message>
</context>
<context> <context>
<name>QObject</name> <name>QObject</name>
<message> <message>
@@ -1351,6 +1358,14 @@ As of January 1, 2022, compatibility with MD5 authentication information will be
<source>Clearing servers...</source> <source>Clearing servers...</source>
<translation>...</translation> <translation>...</translation>
</message> </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>
<context> <context>
<name>Qv2ray::ui::widgets::AutoCompleteTextEdit</name> <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) { GroupItem::GroupItem(QWidget *parent, const QSharedPointer<NekoRay::Group> &ent, QListWidgetItem *item) : QWidget(parent), ui(new Ui::GroupItem) {
ui->setupUi(this); ui->setupUi(this);
this->setLayoutDirection(Qt::LeftToRight);
this->ent = ent; this->ent = ent;
this->item = item; this->item = item;

View File

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

View File

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