larger buttons

main
Benjamin Kraft 1 year ago
parent ab8397d301
commit ea344c281c
  1. 10
      src/Button.cpp
  2. 7
      src/Button.h
  3. 34
      src/MainWindow.cpp

@ -0,0 +1,10 @@
#include "Button.h"
Button::Button(QString text) : QPushButton(text) {
setMinimumHeight(30);
setIconSize(QSize(25, 25));
}
Button::Button(QString text, QString icon) : Button(text) {
setIcon(QIcon(icon));
}

@ -0,0 +1,7 @@
#include <QPushButton>
class Button : public QPushButton {
public:
explicit Button(QString text);
explicit Button(QString text, QString icon);
};

@ -10,10 +10,10 @@
#include <QButtonGroup> #include <QButtonGroup>
#include <iostream> #include <iostream>
#include <QDial> #include <QDial>
#include <iostream>
#include <QColorDialog> #include <QColorDialog>
#include <QCoreApplication> #include <QCoreApplication>
#include "Pendulum.h" #include "Pendulum.h"
#include "Button.h"
MainWindow::MainWindow() { MainWindow::MainWindow() {
simulation = new Simulation; simulation = new Simulation;
@ -130,13 +130,13 @@ QWidget * MainWindow::buildAddUI() {
auto segmentButtonGrid = new QHBoxLayout; auto segmentButtonGrid = new QHBoxLayout;
lyt->addLayout(segmentButtonGrid); lyt->addLayout(segmentButtonGrid);
auto resetMassesBtn = new QPushButton("Reset"); auto resetMassesBtn = new Button("Reset", ":/icons/refresh.svg");
auto normalizeLengthsBtn = new QPushButton("Normalize"); auto normalizeLengthsBtn = new Button("Normalize", ":/icons/compress.svg");
auto resetLengthsBtn = new QPushButton("Reset"); auto resetLengthsBtn = new Button("Reset", ":/icons/refresh.svg");
resetMassesBtn->setIcon(QIcon(":/icons/refresh.svg")); resetMassesBtn->setToolTip("Reset masses to 1kg");
normalizeLengthsBtn->setIcon(QIcon(":/icons/compress.svg")); normalizeLengthsBtn->setToolTip("Normalize lengths to fit screen");
resetLengthsBtn->setIcon(QIcon(":/icons/refresh.svg")); resetLengthsBtn->setToolTip("Reset lengths to 1m");
connect(resetMassesBtn, &QPushButton::clicked, this, &MainWindow::resetMasses); connect(resetMassesBtn, &QPushButton::clicked, this, &MainWindow::resetMasses);
connect(normalizeLengthsBtn, &QPushButton::clicked, this, &MainWindow::normalizeLengths); connect(normalizeLengthsBtn, &QPushButton::clicked, this, &MainWindow::normalizeLengths);
@ -170,7 +170,7 @@ QWidget * MainWindow::buildAddUI() {
auto colorLyt = new QHBoxLayout; auto colorLyt = new QHBoxLayout;
lyt->addLayout(colorLyt); lyt->addLayout(colorLyt);
auto colorBtn = new QPushButton("Select color"); auto colorBtn = new Button("Select color");
auto colorLabel = new QLabel; auto colorLabel = new QLabel;
colorLabel->setStyleSheet("background-color: white"); colorLabel->setStyleSheet("background-color: white");
@ -281,10 +281,11 @@ QWidget * MainWindow::buildAddUI() {
auto btnLyt = new QHBoxLayout; auto btnLyt = new QHBoxLayout;
lyt->addLayout(btnLyt); lyt->addLayout(btnLyt);
auto addBtn = new QPushButton("Add"); auto addBtn = new Button("Add", ":/icons/add.svg");
auto removeBtn = new QPushButton("Remove all"); auto removeBtn = new Button("Remove all", ":/icons/delete.svg");
addBtn->setIcon(QIcon(":/icons/add.svg"));
removeBtn->setIcon(QIcon(":/icons/delete.svg")); addBtn->setToolTip("Add configured pendulum");
removeBtn->setToolTip("Remove all pendula");
connect(addBtn, &QPushButton::clicked, this, &MainWindow::add); connect(addBtn, &QPushButton::clicked, this, &MainWindow::add);
connect(removeBtn, &QPushButton::clicked, this, &MainWindow::remove); connect(removeBtn, &QPushButton::clicked, this, &MainWindow::remove);
@ -334,10 +335,11 @@ QWidget * MainWindow::buildSimulationUI() {
auto btnLyt = new QHBoxLayout; auto btnLyt = new QHBoxLayout;
lyt->addLayout(btnLyt); lyt->addLayout(btnLyt);
auto reset = new QPushButton("Reset"); auto reset = new Button("Reset", ":/icons/refresh.svg");
auto togglePlay = new QPushButton("Resume"); auto togglePlay = new Button("Resume", ":/icons/play.svg");
reset->setIcon(QIcon(":/icons/refresh.svg"));
togglePlay->setIcon(QIcon(":/icons/play.svg")); reset->setToolTip("Reset Simulation controls");
togglePlay->setToolTip("Pause/Resume Simulation");
connect(reset, &QPushButton::clicked, this, &MainWindow::resetSimulationControl); connect(reset, &QPushButton::clicked, this, &MainWindow::resetSimulationControl);
connect(togglePlay, &QPushButton::clicked, this, &MainWindow::toggleSimulation); connect(togglePlay, &QPushButton::clicked, this, &MainWindow::toggleSimulation);

Loading…
Cancel
Save