Skip to content

Commit 061637e

Browse files
authored
Merge branch 'scm-manager' into StickFigure
2 parents 7b5bc60 + 130cdd2 commit 061637e

File tree

11 files changed

+669
-18
lines changed

11 files changed

+669
-18
lines changed

plugins/SkyCultureMaker/src/CMakeLists.txt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,46 @@
1-
INCLUDE_DIRECTORIES(#
1+
INCLUDE_DIRECTORIES(
22
.
3+
gui
4+
${CMAKE_BINARY_DIR}/plugins/SkyCultureMaker/src
5+
${CMAKE_BINARY_DIR}/plugins/SkyCultureMaker/src/gui
36
)
47

58
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src)
69

7-
SET(SkyCultureMaker_SRCS
10+
SET( SkyCultureMaker_SRCS
811
SkyCultureMaker.hpp
912
SkyCultureMaker.cpp
13+
1014
ScmDraw.hpp
1115
ScmDraw.cpp
1216
ScmAsterism.hpp
1317
ScmCommonName.hpp
1418
ScmConstellation.hpp
1519
ScmMgr.hpp
1620
ScmSkyCulture.hpp
21+
22+
gui/ScmStartDialog.hpp
23+
gui/ScmStartDialog.cpp
24+
gui/ScmEditorDialog.hpp
25+
gui/ScmEditorDialog.cpp
1726
)
1827

28+
SET( SCM_UIS
29+
gui/scmStartDialog.ui
30+
gui/scmEditorDialog.ui
31+
)
32+
1933
################# compiles resources files ############
2034
SET(SkyCultureMaker_RES ../resources/SkyCultureMaker.qrc)
2135
IF (${QT_VERSION_MAJOR} EQUAL "5")
36+
QT5_WRAP_UI(SCM_UIS_H ${SCM_UIS})
2237
QT5_ADD_RESOURCES(SkyCultureMaker_RES_CXX ${SkyCultureMaker_RES})
2338
ELSE()
39+
QT_WRAP_UI(SCM_UIS_H ${SCM_UIS})
2440
QT_ADD_RESOURCES(SkyCultureMaker_RES_CXX ${SkyCultureMaker_RES})
2541
ENDIF()
2642

27-
ADD_LIBRARY(SkyCultureMaker-static STATIC ${SkyCultureMaker_SRCS} ${SkyCultureMaker_RES_CXX})
43+
ADD_LIBRARY(SkyCultureMaker-static STATIC ${SkyCultureMaker_SRCS} ${SkyCultureMaker_RES_CXX} ${SCM_UIS})
2844
SET_TARGET_PROPERTIES(SkyCultureMaker-static PROPERTIES OUTPUT_NAME "SkyCultureMaker")
2945
TARGET_LINK_LIBRARIES(SkyCultureMaker-static Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Widgets)
3046
SET_TARGET_PROPERTIES(SkyCultureMaker-static PROPERTIES COMPILE_FLAGS "-DQT_STATICPLUGIN")

plugins/SkyCultureMaker/src/ScmCommonName.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ class ScmCommonName;
2323
class scm::ScmCommonName
2424
{
2525
public:
26-
ScmCommonName(QString id, QString englishName);
26+
ScmCommonName(QString id);
2727
~ScmCommonName();
2828

29+
//! Sets the english name
30+
void setEnglishName(QString name);
31+
2932
//! Sets the native name
3033
void setNativeName(QString name);
3134

@@ -38,9 +41,6 @@ class scm::ScmCommonName
3841
//! Sets the references to the sources of the name spellings
3942
void setReferences(QVector<int> refs);
4043

41-
//! Returns the identifier of the common name
42-
QString getId() const;
43-
4444
//! Returns the english name
4545
QString getEnglishName() const;
4646

plugins/SkyCultureMaker/src/ScmConstellation.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,6 @@ namespace scm
1919

2020
class scm::ScmConstellation
2121
{
22-
public:
23-
24-
//! Sets the common name of the constellation
25-
void setCommonName(ScmCommonName name);
26-
27-
//! Returns the common name of the constellation
28-
ScmCommonName getCommonName() const;
29-
30-
private:
31-
//! Common name of the constellation
32-
ScmCommonName commonName;
3322
};
3423

3524
#endif // SCM_CONSTELLATION_HPP

plugins/SkyCultureMaker/src/SkyCultureMaker.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "SkyCultureMaker.hpp"
88
#include "StelGui.hpp"
99
#include "StelGuiItems.hpp"
10+
#include "ScmStartDialog.hpp"
11+
#include "ScmEditorDialog.hpp"
1012

1113
#include <QApplication>
1214
#include <QDebug>
@@ -49,6 +51,12 @@ SkyCultureMaker::SkyCultureMaker()
4951
{
5052
setObjectName("SkyCultureMaker");
5153
font.setPixelSize(25);
54+
55+
scmStartDialog = new ScmStartDialog();
56+
scmStartDialog->setVisible(true);
57+
58+
scmEditorDialog = new ScmEditorDialog();
59+
scmEditorDialog->setVisible(true);
5260
}
5361

5462
/*************************************************************************
@@ -57,6 +65,7 @@ SkyCultureMaker::SkyCultureMaker()
5765
SkyCultureMaker::~SkyCultureMaker()
5866
{
5967
delete drawObj;
68+
delete scmStartDialog;
6069
}
6170

6271
/*************************************************************************

plugins/SkyCultureMaker/src/SkyCultureMaker.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@
66
#include "StelTranslator.hpp"
77
#include "StelCore.hpp"
88
#include "ScmDraw.hpp"
9+
#include "StelObjectModule.hpp"
910

1011
#include <QFont>
1112

1213
class QPixmap;
1314
class StelButton;
15+
class ScmStartDialog;
16+
class ScmEditorDialog;
1417

1518
//! This is an example of a plug-in which can be dynamically loaded into stellarium
1619
class SkyCultureMaker : public StelModule
@@ -69,6 +72,12 @@ public slots:
6972

7073
scm::ScmDraw *drawObj;
7174

75+
/// Draws the line between the start and the current end point.
76+
/// @param core The core used for drawing the line.
77+
void drawLine(StelCore *core);
78+
79+
ScmStartDialog* scmStartDialog;
80+
ScmEditorDialog* scmEditorDialog;
7281
};
7382

7483
#include <QObject>
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#include "ScmEditorDialog.hpp"
2+
#include "ui_scmEditorDialog.h"
3+
4+
ScmEditorDialog::ScmEditorDialog()
5+
: StelDialog("ScmEditorDialog")
6+
{
7+
ui = new Ui_scmEditorDialog;
8+
}
9+
10+
ScmEditorDialog::~ScmEditorDialog()
11+
{
12+
delete ui;
13+
}
14+
15+
void ScmEditorDialog::retranslate()
16+
{
17+
if (dialog)
18+
{
19+
ui->retranslateUi(dialog);
20+
}
21+
}
22+
23+
void ScmEditorDialog::createDialogContent()
24+
{
25+
ui->setupUi(dialog);
26+
27+
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
28+
connect(ui->titleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
29+
connect(ui->titleBar, &TitleBar::closeClicked, this, &StelDialog::close);
30+
31+
// LABELS TAB
32+
connect(ui->enNameTE, &QTextEdit::textChanged, this, [this]()
33+
{
34+
constellationEnglishName = ui->enNameTE->toPlainText();
35+
if(constellationEnglishName.isEmpty())
36+
{
37+
ui->saveLabelsBtn->setEnabled(false);
38+
}
39+
else
40+
{
41+
ui->saveLabelsBtn->setEnabled(true);
42+
}
43+
updateLabelsSavedLabel(false);
44+
});
45+
connect(ui->natNameTE, &QTextEdit::textChanged, this, [this]()
46+
{
47+
constellationNativeName = ui->natNameTE->toPlainText();
48+
if (constellationNativeName->isEmpty())
49+
{
50+
constellationNativeName = std::nullopt;
51+
}
52+
updateLabelsSavedLabel(false);
53+
});
54+
connect(ui->pronounceTE, &QTextEdit::textChanged, this, [this]()
55+
{
56+
constellationPronounce = ui->pronounceTE->toPlainText();
57+
if (constellationPronounce->isEmpty())
58+
{
59+
constellationPronounce = std::nullopt;
60+
}
61+
updateLabelsSavedLabel(false);
62+
});
63+
connect(ui->ipaTE, &QTextEdit::textChanged, this, [this]()
64+
{
65+
constellationIpa = ui->ipaTE->toPlainText();
66+
if (constellationIpa->isEmpty())
67+
{
68+
constellationIpa = std::nullopt;
69+
}
70+
updateLabelsSavedLabel(false);
71+
});
72+
ui->saveLabelsBtn->setEnabled(false);
73+
connect(ui->saveLabelsBtn, &QPushButton::clicked, this, &ScmEditorDialog::saveLabels);
74+
updateLabelsSavedLabel(false);
75+
}
76+
77+
void ScmEditorDialog::saveLabels()
78+
{
79+
qDebug() << "ScmEditorDialog: Saving labels:";
80+
qDebug() << " English Name:" << constellationEnglishName;
81+
if(constellationNativeName) qDebug() << " Native Name:" << constellationNativeName.value_or("N/A");
82+
if(constellationPronounce) qDebug() << " Pronounce:" << constellationPronounce.value_or("N/A");
83+
if(constellationIpa) qDebug() << " IPA:" << constellationIpa.value_or("N/A");
84+
85+
updateLabelsSavedLabel(true);
86+
}
87+
88+
void ScmEditorDialog::updateLabelsSavedLabel(bool saved)
89+
{
90+
if (saved)
91+
{
92+
ui->labelsSavedLbl->setText("Saved labels.");
93+
}
94+
else
95+
{
96+
ui->labelsSavedLbl->setText("");
97+
}
98+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#ifndef SCM_EDITOR_DIALOG_HPP
2+
#define SCM_EDITOR_DIALOG_HPP
3+
4+
#include <QObject>
5+
#include <QString>
6+
#include <optional>
7+
#include "StelDialog.hpp"
8+
9+
class Ui_scmEditorDialog;
10+
11+
class ScmEditorDialog : public StelDialog
12+
{
13+
14+
protected:
15+
void createDialogContent() override;
16+
17+
public:
18+
ScmEditorDialog();
19+
~ScmEditorDialog() override;
20+
21+
public slots:
22+
void retranslate() override;
23+
24+
private slots:
25+
void saveLabels();
26+
27+
private:
28+
Ui_scmEditorDialog *ui;
29+
30+
QString constellationEnglishName;
31+
std::optional<QString> constellationNativeName;
32+
std::optional<QString> constellationPronounce;
33+
std::optional<QString> constellationIpa;
34+
35+
void updateLabelsSavedLabel(bool saved);
36+
};
37+
38+
#endif // SCM_EDITOR_DIALOG_HPP
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "ScmStartDialog.hpp"
2+
#include "ui_scmStartDialog.h"
3+
4+
ScmStartDialog::ScmStartDialog()
5+
: StelDialog("ScmStartDialog")
6+
{
7+
ui = new Ui_scmStartDialog;
8+
}
9+
10+
ScmStartDialog::~ScmStartDialog()
11+
{
12+
delete ui;
13+
}
14+
15+
void ScmStartDialog::retranslate()
16+
{
17+
if (dialog)
18+
{
19+
ui->retranslateUi(dialog);
20+
}
21+
}
22+
23+
void ScmStartDialog::createDialogContent()
24+
{
25+
ui->setupUi(dialog);
26+
27+
// connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
28+
connect(ui->titleBar, &TitleBar::closeClicked, this, &StelDialog::close);
29+
connect(ui->titleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
30+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef SCMSTARTDIALOG_HPP
2+
#define SCMSTARTDIALOG_HPP
3+
4+
#include <QObject>
5+
#include "StelDialog.hpp"
6+
7+
class Ui_scmStartDialog;
8+
9+
class ScmStartDialog : public StelDialog
10+
{
11+
12+
protected:
13+
void createDialogContent() override;
14+
15+
public:
16+
ScmStartDialog();
17+
~ScmStartDialog() override;
18+
19+
public slots:
20+
void retranslate() override;
21+
22+
private:
23+
Ui_scmStartDialog* ui;
24+
};
25+
26+
#endif // SCMSTARTDIALOG_HPP

0 commit comments

Comments
 (0)