Skip to content

Commit

Permalink
more qt6 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Mar 15, 2024
1 parent baf10a8 commit f8711b3
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 34 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/qite
19 changes: 18 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ set(TRANSLATIONS_DIR "${PROJECT_SOURCE_DIR}/translations" CACHE STRING "Path to

#Work with external packages
set(REQUIRED_QT_COMPONENTS Widgets Core Gui Xml Network Concurrent Multimedia Svg Sql)
if(QT_DEFAULT_MAJOR_VERSION GREATER_EQUAL 6)
list(APPEND REQUIRED_QT_COMPONENTS SvgWidgets)
endif()
if(IS_WEBKIT)
list(APPEND REQUIRED_QT_COMPONENTS WebKit WebKitWidgets)
set(WEBKIT_LIBS Qt${QT_DEFAULT_MAJOR_VERSION}::WebKit Qt${QT_DEFAULT_MAJOR_VERSION}::WebKitWidgets)
Expand Down Expand Up @@ -80,7 +83,21 @@ if(USE_KEYCHAIN)
include_directories(${QTKEYCHAIN_INCLUDE_DIRS})
add_definitions(-DHAVE_KEYCHAIN)
endif()
set(QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::Widgets Qt${QT_DEFAULT_MAJOR_VERSION}::Core Qt${QT_DEFAULT_MAJOR_VERSION}::Network Qt${QT_DEFAULT_MAJOR_VERSION}::Xml ${WEBKIT_LIBS} Qt${QT_DEFAULT_MAJOR_VERSION}::Concurrent Qt${QT_DEFAULT_MAJOR_VERSION}::Multimedia Qt${QT_DEFAULT_MAJOR_VERSION}::Svg Qt${QT_DEFAULT_MAJOR_VERSION}::Sql ${KEYCHAIN_LIBS})
set(QT_LIBRARIES
Qt${QT_DEFAULT_MAJOR_VERSION}::Widgets
Qt${QT_DEFAULT_MAJOR_VERSION}::Core
Qt${QT_DEFAULT_MAJOR_VERSION}::Network
Qt${QT_DEFAULT_MAJOR_VERSION}::Xml
${WEBKIT_LIBS}
Qt${QT_DEFAULT_MAJOR_VERSION}::Concurrent
Qt${QT_DEFAULT_MAJOR_VERSION}::Multimedia
Qt${QT_DEFAULT_MAJOR_VERSION}::Svg
Qt${QT_DEFAULT_MAJOR_VERSION}::Sql
${KEYCHAIN_LIBS}
)
if(QT_DEFAULT_MAJOR_VERSION GREATER_EQUAL 6)
list(APPEND QT_LIBRARIES Qt${QT_DEFAULT_MAJOR_VERSION}::SvgWidgets)
endif()


if(LINUX)
Expand Down
2 changes: 1 addition & 1 deletion src/sxe/sxesession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ QList<const SxeEdit *> SxeSession::startQueueing()
return nonDocElementEdits + edits;
}

