Commit af690912 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port more code for making building against qt6

parent aa7fc379
Pipeline #174591 passed with stage
in 1 minute and 50 seconds
......@@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include "browsemainpage.h"
// Qt
#include <QActionGroup>
#include <QDropEvent>
#include <QMenu>
#include <QVBoxLayout>
......
......@@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
// Qt
#include <QPointer>
#include <QStringList>
#include <QWidget>
// KF
......@@ -32,8 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include "ui_fullscreenconfigwidget.h"
#include <lib/document/document.h>
class QStringList;
class KActionCollection;
class QUrl;
......
......@@ -24,8 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// Local
#include "abstractcontextmanageritem.h"
#include <QStringList>
class QStringList;
class KFileItem;
class KFileItemList;
......
......@@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <config-gwenview.h>
// Qt
#include <QActionGroup>
#include <QApplication>
#include <QClipboard>
#include <QDateTime>
......
......@@ -311,7 +311,11 @@ void SideBarTabBar::paintEvent(QPaintEvent *event)
void SideBarTabBar::drawTab(int index, QStylePainter &painter) const
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QStyleOptionTabV4 opt;
#else
QStyleOptionTab opt;
#endif
QTabBar::initStyleOption(&opt, index);
// draw background before doing anything else
......
......@@ -132,13 +132,24 @@ QSize FlowLayout::sizeHint() const
return minimumSize();
}
int FlowLayout::getMargin() const
{
int left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
if (left == top && top == right && right == bottom) {
return left;
} else {
return -1;
}
}
QSize FlowLayout::minimumSize() const
{
QSize size;
for (QLayoutItem *item : qAsConst(itemList))
size = size.expandedTo(item->minimumSize());
size += QSize(2 * margin(), 2 * margin());
size += QSize(2 * getMargin(), 2 * getMargin());
return size;
}
......@@ -149,9 +160,9 @@ void FlowLayout::addSpacing(const int size)
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
{
const int left = rect.x() + margin();
const int left = rect.x() + getMargin();
int x = left;
int y = rect.y() + margin();
int y = rect.y() + getMargin();
int lineHeight = 0;
bool lastItemIsSpacer = false;
QHash<int, int> widthForY;
......@@ -164,7 +175,7 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
}
int nextX = x + item->sizeHint().width() + horizontalSpacing();
if (nextX - horizontalSpacing() > rect.right() - margin() && lineHeight > 0) {
if (nextX - horizontalSpacing() > rect.right() - getMargin() && lineHeight > 0) {
x = left;
y = y + lineHeight + verticalSpacing();
nextX = x + item->sizeHint().width() + horizontalSpacing();
......@@ -182,14 +193,14 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
x = nextX;
// Don't add spacer items at end of line
if (!itemIsSpacer) {
widthForY[y] = x - margin();
widthForY[y] = x - getMargin();
}
lineHeight = qMax(lineHeight, item->sizeHint().height());
lastItemIsSpacer = itemIsSpacer;
}
if (!testOnly) {
const int contentWidth = rect.width() - 2 * margin();
const int contentWidth = rect.width() - 2 * getMargin();
for (auto item : itemList) {
QRect itemRect = item->geometry();
// Center lines horizontally if flag AlignHCenter is set
......@@ -208,5 +219,5 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
}
}
return y + lineHeight - rect.y() + margin();
return y + lineHeight - rect.y() + getMargin();
}
......@@ -69,6 +69,7 @@ public:
void addSpacing(const int size);
private:
int getMargin() const;
int doLayout(const QRect &rect, bool testOnly) const;
QList<QLayoutItem *> itemList;
......
......@@ -98,7 +98,12 @@ GraphicsWidgetFloater::GraphicsWidgetFloater(QGraphicsWidget *parent)
d->mParent->installEventFilter(this);
d->mChild = nullptr;
d->mAlignment = Qt::AlignCenter;
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
d->mHorizontalMargin = QApplication::style()->pixelMetric(QStyle::PM_DefaultChildMargin);
#else
// TODO
d->mHorizontalMargin = 0;
#endif
d->mVerticalMargin = d->mHorizontalMargin;
d->mInsideUpdateChildGeometry = false;
}
......
......@@ -98,7 +98,12 @@ WidgetFloater::WidgetFloater(QWidget *parent)
d->mParent->installEventFilter(this);
d->mChild = nullptr;
d->mAlignment = Qt::AlignCenter;
d->mHorizontalMargin = QApplication::style()->pixelMetric(QStyle::PM_DefaultChildMargin);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
d->mHorizontalMargin = QApplication::style()->pixelMetric(QStyle::PixelMetric::PM_DefaultChildMargin);
#else
// TODO
d->mHorizontalMargin = 0;
#endif
d->mVerticalMargin = d->mHorizontalMargin;
d->mInsideUpdateChildGeometry = false;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment