[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: Re: New Forgotten atachment detector
From: Alexey Arzamasov <AArzamasov () kkb ! kz>
Date: 2003-08-26 6:10:45
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday 25 August 2003 09:27, Ingo Klöcker wrote:
> One more thing: It should be possible to disable the warning directly in
> the dialog (with the "Don't show again" checkbox). The status of those
> checkboxes is stored in the [Notification Messages] group.
Ok, catch it.
- --
Arzamasov Alexey ICQ 58961246
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/S1sLYnQYd4hpr/wRAt5GAKDIuWPuw8OkvnIQG0isEWgdd02LIgCfdqLv
AiZiIYZczmqoa+PtuEpDQ8E=
=09rP
-----END PGP SIGNATURE-----
["kmail-attach-detector.patch" (text/x-diff)]
diff -u3 -p -b -B ./old/configuredialog.cpp ./new/configuredialog.cpp
--- ./old/configuredialog.cpp Sun Jul 13 19:30:03 2003
+++ ./new/configuredialog.cpp Tue Aug 26 13:01:21 2003
@@ -2324,6 +2324,12 @@ ComposerPage::ComposerPage( QWidget * pa
//
mHeadersTab = new HeadersTab();
addTab( mHeadersTab, mHeadersTab->title() );
+
+ //
+ // "Attachments" tab:
+ //
+ mAttachmentsTab = new AttachmentsTab();
+ addTab( mAttachmentsTab, mAttachmentsTab->title() );
}
@@ -3075,6 +3081,60 @@ void ComposerPage::HeadersTab::apply() {
general.writeEntry( "mime-header-count", numValidEntries );
}
+QString ComposerPage::AttachmentsTab::title() {
+ return i18n("Attachments");
+}
+
+QString ComposerPage::AttachmentsTab::helpAnchor() const {
+ return QString::fromLatin1("configure-composer-attachments");
+}
+
+ComposerPageAttachmentsTab::ComposerPageAttachmentsTab( QWidget * parent, const char \
* name ) + : ConfigurationPage( parent, name ) {
+ // tmp. vars:
+ QVBoxLayout *vlay;
+ QGroupBox *group;
+ QLabel *label;
+
+ vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
+
+ group = new QVGroupBox( i18n("Forgotten &attachment detector"), this );
+ group->layout()->setSpacing( KDialog::spacingHint() );
+
+ // row 0: help text:
+ label = new QLabel( i18n("Recognize any of the following words as intention to \
attach a file\n" + "(entries are case-insensitive \
alternatives):"), group ); + label->setAlignment( AlignLeft|WordBreak );
+
+ // row 1, string list editor:
+ SimpleStringListEditor::ButtonCode buttonCode =
+ static_cast<SimpleStringListEditor::ButtonCode>( \
SimpleStringListEditor::Add|SimpleStringListEditor::Remove ); + \
mAttachWordsListEditor = + new SimpleStringListEditor( group, 0, buttonCode,
+ i18n("A&dd..."), i18n("Re&move"),
+ QString::null,
+ i18n("Enter new \"attachment\" synonym:") );
+
+ vlay->addWidget( group );
+
+}
+
+void ComposerPage::AttachmentsTab::apply() {
+ KConfigGroup composer( kapp->config(), "Composer" );
+ composer.writeEntry("attachment-synonyms", \
mAttachWordsListEditor->stringList()); +}
+
+void ComposerPage::AttachmentsTab::setup() {
+ KConfigGroup composer( kapp->config(), "Composer" );
+
+ QStringList attachWordsList = composer.readListEntry( "attachment-synonyms", ',' \
); + if ( attachWordsList.isEmpty() )
+ // default value
+ attachWordsList << QString::fromLatin1("attachment") << \
QString::fromLatin1("attached") << QString::fromLatin1("patch") << + \
i18n("attachment") << i18n("attached") << i18n("patch"); +
+ mAttachWordsListEditor->setStringList( attachWordsList );
+}
// *************************************************************
// * *
diff -u3 -p -b -B ./old/configuredialog_p.h ./new/configuredialog_p.h
--- ./old/configuredialog_p.h Sun Jul 13 19:30:03 2003
+++ ./new/configuredialog_p.h Tue Aug 26 12:57:09 2003
@@ -682,6 +682,29 @@ protected:
QLabel *mTagValueLabel;
};
+class ComposerPageAttachmentsTab : public ConfigurationPage {
+ Q_OBJECT
+public:
+ ComposerPageAttachmentsTab( QWidget * parent=0, const char * name=0 );
+
+ // no icon
+ static QString iconLabel() {
+ return QString::null;
+ }
+ static const char * iconName() {
+ return 0;
+ }
+
+ static QString title();
+ QString helpAnchor() const;
+
+ void setup();
+ void apply();
+
+protected:
+ SimpleStringListEditor *mAttachWordsListEditor;
+};
+
class ComposerPage : public TabbedConfigurationPage {
Q_OBJECT
public:
@@ -698,6 +721,7 @@ public:
typedef ComposerPageSubjectTab SubjectTab;
typedef ComposerPageCharsetTab CharsetTab;
typedef ComposerPageHeadersTab HeadersTab;
+ typedef ComposerPageAttachmentsTab AttachmentsTab;
protected:
GeneralTab *mGeneralTab;
@@ -705,6 +729,7 @@ protected:
SubjectTab *mSubjectTab;
CharsetTab *mCharsetTab;
HeadersTab *mHeadersTab;
+ AttachmentsTab *mAttachmentsTab;
};
//
diff -u3 -p -b -B ./old/kmcomposewin.cpp ./new/kmcomposewin.cpp
--- ./old/kmcomposewin.cpp Sun Jul 13 19:30:04 2003
+++ ./new/kmcomposewin.cpp Tue Aug 26 13:02:20 2003
@@ -1382,6 +1382,49 @@ bool KMComposeWin::applyChanges(void)
return FALSE;
}
+ if (mAtmList.count() == 0) {
+ QRegExp quotationRx ("^([ \\t]*([|>:}#]|[A-Za-z]+>))+");
+
+ KConfigGroup composer( kapp->config(), "Composer" );
+ QStringList attachWordsList = composer.readListEntry( "attachment-synonyms", \
',' ); +
+ QString subj = mEdtSubject->text();
+ bool isReply = (KMMessage::stripOffPrefixes(subj).compare(subj) != 0);
+
+ if ( attachWordsList.isEmpty() )
+ attachWordsList << QString::fromLatin1("attachment") << \
QString::fromLatin1("attached") << QString::fromLatin1("patch") << + \
i18n("attachment") << i18n("attached") << i18n("patch"); +
+ QRegExp rx (attachWordsList.join("|"));
+ rx.setCaseSensitive(false);
+
+ bool gotMatch = false;
+ for (int i = 0; i < mEditor->numLines(); i++)
+ {
+ QString line = mEditor->textLine(i);
+ gotMatch = (rx.search(line) >= 0) && (quotationRx.search(line) < 0);
+ if (gotMatch) break;
+ }
+
+ if ( gotMatch || ( !isReply && (rx.search(subj) >= 0)))
+ {
+ int rc = KMessageBox::warningYesNoCancel(this,
+ i18n("The message you have composed seems to refer to an attached \
file but you have not attached anything.\nDo you want to attach a file to your \
message?"), + i18n("File Attachment Reminder"),
+ i18n("&Attach file..."),
+ i18n("&Send as is"),
+ "forgottenAttachmentBox");
+ if (rc == KMessageBox::Cancel)
+ return false;
+ else if (rc == KMessageBox::Yes)
+ {
+ slotAttachFile();
+ //preceed with editing
+ return false;
+ }
+ }
+ }
+
bccMsgList.clear();
if (bAutoCharset) {
_______________________________________________
KMail Developers mailing list
kmail@mail.kde.org
http://mail.kde.org/mailman/listinfo/kmail
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic