aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-calculator
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
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')
-rw-r--r--src-qt5/desktop-utils/lumina-calculator/EqValidator.h4
-rw-r--r--src-qt5/desktop-utils/lumina-calculator/mainUI.cpp8
-rw-r--r--src-qt5/desktop-utils/lumina-calculator/mainUI.h1
-rw-r--r--src-qt5/desktop-utils/lumina-calculator/mainUI.ui437
4 files changed, 380 insertions, 70 deletions
diff --git a/src-qt5/desktop-utils/lumina-calculator/EqValidator.h b/src-qt5/desktop-utils/lumina-calculator/EqValidator.h
index 462a330d..8218efdf 100644
--- a/src-qt5/desktop-utils/lumina-calculator/EqValidator.h
+++ b/src-qt5/desktop-utils/lumina-calculator/EqValidator.h
@@ -7,8 +7,8 @@
#ifndef _LUMINA_CALCULATOR_VALIDATOR_H
#define _LUMINA_CALCULATOR_VALIDATOR_H
-#define VALIDCHARS QString("x*+-/^eE().0123456789")
-#define NOSTARTCHARS QString("x*/^)eE.")
+#define VALIDCHARS QString("x*+-/^%eE().0123456789")
+#define NOSTARTCHARS QString("x*/^%)eE.")
#define NOENDCHARS QString("x*/^(eE.")
#define NOCHANGE QString("().")
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();
diff --git a/src-qt5/desktop-utils/lumina-calculator/mainUI.h b/src-qt5/desktop-utils/lumina-calculator/mainUI.h
index b4636126..cf09801e 100644
--- a/src-qt5/desktop-utils/lumina-calculator/mainUI.h
+++ b/src-qt5/desktop-utils/lumina-calculator/mainUI.h
@@ -44,6 +44,7 @@ private slots:
void captureButtonMultiply();
// void captureButtonEqual();
void captureButtonDecimal();
+ void captureButtonPercent();
void insert_history(QListWidgetItem *it);
void copy_to_clipboard(QListWidgetItem *it);
diff --git a/src-qt5/desktop-utils/lumina-calculator/mainUI.ui b/src-qt5/desktop-utils/lumina-calculator/mainUI.ui
index 8586bc8e..699915f2 100644
--- a/src-qt5/desktop-utils/lumina-calculator/mainUI.ui
+++ b/src-qt5/desktop-utils/lumina-calculator/mainUI.ui
@@ -6,20 +6,44 @@
<rect>
<x>0</x>
<y>0</y>
- <width>271</width>
- <height>393</height>
+ <width>171</width>
+ <height>258</height>
</rect>
</property>
<property name="windowTitle">
<string>Calculator</string>
</property>
+ <property name="animated">
+ <bool>false</bool>
+ </property>
<widget class="QWidget" name="centralwidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="leftMargin">
+ <number>4</number>
+ </property>
+ <property name="topMargin">
+ <number>4</number>
+ </property>
+ <property name="rightMargin">
+ <number>4</number>
+ </property>
+ <property name="bottomMargin">
+ <number>4</number>
+ </property>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
+ <property name="handleWidth">
+ <number>10</number>
+ </property>
<property name="childrenCollapsible">
<bool>true</bool>
</property>
@@ -38,10 +62,23 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <widget class="QLineEdit" name="line_eq"/>
+ <widget class="QLineEdit" name="line_eq">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
</item>
<item>
<widget class="QToolButton" name="tool_clear">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
@@ -58,260 +95,528 @@
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <widget class="QPushButton" name="button_7">
+ <item row="3" column="3" rowspan="2">
+ <widget class="QPushButton" name="button_Equal">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
+ <property name="baseSize">
+ <size>
+ <width>30</width>
+ <height>30</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>11</pointsize>
+ <weight>75</weight>
+ <italic>false</italic>
+ <bold>true</bold>
+ <underline>false</underline>
+ </font>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">7</string>
+ <string notr="true">=</string>
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QPushButton" name="button_8">
+ <item row="0" column="2">
+ <widget class="QPushButton" name="button_Multiply">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">8</string>
+ <string notr="true">*</string>
</property>
</widget>
</item>
- <item row="0" column="2">
- <widget class="QPushButton" name="button_9">
+ <item row="1" column="3" rowspan="2">
+ <widget class="QPushButton" name="button_Add">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">9</string>
+ <string notr="true">+</string>
</property>
</widget>
</item>
- <item row="0" column="3">
- <widget class="QPushButton" name="button_Divide">
+ <item row="4" column="2">
+ <widget class="QPushButton" name="button_Decimal">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">/</string>
+ <string notr="true">.</string>
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QPushButton" name="button_4">
+ <item row="4" column="0" colspan="2">
+ <widget class="QPushButton" name="button_0">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">4</string>
+ <string notr="true">0</string>
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QPushButton" name="button_5">
+ <item row="0" column="3">
+ <widget class="QPushButton" name="button_Subtract">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">5</string>
+ <string notr="true">-</string>
</property>
</widget>
</item>
- <item row="1" column="2">
- <widget class="QPushButton" name="button_6">
+ <item row="0" column="1">
+ <widget class="QPushButton" name="button_Divide">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">6</string>
+ <string notr="true">/</string>
</property>
</widget>
</item>
- <item row="1" column="3">
- <widget class="QPushButton" name="button_Multiply">
+ <item row="1" column="0">
+ <widget class="QPushButton" name="button_7">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">*</string>
+ <string notr="true">7</string>
</property>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QPushButton" name="button_1">
+ <item row="1" column="1">
+ <widget class="QPushButton" name="button_8">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">1</string>
+ <string notr="true">8</string>
</property>
</widget>
</item>
- <item row="2" column="1">
- <widget class="QPushButton" name="button_2">
+ <item row="1" column="2">
+ <widget class="QPushButton" name="button_9">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">2</string>
+ <string notr="true">9</string>
</property>
</widget>
</item>
- <item row="2" column="2">
- <widget class="QPushButton" name="button_3">
+ <item row="2" column="0">
+ <widget class="QPushButton" name="button_4">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">3</string>
+ <string notr="true">4</string>
</property>
</widget>
</item>
- <item row="2" column="3">
- <widget class="QPushButton" name="button_Subtract">
+ <item row="2" column="1">
+ <widget class="QPushButton" name="button_5">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">-</string>
+ <string notr="true">5</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QPushButton" name="button_6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="text">
+ <string notr="true">6</string>
</property>
</widget>
</item>
<item row="3" column="0">
- <widget class="QPushButton" name="button_0">
+ <widget class="QPushButton" name="button_1">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">0</string>
+ <string notr="true">1</string>
</property>
</widget>
</item>
<item row="3" column="1">
- <widget class="QPushButton" name="button_Decimal">
+ <widget class="QPushButton" name="button_2">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">.</string>
+ <string notr="true">2</string>
</property>
</widget>
</item>
<item row="3" column="2">
- <widget class="QPushButton" name="button_Equal">
+ <widget class="QPushButton" name="button_3">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
- <string notr="true">=</string>
+ <string notr="true">3</string>
</property>
</widget>
</item>
- <item row="3" column="3">
- <widget class="QPushButton" name="button_Add">
+ <item row="0" column="0">
+ <widget class="QPushButton" name="button_Percent">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="focusPolicy">
- <enum>Qt::NoFocus</enum>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeIncrement">
+ <size>
+ <width>5</width>
+ <height>5</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
- <string notr="true">+</string>
+ <string>%</string>
</property>
</widget>
</item>
bgstack15