diff options
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; |