// Copyright (C) 2020 Jakub Melka // // This file is part of PdfForQt. // // PdfForQt is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // PdfForQt is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with PDFForQt. If not, see . #ifndef GENERATORMAINWINDOW_H #define GENERATORMAINWINDOW_H #include class QTreeWidgetItem; namespace codegen { class CodeGenerator; class GeneratedFunction; } namespace Ui { class GeneratorMainWindow; } class BoolGuard { public: explicit inline BoolGuard(bool& value) : m_oldValue(value), m_value(&value) { *m_value = true; } inline ~BoolGuard() { *m_value = m_oldValue; } private: bool m_oldValue; bool* m_value; }; class GeneratorMainWindow : public QMainWindow { Q_OBJECT public: GeneratorMainWindow(QWidget* parent = nullptr); virtual ~GeneratorMainWindow() override; void load(const QString& fileName); void save(const QString& fileName); private slots: void on_actionLoad_triggered(); void on_actionSaveAs_triggered(); void on_actionSave_triggered(); void on_newFunctionButton_clicked(); void on_cloneFunctionButton_clicked(); void on_removeFunctionButton_clicked(); private: void loadSettings(); void saveSettings(); void updateFunctionListUI(); void setCurrentFunction(codegen::GeneratedFunction* currentFunction); void onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous); Ui::GeneratorMainWindow* ui; codegen::CodeGenerator* m_generator; codegen::GeneratedFunction* m_currentFunction; QString m_defaultFileName; std::map m_mapFunctionToWidgetItem; bool m_isLoadingData; }; #endif // GENERATORMAINWINDOW_H