[kde-doc-english] [trojita] src/Gui: GUI: expand previewable attachments upon first click on the attachment icon
Jan Kundrát
jkt at flaska.net
Thu Apr 3 06:22:18 UTC 2014
Git commit 697333adc57186df168c6d583d3553a43377aea6 by Jan Kundrát.
Committed on 01/04/2014 at 12:46.
Pushed by jkt into branch 'master'.
GUI: expand previewable attachments upon first click on the attachment icon
The motivation is to make expanding of previewable attachments smooth, but at
the same time do not interfere with the way how the button has worked so far too
much.
When an attachment cannot be previewed, nothing changes and everything works as
it used to work before.
When a preview can be shown, however, clicking on the icon of the attachment at
the time the preview is collapsed will simply show the preview. When the preview
is shown, however, clicking any part of the icon will still bring up the menu as
it used to work previously.
This is an alternative implementation to review #117068.
v2: Use another approach for determining what action to take based on the actual
state of the preview in order to prevent duplicate connections. Thanks to Thomas
Lübking for pointing out a possible problem here.
BUG: 332586
REVIEW: 117295
M +21 -3 src/Gui/AttachmentView.cpp
M +3 -0 src/Gui/AttachmentView.h
http://commits.kde.org/trojita/697333adc57186df168c6d583d3553a43377aea6
diff --git a/src/Gui/AttachmentView.cpp b/src/Gui/AttachmentView.cpp
index a00cef0..1cf04f8 100644
--- a/src/Gui/AttachmentView.cpp
+++ b/src/Gui/AttachmentView.cpp
@@ -94,6 +94,7 @@ AttachmentView::AttachmentView(QWidget *parent, Imap::Network::MsgPartNetAccessM
m_showHideAttachment->setCheckable(true);
m_showHideAttachment->setChecked(!m_contentWidget->isHidden());
connect(m_showHideAttachment, SIGNAL(triggered(bool)), m_contentWidget, SLOT(setVisible(bool)));
+ connect(m_showHideAttachment, SIGNAL(triggered()), this, SLOT(updateShowHideAttachmentState()));
}
// Icon on the left
@@ -105,7 +106,7 @@ AttachmentView::AttachmentView(QWidget *parent, Imap::Network::MsgPartNetAccessM
m_icon->setPopupMode(QToolButton::MenuButtonPopup);
m_icon->setMenu(m_menu);
connect(m_icon, SIGNAL(pressed()), SLOT(toggleIconCursor()));
- connect(m_icon, SIGNAL(clicked()), m_icon, SLOT(showMenu()));
+ connect(m_icon, SIGNAL(clicked()), SLOT(showMenuOrPreview()));
connect(m_icon, SIGNAL(released()), SLOT(toggleIconCursor()));
m_icon->setCursor(Qt::ArrowCursor);
@@ -172,6 +173,8 @@ AttachmentView::AttachmentView(QWidget *parent, Imap::Network::MsgPartNetAccessM
if (m_contentWidget) {
contentLayout->addWidget(m_contentWidget);
}
+
+ updateShowHideAttachmentState();
}
void AttachmentView::slotDownloadAttachment()
@@ -248,10 +251,25 @@ void AttachmentView::openDownloadedAttachment()
m_openAttachment->setEnabled(true);
}
+bool AttachmentView::previewIsShown() const
+{
+ return m_contentWidget && m_contentWidget->isVisibleTo(const_cast<AttachmentView*>(this));
+}
+
void AttachmentView::updateShowHideAttachmentState()
{
- if (m_showHideAttachment)
- m_showHideAttachment->setChecked(m_contentWidget && m_contentWidget->isVisibleTo(this));
+ if (m_showHideAttachment) {
+ m_showHideAttachment->setChecked(previewIsShown());
+ }
+}
+
+void AttachmentView::showMenuOrPreview()
+{
+ if (previewIsShown() || !m_contentWidget) {
+ showMenu();
+ } else {
+ m_showHideAttachment->trigger();
+ }
}
void AttachmentView::showMenu()
diff --git a/src/Gui/AttachmentView.h b/src/Gui/AttachmentView.h
index ba58934..14599c4 100644
--- a/src/Gui/AttachmentView.h
+++ b/src/Gui/AttachmentView.h
@@ -77,6 +77,7 @@ private slots:
void onOpenFailed();
void updateShowHideAttachmentState();
void showMenu();
+ void showMenuOrPreview();
void toggleIconCursor();
private:
@@ -98,6 +99,8 @@ private:
QPoint m_dragStartPos;
+ bool previewIsShown() const;
+
AttachmentView(const AttachmentView &); // don't implement
AttachmentView &operator=(const AttachmentView &); // don't implement
};
More information about the kde-doc-english
mailing list