From 9f1ddc2b38469d5028aec5ba7b68131d711f2622 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Wed, 13 Feb 2019 13:18:17 +0100 Subject: Add simple about dialog and prepare menu entries for serial port and peripherals. Signed-off-by: Pavel Pisa --- qtmips_gui/MainWindow.ui | 31 +++++++++++ qtmips_gui/aboutdialog.cpp | 133 +++++++++++++++++++++++++++++++++++++++++++++ qtmips_gui/aboutdialog.h | 61 +++++++++++++++++++++ qtmips_gui/mainwindow.cpp | 14 +++++ qtmips_gui/mainwindow.h | 3 + qtmips_gui/qtmips_gui.pro | 6 +- 6 files changed, 246 insertions(+), 2 deletions(-) create mode 100644 qtmips_gui/aboutdialog.cpp create mode 100644 qtmips_gui/aboutdialog.h diff --git a/qtmips_gui/MainWindow.ui b/qtmips_gui/MainWindow.ui index bdaba23..6954603 100644 --- a/qtmips_gui/MainWindow.ui +++ b/qtmips_gui/MainWindow.ui @@ -68,6 +68,8 @@ + + @@ -82,12 +84,21 @@ + + + + Help + + + + + @@ -327,6 +338,11 @@ Ctrl+2 + + + &About Qt Mips + + true @@ -341,6 +357,21 @@ Ctrl+M + + + About Qt + + + + + Peripherals + + + + + Terminal + + diff --git a/qtmips_gui/aboutdialog.cpp b/qtmips_gui/aboutdialog.cpp new file mode 100644 index 0000000..83ab1b7 --- /dev/null +++ b/qtmips_gui/aboutdialog.cpp @@ -0,0 +1,133 @@ +// 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 + * Copyright (c) 2019 Pavel Pisa + * + * 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. + * + ******************************************************************************/ + +#include "aboutdialog.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +AboutDialog::AboutDialog(QWidget *parent) + : QDialog(parent) +{ + QLabel *lbl; + + setWindowTitle(tr("About Qt Mips")); + + all = new QVBoxLayout(this); + + QWidget *hbox = new QWidget(); + QHBoxLayout *hl = new QHBoxLayout(hbox); + hl->setContentsMargins(0,0,0,0); + + all->addWidget(hbox); + + QWidget *vbox = new QWidget(); + QVBoxLayout *vl = new QVBoxLayout(vbox); + //vl->setContentsMargins(0,0,0,0); + hl->addWidget(vbox); + + QString versionText; + versionText = "Version 0.5 \n"; + + vl->addWidget(new QLabel("Qt Mips - MIPS Architecture Simulator")); + lbl = new QLabel(versionText); + lbl->setAlignment(Qt::AlignHCenter); + lbl->setOpenExternalLinks(true); + vl->addWidget(lbl); + vl->addWidget(new QLabel("Copyright (C) 2017-2019 Karel Kočí " + "cynerd@email.cz
" + "Copyright (C) 2019 Pavel Píša " + "pisa@cmp.felk.cvut.cz")); + + QString supportText; + supportText = "Home Page : https://github.com/ppisa/QtMips
" + "Home Page : https://github.com/Cynerd/QtMips
" + "Implemented for
" + "Computer Architectures
" + "and
" + "Advanced Computer Achitectures
" + "courses at
" + "Czech Technical University in Prague
" + "Faculty of Electrical Engineering
"; + + QTextBrowser *supportBrowser = new QTextBrowser; + supportBrowser->setOpenExternalLinks(true); + supportBrowser->setHtml(supportText); + vl->addWidget(supportBrowser); + + QString licenseText; + licenseText = "This program is free software; you can redistribute it and/or\n" + "modify it under the terms of the GNU General Public License\n" + "as published by the Free Software Foundation; either version 2\n" + "of the License, or (at your option) any later version.\n" + "
\n" + "
\n" + "This program is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU General Public License for more details.\n" + "
\n" + "
\n" + "You should have received a copy of the GNU General Public License\n" + "along with this program; if not, write to the Free Software\n" + "Foundation, Inc., 51 Franklin Street, Fifth Floor,\n" + "Boston, MA 02110-1301, USA.\n"; + + QTextBrowser *licenseBrowser = new QTextBrowser; + licenseBrowser->setOpenExternalLinks(true); + licenseBrowser->setHtml(licenseText); + vl->addWidget(licenseBrowser); + + QWidget *hbBtn = new QWidget(); + QHBoxLayout *hlBtn = new QHBoxLayout(hbBtn); + hlBtn->setContentsMargins(0,0,0,0); + vl->addWidget(hbBtn); + + QPushButton *okButton = new QPushButton(tr("&OK"), parent); + okButton->setFocus(); + connect(okButton, SIGNAL(clicked()), this, SLOT(close())); + hlBtn->addStretch(); + hlBtn->addWidget(okButton); + + prevTab = 0; // first Tab is selected by default +} diff --git a/qtmips_gui/aboutdialog.h b/qtmips_gui/aboutdialog.h new file mode 100644 index 0000000..8470429 --- /dev/null +++ b/qtmips_gui/aboutdialog.h @@ -0,0 +1,61 @@ +// 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 + * Copyright (c) 2019 Pavel Pisa + * + * 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 ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include +#include + +#include +#include + +class QString; +class QTextBrowser; + +class AboutDialog : public QDialog { + Q_OBJECT + +public: + AboutDialog(QWidget *parent = 0); + +private: + QVBoxLayout *all; + QTextBrowser *authorsBrowser; + + int prevTab; +}; + +#endif diff --git a/qtmips_gui/mainwindow.cpp b/qtmips_gui/mainwindow.cpp index 6c752f0..4e716cb 100644 --- a/qtmips_gui/mainwindow.cpp +++ b/qtmips_gui/mainwindow.cpp @@ -34,6 +34,7 @@ ******************************************************************************/ #include "mainwindow.h" +#include "aboutdialog.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { machine = nullptr; @@ -79,6 +80,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { connect(ui->actionMemory, SIGNAL(triggered(bool)), this, SLOT(show_memory())); connect(ui->actionProgram_Cache, SIGNAL(triggered(bool)), this, SLOT(show_cache_program())); connect(ui->actionData_Cache, SIGNAL(triggered(bool)), this, SLOT(show_cache_data())); + connect(ui->actionAbout, SIGNAL(triggered(bool)), this, SLOT(about_qtmips())); + connect(ui->actionAboutQt, SIGNAL(triggered(bool)), this, SLOT(about_qt())); connect(ui->ips1, SIGNAL(toggled(bool)), this, SLOT(set_speed())); connect(ui->ips2, SIGNAL(toggled(bool)), this, SLOT(set_speed())); connect(ui->ips5, SIGNAL(toggled(bool)), this, SLOT(set_speed())); @@ -210,6 +213,17 @@ SHOW_HANDLER(cache_program) SHOW_HANDLER(cache_data) #undef SHOW_HANDLER +void MainWindow::about_qtmips() +{ + AboutDialog *aboutdialog = new AboutDialog(this); + aboutdialog->exec(); +} + +void MainWindow::about_qt() +{ + QMessageBox::aboutQt(this); +} + void MainWindow::set_speed() { if (machine == nullptr) return; // just ignore diff --git a/qtmips_gui/mainwindow.h b/qtmips_gui/mainwindow.h index 71d59c5..48883e5 100644 --- a/qtmips_gui/mainwindow.h +++ b/qtmips_gui/mainwindow.h @@ -70,6 +70,9 @@ public slots: void show_memory(); void show_cache_data(); void show_cache_program(); + // Actions - help menu + void about_qtmips(); + void about_qt(); // Actions - execution speed void set_speed(); // Machine signals diff --git a/qtmips_gui/qtmips_gui.pro b/qtmips_gui/qtmips_gui.pro index 273297f..8822e38 100644 --- a/qtmips_gui/qtmips_gui.pro +++ b/qtmips_gui/qtmips_gui.pro @@ -50,7 +50,8 @@ SOURCES += \ memorytableview.cpp \ hexlineedit.cpp \ programmodel.cpp \ - programtableview.cpp + programtableview.cpp \ + aboutdialog.cpp HEADERS += \ mainwindow.h \ @@ -81,7 +82,8 @@ HEADERS += \ memorytableview.h \ hexlineedit.h \ programmodel.h \ - programtableview.h + programtableview.h \ + aboutdialog.h FORMS += \ NewDialog.ui \ -- cgit v1.2.3