... affecting the composer.
1. Moved the attachments to the top right shoulder to get things more compact
and esp. save precious vertical space
2. Attachments have now full DND support - one can drag them into the text area
and the attachment view to add them and drop them out of the view to remove
them.
3. minor addition to send mails by pressing ctrl+enter (as virtually all other
clients - does it need a config option or "confirm once" dialog?)
4. constrain the input to plain text (try cnp out of eg. a webkit browser atm,
you'll get marked up text...) and word-wrapped 72 chars width. (that showed me
a glitch in the format=flowed patch: a dash can hint flowing text just as much
as a blank -> improve that once the original patch has been reviewed ;-)
Cheers,
Thomas
From 080a29d507e8e34a399ac1b097f3baa36229363d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20L=C3=BCbking?= <[email protected]>
Date: Tue, 9 Oct 2012 20:08:34 +0200
Subject: [PATCH 1/4] move attachment section into top right corner
ratio: spare precious vertical space
so far vertical space was wasted on long recipient lines
and the trailing attachment section on the bottom, which
had a fixed height and hard to read ltr (instead of ttb)
alignment. also the horizontally attached pushbutton wasted
some area
---
src/Gui/ComposeWidget.ui | 176 ++++++++++++++++++++++++++++-------------------
1 file changed, 106 insertions(+), 70 deletions(-)
diff --git a/src/Gui/ComposeWidget.ui b/src/Gui/ComposeWidget.ui
index e86bf23..2bf401d 100644
--- a/src/Gui/ComposeWidget.ui
+++ b/src/Gui/ComposeWidget.ui
@@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
- <width>559</width>
- <height>342</height>
+ <width>715</width>
+ <height>345</height>
</rect>
</property>
<property name="windowTitle">
<string>Compose Mail</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QVBoxLayout" name="verticalLayout_2" stretch="1,1,1000,1">
<item>
<widget class="QLabel" name="developmentWarning">
<property name="palette">
@@ -65,43 +65,118 @@
</widget>
</item>
<item>
- <layout class="QFormLayout" name="envelopeLayout">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="fromLabel">
- <property name="text">
- <string>From</string>
- </property>
- <property name="buddy">
- <cstring>sender</cstring>
+ <layout class="QHBoxLayout" name="horizontalLayout_2" stretch="16,10">
+ <item>
+ <layout class="QFormLayout" name="envelopeLayout">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
- </widget>
+ <item row="0" column="0">
+ <widget class="QLabel" name="fromLabel">
+ <property name="text">
+ <string>From</string>
+ </property>
+ <property name="buddy">
+ <cstring>sender</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="sender">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="subjectLabel">
+ <property name="text">
+ <string>Subject</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="subject"/>
+ </item>
+ </layout>
</item>
- <item row="0" column="1">
- <widget class="QComboBox" name="sender">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string/>
</property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="subjectLabel">
- <property name="text">
- <string>Subject</string>
+ <property name="flat">
+ <bool>false</bool>
</property>
<property name="buddy">
<cstring>subject</cstring>
</property>
+ <layout class="QVBoxLayout" name="verticalLayout" stretch="1,100">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="attachButton">
+ <property name="text">
+ <string>Attach...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListView" name="attachmentsView">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="editTriggers">
+ <set>QAbstractItemView::NoEditTriggers</set>
+ </property>
+ <property name="dragEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="dragDropMode">
+ <enum>QAbstractItemView::DragDrop</enum>
+ </property>
+ <property name="verticalScrollMode">
+ <enum>QAbstractItemView::ScrollPerPixel</enum>
+ </property>
+ <property name="horizontalScrollMode">
+ <enum>QAbstractItemView::ScrollPerPixel</enum>
+ </property>
+ <property name="flow">
+ <enum>QListView::TopToBottom</enum>
+ </property>
+ <property name="isWrapping" stdset="0">
+ <bool>false</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>QListView::Adjust</enum>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="subject"/>
- </item>
</layout>
</item>
<item>
@@ -115,45 +190,6 @@
</widget>
</item>
<item>
- <layout class="QFormLayout" name="formLayout_2">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="0" column="0">
- <widget class="QPushButton" name="attachButton">
- <property name="text">
- <string>Attach...</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QListView" name="attachmentsView">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>64</width>
- <height>40</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>16777215</width>
- <height>40</height>
- </size>
- </property>
- <property name="flow">
- <enum>QListView::LeftToRight</enum>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QDialogButtonBox" name="buttonBox">
--
1.7.12.2
From 842efe0768aa4580cf16184183911e7056cd3f0c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20L=C3=BCbking?= <[email protected]>
Date: Wed, 10 Oct 2012 00:19:46 +0200
Subject: [PATCH 2/4] add dnd support to file attachment
---
src/Gui/ComposeWidget.cpp | 16 +++++-
src/Gui/ComposeWidget.h | 3 ++
src/Gui/ComposeWidget.ui | 16 +++++-
src/Gui/ComposerAttachments.cpp | 64 +++++++++++++++++++++++
src/Gui/ComposerAttachments.h | 38 ++++++++++++++
src/Gui/ComposerTextEdit.cpp | 101 +++++++++++++++++++++++++++++++++++++
src/Gui/ComposerTextEdit.h | 51 +++++++++++++++++++
src/Gui/Gui.pro | 8 ++-
src/Imap/Model/MessageComposer.cpp | 15 +++++-
9 files changed, 304 insertions(+), 8 deletions(-)
create mode 100644 src/Gui/ComposerAttachments.cpp
create mode 100644 src/Gui/ComposerAttachments.h
create mode 100644 src/Gui/ComposerTextEdit.cpp
create mode 100644 src/Gui/ComposerTextEdit.h
diff --git a/src/Gui/ComposeWidget.cpp b/src/Gui/ComposeWidget.cpp
index 6c9a567..efdd514 100644
--- a/src/Gui/ComposeWidget.cpp
+++ b/src/Gui/ComposeWidget.cpp
@@ -58,6 +58,7 @@ ComposeWidget::ComposeWidget(MainWindow *parent) :
Q_ASSERT(m_mainWindow);
m_composer = new Imap::Mailbox::MessageComposer(m_mainWindow->imapModel(), this);
m_composer->setPreloadEnabled(shouldBuildMessageLocally());
+ m_composer->setSupportedDragActions( Qt::MoveAction|Qt::CopyAction|Qt::LinkAction );
ui->setupUi(this);
sendButton = ui->buttonBox->addButton(tr("Send"), QDialogButtonBox::AcceptRole);
@@ -66,14 +67,14 @@ ComposeWidget::ComposeWidget(MainWindow *parent) :
connect(cancelButton, SIGNAL(clicked()), this, SLOT(close()));
ui->attachmentsView->setModel(m_composer);
connect(ui->attachButton, SIGNAL(clicked()), this, SLOT(slotAskForFileAttachment()));
- ui->attachmentsView->setAcceptDrops(true);
- ui->attachmentsView->setDropIndicatorShown(true);
ui->attachmentsView->setContextMenuPolicy(Qt::ActionsContextMenu);
m_actionRemoveAttachment = new QAction(tr("Remove"), this);
connect(m_actionRemoveAttachment, SIGNAL(triggered()), this, SLOT(slotRemoveAttachment()));
ui->attachmentsView->addAction(m_actionRemoveAttachment);
+ connect(ui->attachmentsView, SIGNAL(itemDroppedOut()), SLOT(slotRemoveAttachment()));
+
m_completionPopup = new QMenu(this);
m_completionPopup->installEventFilter(this);
connect (m_completionPopup, SIGNAL(triggered(QAction*)), SLOT(completeRecipient(QAction*)));
@@ -92,6 +93,8 @@ ComposeWidget::ComposeWidget(MainWindow *parent) :
QFont font(QLatin1String("x-trojita-terminus-like-fixed-width"));
font.setStyleHint(QFont::TypeWriter);
ui->mailText->setFont(font);
+
+ connect(ui->mailText, SIGNAL(urlsAdded(QList<QUrl>)), SLOT(slotAttachFiles(QList<QUrl>)));
}
ComposeWidget::~ComposeWidget()
@@ -573,6 +576,15 @@ void ComposeWidget::slotAskForFileAttachment()
}
}
+void ComposeWidget::slotAttachFiles(QList<QUrl> urls)
+{
+ foreach (const QUrl &url, urls) {
+ if (url.isLocalFile()) {
+ m_composer->addFileAttachment(url.path());
+ }
+ }
+}
+
void ComposeWidget::slotRemoveAttachment()
{
m_composer->removeAttachment(ui->attachmentsView->currentIndex());
diff --git a/src/Gui/ComposeWidget.h b/src/Gui/ComposeWidget.h
index 7a9882b..a0368d9 100644
--- a/src/Gui/ComposeWidget.h
+++ b/src/Gui/ComposeWidget.h
@@ -21,6 +21,8 @@
#ifndef COMPOSEWIDGET_H
#define COMPOSEWIDGET_H
+#include <QList>
+#include <QUrl>
#include <QWidget>
#include "Imap/Model/MessageComposer.h"
@@ -73,6 +75,7 @@ private slots:
void slotAskForFileAttachment();
void slotRemoveAttachment();
+ void slotAttachFiles(QList<QUrl> urls);
void slotAppendUidKnown(const uint uidValidity, const uint uid);
void slotGenUrlAuthReceived(const QString &url);
diff --git a/src/Gui/ComposeWidget.ui b/src/Gui/ComposeWidget.ui
index 2bf401d..c6f56bd 100644
--- a/src/Gui/ComposeWidget.ui
+++ b/src/Gui/ComposeWidget.ui
@@ -129,7 +129,7 @@
</widget>
</item>
<item>
- <widget class="QListView" name="attachmentsView">
+ <widget class="ComposerAttachments" name="attachmentsView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
@@ -180,7 +180,7 @@
</layout>
</item>
<item>
- <widget class="QTextEdit" name="mailText">
+ <widget class="ComposerTextEdit" name="mailText">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
@@ -202,6 +202,18 @@
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>ComposerTextEdit</class>
+ <extends>QTextEdit</extends>
+ <header>ComposerTextEdit.h</header>
+ </customwidget>
+ <customwidget>
+ <class>ComposerAttachments</class>
+ <extends>QListView</extends>
+ <header>ComposerAttachments.h</header>
+ </customwidget>
+ </customwidgets>
<tabstops>
<tabstop>sender</tabstop>
<tabstop>subject</tabstop>
diff --git a/src/Gui/ComposerAttachments.cpp b/src/Gui/ComposerAttachments.cpp
new file mode 100644
index 0000000..0b35c41
--- /dev/null
+++ b/src/Gui/ComposerAttachments.cpp
@@ -0,0 +1,64 @@
+/* Copyright (C) 2012 Thomas Lübking <[email protected]>
+ *
+ * This file is part of the Trojita Qt IMAP e-mail client,
+ * http://trojita.flaska.net/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or the version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "ComposerAttachments.h"
+#include <QDragEnterEvent>
+#include <QDebug>
+
+ComposerAttachments::ComposerAttachments(QWidget *parent) : QListView(parent), m_dragging(false), m_dragInside(false)
+{
+ setMouseTracking( true );
+ setAcceptDrops(true);
+ setDragDropMode( DragDrop );
+ setDragDropOverwriteMode( false );
+ setDragEnabled(true);
+ setDropIndicatorShown(false);
+}
+
+
+void ComposerAttachments::startDrag(Qt::DropActions da)
+{
+ m_dragging = true;
+ m_dragInside = true;
+ const QModelIndex idx = indexAt(mapFromGlobal(QCursor::pos()));
+ if (!idx.isValid())
+ setCurrentIndex(idx);
+ QListView::startDrag(da);
+ m_dragging = false;
+ if (!m_dragInside) {
+ emit itemDroppedOut();
+ }
+}
+
+
+void ComposerAttachments::dragEnterEvent(QDragEnterEvent *de)
+{
+ if (m_dragging)
+ m_dragInside = true;
+ QListView::dragEnterEvent(de);
+}
+
+void ComposerAttachments::dragLeaveEvent(QDragLeaveEvent *de)
+{
+ if (m_dragging)
+ m_dragInside = false;
+ QListView::dragLeaveEvent(de);
+}
diff --git a/src/Gui/ComposerAttachments.h b/src/Gui/ComposerAttachments.h
new file mode 100644
index 0000000..28e0ea0
--- /dev/null
+++ b/src/Gui/ComposerAttachments.h
@@ -0,0 +1,38 @@
+/* Copyright (C) 2012 Thomas Lübking <[email protected]>
+ *
+ * This file is part of the Trojita Qt IMAP e-mail client,
+ * http://trojita.flaska.net/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or the version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <QList>
+#include <QListView>
+#include <QUrl>
+
+class ComposerAttachments : public QListView {
+ Q_OBJECT
+public:
+ ComposerAttachments(QWidget *parent = 0);
+signals:
+ void itemDroppedOut();
+protected:
+ void startDrag(Qt::DropActions da);
+ void dragEnterEvent(QDragEnterEvent *de);
+ void dragLeaveEvent(QDragLeaveEvent *de);
+private:
+ bool m_dragging, m_dragInside;
+};
\ No newline at end of file
diff --git a/src/Gui/ComposerTextEdit.cpp b/src/Gui/ComposerTextEdit.cpp
new file mode 100644
index 0000000..0a39e80
--- /dev/null
+++ b/src/Gui/ComposerTextEdit.cpp
@@ -0,0 +1,101 @@
+/* Copyright (C) 2012 Thomas Lübking <[email protected]>
+ *
+ * This file is part of the Trojita Qt IMAP e-mail client,
+ * http://trojita.flaska.net/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or the version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "ComposerTextEdit.h"
+#include <QMimeData>
+#include <QPainter>
+#include <QPaintEvent>
+#include <QTimer>
+#include <QUrl>
+
+ComposerTextEdit::ComposerTextEdit(QWidget *parent) : QTextEdit(parent)
+{
+ m_notificationTimer = new QTimer(this);
+ m_notificationTimer->setSingleShot(true);
+ connect (m_notificationTimer, SIGNAL(timeout()), SLOT(resetNotification()));
+}
+
+void ComposerTextEdit::notify(const QString &n, uint timeout)
+{
+ m_notification = n;
+ if (m_notification.isEmpty() || !timeout) {
+ m_notificationTimer->stop();
+ } else {
+ m_notificationTimer->start(timeout);
+ }
+ viewport()->update();
+}
+
+void ComposerTextEdit::resetNotification()
+{
+ notify(QString());
+}
+
+bool ComposerTextEdit::canInsertFromMimeData( const QMimeData * source ) const
+{
+ QList<QUrl> urls = source->urls();
+ foreach (const QUrl &url, urls) {
+ if (url.isLocalFile())
+ return true;
+ }
+ return QTextEdit::canInsertFromMimeData(source);
+}
+
+void ComposerTextEdit::insertFromMimeData(const QMimeData *source)
+{
+ QList<QUrl> urls = source->urls();
+ foreach (const QUrl &url, urls) {
+ if (url.isLocalFile()) {
+ emit urlsAdded(urls);
+ return;
+ }
+ }
+ QTextEdit::insertFromMimeData(source);
+}
+
+void ComposerTextEdit::paintEvent(QPaintEvent *pe)
+{
+ QTextEdit::paintEvent(pe);
+ if ( !m_notification.isEmpty() )
+ {
+ const int s = width()/5;
+ QRect r(s, 0, width()-2*s, height());
+ QPainter p(viewport());
+ p.setRenderHint(QPainter::Antialiasing);
+ p.setClipRegion(pe->region());
+ QFont fnt = font();
+ fnt.setBold(true);
+ fnt.setPointSize( fnt.pointSize()*2*r.width()/(3*QFontMetrics(fnt).width(m_notification)) );
+ r.setHeight( QFontMetrics(fnt).height() + 16 );
+ r.moveCenter( rect().center() );
+
+ QColor c = palette().color(viewport()->foregroundRole());
+ c.setAlpha( 2 * c.alpha() / 3 );
+ p.setBrush( c );
+ p.setPen( Qt::NoPen );
+ p.drawRoundedRect( r, 8,8 );
+
+ p.setPen( palette().color(viewport()->backgroundRole()) );
+ p.setFont( fnt );
+ p.drawText(r, Qt::AlignCenter|Qt::TextDontClip, m_notification );
+ p.end();
+ }
+}
diff --git a/src/Gui/ComposerTextEdit.h b/src/Gui/ComposerTextEdit.h
new file mode 100644
index 0000000..eef4cf9
--- /dev/null
+++ b/src/Gui/ComposerTextEdit.h
@@ -0,0 +1,51 @@
+/* Copyright (C) 2012 Thomas Lübking <[email protected]>
+ *
+ * This file is part of the Trojita Qt IMAP e-mail client,
+ * http://trojita.flaska.net/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or the version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+class QTimer;
+
+#include <QList>
+#include <QUrl>
+#include <QTextEdit>
+
+class ComposerTextEdit : public QTextEdit {
+ Q_OBJECT
+public:
+ ComposerTextEdit(QWidget *parent = 0);
+ /**
+ * use the view to display a notification for @p timeout ms
+ * using an empty or null string will clear the notification at once
+ * a @p timeout of 0ms shows the notification until it's replaced or reset
+ */
+ void notify(const QString &n, uint timeout = 0);
+signals:
+ void urlsAdded(QList<QUrl> urls);
+protected:
+ /** DND reimplementation **/
+ bool canInsertFromMimeData( const QMimeData * source ) const;
+ void insertFromMimeData(const QMimeData *source);
+ /** painter reimplementation for notification **/
+ void paintEvent(QPaintEvent *pe);
+private slots:
+ void resetNotification();
+private:
+ QString m_notification;
+ QTimer *m_notificationTimer;
+};
\ No newline at end of file
diff --git a/src/Gui/Gui.pro b/src/Gui/Gui.pro
index fc94c68..e517052 100644
--- a/src/Gui/Gui.pro
+++ b/src/Gui/Gui.pro
@@ -43,7 +43,9 @@ SOURCES += \
MessageListWidget.cpp \
MailBoxTreeView.cpp \
LocalAddressbook.cpp \
- AbookAddressbook.cpp
+ AbookAddressbook.cpp \
+ ComposerTextEdit.cpp \
+ ComposerAttachments.cpp
HEADERS += \
../Imap/Model/ModelTest/modeltest.h \
ComposeWidget.h \
@@ -73,7 +75,9 @@ HEADERS += \
MailBoxTreeView.h \
AbstractAddressbook.h \
LocalAddressbook.h \
- AbookAddressbook.h
+ AbookAddressbook.h \
+ ComposerTextEdit.h \
+ ComposerAttachments.h
FORMS += CreateMailboxDialog.ui \
ComposeWidget.ui \
SettingsImapPage.ui \
diff --git a/src/Imap/Model/MessageComposer.cpp b/src/Imap/Model/MessageComposer.cpp
index 5ffbe45..313d4be 100644
--- a/src/Imap/Model/MessageComposer.cpp
+++ b/src/Imap/Model/MessageComposer.cpp
@@ -23,6 +23,7 @@
#include <QBuffer>
#include <QCoreApplication>
#include <QMimeData>
+#include <QUrl>
#include <QUuid>
#include "Imap/Encoders.h"
#include "Imap/Model/ComposerAttachments.h"
@@ -157,13 +158,23 @@ bool MessageComposer::dropMimeData(const QMimeData *data, Qt::DropAction action,
return true;
} else {
- return false;
+ bool attached = false;
+ QList<QUrl> urls = data->urls();
+ foreach (const QUrl &url, urls) {
+ if (url.isLocalFile()) {
+ addFileAttachment(url.path());
+ attached = true;
+ }
+ }
+ return attached;
}
}
QStringList MessageComposer::mimeTypes() const
{
- return QStringList() << QLatin1String("application/x-trojita-message-list") << QLatin1String("application/x-trojita-imap-part");
+ return QStringList() << QLatin1String("application/x-trojita-message-list") <<
+ QLatin1String("application/x-trojita-imap-part") <<
+ QLatin1String("text/uri-list");
}
void MessageComposer::setFrom(const Message::MailAddress &from)
--
1.7.12.2
From a1045995930ae00774d399f6fb526466efabddec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20L=C3=BCbking?= <[email protected]>
Date: Wed, 10 Oct 2012 00:31:20 +0200
Subject: [PATCH 3/4] send by ctrl+enter
---
src/Gui/ComposeWidget.cpp | 1 +
src/Gui/ComposerTextEdit.cpp | 8 ++++++++
src/Gui/ComposerTextEdit.h | 2 ++
3 files changed, 11 insertions(+)
diff --git a/src/Gui/ComposeWidget.cpp b/src/Gui/ComposeWidget.cpp
index efdd514..d8ad22e 100644
--- a/src/Gui/ComposeWidget.cpp
+++ b/src/Gui/ComposeWidget.cpp
@@ -95,6 +95,7 @@ ComposeWidget::ComposeWidget(MainWindow *parent) :
ui->mailText->setFont(font);
connect(ui->mailText, SIGNAL(urlsAdded(QList<QUrl>)), SLOT(slotAttachFiles(QList<QUrl>)));
+ connect(ui->mailText, SIGNAL(sendRequest()), SLOT(send()));
}
ComposeWidget::~ComposeWidget()
diff --git a/src/Gui/ComposerTextEdit.cpp b/src/Gui/ComposerTextEdit.cpp
index 0a39e80..5f956e1 100644
--- a/src/Gui/ComposerTextEdit.cpp
+++ b/src/Gui/ComposerTextEdit.cpp
@@ -71,6 +71,14 @@ void ComposerTextEdit::insertFromMimeData(const QMimeData *source)
QTextEdit::insertFromMimeData(source);
}
+void ComposerTextEdit::keyReleaseEvent(QKeyEvent *ke) {
+ if ((ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) && ke->modifiers() == Qt::ControlModifier) {
+ emit sendRequest();
+ return;
+ }
+ QTextEdit::keyReleaseEvent(ke);
+}
+
void ComposerTextEdit::paintEvent(QPaintEvent *pe)
{
QTextEdit::paintEvent(pe);
diff --git a/src/Gui/ComposerTextEdit.h b/src/Gui/ComposerTextEdit.h
index eef4cf9..c347e92 100644
--- a/src/Gui/ComposerTextEdit.h
+++ b/src/Gui/ComposerTextEdit.h
@@ -36,11 +36,13 @@ public:
*/
void notify(const QString &n, uint timeout = 0);
signals:
+ void sendRequest();
void urlsAdded(QList<QUrl> urls);
protected:
/** DND reimplementation **/
bool canInsertFromMimeData( const QMimeData * source ) const;
void insertFromMimeData(const QMimeData *source);
+ void keyReleaseEvent(QKeyEvent *event);
/** painter reimplementation for notification **/
void paintEvent(QPaintEvent *pe);
private slots:
--
1.7.12.2
From c6748efcf013dbc7ab0dce34fc2e7c3d74127789 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20L=C3=BCbking?= <[email protected]>
Date: Wed, 10 Oct 2012 00:33:33 +0200
Subject: [PATCH 4/4] constrain input, no rich text, 72 chars, wordwrap
---
src/Gui/ComposerTextEdit.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/Gui/ComposerTextEdit.cpp b/src/Gui/ComposerTextEdit.cpp
index 5f956e1..48efc55 100644
--- a/src/Gui/ComposerTextEdit.cpp
+++ b/src/Gui/ComposerTextEdit.cpp
@@ -28,6 +28,10 @@
ComposerTextEdit::ComposerTextEdit(QWidget *parent) : QTextEdit(parent)
{
+ setAcceptRichText(false);
+ setLineWrapMode(QTextEdit::FixedColumnWidth);
+ setWordWrapMode(QTextOption::WordWrap);
+ setLineWrapColumnOrWidth(72);
m_notificationTimer = new QTimer(this);
m_notificationTimer->setSingleShot(true);
connect (m_notificationTimer, SIGNAL(timeout()), SLOT(resetNotification()));
--
1.7.12.2