Skip to content

Commit a4a86d2

Browse files
committed
UI and right click updated
1 parent b519b2a commit a4a86d2

File tree

4 files changed

+75
-88
lines changed

4 files changed

+75
-88
lines changed

src/CentralWidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ CentralWidget::CentralWidget(QWidget *parent) : QWidget(parent) {
5151
iverilogButton->setFixedHeight(36);
5252

5353
// --- Run VVP ---
54-
vvpButton = new QPushButton("run VVP", this);
54+
vvpButton = new QPushButton("Run VVP", this);
5555
vvpButton->setStyleSheet(MODERN_BUTTON_STYLE);
5656
vvpButton->setFixedHeight(36);
5757

@@ -79,8 +79,8 @@ CentralWidget::CentralWidget(QWidget *parent) : QWidget(parent) {
7979
buttonRowLayout->addWidget(iverilogButton);
8080
buttonRowLayout->addWidget(vvpButton);
8181
buttonRowLayout->addWidget(schematicButton);
82-
buttonRowLayout->addWidget(terminalButton);
8382
buttonRowLayout->addWidget(vcdButton);
83+
buttonRowLayout->addWidget(terminalButton);
8484

8585
mainLayout->addWidget(OstivalTextEdit);
8686
mainLayout->addLayout(buttonRowLayout);

src/LeftDockBuilder.cpp

Lines changed: 40 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Team Ostival (hello@ostival.org)
2020
#include <QFileSystemWatcher>
2121
#include <QMenu>
2222
#include <QAction>
23+
#include <QMessageBox>
2324
#include "LeftDockBuilder.h"
2425
#include "TempFiles.h"
2526
#include "config.h"
@@ -66,8 +67,6 @@ LeftDockBuilder::LeftDockBuilder(QMainWindow *mainWindow, QObject *parent)
6667
QListWidget *listWidget2 = new QListWidget; // Python Files
6768
listWidget2->setStyleSheet(MODERN_LIST_STYLE);
6869

69-
// QString jsonpath = projectPath + "/" + projectName + "/" + projectName + ".ostival";
70-
7170
// To load src_files from JSON into the list
7271
auto updateListFromJson = [listWidget, listWidget1, listWidget2]() {
7372
QFile f(projectFile);
@@ -150,48 +149,61 @@ LeftDockBuilder::LeftDockBuilder(QMainWindow *mainWindow, QObject *parent)
150149
if (!item) return;
151150

152151
QMenu menu;
153-
QAction *deleteAction = menu.addAction("Delete File");
154152
QAction *setMainFile = menu.addAction("Set Main File");
153+
QAction *deleteAction = menu.addAction("Delete File");
155154
QAction *selectedAction = menu.exec(listWidget->viewport()->mapToGlobal(pos));
156155

157156
if (selectedAction == deleteAction) {
157+
// Confirmation Dialog to delte the file
158158
QString fileName = item->text();
159-
QString filePath = projectPath + "/" + projectName + "/design_src/" + fileName;
160-
161-
QFile file(filePath);
162-
if (file.exists() && file.remove()) {
163-
qDebug() << "Deleted file:" << filePath;
164-
165-
QFile f(projectFile);
166-
if (f.open(QIODevice::ReadOnly)) {
167-
QJsonDocument doc = QJsonDocument::fromJson(f.readAll());
168-
f.close();
159+
QMessageBox msgBox;
160+
msgBox.setText("Confirm Deletion");
161+
msgBox.setInformativeText(QString("Are you sure you want to delete the file %1?").arg(fileName));
162+
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
163+
msgBox.setDefaultButton(QMessageBox::No);
164+
165+
// Show the dialog and check the user's response
166+
if (msgBox.exec() == QMessageBox::Yes) {
167+
QString filePath = projectPath + "/" + projectName + "/design_src/" + fileName;
168+
169+
QFile file(filePath);
170+
if (file.exists() && file.remove()) {
171+
qDebug() << "Deleted file:" << filePath;
172+
173+
QFile f(projectFile);
174+
if (f.open(QIODevice::ReadOnly)) {
175+
QJsonDocument doc = QJsonDocument::fromJson(f.readAll());
176+
f.close();
169177

170-
QJsonObject obj = doc.object();
171-
QJsonArray arr = obj["src_files"].toArray();
172-
QJsonArray newArr;
173-
for (auto v : arr) {
174-
if (v.toString() != fileName) newArr.append(v.toString());
178+
QJsonObject obj = doc.object();
179+
QJsonArray arr = obj["src_files"].toArray();
180+
QJsonArray newArr;
181+
for (auto v : arr) {
182+
if (v.toString() != fileName) newArr.append(v.toString());
183+
}
184+
obj["src_files"] = newArr;
185+
186+
if (f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
187+
f.write(QJsonDocument(obj).toJson(QJsonDocument::Indented));
188+
f.close();
189+
}
175190
}
176-
obj["src_files"] = newArr;
177191

178-
if (f.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
179-
f.write(QJsonDocument(obj).toJson(QJsonDocument::Indented));
180-
f.close();
181-
}
192+
// Remove from list
193+
delete listWidget->takeItem(listWidget->row(item));
194+
} else {
195+
qWarning() << "Failed to delete file:" << filePath;
182196
}
183-
184-
// Remove from list
185-
delete listWidget->takeItem(listWidget->row(item));
186197
} else {
187-
qWarning() << "Failed to delete file:" << filePath;
198+
// User clicked No or closed the dialog. Do nothing.
199+
qDebug() << "Deletion of file:" << fileName << "cancelled by user.";
188200
}
189201
} else if (selectedAction == setMainFile) {
190202
QString fileName = item->text();
191203
mainDesignFile = fileName;
192204
qDebug() << "item selected as main file" << fileName;
193205
} else {
194-
qWarning() << "Something is missing";
206+
qWarning() << "Something is missing or action was cancelled";
195207
}
196208
});
197209

src/RightDockBuilder.cpp

Lines changed: 23 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,8 @@ Team Ostival (hello@ostival.org)
1313
#include <QListWidget>
1414
#include <QVBoxLayout>
1515
#include "RightDockBuilder.h"
16+
#include "config.h"
1617

17-
const QString MODERN_BUTTON_STYLE = R"(
18-
QPushButton {
19-
background-color: #00A9A5;
20-
color: white;
21-
border: none;
22-
border-radius: 6px;
23-
padding: 8px 16px;
24-
font-size: 14px;
25-
}
26-
QPushButton:hover {
27-
background-color: #008F8B;
28-
}
29-
QPushButton:pressed {
30-
background-color: #006B68;
31-
}
32-
)";
3318

3419
RightDockBuilder::RightDockBuilder(QMainWindow *mainWindow, QObject *parent)
3520
: QObject(parent), OstivalmainWindow(mainWindow)
@@ -50,45 +35,40 @@ RightDockBuilder::RightDockBuilder(QMainWindow *mainWindow, QObject *parent)
5035

5136
QLabel *header = new QLabel("Current Project Status");
5237
header->setAlignment(Qt::AlignCenter);
53-
header->setFixedHeight(40);
54-
header->setStyleSheet(R"(
55-
QLabel {
56-
background-color: #f877ff;
57-
color: white;
58-
border-radius: 12px;
59-
font-size: 16px;
60-
font-weight: 600;
61-
padding-left: 10px;
62-
padding-right: 10px;
63-
}
64-
)");
38+
header->setFixedHeight(20);
39+
header->setStyleSheet(MODERN_TITLE_STYLE);
40+
41+
QLabel *header1 = new QLabel("Constraints Files");
42+
header1->setAlignment(Qt::AlignCenter);
43+
header1->setFixedHeight(20);
44+
header1->setStyleSheet(MODERN_TITLE_STYLE);
6545

6646
QListWidget *listWidget = new QListWidget;
47+
listWidget->setStyleSheet(MODERN_LIST_STYLE);
6748
listWidget->addItems({"Tool: ", "Status: ", "Technology: "});
6849

69-
QPushButton *refreshButton = new QPushButton("Refresh");
70-
refreshButton->setStyleSheet(MODERN_BUTTON_STYLE);
71-
72-
QPushButton *compileButton = new QPushButton("Compile");
73-
compileButton->setStyleSheet(MODERN_BUTTON_STYLE);
50+
QListWidget *listWidget1 = new QListWidget;
51+
listWidget1->setStyleSheet(MODERN_LIST_STYLE);
7452

75-
QPushButton *simulateButton = new QPushButton("Simulate");
76-
simulateButton->setStyleSheet(MODERN_BUTTON_STYLE);
53+
QPushButton *refreshButton = new QPushButton("Pre-Synthesis Check");
54+
refreshButton->setStyleSheet(MODERN_BUTTON_STYLE1);
7755

78-
QPushButton *synthesisButton = new QPushButton("Synthesis");
79-
synthesisButton->setStyleSheet(MODERN_BUTTON_STYLE);
56+
QPushButton *synthesisButton = new QPushButton("Run Synthesis");
57+
synthesisButton->setStyleSheet(MODERN_BUTTON_STYLE1);
8058

81-
QPushButton *implementationButton = new QPushButton("PnR");
82-
implementationButton->setStyleSheet(MODERN_BUTTON_STYLE);
59+
QPushButton *implementationButton = new QPushButton("Run PnR");
60+
implementationButton->setStyleSheet(MODERN_BUTTON_STYLE1);
8361

84-
QPushButton *layoutButton = new QPushButton("Generate Layout");
85-
layoutButton->setStyleSheet(MODERN_BUTTON_STYLE);
62+
QPushButton *layoutButton = new QPushButton("Generate Layout/Bitstream");
63+
layoutButton->setStyleSheet(MODERN_BUTTON_STYLE1);
8664

8765
layout->addWidget(header);
8866
layout->addWidget(listWidget);
67+
layout->addWidget(header1);
68+
layout->addWidget(listWidget1);
8969
layout->addWidget(refreshButton);
90-
layout->addWidget(compileButton);
91-
layout->addWidget(simulateButton);
70+
// layout->addWidget(compileButton);
71+
// layout->addWidget(simulateButton);
9272
layout->addWidget(synthesisButton);
9373
layout->addWidget(implementationButton);
9474
layout->addWidget(layoutButton);

src/config.h

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,43 +41,38 @@ User Interface constants
4141
*/
4242
const QString MODERN_TITLE_STYLE = R"(
4343
QLabel {
44-
background-color: #ff8808;
45-
color: white;
44+
background-color: #2caa8d;
45+
color: #e1e1e1;
4646
border-radius: 12px;
4747
font-size: 16px;
48-
font-weight: 600;
49-
padding-left: 10px;
50-
padding-right: 10px;
48+
font-weight: 400;
5149
}
5250
)";
5351
;
5452

5553
const QString MODERN_LIST_STYLE = R"(
5654
QListWidget {
57-
background-color: #f5f7fa;
58-
color: #5C4033; /* Brown text */
59-
border: 1px solid #d0d0d0;
55+
background-color: #effffc;
56+
color: #000000;
57+
border: 1px solid #610707;
6058
border-radius: 6px;
61-
padding: 4px;
59+
padding: 2px;
6260
font-size: 14px;
63-
outline: 0;
6461
}
6562

6663
QListWidget::item {
67-
padding: 8px 12px;
64+
padding: 4px 3px;
6865
border: none;
6966
margin: 2px 0;
70-
color: #5C4033;
7167
}
7268

7369
QListWidget::item:selected {
7470
background-color: #00A9A5;
75-
color: white;
7671
border-radius: 4px;
7772
}
7873

7974
QListWidget::item:hover {
80-
background-color: #e0f7f6;
75+
background-color: #3292ca;
8176
border-radius: 4px;
8277
})";
8378

@@ -100,7 +95,7 @@ const QString MODERN_LIST_STYLE = R"(
10095

10196
const QString MODERN_BUTTON_STYLE1 = R"(
10297
QPushButton {
103-
background-color: #A6E600;
98+
background-color: #00A9A5;
10499
color: white;
105100
border: none;
106101
border-radius: 6px;

0 commit comments

Comments
 (0)