File: alcoholtool.cpp

package info (click to toggle)
qbrew 0.4.1-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 1,724 kB
  • ctags: 1,355
  • sloc: cpp: 7,503; sh: 414; makefile: 18
file content (49 lines) | stat: -rw-r--r-- 1,580 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/***************************************************************************
  alcoholtool.cpp
  -------------------
  An Alcohol Percentage Calculator utility for QBrew
  -------------------
  Copyright 2004-2008, David Johnson <david@usermode.org>
  Based on code Copyright 2004, Michal Palczewski <michalp@gmail.com>
  Please see the header file for copyright and license information
 ***************************************************************************/

#include <QLabel>

#include "recipe.h"
#include "resource.h"
#include "alcoholtool.h"

//////////////////////////////////////////////////////////////////////////////
// AbvcalcTool()
// ----------------
// Constructor

AlcoholTool::AlcoholTool(QWidget* parent)
    : QDialog(parent)
{
    setWindowTitle(Resource::TITLE + tr(" - Alcohol Tool"));

    ui.setupUi(this);

    // connections
    connect(ui.og, SIGNAL(valueChanged(double)), this, SLOT(recalc()));
    connect(ui.fg, SIGNAL(valueChanged(double)), this, SLOT(recalc()));

    recalc();
}

//////////////////////////////////////////////////////////////////////////////
// recalc()
// --------
// the signal to calculate the Alcohol percentage

void AlcoholTool::recalc()
{
    ui.abw->setText(QString::number(Recipe::ABW(ui.og->value(),
                                                ui.fg->value()) * 100.0,
                                    'f', 1) + "%");
    ui.abv->setText(QString::number(Recipe::ABV(ui.og->value(),
                                                ui.fg->value()) * 100.0,
                                    'f', 1) + "%");
}