Commit 9d02ac0b authored by Christian Rüb's avatar Christian Rüb

initial commit

parents
# -------------------------------------------------
# Project created by QtCreator 2010-01-06T11:57:24
# -------------------------------------------------
TARGET = qcurrency
TEMPLATE = app
linux-gnueabi-oe-g++ {
message(" building for ARM")
OBJECTS_DIR = build
MOC_DIR = build
UI_HEADERS_DIR = build
UI_SOURCES_DIR = build
}
else {
message("building for x86")
OBJECTS_DIR = build.x86
MOC_DIR = build.x86
UI_HEADERS_DIR = build.x86
UI_SOURCES_DIR = build.x86
TARGET = qcurrency.x86
MAKEFILE += Makefile.x86
}
SOURCES += src/main.cpp \
src/qcurrency.cpp
HEADERS += src/qcurrency.h
FORMS += ui/qcurrency.ui
OTHER_FILES += styles/shr.style
#include <QtGui/QApplication>
#include "qcurrency.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QCurrency w;
w.show();
w.loadSettings();
return a.exec();
}
#include "qcurrency.h"
#include "ui_qcurrency.h"
#include <QDebug>
QCurrency::QCurrency(QWidget *parent)
: QMainWindow(parent), ui(new Ui::QCurrency) {
ui->setupUi(this);
settings = new QSettings("QCurrency","QCurrency");
rate = 1.0;
connect(ui->exitButton, SIGNAL(clicked()), this, SLOT(close()));
connect(ui->rateEdit, SIGNAL(textChanged(QString)), this, SLOT(setRate(QString)));
connect(ui->valueEdit, SIGNAL(returnPressed()), this, SLOT(calculateRate()));
connect(ui->calcButton, SIGNAL(clicked()), this, SLOT(calculateRate()));
connect(ui->saveRateButton, SIGNAL(clicked()), this, SLOT(saveSettings()));
ui->rateEdit->setText(QString::number(rate));
}
QCurrency::~QCurrency() {
delete ui;
delete settings;
}
void QCurrency::calculateRate() {
bool ok;
double val = ui->valueEdit->text().toDouble(&ok);
if(ok) {
ui->toEdit->setText(QString::number((val / rate),'f',2));
ui->fromEdit->setText(QString::number((val * rate),'f',2));
}
}
void QCurrency::saveSettings() {
settings->setValue("ui/rate",rate);
}
void QCurrency::loadSettings() {
rate = settings->value("ui/rate",1.0).toDouble();
ui->rateEdit->setText(QString::number(rate));
}
void QCurrency::setRate(QString newrate) {
bool ok;
double retval = newrate.toDouble(&ok);
if(ok) {
rate = retval;
qDebug() << "new rate:" << rate;
}
}
#ifndef QCURRENCY_H
#define QCURRENCY_H
#include <QtGui/QMainWindow>
#include <QSettings>
namespace Ui {
class QCurrency;
}
class QCurrency : public QMainWindow {
Q_OBJECT
public:
QCurrency(QWidget *parent = 0);
~QCurrency();
void loadSettings();
private:
Ui::QCurrency *ui;
QSettings *settings;
double rate;
private slots:
void calculateRate();
void saveSettings();
void setRate(QString);
};
#endif // QCURRENCY_H
* {font-size: 20px;}
QPushButton {
font-size: 25px;
border-radius: 8px;
color: #ffffff;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #909090, stop: 0.49 #909090, stop: 0.5 #000000, stop: 1 #000000);
}
QPushButton:disabled {
color: #000000;
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #d6d7da, stop: 1 #c6c7ca);
}
QPushButton#calcButton, QPushButton#exitButton {
font-size: 35px;
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QCurrency</class>
<widget class="QMainWindow" name="QCurrency">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>480</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>QCurrency</string>
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="rateLabel">
<property name="text">
<string>Exchange rate:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="rateEdit"/>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="saveRateButton">
<property name="text">
<string>Save rate</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="valueLabel">
<property name="text">
<string>Value:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="valueEdit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="toButton">
<property name="text">
<string>To own currency:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="toEdit"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="fromButton">
<property name="text">
<string>From own currency:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="fromEdit"/>
</item>
<item row="5" column="0" colspan="2">
<widget class="QPushButton" name="calcButton">
<property name="text">
<string>Calculate</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<widget class="QPushButton" name="exitButton">
<property name="text">
<string>Exit</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment