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

Loading…
Cancel
Save