File tree Expand file tree Collapse file tree 6 files changed +67
-2
lines changed Expand file tree Collapse file tree 6 files changed +67
-2
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ qt_add_executable(${APP_TARGET}
66 app.h
77 appmenubar.cpp
88 appmenubar.h
9+ libraryinfo.cpp
10+ libraryinfo.h
911)
1012
1113qt_add_qml_module(${APP_TARGET}
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: GPL-3.0-or-later
2+
3+ #include < scratchcpp/scratchconfiguration.h>
4+ #include < scratchcpp-render/scratchcpp-render.h>
5+
6+ #include " libraryinfo.h"
7+
8+ using namespace scratchcpp ;
9+
10+ LibraryInfo::LibraryInfo (QObject *parent) :
11+ QObject(parent)
12+ {
13+ }
14+
15+ QString LibraryInfo::libscratchcppVersion () const
16+ {
17+ return QString::fromStdString (libscratchcpp::ScratchConfiguration::version ());
18+ }
19+
20+ QString LibraryInfo::scratchcppRenderVersion () const
21+ {
22+ return QString::fromStdString (scratchcpprender::version ());
23+ }
Original file line number Diff line number Diff line change 1+ // SPDX-License-Identifier: GPL-3.0-or-later
2+
3+ #pragma once
4+
5+ #include < QQmlEngine>
6+
7+ namespace scratchcpp
8+ {
9+
10+ class LibraryInfo : public QObject
11+ {
12+ Q_OBJECT
13+ QML_ELEMENT
14+ QML_SINGLETON
15+ public:
16+ explicit LibraryInfo (QObject *parent = nullptr );
17+
18+ Q_INVOKABLE QString libscratchcppVersion () const ;
19+ Q_INVOKABLE QString scratchcppRenderVersion () const ;
20+ };
21+
22+ } // namespace scratchcpp
Original file line number Diff line number Diff line change 33import QtQuick
44import QtQuick.Controls
55import QtQuick.Layouts
6+ import ScratchCPP
67import ScratchCPP.Ui
78import ScratchCPP.UiComponents
89
@@ -33,6 +34,16 @@ CustomDialog {
3334 text: qsTr (" Version: %1" ).arg (Qt .application .version )
3435 }
3536
37+ Label {
38+ // : For example "SomeLibrary version: 0.1.0"
39+ text: qsTr (" %1 version: %2" ).arg (" libscratchcpp" ).arg (LibraryInfo .libscratchcppVersion ())
40+ }
41+
42+ Label {
43+ // : For example "SomeLibrary version: 0.1.0"
44+ text: qsTr (" %1 version: %2" ).arg (" ScratchCPP Render" ).arg (LibraryInfo .scratchcppRenderVersion ())
45+ }
46+
3647 Label {
3748 text: qsTr (" Revision: %1" ).arg (AppInfo .revision ())
3849 }
Original file line number Diff line number Diff line change @@ -13,7 +13,12 @@ AppInfo::AppInfo(QObject *parent) :
1313
1414QString scratchcpp::AppInfo::revision () const
1515{
16- return git_CommitSHA1 ();
16+ QString rev = git_CommitSHA1 ();
17+
18+ if (rev.size () >= 8 )
19+ return rev.first (8 );
20+
21+ return " " ;
1722}
1823
1924int scratchcpp::AppInfo::buildYear () const
Original file line number Diff line number Diff line change @@ -15,7 +15,9 @@ using namespace scratchcpp::test;
1515TEST (AppInfoTest, Revision)
1616{
1717 AppInfo info;
18- ASSERT_EQ (info.revision (), git_CommitSHA1 ());
18+ QString rev = git_CommitSHA1 ();
19+ ASSERT_GE (rev.size (), 8 );
20+ ASSERT_EQ (info.revision (), rev.first (8 ));
1921}
2022
2123TEST (AppInfoTest, BuildYear)
You can’t perform that action at this time.
0 commit comments