forked from blue/squawk
0.1.4 kwallet optimisation related fix, DnD files into convs, visual fixes
This commit is contained in:
parent
21c7d65027
commit
cb44b12a7e
18 changed files with 162 additions and 47 deletions
|
@ -44,6 +44,7 @@ Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, c
|
|||
statusIcon(0),
|
||||
statusLabel(0),
|
||||
filesLayout(0),
|
||||
overlay(new QWidget()),
|
||||
filesToAttach(),
|
||||
scroll(down),
|
||||
manualSliderChange(false),
|
||||
|
@ -92,15 +93,26 @@ Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, c
|
|||
line->setMyAvatarPath(acc->getAvatarPath());
|
||||
line->setMyName(acc->getName());
|
||||
|
||||
QFont nf = m_ui->nameLabel->font();
|
||||
nf.setBold(true);
|
||||
nf.setPointSize(nf.pointSize() + 2);
|
||||
m_ui->nameLabel->setFont(nf);
|
||||
|
||||
QFont sf = statusLabel->font();
|
||||
sf.setItalic(true);
|
||||
sf.setPointSize(sf.pointSize() - 2);
|
||||
statusLabel->setFont(sf);
|
||||
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();
|
||||
}
|
||||
|
@ -362,10 +374,16 @@ void Conversation::addAttachedFile(const QString& path)
|
|||
Badge* badge = new Badge(path, info.fileName(), QIcon::fromTheme(type.iconName()));
|
||||
|
||||
connect(badge, &Badge::close, this, &Conversation::onBadgeClose);
|
||||
filesToAttach.push_back(badge); //TODO neet to check if there are any duplicated ids
|
||||
filesLayout->addWidget(badge);
|
||||
if (filesLayout->count() == 1) {
|
||||
filesLayout->setContentsMargins(3, 3, 3, 3);
|
||||
try {
|
||||
filesToAttach.push_back(badge);
|
||||
filesLayout->addWidget(badge);
|
||||
if (filesLayout->count() == 1) {
|
||||
filesLayout->setContentsMargins(3, 3, 3, 3);
|
||||
}
|
||||
} catch (const W::Order<Badge*, Badge::Comparator>::Duplicates& e) {
|
||||
delete badge;
|
||||
} catch (...) {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -421,6 +439,53 @@ void Conversation::setFeedFrames(bool top, bool right, bool bottom, bool left)
|
|||
static_cast<DropShadowEffect*>(m_ui->scrollArea->graphicsEffect())->setFrame(top, right, bottom, left);
|
||||
}
|
||||
|
||||
void Conversation::dragEnterEvent(QDragEnterEvent* event)
|
||||
{
|
||||
bool accept = false;
|
||||
if (event->mimeData()->hasUrls()) {
|
||||
QList<QUrl> list = event->mimeData()->urls();
|
||||
for (const QUrl& url : list) {
|
||||
if (url.isLocalFile()) {
|
||||
QFileInfo info(url.toLocalFile());
|
||||
if (info.isReadable() && info.isFile()) {
|
||||
accept = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (accept) {
|
||||
event->acceptProposedAction();
|
||||
overlay->show();
|
||||
}
|
||||
}
|
||||
|
||||
void Conversation::dragLeaveEvent(QDragLeaveEvent* event)
|
||||
{
|
||||
overlay->hide();
|
||||
}
|
||||
|
||||
void Conversation::dropEvent(QDropEvent* event)
|
||||
{
|
||||
bool accept = false;
|
||||
if (event->mimeData()->hasUrls()) {
|
||||
QList<QUrl> list = event->mimeData()->urls();
|
||||
for (const QUrl& url : list) {
|
||||
if (url.isLocalFile()) {
|
||||
QFileInfo info(url.toLocalFile());
|
||||
if (info.isReadable() && info.isFile()) {
|
||||
addAttachedFile(info.canonicalFilePath());
|
||||
accept = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (accept) {
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
overlay->hide();
|
||||
}
|
||||
|
||||
bool VisibilityCatcher::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::Show) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue