Skip to content

Commit

Permalink
[publish] TUI fixes (#3483)
Browse files Browse the repository at this point in the history
- Make a few properties
- Add configurable actions for showing date/time and object info
- get rid of the formatting in TUI

Thanks to @10110111 for help.
  • Loading branch information
gzotti authored Oct 30, 2023
1 parent 0092fa0 commit 8e40930
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
11 changes: 8 additions & 3 deletions plugins/TextUserInterface/src/TextUserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,9 @@ void TextUserInterface::init()


currentNode = m1;

addAction("actionShow_TUI_dateTime", N_("Text User Interface"), N_("Toggle TUI date&time"), this, "tuiDateTime", ""); // Recommend "Ctrl+Alt+T", but conflicts with Equation of Time.
addAction("actionShow_TUI_objectInfo", N_("Text User Interface"), N_("Toggle TUI object info"), this, "tuiObjInfo", ""); // Recommend "Ctrl+Alt+Shift+T"
}

/*************************************************************************
Expand All @@ -586,10 +589,12 @@ void TextUserInterface::loadConfiguration(void)
Q_ASSERT(conf);

font.setPixelSize(conf->value("tui/tui_font_size", 15).toInt());
tuiDateTime = conf->value("tui/flag_show_tui_datetime", false).toBool();
tuiObjInfo = conf->value("tui/flag_show_tui_short_obj_info", false).toBool();
tuiGravityUi = conf->value("tui/flag_show_gravity_ui", false).toBool();
setTuiDateTime(conf->value("tui/flag_show_tui_datetime", false).toBool());
setTuiObjInfo(conf->value("tui/flag_show_tui_short_obj_info", false).toBool());
setTuiGravityUi(conf->value("tui/flag_show_gravity_ui", false).toBool());
color = Vec3f(conf->value("tui/tui_font_color", "0.3,1,0.3").toString());
StelCore *core=StelApp::getInstance().getCore();
connect(core, SIGNAL(flagGravityLabelsChanged(bool)), this, SLOT(setTuiGravityUi(bool)));
}

/*************************************************************************
Expand Down
21 changes: 15 additions & 6 deletions plugins/TextUserInterface/src/TextUserInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class TuiNode;
class TextUserInterface : public StelModule
{
Q_OBJECT

Q_PROPERTY(bool tuiDateTime READ getTuiDateTime WRITE setTuiDateTime NOTIFY flagShowDateTimeChanged)
Q_PROPERTY(bool tuiObjInfo READ getTuiObjInfo WRITE setTuiObjInfo NOTIFY flagShowObjInfoChanged)
public:
TextUserInterface();
virtual ~TextUserInterface() Q_DECL_OVERRIDE;
Expand All @@ -54,13 +57,15 @@ public slots:
//! Show/hide the TUI menu
void setTuiMenuActive(bool tActive) { tuiActive = tActive;}
//! Show/hide the TUI date time display
void setTuiDateTime(bool tDateTime) { tuiDateTime = tDateTime; }
void setTuiDateTime(bool tDateTime) { tuiDateTime = tDateTime; emit flagShowDateTimeChanged(tDateTime);}
bool getTuiDateTime(){return tuiDateTime;}
//! Show/hide the selected object's short object information
void setTuiObjInfo(bool tObjInfo) { tuiObjInfo = tObjInfo; }
void setTuiObjInfo(bool tObjInfo) { tuiObjInfo = tObjInfo; emit flagShowObjInfoChanged(tObjInfo);}
bool getTuiObjInfo(){return tuiObjInfo;}
//! Set Gravity text for the TUI text
void setTuiGravityUi(bool tGravityUi) { tuiGravityUi = tGravityUi; }
//! Set light pollution level
void setLightPollutionLevel(int level);
//! Set light pollution level
void setLightPollutionLevel(int level);

private slots:
void setHomePlanet(QString planetName);
Expand All @@ -76,12 +81,16 @@ private slots:
void saveDefaultSettings(void);
void shutDown(void);

signals:
void flagShowDateTimeChanged(bool);
void flagShowObjInfoChanged(bool);

private:
DummyDialog dummyDialog;
QFont font;
bool tuiActive;
bool tuiDateTime;
bool tuiObjInfo;
bool tuiDateTime; // property
bool tuiObjInfo; // property
bool tuiGravityUi;
TuiNode* currentNode;
Vec3f color;
Expand Down
19 changes: 13 additions & 6 deletions src/core/StelObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,26 +958,33 @@ void StelObject::postProcessInfoString(QString& str, const InfoStringGroup& flag

// hack for avoiding an empty line before table
static const QRegularExpression tableRe("<br(\\s*/)?><table");
static const QRegularExpression brRe("<br(\\s*/)?>\\s*$");
static const QRegularExpression brRe2("<br(\\s*/)?>\\s*$");
static const QRegularExpression tdRe("<td(\\w*)?>");
static const QRegularExpression tableRe2("<table(\\w*)?>");
static const QRegularExpression brRe("<br(\\s*/)?>\\s*$");
str.replace(tableRe, "<table");
// chomp trailing line breaks
str.replace(brRe, "");

if (flags&PlainText)
{
static const QRegularExpression brRe2("<br(\\s*/)?>\\s*");
static const QRegularExpression tdRe1("<td\\s*>");
static const QRegularExpression tdRe2("<td \\w+='[^']*'>"); // Seen: style, align, colspan, rowspan. Always only one expression.
static const QRegularExpression tdRe3("<td \\w+=\"[^\"]*\">");
static const QRegularExpression tableRe2("<table\\s*>");
static const QRegularExpression tableRe3("<table style='[^']*'>");
static const QRegularExpression tableRe4("<table style=\"[^\"]*\">");
str.replace("<b>", "");
str.replace("</b>", "");
str.replace("<h2>", "");
str.replace("</h2>", "\n");
str.replace(brRe2, "\n");
str.replace("<tr>", "");
str.replace(tdRe, "");
str.replace("<td>", "");
str.replace(tdRe1, "");
str.replace(tdRe2, "");
str.replace(tdRe3, "");
str.replace("</tr>", "\n");
str.replace(tableRe2, "");
str.replace(tableRe3, "");
str.replace(tableRe4, "");
str.replace("</table>", "");
}
else if(!(flags&NoFont))
Expand Down

0 comments on commit 8e40930

Please sign in to comment.