From ad0557059bb83da52e1a5bd7ea608a29a4ab6346 Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 27 Apr 2025 13:53:21 -0400 Subject: Use spinboxes to select cache levels --- gui/cachewaysselector.cc | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 gui/cachewaysselector.cc (limited to 'gui/cachewaysselector.cc') diff --git a/gui/cachewaysselector.cc b/gui/cachewaysselector.cc new file mode 100644 index 0000000..f0314e5 --- /dev/null +++ b/gui/cachewaysselector.cc @@ -0,0 +1,59 @@ +// Simulator for the RISC-V[ECTOR] mini-ISA +// Copyright (C) 2025 Siddarth Suresh +// Copyright (C) 2025 bdunahu + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "cachewaysselector.h" +#include +#include +#include +#include + +CacheWaysSelector::CacheWaysSelector(QWidget *parent) : QWidget(parent) +{ + QVBoxLayout *v; + QHBoxLayout *l; + QSpinBox *sb; + QLabel *b; + int i; + + v = new QVBoxLayout(this); + + for (i = 1; i <= 6; ++i) { + l = new QHBoxLayout(this); + + b = new QLabel(QString("L%1 2^").arg(i), this); + + sb = new QSpinBox; + sb->setRange(-1, 4); + sb->setValue(-1); + + l->addWidget(b); + l->addWidget(sb); + + v->addLayout(l); + this->sbs.append(sb); + } + v->addStretch(); +} + +QList CacheWaysSelector::values() const +{ + QList r; + for (const QSpinBox *sb : this->sbs) { + r.append(sb->value()); + } + return r; +} -- cgit v1.2.3 From 8954fab5b430623e2052753fae20707b878b858c Mon Sep 17 00:00:00 2001 From: bd Date: Sun, 27 Apr 2025 14:33:26 -0400 Subject: Fix styles --- gui/cachewaysselector.cc | 3 +-- gui/gui.ui | 7 ------- gui/resources/styles.qss | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 9 deletions(-) (limited to 'gui/cachewaysselector.cc') diff --git a/gui/cachewaysselector.cc b/gui/cachewaysselector.cc index f0314e5..14dae6f 100644 --- a/gui/cachewaysselector.cc +++ b/gui/cachewaysselector.cc @@ -32,7 +32,7 @@ CacheWaysSelector::CacheWaysSelector(QWidget *parent) : QWidget(parent) v = new QVBoxLayout(this); for (i = 1; i <= 6; ++i) { - l = new QHBoxLayout(this); + l = new QHBoxLayout; b = new QLabel(QString("L%1 2^").arg(i), this); @@ -46,7 +46,6 @@ CacheWaysSelector::CacheWaysSelector(QWidget *parent) : QWidget(parent) v->addLayout(l); this->sbs.append(sb); } - v->addStretch(); } QList CacheWaysSelector::values() const diff --git a/gui/gui.ui b/gui/gui.ui index c20b3f6..57a7974 100644 --- a/gui/gui.ui +++ b/gui/gui.ui @@ -375,13 +375,6 @@ - - - - QLayout::SizeConstraint::SetMinimumSize - - - diff --git a/gui/resources/styles.qss b/gui/resources/styles.qss index a61035e..758978c 100644 --- a/gui/resources/styles.qss +++ b/gui/resources/styles.qss @@ -4,6 +4,8 @@ color: "#00cc00"; background-color: "#000200"; border: 0px solid "#000200"; + selection-background-color: "#00cc00"; + selection-color: "#000200"; } QStatusBar { @@ -50,6 +52,52 @@ QGroupBox::title { QLabel { } +QSpinBox { + padding-right: 15px; /* make room for the arrows */ + border: none; +} + +QSpinBox::up-button { + color: "#000200"; + background-color: "#00cc00"; + subcontrol-origin: border; + subcontrol-position: top right; /* position at the top right corner */ + + width: 16px; + border: none; + subcontrol-origin: border; +} + +QSpinBox::up-arrow { + width: 7px; + height: 7px; +} + +QSpinBox::up-button:pressed { + color: "#00cc00"; + background-color: "#000200"; +} + +QSpinBox::down-button { + color: "#000200"; + background-color: "#00cc00"; + subcontrol-origin: border; + subcontrol-position: bottom right; /* position at bottom right corner */ + + width: 16px; + border: none; +} + +QSpinBox::down-arrow { + width: 7px; + height: 7px; +} + +QSpinBox::down-button:pressed { + color: "#00cc00"; + background-color: "#000200"; +} + QTableView { border: 0px; selection-background-color: transparent; -- cgit v1.2.3