Skip to content

Commit 6c49298

Browse files
committed
add button for drawing dark constellations
1 parent 9d1fadd commit 6c49298

File tree

10 files changed

+112
-27
lines changed

10 files changed

+112
-27
lines changed

plugins/SkyCultureMaker/src/ScmConstellation.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@ class ScmConstellation
213213
*/
214214
void show();
215215

216+
/**
217+
* @brief Returns whether the constellation is a dark constellation.
218+
*
219+
* @return true If the constellation is a dark constellation, false otherwise.
220+
*/
221+
bool getIsDarkConstellation() const { return isDarkConstellation; }
222+
216223
private:
217224
/// Identifier of the constellation
218225
QString id;

plugins/SkyCultureMaker/src/ScmDraw.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ public slots:
194194
*/
195195
void setTool(DrawTools tool);
196196

197+
/**
198+
* @brief Sets the drawing mode.
199+
*
200+
* @param mode The drawing mode to use.
201+
*/
202+
void setDrawingMode(DrawingMode mode) { drawingMode = mode; }
203+
197204
/**
198205
* @brief Resets the currently drawn lines.
199206
*/

plugins/SkyCultureMaker/src/SkyCultureMaker.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,19 @@ void SkyCultureMaker::setConstellationDialogVisibility(bool b)
333333
scmConstellationDialog->setVisible(b);
334334
}
335335

336+
// Disable the add constellation buttons when the dialog is opened
337+
scmSkyCultureDialog->updateAddConstellationButtons(!b);
336338
setIsLineDrawEnabled(b);
337339
}
338340

