Commit graph

14361 commits

Author SHA1 Message Date
jan Iversen
f1648d297b core: qPref replace COPY_TXT with copy_txt in qPrefPrivate
Add copy_txt function to qPrefPrivate class
Remove macro COPY_TXT from qPrefPrivate.h
Replace use of COPY_TXT with copy_txt in qPref classes

copy_txt is only once, COPY_TXT was expanded approx. 160 times, so
this commit saves space (and removes a macro).

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-25 08:35:04 -07:00
Berthold Stoeger
597aa75348 Update CHANGELOG.md
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23 15:58:55 -07:00
Berthold Stoeger
b3feaa80e2 Dive video: paint duration-bar above thumbnail in profile plot
Paint a rectangle on top of thumbnails indicating the run-time
of the video.

Use the z=100.0-101.0 range for painting the thumbnails, whereby
the z-value increases uniformly from first to last thumbnail
(sorted by timestamp). The duration-bars are placed at z-values
midway between those of the thumbnails.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23 15:58:55 -07:00
Berthold Stoeger
c742885984 Dive media: prepare for video-thumbnails
Video thumbnails are more complex than simple picture thumbnails.
We store a duration and might want to store multiple images.

Therefore, refactor the thumbnailing in imagedownloader.cpp. Move
the thumbnail-writing down in the call chain to where the thumbnails
are created, since we have more information there (i.e. whether we
could parse the file but not extract an image, etc.).

Split the write-to-cache function into three versions:
  - pictures
  - videos
  - unknown

Define the video-thumbnail on-disk format as
  - uint32  MEDIATYPE_VIDEO
  - uint32  duration of video in seconds
  - uint32  number of pictures
  for each picture:
	- uint32  offset in msec from begining of video
	- QImage  frame

Currently, we write 0 pictures. This will be filled in subsequent commits.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23 15:58:55 -07:00
Berthold Stoeger
7dd49acf4b Cleanup: remove DiveItem::icon_names member array
Each DiveItem (which is a wrapper around diveId with some virtual
functions), had a member icon_names, which is an array of
four QStrings. These were not used anywhere and must be an obscure
oversight and was probably planned as a static cons array?.
In any case, remove it.

There *was* a function-local analogous icon_names array in
DiveItem::data() though. This array would initialize four
QStrings from C-string literals on every invocation. Make
this array static, local to the translation unit and use
the QStringLiteral macro to construct the QString object at
compile-time.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-23 17:05:15 +03:00
jan Iversen
be50ee2017 tests: add CloudStorage qml test cases
Add tst_qPrefCloudStorage qml file to test C++ qml connection

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-21 07:49:25 -07:00
jan Iversen
be8e93d28a tests: move CloudStorage test from testpreferences
Remove CloudStorage test in testpreferences
add the same CloudStorage tests to testqPrefCloudStorage

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-21 07:49:25 -07:00
jan Iversen
cabdf71bf7 tests: add qPrefCloudStorage testcases
add test cases to secure struct preferences and qPrefCloudStorage work together

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-21 07:49:25 -07:00
jan Iversen
b9b1f03f0d core: activate qPrefCloudStorage
remove CloudStorage from SettingsObjectWrapper and reference qPrefCloudStorage

update files using SettingsObjectWrapper/CloudStorage to use qPrefCloudStorage

this activated qPrefCloudStorage and removed the similar class from
SettingsObjectWrapper.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-21 07:49:25 -07:00
jan Iversen
4b68329c9d core: create qPrefCloudStorage from SettingsObjectWrapper
Update set/get functions to follow common name scheme:
- get function have same name as in struct preferences
- set function have set_<name> (from struct preferences>)
- signal function have <name>_changed (from struct preferences>)

one class one .h/.cpp is the C++ idiom. Having load/sync of each
variable in 1 functions (in contrast to the distributed way SettingsObjectWrapper
handles it) secures the same storage name is used. Having the set/get/load/sync
functions grouped together makes it easier to get an overview.

REMARK: this commit only defines the class, it is not active in production
Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-21 07:49:25 -07:00
Berthold Stoeger
f23425c558 Uninline functions in dive.h
There were numerous inlined functions in dive.h. For many of them
inlining is dubious. Let's uninline most of them, with the exception
of trivial accessors and interpolate().

