[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    [PATCH] Shrink quoted text v2b
From:       Ivor Hewitt <ivor () ivor ! org>
Date:       2005-05-12 21:39:22
Message-ID: 200505122239.22171.ivor () ivor ! org
[Download RAW message or body]

On Tuesday 10 May 2005 22:03, Ivor Hewitt wrote:
> Hi,
> I like the way thunderbird shrinks the font size of quoted text to give it
> less visual importance.
> Whilst I like the new collapsing feature I came up with this patch which
> automatically shrinks the quoted text font size by reducing the size to
> 85,80,75 and 70% of original.
>
> Does anyone see merit in this?
>
> Cheers,

Recreating the diff after making a change would be smart. :(
Attached.

-- 
Ivor Hewitt.
http://www.ivor.it - tech | http://www.ivor.org - hedge

["kmail.diff" (text/x-diff)]

Index: csshelper.cpp
===================================================================
--- csshelper.cpp	(revision 412172)
+++ csshelper.cpp	(working copy)
@@ -97,6 +97,7 @@
       cPgpEncrF, cPgpEncrH, cPgpEncrB;
     // color of frame of warning preceding the source of HTML messages
     QColor cHtmlWarning;
+    bool mShrinkQuotes;
   };
 
   bool CSSHelper::Private::operator==( const Private & other ) const {
@@ -118,7 +119,8 @@
       cPgpOk0F == other.cPgpOk0F && cPgpOk0H == other.cPgpOk0H && cPgpOk0B == \
                other.cPgpOk0B &&
       cPgpWarnF == other.cPgpWarnF && cPgpWarnH == other.cPgpWarnH && cPgpWarnB == \
                other.cPgpWarnB &&
       cPgpErrF == other.cPgpErrF && cPgpErrH == other.cPgpErrH && cPgpErrB == \
                other.cPgpErrB &&
-      cPgpEncrF == other.cPgpEncrF && cPgpEncrH == other.cPgpEncrH && cPgpEncrB == \
other.cPgpEncrB ; +      cPgpEncrF == other.cPgpEncrF && cPgpEncrH == other.cPgpEncrH \
&& cPgpEncrB == other.cPgpEncrB && +      mShrinkQuotes == other.mShrinkQuotes;
     }
 
   namespace {
@@ -257,7 +259,9 @@
         mQuoteFont[i] = fonts.readFontEntry( key, &defaultFont );
       }
     }
-
+   
+    mShrinkQuotes = reader.readBoolEntry("ShrinkQuotes",false);
+    
     mBackingPixmapStr = pixmaps.readPathEntry("Readerwin");
     mBackingPixmapOn = !mBackingPixmapStr.isEmpty();
   }
@@ -446,6 +450,8 @@
     if ( !quoteCSS.isEmpty() )
       quoteCSS = "div.noquote {\n" + quoteCSS + "}\n\n";
 
+    QString footCSS;
+    
     for ( int i = 0 ; i < 3 ; ++i ) {
       quoteCSS += QString( "div.quotelevel%1 {\n"
                            "  color: %2 ! important;\n" )
@@ -454,6 +460,28 @@
         quoteCSS += "  font-style: italic ! important;\n";
       if ( mQuoteFont[i].bold() )
         quoteCSS += "  font-weight: bold ! important;\n";
+
+      if (mShrinkQuotes) //and footer
+      {
+          footCSS += QString("div.footer {\n"
+                             "  font-family: \"%1\" ! important;\n"
+                             "  font-size: 80%;\n"
+                             "  color: #808080;\n"
+                             "}\n\n")
+                     .arg(bodyFont( true ).family());
+          
+          switch (i){
+              case 0:
+                  quoteCSS+="  font-size: 85%;\n"; break;
+              case 1:
+                  quoteCSS+="  font-size: 80%;\n"; break;
+              case 2:
+                  quoteCSS+="  font-size: 75%;\n"; break;
+              default:
+                  quoteCSS+="  font-size: 70%;\n"; break;
+          };
+      }
+      
       quoteCSS += "}\n\n";
     }
 
@@ -625,7 +653,8 @@
             cg.foreground().name(),
             cg.background().name() )
       .arg( cg.mid().name() )
-      + quoteCSS;
+      + quoteCSS
+      + footCSS;
   }
 
   QString CSSHelper::Private::commonCssDefinitions() const {
Index: configuredialog_p.h
===================================================================
--- configuredialog_p.h	(revision 412172)
+++ configuredialog_p.h	(working copy)
@@ -521,6 +521,7 @@
   QCheckBox *mShowEmoticonsCheck;
   QCheckBox *mShowExpandQuotesMark;
   KIntSpinBox  *mCollapseQuoteLevelSpin;
+  QCheckBox *mShrinkQuotesCheck;
   QComboBox *mCharsetCombo;
   QComboBox *mOverrideCharsetCombo;
 };
Index: kmail.kcfg
===================================================================
--- kmail.kcfg	(revision 412172)
+++ kmail.kcfg	(working copy)
@@ -399,8 +399,11 @@
         <min>0</min>
         <max>10</max>
       </entry>