void SxeSession::arrangeEdits(QHash<QString, QString> &ridByParent, QList<const SxeEdit *> &output,
void SxeSession::arrangeEdits(QMultiHash<QString, QString> &ridByParent, QList<const SxeEdit *> &output,
const QString &iterator)
{
// add the edits to this node
Expand Down
2 changes: 1 addition & 1 deletion src/sxe/sxesession.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private slots:
/*! \brief Generates SxeRemoveEdits for \a node and its children. */
void generateRemoves(const QDomNode &node);
/*! \brief Recursive helper method for arranging edits for the snapshot. */
void arrangeEdits(QHash<QString, QString> &ridByParent, QList<const SxeEdit *> &output, const QString &iterator);
void arrangeEdits(QMultiHash<QString, QString> &ridByParent, QList<const SxeEdit *> &output, const QString &iterator);
/*! \brief Insert node with the given primaryWeight.
* Returns node if the node was already in the document. Otherwise returns the created node. */
const QDomNode insertNode(const QDomNode &node, const QString &parentId, double primaryWeight);
Expand Down
2 changes: 1 addition & 1 deletion src/tabs/tabmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ TabDlg *TabManager::getTabs(QWidget *widget)

QChar TabManager::tabKind(QWidget *widget)
{
QChar retval = 0;
QChar retval;
if (widget) {
const QString name = widget->objectName();
if (name == "ChatDlg") {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/advwidget/advwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void GAdvancedWidget::Private::doFlash(bool yes)

void GAdvancedWidget::Private::moveEvent(QMoveEvent *)
{
if (!parentWidget_->isTopLevel())
if (!parentWidget_->isWindow())
return;
#ifdef Q_OS_MAC
QRect r = qApp->desktop()->availableGeometry(parentWidget_);
Expand Down
2 changes: 1 addition & 1 deletion src/whiteboarding/wbdlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@
#include <QKeyEvent>
#include <QLabel>
#include <QLineEdit>
// #include <QMessageBoxEx>
#include <QResizeEvent>
#include <QShowEvent>
#include <QToolBar>

class AccountLabel;
class PsiAccount;
class IconAction;

using namespace XMPP;

Expand Down
31 changes: 17 additions & 14 deletions src/whiteboarding/wbitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@

#include "wbscene.h"
#include "wbwidget.h"
#include <iconaction.h>

#include <QDebug>
#include <QRegularExpression>
#include <QSvgRenderer>
#include <QActionGroup>

#include <math.h>

static QMatrix parseTransformationMatrix(const QString &value);
static QTransform parseTransformationMatrix(const QString &value);

/*
* WbItemMenu
Expand Down Expand Up @@ -140,7 +143,7 @@ void WbItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
// qDebug() << QString("d: %1 %2 = %3 %4 + %5
// %6").arg(difference.x()).arg(difference.y()).arg(event->scenePos().x()).arg(event->scenePos().y()).arg(event->lastScenePos().x()).arg(event->lastScenePos().y());
QPointF p = event->scenePos();
QMatrix delta;
QTransform delta;
if (p.x() >= scenePivot.x() && p.y() >= scenePivot.y()) {
delta.rotate((-difference.x() + difference.y()) / 2);
} else if (p.x() < scenePivot.x() && p.y() >= scenePivot.y()) {
Expand All @@ -154,7 +157,7 @@ void WbItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
const auto &gItems = scene()->selectedItems();
for (QGraphicsItem *graphicsitem : gItems) {
if (!graphicsitem->parentItem() || !graphicsitem->parentItem()->isSelected()) {
QMatrix translation;
QTransform translation;
// get center coordinates of selected items in item coordinates
QPointF itemPivot = graphicsitem->mapFromScene(scenePivot);
// translates the the item's center to the origin of the item coordinates
Expand All @@ -178,7 +181,7 @@ void WbItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)

// get center coordinates in item coordinates
QPointF c = center();
QMatrix translation, delta;
QTransform translation, delta;
// translates the the item's center to the origin of the item coordinates
translation.translate(-c.x(), -c.y());
// Scale.
Expand All @@ -188,7 +191,7 @@ void WbItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
// Note: the y axis points downwards in scene coordinates
delta.scale(1 + difference.x() / 50, 1 - difference.y() / 50);
// set the matrix
setTransform(QTransform(translation * delta * translation.inverted()), true);
setTransform(translation * delta * translation.inverted(), true);

// Regenerate the SVG transformation matrix later
scene_->queueTransformationRegeneration(dynamic_cast<WbItem *>(graphicsitem));
Expand All @@ -205,16 +208,16 @@ void WbItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
scene_->regenerateTransformations();
}

QMatrix WbItem::parseSvgTransform(QString string)
QTransform WbItem::parseSvgTransform(QString string)
{
string = string.trimmed();
if (string.isEmpty())
return QMatrix();
return {};

return parseTransformationMatrix(string);
}

QString WbItem::toSvgTransform(const QMatrix &m)
QString WbItem::toSvgTransform(const QTransform &m)
{
return QString("matrix(%1 %2 %3 %4 %5 %6)")
.arg(m.m11())
Expand All @@ -231,16 +234,16 @@ void WbItem::regenerateTransform()
// Possible as long as no perspective transformations have been applied.

// delta is the new transformation to be applied
QMatrix delta = transform().toAffine();
QTransform delta = transform();
if (delta.isIdentity())
return;

// get the existing SVG transformation
QString oldValue = node_.attribute("transform");
QMatrix oldTransform = parseSvgTransform(oldValue);
QTransform oldTransform = parseSvgTransform(oldValue);

// construct a translation that translates the item to (0,0) in scene coordinates
QMatrix translation;
QTransform translation;
// translates the the item's center to the origin of the item coordinates
translation.translate(-pos().x(), -pos().y());

Expand Down Expand Up @@ -533,9 +536,9 @@ static QVector<qreal> parseNumbersList(const QChar *&str)
return points;
}

static QMatrix parseTransformationMatrix(const QString &value)
static QTransform parseTransformationMatrix(const QString &value)
{
QMatrix matrix;
QTransform matrix;
const QChar *str = value.constData();

while (*str != QLatin1Char(0)) {
Expand Down Expand Up @@ -614,7 +617,7 @@ static QMatrix parseTransformationMatrix(const QString &value)
if (points.count() != 6) {
goto error;
}
matrix = matrix * QMatrix(points[0], points[1], points[2], points[3], points[4], points[5]);
matrix = matrix * QTransform(points[0], points[1], points[2], points[3], points[4], points[5]);
} else if (state == State::Translate) {
if (points.count() == 1)
matrix.translate(points[0], 0);
Expand Down
6 changes: 3 additions & 3 deletions src/whiteboarding/wbitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
#define WBITEM_H

#include "../sxe/sxesession.h"
#include "iconaction.h"

#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsSvgItem>
#include <QMenu>
#include <QTransform>

class WbScene;
class WbWidget;
Expand Down Expand Up @@ -88,9 +88,9 @@ class WbItem : public QGraphicsSvgItem {
void resetPos();

/*! \brief Returns a QTransform based on \a string provided in the SVG 'transform' attribute format.*/
static QMatrix parseSvgTransform(QString string);
static QTransform parseSvgTransform(QString string);
/*! \brief Returns a QString in the SVG 'transform' attribute format based on \a matrix.*/
static QString toSvgTransform(const QMatrix &matrix);
static QString toSvgTransform(const QTransform &matrix);

protected:
/*! \brief Constructs and popsup the default context menu.*/
Expand Down
3 changes: 0 additions & 3 deletions src/widgets/iconselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@

#include "emojiregistry.h"
#include "iconset.h"
#include "psitooltip.h"

#include <QAbstractButton>
#include <QApplication>
//#include <QDesktopWidget>
#include <QEvent>
#include <QLabel>
#include <QLayout>
Expand All @@ -35,7 +33,6 @@
#include <QScrollBar>
#include <QStyle>
#include <QStyleOption>
#include <QTextCodec>
#include <QWidgetAction>
#include <QScreen>

Expand Down
6 changes: 3 additions & 3 deletions src/widgets/psitabwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ PsiTabWidget::PsiTabWidget(QWidget *parent) : QWidget(parent)
tabBar_->setUsesScrollButtons(!multiRow);
tabBar_->setCurrentIndexAlwaysAtBottom(currentIndexAlwaysAtBottom);
layout_ = new QVBoxLayout(this);
layout_->setMargin(0);
layout_->setContentsMargins(0,0,0,0);
layout_->setSpacing(0);
barLayout_ = new QHBoxLayout;
layout_->addLayout(barLayout_);
barLayout_->setMargin(0);
barLayout_->setContentsMargins(0,0,0,0);
barLayout_->setSpacing(0);
barLayout_->addWidget(tabBar_, 2);
barLayout_->setAlignment(Qt::AlignLeft);

int buttonwidth = qMax(tabBar_->style()->pixelMetric(QStyle::PM_TabBarScrollButtonWidth, nullptr, tabBar_),
QApplication::globalStrut().width());
16);

downButton_ = new QToolButton(this);
downButton_->setMinimumSize(3, 3);
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/psitiplabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void PsiTipLabel::paintEvent(QPaintEvent *)
{
QStylePainter p(this);
QStyleOptionFrame opt;
opt.init(this);
opt.initFrom(this);
if (enableColoring_) {
p.drawPrimitive(QStyle::PE_Frame, opt);
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/tabbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CloseButton : public QAbstractButton {

QSize sizeHint() const;
inline QSize minimumSizeHint() const { return sizeHint(); }
void enterEvent(QEvent *event);
void enterEvent(QEnterEvent *event);
void leaveEvent(QEvent *event);
void paintEvent(QPaintEvent *event);
};
Expand Down Expand Up @@ -838,7 +838,7 @@ static void initStyleBaseOption(QStyleOptionTabBarBase *optTabBase, QTabBar *tab
tabOverlap.shape = tabbar->shape();
int overlap = tabbar->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap, tabbar);
QWidget *theParent = tabbar->parentWidget();
optTabBase->init(tabbar);
optTabBase->initFrom(tabbar);
optTabBase->shape = tabbar->shape();
optTabBase->documentMode = tabbar->documentMode();
if (theParent && overlap > 0) {
Expand Down Expand Up @@ -1222,7 +1222,7 @@ QSize CloseButton::sizeHint() const
return { width, height };
}

void CloseButton::enterEvent(QEvent *event)
void CloseButton::enterEvent(QEnterEvent *event)
{
if (isEnabled())
update();
Expand Down

0 comments on commit f8711b3

Please sign in to comment.