본문으로 건너뛰기
로딩중...
검색중...
일치하는것 없음
StyleCatalogDialog.h
1#pragma once
2
3#include "gdkqt/QtGdkExport.h"
4
5#include "styles/catalog/StyleCatalogDocument.h"
6
7#include <QDialog>
8#include <QString>
9#include <QStringList>
10
11#include <functional>
12#include <memory>
13#include <optional>
14
15class QCloseEvent;
16class QComboBox;
17class QLineEdit;
18class QPlainTextEdit;
19class QPushButton;
20class QTableView;
21class QTimer;
22
23namespace GdkQt {
24class StyleCatalogEntryFormBinder;
25class StyleCatalogTableController;
26class StylePreviewWidget;
27
34class QT_GDK_API StyleCatalogDialog final : public QDialog
35{
36public:
41 explicit StyleCatalogDialog(QWidget* parent = nullptr);
49 void setAfterSaveCallback(std::function<QString(const QString&)> callback);
55 void setStyleResourceFolderProvider(std::function<QStringList()> provider);
61 std::function<std::optional<QString>(const QString&, const QString&)> runner);
62
67 void setImportPathProviderForTest(std::function<QString()> provider);
68
69protected:
75 void closeEvent(QCloseEvent* event) override;
79 void reject() override;
80
81private:
82 using EntryDraft = StyleCatalogDocument::Entry;
83
84 void resetDocument(const QString& filePath = {});
85 void refreshTitle();
86 void refreshTable(const QString& selectId = {});
87 void refreshTableRow(int documentRow);
88 void refreshDetails();
89 void setDirty(bool dirty);
90 bool confirmDiscard();
91 bool buildCurrentEntryFromUi(EntryDraft& entry);
92 bool applyDetails();
93 bool saveCurrentDocument(const QString& filePath);
94 bool loadFromFile(const QString& filePath);
95 bool importFromFile(const QString& filePath);
96 void addEntry();
97 void duplicateCurrentEntry();
98 void deleteCurrentEntry();
99 void editCurrentStyle();
100 void schedulePreviewRefresh();
101 void refreshPreviewNow();
102 int currentDocumentRow() const;
103 EntryDraft currentEntry() const;
104 bool writeEntry(const EntryDraft& entry, const QString& replacedId = {});
105 void notifySaved(const QString& filePath);
106 void onTableSelectionChanged();
107 void onTypeFilterChanged();
108 void selectTypeFilter(const QString& styleType);
109
110 StyleCatalogDocument m_document;
111 std::function<QString(const QString&)> m_afterSaveCallback;
112 std::function<QStringList()> m_styleResourceFolderProvider;
113 std::function<std::optional<QString>(const QString&, const QString&)> m_styleEditorRunnerForTest;
114 std::function<QString()> m_importPathProviderForTest;
115 bool m_updatingDetails = false;
116 // True once the user typed into the entry form and it was not applied yet.
117 bool m_formEdited = false;
118 // Entry id the form currently shows; a row switch applies the form to it first.
119 QString m_shownEntryId;
120 // Set while the dialog rebuilds/reselects rows itself (not a user row switch).
121 bool m_programmaticSelection = false;
122 // Set while the dialog puts the selection back; the change is not handled at all.
123 bool m_restoringSelection = false;
124 int m_lastTypeFilterIndex = 0;
125 std::unique_ptr<StyleCatalogEntryFormBinder> m_formBinder;
126 std::unique_ptr<StyleCatalogTableController> m_tableController;
127
128 QTableView* m_entryTable = nullptr;
129 QComboBox* m_typeFilter = nullptr;
130 QLineEdit* m_idEdit = nullptr;
131 QLineEdit* m_nameEdit = nullptr;
132 QLineEdit* m_groupEdit = nullptr;
133 QLineEdit* m_categoryEdit = nullptr;
134 QLineEdit* m_displayNameEdit = nullptr;
135 QLineEdit* m_tagsEdit = nullptr;
136 QPlainTextEdit* m_descriptionEdit = nullptr;
137 QPlainTextEdit* m_styleJsonEdit = nullptr;
138 QPushButton* m_editStyleButton = nullptr;
139 StylePreviewWidget* m_preview = nullptr;
140 QTimer* m_previewRefreshTimer = nullptr;
141};
142
143} // namespace GdkQt
StyleCatalogDialog(QWidget *parent=nullptr)
빈 카탈로그 문서("Untitled")로 대화상자를 만듭니다.
void setAfterSaveCallback(std::function< QString(const QString &)> callback)
저장 뒤에 부를 콜백을 등록합니다.
void setStyleResourceFolderProvider(std::function< QStringList()> provider)
스타일 편집기에서 미리 보기 이미지와 리소스를 찾을 추가 폴더 목록 공급자를 등록합니다.
void setStyleEditorRunnerForTest(std::function< std::optional< QString >(const QString &, const QString &)> runner)
테스트용: "스타일 편집"이 여는 모달 스타일 편집기를 대신할 함수를 지정합니다.
void setImportPathProviderForTest(std::function< QString()> provider)
테스트용: "가져오기"의 파일 열기 대화상자를 대신할 함수를 지정합니다.
void closeEvent(QCloseEvent *event) override
창 닫기 전에 저장하지 않은 변경을 확인합니다.
~StyleCatalogDialog() override
대화상자를 해제합니다.
void reject() override
Esc나 닫기 버튼으로 대화상자를 닫기 전에 저장하지 않은 변경을 확인합니다.
StyleCatalogEntry Entry
카탈로그 항목 형식입니다. StyleCatalogEntry와 같습니다.
정의 StyleCatalogDocument.h:19
glsGdkQt의 공개 형식과 함수가 있는 네임스페이스입니다.
정의 AppSettings.h:15