Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for kddockwidgets 2.0 #570

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/appimage/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ FROM centos/devtoolset-7-toolchain-centos7 as intermediate

ARG QT_VERSION=5.15.11
ARG KF5_VERSION v5.110.0
ARG KDDockWidgets_VERSION=1.7
ARG KDDockWidgets_VERSION=2.0
ARG QCustomPlot_VERSION=2.1.1
ARG rust_demangler_VERSION=0.1.23
ARG d_demangler_VERSION=0.0.2
Expand Down Expand Up @@ -124,7 +124,7 @@ RUN ldconfig && \

# kddockwidgets
RUN cd /opt && git clone --recursive https://github.com/KDAB/KDDockWidgets.git -b ${KDDockWidgets_VERSION} && \
cd KDDockWidgets && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=/usr .. && \
cd KDDockWidgets && mkdir build && cd build && cmake -DCMAKE_INSTALL_PREFIX=/usr -DKDDockWidgets_EXAMPLES=0 -DKDDockWidgets_FRONTENDS="qtwidgets" .. && \
make -j && make install && cd /opt && rm -Rf KDDockWidgets

FROM intermediate
Expand Down
4 changes: 2 additions & 2 deletions scripts/compile-test/BaseArchlinux
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ RUN pacman -Sy --noconfirm && \
pacman -S archlinux-keyring --noconfirm && pacman-key --init && pacman-key --populate && \
pacman -Syu --noconfirm git make qt5-x11extras cmake gcc extra-cmake-modules \
libelf gettext qt5-base ninja qcustomplot \
threadweaver kconfigwidgets knotifications karchive syntax-highlighting \
kiconthemes kitemviews kitemmodels kwindowsystem kio kparts solid clazy python python-yaml
threadweaver5 kconfigwidgets5 knotifications5 karchive5 syntax-highlighting5 \
kiconthemes5 kitemviews5 kitemmodels5 kwindowsystem5 kio5 kparts5 solid5 clazy python python-yaml
5 changes: 3 additions & 2 deletions scripts/compile-test/BuildDependencies
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
ARG BASEIMAGE
FROM $BASEIMAGE

ARG KDDOCKWIDGETS_VERSION="1.6"
WORKDIR /opt

RUN git clone -b 1.6 https://github.com/KDAB/KDDockWidgets && \
RUN git clone -b "$KDDOCKWIDGETS_VERSION" https://github.com/KDAB/KDDockWidgets && \
cd KDDockWidgets && mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr/ \
-DKDDockWidgets_EXAMPLES=OFF -G Ninja .. && \
-DKDDockWidgets_EXAMPLES=OFF -DKDDockWidgets_FRONTENDS="qtwidgets" -G Ninja .. && \
cmake --build . --target install && cd /opt && rm -Rf KDDockWidgets
5 changes: 3 additions & 2 deletions scripts/compile-test/BuildDependenciesQt6
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
ARG BASEIMAGE
FROM $BASEIMAGE

ARG KDDOCKWIDGETS_VERSION
WORKDIR /opt

RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
Expand All @@ -17,8 +18,8 @@ RUN wget https://www.qcustomplot.com/release/2.1.1/QCustomPlot-source.tar.gz &&
qmake6 CONFIG+=release CONFIG+=force_debug_info && make -j && \
cp -va libqcustomplot* /usr/lib/x86_64-linux-gnu/ && cd /opt && rm -Rf qcustomplot-source

RUN git clone -b 1.7 https://github.com/KDAB/KDDockWidgets && \
RUN git clone -b $KDDOCKWIDGETS_VERSION https://github.com/KDAB/KDDockWidgets && \
cd KDDockWidgets && mkdir build && cd build && \
cmake -DCMAKE_BUILD_TYPE=Debug -DKDDockWidgets_QT6=ON -DCMAKE_INSTALL_PREFIX=/usr/ \
-DKDDockWidgets_EXAMPLES=OFF -G Ninja .. && \
-DKDDockWidgets_EXAMPLES=OFF -DKDDockWidgets_FRONTENDS="qtwidgets" -G Ninja .. && \
cmake --build . --target install && cd /opt && rm -Rf KDDockWidgets
22 changes: 13 additions & 9 deletions scripts/compile-test/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ buildBase()
buildDependencies()
{
distro=$1
kddw_version=$2

tag=$(toLower $distro)

buildBase $distro
Expand All @@ -33,21 +35,22 @@ buildDependencies()
fi

docker build --ulimit nofile=1024:262144 -t hotspot-$tag-dependencies \
--build-arg BASEIMAGE=hotspot-$tag-base \
--build-arg BASEIMAGE=hotspot-$tag-base --build-arg KDDOCKWIDGETS_VERSION="$kddw_version" \
-f scripts/compile-test/BuildDependencies$suffix $extraArgs .
}

