Hi, there's a problem with the compose widget -- when there are too many
recipients, there is not much space left for the actual area where one
could type the message. That's why I'd like to add a QScrollArea to the
mix. I've tried two approaches, but I don't like the result of either of
them too much.
The first one (see the attached patch) wraps the whole "envelopeLayout"
(i.e. the From field, all recipients and the subject). I think that this is
suboptimal because it can hide important fields like From and Subject.
The second one wraps just the recipients. It behaves "strange" and is ugly
-- the column boundary of the two nested form layouts is not aligned for
obvious reasons, and IIRC I wasn't able to get the whole thing to expand
properly when I move the splitter between the "actual mail body" and the
"stuff above" parts.
I suspect that the tab order is probably wrong in at least one of the
corner cases, etc. In short, I don't like writing GUI code. Thomas, could
you please help me here? Others are of course more than welcome to chime in
as well.
Cheers,
Jan
--
Trojitá, a fast Qt IMAP e-mail client -- http://trojita.flaska.net/
diff --git a/src/Gui/ComposeWidget.ui b/src/Gui/ComposeWidget.ui
index 11bfca6..8b70aed 100644
--- a/src/Gui/ComposeWidget.ui
+++ b/src/Gui/ComposeWidget.ui
@@ -35,7 +35,28 @@
<property name="childrenCollapsible">
<bool>false</bool>
</property>
+ <widget class="QScrollArea" name="scrollArea">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
+ <horstretch>5</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
<widget class="QWidget" name="envelopeWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>295</width>
+ <height>59</height>
+ </rect>
+ </property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>4</horstretch>
@@ -81,6 +102,7 @@
</item>
</layout>
</widget>
+ </widget>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
diff --git a/src/Gui/ComposeWidget.cpp b/src/Gui/ComposeWidget.cpp
index 7eef98f..e7e573c 100644
--- a/src/Gui/ComposeWidget.cpp
+++ b/src/Gui/ComposeWidget.cpp
@@ -56,7 +56,7 @@
namespace
{
-enum { OFFSET_OF_FIRST_ADDRESSEE = 1 };
+enum { OFFSET_OF_FIRST_ADDRESSEE = 0 };
}
namespace Gui
@@ -316,7 +316,7 @@ void ComposeWidget::setData(const QList<QPair<Composer::RecipientKind, QString>
addRecipient(i, recipients.at(i).first, recipients.at(i).second);
}
updateRecipientList();
- ui->envelopeLayout->itemAt(OFFSET_OF_FIRST_ADDRESSEE, QFormLayout::FieldRole)->widget()->setFocus();
+ ui->recipientsLayout->itemAt(OFFSET_OF_FIRST_ADDRESSEE, QFormLayout::FieldRole)->widget()->setFocus();
ui->subject->setText(subject);
const bool wasEdited = m_messageEverEdited;
ui->mailText->setText(body);
@@ -439,8 +439,8 @@ void ComposeWidget::addRecipient(int position, Composer::RecipientKind kind, con
connect(edit, SIGNAL(editingFinished()), SLOT(collapseRecipients()));
connect(edit, SIGNAL(textChanged(QString)), m_recipientListUpdateTimer, SLOT(start()));
m_recipients.insert(position, Recipient(combo, edit));
- ui->envelopeLayout->insertRow(actualRow(ui->envelopeLayout, position + OFFSET_OF_FIRST_ADDRESSEE), combo, edit);
- setTabOrder(formPredecessor(ui->envelopeLayout, combo), combo);
+ ui->recipientsLayout->insertRow(actualRow(ui->recipientsLayout, position + OFFSET_OF_FIRST_ADDRESSEE), combo, edit);
+ setTabOrder(formPredecessor(ui->recipientsLayout, combo), combo);
setTabOrder(combo, edit);
}
@@ -468,8 +468,8 @@ void ComposeWidget::removeRecipient(int pos)
// removing the widgets from the layout is important
// a) not doing so leaks (minor)
// b) deleteLater() crosses the evenchain and so our actualRow function would be tricked
- ui->envelopeLayout->removeWidget(m_recipients.at(pos).first);
- ui->envelopeLayout->removeWidget(m_recipients.at(pos).second);
+ ui->recipientsLayout->removeWidget(m_recipients.at(pos).first);
+ ui->recipientsLayout->removeWidget(m_recipients.at(pos).second);
m_recipients.at(pos).first->deleteLater();
m_recipients.at(pos).second->deleteLater();
m_recipients.removeAt(pos);
diff --git a/src/Gui/ComposeWidget.ui b/src/Gui/ComposeWidget.ui
index 11bfca6..d516fe0 100644
--- a/src/Gui/ComposeWidget.ui
+++ b/src/Gui/ComposeWidget.ui
@@ -66,7 +66,7 @@
</property>
</widget>
</item>
- <item row="1" column="0">
+ <item row="2" column="0">
<widget class="QLabel" name="subjectLabel">
<property name="text">
<string>Subject</string>
@@ -76,9 +76,34 @@
</property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="2" column="1">
<widget class="LineEdit" name="subject"/>
</item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QScrollArea" name="scrollArea">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="scrollAreaWidgetContents">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>516</width>
+ <height>72</height>
+ </rect>
+ </property>
+ <layout class="QFormLayout" name="recipientsLayout">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::ExpandingFieldsGrow</enum>
+ </property>
+ </layout>
+ </widget>
+ </widget>
+ </item>
</layout>
</widget>
<widget class="QGroupBox" name="groupBox">