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}
6
6
app.h
7
7
appmenubar.cpp
8
8
appmenubar.h
9
+ libraryinfo.cpp
10
+ libraryinfo.h
9
11
)
10
12
11
13
qt_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 3
3
import QtQuick
4
4
import QtQuick.Controls
5
5
import QtQuick.Layouts
6
+ import ScratchCPP
6
7
import ScratchCPP.Ui
7
8
import ScratchCPP.UiComponents
8
9
@@ -33,6 +34,16 @@ CustomDialog {
33
34
text: qsTr (" Version: %1" ).arg (Qt .application .version )
34
35
}
35
36
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
+
36
47
Label {
37
48
text: qsTr (" Revision: %1" ).arg (AppInfo .revision ())
38
49
}
Original file line number Diff line number Diff line change @@ -13,7 +13,12 @@ AppInfo::AppInfo(QObject *parent) :
13
13
14
14
QString scratchcpp::AppInfo::revision () const
15
15
{
16
- return git_CommitSHA1 ();
16
+ QString rev = git_CommitSHA1 ();
17
+
18
+ if (rev.size () >= 8 )
19
+ return rev.first (8 );
20
+
21
+ return " " ;
17
22
}
18
23
19
24
int scratchcpp::AppInfo::buildYear () const
Original file line number Diff line number Diff line change @@ -15,7 +15,9 @@ using namespace scratchcpp::test;
15
15
TEST (AppInfoTest, Revision)
16
16
{
17
17
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 ));
19
21
}
20
22
21
23
TEST (AppInfoTest, BuildYear)
You can’t perform that action at this time.
0 commit comments