buildHotspotWithPresets()
{
distro=$1
kddw_version=$2
tag=$(toLower $distro)

suffix=
if [[ $distro == *Qt6 ]]; then
suffix=Qt6
fi

buildDependencies $distro
buildDependencies $distro $kddw_version
docker build --ulimit nofile=1024:262144 -t hotspot-$tag \
--build-arg BASEIMAGE=hotspot-$tag-dependencies \
-f scripts/compile-test/BuildHotspotWithPresets$suffix $extraArgs .
Expand All @@ -56,18 +59,19 @@ buildHotspotWithPresets()
buildHotspotWithoutPresets()
{
distro=$1
kddw_version=$2
tag=$(toLower $distro)

buildDependencies $distro
buildDependencies $distro $kddw_version
docker build --ulimit nofile=1024:262144 -t hotspot-$tag \
--build-arg BASEIMAGE=hotspot-$tag-dependencies \
-f scripts/compile-test/BuildHotspotWithoutPresets $extraArgs .
}

export DOCKER_BUILDKIT=1
buildHotspotWithoutPresets Ubuntu20.04
buildHotspotWithPresets Ubuntu22.04
buildHotspotWithPresets Archlinux
buildHotspotWithPresets OpenSuseTumbleweed
buildHotspotWithoutPresets Fedora34
buildHotspotWithPresets NeonQt6
buildHotspotWithoutPresets Ubuntu20.04 1.6
buildHotspotWithPresets Ubuntu22.04 2.0
buildHotspotWithPresets Archlinux 2.0
buildHotspotWithPresets OpenSuseTumbleweed 2.0
buildHotspotWithoutPresets Fedora34 2.0
buildHotspotWithPresets NeonQt6 2.0
37 changes: 37 additions & 0 deletions src/dockwidgets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
SPDX-FileCopyrightText: Lieven Hey <lieven.hey@kdab.com>
SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com

SPDX-License-Identifier: GPL-2.0-or-later
*/

#pragma once

#include <kddockwidgets/kddockwidgets_version.h>

#if KDDOCKWIDGETS_VERSION < KDDOCKWIDGETS_VERSION_CHECK(2, 0, 0)
namespace KDDockWidgets {
class DockWidgetBase;
class DockWidget;
class MainWindow;
}

using DockWidget = KDDockWidgets::DockWidget;
lievenhey marked this conversation as resolved.
Show resolved Hide resolved
using DockMainWindow = KDDockWidgets::MainWindow;
using CoreDockWidget = KDDockWidgets::DockWidgetBase;
#else
namespace KDDockWidgets {
namespace QtWidgets {
class DockWidget;
class MainWindow;
}

namespace Core {
lievenhey marked this conversation as resolved.
Show resolved Hide resolved
class DockWidget;
}
}

using DockWidget = KDDockWidgets::QtWidgets::DockWidget;
using CoreDockWidget = KDDockWidgets::Core::DockWidget;
using DockMainWindow = KDDockWidgets::QtWidgets::MainWindow;
#endif // KDDOCKWIDGETS_VERSION < KDDOCKWIDGETS_VERSION_CHECK(2, 0, 0)
28 changes: 22 additions & 6 deletions src/dockwidgetsetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@
#include "dockwidgetsetup.h"

#include <kddockwidgets/Config.h>
#include <kddockwidgets/FrameworkWidgetFactory.h>
#include <kddockwidgets/kddockwidgets_version.h>

#if KDDOCKWIDGETS_VERSION < KDDOCKWIDGETS_VERSION_CHECK(2, 0, 0)
#include <kddockwidgets/DefaultWidgetFactory>
#include <kddockwidgets/MainWindow.h>
#else
#include <kddockwidgets/ViewFactory.h>
#include <kddockwidgets/qtwidgets/MainWindow.h>
#endif // KDDOCKWIDGETS_VERSION < KDDOCKWIDGETS_VERSION_CHECK(2, 0, 0)

namespace {
class DockingArea : public KDDockWidgets::MainWindow
class DockingArea : public DockMainWindow
{
Q_OBJECT
public:
using MainWindow::MainWindow;
using DockMainWindow::MainWindow;

protected:
QMargins centerWidgetMargins() const override
Expand All @@ -38,12 +45,21 @@ class DockingArea : public KDDockWidgets::MainWindow

void setupDockWidgets()
{
KDDockWidgets::Config::self().setFlags(KDDockWidgets::Config::Flag_HideTitleBarWhenTabsVisible
| KDDockWidgets::Config::Flag_TabsHaveCloseButton);
constexpr auto flags =
KDDockWidgets::Config::Flag_HideTitleBarWhenTabsVisible | KDDockWidgets::Config::Flag_TabsHaveCloseButton;

#if KDDOCKWIDGETS_VERSION < KDDOCKWIDGETS_VERSION_CHECK(2, 0, 0)
KDDockWidgets::Config::self().setFlags(flags);
KDDockWidgets::DefaultWidgetFactory::s_dropIndicatorType = KDDockWidgets::DropIndicatorType::Segmented;

#else
KDDockWidgets::initFrontend(KDDockWidgets::FrontendType::QtWidgets);
KDDockWidgets::Config::self().setFlags(flags);
KDDockWidgets::Core::ViewFactory::s_dropIndicatorType = KDDockWidgets::DropIndicatorType::Segmented;
#endif
}

KDDockWidgets::MainWindow* createDockingArea(const QString& id, QWidget* parent)
DockMainWindow* createDockingArea(const QString& id, QWidget* parent)
{
auto ret = new DockingArea(id, KDDockWidgets::MainWindowOption_None, parent);

Expand Down
6 changes: 2 additions & 4 deletions src/dockwidgetsetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@

#pragma once

namespace KDDockWidgets {
class MainWindow;
}
#include "dockwidgets.h"

class QWidget;
class QString;

void setupDockWidgets();
KDDockWidgets::MainWindow* createDockingArea(const QString& id, QWidget* parent);
DockMainWindow* createDockingArea(const QString& id, QWidget* parent);
34 changes: 27 additions & 7 deletions src/resultspage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@

#include <KLocalizedString>

#include <kddockwidgets/kddockwidgets_version.h>

#if KDDOCKWIDGETS_VERSION < KDDOCKWIDGETS_VERSION_CHECK(2, 0, 0)
#include <kddockwidgets/DockWidget.h>
#include <kddockwidgets/MainWindow.h>
#else
#include <kddockwidgets/qtwidgets/DockWidget.h>
#include <kddockwidgets/qtwidgets/MainWindow.h>
#endif // KDDOCKWIDGETS_VERSION < KDDOCKWIDGETS_VERSION_CHECK(2, 0, 0)

#include <QDebug>
#include <QLabel>
Expand All @@ -42,12 +49,21 @@
#endif

namespace {
void showDock(KDDockWidgets::DockWidget* dock)
void showDock(DockWidget* dock)
{
dock->show();
dock->setFocus();
dock->setFocus(Qt::FocusReason::NoFocusReason);
dock->setAsCurrentTab();
}

CoreDockWidget* toDockWidget(DockWidget* dock)
{
#if KDDOCKWIDGETS_VERSION < KDDOCKWIDGETS_VERSION_CHECK(2, 0, 0)
return dock;
#else
return dock->dockWidget();
#endif // KDDOCKWIDGETS_VERSION < KDDOCKWIDGETS_VERSION_CHECK
}
}

ResultsPage::ResultsPage(PerfParser* parser, QWidget* parent)
Expand Down Expand Up @@ -90,7 +106,7 @@ ResultsPage::ResultsPage(PerfParser* parser, QWidget* parent)
ui->lostMessage->hide();

auto dockify = [](QWidget* widget, const QString& id, const QString& title, const QString& shortcut) {
auto* dock = new KDDockWidgets::DockWidget(id);
auto* dock = new DockWidget(id);
dock->setWidget(widget);
dock->setTitle(title);
dock->toggleAction()->setShortcut(shortcut);
Expand Down Expand Up @@ -254,7 +270,7 @@ void ResultsPage::onOpenEditor(const Data::Symbol& symbol)
void ResultsPage::selectSummaryTab()
{
m_summaryPageDock->show();
m_summaryPageDock->setFocus();
m_summaryPageDock->setFocus(Qt::NoFocusReason);
m_summaryPageDock->setAsCurrentTab();
}

Expand Down Expand Up @@ -312,14 +328,18 @@ void ResultsPage::showError(const QString& message)
QTimer::singleShot(5000, ui->errorWidget, &KMessageWidget::animatedHide);
}

void ResultsPage::initDockWidgets(const QVector<KDDockWidgets::DockWidgetBase*>& restored)
void ResultsPage::initDockWidgets(const QVector<CoreDockWidget*>& restored)
{
Q_ASSERT(restored.contains(m_summaryPageDock));
auto summaryPageDock = toDockWidget(m_summaryPageDock);

Q_ASSERT(restored.contains(summaryPageDock));

const auto docks = {m_bottomUpDock, m_topDownDock, m_flameGraphDock, m_callerCalleeDock,
m_timeLineDock, m_disassemblyDock, m_frequencyDock};
for (auto dock : docks) {
if (!dock || restored.contains(dock))
auto dockWidget = toDockWidget(dock);

if (!dock || restored.contains(dockWidget))
continue;

auto initialOption = KDDockWidgets::InitialOption {};
Expand Down
28 changes: 12 additions & 16 deletions src/resultspage.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

#include <memory>

#include "dockwidgets.h"

class QMenu;
class QAction;

Expand All @@ -23,12 +25,6 @@ namespace Data {
struct Symbol;
}

namespace KDDockWidgets {
class MainWindow;
class DockWidget;
class DockWidgetBase;
}

class PerfParser;
class ResultsSummaryPage;
class ResultsBottomUpPage;
Expand All @@ -54,7 +50,7 @@ class ResultsPage : public QWidget
QMenu* exportMenu() const;
QList<QAction*> windowActions() const;

void initDockWidgets(const QVector<KDDockWidgets::DockWidgetBase*>& restored);
void initDockWidgets(const QVector<CoreDockWidget*>& restored);

public slots:
void setSysroot(const QString& path);
Expand All @@ -74,27 +70,27 @@ public slots:
void repositionFilterBusyIndicator();

std::unique_ptr<Ui::ResultsPage> ui;
KDDockWidgets::MainWindow* m_contents;
DockMainWindow* m_contents;
FilterAndZoomStack* m_filterAndZoomStack;
CostContextMenu* m_costContextMenu;
QMenu* m_filterMenu;
QMenu* m_exportMenu;
KDDockWidgets::DockWidget* m_summaryPageDock;
DockWidget* m_summaryPageDock;
ResultsSummaryPage* m_resultsSummaryPage;
KDDockWidgets::DockWidget* m_bottomUpDock;
DockWidget* m_bottomUpDock;
ResultsBottomUpPage* m_resultsBottomUpPage;
KDDockWidgets::DockWidget* m_topDownDock;
DockWidget* m_topDownDock;
ResultsTopDownPage* m_resultsTopDownPage;
KDDockWidgets::DockWidget* m_flameGraphDock;
DockWidget* m_flameGraphDock;
ResultsFlameGraphPage* m_resultsFlameGraphPage;
KDDockWidgets::DockWidget* m_callerCalleeDock;
DockWidget* m_callerCalleeDock;
ResultsCallerCalleePage* m_resultsCallerCalleePage;
KDDockWidgets::DockWidget* m_disassemblyDock;
DockWidget* m_disassemblyDock;
ResultsDisassemblyPage* m_resultsDisassemblyPage;
KDDockWidgets::DockWidget* m_timeLineDock;
DockWidget* m_timeLineDock;
TimeLineWidget* m_timeLineWidget;
FrequencyPage* m_frequencyPage = nullptr;
KDDockWidgets::DockWidget* m_frequencyDock = nullptr;
DockWidget* m_frequencyDock = nullptr;
QWidget* m_filterBusyIndicator = nullptr;
bool m_timelineVisible;
};