Skip to content

Commit

Permalink
feat: display git describe version string in app if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
BLumia committed Sep 29, 2020
1 parent 4c3e370 commit 7c39668
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
)
string (REGEX REPLACE "\n" "" _git_describe_long "${_git_describe_long}")
ppic_set_version_via_describe(${_git_describe_long})
target_compile_definitions(${EXE_NAME} PRIVATE
GIT_DESCRIBE_VERSION_STRING="${_git_describe_long}"
)
endif ()
endif ()

Expand Down
5 changes: 4 additions & 1 deletion aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ AboutDialog::AboutDialog(QWidget *parent)
QStringList aboutStr {
QStringLiteral("<center><img width='128' height='128' src=':/icons/app-icon.svg'/><br/>"),
qApp->applicationDisplayName(),
#ifdef GIT_DESCRIBE_VERSION_STRING
(QStringLiteral("<br/>") + tr("Version: %1").arg(GIT_DESCRIBE_VERSION_STRING)),
#endif // GIT_DESCRIBE_VERSION_STRING
"<hr/>",
tr("Built with Qt %1 (%2)").arg(QT_VERSION_STR, QSysInfo::buildCpuArchitecture()),
QStringLiteral("<br/><a href='%1'>%2</a>").arg("https://github.com/BLumia/pineapple-pictures", tr("Source code")),
Expand Down Expand Up @@ -103,7 +106,7 @@ SOFTWARE.

this->setLayout(mainLayout);
this->setMinimumSize(361, 161); // not sure why it complain "Unable to set geometry"
this->resize(520, 320);
this->resize(520, 330);
setWindowFlag(Qt::WindowContextHelpButtonHint, false);
}

Expand Down
17 changes: 11 additions & 6 deletions languages/PineapplePictures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,41 @@
</message>
<message>
<location filename="../aboutdialog.cpp" line="37"/>
<source>Version: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="40"/>
<source>Built with Qt %1 (%2)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="38"/>
<location filename="../aboutdialog.cpp" line="41"/>
<source>Source code</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="42"/>
<location filename="../aboutdialog.cpp" line="45"/>
<source>&lt;p&gt;&lt;i&gt;%1&lt;/i&gt; is released under the MIT License.&lt;/p&gt;&lt;p&gt;This license grants people a number of freedoms:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You are free to use &lt;i&gt;%1&lt;/i&gt;, for any purpose&lt;/li&gt;&lt;li&gt;You are free to distribute &lt;i&gt;%1&lt;/i&gt;&lt;/li&gt;&lt;li&gt;You can study how &lt;i&gt;%1&lt;/i&gt; works and change it&lt;/li&gt;&lt;li&gt;You can distribute changed versions of &lt;i&gt;%1&lt;/i&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The MIT license guarantees you this freedom. Nobody is ever permitted to take it away.&lt;/p&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="55"/>
<location filename="../aboutdialog.cpp" line="58"/>
<source>Your Rights</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="90"/>
<location filename="../aboutdialog.cpp" line="93"/>
<source>&amp;Help</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="91"/>
<location filename="../aboutdialog.cpp" line="94"/>
<source>&amp;About</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="92"/>
<location filename="../aboutdialog.cpp" line="95"/>
<source>&amp;License</source>
<translation type="unfinished"></translation>
</message>
Expand Down
17 changes: 11 additions & 6 deletions languages/PineapplePictures_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,41 @@
</message>
<message>
<location filename="../aboutdialog.cpp" line="37"/>
<source>Version: %1</source>
<translation>版本: %1</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="40"/>
<source>Built with Qt %1 (%2)</source>
<translation>使用 Qt %1 (%2) 进行构建</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="38"/>
<location filename="../aboutdialog.cpp" line="41"/>
<source>Source code</source>
<translation>源代码</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="42"/>
<location filename="../aboutdialog.cpp" line="45"/>
<source>&lt;p&gt;&lt;i&gt;%1&lt;/i&gt; is released under the MIT License.&lt;/p&gt;&lt;p&gt;This license grants people a number of freedoms:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;You are free to use &lt;i&gt;%1&lt;/i&gt;, for any purpose&lt;/li&gt;&lt;li&gt;You are free to distribute &lt;i&gt;%1&lt;/i&gt;&lt;/li&gt;&lt;li&gt;You can study how &lt;i&gt;%1&lt;/i&gt; works and change it&lt;/li&gt;&lt;li&gt;You can distribute changed versions of &lt;i&gt;%1&lt;/i&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;The MIT license guarantees you this freedom. Nobody is ever permitted to take it away.&lt;/p&gt;</source>
<translation>&lt;p&gt;&lt;i&gt;%1&lt;/i&gt; 是在 MIT 许可协议下发布的。&lt;/p&gt;&lt;p&gt;此许可证赋予人们以下自由的权利:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;任何人都可以为了任何目的自由地使用 &lt;i&gt;%1&lt;/i&gt;&lt;/li&gt;&lt;li&gt;任何人都可以自由地分发 &lt;i&gt;%1&lt;/i&gt;&lt;/li&gt;&lt;li&gt;任何人都可以自由地研究 &lt;i&gt;%1&lt;/i&gt; 的工作原理并对其进行修改&lt;/li&gt;&lt;li&gt;任何人都可以自由地分发修改过的 &lt;i&gt;%1&lt;/i&gt; 版本&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;此软件通过 MIT 许可证赋予用户上述自由,任何人无权剥夺。&lt;/p&gt;</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="55"/>
<location filename="../aboutdialog.cpp" line="58"/>
<source>Your Rights</source>
<translation>用户的权利</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="90"/>
<location filename="../aboutdialog.cpp" line="93"/>
<source>&amp;Help</source>
<translation>帮助(&amp;H)</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="91"/>
<location filename="../aboutdialog.cpp" line="94"/>
<source>&amp;About</source>
<translation>关于(&amp;A)</translation>
</message>
<message>
<location filename="../aboutdialog.cpp" line="92"/>
<location filename="../aboutdialog.cpp" line="95"/>
<source>&amp;License</source>
<translation>软件许可证(&amp;L)</translation>
</message>
Expand Down

0 comments on commit 7c39668

Please sign in to comment.