EnvelopeView::EnvelopeView(QWidget *parent, MessageView *messageView): QWidget(parent), m_messageView(messageView) { // we create a dummy header, pass it through the style and the use it's color roles so we // know what headers in general look like in the system QHeaderView helpingHeader(Qt::Horizontal); helpingHeader.ensurePolished(); setBackgroundRole(helpingHeader.backgroundRole()); setForegroundRole(helpingHeader.foregroundRole()); QVBoxLayout *lay = new QVBoxLayout(this); lay->setSpacing(0); lay->setContentsMargins(0, 0, 0, 0); setLayout(lay); }
EnvelopeView::EnvelopeView(QWidget *parent, MessageView *messageView): QLabel(parent) { // we create a dummy header, pass it through the style and the use it's color roles so we // know what headers in general look like in the system QHeaderView helpingHeader(Qt::Horizontal); helpingHeader.ensurePolished(); setBackgroundRole(helpingHeader.backgroundRole()); setForegroundRole(helpingHeader.foregroundRole()); setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse); setIndent(5); setWordWrap(true); connect(this, SIGNAL(linkHovered(QString)), this, SLOT(onLinkHovered(QString))); QFontMetrics fm(font()); int iconSize = fm.boundingRect(QLatin1Char('M')).height(); contactKnownUrl = Gui::Util::resizedImageAsDataUrl(QLatin1String(":/icons/contact-known.png"), iconSize); contactUnknownUrl = Gui::Util::resizedImageAsDataUrl(QLatin1String(":/icons/contact-unknown.png"), iconSize); connect(this, SIGNAL(linkActivated(QString)), messageView, SLOT(headerLinkActivated(QString))); connect(this, SIGNAL(addressDetailsRequested(QString,QStringList&)), messageView, SIGNAL(addressDetailsRequested(QString,QStringList&))); }
MessageView::MessageView(QWidget *parent, QSettings *settings): QWidget(parent), m_settings(settings) { QPalette pal = palette(); pal.setColor(backgroundRole(), palette().color(QPalette::Active, QPalette::Base)); pal.setColor(foregroundRole(), palette().color(QPalette::Active, QPalette::Text)); setPalette(pal); setAutoFillBackground(true); setFocusPolicy(Qt::StrongFocus); // not by the wheel netAccess = new Imap::Network::MsgPartNetAccessManager(this); connect(netAccess, SIGNAL(requestingExternal(QUrl)), this, SLOT(externalsRequested(QUrl))); factory = new PartWidgetFactory(netAccess, this); emptyView = new EmbeddedWebView(this, new QNetworkAccessManager(this)); emptyView->setFixedSize(450,300); QMetaObject::invokeMethod(emptyView, "handlePageLoadFinished", Qt::QueuedConnection); emptyView->setPage(new UserAgentWebPage(emptyView)); emptyView->installEventFilter(this); emptyView->setAutoFillBackground(false); viewer = emptyView; //BEGIN create header section headerSection = new QWidget(this); // we create a dummy header, pass it through the style and the use it's color roles so we // know what headers in general look like in the system QHeaderView helpingHeader(Qt::Horizontal); helpingHeader.ensurePolished(); pal = headerSection->palette(); pal.setColor(headerSection->backgroundRole(), palette().color(QPalette::Active, helpingHeader.backgroundRole())); pal.setColor(headerSection->foregroundRole(), palette().color(QPalette::Active, helpingHeader.foregroundRole())); headerSection->setPalette(pal); headerSection->setAutoFillBackground(true); // the actual mail header m_envelope = new EnvelopeView(headerSection, this); // the tag bar tags = new TagListWidget(headerSection); tags->setBackgroundRole(helpingHeader.backgroundRole()); tags->setForegroundRole(helpingHeader.foregroundRole()); tags->hide(); connect(tags, SIGNAL(tagAdded(QString)), this, SLOT(newLabelAction(QString))); connect(tags, SIGNAL(tagRemoved(QString)), this, SLOT(deleteLabelAction(QString))); // whether we allow to load external elements externalElements = new ExternalElementsWidget(this); externalElements->hide(); connect(externalElements, SIGNAL(loadingEnabled()), this, SLOT(externalsEnabled())); // layout the header layout = new QVBoxLayout(headerSection); layout->addWidget(m_envelope, 1); layout->addWidget(tags, 3); layout->addWidget(externalElements, 1); //END create header section //BEGIN layout the message layout = new QVBoxLayout(this); layout->setSpacing(0); layout->setContentsMargins(0,0,0,0); layout->addWidget(headerSection, 1); headerSection->hide(); // put the actual messages into an extra horizontal view // this allows us easy usage of the trailing stretch and also to indent the message a bit QHBoxLayout *hLayout = new QHBoxLayout; hLayout->setContentsMargins(6,6,6,0); hLayout->addWidget(viewer); static_cast<QVBoxLayout*>(layout)->addLayout(hLayout, 1); // add a strong stretch to squeeze header and message to the top // possibly passing a large stretch factor to the message could be enough... layout->addStretch(1000); //END layout the message // make the layout used to add messages our new horizontal layout layout = hLayout; markAsReadTimer = new QTimer(this); markAsReadTimer->setSingleShot(true); connect(markAsReadTimer, SIGNAL(timeout()), this, SLOT(markAsRead())); m_loadingSpinner = new Spinner(this); m_loadingSpinner->setText(tr("Fetching\nMessage")); m_loadingSpinner->setType(Spinner::Sun); }