diff options
-rw-r--r-- | src-qt5/desktop-utils/lumina-calculator/mainUI.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp b/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp index 18d2cfdd..f759f5c6 100644 --- a/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-calculator/mainUI.cpp @@ -16,13 +16,30 @@ mainUI::mainUI() : QMainWindow(), ui(new Ui::mainUI()){ ui->setupUi(this); - connect(ui->tool_start, SIGNAL(clicked()), this, SLOT(start_calc()) ); + connect(ui->tool_clear, SIGNAL(clicked()), this, SLOT(clear_calc()) ); connect(ui->line_eq, SIGNAL(returnPressed()), this, SLOT(start_calc()) ); + 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())); + connect (ui->button_4, SIGNAL (clicked()), this, SLOT (captureButton4())); + connect (ui->button_5, SIGNAL (clicked()), this, SLOT (captureButton5())); + connect (ui->button_6, SIGNAL (clicked()), this, SLOT (captureButton6())); + connect (ui->button_7, SIGNAL (clicked()), this, SLOT (captureButton7())); + connect (ui->button_8, SIGNAL (clicked()), this, SLOT (captureButton8())); + connect (ui->button_9, SIGNAL (clicked()), this, SLOT (captureButton9())); + connect (ui->button_0, SIGNAL (clicked()), this, SLOT (captureButton0())); + connect (ui->button_Subtract, SIGNAL (clicked()), this, SLOT (captureButtonSubtract())); + connect (ui->button_Add, SIGNAL (clicked()), this, SLOT (captureButtonAdd())); + 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_Equal, SIGNAL (clicked()), this, SLOT (start_calc())); + + ui->line_eq->setFocus(); } mainUI::~mainUI(){ - } void mainUI::start_calc(){ @@ -35,6 +52,28 @@ void mainUI::start_calc(){ ui->line_eq->clear(); } +void mainUI::clear_calc(){ + ui->line_eq->clear(); + ui->line_eq->setFocus(); +} + +void mainUI::captureButton1(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_1->text()); } +void mainUI::captureButton2(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_2->text()); } +void mainUI::captureButton3(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_3->text()); } +void mainUI::captureButton4(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_4->text()); } +void mainUI::captureButton5(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_5->text()); } +void mainUI::captureButton6(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_6->text()); } +void mainUI::captureButton7(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_7->text()); } +void mainUI::captureButton8(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_8->text()); } +void mainUI::captureButton9(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_9->text()); } +void mainUI::captureButton0(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_0->text()); } +void mainUI::captureButtonSubtract(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_Subtract->text()); } +void mainUI::captureButtonAdd(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_Add->text()); } +void mainUI::captureButtonDivide(){ ui->line_eq->setText(ui->line_eq->text() += ui->button_Divide->text()); } +void mainUI::captureButtonMultiply(){ ui->line_eq->setText(ui->line_eq->text() += 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->setText(ui->line_eq->text() += ui->button_Decimal->text()); } + double mainUI::performOperation(double LHS, double RHS, QChar symbol){ if(symbol== '+'){ return (LHS+RHS); } else if(symbol== '-'){ return (LHS-RHS); } |