The Qtr_ hack isn't needed as in commit 720fc15b2dcd ("Introduce
QApplication") had already made sure that we are using gettext.
I didn't revert the two commits as I wanted to keep the added header
comments and fix the tooling in the Makefile as well.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This should wrap gettext nicely and replace the "_()" macros we use in C
code.
Also added comments to the top of all the new files.
Suggested-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
1 - Open File already open files, it tries to not break the Gtk version,
but some methods on the GTK version still need to be called inside Qt
because the code is too tight-coupled.
2 - Close file already close files, same comments for the open file dialog
applies here.
3 - The code for adding new cylinders in the cylinder dialog is done,
already works and it's integrated with the system. There's a need to
implement the edit and delete now, but it will be easyer since I'm
starting to not get lost on the code.
4 - Some functions that were used to convert unities have been moved to
convert.h ( can be changed later, put there because it's easyer to
find something that converts in a convert.h =p ) because they were
static functions that operated in the GTK version but I need those
functions in the Qt version too.
[Dirk Hohndel: lots and lots of whitespace and coding style changes]
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add files for dive list model/view implementation. Replace TableView
with the custom list view. Amendments to makefile to match.
Note: we don't yet handle trips and may want to add additional columns
to describe the dive.
A single, dummy dive is added to show how this works (get root; item is
child of root). Purely to illustrate - needs proper integration etc.
Amend member names for dive list view components
Various naming changes to conform to coding style. Required changes to
members (remove prefix) and methods (avoid clash with members).
Clean up indentation (swap spaces for tabs). Code for model/view was
written with a different editor which had different settings :-/
[Dirk Hohndel: minor whitespace cleanup]
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Rename the 3 main widgets in the Qt mainwindow.
Wire view menu options to the setVisible methods of same.
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
As Thiago wrote: qDebug("actionNew") also works. The current policy is to avoid
C++ style source code as much as possible.
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Naming of QActions was inconsistent wrt abbreviations - fixed.
Add stub slots for each action relying on connect by name.
Add qDebug() message to allow people to check that menu items fire
slots; not really necessary but may provide some reassurance as we build
familiarity with Qt.
Some changes to display text for menu items (e.g. Tree becomes View
All).
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add some magic rules to detect which files need to be processed by the
moc or uic tools, as well as a way to manually specify exceptions.
Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
For some reason, 'private slots:' causes a build error but private
Q_SLOTS: works.
The error was that 'slots' did not name a type and it appeared to be
insensitive to whether the Makefile rule for .moc was in its current
place or preceeded the rule for .cpp.
Add a slot using the connectByName idiom e.g. actionNew connects to slot
on_actionNew_triggered(). Use qDebug to show this fires if the menu
option is selected.
Above to demonstrate how to begin to link menu to code paths.
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Names for individual tab widgets were not specific and caused warnings
from UIC. Rename the individual widgets to reflect purpose.
[Dirk Hohndel: removed some of the hunks that appeared to be unintentional
changes not mentioned in the commit log]
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is fron Alberto's first stab at MainWindow, but Tomaz is doing all
this work in the qt-ui directory now...
Reported-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Most of the warnings are IMHO false positives:
e.g.: an enum variable is initialized in a switch statement that has a case for
each possible enum value - yet gcc 4.8 warns that it could be used
uninitialized;
or: two variables are initialized together in the code - second one of them
is previously initialized to -1 at declaration time, both are initialized
in an if (second one == -1) clause - so they are guaranteed to both be
initialized...
I did not "fix" those as the code is actually correct.
But there are three spots where it catches things that could indeed go wrong
(with odd input data in one of them).
This commit also adds a check to only call g_type_init() for older versions of
glib as in newer ones it is deprecated.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Relatively straight forward, just a handful of places where we call
show_error() (a UI function) from the logic code. In the process I noticed
a few places where error returns weren't dealt with correctly.
Added a new planner.h files for the necessary declarations.
This should make no difference to functionality.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is based on several commits from Tomaz - mingled together and mildly
extended by Dirk (mostly Makefile hacking).
All Qt UI related stuff should eventually move into the qt-ui directory.
So the Makefile rules for moc and uic have been adjusted accordingly.
The MainWindow class has been moved into its own file in qt-ui (but just
with a placeholder, the existing class has simply been ifdef'ed out in
qt-gui.cpp for the moment).
We still have a couple of Qt things in qt-gui.cpp in the main directory...
all this needs to move into the qt-ui directory and be built with separate
.h files. Right now we have the one-off Makefile rule to create the
qt-gui.moc file from the qt-gui.cpp file.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is simplistic & brute force: any function that touches Gtk related
data structures is moved to divelist-gtk.c, everything else stays in
divelist.c.
Header files have been adjusted so that this still compiles and appears to
work. More thought is needed to truly abstract this out, but this seems to
be a good point to commit this change.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is just an empty window with a File menu and a few items.
It shows how to hook up functions to menu actions.
Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Remove the boolean parameter from parse_file; the code is more readable
by having an explicit call to set_filename() where necessary, rather
than a boolean parameter.
Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
The previous rules were conflicting, and the naming of the moc-generated
file to be included in .cpp files was deviating from what's most used in
Qt: the usual way is to
#include "file.moc"
and not
#include "file.moc.cpp"
Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
This prevents Qt headers from defining macro symbols such as "emit" and
"signals", therefore avoiding conflicts when struct members with the
same names are defined in some C header.
Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
The signatures for subsurface_get_conf* in windows.c and macos.c
was slightly different from those in linux.c, which broke the
build (at least on Mac).
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instantiate a QApplication and let Qt handle the event loop.
Add a QTranslator subclass to translate the UI via gettext.
Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Rename gtk-gui.c to qt-gui.cpp, and make the necessary changes so that
the project still builds.
Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
Setup the build variables for building with QtWidgets, and add rules for
processing the Q_OBJECT macros with moc and generate widget code from
.ui files with uic.
Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
The pressure interpolation code mostly worked for the simple cases, but
got terminally confused for some more complex gas change situations,
resulting in nonsensical interpolations.
This simplifies and clarifies the code a bit, and in the process fixes a
few special cases where the gas interpolation segments didn't end up
having the end conditions set.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
They do the "02=0 means air" thing autmatically, and make for less
typing. So use them more widely in places that looked up the o2 and he
permille values of a gasmix.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
get_cylinder_index() looks up which cylinder to use based on the
gaschange event that describes the mix. However, it was both buggy and
not very good.
It was buggy because it didn't understand about our air rules, and it
was not very good because it required an exact match (after rounding our
permille-based numbers to percent).
So fix it to use the right permille values, and look for a closest match
(using the normal sum-of-squares distance function - although I wonder
if we should consider helium percentages to be "more important" and give
them a stronger weight).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
.. so that different computers that have different ordering of the same
cylinders will see the end result the same way.
This also fixes up the sample sensor index and generates special initial
tank change events for the dive computers that had their cylinder
indexes renamed on them.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In planning you usually plan lengths of segments rather than runtimes to
leave a level.
This patch superseeds a previous one with a similar name and (even more)
broken spacing.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In save_window_geometry() use gdk_window_get_state() to retrieve
the window maximized state and store it in the user configuration.
Then in restore_window_geometry() restore the maximized state with
gtk_window_maximize(), if needed.
To achieve good results we also need to override "window-state-event"
for the main window and define an extra couple of configuration parameters:
"vpane_position_maximized" and "hpane_position_maximized".
Then store two different pane states for maximized and restored window each
time the user makes a switch.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Valid divelogs.de export might contain non-ascii characters in CDATA
fields as long as these characters are found in iso-8859-1. So we'll
have to test to make sure the content is fully ascii before calling
xmlStringLenDecodeEntities to decode possible character references.
Acked-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Some colors such as the ones for ceiling were still green on B/W
print. This patch makes all colors in the second row
of profile.c:profile_color monochrome.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While working on UDDF export I noticed that the grabbing of last
sample pressure was not working properly. This will fix it for DLD
export.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Examples on UDDF specification indicate that pressures are reported in
Pascal. Also prefer the sample data from first dive computer for start
and end tank pressures.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch generates a gases section on UDDF export. The section
consists of all the unique gas mixes sawn on the dive log.
The latter part includes events to the export. Gas change and heading
events are properly translated to respective UDDF naming. Other events
are copied over as is. Some of the events are the same (ascent, deco,
rbt, surface) in UDDF some are not available.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The window which holds the custom print options tab appears to have
unchangeable dimensions on Windows OS (unless hacked in some way).
This makes the sliders in the custom tab not accessible unless
we add the entire dialog into a GtkScrolledWindow and return that
for the "create-custom-widget" event.
The patch also makes the contents of the "Layout Options" frame
packed vertically (with a GtkVBox) instead of horizontally, so that
the entire tab contents are "mostly" scrollable vertically instead
of horizontally.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Also make the profile border color the same as the depth grid color.
Fixes#97
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This replaces the hardcoded sizes all over the sources.
Make the size in the text_render_options_t a double - With this you can
compile Subsurface with
make CLCFLAGS=-DTEXT_SCALE=1.5
and the fonts in the profile are 50% bigger. Very nice on a high-pixel
density display.
Also remove the unused text_render_options for event text.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch implements exporting dives from Subsurface to UDDF format.
Events and cylinder info are the most remarkable things still missing
from the export.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While colorButton defaults to "color" in first access to print menu, it seems
preferable to keep the last state selected by the user. At least until exit session.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
close() should be included from unistd.h, instead of fcntl.h for
better portability.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
92.5 is wrong the correct divisor is its inverse number 108.1
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While it makes sense for the program to have a 7.5% fixed header, from a
user perspectice this is just odd. So instead we now have the notes,
profile and tank data sizes add up to 100% and scale the information when
it is combined with the header.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>