2013-07-09 12:37:53 +00:00
|
|
|
#include "printoptions.h"
|
2013-07-10 21:45:29 +00:00
|
|
|
#include "../display.h"
|
2013-07-09 12:37:53 +00:00
|
|
|
|
2013-07-09 20:43:21 +00:00
|
|
|
PrintOptions::PrintOptions(QWidget *parent, struct options *printOpt)
|
2013-07-09 12:37:53 +00:00
|
|
|
{
|
2013-07-10 07:54:25 +00:00
|
|
|
hasSetupSlots = false;
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.setupUi(this);
|
2013-07-09 20:43:21 +00:00
|
|
|
if (parent)
|
|
|
|
setParent(parent);
|
|
|
|
if (!printOpt)
|
|
|
|
return;
|
2013-07-10 07:54:25 +00:00
|
|
|
setup(printOpt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintOptions::setup(struct options *printOpt)
|
|
|
|
{
|
2013-11-30 16:43:40 +00:00
|
|
|
/* these options are not supported ATM and we hide them.
|
|
|
|
* basically the entire PrintDialog class needs re-implementation, so that
|
|
|
|
* the paper size, DPI and all other options are displayed in one dialog.
|
|
|
|
* this way we can print directly or do an optional preview first.
|
|
|
|
*/
|
|
|
|
ui.sizingHeights->setVisible(false);
|
|
|
|
|
2013-07-09 20:43:21 +00:00
|
|
|
printOptions = printOpt;
|
2013-07-10 07:54:25 +00:00
|
|
|
// layout height sliders
|
2013-10-03 18:54:25 +00:00
|
|
|
initSliderWithLabel(ui.sliderPHeight, ui.valuePHeight, printOptions->profile_height);
|
|
|
|
initSliderWithLabel(ui.sliderOHeight, ui.valueOHeight, printOptions->notes_height);
|
|
|
|
initSliderWithLabel(ui.sliderNHeight, ui.valueNHeight, printOptions->tanks_height);
|
2013-07-10 07:54:25 +00:00
|
|
|
// print type radio buttons
|
2013-07-10 12:34:57 +00:00
|
|
|
switch (printOptions->type) {
|
2013-07-10 07:54:25 +00:00
|
|
|
case options::PRETTY:
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.radioSixDives->setChecked(true);
|
2013-07-10 07:54:25 +00:00
|
|
|
break;
|
|
|
|
case options::TWOPERPAGE:
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.radioTwoDives->setChecked(true);
|
2013-07-10 07:54:25 +00:00
|
|
|
break;
|
|
|
|
case options::TABLE:
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.radioTablePrint->setChecked(true);
|
2013-07-10 07:54:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
// general print option checkboxes
|
|
|
|
if (printOptions->color_selected)
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.printInColor->setChecked(true);
|
2013-07-10 07:54:25 +00:00
|
|
|
if (printOptions->print_selected)
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.printSelected->setChecked(true);
|
2013-07-10 07:54:25 +00:00
|
|
|
// ordering
|
|
|
|
if (printOptions->notes_up)
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.notesOnTop->setChecked(true);
|
2013-07-10 07:54:25 +00:00
|
|
|
else
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.profileOnTop->setChecked(true);
|
2013-07-10 07:54:25 +00:00
|
|
|
|
|
|
|
// connect slots only once
|
|
|
|
if (hasSetupSlots)
|
|
|
|
return;
|
2013-10-03 18:54:25 +00:00
|
|
|
connect(ui.sliderPHeight, SIGNAL(sliderMoved(int)), this, SLOT(sliderPHeightMoved(int)));
|
|
|
|
connect(ui.sliderOHeight, SIGNAL(sliderMoved(int)), this, SLOT(sliderOHeightMoved(int)));
|
|
|
|
connect(ui.sliderNHeight, SIGNAL(sliderMoved(int)), this, SLOT(sliderNHeightMoved(int)));
|
2013-07-10 07:54:25 +00:00
|
|
|
|
2013-10-03 18:54:25 +00:00
|
|
|
connect(ui.radioSixDives, SIGNAL(clicked(bool)), this, SLOT(radioSixDivesClicked(bool)));
|
|
|
|
connect(ui.radioTwoDives, SIGNAL(clicked(bool)), this, SLOT(radioTwoDivesClicked(bool)));
|
|
|
|
connect(ui.radioTablePrint, SIGNAL(clicked(bool)), this, SLOT(radioTablePrintClicked(bool)));
|
2013-07-10 07:54:25 +00:00
|
|
|
|
2013-10-03 18:54:25 +00:00
|
|
|
connect(ui.printInColor, SIGNAL(clicked(bool)), this, SLOT(printInColorClicked(bool)));
|
|
|
|
connect(ui.printSelected, SIGNAL(clicked(bool)), this, SLOT(printSelectedClicked(bool)));
|
2013-07-10 07:54:25 +00:00
|
|
|
|
2013-10-03 18:54:25 +00:00
|
|
|
connect(ui.notesOnTop, SIGNAL(clicked(bool)), this, SLOT(notesOnTopClicked(bool)));
|
|
|
|
connect(ui.profileOnTop, SIGNAL(clicked(bool)), this, SLOT(profileOnTopClicked(bool)));
|
2013-07-10 07:54:25 +00:00
|
|
|
hasSetupSlots = true;
|
2013-07-09 12:37:53 +00:00
|
|
|
}
|
|
|
|
|
2013-07-10 07:54:25 +00:00
|
|
|
// layout height sliders
|
2013-07-09 20:43:21 +00:00
|
|
|
void PrintOptions::initSliderWithLabel(QSlider *slider, QLabel *label, int value)
|
2013-07-09 12:37:53 +00:00
|
|
|
{
|
2013-07-09 20:43:21 +00:00
|
|
|
slider->setValue(value);
|
|
|
|
label->setText(formatSliderValueText(value));
|
|
|
|
}
|
|
|
|
|
|
|
|
QString PrintOptions::formatSliderValueText(int value)
|
|
|
|
{
|
|
|
|
QString str = QString("%1%").arg(QString::number(value));
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintOptions::sliderPHeightMoved(int value)
|
|
|
|
{
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.valuePHeight->setText(formatSliderValueText(value));
|
2013-07-09 20:43:21 +00:00
|
|
|
printOptions->profile_height = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintOptions::sliderOHeightMoved(int value)
|
|
|
|
{
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.valueOHeight->setText(formatSliderValueText(value));
|
2013-07-09 20:43:21 +00:00
|
|
|
printOptions->notes_height = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintOptions::sliderNHeightMoved(int value)
|
|
|
|
{
|
2013-10-03 18:54:25 +00:00
|
|
|
ui.valueNHeight->setText(formatSliderValueText(value));
|
2013-07-09 20:43:21 +00:00
|
|
|
printOptions->tanks_height = value;
|
2013-07-09 12:37:53 +00:00
|
|
|
}
|
2013-07-10 07:54:25 +00:00
|
|
|
|
|
|
|
// print type radio buttons
|
|
|
|
void PrintOptions::radioSixDivesClicked(bool check)
|
|
|
|
{
|
|
|
|
printOptions->type = options::PRETTY;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintOptions::radioTwoDivesClicked(bool check)
|
|
|
|
{
|
|
|
|
printOptions->type = options::TWOPERPAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintOptions::radioTablePrintClicked(bool check)
|
|
|
|
{
|
|
|
|
printOptions->type = options::TABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// general print option checkboxes
|
|
|
|
void PrintOptions::printInColorClicked(bool check)
|
|
|
|
{
|
|
|
|
printOptions->color_selected = (int)check;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintOptions::printSelectedClicked(bool check)
|
|
|
|
{
|
|
|
|
printOptions->print_selected = (int)check;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ordering
|
|
|
|
void PrintOptions::notesOnTopClicked(bool check)
|
|
|
|
{
|
|
|
|
printOptions->notes_up = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintOptions::profileOnTopClicked(bool check)
|
|
|
|
{
|
|
|
|
printOptions->notes_up = false;
|
|
|
|
}
|