Camera Raw panel docked beside the canvas: scope, Light, Color, Effects, canvas tools (12.8b1)
This commit is contained in:
1 parent
9d012d325a
commit
56af936a7b
26 files changed
+1794
-34
No files matched your search
@@ -4,6 +4,9 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QDialog>
|
||||
#include <QHash>
|
||||
#include <QLabel>
|
||||
#include <QStyle>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace {
|
||||
@@ -39,7 +42,8 @@ protected:
|
||||
void moveEvent(QMoveEvent *event) override
|
||||
{
|
||||
QDialog::moveEvent(event);
|
||||
if (isVisible())
|
||||
// A docked frame is the window's: never remembered.
|
||||
if (isVisible() && isWindow())
|
||||
m_owner.remember();
|
||||
}
|
||||
|
||||
@@ -52,22 +56,22 @@ FloatingPanel::FloatingPanel(const QString &name, QWidget &owner) : m_name(name)
|
||||
FloatingPanel::~FloatingPanel()
|
||||
{
|
||||
delete m_panel;
|
||||
delete m_docked;
|
||||
}
|
||||
|
||||
void FloatingPanel::show(const QString &title, QWidget *content)
|
||||
void FloatingPanel::show(const QString &title, QWidget *content, QWidget *dock)
|
||||
{
|
||||
if (dock) {
|
||||
showDocked(title, content, *dock);
|
||||
return;
|
||||
}
|
||||
if (!m_panel) {
|
||||
m_panel = new PanelWindow(*this, m_owner.window());
|
||||
m_panel->setObjectName(m_name);
|
||||
}
|
||||
const bool wasVisible = m_panel->isVisible();
|
||||
m_panel->setWindowTitle(title);
|
||||
// Later: a signal from the old content may still run.
|
||||
if (m_content) {
|
||||
m_content->hide();
|
||||
m_content->deleteLater();
|
||||
}
|
||||
m_content = content;
|
||||
place(content);
|
||||
m_panel->layout()->addWidget(content);
|
||||
// Shown now: layouts show late children from the event loop.
|
||||
content->show();
|
||||
@@ -86,16 +90,61 @@ void FloatingPanel::show(const QString &title, QWidget *content)
|
||||
remember();
|
||||
}
|
||||
|
||||
// Wayland lets no client place a window: a slot instead.
|
||||
void FloatingPanel::showDocked(const QString &title, QWidget *content, QWidget &dock)
|
||||
{
|
||||
if (!m_docked) {
|
||||
m_docked = new PanelWindow(*this, &dock);
|
||||
m_docked->setWindowFlags(Qt::Widget);
|
||||
m_docked->setObjectName(m_name);
|
||||
m_docked->layout()->setSizeConstraint(QLayout::SetDefaultConstraint);
|
||||
auto *header = new QWidget(m_docked);
|
||||
auto *row = new QHBoxLayout(header);
|
||||
row->setContentsMargins(12, 8, 8, 0);
|
||||
auto *heading = new QLabel(header);
|
||||
heading->setObjectName(QStringLiteral("dockedTitle"));
|
||||
auto *closer = new QToolButton(header);
|
||||
closer->setObjectName(QStringLiteral("dockedClose"));
|
||||
closer->setIcon(closer->style()->standardIcon(QStyle::SP_TitleBarCloseButton));
|
||||
closer->setAccessibleName(QStringLiteral("Close"));
|
||||
closer->setAutoRaise(true);
|
||||
QObject::connect(closer, &QToolButton::clicked, m_docked, &QWidget::close);
|
||||
row->addWidget(heading, 1);
|
||||
row->addWidget(closer);
|
||||
m_docked->layout()->addWidget(header);
|
||||
dock.layout()->addWidget(m_docked);
|
||||
}
|
||||
m_docked->findChild<QLabel *>(QStringLiteral("dockedTitle"))->setText(title);
|
||||
place(content);
|
||||
m_docked->layout()->addWidget(content);
|
||||
content->show();
|
||||
m_docked->show();
|
||||
dock.show();
|
||||
m_docked->setFocus();
|
||||
}
|
||||
|
||||
// Later: a signal from the old content may still run.
|
||||
void FloatingPanel::place(QWidget *content)
|
||||
{
|
||||
if (m_content) {
|
||||
m_content->hide();
|
||||
m_content->deleteLater();
|
||||
}
|
||||
m_content = content;
|
||||
}
|
||||
|
||||
// Moves were remembered as they came; hide sends no close.
|
||||
void FloatingPanel::close()
|
||||
{
|
||||
if (m_panel)
|
||||
m_panel->hide();
|
||||
if (m_docked)
|
||||
m_docked->parentWidget()->hide();
|
||||
}
|
||||
|
||||
bool FloatingPanel::isVisible() const
|
||||
{
|
||||
return m_panel && m_panel->isVisible();
|
||||
return (m_panel && m_panel->isVisible()) || (m_docked && m_docked->isVisible());
|
||||
}
|
||||
|
||||
void FloatingPanel::refocus(const QString &name)
|
||||
@@ -103,6 +152,11 @@ void FloatingPanel::refocus(const QString &name)
|
||||
for (QWidget *widget : QApplication::topLevelWidgets()) {
|
||||
if (widget->objectName() == name && widget->isVisible())
|
||||
widget->activateWindow();
|
||||
// A docked panel takes the keys inside its window.
|
||||
for (QDialog *docked : widget->findChildren<QDialog *>(name)) {
|
||||
if (docked->isVisible() && !docked->isWindow())
|
||||
docked->setFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user