From 2055d6c929cce3916d65ed18929850829be4546a Mon Sep 17 00:00:00 2001 From: Markus Wuebben Date: Wed, 10 Dec 1997 23:32:39 +0000 Subject: [PATCH] // $markus: - Added fore and background color support. - Reimplemented slotInsertFile due to request svn path=/trunk/kdenetwork/kmail/; revision=3357 --- kmcomposewin.cpp | 80 ++++++++++++++++++++++++++++++++++++++++++++---- kmcomposewin.h | 8 +++++ 2 files changed, 82 insertions(+), 6 deletions(-) diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index 82452dd07..c2f9a4f07 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -156,6 +156,9 @@ void KMComposeWin::readConfig(void) mShowHeaders = config->readNumEntry("headers", HDR_STANDARD); mWordWrap = config->readNumEntry("word-wrap", 1); mLineBreak = config->readNumEntry("break-at", 80); + mBackColor = config->readEntry( "Back-Color"); + mForeColor = config->readEntry( "Fore-Color"); + config->setGroup("Geometry"); str = config->readEntry("composer", "480 510"); @@ -180,6 +183,14 @@ void KMComposeWin::writeConfig(bool aWithSync) config->writeEntry("headers", mShowHeaders); config->writeEntry("word-wrap",mWordWrap); config->writeEntry("break-at", mLineBreak); + str = ""; + str.sprintf("#%02x%02x%02x", foreColor.red(), foreColor.green(), + foreColor.blue()); + config->writeEntry("Fore-Color",str); + str = ""; + str.sprintf("#%02x%02x%02x", backColor.red(), backColor.green(), + backColor.blue()); + config->writeEntry("Back-Color",str); config->setGroup("Geometry"); str.sprintf("%d %d", width(), height()); @@ -374,10 +385,11 @@ void KMComposeWin::setupMenuBar(void) menu->insertItem(nls->translate("&Followup-To"), HDR_FOLLOWUP_TO); // for KRN mMenuBar->insertItem(nls->translate("&View"), menu); - //---------- Menu: Attach menu = new QPopupMenu(); menu->insertItem(nls->translate("Append S&ignature"), this, SLOT(slotAppendSignature())); + menu->insertItem(nls->translate("&Insert File"), this, + SLOT(slotInsertFile())); menu->insertItem(nls->translate("&Attach..."), this, SLOT(slotAttachFile())); menu->insertSeparator(); menu->insertItem(nls->translate("&Remove"), this, SLOT(slotAttachRemove())); @@ -475,6 +487,30 @@ void KMComposeWin::setupEditor(void) // Font setup + + // Color setup + if( mForeColor.isEmpty()) + mForeColor = "black"; + + if( mBackColor.isEmpty()) + mBackColor = "white"; + + foreColor.setNamedColor(mForeColor); + backColor.setNamedColor(mBackColor); + + QPalette myPalette = (mEditor->palette()).copy(); + QColorGroup cgrp = myPalette.normal(); + QColorGroup ncgrp(foreColor,cgrp.background(), + cgrp.light(),cgrp.dark(), cgrp.mid(), foreColor, + backColor); + myPalette.setNormal(ncgrp); + myPalette.setDisabled(ncgrp); + myPalette.setActive(ncgrp); + + mEditor->setPalette(myPalette); + mEditor->setBackgroundColor(backColor); + + #ifdef BROKEN popup = new QPopupMenu(); popup->insertItem (klocale->translate("Send now"), @@ -680,10 +716,9 @@ void KMComposeWin::removeAttach(const QString aUrl) int idx; KMMessagePart* msgPart; - for(idx=0,msgPart=mAtmList.first(); msgPart; msgPart=mAtmList.next(),idx++) - { - if (msgPart->name() == aUrl) - { + for(idx=0,msgPart=mAtmList.first(); msgPart; + msgPart=mAtmList.next(),idx++) { + if (msgPart->name() == aUrl) { removeAttach(idx); return; } @@ -726,6 +761,39 @@ void KMComposeWin::slotAttachFile() } +void KMComposeWin::slotInsertFile() +{ + // Create File Dialog and return selected file + + QString fileName; + QString strCopy; + char temp[256]; + int col, line; + QFileDialog fdlg(".","*",this,NULL,TRUE); + + fdlg.setCaption(nls->translate("Attach File")); + if (!fdlg.exec()) return; + + fileName = fdlg.selectedFile(); + if(fileName.isEmpty()) return; + + cout << fileName << endl; + QFile *f = new QFile(fileName); + + if(!f->open(IO_ReadOnly)) + return; + + f->at(0); + while(!f->atEnd()) { + f->readLine(temp,255); + strCopy.append(temp); + } + + mEditor->getCursorPosition(&line,&col); + mEditor->insertAt(strCopy, line ,col); + f->close(); +} + //----------------------------------------------------------------------------- void KMComposeWin::slotAttachPopupMenu(int index, int) { @@ -965,7 +1033,7 @@ void KMComposeWin::slotAppendSignature() if (!sigText.isEmpty()) { - mEditor->insertLine("\n--\n", -1); + // mEditor->insertLine("\n--\n", -1); mEditor->insertLine(sigText, -1); mEditor->toggleModified(mod); } diff --git a/kmcomposewin.h b/kmcomposewin.h index 7853b794c..9328165d7 100644 --- a/kmcomposewin.h +++ b/kmcomposewin.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "kmmsgpart.h" @@ -101,6 +102,9 @@ public slots: /** Append signature file to the end of the text in the editor. */ void slotAppendSignature(); + /** Insert a file to the end of the text in the editor. */ + void slotInsertFile(); + /** Popup a nice "not implemented" message. */ void slotToDo(); @@ -187,6 +191,10 @@ protected: int mNumHeaders; int mLineBreak; int mWordWrap; + QString mForeColor, mBackColor; + +private: + QColor foreColor,backColor; }; #endif