summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/plannernotes.c6
-rw-r--r--core/qt-init.cpp6
-rw-r--r--core/qthelper.h26
-rw-r--r--core/qtserialbluetooth.cpp11
-rw-r--r--core/serial_ftdi.c8
5 files changed, 49 insertions, 8 deletions
diff --git a/core/plannernotes.c b/core/plannernotes.c
index 10b4a2ddb..c7d443324 100644
--- a/core/plannernotes.c
+++ b/core/plannernotes.c
@@ -245,7 +245,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
FRACTION(dp->time - lasttime, 60),
FRACTION(dp->time, 60),
gasname(&gasmix),
- divemode_text_ui[dp->divemode]);
+ translate("gettextFromC", divemode_text_ui[dp->divemode]));
}
put_string(&buf, "<br>");
newdepth = dp->depth.mm;
@@ -312,7 +312,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
free(temp);
} else {
put_format(&buf, "<td style='padding-left: 10px; color: red; float: left;'><b>%s %s</b></td>",
- gasname(&newgasmix), lastdivemode == dp->divemode ? "" : divemode_text_ui[dp->divemode]);
+ gasname(&newgasmix), lastdivemode == UNDEF_COMP_TYPE || lastdivemode == dp->divemode ? "" : translate("gettextFromC", divemode_text_ui[dp->divemode]));
if (isascent && (get_he(&lastprintgasmix) > 0)) { // For a trimix gas change on ascent, save ICD info if previous cylinder had helium
if (isobaric_counterdiffusion(&lastprintgasmix, &newgasmix, &icdvalues)) // Do icd calulations
icdwarning = true;
@@ -334,7 +334,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
free(temp);
} else {
put_format(&buf, "<td style='padding-left: 10px; color: red; float: left;'><b>%s %s</b></td>", gasname(&gasmix),
- lastdivemode == dp->divemode ? "" : divemode_text_ui[dp->divemode]);
+ lastdivemode == UNDEF_COMP_TYPE || lastdivemode == dp->divemode ? "" : translate("gettextFromC", divemode_text_ui[dp->divemode]));
if (get_he(&lastprintgasmix) > 0) { // For a trimix gas change, save ICD info if previous cylinder had helium
if (isobaric_counterdiffusion(&lastprintgasmix, &gasmix, &icdvalues)) // Do icd calculations
icdwarning = true;
diff --git a/core/qt-init.cpp b/core/qt-init.cpp
index b1a235cb6..5596b3f95 100644
--- a/core/qt-init.cpp
+++ b/core/qt-init.cpp
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <QApplication>
+#include <Qt>
#include <QNetworkProxy>
#include <QLibraryInfo>
#include <QTextCodec>
@@ -42,6 +43,11 @@ void init_qt_late()
QCoreApplication::setApplicationName("Subsurface");
#endif
}
+ // 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.
+#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
+ QCoreApplication::setAttribute(Qt::AA_DisableWindowContextHelpButton);
+#endif
// find plugins installed in the application directory (without this SVGs don't work on Windows)
SettingsObjectWrapper::instance()->load();
diff --git a/core/qthelper.h b/core/qthelper.h
index a2decd527..e1517991c 100644
--- a/core/qthelper.h
+++ b/core/qthelper.h
@@ -88,6 +88,32 @@ QString getUserAgent();
#define TITLE_OR_TEXT(_t, _m) _t, _m
#endif
+// Move a range in a vector to a different position.
+// The parameters are given according to the usual STL-semantics:
+// v: a container with STL-like random access iterator via std::begin(...)
+// rangeBegin: index of first element
+// rangeEnd: index one *past* last element
+// destination: index to element before which the range will be moved
+// Owing to std::begin() magic, this function works with STL-like containers:
+// QVector<int> v{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+// moveInVector(v, 1, 4, 6);
+// as well as with C-style arrays:
+// int array[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+// moveInVector(array, 1, 4, 6);
+// Both calls will have the following effect:
+// Before: 0 1 2 3 4 5 6 7 8 9
+// After: 0 4 5 1 2 3 6 7 8 9
+// No sanitizing of the input arguments is performed.
+template <typename Vector>
+void moveInVector(Vector &v, int rangeBegin, int rangeEnd, int destination)
+{
+ auto it = std::begin(v);
+ if (destination > rangeEnd)
+ std::rotate(it + rangeBegin, it + rangeEnd, it + destination);
+ else if (destination < rangeBegin)
+ std::rotate(it + destination, it + rangeBegin, it + rangeEnd);
+}
+
#endif
// 3) Functions visible to C and C++
diff --git a/core/qtserialbluetooth.cpp b/core/qtserialbluetooth.cpp
index 71a76187f..14ddacf2b 100644
--- a/core/qtserialbluetooth.cpp
+++ b/core/qtserialbluetooth.cpp
@@ -6,6 +6,7 @@
#include <QEventLoop>
#include <QTimer>
#include <QDebug>
+#include <QThread>
#include <libdivecomputer/version.h>
#include <libdivecomputer/context.h>
@@ -395,6 +396,12 @@ static dc_status_t qt_serial_set_timeout(void *io, int timeout)
return DC_STATUS_SUCCESS;
}
+static dc_status_t qt_custom_sleep(void *io, unsigned int timeout)
+{
+ QThread::msleep(timeout);
+ return DC_STATUS_SUCCESS;
+}
+
#ifdef BLE_SUPPORT
dc_status_t
ble_packet_open(dc_iostream_t **iostream, dc_context_t *context, const char* devaddr, void *userdata)
@@ -415,7 +422,7 @@ ble_packet_open(dc_iostream_t **iostream, dc_context_t *context, const char* dev
qt_ble_write, /* write */
NULL, /* flush */
NULL, /* purge */
- NULL, /* sleep */
+ qt_custom_sleep, /* sleep */
qt_ble_close, /* close */
};
@@ -448,7 +455,7 @@ rfcomm_stream_open(dc_iostream_t **iostream, dc_context_t *context, const char*
qt_serial_write, /* write */
NULL, /* flush */
qt_serial_purge, /* purge */
- NULL, /* sleep */
+ qt_custom_sleep, /* sleep */
qt_serial_close, /* close */
};
diff --git a/core/serial_ftdi.c b/core/serial_ftdi.c
index 6d99672f2..9bcf7aba0 100644
--- a/core/serial_ftdi.c
+++ b/core/serial_ftdi.c
@@ -98,12 +98,14 @@ static dc_status_t serial_ftdi_get_transmitted (ftdi_serial_t *device)
return DC_STATUS_UNSUPPORTED;
}
-static dc_status_t serial_ftdi_sleep (ftdi_serial_t *device, unsigned long timeout)
+static dc_status_t serial_ftdi_sleep (void *io, unsigned int timeout)
{
+ ftdi_serial_t *device = io;
+
if (device == NULL)
return DC_STATUS_INVALIDARGS;
- INFO (device->context, "Sleep: value=%lu", timeout);
+ INFO (device->context, "Sleep: value=%u", timeout);
struct timespec ts;
ts.tv_sec = (timeout / 1000);
@@ -541,7 +543,7 @@ dc_status_t ftdi_open(dc_iostream_t **iostream, dc_context_t *context)
serial_ftdi_write, /* write */
NULL, /* flush */
serial_ftdi_purge, /* purge */
- NULL, /* sleep */
+ serial_ftdi_sleep, /* sleep */
serial_ftdi_close, /* close */
};