Commit graph

2091 commits

Author SHA1 Message Date
Dirk Hohndel
d8e11439ad Undoing the last Qtr_ hack
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>
2013-04-14 06:58:56 -07:00
Dirk Hohndel
fc0e307f00 Add common.h file
Oops

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-14 06:21:32 -07:00
Dirk Hohndel
f5c958ad73 Add Qtr_ macros that uses gettext in a tr() compatible manner
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>
2013-04-13 20:44:02 -07:00
Thiago Macieira
14e133321f Remove the mandatory -fPIC from CXXFLAGS
This isn't necessary. There's code below adding -fPIE when necessary
only.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-13 19:38:09 -07:00
Tomaz Canabrava
92397a2bad Started the real code on the Qt Interface.
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>
2013-04-13 14:08:16 -07:00
Amit Chaudhuri
76f71b4ca0 Add dive list view to main window
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>
2013-04-12 12:54:08 -07:00
Alberto Mardegan
9dbda9f62a Update .gitignore
Ignore some moc/uic-generated files.

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
2013-04-10 19:02:06 +04:00
Alberto Mardegan
ec8c2b9368 MainWindow: remove useless include
This was accidentally reintroduced by a previous commit, and was causing
a moc warning.

Signed-off-by: Alberto Mardegan <mardy@users.sourceforge.net>
2013-04-10 19:00:20 +04:00
Amit Chaudhuri
6e02e9d5b7 Add logic to switch views
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>
2013-04-10 07:35:07 -07:00
Henrik Brautaset Aronsen
55106a7583 Avoid C++ style streams
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>
2013-04-10 07:31:14 -07:00
Amit Chaudhuri
1182c98997 Add stub slots for all menu items
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>
2013-04-09 22:49:13 -07:00
Alberto Mardegan
99153de715 Makefile: detect which files need moc and uic
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>
2013-04-09 19:54:41 -07:00
Dirk Hohndel
80c8d08d8b Make Qt branch cross-build for Windows
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-09 07:01:20 -07:00
Amit Chaudhuri
a94e09ad5c Add a slot to mainwindow but amend to use Q_SLOTS
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>
2013-04-09 06:50:42 -07:00
Amit Chaudhuri
e865aed478 Change tab widget names.
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>
2013-04-08 12:58:06 -07:00
Dirk Hohndel
d3c0a90e34 Remove the toplevel ui directory
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>
2013-04-08 09:36:38 -07:00
Dirk Hohndel
459dc08c32 Forgot to add planner-gtk.c
Oops

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-07 20:33:48 -07:00
Dirk Hohndel
4cf244e228 Fix some of the gcc-4.8 warnings
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>
2013-04-07 20:25:14 -07:00
Dirk Hohndel
1d02ba12a3 Separate Gtk related code from core logic: planner
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>
2013-04-07 20:22:41 -07:00
Tomaz Canabrava
ba712c3b54 Start creating the Qt UI
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>
2013-04-07 15:59:33 -07:00
Dirk Hohndel
081000963a Continue to separate Gtk related code from core logic: divelist
Move some more logic out of the divelist-gtk.c file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-04-06 21:28:42 -07:00
Dirk Hohndel
1d61955be9 Separate Gtk related code from core logic: divelist
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>
2013-04-06 20:49:06 -07:00
Alberto Mardegan
a412753b0a Add a Qt main window
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>
2013-04-02 19:55:53 +03:00
Alberto Mardegan
2f759f52e1 Move set_filename() calls outside of parse_file()
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>
2013-04-02 19:55:44 +03:00
Alberto Mardegan
40e3671bd2 Improve Makefile rules for running moc
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>
2013-04-01 23:11:25 +03:00
Alberto Mardegan
b5b14f1d95 Define QT_NO_KEYWORDS
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>
2013-04-01 23:07:47 +03:00
Henrik Brautaset Aronsen
f2ab8f42ee Match subsurface_get_conf* in windows/macos.c with linux.c
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>
2013-04-01 10:01:01 -07:00
Alberto Mardegan
7ea2281180 Introduce QApplication
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>
2013-04-01 16:03:59 +03:00
Alberto Mardegan
578d633d01 Have some C++ file in the project
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>
2013-04-01 16:03:59 +03:00
Alberto Mardegan
42365ede79 Setup Makefile for Qt/C++ builds
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>
2013-04-01 16:03:43 +03:00
Linus Torvalds
218fd994ee Fix cylinder pressure interpolation
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>
2013-03-28 13:47:36 -07:00
Linus Torvalds
1b05d28944 Use the new get_o2()/get_he() helper functions more widely
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>
2013-03-28 13:47:31 -07:00
Linus Torvalds
99070c49e2 Fix get_cylinder_index() gasmix comparisons
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>
2013-03-28 13:47:28 -07:00
Linus Torvalds
f2f29665d4 When merging dives, match up the cylinders to each other using gasmix
.. 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>
2013-03-28 13:47:23 -07:00
Robert C. Helling
c083ec45a9 Make relative times default in planner 2
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>
2013-03-26 19:30:38 -07:00
Lubomir I. Ivanov
2a6fded3b7 gtk-gui.c: Some small whitespace indentation fixes
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-03-26 19:26:55 -07:00
Lubomir I. Ivanov
c2520125d1 Store the main window maximized state in the configuration
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>
2013-03-26 19:26:43 -07:00
Miika Turkia
ed9c9051d2 Check if DLD contains non-ascii characters
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>
2013-03-26 13:15:38 -07:00
Lubomir I. Ivanov
61473080a5 B/W Print: Make sure that all colors are monochrome
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>
2013-03-26 12:55:56 -07:00
Miika Turkia
5533cd749f Fix end pressure on DLD export
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>
2013-03-26 12:52:39 -07:00
Miika Turkia
ac5881c3fe Fix pressures on UDDF export
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>
2013-03-26 12:52:30 -07:00
Miika Turkia
b18f9fa057 Gases and events support for UDDF export
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>
2013-03-26 12:51:19 -07:00
Lubomir I. Ivanov
23ec2a9cb4 Print dialog: Fix inaccessible controls on Windows
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>
2013-03-26 12:13:19 -07:00
Lubomir I. Ivanov
578851bef3 Color print: Show SAC lines in a color different from white
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>
2013-03-26 12:12:54 -07:00
Dirk Hohndel
826401a39c Add macros for text sizes
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>
2013-03-25 18:05:45 -07:00
Miika Turkia
12d5ab4ce3 Export dives to UDDF file
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>
2013-03-24 06:37:56 -07:00
Salvador Cuñat
ca0ecc234a Print_c Make colorButton remember last state during session
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>
2013-03-20 13:31:02 -07:00
Lubomir I. Ivanov
5766e299c3 divelist.c: Fix an 'implicit declaration' warning
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>
2013-03-20 10:23:25 -07:00
Salvador Cuñat
d2b87bb086 Fix error while translating base of height calculation in print function
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>
2013-03-19 19:16:15 -07:00
Dirk Hohndel
c9af18b9cd Rescale print layout sizes to add to 100%
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>
2013-03-19 14:25:38 -07:00