aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2016-10-21 09:28:16 -0400
committerKen Moore <ken@ixsystems.com>2016-10-21 09:28:16 -0400
commit91f80ba710f08a41a559182b32b793a31a239180 (patch)
tree630243d40c80d33a112803c83542b0901274d6e9 /src-qt5/desktop-utils/lumina-calculator/mainUI.cpp
parentAdd directory context to the lumina-textedit in a couple ways: (diff)
downloadlumina-91f80ba710f08a41a559182b32b793a31a239180.tar.gz
lumina-91f80ba710f08a41a559182b32b793a31a239180.tar.bz2
lumina-91f80ba710f08a41a559182b32b793a31a239180.zip
Update lumina-calculator a bit:
1) Re-arrange the buttons a tiny bit to match what a numpad looks like (based on user feedback) 2) To fill the empty spot in the corner, add a "percent" button and add handling for that within the solver. 3) Adjust all the button properties so that the window can be resized down to a much smaller footprint as desired.
Diffstat (limited to 'src-qt5/desktop-utils/lumina-calculator/mainUI.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-calculator/mainUI.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp b/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp
index a85bcf42..1ea925cd 100644
--- a/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp
@@ -16,7 +16,7 @@
#include <math.h>
#define BADVALUE NAN
-#define OPS QString("+-*/x^")
+#define OPS QString("+-*/x^%")
mainUI::mainUI() : QMainWindow(), ui(new Ui::mainUI()){
ui->setupUi(this);
@@ -38,6 +38,7 @@ mainUI::mainUI() : QMainWindow(), ui(new Ui::mainUI()){
connect(ui->button_Divide, SIGNAL (clicked()), this, SLOT (captureButtonDivide()));
connect(ui->button_Multiply, SIGNAL (clicked()), this, SLOT (captureButtonMultiply()));
connect(ui->button_Decimal, SIGNAL (clicked()), this, SLOT (captureButtonDecimal()));
+ connect(ui->button_Percent, SIGNAL(clicked()), this, SLOT(captureButtonPercent()) );
connect(ui->button_Equal, SIGNAL (clicked()), this, SLOT (start_calc()));
connect(ui->list_results, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(insert_history(QListWidgetItem*)) );
//connect(ui->list_results, SIGNAL(itemRightClicked(QListWidgetItem*)), this, SLOT(copt_to_clipboard(QListWidgetItem*)) );
@@ -57,7 +58,9 @@ void mainUI::updateIcons(){
void mainUI::start_calc(){
if(ui->line_eq->text().isEmpty()){ return; } //nothing to do
- double result = strToNumber(ui->line_eq->text());
+ QString eq = ui->line_eq->text();
+ eq.replace("%","/(100)");
+ double result = strToNumber(eq);
if(result!=result){ return; } //bad calculation - NaN's values are special in that they don't equal itself
QString res = "%1 \t= [ %2 ]";
ui->list_results->addItem(res.arg(QString::number(result), ui->line_eq->text()));
@@ -86,6 +89,7 @@ void mainUI::captureButtonDivide(){ ui->line_eq->insert(ui->button_Divide->text(
void mainUI::captureButtonMultiply(){ ui->line_eq->insert(ui->button_Multiply->text()); }
//void mainUI::captureButtonEqual(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_Equal->text()); }
void mainUI::captureButtonDecimal(){ ui->line_eq->insert(ui->button_Decimal->text()); }
+void mainUI::captureButtonPercent(){ ui->line_eq->insert(ui->button_Percent->text()); }
void mainUI::insert_history(QListWidgetItem *it){
QString txt = it->text().section("[",1,-1).section("]",0,0).simplified();
bgstack15