diff options
author | Ken Moore <ken@ixsystems.com> | 2016-10-20 15:43:54 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2016-10-20 15:43:54 -0400 |
commit | 0107662030f5ebf25a65fca39d203e821cfeb544 (patch) | |
tree | c460f08849a7ce03dbaa891cc48bbdb94e06d16e /src-qt5/desktop-utils | |
parent | Oops, make sure the .desktop file actually gets installed. (diff) | |
download | lumina-0107662030f5ebf25a65fca39d203e821cfeb544.tar.gz lumina-0107662030f5ebf25a65fca39d203e821cfeb544.tar.bz2 lumina-0107662030f5ebf25a65fca39d203e821cfeb544.zip |
Setup the calculator to automatically load the last result if the first char is an operator.
Diffstat (limited to 'src-qt5/desktop-utils')
-rw-r--r-- | src-qt5/desktop-utils/lumina-calculator/mainUI.cpp | 13 | ||||
-rw-r--r-- | src-qt5/desktop-utils/lumina-calculator/mainUI.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp b/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp index 49449586..a85bcf42 100644 --- a/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp @@ -16,10 +16,13 @@ #include <math.h> #define BADVALUE NAN +#define OPS QString("+-*/x^") + mainUI::mainUI() : QMainWindow(), ui(new Ui::mainUI()){ ui->setupUi(this); connect(ui->tool_clear, SIGNAL(clicked()), this, SLOT(clear_calc()) ); connect(ui->line_eq, SIGNAL(returnPressed()), this, SLOT(start_calc()) ); + connect(ui->line_eq, SIGNAL(textEdited(const QString&)), this, SLOT(checkInput(const QString&)) ); connect(ui->button_1, SIGNAL (clicked()), this, SLOT (captureButton1())); connect(ui->button_2, SIGNAL (clicked()), this, SLOT (captureButton2())); connect(ui->button_3, SIGNAL (clicked()), this, SLOT (captureButton3())); @@ -93,6 +96,16 @@ void mainUI::copy_to_clipboard(QListWidgetItem *it){ QString txt = it->text(); QApplication::clipboard()->setText(txt); } + +void mainUI::checkInput(const QString &str){ + if(str.length()==1 && ui->list_results->count()>0){ + if(OPS.contains(str)){ + QString lastresult = ui->list_results->item( ui->list_results->count()-1)->text().section("=",0,0).simplified(); + ui->line_eq->setText( lastresult+str); + } + } +} + // ===================== // PRIVATE FUNCTIONS // ===================== diff --git a/src-qt5/desktop-utils/lumina-calculator/mainUI.h b/src-qt5/desktop-utils/lumina-calculator/mainUI.h index 50762677..b4636126 100644 --- a/src-qt5/desktop-utils/lumina-calculator/mainUI.h +++ b/src-qt5/desktop-utils/lumina-calculator/mainUI.h @@ -47,6 +47,7 @@ private slots: void insert_history(QListWidgetItem *it); void copy_to_clipboard(QListWidgetItem *it); + void checkInput(const QString&); private: Ui::mainUI *ui; |