116 lines
3.2 KiB
C++
116 lines
3.2 KiB
C++
/*
|
|
Copyright (C) 2017 Grégory Soutadé
|
|
|
|
This file is part of Hex offsets.
|
|
|
|
Hex offsets 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 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
Hex offsets 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 Hex offsets. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "uientry.hpp"
|
|
#include "mainwindow.hpp"
|
|
|
|
UIEntry::operation UIEntry::getOperation(void)
|
|
{
|
|
if (this->buttonPlus->isChecked())
|
|
return UIEntry::operation::OPERATION_PLUS;
|
|
else
|
|
return UIEntry::operation::OPERATION_MINUS;
|
|
}
|
|
|
|
void UIEntry::on_line_textChanged(const QString &arg1)
|
|
{
|
|
(void) arg1;
|
|
this->ui->computeResult();
|
|
}
|
|
|
|
void UIEntry::on_buttonPlus_toggled(bool checked)
|
|
{
|
|
this->buttonMinus->setChecked(!checked);
|
|
this->ui->computeResult();
|
|
}
|
|
|
|
void UIEntry::on_buttonMinus_toggled(bool checked)
|
|
{
|
|
this->buttonPlus->setChecked(!checked);
|
|
this->ui->computeResult();
|
|
}
|
|
|
|
void UIEntry::on_buttonClear_clicked()
|
|
{
|
|
this->line->clear();
|
|
this->ui->computeResult();
|
|
}
|
|
|
|
void UIEntry::on_checkEnable_toggled(bool checked)
|
|
{
|
|
(void) checked;
|
|
this->ui->computeResult();
|
|
}
|
|
|
|
UIEntry::UIEntry(QWidget *parent, MainWindow* ui) : parent(parent), ui(ui)
|
|
{
|
|
layout = new QHBoxLayout(0);
|
|
|
|
layout->setMargin(0);
|
|
layout->setSpacing(0);
|
|
|
|
buttonClear = new QPushButton(QString("Clear"), this);
|
|
buttonPlus = new QPushButton(QString("+"), this);
|
|
buttonMinus = new QPushButton(QString("-"), this);
|
|
checkEnable = new QCheckBox(this);
|
|
line = new QLineEdit(this);
|
|
|
|
line->setAlignment(Qt::AlignRight);
|
|
|
|
buttonPlus->setCheckable(true);
|
|
buttonMinus->setCheckable(true);
|
|
buttonPlus->setChecked(true);
|
|
|
|
checkEnable->setChecked(true);
|
|
|
|
buttonClear->setFocusPolicy(Qt::NoFocus);
|
|
buttonPlus->setFocusPolicy(Qt::NoFocus);
|
|
buttonMinus->setFocusPolicy(Qt::NoFocus);
|
|
checkEnable->setFocusPolicy(Qt::NoFocus);
|
|
line->setFocusPolicy(Qt::StrongFocus);
|
|
setFocusPolicy(Qt::StrongFocus);
|
|
|
|
this->connect(buttonClear, SIGNAL(clicked(void)), this, SLOT(on_buttonClear_clicked(void)));
|
|
this->connect(buttonPlus, SIGNAL(toggled(bool)), this, SLOT(on_buttonPlus_toggled(bool)));
|
|
this->connect(buttonMinus, SIGNAL(toggled(bool)), this, SLOT(on_buttonMinus_toggled(bool)));
|
|
this->connect(checkEnable, SIGNAL(toggled(bool)), this, SLOT(on_checkEnable_toggled(bool)));
|
|
this->connect(line, SIGNAL(textChanged(QString)), this, SLOT(on_line_textChanged(QString)));
|
|
|
|
layout->addWidget(buttonClear);
|
|
layout->addWidget(buttonPlus);
|
|
layout->addWidget(buttonMinus);
|
|
layout->addWidget(checkEnable);
|
|
layout->addWidget(line);
|
|
|
|
setLayout(layout);
|
|
resize(width(), minimumHeight());
|
|
}
|
|
|
|
UIEntry::~UIEntry()
|
|
{
|
|
delete buttonClear;
|
|
delete buttonPlus;
|
|
delete buttonMinus;
|
|
delete checkEnable;
|
|
delete line;
|
|
|
|
delete layout;
|
|
}
|
|
|