From: Shane Synan Date: Sun, 8 Jan 2017 19:30:38 +0000 (-0600) Subject: Show timestamp format tooltips when core supports X-Git-Tag: travis-deploy-test~309 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=4c5b4bf5355413e3f3df3704512ff350fa062961 Show timestamp format tooltips when core supports Only change tooltip for away messages when supported by the core. Restore original tooltip and concatenate together to reuse existing translations (can be split apart if not a good idea). Add new feature flag "AwayFormatTimestamp" to indicate when the core supports parsing timestamp formats in away messages. This isn't strictly required and if needed can be left out. It just might be confusing for the UI to say you can do something.. and it doesn't work. Resolves GH-270. --- diff --git a/src/common/quassel.h b/src/common/quassel.h index e9ed0f95..5097bada 100644 --- a/src/common/quassel.h +++ b/src/common/quassel.h @@ -75,8 +75,9 @@ public: VerifyServerSSL = 0x0040, /// IRC server SSL validation CustomRateLimits = 0x0080, /// IRC server custom message rate limits DccFileTransfer = 0x0100, + AwayFormatTimestamp = 0x0200, /// Timestamp formatting in away (e.g. %%hh:mm%%) - NumFeatures = 0x0100 + NumFeatures = 0x0200 }; Q_DECLARE_FLAGS(Features, Feature) diff --git a/src/qtui/settingspages/identityeditwidget.cpp b/src/qtui/settingspages/identityeditwidget.cpp index e1659155..9085ae90 100644 --- a/src/qtui/settingspages/identityeditwidget.cpp +++ b/src/qtui/settingspages/identityeditwidget.cpp @@ -85,6 +85,52 @@ IdentityEditWidget::IdentityEditWidget(QWidget *parent) ui.sslCertGroupBox->setAcceptDrops(true); ui.sslCertGroupBox->installEventFilter(this); #endif + + if (Client::coreFeatures() & Quassel::AwayFormatTimestamp) { + // Core allows formatting %%timestamp%% messages in away strings. Update tooltips. + QString strFormatTooltip; + QTextStream formatTooltip( &strFormatTooltip, QIODevice::WriteOnly ); + formatTooltip << ""; + + // Function to add a row to the tooltip table + auto addRow = [&](const QString& key, const QString& value, bool condition) { + if (condition) { + formatTooltip << "" + << key << "" << value << ""; + } + }; + + // Original tooltip goes here + formatTooltip << "

%1

"; + // New timestamp formatting guide here + formatTooltip << "

" << tr("You can add date/time to this message " + "using the syntax: " + "
%%<format>%%, where " + "<format> is:") << "

"; + formatTooltip << ""; + addRow("hh", tr("the hour"), true); + addRow("mm", tr("the minutes"), true); + addRow("ss", tr("seconds"), true); + addRow("AP", tr("AM/PM"), true); + addRow("dd", tr("day"), true); + addRow("MM", tr("month"), true); +#if QT_VERSION > 0x050000 + // Alas, this was only added in Qt 5. We don't know what version the core has, just hope + // for the best (Qt 4 will soon be dropped). + addRow("t", tr("current timezone"), true); +#endif + formatTooltip << "
"; + formatTooltip << "

" << tr("Example: Away since %%hh:mm%% on %%dd.MM%%.") << "

"; + formatTooltip << "

" << tr("%%%% without anything inside represents %%. Other format " + "codes are available.") << "

"; + formatTooltip << "
"; + + // Split up the message to allow re-using translations: + // [Original tool-tip] [Timestamp format message] + ui.awayReason->setToolTip(strFormatTooltip.arg(ui.awayReason->toolTip())); + ui.detachAwayEnabled->setToolTip(strFormatTooltip.arg(ui.detachAwayEnabled->toolTip())); + } // else: Do nothing, leave the original translated string } diff --git a/src/qtui/settingspages/identityeditwidget.ui b/src/qtui/settingspages/identityeditwidget.ui index 942f99d1..cedcdf06 100644 --- a/src/qtui/settingspages/identityeditwidget.ui +++ b/src/qtui/settingspages/identityeditwidget.ui @@ -251,7 +251,7 @@ true - <html><head/><body><p>Default away reason. You can add date/time to this message using syntax: %% &lt;format&gt; %%. Where &lt;format&gt; is: <br/>hh - the hour<br/>mm - the minutes<br/>ss - second<br/>AP - AM/PM<<br/>dd - day<br/>MM - month</p></body></html> + Default away reason @@ -277,7 +277,7 @@ - <html><head/><body><p>Set away when all clients have detached from the core. You can add date/time to this message using syntax: %% &lt;format&gt; %%. Where &lt;format&gt; is:<br/>hh - the hour<br/>mm - the minutes<br/>ss - second<br/>AP - AM/PM<br/>dd - day<br/>MM - month</p></body></html> + Set away when all clients have detached from the core Away On Detach