33
44#include " processing.h"
55
6+ class MainWindow ;
7+
68DropArea::DropArea () {
79 QVBoxLayout* layout = new QVBoxLayout;
810 QLabel* label = new QLabel (" Drag & drop files here" );
@@ -41,51 +43,76 @@ MainWindow::MainWindow() {
4143
4244 layout->addWidget (dropArea); // Add the drop area to the layout
4345
44- // Create a new QPlainTextEdit
45- QPlainTextEdit* textOutput = new QPlainTextEdit;
46- textOutput->setReadOnly (true ); // Make it read-only so users can't edit the text
47- // set the size to fill width and 1/3 of the height
48- textOutput->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);
49- textOutput->setFixedHeight (50 );
50- textOutput->setStyleSheet (" border-radius: 3px; background-color: #E0E0E0; margin-bottom: 4px;" );
51- // add some text to the text output
52- textOutput->setPlainText (" Debug:\n " );
53-
54- layout->addWidget (textOutput); // Add the textOutput to the layout
55-
46+ // Progress bar
5647 progressBar = new QProgressBar;
5748 progressBar->setFixedHeight (20 );
5849 progressBar->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);
5950 progressBar->setRange (0 , 100 );
6051 // progressBar->setValue(75);
6152 progressBar->setTextVisible (false );
6253 progressBar->setStyleSheet (
63- " QProgressBar {border: 0px solid black; border-radius: 3px; background-color: white; color: black;}"
64- " QProgressBar::chunk {background-color: #05B8CC;}" );
65- layout->addWidget (progressBar); // Add the progress bar to the layout
54+ " QProgressBar {border: 0px solid black; border-radius: 3px; background-color: white; color: black; margin-bottom: 4px;}"
55+ " QProgressBar::chunk {background-color: #05B8CC;}" );
56+ layout->addWidget (progressBar);
57+
58+ // Create a new QPlainTextEdit
59+ QPlainTextEdit* textOutput = new QPlainTextEdit;
60+ textOutput->setReadOnly (true ); // Make it read-only so users can't edit the text
61+ // set the size to fill width and 1/3 of the height
62+ textOutput->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed);
63+ textOutput->setFixedHeight (52 );
64+ textOutput->setStyleSheet (" border-radius: 3px; background-color: #E0E0E0; padding-left: 4px; padding-right: 4px;" );
65+ // text size
66+ QFont font = this ->font ();
67+ font.setPointSize (8 );
68+ font.setStyleHint (QFont::Monospace);
69+ textOutput->setFont (font);
70+
71+ textOutput->setPlainText (" Waiting for user inputs..." );
72+ textOutput->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
73+ layout->addWidget (textOutput);
74+
75+ // widgets
6676
6777 QWidget* centralWidget = new QWidget;
6878 centralWidget->setLayout (layout); // Set the layout for the central widget
6979 setCentralWidget (centralWidget); // Set the central widget of the MainWindow
7080
7181 QMenuBar* menuBar = new QMenuBar;
7282 QMenu* f_menu = new QMenu (" Files" , menuBar);
73- QMenu* r_menu = new QMenu (" Reset" , menuBar);
74- QAction* f_Restart = new QAction (" Restart" , r_menu);
83+ QMenu* s_menu = new QMenu (" Settings" , menuBar);
84+ // QMenu* r_menu = new QMenu("Reset", menuBar);
85+ // QAction* f_Restart = new QAction("Restart", r_menu);
86+ QAction* s_Settings = new QAction (" Enable Console" , s_menu);
87+ s_Settings->setCheckable (true );
88+ s_Settings->setChecked (false );
89+ QAction* f_Restart = new QAction (" Restart" , f_menu);
7590 QAction* f_Exit = new QAction (" Exit" , f_menu);
76- r_menu->addAction (f_Restart);
91+ // r_menu->addAction(f_Restart);
92+ s_menu->addAction (s_Settings);
93+ f_menu->addAction (f_Restart);
94+ f_menu->addSeparator ();
7795 f_menu->addAction (f_Exit);
7896 menuBar->addMenu (f_menu);
79- menuBar->addMenu (r_menu );
97+ menuBar->addMenu (s_menu );
8098 setMenuBar (menuBar);
8199
82100 setWindowFlags (Qt::WindowStaysOnTopHint);
83- setWindowTitle (" Solidify 1.22 " );
84- setFixedSize (400 , 400 );
101+ setWindowTitle (" Solidify 1.30 " );
102+ setFixedSize (440 , 440 );
85103
104+ // Add a flag to indicate whether the console has been allocated
105+ bool consoleAllocated = false ;
106+
86107 // Connect the signal from the drop area to the slot in the main window
87108 connect (dropArea, &DropArea::filesDropped, this , &MainWindow::startProcessing);
88109
110+ // Connect the Settings action's triggered signal to a slot that toggles the console
111+ connect (s_Settings, &QAction::toggled, this , &MainWindow::toggleConsole);
112+
113+ // Add new connection for updating the textOutput
114+ connect (this , &MainWindow::updateTextSignal, textOutput, &QPlainTextEdit::setPlainText);
115+
89116 // Connect the Exit action's triggered signal to QApplication's quit slot
90117 connect (f_Exit, &QAction::triggered, qApp, &QApplication::quit);
91118
@@ -95,16 +122,39 @@ MainWindow::MainWindow() {
95122
96123void MainWindow::startProcessing (QList<QUrl> urls) {
97124 // Move the processing to a separate thread
98- QFuture<bool > future = QtConcurrent::run (doProcessing, urls, progressBar);
125+ QFuture<bool > future = QtConcurrent::run (doProcessing, urls, progressBar, this );
99126
100127 processingWatcher.setFuture (future);
101128
102129 connect (&processingWatcher, &QFutureWatcher<bool >::progressValueChanged, progressBar, &QProgressBar::setValue);
103130}
104131
132+ void MainWindow::toggleConsole (bool checked) {
133+ if (checked) {
134+ // Show console
135+ ShowWindow (GetConsoleWindow (), SW_SHOW);
136+ }
137+ else {
138+ // Hide console
139+ ShowWindow (GetConsoleWindow (), SW_HIDE);
140+ }
141+ }
142+
105143void MainWindow::restartApp () {
106144 QStringList arguments;
107145 QProcess::startDetached (QApplication::applicationFilePath (), arguments);
108146
109147 QApplication::quit ();
148+ }
149+
150+ void setPBarColor (QProgressBar* progressBar, const QColor& color) {
151+ QString style = QString (
152+ " QProgressBar {"
153+ " border: 0px solid black; border-radius: 3px; background-color: white; color: black;"
154+ " margin-bottom: 4px;"
155+ " }"
156+ " QProgressBar::chunk {background-color: %1;}"
157+ ).arg (color.name ());
158+
159+ progressBar->setStyleSheet (style);
110160}
0 commit comments