Skip to content

Commit 3e499a2

Browse files
Add Save AS implementation
1 parent 894d1fd commit 3e499a2

File tree

3 files changed

+38
-22
lines changed

3 files changed

+38
-22
lines changed

src/GUI/EditorWindow.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "SettingsWindow.hpp"
2121
#include "EditorWindow.hpp"
2222

23+
#pragma region CTORs and Setters
24+
2325
EditorWindow::EditorWindow(QWidget* parent)
2426
: QMainWindow(parent)
2527
, pFactionsButtonsGroup{new QButtonGroup{this}}
@@ -391,6 +393,10 @@ void EditorWindow::SetActionHotkey(const QString& fctShortName, const QString& g
391393
fct.SetHotkey(goName, actName, hk);
392394
}
393395

396+
#pragma endregion
397+
398+
#pragma region Handlers
399+
394400
void EditorWindow::KeyboardWindow_Nullify()
395401
{
396402
for (QChar& qc : QString("QWERTYUIOPASDFGHJKLZXCVBNM"))
@@ -525,9 +531,16 @@ void EditorWindow::ActSave_Triggered()
525531

526532
void EditorWindow::ActSaveAs_Triggered()
527533
{
528-
LOGMSG("ActSaveAs_Triggered");
534+
QFileDialog* fdSelectFileWindow = new QFileDialog();
535+
connect(fdSelectFileWindow, &QFileDialog::fileSelected, this, &EditorWindow::ActSaveAs_SaveToSelectedFile);
536+
fdSelectFileWindow->setFileMode(QFileDialog::FileMode::AnyFile);
537+
fdSelectFileWindow->setAcceptMode(QFileDialog::AcceptMode::AcceptSave);
538+
fdSelectFileWindow->setDefaultSuffix("csf");
539+
fdSelectFileWindow->exec();
529540
}
530541

542+
void EditorWindow::ActSaveAs_SaveToSelectedFile(const QString& filepath) { CSF_PARSER->Save(filepath); }
543+
531544
void EditorWindow::ActOpen_Triggered()
532545
{
533546
QFileDialog* fdSelectFileWindow = new QFileDialog();
@@ -544,3 +557,5 @@ void EditorWindow::ActOpen_NewHotkeyFileSelected(const QString& filepath)
544557
LOGMSG("Selected file: " + filepath);
545558
emit newHotkeyFileSelected(filepath);
546559
}
560+
561+
#pragma endregion

src/GUI/EditorWindow.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ private slots:
5757
void ActSaveAs_Triggered();
5858
void ActOpen_Triggered();
5959
void ActOpen_NewHotkeyFileSelected(const QString& filepath);
60+
void ActSaveAs_SaveToSelectedFile(const QString& filepath);
6061

6162
signals:
6263
void languageChanged();

src/GUI/Translations/ru.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,99 +38,99 @@
3838
<context>
3939
<name>EditorWindow</name>
4040
<message>
41-
<location filename="../EditorWindow.cpp" line="168"/>
41+
<location filename="../EditorWindow.cpp" line="170"/>
4242
<source>File</source>
4343
<translation>Файл</translation>
4444
</message>
4545
<message>
46-
<location filename="../EditorWindow.cpp" line="169"/>
46+
<location filename="../EditorWindow.cpp" line="171"/>
4747
<source>Open</source>
4848
<translation>Открыть</translation>
4949
</message>
5050
<message>
51-
<location filename="../EditorWindow.cpp" line="170"/>
51+
<location filename="../EditorWindow.cpp" line="172"/>
5252
<source>Save</source>
5353
<translation>Сохранить</translation>
5454
</message>
5555
<message>
56-
<location filename="../EditorWindow.cpp" line="171"/>
56+
<location filename="../EditorWindow.cpp" line="173"/>
5757
<source>Save As...</source>
5858
<translation>Сохранить как...</translation>
5959
</message>
6060
<message>
61-
<location filename="../EditorWindow.cpp" line="172"/>
61+
<location filename="../EditorWindow.cpp" line="174"/>
6262
<source>Special</source>
6363
<translation>Дополнительно</translation>
6464
</message>
6565
<message>
66-
<location filename="../EditorWindow.cpp" line="188"/>
66+
<location filename="../EditorWindow.cpp" line="190"/>
6767
<source>View</source>
6868
<translation>Вид</translation>
6969
</message>
7070
<message>
71-
<location filename="../EditorWindow.cpp" line="189"/>
71+
<location filename="../EditorWindow.cpp" line="191"/>
7272
<source>Status Bar</source>
7373
<translation>Строка состояния</translation>
7474
</message>
7575
<message>
76-
<location filename="../EditorWindow.cpp" line="190"/>
76+
<location filename="../EditorWindow.cpp" line="192"/>
7777
<source>Enable</source>
7878
<translation>Включить</translation>
7979
</message>
8080
<message>
81-
<location filename="../EditorWindow.cpp" line="191"/>
81+
<location filename="../EditorWindow.cpp" line="193"/>
8282
<source>Disable</source>
8383
<translation>Отключить</translation>
8484
</message>
8585
<message>
86-
<location filename="../EditorWindow.cpp" line="195"/>
87-
<location filename="../EditorWindow.cpp" line="504"/>
86+
<location filename="../EditorWindow.cpp" line="197"/>
87+
<location filename="../EditorWindow.cpp" line="510"/>
8888
<source>Settings</source>
8989
<translation>Настройки</translation>
9090
</message>
9191
<message>
92-
<location filename="../EditorWindow.cpp" line="199"/>
93-
<location filename="../EditorWindow.cpp" line="469"/>
92+
<location filename="../EditorWindow.cpp" line="201"/>
93+
<location filename="../EditorWindow.cpp" line="475"/>
9494
<source>About</source>
9595
<translation>О программе</translation>
9696
</message>
9797
<message>
98-
<location filename="../EditorWindow.cpp" line="333"/>
98+
<location filename="../EditorWindow.cpp" line="335"/>
9999
<source>Layout %1</source>
100100
<translation>Раскладка %1</translation>
101101
</message>
102102
<message>
103-
<location filename="../EditorWindow.cpp" line="449"/>
103+
<location filename="../EditorWindow.cpp" line="455"/>
104104
<source>Authors: </source>
105105
<translation>Авторы: </translation>
106106
</message>
107107
<message>
108-
<location filename="../EditorWindow.cpp" line="450"/>
108+
<location filename="../EditorWindow.cpp" line="456"/>
109109
<source>Version: </source>
110110
<translation>Версия: </translation>
111111
</message>
112112
<message>
113-
<location filename="../EditorWindow.cpp" line="451"/>
113+
<location filename="../EditorWindow.cpp" line="457"/>
114114
<source>Program licensed with </source>
115115
<translation>Программа лицензирована под </translation>
116116
</message>
117117
<message>
118-
<location filename="../EditorWindow.cpp" line="452"/>
118+
<location filename="../EditorWindow.cpp" line="458"/>
119119
<source>GitHub repository:</source>
120120
<translation>Репозиторий на GitHub:</translation>
121121
</message>
122122
<message>
123-
<location filename="../EditorWindow.cpp" line="454"/>
123+
<location filename="../EditorWindow.cpp" line="460"/>
124124
<source>Support development:</source>
125125
<translation>Поддержать разработку:</translation>
126126
</message>
127127
<message>
128-
<location filename="../EditorWindow.cpp" line="537"/>
128+
<location filename="../EditorWindow.cpp" line="550"/>
129129
<source>Binary files</source>
130130
<translation type="unfinished">Двоичные файлы</translation>
131131
</message>
132132
<message>
133-
<location filename="../EditorWindow.cpp" line="538"/>
133+
<location filename="../EditorWindow.cpp" line="551"/>
134134
<source>Any files</source>
135135
<translation type="unfinished">Все файлы</translation>
136136
</message>

0 commit comments

Comments
 (0)