subsurface/qt-ui/printoptions.cpp
Gehad elrobey b4e1563d10 Printing: remove the print_options struct from display.h
Move print_options struct to printoptions.h, its more relevant to be
placed here.

Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 10:07:59 -07:00

77 lines
1.7 KiB
C++

#include "printoptions.h"
PrintOptions::PrintOptions(QWidget *parent, struct print_options *printOpt)
{
hasSetupSlots = false;
ui.setupUi(this);
if (parent)
setParent(parent);
if (!printOpt)
return;
setup(printOpt);
}
void PrintOptions::setup(struct print_options *printOpt)
{
printOptions = printOpt;
// print type radio buttons
switch (printOptions->type) {
case print_options::DIVELIST:
ui.radioDiveListPrint->setChecked(true);
break;
case print_options::TABLE:
ui.radioTablePrint->setChecked(true);
break;
case print_options::STATISTICS:
ui.radioStatisticsPrint->setChecked(true);
break;
}
// general print option checkboxes
if (printOptions->color_selected)
ui.printInColor->setChecked(true);
if (printOptions->print_selected)
ui.printSelected->setChecked(true);
// connect slots only once
if (hasSetupSlots)
return;
connect(ui.printInColor, SIGNAL(clicked(bool)), this, SLOT(printInColorClicked(bool)));
connect(ui.printSelected, SIGNAL(clicked(bool)), this, SLOT(printSelectedClicked(bool)));
hasSetupSlots = true;
}
// print type radio buttons
void PrintOptions::on_radioDiveListPrint_clicked(bool check)
{
if (check) {
printOptions->type = print_options::DIVELIST;
}
}
void PrintOptions::on_radioTablePrint_clicked(bool check)
{
if (check) {
printOptions->type = print_options::TABLE;
}
}
void PrintOptions::on_radioStatisticsPrint_clicked(bool check)
{
if (check) {
printOptions->type = print_options::STATISTICS;
}
}
// general print option checkboxes
void PrintOptions::printInColorClicked(bool check)
{
printOptions->color_selected = check;
}
void PrintOptions::printSelectedClicked(bool check)
{
printOptions->print_selected = check;
}