-
-
+     <entry name="ShrinkQuotes" type="Bool">
+         <default>false</default>
+         <label>Reduce font sizes for quoted text and footers</label>
+         <whatsthis>Enabling this option causes quoted text to reduce in size for \
each nested text quotation, footers are also detected and displayed in a small fixed \
font.</whatsthis> +     </entry>
     </group>
 
 </kcfg>
Index: configuredialog.cpp
===================================================================
--- configuredialog.cpp	(revision 412172)
+++ configuredialog.cpp	(working copy)
@@ -2188,6 +2188,9 @@
 static const BoolConfigEntry showExpandQuotesMark= {
   "Reader", "ShowExpandQuotesMark", I18N_NOOP("Show expand/collapse quote marks"), \
false  };
+static const BoolConfigEntry shrinkQuotes= {
+  "Reader", "ShrinkQuotes", I18N_NOOP("Shrink quoted text size"), false
+};
 
 
 QString AppearancePage::ReaderTab::helpAnchor() const {
@@ -2241,7 +2244,12 @@
 
   connect( mShowExpandQuotesMark, SIGNAL( toggled( bool ) ),
       mCollapseQuoteLevelSpin, SLOT( setEnabled( bool ) ) );
-
+  
+  populateCheckBox( mShrinkQuotesCheck = new QCheckBox( this ), shrinkQuotes );
+  vlay->addWidget( mShrinkQuotesCheck );
+  connect( mShrinkQuotesCheck, SIGNAL ( stateChanged( int ) ),
+           this, SLOT( slotEmitChanged() ) );
+  
   // Fallback Character Encoding
   hlay = new QHBoxLayout( vlay ); // inherits spacing
   mCharsetCombo = new QComboBox( this );
@@ -2323,6 +2331,7 @@
   mShowEmoticonsCheck->setChecked( GlobalSettings::showEmoticons() );
   mShowExpandQuotesMark->setChecked( GlobalSettings::showExpandQuotesMark() );
   mCollapseQuoteLevelSpin->setValue( GlobalSettings::collapseQuoteLevelSpin() );
+  mShrinkQuotesCheck->setChecked( GlobalSettings::shrinkQuotes() );
   readCurrentOverrideCodec();
 }
 
@@ -2340,6 +2349,7 @@
   saveCheckBox( mShowSpamStatusCheck, reader, showSpamStatusMode );
   GlobalSettings::setShowEmoticons( mShowEmoticonsCheck->isChecked() );
   GlobalSettings::setShowExpandQuotesMark( mShowExpandQuotesMark->isChecked() );
+  GlobalSettings::setShrinkQuotes( mShrinkQuotesCheck->isChecked() );
   
   GlobalSettings::setCollapseQuoteLevelSpin( mCollapseQuoteLevelSpin->value() );
   GlobalSettings::setFallbackCharacterEncoding(
@@ -2355,6 +2365,7 @@
   loadProfile( mShowSpamStatusCheck, reader, showSpamStatusMode );
   loadProfile( mShowEmoticonsCheck, reader, showEmoticons );
   loadProfile( mShowExpandQuotesMark, reader, showExpandQuotesMark);
+  loadProfile( mShrinkQuotesCheck, reader, shrinkQuotes );
 }
 
 
Index: objecttreeparser.cpp
===================================================================
--- objecttreeparser.cpp	(revision 412172)
+++ objecttreeparser.cpp	(working copy)
@@ -2452,6 +2452,11 @@
   int currQuoteLevel = -2; // -2 == no previous lines
   bool curHidden = false; // no hide any block
 
+  int sigStart=-1;
+  int sigLineCount=0;
+  
+  QRegExp sigSep("^\\s*[\\-_\\*]{2}[\\-_ \\*]*$");
+  
   while (beg<length)
   {
     QString line;
@@ -2464,6 +2469,25 @@
     line = s.mid(beg,pos-beg);
     beg = pos+1;
 
+    // Attempt to find last footer.
+
+    if (GlobalSettings::shrinkQuotes())
+    {
+      if (sigStart>0)
+        sigLineCount++;
+
+      if (sigSep.search(line) != -1)
+      {
+        //assume a sig over 20 lines is a mistake and start again
+        if (sigLineCount>20)
+          sigLineCount=0;
+       
+        //if we're looking for the sig start remember the location
+        if (sigLineCount==0)
+          sigStart = htmlStr.length();
+      }
+    }
+    
     /* calculate line's current quoting depth */
     int actQuoteLevel = -1;
 
@@ -2563,11 +2587,18 @@
     }
   } /* while() */
 
+  
   /* really finish the last quotelevel */
   if (currQuoteLevel == -1)
      htmlStr.append( normalEndTag );
   else
      htmlStr.append( quoteEnd );
+  
+  if (sigStart > 0 && sigLineCount < 20)
+  {
+      htmlStr.insert(sigStart,"<div class=\"footer\">");
+      htmlStr += "</div>";
+  }
 
   //kdDebug(5006) << "KMReaderWin::quotedHTML:\n"
   //              << "========================================\n"



_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic