CompleteMessageWidget::CompleteMessageWidget(QWidget *parent, QSettings *settings, Plugins::PluginManager *pluginManager,
        Imap::Mailbox::FavoriteTagsModel *m_favoriteTags)
    : QWidget(parent)
    , FindBarMixin(this), settings(settings)
{
    setWindowIcon(UiUtils::loadIcon(QStringLiteral("mail-mark-read")));
    messageView = new MessageView(this, settings, pluginManager, m_favoriteTags);
    area = new QScrollArea();
    area->setWidget(messageView);
    area->setWidgetResizable(true);
    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(area);
    animator = new QPropertyAnimation(area->verticalScrollBar(), "value", this);
    animator->setDuration(250); // the default, maybe play with values
    animator->setEasingCurve(QEasingCurve::InOutCubic); // InOutQuad?

    layout->addWidget(m_findBar);
    connect(messageView, &MessageView::searchRequestedBy,
            this, [this](EmbeddedWebView *w) {
        searchRequestedBy(w);
    });
    // because the FindBarMixin is not a QObject, we have to use lambda above, otherwise a cast
    // from FindBarMixin * to QObject * fails

    auto geometry = settings->value(Common::SettingsNames::completeMessageWidgetGeometry);
    if (geometry.isValid()) {
        restoreGeometry(geometry.toByteArray());
    } else {
        resize(800, 600);
    }
}
Beispiel #2
0
MessageHeadersWidget::MessageHeadersWidget(QWidget *parent, const QModelIndex &messageIndex)
    : QWidget(parent)
    , FindBarMixin(this)
    , m_widget(new QWebView(this))

{
    setWindowIcon(UiUtils::loadIcon(QStringLiteral("text-x-hex")));
    //: Translators: %1 is the UID of a message (a number) and %2 is the name of a mailbox.
    setWindowTitle(tr("Message headers of UID %1 in %2").arg(
                       QString::number(messageIndex.data(Imap::Mailbox::RoleMessageUid).toUInt()),
                       messageIndex.parent().parent().data(Imap::Mailbox::RoleMailboxName).toString()
                       ));
    Q_ASSERT(messageIndex.isValid());

    auto netAccess = new Imap::Network::MsgPartNetAccessManager(this);
    netAccess->setModelMessage(messageIndex);
    m_widget->page()->setNetworkAccessManager(netAccess);
    m_widget->setUrl(QUrl(QStringLiteral("trojita-imap://msg/HEADER")));

    auto find = new QAction(UiUtils::loadIcon(QStringLiteral("edit-find")), tr("Search..."), this);
    find->setShortcut(tr("Ctrl+F"));
    connect(find, &QAction::triggered, this, [this]() {
        searchRequestedBy(m_widget);
    });
    addAction(find);

    auto layout = new QVBoxLayout(this);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(m_widget, 1);
    layout->addWidget(m_findBar);
    setLayout(layout);
}
Beispiel #3
0
void MessageView::triggerSearchDialog()
{
    emit searchRequestedBy(qobject_cast<QWebView*>(sender()));
}