This commit is contained in:
shunf4 2021-07-07 21:45:08 +08:00
parent ef1a9846bf
commit 5d1f4cc36f
19 changed files with 217 additions and 37 deletions

View file

@ -33,6 +33,9 @@ Badge::Badge(const QString& p_id, const QString& p_text, const QIcon& icon, QWid
image->setPixmap(icon.pixmap(25, 25));
closeButton->setIcon(QIcon::fromTheme("tab-close"));
QIcon qIcon;
qIcon.addFile(QString::fromUtf8(":/images/fallback/dark/big/edit-none.svg"), QSize(), QIcon::Normal, QIcon::Off);
closeButton->setIcon(qIcon);
closeButton->setMaximumHeight(25);
closeButton->setMaximumWidth(25);

View file

@ -203,16 +203,23 @@ void Message::showFile(const QString& path)
file = new Image(path);
} else {
file = new QLabel();
file->setPixmap(QIcon::fromTheme(type.iconName()).pixmap(50));
QIcon qIcon = QIcon::fromTheme(type.iconName());
if (qIcon.isNull()) {
qIcon.addFile(QString::fromUtf8(":/images/fallback/dark/big/mail-attachment.svg"), QSize(), QIcon::Normal, QIcon::Off);
}
file->setPixmap(qIcon.pixmap(50));
file->setAlignment(Qt::AlignCenter);
showComment(info.fileName(), true);
}
file->setContextMenuPolicy(Qt::ActionsContextMenu);
QAction* openAction = new QAction(QIcon::fromTheme("document-new-from-template"), tr("Open"), file);
QAction* openAction = new QAction(QIcon::fromTheme("document-new-from-template"), tr("Open"), this);
connect(openAction, &QAction::triggered, [path]() { //TODO need to get rid of this shame
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
});
file->addAction(openAction);
fileComment->setContextMenuPolicy(Qt::ActionsContextMenu);
fileComment->addAction(openAction);
bodyLayout->insertWidget(2, file);
hasFile = true;
}

View file

@ -38,7 +38,8 @@ MessageLine::MessageLine(bool p_room, QWidget* parent):
downloading(),
room(p_room),
busyShown(false),
progress()
progress(),
lastHeight(0)
{
setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins(0, 0, 0, 0);
@ -163,6 +164,7 @@ MessageLine::Position MessageLine::message(const Shared::Message& msg, bool forc
emit requestLocalFile(msg.getId(), msg.getOutOfBandUrl());
connect(message, &Message::buttonClicked, this, &MessageLine::onDownload);
}
qDebug() << "inserted message " << id;
return res;
}
@ -309,7 +311,11 @@ void MessageLine::movePalAvatarToEx(const QString& name)
void MessageLine::resizeEvent(QResizeEvent* event)
{
QWidget::resizeEvent(event);
emit resize(event->size().height() - event->oldSize().height());
qDebug() << "Resize(unordered): " << event->size().height() << event->oldSize().height();
qDebug() << "Resize: " << height() << lastHeight;
emit resize(height() - lastHeight);
lastHeight = height();
}
@ -328,6 +334,7 @@ void MessageLine::showBusyIndicator()
layout->insertWidget(0, &progress);
progress.start();
busyShown = true;
qDebug() << "showBusyIndicator";
}
}
@ -337,6 +344,7 @@ void MessageLine::hideBusyIndicator()
progress.stop();
layout->removeWidget(&progress);
busyShown = false;
qDebug() << "hideBusyIndicator";
}
}

View file

@ -103,6 +103,7 @@ private:
bool room;
bool busyShown;
Progress progress;
int lastHeight;
};
#endif // MESSAGELINE_H