On current master, this gave a size reduction of 5 pages:

-rwxrwxr-x 1 bs bs 5863656 Jul 18 20:57 subsurface-inline
-rwxrwxr-x 1 bs bs 5843176 Jul 18 20:48 subsurface-noinline
-----------------------------------------------------------
                     20480

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-21 07:46:44 -07:00
Berthold Stoeger
6b9380efb0 Fetch sqlite from https:// site
The http:// version is down an makes Travis fail.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-21 00:14:49 +03:00
Berthold Stoeger
4bb56db35e Update CHANGELOG.md
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-20 08:29:27 +02:00
Berthold Stoeger
4f42e4fd50 Dive media: implement "Open folder of selected media files"
Add a context-menu entry to TabDivePhotos which opens the folder(s)
of all selected files.

Fixes #1514.

Suggested-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-20 08:29:27 +02:00
Berthold Stoeger
325b8bba35 Undo: remember deleted trip in UndoRemoveDivesFromTrip::undo()
If the last dive of a trip is removed, the trip is deleted.
On redo the dive is added to a non existing trip, leading to a
segfault.

Therefore, keep a copy of the trip to reinstate it on redo.
Note: this cannot work for a sequence of multiple commands.
One would have to rewrite the whole undo-history. Nevertheless,
let's do this as a stop-gap measure.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-19 02:43:08 +03:00
Berthold Stoeger
b51e616b6a Undo: clear list of trips to be recreated in UndoDeleteDive::undo()
UndoDeleteDive::tripList kept track of the trips to be recreated on
undo. But the list wasn't cleared on undo, thus on subsequent redo
the same trip was readded to the list, leading to double-free.

This could trivially be reproduced by repeated CTRL-Z, CTRL-SHIFT-Z
pairs.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-19 02:43:08 +03:00
jan Iversen
6c95714b9f tests: update qPrefAnimations test cases
remove include of QtTest in header, becaue it is not needed,
add include of QObject in header, so moc can generate code.
add QTest in cpp file, which replaces QtTest

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-18 10:40:08 -07:00
jan Iversen
0363e590f3 tests: update qPrefDisplay test cases
remove include of QtTest in header, becaue it is not needed,
add include of QObject in header, so moc can generate code.
add QTest in cpp file, which replaces QtTest

Change content of strings to test divelist_font to a not normal
font name, to ensure less confusion by readers. Remark the old
surrounding code accept illegal font names, but correcting this
is not covered in this commit.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-18 10:40:08 -07:00
jan Iversen
3c3729711c core: remove QSettings in qPref* and use a shared variable
Add qPrefPrivate class which contains one QSettings variable,
delete QSettings from qPref* class definitions

this secures there are only instance of QSettings
(QSettings needs to be in a QObject class to work)

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-18 10:40:08 -07:00
jan Iversen
c0e9e978a1 core: remove include QSettings from QPref
remove QSettings header file from qPref.h (which is included in many files)
to isolate the use of QSettings in the total system.

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-18 10:40:08 -07:00
jan Iversen
4719af308f tests: update CMakeLists.txt to incude qPref* in both places
Files are listed in 2 places in CMakeLists.txt, update file to
secure qPrefAnimations and qPrefDisplay are listed correctly

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-18 10:40:08 -07:00
Berthold Stoeger
c5f66c5538 Dive media: transport dive-id in drag'n'drop events
9efb56e2d4 introduced rather complex
logic for picture drag'n'drop events onto the profile. Among other
things, the code had to check whether the picture actually belongs
to the displayed dive.

This can be simplified by transporting the dive-id in the drag'n'drop
event structure. The flow goes like this:
DivePictureModel--(1)-->DivePictureWidget--(2)-->ProfileWidget

For (1), we can use the Qt::UserRole role. This was used to transport
the picture-offset, but this is not needed anymore since ProfileWidget
was decoupled from DivePictureModel.

For (2), we simply replace the "position" value, which was never used.
Why would the receiver care which pixel was pressed in the media-tab?

