0.1.4 kwallet optimisation related fix, DnD files into convs, visual fixes

This commit is contained in:
Blue 2020-04-14 19:30:33 +03:00
parent 21c7d65027
commit cb44b12a7e
18 changed files with 162 additions and 47 deletions

View file

@ -34,7 +34,8 @@ Squawk::Squawk(QWidget *parent) :
requestedAccountsForPasswords(),
prompt(0),
currentConversation(0),
restoreSelection()
restoreSelection(),
needToRestore(false)
{
m_ui->setupUi(this);
m_ui->roster->setModel(&rosterModel);
@ -1139,6 +1140,7 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn
if (id != 0) {
delete id;
}
needToRestore = true;
restoreSelection = previous;
return;
}
@ -1204,5 +1206,8 @@ void Squawk::onRosterSelectionChanged(const QModelIndex& current, const QModelIn
void Squawk::onContextAboutToHide()
{
m_ui->roster->selectionModel()->setCurrentIndex(restoreSelection, QItemSelectionModel::ClearAndSelect);
if (needToRestore) {
needToRestore = false;
m_ui->roster->selectionModel()->setCurrentIndex(restoreSelection, QItemSelectionModel::ClearAndSelect);
}
}

View file

@ -126,6 +126,7 @@ private:
QInputDialog* prompt;
Conversation* currentConversation;
QModelIndex restoreSelection;
bool needToRestore;
protected:
void closeEvent(QCloseEvent * event) override;

View file

@ -129,8 +129,18 @@
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>26</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-size:26pt;&quot;&gt;Please select a contact to start chatting&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Please select a contact to start chatting</string>
</property>
<property name="textFormat">
<enum>Qt::PlainText</enum>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>

View file

@ -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) {

View file

@ -22,6 +22,8 @@
#include <QWidget>
#include <QScopedPointer>
#include <QMap>
#include <QMimeData>
#include <QFileInfo>
#include "shared/message.h"
#include "order.h"
@ -105,6 +107,9 @@ protected:
void addAttachedFile(const QString& path);
void removeAttachedFile(Badge* badge);
void clearAttachedFiles();
void dragEnterEvent(QDragEnterEvent* event) override;
void dragLeaveEvent(QDragLeaveEvent* event) override;
void dropEvent(QDropEvent* event) override;
protected slots:
void onEnterPressed();
@ -138,6 +143,7 @@ protected:
QLabel* statusIcon;
QLabel* statusLabel;
FlowLayout* filesLayout;
QWidget* overlay;
W::Order<Badge*, Badge::Comparator> filesToAttach;
Scroll scroll;
bool manualSliderChange;

View file

@ -16,10 +16,10 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
@ -32,7 +32,7 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
@ -115,6 +115,13 @@
</property>
<item>
<widget class="QLabel" name="nameLabel">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string/>
</property>
@ -128,6 +135,12 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<italic>true</italic>
</font>
</property>
<property name="text">
<string/>
</property>
@ -230,7 +243,7 @@
<x>0</x>
<y>0</y>
<width>520</width>
<height>392</height>
<height>385</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
@ -258,7 +271,7 @@
<zorder>widget_3</zorder>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QWidget" name="widget_2" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">

View file

@ -126,7 +126,11 @@ VCard::VCard(const QString& jid, bool edit, QWidget* parent):
overlay->setAutoFillBackground(true);
overlay->setGraphicsEffect(opacity);
progressLabel->setAlignment(Qt::AlignCenter);
progressLabel->setStyleSheet("font: 16pt");
QFont pf = progressLabel->font();
pf.setBold(true);
pf.setPointSize(26);
progressLabel->setFont(pf);
progressLabel->setWordWrap(true);
nl->addStretch();
nl->addWidget(progress);
nl->addWidget(progressLabel);