Skip to content

Commit ab935b5

Browse files
committed
Remove overshoot
1 parent c736cf9 commit ab935b5

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

src/core/StelObject.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ void StelObject::postProcessInfoString(QString& str, const InfoStringGroup& flag
10391039

10401040
if (flags&PlainText)
10411041
{
1042+
static const QRegularExpression h2Re("<h2[^>]*>");
10421043
static const QRegularExpression brRe2("<br(\\s*/)?>\\s*");
10431044
static const QRegularExpression tdRe1("<td\\s*>");
10441045
static const QRegularExpression tdRe2("<td \\w+='[^']*'>"); // Seen: style, align, colspan, rowspan. Always only one expression.
@@ -1048,7 +1049,7 @@ void StelObject::postProcessInfoString(QString& str, const InfoStringGroup& flag
10481049
static const QRegularExpression tableRe4("<table style=\"[^\"]*\">");
10491050
str.replace("<b>", "");
10501051
str.replace("</b>", "");
1051-
str.replace("<h2>", "");
1052+
str.replace(h2Re, "");
10521053
str.replace("</h2>", "\n");
10531054
str.replace(brRe2, "\n");
10541055
str.replace("<tr>", "");

src/core/StelSkyCultureMgr.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,6 @@ QString StelSkyCultureMgr::createCulturalLabel(const StelObject::CulturalName &c
977977
const QString &commonNameI18n,
978978
const QString &abbrevI18n) const
979979
{
980-
// rtl tracks the right-to-left status of the text in the current position.
981-
const bool rtl = StelApp::getInstance().getLocaleMgr().isSkyRTL();
982980
// Each element may be in an RTL language (e.g. Arab). However,
983981
// - for most (left-to-right) languages we want a canonical order of left to right elements.
984982
// - for Arab and other right-to-left user languages, we set a canonical order of right-to-left elements.
@@ -1016,7 +1014,7 @@ QString StelSkyCultureMgr::createCulturalLabel(const StelObject::CulturalName &c
10161014
// If native contains non-Latin glyphs, pronounce or transliteration is mandatory.
10171015
QString pronounceStr=(lName.pronounceI18n.isEmpty() ? lName.pronounce : lName.pronounceI18n);
10181016
QString nativeOrPronounce = (lName.native.isEmpty() ? lName.pronounceI18n : lName.native);
1019-
QString pronounceOrNative = (lName.pronounceI18n.isEmpty() ? lName.native : lName.pronounceI18n);
1017+
QString pronounceOrNative = (pronounceStr.isEmpty() ? lName.native : pronounceStr);
10201018
QString translitOrPronounce = (lName.transliteration.isEmpty() ? pronounceStr : lName.transliteration);
10211019

10221020
// If you call this with an actual argument abbrevI18n, you really only want a short label.
@@ -1090,19 +1088,13 @@ QString StelSkyCultureMgr::createCulturalLabel(const StelObject::CulturalName &c
10901088
if (!braced.isEmpty())
10911089
{
10921090
QString pronTrans=QString(" %1%3%2").arg(QChar(0x2997), QChar(0x2998), braced.join(", "+ZWS));
1093-
if (rtl)
1094-
label.prepend(pronTrans+ZWS);
1095-
else
10961091
label.append(pronTrans+ZWS);
10971092
}
10981093

10991094
// Add IPA (where possible)
11001095
if ((styleInt & int(StelObject::CulturalDisplayStyle::IPA)) && (!lName.IPA.isEmpty()) && (label != lName.IPA))
11011096
{
11021097
QString ipa=QString(" [%1]").arg(lName.IPA);
1103-
if (rtl)
1104-
label.prepend(ipa+ZWS);
1105-
else
11061098
label.append(ipa+ZWS);
11071099
}
11081100

@@ -1124,9 +1116,6 @@ QString StelSkyCultureMgr::createCulturalLabel(const StelObject::CulturalName &c
11241116
if (!bracketed.isEmpty())
11251117
{
11261118
QString transBy=QString(" (%1)").arg(bracketed.join(", "+ZWS));
1127-
if (rtl)
1128-
label.prepend(transBy+ZWS);
1129-
else
11301119
label.append(transBy+ZWS);
11311120
}
11321121

@@ -1135,9 +1124,6 @@ QString StelSkyCultureMgr::createCulturalLabel(const StelObject::CulturalName &c
11351124
if ((styleInt & int(StelObject::CulturalDisplayStyle::Modern)) && (!commonNameI18n.isEmpty()) && (!label.startsWith(lCommonNameI18n)) && (lCommonNameI18n!=lName.translatedI18n))
11361125
{
11371126
QString modern=QString(" %1%3%2").arg(QChar(0x29FC), QChar(0x29FD), lCommonNameI18n);
1138-
if (rtl)
1139-
label.prepend(modern+ZWS);
1140-
else
11411127
label.append(modern+ZWS);
11421128
}
11431129
if ((styleInt & int(StelObject::CulturalDisplayStyle::Modern)) && label.isEmpty()) // if something went wrong?

src/core/modules/MinorPlanet.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "MinorPlanet.hpp"
2323
#include "Orbit.hpp"
2424
#include "StelCore.hpp"
25+
#include "StelLocaleMgr.hpp"
2526
#include "StelTranslator.hpp"
2627

2728
#include <QRegularExpression>
@@ -169,10 +170,12 @@ QString MinorPlanet::getNameI18n() const
169170
QString MinorPlanet::getInfoStringName(const StelCore *core, const InfoStringGroup& flags) const
170171
{
171172
Q_UNUSED(core) Q_UNUSED(flags)
173+
// rtl tracks the right-to-left status of the text in the current position.
174+
const bool rtl = StelApp::getInstance().getLocaleMgr().isSkyRTL();
172175
QString str;
173176
QTextStream oss(&str);
174177

175-
oss << "<h2>";
178+
oss << (rtl ? "<h2 dir=\"rtl\">" : "<h2 dir=\"ltr\">");
176179
if (nameIsIAUDesignation)
177180
{
178181
if (minorPlanetNumber)

src/core/modules/Nebula.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "Nebula.hpp"
2323
#include "NebulaMgr.hpp"
2424
#include "Planet.hpp"
25+
#include "StelLocaleMgr.hpp"
2526
#include "StelTexture.hpp"
2627

2728
#include "StelUtils.hpp"
@@ -240,12 +241,14 @@ QStringList Nebula::getCultureLabels(StelObject::CulturalDisplayStyle style) con
240241

241242
QString Nebula::getInfoString(const StelCore *core, const InfoStringGroup& flags) const
242243
{
244+
// rtl tracks the right-to-left status of the text in the current position.
245+
const bool rtl = StelApp::getInstance().getLocaleMgr().isSkyRTL();
243246
QString str;
244247
QTextStream oss(&str);
245248
bool withDecimalDegree = StelApp::getInstance().getFlagShowDecimalDegrees();
246249

247250
if ((flags&Name) || (flags&CatalogNumber))
248-
oss << "<h2>";
251+
oss << (rtl ? "<h2 dir=\"rtl\">" : "<h2 dir=\"ltr\">");
249252

250253
if (!culturalNames.isEmpty() && flags&Name)
251254
oss << getInfoLabel() << "<br/>";

src/core/modules/Planet.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,10 @@ QString Planet::getScreenLabel() const
501501
}
502502
QString Planet::getInfoLabel() const
503503
{
504+
static const QString ZWS{"\u200b"}; // zero-width space (we use them to combine cultural label groups)
504505
static StelSkyCultureMgr *scMgr=GETSTELMODULE(StelSkyCultureMgr);
505506
QStringList list=getCultureLabels(scMgr->getInfoLabelStyle());
506-
return list.isEmpty() ? getNameI18n() : list.join(" - ");
507+
return list.isEmpty() ? getNameI18n() : list.join(ZWS + " - " + ZWS);
507508
}
508509

509510
QStringList Planet::getCultureLabels(StelObject::CulturalDisplayStyle style) const
@@ -532,9 +533,11 @@ QStringList Planet::getCultureLabels(StelObject::CulturalDisplayStyle style) con
532533
QString Planet::getInfoStringName(const StelCore *core, const InfoStringGroup& flags) const
533534
{
534535
Q_UNUSED(core) Q_UNUSED(flags)
536+
// rtl tracks the right-to-left status of the text in the current position.
537+
const bool rtl = StelApp::getInstance().getLocaleMgr().isSkyRTL();
535538
QString str;
536539
QTextStream oss(&str);
537-
oss << "<h2 dir=\"ltr\">";
540+
oss << (rtl ? "<h2 dir=\"rtl\">" : "<h2 dir=\"ltr\">");
538541

539542
// NOTE: currently only moons have an IAU designation
540543
if (!iauMoonNumber.isEmpty())

src/core/modules/StarMgr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2501,9 +2501,10 @@ QString StarMgr::getCulturalScreenLabel(StarId hip)
25012501
//! When dealing with foreign skycultures, many users will want this to be longer, with more name components.
25022502
QString StarMgr::getCulturalInfoLabel(StarId hip)
25032503
{
2504+
static const QString ZWS{"\u200b"}; // zero-width space (we use them to combine cultural label groups)
25042505
static StelSkyCultureMgr *scMgr=GETSTELMODULE(StelSkyCultureMgr);
25052506
QStringList list=getCultureLabels(hip, scMgr->getInfoLabelStyle());
2506-
return list.isEmpty() ? "" : list.join(" - ");
2507+
return list.isEmpty() ? "" : list.join(ZWS + " - " + ZWS);
25072508
}
25082509

25092510
QStringList StarMgr::getCultureLabels(StarId hip, StelObject::CulturalDisplayStyle style)

src/core/modules/StarWrapper.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323

2424
#include "StarWrapper.hpp"
25+
#include "StelLocaleMgr.hpp"
2526
#include "ZoneArray.hpp"
2627

2728
#include "StelUtils.hpp"
@@ -149,6 +150,8 @@ QString StarWrapper1::getObjectTypeI18n() const
149150

150151
QString StarWrapper1::getInfoString(const StelCore *core, const InfoStringGroup& flags) const
151152
{
153+
// rtl tracks the right-to-left status of the text in the current position.
154+
const bool rtl = StelApp::getInstance().getLocaleMgr().isSkyRTL();
152155
QString str;
153156
QTextStream oss(&str);
154157
double az_app, alt_app;
@@ -172,7 +175,7 @@ QString StarWrapper1::getInfoString(const StelCore *core, const InfoStringGroup&
172175
const int vMm = StarMgr::getGcvsMM(star_id);
173176

174177
if ((flags&Name) || (flags&CatalogNumber))
175-
oss << "<h2 dir=\"ltr\">";
178+
oss << (rtl ? "<h2 dir=\"rtl\">" : "<h2 dir=\"ltr\">");
176179

177180
const QString commonNameI18 = StarMgr::getCommonNameI18n(star_id);
178181
const QString culturalInfoName=StarMgr::getCulturalInfoLabel(star_id);

0 commit comments

Comments
 (0)