-
Notifications
You must be signed in to change notification settings - Fork 2
/
mainwindow.h
188 lines (127 loc) · 4.56 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "inferer.h"
#include <QHBoxLayout>
#include <QTimer>
#include <queue>
#include "topbarimg.h"
#include <QGoodWindow>
#include "imagesaverthread.h"
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE
using CanvasTabPtr = QWidget*;
struct SDOrder{
std::string Prompt;
std::string NegativePrompt;
Axodox::MachineLearning::StableDiffusionOptions Options;
uint32_t BatchCount;
bool RandomSeed;
QImage InputImage;
QImage InputMask;
bool IsUpscale = false;
std::string OutputPath = "";
QListWidgetItem* itmUpscaleInput = nullptr;
};
class MainWindow : public QMainWindow
{
Q_OBJECT
protected:
void showEvent(QShowEvent* event) override;
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
QGoodWindow* ParentGoodWin;
bool IsExiting(){return Exiting;};
public slots:
void OnImageDone(QImage InImg, StableDiffusionJobType JobType);
void OnBulkImageDone(QImage InImg, std::string OutputPath, QListWidgetItem *Itm);
void OnInpaintWidImageSet();
void OnImageSendToImg2Img(QImage* SndImg);
void OnImageSendToInpaint(QImage* SndImg);
void OnImageSendToUpscale(QImage* SndImg, bool TransferOwnership = false);
void OnPreviewsAvailable(std::vector<QImage> Previews);
void ModelLoadDemanded();
private slots:
void OnProgressPoll(); // Slot to be called by QTimer
void OnThreadDone();
void OnTopBarHoverChange(size_t LblIndex, bool Hovering);
void OnTopBarClick(size_t LblIndex);
void OnRequestModelDownload(QString MdlName);
void checkFirstStart();
private slots:
void on_btnGenerate_clicked();
void on_btnLoadModel_clicked();
void on_btnImagesForward_clicked();
void on_btnImagesBackwards_clicked();
void on_actionScroll_Left_triggered();
void on_actionScroll_Right_triggered();
void on_actionOpen_outputs_directory_triggered();
void on_actionClear_current_outputs_2_triggered();
void on_btnCancel_clicked();
void on_actionRefresh_model_listing_triggered();
void on_chkImg2Img_stateChanged(int arg1);
void on_sliDenoiseStrength_valueChanged(int value);
void on_chkInpaint_stateChanged(int arg1);
void on_btnClearInpaint_clicked();
void on_btnUpscale_clicked();
void on_btnLoadUpscaler_clicked();
void on_btnUpsBrowseFolder_clicked();
void on_btnAddBulkFolder_clicked();
void on_btnBrowseBulkUpsOutFolder_clicked();
void on_btnAddFromSpecialFolder_clicked();
void on_actionOpen_favorites_directory_triggered();
void on_actionWhat_s_this_triggered(bool checked);
void on_actionWhat_s_this_triggered();
void on_btnClearUpscaleAdds_clicked();
void on_actUndo_triggered();
void on_actRender_triggered();
void on_actNewCanvas_triggered();
void on_actionDownload_models_triggered();
void on_actionDownload_a_model_from_Huggingface_triggered();
void on_actCheckGPU_triggered();
void on_actGenerate_triggered();
private:
void OpenDownloadModelDlg(const QString& DownMdlName = "");
void SetControls(bool Enabled);
bool LoadRecommendedSettings(const QString& ModelFolder);
bool DidFirstShowStuff;
int32_t GetNeighbor(size_t InIdx);
void IterateQueue();
std::queue<SDOrder> TaskQueue; // STL queue for tasks
QTimer* ProcessTimer; // Timer to trigger processing of the next task
bool IsProcessing = false; // Flag to indicate if a task is currently being processed
uint32_t CurrentItemNumber = 0;
uint32_t CurrentImageNumber = 0;
bool LoadingFromModelsFolder;
size_t CurrentImgDisplayIndex = 0;
std::vector<TopBarImg*> TopBarImages;
QProgressBar* CurrentPgb = nullptr;
QProgressBar* CurrentGlobalPgb = nullptr;
void UpdateModelListing();
void UpdateSelectedTopBarImg(size_t NewSelected);
void ResetViewports();
void OnImg2ImgEnabled();
void OpenDirectory(const QString& dir);
private:
bool Exiting = false;
QTimer* progressPoller; // QTimer object
std::unique_ptr<Axodox::Threading::async_operation_source> CurrentAsyncSrc;
QString OutpsDir;
QSpacerItem* PreviewsSpacer = nullptr;
bool UseFirst = true;
StableDiffusionModel CurrentMdl;
Upscaler CurrentUpscaler;
Ui::MainWindow *ui;
Inferer* CurrentInferThrd = nullptr;
CanvasTabPtr canvasTab;
ImageSaverThread* imageSaver = nullptr;
void UpdateUpscalerListing();
QString saveImage(const QImage &image, const QString &directoryPath);
void SetupUI();
void SetupCanvas();
};
#endif // MAINWINDOW_H