341+
void SkyCultureMaker::setConstellationDialogIsDarkConstellation(bool isDarkConstellation)
342+
{
343+
if (scmConstellationDialog != nullptr)
344+
{
345+
scmConstellationDialog->setIsDarkConstellation(isDarkConstellation);
346+
}
347+
}
348+
339349
void SkyCultureMaker::setSkyCultureExportDialogVisibility(bool b)
340350
{
341351
if (b != scmSkyCultureExportDialog->visible())

plugins/SkyCultureMaker/src/SkyCultureMaker.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ class SkyCultureMaker : public StelModule
105105
*/
106106
void setConstellationDialogVisibility(bool b);
107107

108+
/**
109+
* @brief Sets whether the constellation dialog is for a dark constellation.
110+
*
111+
* @param isDarkConstellation The boolean value to be set.
112+
*/
113+
void setConstellationDialogIsDarkConstellation(bool isDarkConstellation);
114+
108115
/**
109116
* @brief Shows the sky culture export dialog.
110117
*

plugins/SkyCultureMaker/src/gui/ScmConstellationDialog.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <QDebug>
3434
#include <QFileDialog>
3535
#include <QFileInfo>
36+
#include "types/DrawingMode.hpp"
3637

3738
ScmConstellationDialog::ScmConstellationDialog(SkyCultureMaker *maker)
3839
: StelDialogSeparate("ScmConstellationDialog")
@@ -69,6 +70,7 @@ void ScmConstellationDialog::loadFromConstellation(scm::ScmConstellation *conste
6970

7071
// Save the constellation that is currently being edited
7172
constellationBeingEdited = constellation;
73+
setIsDarkConstellation(constellation->getIsDarkConstellation());
7274

7375
constellationId = constellation->getId();
7476
constellationEnglishName = constellation->getEnglishName();
@@ -97,6 +99,26 @@ void ScmConstellationDialog::loadFromConstellation(scm::ScmConstellation *conste
9799
updateArtwork();
98100
}
99101

102+
void ScmConstellationDialog::setIsDarkConstellation(bool isDark)
103+
{
104+
if (!isDialogInitialized)
105+
{
106+
createDialogContent();
107+
}
108+
109+
scm::ScmDraw *draw = maker->getScmDraw();
110+
if(draw != nullptr)
111+
{
112+
draw->setDrawingMode(isDark ? scm::DrawingMode::Coordinates : scm::DrawingMode::StarsAndDSO);
113+
}
114+
115+
if (ui != nullptr)
116+
{
117+
ui->titleBar->setTitle(isDark ? q_("SCM: Dark Constellation Editor") : q_("SCM: Constellation Editor"));
118+
ui->labelsTitle->setText(isDark ? q_("Please name your Dark Constellation") : q_("Please name your Constellation"));
119+
}
120+
}
121+
100122
void ScmConstellationDialog::retranslate()
101123
{
102124
if (dialog)
@@ -118,6 +140,8 @@ void ScmConstellationDialog::createDialogContent()
118140
ui->artwork_image->setScene(imageItem->scene());
119141
ui->bind_star->setEnabled(false);
120142

143+
setIsDarkConstellation(false);
144+
121145
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate()));
122146
connect(ui->titleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMovedTo(QPoint)));
123147
connect(ui->titleBar, &TitleBar::closeClicked, this, &ScmConstellationDialog::close);

plugins/SkyCultureMaker/src/gui/ScmConstellationDialog.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class ScmConstellationDialog : public StelDialogSeparate
4646
ScmConstellationDialog(SkyCultureMaker *maker);
4747
~ScmConstellationDialog() override;
4848
void loadFromConstellation(scm::ScmConstellation *constellation);
49+
void setIsDarkConstellation(bool isDarkConstellation);
4950

5051
public slots:
5152
void retranslate() override;

plugins/SkyCultureMaker/src/gui/ScmSkyCultureDialog.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ void ScmSkyCultureDialog::createDialogContent()
104104
ui->ExportSkyCultureBtn->setEnabled(false);
105105
ui->RemoveConstellationBtn->setEnabled(false);
106106
ui->EditConstellationBtn->setEnabled(false);
107+
107108
connect(ui->ExportSkyCultureBtn, &QPushButton::clicked, this, &ScmSkyCultureDialog::saveSkyCulture);
108-
connect(ui->AddConstellationBtn, &QPushButton::clicked, this, &ScmSkyCultureDialog::constellationDialog);
109+
connect(ui->AddConstellationBtn, &QPushButton::clicked, this, [this]() { openConstellationDialog(false); });
110+
connect(ui->AddDarkConstellationBtn, &QPushButton::clicked, this, [this]() { openConstellationDialog(true); });
109111

110112
connect(ui->EditConstellationBtn, &QPushButton::clicked, this, &ScmSkyCultureDialog::editSelectedConstellation);
111113
connect(ui->constellationsList, &QListWidget::itemSelectionChanged, this,
@@ -247,9 +249,10 @@ void ScmSkyCultureDialog::removeSelectedConstellation()
247249
}
248250
}
249251

250-
void ScmSkyCultureDialog::constellationDialog()
252+
void ScmSkyCultureDialog::openConstellationDialog(bool isDarkConstellation)
251253
{
252254
maker->setConstellationDialogVisibility(true);
255+
maker->setConstellationDialogIsDarkConstellation(isDarkConstellation);
253256
}
254257

255258
void ScmSkyCultureDialog::setIdFromName(QString &name)
@@ -258,6 +261,12 @@ void ScmSkyCultureDialog::setIdFromName(QString &name)
258261
maker->getCurrentSkyCulture()->setId(id);
259262
}
260263

264+
void ScmSkyCultureDialog::updateAddConstellationButtons(bool enabled)
265+
{
266+
ui->AddConstellationBtn->setEnabled(enabled);
267+
ui->AddDarkConstellationBtn->setEnabled(enabled);
268+
}
269+
261270
void ScmSkyCultureDialog::updateEditConstellationButton()
262271
{
263272
if (!ui->constellationsList->selectedItems().isEmpty())

plugins/SkyCultureMaker/src/gui/ScmSkyCultureDialog.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ class ScmSkyCultureDialog : public StelDialogSeparate
7171
*/
7272
void resetDialog();
7373

74+
/**
75+
* @brief Updates the add constellation button state.
76+
*
77+
* @param enabled Whether the button should be enabled or disabled.
78+
*/
79+
void updateAddConstellationButtons(bool enabled);
80+
7481
public slots:
7582
void retranslate() override;
7683
void close() override;
@@ -80,7 +87,7 @@ protected slots:
8087

8188
private slots:
8289
void saveSkyCulture();
83-
void constellationDialog();
90+
void openConstellationDialog(bool isDarkConstellation);
8491
void editSelectedConstellation();
8592
void removeSelectedConstellation();
8693
void updateEditConstellationButton();

plugins/SkyCultureMaker/src/gui/scmConstellationDialog.ui

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@
128128
</property>
129129
<item>
130130
<widget class="QLabel" name="labelsTitle">
131-
<property name="text">
132-
<string>Please name the Constellation</string>
133-
</property>
134131
</widget>
135132
</item>
136133
<item>

plugins/SkyCultureMaker/src/gui/scmSkyCultureDialog.ui

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>418</width>
10-
<height>401</height>
9+
<width>355</width>
10+
<height>426</height>
1111
</rect>
1212
</property>
1313
<property name="minimumSize">
1414
<size>
15-
<width>0</width>
15+
<width>355</width>
1616
<height>0</height>
1717
</size>
1818
</property>
@@ -120,13 +120,10 @@
120120
</property>
121121
<property name="html">
122122
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
123-
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
123+
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
124124
p, li { white-space: pre-wrap; }
125-
hr { height: 1px; border-width: 0; }
126-
li.unchecked::marker { content: &quot;\2610&quot;; }
127-
li.checked::marker { content: &quot;\2612&quot;; }
128-
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
129-
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
125+
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'.AppleSystemUIFont'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
126+
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Segoe UI'; font-size:9pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
130127
</property>
131128
<property name="acceptRichText">
132129
<bool>false</bool>
@@ -167,8 +164,8 @@ li.checked::marker { content: &quot;\2612&quot;; }
167164
</widget>
168165
</item>
169166
<item>
170-
<layout class="QHBoxLayout" name="overviewConstellationBtnLayout">
171-
<item>
167+
<layout class="QGridLayout" name="overviewConstellationBtnLayout">
168+
<item row="0" column="0">
172169
<widget class="QPushButton" name="AddConstellationBtn">
173170
<property name="sizePolicy">
174171
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
@@ -178,16 +175,35 @@ li.checked::marker { content: &quot;\2612&quot;; }
178175
</property>
179176
<property name="minimumSize">
180177
<size>
181-
<width>100</width>
178+
<width>140</width>
182179
<height>0</height>
183180
</size>
184181
</property>
185182
<property name="text">
186-
<string>Add</string>
183+
<string>Add Constellation</string>
187184
</property>
188185
</widget>
189186
</item>
190-
<item>
187+
<item row="0" column="1">
188+
<widget class="QPushButton" name="AddDarkConstellationBtn">
189+
<property name="sizePolicy">
190+
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
191+
<horstretch>0</horstretch>
192+
<verstretch>0</verstretch>
193+
</sizepolicy>
194+
</property>
195+
<property name="minimumSize">
196+
<size>
197+
<width>140</width>
198+
<height>0</height>
199+
</size>
200+
</property>
201+
<property name="text">
202+
<string>Add Dark Constellation</string>
203+
</property>
204+
</widget>
205+
</item>
206+
<item row="1" column="0">
191207
<widget class="QPushButton" name="EditConstellationBtn">
192208
<property name="sizePolicy">
193209
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
@@ -197,7 +213,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
197213
</property>
198214
<property name="minimumSize">
199215
<size>
200-
<width>100</width>
216+
<width>140</width>
201217
<height>0</height>
202218
</size>
203219
</property>
@@ -206,7 +222,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
206222
</property>
207223
</widget>
208224
</item>
209-
<item>
225+
<item row="1" column="1">
210226
<widget class="QPushButton" name="RemoveConstellationBtn">
211227
<property name="sizePolicy">
212228
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
@@ -216,7 +232,7 @@ li.checked::marker { content: &quot;\2612&quot;; }
216232
</property>
217233
<property name="minimumSize">
218234
<size>
219-
<width>100</width>
235+
<width>140</width>
220236
<height>0</height>
221237
</size>
222238
</property>
@@ -299,8 +315,8 @@ li.checked::marker { content: &quot;\2612&quot;; }
299315
<rect>
300316
<x>0</x>
301317
<y>0</y>
302-
<width>395</width>
303-
<height>1200</height>
318+
<width>320</width>
319+
<height>1886</height>
304320
</rect>
305321
</property>
306322
<layout class="QVBoxLayout" name="descriptionLayout">
@@ -708,8 +724,8 @@ li.checked::marker { content: &quot;\2612&quot;; }
708724
</property>
709725
<property name="sizeHint" stdset="0">
710726
<size>
711-
<width>20</width>
712-
<height>40</height>
727+
<width>40</width>
728+
<height>20</height>
713729
</size>
714730
</property>
715731
</spacer>

0 commit comments

Comments
 (0)