Skip to content

Commit a6d0035

Browse files
initial ui for import
1 parent 9e946b9 commit a6d0035

File tree

3 files changed

+152
-41
lines changed

3 files changed

+152
-41
lines changed

plugins/SkyCultureMaker/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ CPMAddPackage(
2020
"SKYCULTURE_CONVERTER_BUILD_TESTS OFF"
2121
)
2222

23+
# download https://github.com/artemvlas/qmicroz for archives
24+
# CPMAddPackage(
25+
# NAME qmicroz
26+
# GITHUB_REPOSITORY artemvlas/qmicroz
27+
# GIT_TAG v0.4
28+
# )
29+
2330

2431
ADD_DEFINITIONS(-DSKYCULTUREMAKER_PLUGIN_VERSION="${SCM_VERSION}")
2532
ADD_DEFINITIONS(-DSKYCULTUREMAKER_PLUGIN_LICENSE="GNU GPLv2 or later")

plugins/SkyCultureMaker/src/gui/ScmEditorDialog.cpp

Lines changed: 83 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#include "ScmEditorDialog.hpp"
22
#include "ui_scmEditorDialog.h"
3+
#include <QFileDialog>
4+
#include <QFileSystemModel>
5+
#include <QMessageBox>
36

47
ScmEditorDialog::ScmEditorDialog()
58
: StelDialog("ScmEditorDialog")
@@ -29,58 +32,99 @@ void ScmEditorDialog::createDialogContent()
2932
connect(ui->titleBar, &TitleBar::closeClicked, this, &StelDialog::close);
3033

3134
// LABELS TAB
32-
connect(ui->enNameTE, &QTextEdit::textChanged, this, [this]()
33-
{
34-
constellationEnglishName = ui->enNameTE->toPlainText();
35-
if(constellationEnglishName.isEmpty())
35+
connect(ui->enNameTE,
36+
&QTextEdit::textChanged,
37+
this,
38+
[this]()
3639
{
37-
ui->saveLabelsBtn->setEnabled(false);
38-
}
39-
else
40+
constellationEnglishName = ui->enNameTE->toPlainText();
41+
if (constellationEnglishName.isEmpty())
42+
{
43+
ui->saveLabelsBtn->setEnabled(false);
44+
}
45+
else
46+
{
47+
ui->saveLabelsBtn->setEnabled(true);
48+
}
49+
updateLabelsSavedLabel(false);
50+
});
51+
connect(ui->natNameTE,
52+
&QTextEdit::textChanged,
53+
this,
54+
[this]()
4055
{
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())
56+
constellationNativeName = ui->natNameTE->toPlainText();
57+
if (constellationNativeName->isEmpty())
58+
{
59+
constellationNativeName = std::nullopt;
60+
}
61+
updateLabelsSavedLabel(false);
62+
});
63+
connect(ui->pronounceTE,
64+
&QTextEdit::textChanged,
65+
this,
66+
[this]()
4967
{
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())
68+
constellationPronounce = ui->pronounceTE->toPlainText();
69+
if (constellationPronounce->isEmpty())
70+
{
71+
constellationPronounce = std::nullopt;
72+
}
73+
updateLabelsSavedLabel(false);
74+
});
75+
connect(ui->ipaTE,
76+
&QTextEdit::textChanged,
77+
this,
78+
[this]()
6779
{
68-
constellationIpa = std::nullopt;
69-
}
70-
updateLabelsSavedLabel(false);
71-
});
80+
constellationIpa = ui->ipaTE->toPlainText();
81+
if (constellationIpa->isEmpty())
82+
{
83+
constellationIpa = std::nullopt;
84+
}
85+
updateLabelsSavedLabel(false);
86+
});
7287
ui->saveLabelsBtn->setEnabled(false);
7388
connect(ui->saveLabelsBtn, &QPushButton::clicked, this, &ScmEditorDialog::saveLabels);
7489
updateLabelsSavedLabel(false);
90+
91+
/* ============================================= SCM importer/converter ============================================= */
92+
auto fsModel = new QFileSystemModel(this);
93+
fsModel->setRootPath(QDir::homePath());
94+
ui->fileSystem->setModel(fsModel);
95+
ui->fileSystem->setRootIndex(fsModel->index(QDir::homePath()));
96+
97+
connect(ui->fileSystem,
98+
&QTreeView::doubleClicked,
99+
this,
100+
[this, fsModel](const QModelIndex &idx)
101+
{
102+
const QString path = fsModel->filePath(idx);
103+
ui->filePathLineEdit->setText(path);
104+
});
105+
connect(ui->pushButton, &QPushButton::clicked, this, [this]()
106+
{
107+
const QString path = ui->filePathLineEdit->text();
108+
if (path.isEmpty())
109+
{
110+
QMessageBox::warning(dialog, tr("No file selected"), tr("Please pick a file first."));
111+
return;
112+
}
113+
qDebug() << "Importing file:" << path;
114+
});
115+
/* ================================================================================================================== */
75116
}
76117

