Commit graph

22 commits

Author SHA1 Message Date
Robert C. Helling
e27653374d Add printing option for page orientation
Strangely enough, half of the infrastructure was
already there, it just wasn't hooked up to a UI
element

Signed-off-by: Robert C. Helling <helling@atdotde.de>
2023-03-28 21:08:37 -07:00
Berthold Stoeger
cea171ffd4 core: implement an enumerating iterator
In the printing-template code, we loop through a vector and
then determine the index of the current element by searching
the vector. This irks me.

Since looping over a collection with an index is a rather
common theme, implement an enumerating iterator that can
be used as in:
	for (auto [idx, item]: enumerated_range(v)) {
		...
	}

For now, use it for the above vexing case. Convert other
iterations of this theme later.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2022-10-30 21:57:39 +01:00
Berthold Stoeger
fa6eb6144b printing: move #includes from headers to source files
To decrease include-file interdependencies.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
0cbb448740 cleanup: make templateOptions and printOptions reference types
These two structs describe options used during printing.
They are passed through numerous classes as pointer. In this
case, reference semantics are preferred, as references:
 - can never be null
 - can not change during their lifetime
This not only helps the compiler, as it can optimize away null
checks, but also your fellow coder. Moreover, it prevents
unintentional creation of uninitialized references: one can't
create an instance of a class without initializing a reference
member. It does not prevent references from going dangling.
However, pointers have the same disadvantage.

Contains a few whitespace cleanups.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-12-17 13:03:56 -08:00
Berthold Stoeger
0272f118ae printing: properly initialize DPI value
The DPI value in the print_options structure was never initialized.
This could lead to random DPI values and crashes. How this ever
worked is a mystery.

Therefore, read and write the DPI value from the settings just
as the other print-options. And initialize the corresponding dialog
widget to this value.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-11-12 11:20:54 -08:00
Robert C. Helling
8f6d054140 Set printer resolution
You need a better resolution to plot a picture with high resolution...

Connection done with a lambda expression thanks to @dirkhh.

Signed-off-by: Robert C. Helling <helling@atdotde.de> (+1 squashed commit)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-03 11:46:16 -07:00
Rolf Eike Beer
e3d43b5696 replace deprecated qSort() with std::sort()
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12 12:59:17 +03:00
Berthold Stoeger
36b9e5e31e Cleanup: fold core/helpers.h into core/qthelper.h
helpers.h included qthelper.h and all functions declared in helpers.h
were defined in qthelper.h. Therefore fold the former into the latter,
since the split seems completely arbitrary.

While doing so, change the return-type of get_dc_nichname from
"const QString" to "QString".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-04 08:50:10 -07:00
Martin Měřinský
fa7b93ba5b Fix typo connot > cannot.
Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-28 11:36:19 +02:00
Lubomir I. Ivanov
712697e0c2 printing: detect a 'statistics' template when editing
Prefix the path for 'statistics' templates when
detecting if a template is read-only.

Import / Export for statistic templates is not supported.
So the user has to manually copy and chown a '/statistics'
templates.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 22:27:30 +02:00
Lubomir I. Ivanov
ba7f2a399b printing: handle overwriting in import / export
Show an error message if trying to:
1) Import over an existing read-only template with the same name
2) Export to a read-only file with the same name
3) Delete a read-only template

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 22:27:30 +02:00
Lubomir I. Ivanov
c57df085a4 printing: make sure that exported templates are .html
Thus far the exported template did not had the .html
extension. This patch makes sure that the extension
is always added to the file if missing.

Also handle the case where the user used ".htm" and
replace that with ".html".

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 22:27:30 +02:00
Lubomir I. Ivanov
a2ec791f2f printing: store the last import / export template
Store the last template file name which the user
imported / exported and then try to pre-select
it in the combo box.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 21:50:16 +02:00
Lubomir I. Ivanov
bc6146577d printing: improve messaging in printoptions.cpp
1) on_deleteButton_clicked() show a proper message box with
icon title and also quote the file name.
2) When exporting a file, make sure that the destination is not
read-only even if the source is.
3) Do not allow editing of read-only templates (e.g. the bundled ones).
Instruct the user to Export first.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 21:50:16 +02:00
Lubomir I. Ivanov
c6c9b3bd8b printing: minor improvements to import / export
1) Always open the user path on Import / Export
2) Update the list after Export, as the user might
have exported to the user path

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-11-24 21:50:16 +02:00
Stefan Fuchs
8b56dc30d7 Correct, cleanup, translate and unify file filters
Correct spelling and typos in file filters.
Unify and translate file filter names.

Don't pass a file filter to a directory open dialog - not needed.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-11-04 14:27:00 +01:00
Lubomir I. Ivanov
e9673938fb printoptions.cpp: correctly remember the last selected template
To find the last selected template index in the combo box,
comparing against `printOptions->p_template` would work fine,
except the `on_printTemplate_currentIndexChanged()` slot updates
`printOptions->p_template` each time QComboBox::addItem() is
called. This makes the `for` loop to add new combo box items
and find the index of the last selected template not possible.

To work around the issue, a local QString variable `storedTemplate`
is introduced and it does not change during the `for` loop.

Fixes #595

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2017-10-19 14:04:38 +03:00
Dirk Hohndel
9021a44ccc Add SPDX header to desktop widgets
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Linus Torvalds
ad2ac58ea2 Fix include paths
As expected, commit 7be962bfc2 ("Move subsurface-core to core and qt-mobile
to mobile-widgets") caused some breakage.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-05 09:40:58 -07:00
Tomaz Canabrava
dec2572ec6 Don't if true then true
Set the values directly, seems much more sane.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-08 10:02:20 -08:00
Tomaz Canabrava
1210d4b575 Simplify code on the printingDialog
instead of duplicate the code that only chaged the QList that it
would access, create a temporary list and use it for dealing
with the code.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-01-08 10:01:51 -08:00
Tomaz Canabrava
e49d6213ad Move qt-ui to desktop-widgets
Since we have now destkop and mobile versions, 'qt-ui' was a very
poor name choice for a folder that contains only destkop-enabled
widgets.

Also, move the graphicsview-common.h/cpp to subsurface-core because
it doesn't depend on qgraphicsview, it merely implements all the
colors that we use throughout Subsurface, and we will use colors on both
desktop and mobile versions

Same thing applies for metrics.h/cpp

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-30 10:36:49 -07:00
Renamed from qt-ui/printoptions.cpp (Browse further)