1- /*
2- * Solidify (Push Pull) algorithm implementation using OpenImageIO
3- * Copyright (c) 2022 Erium Vladlen.
4- *
5- * This program is free software: you can redistribute it and/or modify
6- * it under the terms of the GNU General Public License as published by
7- * the Free Software Foundation, version 3.
8- *
9- * This program is distributed in the hope that it will be useful, but
10- * WITHOUT ANY WARRANTY; without even the implied warranty of
11- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12- * General Public License for more details.
13- *
14- * You should have received a copy of the GNU General Public License
15- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16- */
1+ #include " ui.h"
172
183#include < QtWidgets/QMainWindow>
194#include < QtWidgets/QMenuBar>
3116
3217#include " processing.h"
3318
34- class DropArea : public QLabel {
35- public:
36- DropArea () {
37- setAcceptDrops (true );
38- resize (400 , 400 );
39- setMinimumSize (400 , 400 );
40- setMaximumSize (400 , 400 );
41- setWindowFlags (Qt::WindowStaysOnTopHint);
42- setWindowTitle (" Solidify 1.22" );
43- setText (" Drag & drop files here" ); // Set text
44- setAlignment (Qt::AlignCenter); // Set alignment to center
45-
46- QFont font = this ->font ();
47- font.setPointSize (16 );
48- setFont (font);
49- }
19+ DropArea::DropArea () {
20+ setAcceptDrops (true );
21+ setText (" Drag & drop files here" ); // Set text
22+ setAlignment (Qt::AlignCenter); // Set alignment to center
23+
24+ QFont font = this ->font ();
25+ font.setPointSize (16 );
26+ setFont (font);
27+ }
5028
51- protected:
52- void dragEnterEvent (QDragEnterEvent* event) override {
53- event->acceptProposedAction ();
29+ void DropArea::dragEnterEvent (QDragEnterEvent* event) {
30+ event->acceptProposedAction ();
31+ }
32+
33+ void DropArea::dropEvent (QDropEvent* event) {
34+ QList<QUrl> urls = event->mimeData ()->urls ();
35+ if (urls.isEmpty ()) {
36+ return ;
5437 }
5538
56- void dropEvent (QDropEvent* event) override {
57- QList<QUrl> urls = event->mimeData ()->urls ();
58- if (urls.isEmpty ()) {
59- return ;
60- }
39+ // QString fileName = urls.first().toLocalFile();
40+ // if (fileName.isEmpty()) {
41+ // return;
42+ // }
6143
62- // QString fileName = urls.first().toLocalFile();
63- // if (fileName.isEmpty()) {
64- // return;
65- // }
44+ // Processing
6645
67- // Processing
46+ bool success = doProcessing (urls);
6847
69- bool success = doProcessing (urls) ;
48+ qDebug () << " Done! " ;
7049
71- qDebug () << " Done!" ;
50+ return ;
51+ }
7252
73- return ;
74- }
75- };
76-
77- class MainWindow : public QMainWindow {
78- public:
79- MainWindow () {
80- DropArea* dropArea = new DropArea;
81- setCentralWidget (dropArea);
82-
83- QMenuBar* menuBar = new QMenuBar;
84- QMenu* f_menu = new QMenu (" Files" , menuBar);
85- QMenu* r_menu = new QMenu (" Reset" , menuBar);
86- QAction* f_Restart = new QAction (" Restart" , r_menu);
87- QAction* f_Exit = new QAction (" Exit" , f_menu);
88- r_menu->addAction (f_Restart);
89- f_menu->addAction (f_Exit);
90- menuBar->addMenu (f_menu);
91- menuBar->addMenu (r_menu);
92- setMenuBar (menuBar);
93-
94- // Connect the Exit action's triggered signal to QApplication's quit slot
95- connect (f_Exit, &QAction::triggered, qApp, &QApplication::quit);
96-
97- // Connect the Restart action's triggered signal to a slot that restarts the app
98- connect (f_Restart, &QAction::triggered, this , &MainWindow::restartApp);
99- }
53+ MainWindow::MainWindow () {
54+ DropArea* dropArea = new DropArea;
55+ dropArea->setFixedSize (400 , 400 ); // Set the size of the drop area
56+ setCentralWidget (dropArea);
10057
101- private slots:
102- void restartApp () {
103- QStringList arguments;
104- QProcess::startDetached (QApplication::applicationFilePath (), arguments);
58+ setWindowFlags (Qt::WindowStaysOnTopHint);
59+ setWindowTitle (" Solidify 1.22" );
10560
106- QApplication::quit ();
107- }
108- };
61+ QMenuBar* menuBar = new QMenuBar;
62+ QMenu* f_menu = new QMenu (" Files" , menuBar);
63+ QMenu* r_menu = new QMenu (" Reset" , menuBar);
64+ QAction* f_Restart = new QAction (" Restart" , r_menu);
65+ QAction* f_Exit = new QAction (" Exit" , f_menu);
66+ r_menu->addAction (f_Restart);
67+ f_menu->addAction (f_Exit);
68+ menuBar->addMenu (f_menu);
69+ menuBar->addMenu (r_menu);
70+ setMenuBar (menuBar);
10971
110- int main ( int argc, char * argv[]) {
111- QApplication app (argc, argv );
72+ // Connect the Exit action's triggered signal to QApplication's quit slot
73+ connect (f_Exit, &QAction::triggered, qApp, &QApplication::quit );
11274
113- MainWindow window;
114- window.show ();
75+ // Connect the Restart action's triggered signal to a slot that restarts the app
76+ connect (f_Restart, &QAction::triggered, this , &MainWindow::restartApp);
77+ }
11578
116- // DropArea dropArea;
117- // dropArea.show();
79+ void MainWindow::restartApp () {
80+ QStringList arguments;
81+ QProcess::startDetached (QApplication::applicationFilePath (), arguments);
11882
119- return app. exec ();
83+ QApplication::quit ();
12084}
0 commit comments