77118
void ScmEditorDialog::saveLabels()
78119
{
79120
qDebug() << "ScmEditorDialog: Saving labels:";
80121
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");
122+
if (constellationNativeName)
123+
qDebug() << " Native Name:" << constellationNativeName.value_or("N/A");
124+
if (constellationPronounce)
125+
qDebug() << " Pronounce:" << constellationPronounce.value_or("N/A");
126+
if (constellationIpa)
127+
qDebug() << " IPA:" << constellationIpa.value_or("N/A");
84128

85129
updateLabelsSavedLabel(true);
86130
}

plugins/SkyCultureMaker/src/gui/scmEditorDialog.ui

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>361</width>
9+
<width>609</width>
1010
<height>412</height>
1111
</rect>
1212
</property>
@@ -84,7 +84,7 @@
8484
</size>
8585
</property>
8686
<property name="currentIndex">
87-
<number>1</number>
87+
<number>4</number>
8888
</property>
8989
<property name="iconSize">
9090
<size>
@@ -237,6 +237,66 @@
237237
<string>Boundaries</string>
238238
</attribute>
239239
</widget>
240+
<widget class="QWidget" name="Import">
241+
<property name="enabled">
242+
<bool>true</bool>
243+
</property>
244+
<attribute name="title">
245+
<string>Import</string>
246+
</attribute>
247+
<widget class="QPushButton" name="pushButton">
248+
<property name="geometry">
249+
<rect>
250+
<x>10</x>
251+
<y>300</y>
252+
<width>581</width>
253+
<height>22</height>
254+
</rect>
255+
</property>
256+
<property name="text">
257+
<string>Import</string>
258+
</property>
259+
</widget>
260+
<widget class="QTreeView" name="fileSystem">
261+
<property name="geometry">
262+
<rect>
263+
<x>10</x>
264+
<y>39</y>
265+
<width>581</width>
266+
<height>221</height>
267+
</rect>
268+
</property>
269+
</widget>
270+
<widget class="QLineEdit" name="filePathLineEdit">
271+
<property name="geometry">
272+
<rect>
273+
<x>10</x>
274+
<y>270</y>
275+
<width>581</width>
276+
<height>22</height>
277+
</rect>
278+
</property>
279+
<property name="readOnly">
280+
<bool>true</bool>
281+
</property>
282+
<property name="placeholderText">
283+
<string>Select a file…</string>
284+
</property>
285+
</widget>
286+
<widget class="QLabel" name="label">
287+
<property name="geometry">
288+
<rect>
289+
<x>10</x>
290+
<y>10</y>
291+
<width>581</width>
292+
<height>16</height>
293+
</rect>
294+
</property>
295+
<property name="text">
296+
<string>Select an archive (.zip, .rar, ...) with an old format to convert to the new format</string>
297+
</property>
298+
</widget>
299+
</widget>
240300
<widget class="QWidget" name="License">
241301
<attribute name="title">
242302
<string>License</string>

0 commit comments

Comments
 (0)