1
0
Fork 0
forked from blue/squawk

qt6 build

This commit is contained in:
Blue 2024-12-14 01:53:04 +02:00
parent a04693e39d
commit d4cec645b5
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
35 changed files with 279 additions and 632 deletions

View file

@ -38,11 +38,6 @@ Account::Account():
QStandardItem *item = model->item(static_cast<int>(Shared::AccountPassword::kwallet));
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
}
if (!Shared::Global::supported("simpleCryptJammedPassword")) {
QStandardItem *item = model->item(static_cast<int>(Shared::AccountPassword::jammed));
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
}
}
Account::~Account() {}

View file

@ -500,7 +500,7 @@ void Conversation::onFeedContext(const QPoint& pos) {
}
QString path = Shared::resolvePath(item->getAttachPath());
if (path.size() > 0) {
if (!path.isEmpty()) {
showMenu = true;
QAction* open = contextMenu->addAction(Shared::icon("document-preview"), tr("Open"));
connect(open, &QAction::triggered, [path]() {
@ -513,7 +513,7 @@ void Conversation::onFeedContext(const QPoint& pos) {
});
}
bool hasAttach = item->getAttachPath() > 0 || item->getOutOfBandUrl() > 0;
bool hasAttach = !item->getAttachPath().isEmpty() || !item->getOutOfBandUrl().isEmpty();
//the only mandatory condition - is for the message to be outgoing, the rest is just a good intention on the server
if (item->getOutgoing() && !hasAttach && index.row() < 100 && item->getTime().daysTo(QDateTime::currentDateTimeUtc()) < 20) {
showMenu = true;

View file

@ -141,7 +141,15 @@ void FeedView::updateGeometries() {
const QStyle* st = style();
QSize layoutBounds = maximumViewportSize();
QStyleOptionViewItem option = viewOptions();
QStyleOptionViewItem option;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
initViewItemOption(&option);
#else
option = viewOptions();
#endif
option.rect.setHeight(maxMessageHeight);
option.rect.setWidth(layoutBounds.width());
int frameAroundContents = 0;
@ -182,7 +190,7 @@ void FeedView::updateGeometries() {
previousOffset += elementMargin;
}
lastDate = currentDate;
QSize messageSize = itemDelegate(index)->sizeHint(option, index);
QSize messageSize = itemDelegateForIndex(index)->sizeHint(option, index);
uint32_t offsetX(0);
if (specialDelegate) {
if (index.data(Models::MessageFeed::SentByMe).toBool())
@ -232,7 +240,7 @@ bool FeedView::tryToCalculateGeometriesWithNoScrollbars(const QStyleOptionViewIt
previousOffset += elementMargin;
}
lastDate = currentDate;
QSize messageSize = itemDelegate(index)->sizeHint(option, index);
QSize messageSize = itemDelegateForIndex(index)->sizeHint(option, index);
if (previousOffset + messageSize.height() + elementMargin > totalHeight)
return false;
@ -288,8 +296,14 @@ void FeedView::paintEvent(QPaintEvent* event) {
}
}
QStyleOptionViewItem option;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
initViewItemOption(&option);
#else
option = viewOptions();
#endif
QPainter painter(vp);
QStyleOptionViewItem option = viewOptions();
option.features = QStyleOptionViewItem::WrapText;
QPoint cursor = vp->mapFromGlobal(QCursor::pos());
@ -319,7 +333,7 @@ void FeedView::paintEvent(QPaintEvent* event) {
stripe.setWidth(viewportRect.width());
bool mouseOver = stripe.contains(cursor) && viewportRect.contains(cursor);
option.state.setFlag(QStyle::State_MouseOver, mouseOver);
itemDelegate(index)->paint(&painter, option, index);
itemDelegateForIndex(index)->paint(&painter, option, index);
if (!lastDate.isNull() && currentDate.daysTo(lastDate) > 0)
drawDateDevider(option.rect.bottom(), lastDate, painter);
@ -380,7 +394,7 @@ void FeedView::mouseMoveEvent(QMouseEvent* event) {
if (!isVisible())
return;
dragEndPoint = event->localPos().toPoint();
dragEndPoint = event->position().toPoint();
if (mousePressed) {
QPoint distance = dragStartPoint - dragEndPoint;
if (distance.manhattanLength() > 5)
@ -423,7 +437,7 @@ void FeedView::mousePressEvent(QMouseEvent* event) {
mousePressed = event->button() == Qt::LeftButton;
if (mousePressed) {
dragStartPoint = event->localPos().toPoint();
dragStartPoint = event->position().toPoint();
if (specialDelegate && specialModel) {
MessageDelegate* del = static_cast<MessageDelegate*>(itemDelegate());
QString lastSelectedId = del->clearSelection();
@ -441,7 +455,7 @@ void FeedView::mouseDoubleClickEvent(QMouseEvent* event) {
QAbstractItemView::mouseDoubleClickEvent(event);
mousePressed = event->button() == Qt::LeftButton;
if (mousePressed) {
dragStartPoint = event->localPos().toPoint();
dragStartPoint = event->position().toPoint();
if (specialDelegate && specialModel) {
MessageDelegate* del = static_cast<MessageDelegate*>(itemDelegate());
QString lastSelectedId = del->clearSelection();
@ -469,7 +483,7 @@ void FeedView::mouseReleaseEvent(QMouseEvent* event) {
if (mousePressed) {
if (!dragging && specialDelegate) {
QPoint point = event->localPos().toPoint();
QPoint point = event->position().toPoint();
QModelIndex index = indexAt(point);
if (index.isValid()) {
QRect rect = visualRect(index);

View file

@ -16,8 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FEEDVIEW_H
#define FEEDVIEW_H
#pragma once
#include <QAbstractItemView>
#include <QDesktopServices>
@ -30,11 +29,7 @@
#include <ui/utils/progress.h>
#include <shared/utils.h>
/**
* @todo write docs
*/
class FeedView : public QAbstractItemView
{
class FeedView : public QAbstractItemView {
Q_OBJECT
public:
FeedView(QWidget* parent = nullptr);
@ -111,5 +106,3 @@ private:
static const std::set<int> geometryChangingRoles;
};
#endif //FEEDVIEW_H

View file

@ -659,7 +659,7 @@ QLabel * MessageDelegate::getStatusIcon(const Models::FeedItem& data) const {
QIcon q(Shared::icon(Shared::messageStateThemeIcons[static_cast<uint8_t>(data.state)]));
QString tt = Shared::Global::getName(data.state);
if (data.state == Shared::Message::State::error) {
if (data.error > 0)
if (data.error.size() > 0)
tt += ": " + data.error;
}
if (result->toolTip() != tt) { //If i just assign pixmap every time unconditionally

View file

@ -21,36 +21,39 @@
SettingsList::SettingsList(QWidget* parent):
QListWidget(parent),
lastWidth(0)
{
{}
SettingsList::~SettingsList() {}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void SettingsList::initViewItemOption(QStyleOptionViewItem* option) const {
QListWidget::initViewItemOption(option);
if (!iconSize().isValid())
option->decorationSize.setWidth(lastWidth);
option->rect.setWidth(lastWidth);
}
SettingsList::~SettingsList()
{
}
QStyleOptionViewItem SettingsList::viewOptions() const
{
#else
QStyleOptionViewItem SettingsList::viewOptions() const {
QStyleOptionViewItem option = QListWidget::viewOptions();
if (!iconSize().isValid()) {
if (!iconSize().isValid())
option.decorationSize.setWidth(lastWidth);
}
option.rect.setWidth(lastWidth);
return option;
}
#endif
void SettingsList::resizeEvent(QResizeEvent* event)
{
void SettingsList::resizeEvent(QResizeEvent* event) {
lastWidth = event->size().width();
QListWidget::resizeEvent(event);
}
QRect SettingsList::visualRect(const QModelIndex& index) const
{
QRect SettingsList::visualRect(const QModelIndex& index) const {
QRect res = QListWidget::visualRect(index);
if (index.isValid()) {
if (index.isValid())
res.setWidth(lastWidth);
}
return res;
}

View file

@ -16,29 +16,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef UI_SETTINGSLIST_H
#define UI_SETTINGSLIST_H
#pragma once
#include <QListWidget>
#include <QResizeEvent>
#include <QStyleOptionViewItem>
/**
* @todo write docs
*/
class SettingsList : public QListWidget
{
class SettingsList : public QListWidget {
Q_OBJECT
public:
SettingsList(QWidget* parent = nullptr);
~SettingsList();
protected:
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void initViewItemOption(QStyleOptionViewItem* option) const override;
#else
QStyleOptionViewItem viewOptions() const override;
#endif
void resizeEvent(QResizeEvent * event) override;
QRect visualRect(const QModelIndex & index) const override;
private:
int lastWidth;
};
#endif // UI_SETTINGSLIST_H