summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-15 05:22:07 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-08-15 05:22:07 -0700
commit2455a5dec70d1baa2d0009e602db6b4f19941b56 (patch)
tree49a74aed6f2186fbdf5c9b301fa353e764da3a07 /qt-ui
parent0aafa2556e6abefc54469bc7fa3e258c2ce10b51 (diff)
parentf3c5699714e43e91c8ff8f66119da454b314264d (diff)
downloadsubsurface-2455a5dec70d1baa2d0009e602db6b4f19941b56.tar.gz
Merge branch 'custom-print' of github.com:neolit123/subsurface
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/printdialog.cpp51
-rw-r--r--qt-ui/printoptions.cpp26
-rw-r--r--qt-ui/printoptions.h9
-rw-r--r--qt-ui/profile/profilewidget2.cpp11
-rw-r--r--qt-ui/templateedit.cpp45
-rw-r--r--qt-ui/templateedit.h1
-rw-r--r--qt-ui/templateedit.ui60
7 files changed, 148 insertions, 55 deletions
diff --git a/qt-ui/printdialog.cpp b/qt-ui/printdialog.cpp
index 6c50ae99b..002f9b9f4 100644
--- a/qt-ui/printdialog.cpp
+++ b/qt-ui/printdialog.cpp
@@ -17,21 +17,24 @@ template_options::color_palette_struct ssrf_colors, almond_colors, blueshades_co
PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f)
{
// initialize const colors
- ssrf_colors.color1 = QColor::fromRgb(0xef, 0xf7, 0xff);
+ ssrf_colors.color1 = QColor::fromRgb(0xff, 0xff, 0xff);
ssrf_colors.color2 = QColor::fromRgb(0xa6, 0xbc, 0xd7);
- ssrf_colors.color3 = QColor::fromRgb(0x34, 0x65, 0xa4);
- ssrf_colors.color4 = QColor::fromRgb(0x20, 0x4a, 0x87);
- ssrf_colors.color5 = QColor::fromRgb(0x17, 0x37, 0x64);
- almond_colors.color1 = QColor::fromRgb(243, 234, 207);
+ ssrf_colors.color3 = QColor::fromRgb(0xef, 0xf7, 0xff);
+ ssrf_colors.color4 = QColor::fromRgb(0x34, 0x65, 0xa4);
+ ssrf_colors.color5 = QColor::fromRgb(0x20, 0x4a, 0x87);
+ ssrf_colors.color6 = QColor::fromRgb(0x17, 0x37, 0x64);
+ almond_colors.color1 = QColor::fromRgb(255, 255, 255);
almond_colors.color2 = QColor::fromRgb(253, 204, 156);
- almond_colors.color3 = QColor::fromRgb(136, 160, 150);
- almond_colors.color4 = QColor::fromRgb(187, 171, 139);
- almond_colors.color5 = QColor::fromRgb(239, 130, 117);
- blueshades_colors.color1 = QColor::fromRgb(182, 192, 206);
+ almond_colors.color3 = QColor::fromRgb(243, 234, 207);
+ almond_colors.color4 = QColor::fromRgb(136, 160, 150);
+ almond_colors.color5 = QColor::fromRgb(187, 171, 139);
+ almond_colors.color6 = QColor::fromRgb(0, 0, 0);
+ blueshades_colors.color1 = QColor::fromRgb(255, 255, 255);
blueshades_colors.color2 = QColor::fromRgb(142, 152, 166);
- blueshades_colors.color3 = QColor::fromRgb(31, 49, 75);
- blueshades_colors.color4 = QColor::fromRgb(21, 45, 84);
- blueshades_colors.color5 = QColor::fromRgb(5, 25, 56);
+ blueshades_colors.color3 = QColor::fromRgb(182, 192, 206);
+ blueshades_colors.color4 = QColor::fromRgb(31, 49, 75);
+ blueshades_colors.color5 = QColor::fromRgb(21, 45, 84);
+ blueshades_colors.color6 = QColor::fromRgb(0, 0, 0);
// check if the options were previously stored in the settings; if not use some defaults.
QSettings s;
@@ -164,13 +167,6 @@ void PrintDialog::onFinished()
void PrintDialog::previewClicked(void)
{
- if (printOptions.type == print_options::STATISTICS) {
- QMessageBox msgBox;
- msgBox.setText("This feature is not implemented yet");
- msgBox.exec();
- return;
- }
-
QPrintPreviewDialog previewDialog(&qprinter, this, Qt::Window
| Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint
| Qt::WindowTitleHint);
@@ -180,13 +176,6 @@ void PrintDialog::previewClicked(void)
void PrintDialog::printClicked(void)
{
- if (printOptions.type == print_options::STATISTICS) {
- QMessageBox msgBox;
- msgBox.setText("This feature is not implemented yet");
- msgBox.exec();
- return;
- }
-
QPrintDialog printDialog(&qprinter, this);
if (printDialog.exec() == QDialog::Accepted) {
switch (printOptions.type) {
@@ -195,6 +184,7 @@ void PrintDialog::printClicked(void)
printer->print();
break;
case print_options::STATISTICS:
+ printer->print_statistics();
break;
}
close();
@@ -204,7 +194,14 @@ void PrintDialog::printClicked(void)
void PrintDialog::onPaintRequested(QPrinter *printerPtr)
{
connect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
- printer->print();
+ switch (printOptions.type) {
+ case print_options::DIVELIST:
+ printer->print();
+ break;
+ case print_options::STATISTICS:
+ printer->print_statistics();
+ break;
+ }
progressBar->setValue(0);
disconnect(printer, SIGNAL(progessUpdated(int)), progressBar, SLOT(setValue(int)));
}
diff --git a/qt-ui/printoptions.cpp b/qt-ui/printoptions.cpp
index 1da95a94d..419098cf8 100644
--- a/qt-ui/printoptions.cpp
+++ b/qt-ui/printoptions.cpp
@@ -64,17 +64,39 @@ void PrintOptions::setup()
}
// print type radio buttons
-void PrintOptions::on_radioDiveListPrint_clicked(bool check)
+void PrintOptions::on_radioDiveListPrint_toggled(bool check)
{
if (check) {
printOptions->type = print_options::DIVELIST;
+
+ // print options
+ ui.printInColor->setEnabled(true);
+ ui.printSelected->setEnabled(true);
+
+ // print template
+ ui.deleteButton->setEnabled(true);
+ ui.editButton->setEnabled(true);
+ ui.exportButton->setEnabled(true);
+ ui.importButton->setEnabled(true);
+ ui.printTemplate->setEnabled(true);
}
}
-void PrintOptions::on_radioStatisticsPrint_clicked(bool check)
+void PrintOptions::on_radioStatisticsPrint_toggled(bool check)
{
if (check) {
printOptions->type = print_options::STATISTICS;
+
+ // print options
+ ui.printInColor->setEnabled(false);
+ ui.printSelected->setEnabled(false);
+
+ // print template
+ ui.deleteButton->setEnabled(false);
+ ui.editButton->setEnabled(false);
+ ui.exportButton->setEnabled(false);
+ ui.importButton->setEnabled(false);
+ ui.printTemplate->setEnabled(false);
}
}
diff --git a/qt-ui/printoptions.h b/qt-ui/printoptions.h
index 4903da09f..6d7ffffee 100644
--- a/qt-ui/printoptions.h
+++ b/qt-ui/printoptions.h
@@ -19,6 +19,7 @@ struct print_options {
struct template_options {
int font_index;
int color_palette_index;
+ int border_width;
double font_size;
double line_spacing;
struct color_palette_struct {
@@ -27,12 +28,14 @@ struct template_options {
QColor color3;
QColor color4;
QColor color5;
+ QColor color6;
bool operator!=(const color_palette_struct &other) const {
return other.color1 != color1
|| other.color2 != color2
|| other.color3 != color3
|| other.color4 != color4
- || other.color5 != color5;
+ || other.color5 != color5
+ || other.color6 != color6;
}
} color_palette;
bool operator!=(const template_options &other) const {
@@ -72,8 +75,8 @@ private
slots:
void printInColorClicked(bool check);
void printSelectedClicked(bool check);
- void on_radioStatisticsPrint_clicked(bool check);
- void on_radioDiveListPrint_clicked(bool check);
+ void on_radioStatisticsPrint_toggled(bool check);
+ void on_radioDiveListPrint_toggled(bool check);
void on_printTemplate_currentIndexChanged(int index);
void on_editButton_clicked();
void on_importButton_clicked();
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 400401655..c776f9fea 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -627,6 +627,17 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
eventItems.clear();
struct event *event = currentdc->events;
while (event) {
+ // if print mode is selected only draw headings, SP change, gas events or bookmark event
+ if (printMode) {
+ if (same_string(event->name, "") ||
+ !(strcmp(event->name, "heading") == 0 ||
+ (same_string(event->name, "SP change") && event->time.seconds == 0) ||
+ event_is_gaschange(event) ||
+ event->type == SAMPLE_EVENT_BOOKMARK)) {
+ event = event->next;
+ continue;
+ }
+ }
DiveEventItem *item = new DiveEventItem();
item->setHorizontalAxis(timeAxis);
item->setVerticalAxis(profileYAxis);
diff --git a/qt-ui/templateedit.cpp b/qt-ui/templateedit.cpp
index 94ed276b5..e4e6453ac 100644
--- a/qt-ui/templateedit.cpp
+++ b/qt-ui/templateedit.cpp
@@ -30,9 +30,11 @@ TemplateEdit::TemplateEdit(QWidget *parent, struct print_options *printOptions,
btnGroup->addButton(ui->editButton3, 3);
btnGroup->addButton(ui->editButton4, 4);
btnGroup->addButton(ui->editButton5, 5);
+ btnGroup->addButton(ui->editButton6, 6);
connect(btnGroup, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(colorSelect(QAbstractButton*)));
ui->plainTextEdit->setPlainText(grantlee_template);
+ editingCustomColors = false;
updatePreview();
}
@@ -59,12 +61,14 @@ void TemplateEdit::updatePreview()
ui->colorLable3->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color3.name() + "\";}");
ui->colorLable4->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color4.name() + "\";}");
ui->colorLable5->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color5.name() + "\";}");
+ ui->colorLable6->setStyleSheet("QLabel { background-color : \"" + newTemplateOptions.color_palette.color6.name() + "\";}");
ui->colorLable1->setText(newTemplateOptions.color_palette.color1.name());
ui->colorLable2->setText(newTemplateOptions.color_palette.color2.name());
ui->colorLable3->setText(newTemplateOptions.color_palette.color3.name());
ui->colorLable4->setText(newTemplateOptions.color_palette.color4.name());
ui->colorLable5->setText(newTemplateOptions.color_palette.color5.name());
+ ui->colorLable6->setText(newTemplateOptions.color_palette.color6.name());
// update critical UI elements
ui->colorpalette->setCurrentIndex(newTemplateOptions.color_palette_index);
@@ -102,7 +106,10 @@ void TemplateEdit::on_colorpalette_currentIndexChanged(int index)
newTemplateOptions.color_palette = blueshades_colors;
break;
case CUSTOM: // custom
- newTemplateOptions.color_palette = custom_colors;
+ if (!editingCustomColors)
+ newTemplateOptions.color_palette = custom_colors;
+ else
+ editingCustomColors = false;
break;
}
updatePreview();
@@ -121,7 +128,7 @@ void TemplateEdit::saveSettings()
printOptions->p_template = "custom.html";
TemplateLayout::writeTemplate("custom.html", ui->plainTextEdit->toPlainText());
}
- if (templateOptions->color_palette_index == 2) {
+ if (templateOptions->color_palette_index == CUSTOM) {
custom_colors = templateOptions->color_palette;
}
}
@@ -148,6 +155,7 @@ void TemplateEdit::on_buttonBox_clicked(QAbstractButton *button)
void TemplateEdit::colorSelect(QAbstractButton *button)
{
+ editingCustomColors = true;
// reset custom colors palette
switch (newTemplateOptions.color_palette_index) {
case SSRF_COLORS: // subsurface derived default colors
@@ -155,11 +163,11 @@ void TemplateEdit::colorSelect(QAbstractButton *button)
break;
case ALMOND: // almond
newTemplateOptions.color_palette = almond_colors;
- custom_colors = newTemplateOptions.color_palette;
break;
case BLUESHADES: // blueshades
newTemplateOptions.color_palette = blueshades_colors;
- custom_colors = newTemplateOptions.color_palette;
+ break;
+ default:
break;
}
@@ -168,24 +176,35 @@ void TemplateEdit::colorSelect(QAbstractButton *button)
switch (btnGroup->id(button)) {
case 1:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color1, this);
- newTemplateOptions.color_palette.color1 = color;
+ if (color.isValid()) {
+ newTemplateOptions.color_palette.color1 = color;
+ }
break;
case 2:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color2, this);
- newTemplateOptions.color_palette.color2 = color;
- break;
+ if (color.isValid()) {
+ newTemplateOptions.color_palette.color2 = color;
+ } break;
case 3:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color3, this);
- newTemplateOptions.color_palette.color3 = color;
- break;
+ if (color.isValid()) {
+ newTemplateOptions.color_palette.color3 = color;
+ } break;
case 4:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color4, this);
- newTemplateOptions.color_palette.color4 = color;
- break;
+ if (color.isValid()) {
+ newTemplateOptions.color_palette.color4 = color;
+ } break;
case 5:
color = QColorDialog::getColor(newTemplateOptions.color_palette.color5, this);
- newTemplateOptions.color_palette.color5 = color;
- break;
+ if (color.isValid()) {
+ newTemplateOptions.color_palette.color5 = color;
+ } break;
+ case 6:
+ color = QColorDialog::getColor(newTemplateOptions.color_palette.color6, this);
+ if (color.isValid()) {
+ newTemplateOptions.color_palette.color6 = color;
+ } break;
}
newTemplateOptions.color_palette_index = CUSTOM;
updatePreview();
diff --git a/qt-ui/templateedit.h b/qt-ui/templateedit.h
index 15b717f78..5e548ae19 100644
--- a/qt-ui/templateedit.h
+++ b/qt-ui/templateedit.h
@@ -31,6 +31,7 @@ private slots:
private:
Ui::TemplateEdit *ui;
QButtonGroup *btnGroup;
+ bool editingCustomColors;
struct template_options *templateOptions;
struct template_options newTemplateOptions;
struct print_options *printOptions;
diff --git a/qt-ui/templateedit.ui b/qt-ui/templateedit.ui
index 238e69290..322193cc6 100644
--- a/qt-ui/templateedit.ui
+++ b/qt-ui/templateedit.ui
@@ -317,7 +317,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>Table cells</string>
+ <string>Table cells 1</string>
</property>
</widget>
</item>
@@ -347,9 +347,9 @@
</layout>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
- <widget class="QLabel" name="label_7">
+ <widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -357,7 +357,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>Text 1</string>
+ <string>Table cells 2</string>
</property>
</widget>
</item>
@@ -387,9 +387,9 @@
</layout>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
- <widget class="QLabel" name="label_11">
+ <widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -397,7 +397,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>Text 2</string>
+ <string>Text 1</string>
</property>
</widget>
</item>
@@ -427,9 +427,9 @@
</layout>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
- <widget class="QLabel" name="label_4">
+ <widget class="QLabel" name="label_11">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -437,7 +437,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>Borders</string>
+ <string>Text 2</string>
</property>
</widget>
</item>
@@ -467,6 +467,46 @@
</layout>
</item>
<item>
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Borders</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="colorLable6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>color6</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="editButton6">
+ <property name="text">
+ <string>Edit</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>