mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-01-09 08:25:13 +00:00
a967d891d6
* added psf file format * clang format fix * crypto functions for pkg decryption * pkg decryption * initial add of qt gui , not yet usable * renamed ini for qt gui settings into shadps4qt.ini * file detection and loader support * option to build QT qui * clang format fix * fixed reuse * Update src/core/file_format/pkg.cpp Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * Update src/core/file_format/pkg.cpp Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * Update src/core/file_format/pkg.cpp Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * Update src/core/file_format/pkg.cpp Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * Update src/core/loader.h Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * Update src/core/loader.cpp Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * uppercase fix * clang format fix * small fixes * let's try windows qt build ci * some more fixes for ci * Update src/core/file_format/pkg.cpp Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * Update src/core/file_format/pkg.cpp Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * Update src/core/file_format/pkg.cpp Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * Update src/core/file_format/pkg.cpp Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * Update .github/workflows/windows-qt.yml Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * Update src/core/loader.cpp Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * Update src/core/file_format/psf.cpp Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * loader namespace * Update src/core/loader.cpp Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> * constexpr magic * linux qt ci by qurious * fix for linux qt * Make script executable * ci fix? --------- Co-authored-by: raziel1000 <ckraziel@gmail.com> Co-authored-by: GPUCode <47210458+GPUCode@users.noreply.github.com> Co-authored-by: GPUCode <geoster3d@gmail.com>
63 lines
2.1 KiB
C++
63 lines
2.1 KiB
C++
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <QDockWidget>
|
|
#include <QPainter>
|
|
#include <QStyleOption>
|
|
|
|
class CustomDockWidget : public QDockWidget {
|
|
private:
|
|
std::shared_ptr<QWidget> m_title_bar_widget;
|
|
bool m_is_title_bar_visible = true;
|
|
|
|
public:
|
|
explicit CustomDockWidget(const QString& title, QWidget* parent = Q_NULLPTR,
|
|
Qt::WindowFlags flags = Qt::WindowFlags())
|
|
: QDockWidget(title, parent, flags) {
|
|
m_title_bar_widget.reset(titleBarWidget());
|
|
|
|
connect(this, &QDockWidget::topLevelChanged, [this](bool /* topLevel*/) {
|
|
SetTitleBarVisible(m_is_title_bar_visible);
|
|
style()->unpolish(this);
|
|
style()->polish(this);
|
|
});
|
|
}
|
|
|
|
void SetTitleBarVisible(bool visible) {
|
|
if (visible || isFloating()) {
|
|
if (m_title_bar_widget.get() != titleBarWidget()) {
|
|
setTitleBarWidget(m_title_bar_widget.get());
|
|
QMargins margins = widget()->contentsMargins();
|
|
margins.setTop(0);
|
|
widget()->setContentsMargins(margins);
|
|
}
|
|
} else {
|
|
setTitleBarWidget(new QWidget());
|
|
QMargins margins = widget()->contentsMargins();
|
|
margins.setTop(1);
|
|
widget()->setContentsMargins(margins);
|
|
}
|
|
|
|
m_is_title_bar_visible = visible;
|
|
}
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent* event) override {
|
|
// We need to repaint the dock widgets as plain widgets in floating mode.
|
|
// Source:
|
|
// https://stackoverflow.com/questions/10272091/cannot-add-a-background-image-to-a-qdockwidget
|
|
if (isFloating()) {
|
|
QStyleOption opt;
|
|
opt.initFrom(this);
|
|
QPainter p(this);
|
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
|
return;
|
|
}
|
|
|
|
// Use inherited method for docked mode because otherwise the dock would lose the title etc.
|
|
QDockWidget::paintEvent(event);
|
|
}
|
|
};
|