forked from blue/squawk
a bit of refactor, fix the time to request next portion of messages in ui, fancy shadows are back!
This commit is contained in:
parent
216dcd29e9
commit
05d6761baa
12 changed files with 826 additions and 600 deletions
|
@ -26,5 +26,6 @@ add_library(squawkWidgets ${squawkWidgets_SRC})
|
|||
# Use the Widgets module from Qt 5.
|
||||
target_link_libraries(squawkWidgets vCardUI)
|
||||
target_link_libraries(squawkWidgets Qt5::Widgets)
|
||||
target_link_libraries(squawkWidgets squawkUI)
|
||||
|
||||
qt5_use_modules(squawkWidgets Core Widgets)
|
||||
|
|
|
@ -46,19 +46,23 @@ Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el,
|
|||
filesToAttach(),
|
||||
feed(new FeedView()),
|
||||
delegate(new MessageDelegate(this)),
|
||||
scroll(down),
|
||||
manualSliderChange(false),
|
||||
tsb(QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient) == 1)
|
||||
tsb(QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient) == 1),
|
||||
shadow(10, 1, Qt::black, this)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
shadow.setFrames(true, false, true, false);
|
||||
|
||||
feed->setItemDelegate(delegate);
|
||||
feed->setFrameShape(QFrame::NoFrame);
|
||||
delegate->initializeFonts(feed->getFont());
|
||||
feed->setModel(el->feed);
|
||||
el->feed->incrementObservers();
|
||||
m_ui->widget->layout()->addWidget(feed);
|
||||
|
||||
connect(el->feed, &Models::MessageFeed::newMessage, this, &Conversation::onFeedMessage);
|
||||
connect(feed, &FeedView::resized, this, &Conversation::positionShadow);
|
||||
|
||||
connect(acc, &Models::Account::childChanged, this, &Conversation::onAccountChanged);
|
||||
|
||||
|
@ -77,9 +81,6 @@ Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el,
|
|||
|
||||
m_ui->messageEditor->installEventFilter(&ker);
|
||||
|
||||
//QScrollBar* vs = m_ui->scrollArea->verticalScrollBar();
|
||||
//m_ui->scrollArea->setWidget(line);
|
||||
//vs->installEventFilter(&vis);
|
||||
|
||||
//line->setAutoFillBackground(false);
|
||||
//if (testAttribute(Qt::WA_TranslucentBackground)) {
|
||||
|
@ -93,28 +94,7 @@ Conversation::Conversation(bool muc, Models::Account* acc, Models::Element* el,
|
|||
//line->setMyAvatarPath(acc->getAvatarPath());
|
||||
//line->setMyName(acc->getName());
|
||||
|
||||
QGridLayout* gr = static_cast<QGridLayout*>(layout());
|
||||
QLabel* progressLabel = new QLabel(tr("Drop files here to attach them to your message"));
|
||||
gr->addWidget(overlay, 0, 0, 2, 1);
|
||||
QVBoxLayout* nl = new QVBoxLayout();
|
||||
QGraphicsOpacityEffect* opacity = new QGraphicsOpacityEffect();
|
||||
opacity->setOpacity(0.8);
|
||||
overlay->setLayout(nl);
|
||||
overlay->setBackgroundRole(QPalette::Base);
|
||||
overlay->setAutoFillBackground(true);
|
||||
overlay->setGraphicsEffect(opacity);
|
||||
progressLabel->setAlignment(Qt::AlignCenter);
|
||||
QFont pf = progressLabel->font();
|
||||
pf.setBold(true);
|
||||
pf.setPointSize(26);
|
||||
progressLabel->setWordWrap(true);
|
||||
progressLabel->setFont(pf);
|
||||
nl->addStretch();
|
||||
nl->addWidget(progressLabel);
|
||||
nl->addStretch();
|
||||
overlay->hide();
|
||||
|
||||
applyVisualEffects();
|
||||
initializeOverlay();
|
||||
}
|
||||
|
||||
Conversation::~Conversation()
|
||||
|
@ -136,14 +116,28 @@ void Conversation::onAccountChanged(Models::Item* item, int row, int col)
|
|||
}
|
||||
}
|
||||
|
||||
void Conversation::applyVisualEffects()
|
||||
void Conversation::initializeOverlay()
|
||||
{
|
||||
// DropShadowEffect *e1 = new DropShadowEffect;
|
||||
// e1->setBlurRadius(10);
|
||||
// e1->setColor(Qt::black);
|
||||
// e1->setThickness(1);
|
||||
// e1->setFrame(true, false, true, false);
|
||||
// m_ui->scrollArea->setGraphicsEffect(e1);
|
||||
QGridLayout* gr = static_cast<QGridLayout*>(layout());
|
||||
QLabel* progressLabel = new QLabel(tr("Drop files here to attach them to your message"));
|
||||
gr->addWidget(overlay, 0, 0, 2, 1);
|
||||
QVBoxLayout* nl = new QVBoxLayout();
|
||||
QGraphicsOpacityEffect* opacity = new QGraphicsOpacityEffect();
|
||||
opacity->setOpacity(0.8);
|
||||
overlay->setLayout(nl);
|
||||
overlay->setBackgroundRole(QPalette::Base);
|
||||
overlay->setAutoFillBackground(true);
|
||||
overlay->setGraphicsEffect(opacity);
|
||||
progressLabel->setAlignment(Qt::AlignCenter);
|
||||
QFont pf = progressLabel->font();
|
||||
pf.setBold(true);
|
||||
pf.setPointSize(26);
|
||||
progressLabel->setWordWrap(true);
|
||||
progressLabel->setFont(pf);
|
||||
nl->addStretch();
|
||||
nl->addWidget(progressLabel);
|
||||
nl->addStretch();
|
||||
overlay->hide();
|
||||
}
|
||||
|
||||
void Conversation::setName(const QString& name)
|
||||
|
@ -325,7 +319,7 @@ void Conversation::onTextEditDocSizeChanged(const QSizeF& size)
|
|||
|
||||
void Conversation::setFeedFrames(bool top, bool right, bool bottom, bool left)
|
||||
{
|
||||
//static_cast<DropShadowEffect*>(m_ui->scrollArea->graphicsEffect())->setFrame(top, right, bottom, left);
|
||||
shadow.setFrames(top, right, bottom, left);
|
||||
}
|
||||
|
||||
void Conversation::dragEnterEvent(QDragEnterEvent* event)
|
||||
|
@ -399,3 +393,13 @@ void Conversation::onMessage(const Shared::Message& msg)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Conversation::positionShadow()
|
||||
{
|
||||
int w = width();
|
||||
int h = feed->height();
|
||||
|
||||
shadow.resize(w, h);
|
||||
shadow.move(feed->pos());
|
||||
shadow.raise();
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "ui/utils/badge.h"
|
||||
#include "ui/utils/feedview.h"
|
||||
#include "ui/utils/messagedelegate.h"
|
||||
#include "ui/utils/shadowoverlay.h"
|
||||
#include "shared/icons.h"
|
||||
#include "shared/utils.h"
|
||||
|
||||
|
@ -81,7 +82,6 @@ signals:
|
|||
|
||||
protected:
|
||||
virtual void setName(const QString& name);
|
||||
void applyVisualEffects();
|
||||
virtual Shared::Message createMessage() const;
|
||||
void setStatus(const QString& status);
|
||||
void addAttachedFile(const QString& path);
|
||||
|
@ -90,6 +90,7 @@ protected:
|
|||
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||
void dragLeaveEvent(QDragLeaveEvent* event) override;
|
||||
void dropEvent(QDropEvent* event) override;
|
||||
void initializeOverlay();
|
||||
virtual void onMessage(const Shared::Message& msg);
|
||||
|
||||
protected slots:
|
||||
|
@ -101,16 +102,12 @@ protected slots:
|
|||
void onTextEditDocSizeChanged(const QSizeF& size);
|
||||
void onAccountChanged(Models::Item* item, int row, int col);
|
||||
void onFeedMessage(const Shared::Message& msg);
|
||||
void positionShadow();
|
||||
|
||||
public:
|
||||
const bool isMuc;
|
||||
|
||||
protected:
|
||||
enum Scroll {
|
||||
nothing,
|
||||
keep,
|
||||
down
|
||||
};
|
||||
Models::Account* account;
|
||||
Models::Element* element;
|
||||
QString palJid;
|
||||
|
@ -125,9 +122,10 @@ protected:
|
|||
W::Order<Badge*, Badge::Comparator> filesToAttach;
|
||||
FeedView* feed;
|
||||
MessageDelegate* delegate;
|
||||
Scroll scroll;
|
||||
bool manualSliderChange;
|
||||
bool tsb; //transient scroll bars
|
||||
|
||||
ShadowOverlay shadow;
|
||||
};
|
||||
|
||||
#endif // CONVERSATION_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue