aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui
diff options
context:
space:
mode:
authorFanda Vacek <vacek@elektroline.cz>2019-02-18 20:07:20 +0100
committerPavel Pisa <pisa@cmp.felk.cvut.cz>2019-02-19 11:26:28 +0100
commitb6355b1d65edfa51c9f80ac4c8c088bf9f19b788 (patch)
treebe83041544feb5811498cb8424413a8a48dd5697 /qtmips_gui
parent49c367d1d46cbe65de367ccb763f072399c6c05b (diff)
downloadqtmips-b6355b1d65edfa51c9f80ac4c8c088bf9f19b788.tar.gz
qtmips-b6355b1d65edfa51c9f80ac4c8c088bf9f19b788.tar.bz2
qtmips-b6355b1d65edfa51c9f80ac4c8c088bf9f19b788.zip
variable font size
Diffstat (limited to 'qtmips_gui')
-rw-r--r--qtmips_gui/cacheview.cpp3
-rw-r--r--qtmips_gui/coreview.cpp3
-rw-r--r--qtmips_gui/coreview/adder.cpp3
-rw-r--r--qtmips_gui/coreview/alu.cpp3
-rw-r--r--qtmips_gui/coreview/constant.cpp3
-rw-r--r--qtmips_gui/coreview/instructionview.cpp4
-rw-r--r--qtmips_gui/coreview/logicblock.cpp3
-rw-r--r--qtmips_gui/coreview/memory.cpp3
-rw-r--r--qtmips_gui/coreview/programcounter.cpp5
-rw-r--r--qtmips_gui/coreview/registers.cpp3
-rw-r--r--qtmips_gui/coreview/value.cpp3
-rw-r--r--qtmips_gui/fontsize.cpp23
-rw-r--r--qtmips_gui/fontsize.h14
-rw-r--r--qtmips_gui/mainwindow.cpp1
-rw-r--r--qtmips_gui/qtmips_gui.pro6
15 files changed, 66 insertions, 14 deletions
diff --git a/qtmips_gui/cacheview.cpp b/qtmips_gui/cacheview.cpp
index d279083..9373cff 100644
--- a/qtmips_gui/cacheview.cpp
+++ b/qtmips_gui/cacheview.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "cacheview.h"
+#include "fontsize.h"
#include <cmath>
//////////////////////
@@ -145,7 +146,7 @@ CacheViewBlock::CacheViewBlock(const machine::Cache *cache, unsigned block , boo
curr_row = 0;
QFont font;
- font.setPointSize(7);
+ font.setPointSize(FontSize::SIZE7);
validity = new QGraphicsSimpleTextItem*[rows];
if (cache->config().write_policy() == machine::MachineConfigCache::WP_BACK)
diff --git a/qtmips_gui/coreview.cpp b/qtmips_gui/coreview.cpp
index 2e8ec5c..121b622 100644
--- a/qtmips_gui/coreview.cpp
+++ b/qtmips_gui/coreview.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "coreview.h"
+#include "fontsize.h"
#include <cmath>
//////////////////////////////////////////////////////////////////////////////
@@ -243,7 +244,7 @@ coreview::Signal *CoreViewScene::new_signal(const coreview::Connector *a, const
QGraphicsSimpleTextItem *CoreViewScene::new_label(const QString &str, qreal x, qreal y) {
QGraphicsSimpleTextItem *i= new QGraphicsSimpleTextItem(str);
QFont f;
- f.setPointSize(5);
+ f.setPointSize(FontSize::SIZE5);
i->setFont(f);
addItem(i);
i->setPos(x, y);
diff --git a/qtmips_gui/coreview/adder.cpp b/qtmips_gui/coreview/adder.cpp
index 0da3814..d24b603 100644
--- a/qtmips_gui/coreview/adder.cpp
+++ b/qtmips_gui/coreview/adder.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "adder.h"
+#include "fontsize.h"
#include <cmath>
using namespace coreview;
@@ -47,7 +48,7 @@ using namespace coreview;
Adder::Adder() : QGraphicsItem(nullptr), plus("+", this) {
QFont font;
- font.setPointSize(7);
+ font.setPointSize(FontSize::SIZE7);
plus.setFont(font);
QRectF plus_box = plus.boundingRect();
plus.setPos(DENT + (WIDTH-DENT)/2 - plus_box.width()/2, HEIGHT/2 - plus_box.height()/2);
diff --git a/qtmips_gui/coreview/alu.cpp b/qtmips_gui/coreview/alu.cpp
index 5327f4e..31f1529 100644
--- a/qtmips_gui/coreview/alu.cpp
+++ b/qtmips_gui/coreview/alu.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "alu.h"
+#include "fontsize.h"
#include <cmath>
//////////////////////
@@ -46,7 +47,7 @@
coreview::Alu::Alu() : QGraphicsItem(nullptr), name("ALU", this) {
name.setPos(3, 25);
QFont font;
- font.setPointSize(7);
+ font.setPointSize(FontSize::SIZE7);
name.setFont(font);
con_in_a = new Connector(Connector::AX_X);
diff --git a/qtmips_gui/coreview/constant.cpp b/qtmips_gui/coreview/constant.cpp
index 15ebbc7..a4286e6 100644
--- a/qtmips_gui/coreview/constant.cpp
+++ b/qtmips_gui/coreview/constant.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "constant.h"
+#include "fontsize.h"
#include <cmath>
using namespace coreview;
@@ -44,7 +45,7 @@ using namespace coreview;
Constant::Constant(const Connector *con, const QString &text) : QGraphicsObject(nullptr), text(text, this) {
QFont font;
- font.setPointSize(7);
+ font.setPointSize(FontSize::SIZE7);
this->text.setFont(font);
con_our = new Connector(Connector::AX_X);
diff --git a/qtmips_gui/coreview/instructionview.cpp b/qtmips_gui/coreview/instructionview.cpp
index 495edfb..9794ae5 100644
--- a/qtmips_gui/coreview/instructionview.cpp
+++ b/qtmips_gui/coreview/instructionview.cpp
@@ -34,6 +34,8 @@
******************************************************************************/
#include "instructionview.h"
+#include "../fontsize.h"
+
#include <QPainter>
#include <QFont>
@@ -49,7 +51,7 @@ using namespace coreview;
InstructionView::InstructionView() : QGraphicsObject(nullptr), text(this) {
QFont f;
- f.setPointSize(6);
+ f.setPointSize(FontSize::SIZE6);
text.setFont(f);
// Initialize to NOP
diff --git a/qtmips_gui/coreview/logicblock.cpp b/qtmips_gui/coreview/logicblock.cpp
index e2c5e24..dfc77b1 100644
--- a/qtmips_gui/coreview/logicblock.cpp
+++ b/qtmips_gui/coreview/logicblock.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "logicblock.h"
+#include "fontsize.h"
#include <cmath>
using namespace coreview;
@@ -49,7 +50,7 @@ LogicBlock::LogicBlock(QString name) : LogicBlock(QVector<QString>({name})) { }
LogicBlock::LogicBlock(QVector<QString> name) : QGraphicsObject(nullptr) {
QFont font;
- font.setPointSize(7);
+ font.setPointSize(FontSize::SIZE7);
qreal h = 0, w = 0;
for (int i = 0; i < name.size(); i++) {
diff --git a/qtmips_gui/coreview/memory.cpp b/qtmips_gui/coreview/memory.cpp
index 7d30da8..b690db4 100644
--- a/qtmips_gui/coreview/memory.cpp
+++ b/qtmips_gui/coreview/memory.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "memory.h"
+#include "fontsize.h"
#include <cmath>
using namespace coreview;
@@ -49,7 +50,7 @@ Memory::Memory(bool cache_used, const machine::Cache *cch) : QGraphicsObject(nul
cache = cache_used;
QFont font;
- font.setPointSize(7);
+ font.setPointSize(FontSize::SIZE7);
name.setFont(font);
type.setFont(font);
cache_t.setFont(font);
diff --git a/qtmips_gui/coreview/programcounter.cpp b/qtmips_gui/coreview/programcounter.cpp
index 262d122..3a8c068 100644
--- a/qtmips_gui/coreview/programcounter.cpp
+++ b/qtmips_gui/coreview/programcounter.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "programcounter.h"
+#include "fontsize.h"
#include <cmath>
using namespace coreview;
@@ -49,10 +50,10 @@ ProgramCounter::ProgramCounter(machine::QtMipsMachine *machine) : QGraphicsObjec
QFont font;
- font.setPointSize(7);
+ font.setPointSize(FontSize::SIZE7);
name.setPos(WIDTH/2 - name.boundingRect().width()/2, 0);
name.setFont(font);
- font.setPointSize(8);
+ font.setPointSize(FontSize::SIZE8);
value.setText(QString("0x") + QString::number(machine->registers()->read_pc(), 16));
value.setPos(1, HEIGHT - value.boundingRect().height());
value.setFont(font);
diff --git a/qtmips_gui/coreview/registers.cpp b/qtmips_gui/coreview/registers.cpp
index d58109f..8ccff27 100644
--- a/qtmips_gui/coreview/registers.cpp
+++ b/qtmips_gui/coreview/registers.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "registers.h"
+#include "fontsize.h"
#include <cmath>
using namespace coreview;
@@ -56,7 +57,7 @@ Registers::Registers() : QGraphicsObject(nullptr), name("Registers", this) {
// TODO do we want to have any hooks on real registers?
QFont font;
- font.setPointSize(7);
+ font.setPointSize(FontSize::SIZE7);
name.setFont(font);
QRectF name_box = name.boundingRect();
diff --git a/qtmips_gui/coreview/value.cpp b/qtmips_gui/coreview/value.cpp
index 9a3ab09..2be8bb6 100644
--- a/qtmips_gui/coreview/value.cpp
+++ b/qtmips_gui/coreview/value.cpp
@@ -34,6 +34,7 @@
******************************************************************************/
#include "value.h"
+#include "../fontsize.h"
using namespace coreview;
@@ -58,7 +59,7 @@ QRectF Value::boundingRect() const {
void Value::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))){
QFont f;
- f.setPointSize(7);
+ f.setPointSize(FontSize::SIZE7);
painter->setFont(f);
QRectF rect;
diff --git a/qtmips_gui/fontsize.cpp b/qtmips_gui/fontsize.cpp
new file mode 100644
index 0000000..8923d08
--- /dev/null
+++ b/qtmips_gui/fontsize.cpp
@@ -0,0 +1,23 @@
+#include "fontsize.h"
+
+#include <QFont>
+#include <QDebug>
+#include <QApplication>
+#include <QFontMetrics>
+
+int FontSize::SIZE5 = 5;
+int FontSize::SIZE6 = 6;
+int FontSize::SIZE7 = 7;
+int FontSize::SIZE8 = 8;
+
+void FontSize::init()
+{
+ int h = QFontMetrics(QApplication::font()).height();
+ qDebug() << "Font size:" << h;
+ h /= 5;
+ int d = h / 10 + 1;
+ FontSize::SIZE5 = h - 2*d;
+ FontSize::SIZE6 = h - d;
+ FontSize::SIZE7 = h;
+ FontSize::SIZE8 = h + d;
+}
diff --git a/qtmips_gui/fontsize.h b/qtmips_gui/fontsize.h
new file mode 100644
index 0000000..d5a20e3
--- /dev/null
+++ b/qtmips_gui/fontsize.h
@@ -0,0 +1,14 @@
+#ifndef FONTSIZES_H
+#define FONTSIZES_H
+
+struct FontSize
+{
+ static int SIZE5;
+ static int SIZE6;
+ static int SIZE7;
+ static int SIZE8;
+
+ static void init();
+};
+
+#endif // FONTSIZES_H
diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp
index 5174949..bbb3a3b 100644
--- a/qtmips_gui/mainwindow.cpp
+++ b/qtmips_gui/mainwindow.cpp
@@ -36,6 +36,7 @@
#include "mainwindow.h"
#include "aboutdialog.h"
#include "ossyscall.h"
+#include "fontsize.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
machine = nullptr;
diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro
index e9c0caf..4f4b863 100644
--- a/qtmips_gui/qtmips_gui.pro
+++ b/qtmips_gui/qtmips_gui.pro
@@ -56,7 +56,8 @@ SOURCES += \
peripheralsdock.cpp \
terminaldock.cpp \
peripheralsview.cpp \
- coreview/multitext.cpp
+ coreview/multitext.cpp \
+ fontsize.cpp
HEADERS += \
mainwindow.h \
@@ -92,7 +93,8 @@ HEADERS += \
peripheralsdock.h \
terminaldock.h \
peripheralsview.h \
- coreview/multitext.h
+ coreview/multitext.h \
+ fontsize.h
FORMS += \
NewDialog.ui \