aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Pisa <pisa@cmp.felk.cvut.cz>2019-10-10 07:39:50 +0200
committerGitHub <noreply@github.com>2019-10-10 07:39:50 +0200
commit9aa03382ea46f87f336dd8f55bcd17423d1632b5 (patch)
treec1665ae87bc5a1208aa353ad9df2a44185b8e84c
parent7ec180881848027fbad6c7dd84b883c26643103f (diff)
parent2bfe22d935cb7d7c4f6c75f79ecfb568e75dc5d0 (diff)
downloadqtmips-9aa03382ea46f87f336dd8f55bcd17423d1632b5.tar.gz
qtmips-9aa03382ea46f87f336dd8f55bcd17423d1632b5.tar.bz2
qtmips-9aa03382ea46f87f336dd8f55bcd17423d1632b5.zip
Merge pull request #3 from MadCatX/dark_themes_compat
Improve UI compatbility with dark color schemes
-rw-r--r--qtmips_gui/coreview.cpp2
-rw-r--r--qtmips_gui/coreview/adder.cpp6
-rw-r--r--qtmips_gui/coreview/alu.cpp6
-rw-r--r--qtmips_gui/coreview/and.cpp5
-rw-r--r--qtmips_gui/coreview/coreview_colors.h43
-rw-r--r--qtmips_gui/coreview/latch.cpp5
-rw-r--r--qtmips_gui/coreview/logicblock.cpp5
-rw-r--r--qtmips_gui/coreview/memory.cpp5
-rw-r--r--qtmips_gui/coreview/programcounter.cpp5
-rw-r--r--qtmips_gui/coreview/registers.cpp5
-rw-r--r--qtmips_gui/coreview/value.cpp3
-rw-r--r--qtmips_gui/registersdock.cpp16
-rw-r--r--qtmips_gui/srceditor.cpp9
13 files changed, 110 insertions, 5 deletions
diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp
index b45f7ca..a130f0d 100644
--- a/qtmips_gui/coreview.cpp
+++ b/qtmips_gui/coreview.cpp
@@ -234,6 +234,8 @@ CoreViewScene::CoreViewScene(machine::QtMipsMachine *machine) : QGraphicsScene()
new_label("Stalls", 570, SC_HEIGHT - 14);
NEW_V(630, SC_HEIGHT - 9, stall_c_value, false, 10, 0, 10, ' ', false);
+ setBackgroundBrush(QBrush(Qt::white));
+
connect(regs, SIGNAL(open_registers()), this, SIGNAL(request_registers()));
connect(mem_program, SIGNAL(open_mem()), this, SIGNAL(request_program_memory()));
connect(mem_data, SIGNAL(open_mem()), this, SIGNAL(request_data_memory()));
diff --git a/qtmips_gui/coreview/adder.cpp b/qtmips_gui/coreview/adder.cpp
index 49d67d4..0fe812f 100644
--- a/qtmips_gui/coreview/adder.cpp
+++ b/qtmips_gui/coreview/adder.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "adder.h"
+#include "coreview_colors.h"
#include "fontsize.h"
#include <cmath>
@@ -80,6 +81,11 @@ void Adder::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __at
QPointF(DENT, HEIGHT / 2),
QPointF(0, (HEIGHT / 2) - DENT)
};
+
+ QPen pen = painter->pen();
+ pen.setColor(BLOCK_OUTLINE_COLOR);
+ painter->setPen(pen);
+
painter->drawPolygon(poly, sizeof(poly) / sizeof(QPointF));
}
diff --git a/qtmips_gui/coreview/alu.cpp b/qtmips_gui/coreview/alu.cpp
index 5494b3f..33b1fa8 100644
--- a/qtmips_gui/coreview/alu.cpp
+++ b/qtmips_gui/coreview/alu.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "alu.h"
+#include "coreview_colors.h"
#include "fontsize.h"
#include <cmath>
@@ -79,6 +80,11 @@ void coreview::Alu::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
QPointF(DENT, HEIGHT / 2),
QPointF(0, (HEIGHT / 2) - DENT)
};
+
+ QPen pen = painter->pen();
+ pen.setColor(BLOCK_OUTLINE_COLOR);
+ painter->setPen(pen);
+
painter->drawPolygon(poly, sizeof(poly) / sizeof(QPointF));
}
diff --git a/qtmips_gui/coreview/and.cpp b/qtmips_gui/coreview/and.cpp
index 94128fb..6ac7a62 100644
--- a/qtmips_gui/coreview/and.cpp
+++ b/qtmips_gui/coreview/and.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "and.h"
+#include "coreview_colors.h"
#include <cmath>
using namespace coreview;
@@ -63,6 +64,10 @@ QRectF And::boundingRect() const {
}
void And::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))) {
+ QPen pen = painter->pen();
+ pen.setColor(BLOCK_OUTLINE_COLOR);
+ painter->setPen(pen);
+
qreal size = GAP * connectors.size();
painter->drawLine(0, 0, 0, size);
painter->drawLine(0, 0, size/2, 0);
diff --git a/qtmips_gui/coreview/coreview_colors.h b/qtmips_gui/coreview/coreview_colors.h
new file mode 100644
index 0000000..da8d2ae
--- /dev/null
+++ b/qtmips_gui/coreview/coreview_colors.h
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*******************************************************************************
+ * QtMips - MIPS 32-bit Architecture Subset Simulator
+ *
+ * Implemented to support following courses:
+ *
+ * B35APO - Computer Architectures
+ * https://cw.fel.cvut.cz/wiki/courses/b35apo
+ *
+ * B4M35PAP - Advanced Computer Architectures
+ * https://cw.fel.cvut.cz/wiki/courses/b4m35pap/start
+ *
+ * Copyright (c) 2017-2019 Karel Koci<cynerd@email.cz>
+ * Copyright (c) 2019 Pavel Pisa <pisa@cmp.felk.cvut.cz>
+ *
+ * Faculty of Electrical Engineering (http://www.fel.cvut.cz)
+ * Czech Technical University (http://www.cvut.cz/)
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ ******************************************************************************/
+
+#ifndef COREVIEW_COLORS_H
+#define COREVIEW_COLORS_H
+
+#include <QColor>
+
+static const QColor BLOCK_OUTLINE_COLOR(85, 85, 85);
+
+#endif // COREVIEW_COLORS_H
diff --git a/qtmips_gui/coreview/latch.cpp b/qtmips_gui/coreview/latch.cpp
index e458f9b..fbfa6f0 100644
--- a/qtmips_gui/coreview/latch.cpp
+++ b/qtmips_gui/coreview/latch.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "latch.h"
+#include "coreview_colors.h"
#include <cmath>
using namespace coreview;
@@ -76,6 +77,10 @@ QRectF Latch::boundingRect() const {
}
void Latch::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))) {
+ QPen pen = painter->pen();
+ pen.setColor(BLOCK_OUTLINE_COLOR);
+ painter->setPen(pen);
+
painter->drawRect(0, 0, WIDTH, height);
// Now tick rectangle
const QPointF tickPolygon[] = {
diff --git a/qtmips_gui/coreview/logicblock.cpp b/qtmips_gui/coreview/logicblock.cpp
index b1ab37c..dd77ee2 100644
--- a/qtmips_gui/coreview/logicblock.cpp
+++ b/qtmips_gui/coreview/logicblock.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "logicblock.h"
+#include "coreview_colors.h"
#include "fontsize.h"
#include <cmath>
@@ -79,6 +80,10 @@ QRectF LogicBlock::boundingRect() const {
}
void LogicBlock::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))) {
+ QPen pen = painter->pen();
+ pen.setColor(BLOCK_OUTLINE_COLOR);
+ painter->setPen(pen);
+
painter->drawRoundedRect(box, RADIUS, RADIUS);
}
diff --git a/qtmips_gui/coreview/memory.cpp b/qtmips_gui/coreview/memory.cpp
index 286e6da..b2b1ffe 100644
--- a/qtmips_gui/coreview/memory.cpp
+++ b/qtmips_gui/coreview/memory.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "memory.h"
+#include "coreview_colors.h"
#include "fontsize.h"
#include <cmath>
@@ -81,6 +82,10 @@ QRectF Memory::boundingRect() const {
}
void Memory::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))) {
+ QPen pen = painter->pen();
+ pen.setColor(BLOCK_OUTLINE_COLOR);
+ painter->setPen(pen);
+
painter->drawRect(0, 0, WIDTH, HEIGHT);
if (cache)
painter->drawLine(0, CACHE_HEIGHT, WIDTH, CACHE_HEIGHT);
diff --git a/qtmips_gui/coreview/programcounter.cpp b/qtmips_gui/coreview/programcounter.cpp
index 2fb6980..ba8e1c6 100644
--- a/qtmips_gui/coreview/programcounter.cpp
+++ b/qtmips_gui/coreview/programcounter.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "programcounter.h"
+#include "coreview_colors.h"
#include "fontsize.h"
#include <cmath>
@@ -75,6 +76,10 @@ QRectF ProgramCounter::boundingRect() const {
}
void ProgramCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))) {
+ QPen pen = painter->pen();
+ pen.setColor(BLOCK_OUTLINE_COLOR);
+ painter->setPen(pen);
+
painter->drawRect(0, 0, WIDTH, HEIGHT);
}
diff --git a/qtmips_gui/coreview/registers.cpp b/qtmips_gui/coreview/registers.cpp
index ed3b508..982ba07 100644
--- a/qtmips_gui/coreview/registers.cpp
+++ b/qtmips_gui/coreview/registers.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "registers.h"
+#include "coreview_colors.h"
#include "fontsize.h"
#include <cmath>
@@ -81,6 +82,10 @@ QRectF Registers::boundingRect() const {
}
void Registers::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute((unused)), QWidget *widget __attribute((unused))) {
+ QPen pen = painter->pen();
+ pen.setColor(BLOCK_OUTLINE_COLOR);
+ painter->setPen(pen);
+
painter->drawRect(0, 0, WIDTH, HEIGHT);
}
diff --git a/qtmips_gui/coreview/value.cpp b/qtmips_gui/coreview/value.cpp
index 7dd1e6a..c7f87f7 100644
--- a/qtmips_gui/coreview/value.cpp
+++ b/qtmips_gui/coreview/value.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "value.h"
+#include "coreview_colors.h"
#include "../fontsize.h"
using namespace coreview;
@@ -73,6 +74,8 @@ void Value::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __at
painter->setBackgroundMode(Qt::OpaqueMode);
if (!frame)
painter->setPen(QColor(Qt::white));
+ else
+ painter->setPen(QColor(BLOCK_OUTLINE_COLOR));
painter->drawRect(rect);
painter->setPen(QColor(Qt::black));
painter->setBackgroundMode(Qt::TransparentMode);
diff --git a/qtmips_gui/registersdock.cpp b/qtmips_gui/registersdock.cpp
index b72696d..fa89c94 100644
--- a/qtmips_gui/registersdock.cpp
+++ b/qtmips_gui/registersdock.cpp
@@ -71,6 +71,8 @@ static const QString labels[] = {
};
RegistersDock::RegistersDock(QWidget *parent) : QDockWidget(parent) {
+ static const QColor defaultTextColor(0, 0, 0);
+
scrollarea = new QScrollArea(this);
scrollarea->setWidgetResizable(true);
widg = new StaticTable(scrollarea);
@@ -78,12 +80,18 @@ RegistersDock::RegistersDock(QWidget *parent) : QDockWidget(parent) {
hi_highlighted = false;
lo_highlighted = false;
+ pal_normal = palette();
+ pal_normal.setColor(QPalette::WindowText, defaultTextColor);
+
#define INIT(X, LABEL) do{ \
X = new QLabel("0x00000000", widg); \
X->setFixedSize(X->sizeHint()); \
X->setText(""); \
+ X->setPalette(pal_normal); \
X->setTextInteractionFlags(Qt::TextSelectableByMouse); \
- widg->addRow({new QLabel(LABEL, widg), X}); \
+ QLabel *l = new QLabel(LABEL, widg); \
+ l->setPalette(pal_normal); \
+ widg->addRow({l, X}); \
} while(false)
for (int i = 0; i < 32; i++)
@@ -98,10 +106,8 @@ RegistersDock::RegistersDock(QWidget *parent) : QDockWidget(parent) {
setObjectName("Registers");
setWindowTitle("Registers");
- pal_normal = QPalette(gp[0]->palette());
- pal_updated = QPalette(gp[0]->palette());
- pal_read = QPalette(gp[0]->palette());
- pal_normal.setColor(QPalette::WindowText, QColor(0, 0, 0));
+ pal_updated = pal_normal;
+ pal_read = pal_normal;
pal_updated.setColor(QPalette::WindowText, QColor(240, 0, 0));
pal_read.setColor(QPalette::WindowText, QColor(0, 0, 240));
}
diff --git a/qtmips_gui/srceditor.cpp b/qtmips_gui/srceditor.cpp
index 2d4a5ec..43e9075 100644
--- a/qtmips_gui/srceditor.cpp
+++ b/qtmips_gui/srceditor.cpp
@@ -35,6 +35,7 @@
#include <QFile>
#include <QFileInfo>
+#include <QPalette>
#include <QTextDocumentWriter>
#include <QTextCursor>
#include <QTextBlock>
@@ -52,6 +53,14 @@ void SrcEditor::setup_common() {
setFont(font);
tname = "Unknown";
highlighter = new HighlighterAsm(document());
+
+ QPalette p = palette();
+ p.setColor(QPalette::Active, QPalette::Base, Qt::white);
+ p.setColor(QPalette::Inactive, QPalette::Base, Qt::white);
+ p.setColor(QPalette::Disabled, QPalette::Base, Qt::white);
+ setPalette(p);
+
+ setTextColor(Qt::black);
}
SrcEditor::SrcEditor(QWidget *parent) : Super(parent) {