mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-17 21:06:17 +00:00
Facebook integration: improve the confirmation UI experience
Date and time needs to be a string, not a time_t. Duration should be called that (and not time) and wasn't hooked up. Also added a helper to get the duration string. Finally reordered the components of the text that is shown to make it more natural (or I should say, more in line with the order we use elsewhere). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
adb5cc5d30
commit
cab320201b
4 changed files with 31 additions and 7 deletions
|
@ -29,6 +29,7 @@ QString getSubsurfaceDataPath(QString folderToFind);
|
|||
extern const QString get_dc_nickname(const char *model, uint32_t deviceid);
|
||||
int gettimezoneoffset(timestamp_t when = 0);
|
||||
int parseTemperatureToMkelvin(const QString &text);
|
||||
QString get_dive_duration_string(timestamp_t when, QString hourText, QString minutesText);
|
||||
QString get_dive_date_string(timestamp_t when);
|
||||
QString get_short_dive_date_string(timestamp_t when);
|
||||
QString get_trip_date_string(timestamp_t when, int nr);
|
||||
|
|
16
qt-gui.cpp
16
qt-gui.cpp
|
@ -416,6 +416,22 @@ int parseTemperatureToMkelvin(const QString &text)
|
|||
return mkelvin;
|
||||
}
|
||||
|
||||
QString get_dive_duration_string(timestamp_t when, QString hourText, QString minutesText)
|
||||
{
|
||||
int hrs, mins;
|
||||
mins = (when + 59) / 60;
|
||||
hrs = mins / 60;
|
||||
mins -= hrs * 60;
|
||||
|
||||
QString displayTime;
|
||||
if (hrs)
|
||||
displayTime = QString("%1%2%3%4").arg(hrs).arg(hourText).arg(mins, 2, 10, QChar('0')).arg(minutesText);
|
||||
else
|
||||
displayTime = QString("%1%2").arg(mins).arg(minutesText);
|
||||
|
||||
return displayTime;
|
||||
}
|
||||
|
||||
QString get_dive_date_string(timestamp_t when)
|
||||
{
|
||||
QDateTime ts;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "mainwindow.h"
|
||||
#include "profile/profilewidget2.h"
|
||||
#include "pref.h"
|
||||
#include "helpers.h"
|
||||
#include "ui_socialnetworksdialog.h"
|
||||
|
||||
#define GET_TXT(name, field) \
|
||||
|
@ -259,6 +260,7 @@ SocialNetworkDialog::SocialNetworkDialog(QWidget *parent) : QDialog(parent)
|
|||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->date, SIGNAL(clicked()), this, SLOT(selectionChanged()));
|
||||
connect(ui->duration, SIGNAL(clicked()), this, SLOT(selectionChanged()));
|
||||
connect(ui->Buddy, SIGNAL(clicked()), this, SLOT(selectionChanged()));
|
||||
connect(ui->Divemaster, SIGNAL(clicked()), this, SLOT(selectionChanged()));
|
||||
connect(ui->Location, SIGNAL(clicked()), this, SLOT(selectionChanged()));
|
||||
|
@ -269,7 +271,15 @@ void SocialNetworkDialog::selectionChanged() {
|
|||
struct dive *d = current_dive;
|
||||
QString fullText;
|
||||
if (ui->date->isChecked()) {
|
||||
fullText += tr("Dive Date: %1 \n").arg(d->when);
|
||||
fullText += tr("Dive Date: %1 \n").arg(get_short_dive_date_string(d->when));
|
||||
}
|
||||
if (ui->duration->isChecked()) {
|
||||
fullText += tr("Duration: %1 \n").arg(get_dive_duration_string(d->duration.seconds,
|
||||
tr("h:", "abbreviation for hours plus separator"),
|
||||
tr("min", "abbreviation for minutes")));
|
||||
}
|
||||
if (ui->Location->isChecked()) {
|
||||
fullText += tr("Dive Location: %1 \n").arg(d->location);
|
||||
}
|
||||
if (ui->Buddy->isChecked()) {
|
||||
fullText += tr("Buddy: %1 \n").arg(d->buddy);
|
||||
|
@ -277,9 +287,6 @@ void SocialNetworkDialog::selectionChanged() {
|
|||
if (ui->Divemaster->isChecked()) {
|
||||
fullText += tr("Divemaster: %1 \n").arg(d->divemaster);
|
||||
}
|
||||
if (ui->Location->isChecked()) {
|
||||
fullText += tr("Dive Location: %1 \n").arg(d->location);
|
||||
}
|
||||
if (ui->Notes->isChecked()) {
|
||||
fullText += tr("\n %1").arg(d->notes);
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
<widget class="QPlainTextEdit" name="text"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QCheckBox" name="time">
|
||||
<widget class="QCheckBox" name="duration">
|
||||
<property name="text">
|
||||
<string>Time</string>
|
||||
<string>Duration</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -58,7 +58,7 @@
|
|||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="date">
|
||||
<property name="text">
|
||||
<string>date</string>
|
||||
<string>Date and time</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Add table
Reference in a new issue