1 #pragma once 2 3 #ifndef CLEANUPPOPUP_H 4 #define CLEANUPPOPUP_H 5 6 #include <memory> 7 8 // TnzQt includes 9 #include "toonzqt/validatedchoicedialog.h" 10 11 // TnzCore includes 12 #include "tfilepath.h" 13 #include "timage.h" 14 15 #include <QMap> 16 17 //================================================ 18 19 // Forward declarations 20 21 class TXshSimpleLevel; 22 class ImageViewer; 23 class CleanupParameters; 24 class LevelUpdater; 25 26 namespace DVGui { 27 class LineEdit; 28 } 29 30 class QProgressBar; 31 class QLabel; 32 class QPushButton; 33 class QHideEvent; 34 class QGroupBox; 35 36 //================================================ 37 38 //***************************************************************************** 39 // CleanupPopup declaration 40 //***************************************************************************** 41 42 class CleanupPopup final : public QDialog { 43 Q_OBJECT 44 45 public: 46 CleanupPopup(); 47 ~CleanupPopup(); 48 49 void execute(); 50 51 protected: 52 void closeEvent(QCloseEvent *) override; 53 54 private: 55 class OverwriteDialog; 56 struct CleanupLevel; 57 58 private: 59 QProgressBar *m_progressBar; 60 QLabel *m_progressLabel; 61 QLabel *m_cleanupQuestionLabel; 62 ImageViewer *m_imageViewer; 63 QGroupBox *m_imgViewBox; 64 65 /*---ビジー時にボタンをUnableするため---*/ 66 QPushButton *m_cleanupAllButton; 67 QPushButton *m_cleanupButton; 68 QPushButton *m_skipButton; 69 70 std::unique_ptr<LevelUpdater> m_updater; //!< The cleanup level updater. 71 72 std::vector<CleanupLevel> 73 m_cleanupLevels; //!< List of levels to be cleanupped. 74 std::pair<int, int> m_idx, //!< Current cleanup list position. 75 m_completion; //!< Count of completed frames versus total frames. 76 bool m_firstLevelFrame; //!< Whether this is the first cleanupped frame on 77 //! current level. Used in some autoadjust cases. 78 79 std::vector<TFrameId> m_cleanuppedLevelFrames; //!< Current level's list of 80 //! cleanupped frames. Used 81 //! to selectively build the level's unpainted backup. 82 std::unique_ptr<CleanupParameters> 83 m_params; //!< Cleanup params used to cleanup. 84 85 std::unique_ptr<OverwriteDialog> 86 m_overwriteDialog; //!< Dialog about level overwriting options. 87 88 /* Palette上書きの判断をするために、保存先Levelが既に存在するかどうかのフラグ 89 ただし、REPLACE又はNOPAINT_ONLYの場合はこのフラグは無視して必ずPaletteを上書きする 90 */ 91 QMap<TXshSimpleLevel *, bool> m_levelAlreadyExists; 92 /*--- 再Cleanupの場合、Xsheetを再現するためにパスを取っておく ---*/ 93 TFilePath m_originalLevelPath; 94 /* Cleanup後、Paletteを更新するかどうかのフラグ。再Cleanupの場合は、 95 m_actionがREPLACE_LEVELの場合以外は元のPaletteを保持する。 96 */ 97 bool m_keepOriginalPalette; 98 TPalette *m_originalPalette; 99 100 private: 101 void reset(); 102 void buildCleanupList(); 103 bool 104 analyzeCleanupList(); //!< Checks m_cleanupFrames for existing output levels 105 //! and updates it depending on user choices. \return Whether cleanup can 106 //! take place. 107 bool isValidPosition(const std::pair<int, int> &pos) 108 const; //!< Returns whether specified cleanup position is valid. 109 QString currentString() const; 110 TImageP currentImage() const; 111 112 QString setupLevel(); //!< Prepares level for cleanup. \return An eventual 113 //! failure message. 114 QString resetLevel(); //!< Erases existing output for the cleanup operation. 115 //!\return An eventual failure message. 116 void closeLevel(); 117 118 void cleanupFrame(); 119 void advanceFrame(); 120 121 /*--- 進捗をタスクバーから確認するため、MainWindowのタイトルバーに表示する 122 * ---*/ 123 void updateTitleString(); 124 125 private slots: 126 127 void onCleanupFrame(); 128 void onSkipFrame(); 129 void onCleanupAllFrame(); 130 void onCancelCleanup(); 131 void onValueChanged(int); 132 void onImgViewBoxToggled(bool); 133 }; 134 135 //***************************************************************************** 136 // CleanupPopup::OverwriteDialog declaration (private) 137 //***************************************************************************** 138 139 class CleanupPopup::OverwriteDialog final 140 : public DVGui::ValidatedChoiceDialog { 141 Q_OBJECT 142 143 public: 144 OverwriteDialog(); 145 146 void reset() override; 147 148 private: 149 DVGui::LineEdit *m_suffix; 150 QString m_suffixText; 151 152 private: 153 QString acceptResolution(void *obj, int resolution, bool applyToAll) override; 154 void initializeUserInteraction(const void *obj) override; 155 156 private slots: 157 158 void onButtonClicked(int buttonId); 159 }; 160 161 #endif // CLEANUPPOPUP_H 162