summaryrefslogtreecommitdiffstats
path: root/kmail
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-07 22:30:29 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-07 22:30:29 +0000
commitd8b40941f9d1a221add0b9094eb09405a91a8aab (patch)
tree0b8e9b6347f6e75925bb3c386a47c5300b1a4775 /kmail
parent009631d0fc83f471d6c515e2a5001337a5a2ea21 (diff)
downloadtdepim-d8b40941f9d1a221add0b9094eb09405a91a8aab.tar.gz
tdepim-d8b40941f9d1a221add0b9094eb09405a91a8aab.zip
Part 2/2 of Chakra patch commit
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1172727 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmail')
-rw-r--r--kmail/configuredialog.cpp11
-rw-r--r--kmail/configuredialog_p.h1
-rw-r--r--kmail/headerstyle.cpp120
-rw-r--r--kmail/kmail.kcfg6
4 files changed, 137 insertions, 1 deletions
diff --git a/kmail/configuredialog.cpp b/kmail/configuredialog.cpp
index 32399f815..4378c325d 100644
--- a/kmail/configuredialog.cpp
+++ b/kmail/configuredialog.cpp
@@ -2241,6 +2241,9 @@ static const BoolConfigEntry showExpandQuotesMark= {
"Reader", "ShowExpandQuotesMark", I18N_NOOP("Show expand/collapse quote marks"), false
};
+static const BoolConfigEntry showCurrentTime = {
+ "Reader", "ShowCurrentTime", I18N_NOOP("Show current sender time"), true
+};
TQString AppearancePage::ReaderTab::helpAnchor() const {
return TQString::fromLatin1("configure-appearance-reader");
@@ -2349,6 +2352,11 @@ AppearancePageReaderTab::AppearancePageReaderTab( TQWidget * parent,
hlay2->addWidget( label );
hlay2->addWidget( mOverrideCharsetCombo );
+ populateCheckBox( mShowCurrentTimeCheck = new TQCheckBox( this ), showCurrentTime );
+ vlay->addWidget( mShowCurrentTimeCheck );
+ connect( mShowCurrentTimeCheck, TQT_SIGNAL ( stateChanged( int ) ),
+ this, TQT_SLOT( slotEmitChanged() ) );
+
vlay->addStretch( 100 ); // spacer
}
@@ -2420,6 +2428,7 @@ void AppearancePage::ReaderTab::doLoadFromGlobalSettings()
mCollapseQuoteLevelSpin->setValue( GlobalSettings::self()->collapseQuoteLevelSpin() );
readCurrentFallbackCodec();
readCurrentOverrideCodec();
+ mShowCurrentTimeCheck->setChecked( GlobalSettings::self()->showCurrentTime() );
}
void AppearancePage::ReaderTab::doLoadOther()
@@ -2446,6 +2455,7 @@ void AppearancePage::ReaderTab::save() {
mOverrideCharsetCombo->currentItem() == 0 ?
TQString() :
KGlobal::charsets()->encodingForName( mOverrideCharsetCombo->currentText() ) );
+ GlobalSettings::self()->setShowCurrentTime( mShowCurrentTimeCheck->isChecked() );
}
@@ -2457,6 +2467,7 @@ void AppearancePage::ReaderTab::installProfile( KConfig * /* profile */ ) {
loadProfile( mShowEmoticonsCheck, reader, showEmoticons );
loadProfile( mShrinkQuotesCheck, reader, shrinkQuotes );
loadProfile( mShowExpandQuotesMark, reader, showExpandQuotesMark);
+ loadProfile( mShowCurrentTimeCheck, reader, showCurrentTime );
}
diff --git a/kmail/configuredialog_p.h b/kmail/configuredialog_p.h
index 6a1f538e6..096ba45a3 100644
--- a/kmail/configuredialog_p.h
+++ b/kmail/configuredialog_p.h
@@ -541,6 +541,7 @@ private: // data
TQCheckBox *mShrinkQuotesCheck;
TQComboBox *mCharsetCombo;
TQComboBox *mOverrideCharsetCombo;
+ TQCheckBox *mShowCurrentTimeCheck;
};
diff --git a/kmail/headerstyle.cpp b/kmail/headerstyle.cpp
index 29046112a..f099d9822 100644
--- a/kmail/headerstyle.cpp
+++ b/kmail/headerstyle.cpp
@@ -615,6 +615,122 @@ namespace KMail {
kdDebug( 5006 ) << "final presence: '" << presence << "'" << endl;
#endif
+ TQString timeHTML;
+ if ( GlobalSettings::self()->showCurrentTime() && strategy->showHeader( "date" ) ) {
+ DwHeaders& header = message->headers();
+ if ( header.HasDate() ) {
+ DwDateTime& origDate = header.Date();
+ int zone = origDate.Zone();
+ // kdDebug() << "FancyHeaderStyle::format() zone offset (in minutes): " << zone << endl;
+
+ // copyed fro mimelib -- code to determine local timezone
+ time_t t_now = time((time_t*) 0);
+#if defined(HAVE_GMTIME_R)
+ struct tm utc;
+ gmtime_r(&t_now, &utc);
+ struct tm local;
+ localtime_r(&t_now, &local);
+#else
+ struct tm utc = *gmtime(&t_now);
+ struct tm local = *localtime(&t_now);
+#endif
+ DwUint32 t_local = 0;
+ t_local = 24 * t_local + local.tm_hour;
+ t_local = 60 * t_local + local.tm_min;
+ t_local = 60 * t_local + local.tm_sec;
+ DwUint32 t_utc = 0;
+ t_utc = 24 * t_utc + utc.tm_hour;
+ t_utc = 60 * t_utc + utc.tm_min;
+ t_utc = 60 * t_utc + utc.tm_sec;
+ int lzone = (int) (t_local - t_utc) / 60;
+
+ // kdDebug() << "FancyHeaderStyle::format() local zone offset (in minutes): " << lzone << endl;
+
+ TQTime currTime = TQTime::currentTime( Qt::UTC );
+
+ // kdDebug() << "FancyHeaderStyle::format() current time: " << currTime << endl;
+
+ // now currTime contain message sender local time
+ currTime = currTime.addSecs( zone * 60 );
+
+ TQString timeofday;
+ TQString color;
+ TQString bg_color;
+ TQString bg_image;
+ if ( currTime > TQTime( 0, 0, 0 ) && currTime <= TQTime( 6, 0, 0 ) ) {
+ timeofday = i18n( "Night" );
+ color = "white";
+ bg_color = "#000B6B";
+ bg_image = "url(data:image/png;base64,"
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAyCAIAAAASmSbdAAAAS0lEQVQI11WOsRGAQAzDOG/LHoz9"
+ "kikIcF+kSBxbPs7LoNGVapAI0Zn+O+8NUwldozn6io7G7kdS/5zi7i+BvUM/5uSXlIfzMHx/bmWR"
+ "k++yj9rZAAAAAElFTkSuQmCC)";
+ }
+ else if ( currTime > TQTime( 6, 0, 0 ) && currTime <= TQTime( 12, 0, 0 ) ) {
+ timeofday = i18n( "Morning" );
+ color = "white";
+ bg_color = "#00A6FF";
+ bg_image = "url(data:image/png;base64,"
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAyCAYAAACd+7GKAAAAWklEQVQI122OQQ7DMAzDaP3/dfuO"
+ "pWSHJgva7iZIBk3m/Ew5hexCHVCilewzFHKEbFZqgxJQWyzKhWKl9unqddJj8+L9sl0oR2gUim+o"
+ "zu4uSh7kn67/DNv+C4tsZOtjAWEHAAAAAElFTkSuQmCC)";
+ }
+ else if ( currTime > TQTime( 12, 0, 0 ) && currTime <= TQTime( 18, 0, 0 ) ) {
+ timeofday = i18n( "Afternoon" );
+ color = "black";
+ bg_color = "#00A6FF";
+ bg_image = "url(data:image/png;base64,"
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAyCAYAAACd+7GKAAAAPUlEQVQI132OwQ0AIAwCSfcfw91c"
+ "QsCfRm399HFwoWjdDhMICQhxHSWMQPhkTCoqWRZU2h5i9tr4GZfmV5t3wWUI3h+NugAAAABJRU5E"
+ "rkJggg==)";
+ }
+ else {
+ timeofday = i18n( "Evening" );
+ color = "white";
+ bg_color = "#0014CC";
+ bg_image = "url(data:image/png;base64,"
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAAyCAYAAACd+7GKAAAAWklEQVQI11WOyRHAMAgDNQuUlBrS"
+ "fyFpAfKwje0PwyEt0vN+hVsJpzS6QML2ziWcFI6mZBZNSVDXYehyUgI1XsLI9eimHDH6kW0ddVIO"
+ "xx7JjrtshlbXlLDSD+WhJ+hwqWo8AAAAAElFTkSuQmCC)";
+ }
+
+ TQString tformat;
+ if ( KGlobal::locale()->use12Clock() ) {
+ tformat = "h:mm AP";
+ }
+ else {
+ tformat = "h:mm";
+ }
+
+ // kdDebug() << "FancyHeaderStyle::format() current time: " << currTime << " (" << timeofday << ")" << endl;
+
+ timeHTML.append( TQString(
+ "<div style=\""
+ "border:1px solid %1;"
+ "color:%2;"
+ "background-image:%3;"
+ "background-position:center left;"
+ "background-repeat:repeat-x;"
+ "text-align:center;"
+ "font-size:12px;"
+ "padding:2px;"
+ "width:50px;"
+ "heigth:50px;"
+ "margin: 0px 0px 3px 0px;"
+ "\" class=\"curtime\">%4<br />%5<br />%6</div>"
+ )
+ .arg( bg_color )
+ .arg( color )
+ .arg( bg_image )
+ .arg( i18n( "Now:" ) )
+ .arg( currTime.toString( tformat ) )
+ .arg( timeofday )
+ );
+ }
+ else {
+ // kdDebug() << "FancyHeaderStyle::format() no date header to display" << endl;
+ }
+ }
//case HdrFancy:
// the subject line and box below for details
@@ -719,7 +835,9 @@ namespace KMail {
*/
headerStr.append( TQString("<tr><td colspan=\"2\"><div id=\"attachmentInjectionPoint\"></div></td></tr>" ) );
headerStr.append(
- TQString( "</table></td><td align=\"center\">%1</td></tr></table>\n" ).arg(userHTML) );
+ TQString( "</table></td><td align=\"center\" valign=\"top\">%1%2</td></tr></table>\n" )
+ .arg(timeHTML)
+ .arg(userHTML) );
if ( !spamHTML.isEmpty() )
headerStr.append( TQString( "<div class=\"spamheader\" dir=\"%1\"><b>%2</b>&nbsp;<span style=\"padding-left: 20px;\">%3</span></div>\n")
diff --git a/kmail/kmail.kcfg b/kmail/kmail.kcfg
index 4192d234f..4bbd1be6c 100644
--- a/kmail/kmail.kcfg
+++ b/kmail/kmail.kcfg
@@ -607,6 +607,12 @@
<entry name="ChiasmusDecryptionOptions" type="String">
</entry>
+ <entry name="ShowCurrentTime" type="Bool">
+ <default>true</default>
+ <label>Show current message sender time</label>
+ <whatsthis>Enable this if you like to know what time of day are now in sender location (calculated from sender time zone).</whatsthis>
+ </entry>
+
<entry name="ShowUserAgent" type="Bool">
<default>false</default>
<label>Show user agent in fancy headers</label>