This commit also contains a minor cleanup in DivePictureWidget:
QListView::mousePressEvent(event) was called in both branches of an
if and can therefore be removed from the if. This is so trivial,
that it doesn't warrant its own commit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 09:06:37 -07:00
Berthold Stoeger
8ff7314b21 Cleanup: rename trip->index to trip->saved
The index-field was misused by the IO routines to mark which dives
had been saved. Somewhat questionable, but let's at least name the
field accordingly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 09:04:47 -07:00
Berthold Stoeger
3a933637da Cleanup: removed unused functions in divelist.h
find_trip_by_idx() and find_matching_trip() weren't used anywhere.
The trip index actually is only misused as a "trip saved"-flag.

trip_has_selected_dives() only existed as a comment.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 09:04:47 -07:00
Berthold Stoeger
b7bb9b4177 Bluetooth: don't call deviceDiscoveryError() on scan finished
In the remoteDeviceScanFinished slot, the old code called into
the deviceDiscoveryError() in case the device discovery agent
had the error flag set. This is not necessary, since the agent
will send an error signal in such a case.

For Qt's device discovery agent, the whole check-for-error is
unnecessary, as the documentation states:
"The signal is not going to be emitted if the device discovery
finishes with an error."

But for the homebrew WinBluetoothDeviceDiscoveryAgent, which
derives from QThread, both an error() *and* a finished()
signal will be sent. Therefore keep the test, but don't call
into the slot twice.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 02:11:16 +03:00
Berthold Stoeger
6d72871942 Cleanups to core/color.[c|hpp]
A number of small cleanups to the color-table:

1) Make the profile_color map of static linkage - it is not
used outside of this file.

2) Remove the third color, which originally was planned for
printing. It was not accessed anywhere.

3) Replace QVector<QColor> by std::array<QColor, 2>. Using a
reference-counted, copy-on-write, dynamic container for static
data seems like overkill. std::array<QColor, 2> has exactly the
same run-time impact as QColor[2], but allows for assignment.

4) Use brace-initialization and remove the unneeded COLOR macro.

5) Remove the fill_profile_color function. Simply use static
initialization.

6) Move #includes from .h to .cpp file.

7) Remove text_render_options(_t), which were not used anywhere.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-18 02:09:15 +03:00
Berthold Stoeger
2c6b1a99af Cleanup: simplify dive_getUniqID()
dive_getUniqID() is used to create unique dive ids, which are
stable during application lifetime. It was passed a dive, checked
that the id was not set (if it was that it is know to the application)
and set a new id (in contradiction to its name!) if it hadn't any.

There were three callers:

alloc_dive(): called the function on a zeroed dive struct.
fixup_dive(): called the function only if the dive had a 0 id.
MainWindow::setupForAddAndPlan(): called the function on a zeroed dive
struct.

Thus, in all three callers the id is guaranteed to be zero and
the whole keeping-track-of-ids logic is moot. Remove the logic,
don't pass a dive struct to dive_getUniqID() and move the function
to the C-backend.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-17 15:20:52 -07:00
Berthold Stoeger
4931b5a8e6 Dive media: fix stacking of thumbnails in profile plot
9efb56e2d4 added code to rearrange
pictures on drag'n'drop. To keep the correct repainting order (i.e.
later thumbnails are painted on top of previous thumbnails), the
z-value was set accordingly. In principle a sound idea, but it did
not work out, because on hoverEnter and hoverExit events, the z-values
were modified, thus restoring the wrong drawing order.

Instead, use the QGraphicsItem::packBefore() function. Experimentation
showed that this only works if stacking is done from the back
of the list.

Silence an erroneous compiler warning by initializing a variable to 0.0.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-16 23:29:21 +03:00
Berthold Stoeger
b53672507d Fix typo in INSTALL: add missing backspace at end of line
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-16 00:09:59 +03:00
Stefan Fuchs
397ff368d5 Update CHANGELOG.md
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-07-15 09:38:12 -07:00
Stefan Fuchs
bb2dfdfe54 For media file open dialog add different file filters
On top of the file filter for all media files add a file filter
for images only, one for videos only and one for all files.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-07-15 09:38:12 -07:00
Stefan Fuchs
669277d490 UI change of "images"/"photo" to "media" or "media files"
This changes the above mentioned terms everywhere in the UI to
reflect the fact that Subsurface now also supports video files on top
of image files.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-07-15 09:38:12 -07:00
jan Iversen
80761beb93 core: solve copy/paste error in qPref_private
DISK_LOADSYNC_INT used double correct to int

DISK_LOADSYNC_INT used double correct to int

Signed-off-by: Jan Iversen <jani@apache.org>Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-15 14:35:31 +02:00
jan Iversen
8d857a650d core: qPrefDisplay correct font setting.
SettingsObjectWrapper contained some delicate font handling mixing font and
font_size, breaking that into 2 parts broke font handling on some platforms

Copy font + font_size handling 1-1 from SettingsObjectWrapper

Signed-off-by: Jan Iversen <jani@apache.org>
2018-07-15 14:35:31 +02:00
Dirk Hohndel
55336bd7ad Merge branch 'metadata' of https://github.com/bstoeger/subsurface 2018-07-14 08:20:47 -07:00
Dirk Hohndel
dc22747cb0 Merge branch 'qPrefAnimations' of https://github.com/janiversen/subsurface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-14 08:16:14 -07:00
Dirk Hohndel
e834874a7a Merge branch 'qPrefDisplay' of https://github.com/janiversen/subsurface 2018-07-14 08:14:31 -07:00
Dirk Hohndel
cf329ca131 Merge branch 'qml_test' of https://github.com/janiversen/subsurface
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-14 08:12:27 -07:00
Berthold Stoeger
cf73afb452 Update CHANGELOG.md
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-14 08:34:10 +02:00
Berthold Stoeger
772935b596 Metadata: Parse ASFs (=WMVs)
The simplest video-formats to parse so far.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-14 08:32:30 +02:00
Berthold Stoeger
4de0b7dd3d Metadata: Parse AVIs
Whereas extraction of the dive-duration is trivial, AVIs don't seem
to have a standardized way of saving the creation time. This commit
implements support for two versions randomly found on the internet.
Additional version will follow if need arises. AVI seems not to be
a particular popular format for either vacation or professional
videographers.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-14 08:32:30 +02:00
Berthold Stoeger
02ad18d4d8 Metadata: extract duration fom QuickTime/MP4-style containers
We want the duration of videos for two reasons:
 - To display the duration of the video in the profile plot.
 - To be able to determine which dive a video is closer to if the
   start is not during a dive.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-07-14 08:32:30 +02:00
Berthold Stoeger
52cc51f906 Update CHANGELOG.md
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-13 17:07:52 -07:00
Berthold Stoeger
9efb56e2d4 Dive pictures: don't update all images on drag&drop to profile
Gracefully handle drag & drop to the profile, which changes the
offset of the pictures. To do this, keep the pictures in the
DivePictureModel and the ProfileWidget2 sorted by offset and
re-arrange if needed to keep the list sorted. This needs some
code reshuffling.

Introduce a helper-function that moves ranges in arrays.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-13 17:07:42 -07:00
Berthold Stoeger
0aaa1bf386 Dive pictures: update thumbnail positions on deletion
If pictures were deleted, the remaining thumbails where staying at
their positions. Only when switching between dives, the new positions
were recalculated. Do the recalculation immediately. More precisely:
the x-coordinate, which is determined by the timestamp, stays identical.
Only the y-coordinate is recalculated such that overlapping of thumbnails
is avoided.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-13 17:07:22 -07:00
Dirk Hohndel
b2422f8856 Prepare README and ReleaseNotes for 4.8.1
And clear out CHANGELOG.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-13 15:28:06 -07:00
Dirk Hohndel
396f85d0f4 Update to latest libdc
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-13 15:28:06 -07:00
Dirk Hohndel
10053c41fb Latest translations
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-13 15:22:36 -07:00
Stefan Fuchs
63e63ee07d Disable the WindowContextHelpButtonHint for Qt >=5.10
Disables the WindowContextHelpButtonHint by default on Qt::Sheet and
Qt::Dialog widgets. This hides the ? button on Windows, which only
makes sense if you use QWhatsThis functionality.
This value has been added in Qt 5.10.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2018-07-13 14:46:10 -07:00
Dirk Hohndel
ff1490184b Update CHANGELOG.md
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-07-13 11:30:31 -07:00