mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 03:14:23 +00:00
Interface mockup 3
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
// This file was generated with the assistance of an AI coding tool.
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include "CollapsibleSection.h"
|
||||
|
||||
#include "SvgIcon.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace ifcinterface::components::inspector {
|
||||
|
||||
namespace {
|
||||
|
||||
QWidget* makeInspectorFilterField(const QString& placeholder, QWidget* parent = nullptr) {
|
||||
auto* field = new QLineEdit(parent);
|
||||
field->setPlaceholderText(placeholder);
|
||||
field->setClearButtonEnabled(true);
|
||||
field->addAction(icons::makePanelSvgIcon(":/icons/filter.svg"), QLineEdit::LeadingPosition);
|
||||
return field;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CollapsibleSection::CollapsibleSection(const QString& title, const QString& filter_placeholder, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setObjectName("inspectorSection");
|
||||
auto* layout = new QVBoxLayout(this);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(6);
|
||||
|
||||
auto* header = new QFrame(this);
|
||||
header->setObjectName("inspectorSectionHeader");
|
||||
auto* header_layout = new QHBoxLayout(header);
|
||||
header_layout->setContentsMargins(0, 0, 0, 0);
|
||||
header_layout->setSpacing(6);
|
||||
|
||||
auto* toggle = new QToolButton(header);
|
||||
toggle->setObjectName("inspectorSectionButton");
|
||||
toggle->setText(title);
|
||||
toggle->setCheckable(true);
|
||||
toggle->setChecked(true);
|
||||
toggle->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
toggle->setArrowType(Qt::DownArrow);
|
||||
header_layout->addWidget(toggle);
|
||||
header_layout->addStretch(1);
|
||||
|
||||
if (!filter_placeholder.isEmpty()) {
|
||||
auto* filter_toggle = new QToolButton(header);
|
||||
filter_toggle->setObjectName("inspectorFilterToggle");
|
||||
filter_toggle->setCheckable(true);
|
||||
filter_toggle->setIcon(icons::makePanelSvgIcon(":/icons/filter.svg"));
|
||||
filter_toggle->setAutoRaise(true);
|
||||
header_layout->addWidget(filter_toggle);
|
||||
|
||||
filter_field_ = qobject_cast<QLineEdit*>(makeInspectorFilterField(filter_placeholder, this));
|
||||
filter_field_->setVisible(false);
|
||||
connect(filter_toggle, &QToolButton::toggled, filter_field_, [this](bool visible) {
|
||||
filter_field_->setVisible(visible);
|
||||
if (visible) filter_field_->setFocus();
|
||||
});
|
||||
}
|
||||
|
||||
body_ = new QWidget(this);
|
||||
body_->setObjectName("inspectorSectionBody");
|
||||
body_layout_ = new QVBoxLayout(body_);
|
||||
body_layout_->setContentsMargins(10, 6, 10, 0);
|
||||
body_layout_->setSpacing(6);
|
||||
|
||||
connect(toggle, &QToolButton::toggled, body_, [toggle, this](bool expanded) {
|
||||
toggle->setArrowType(expanded ? Qt::DownArrow : Qt::RightArrow);
|
||||
body_->setVisible(expanded);
|
||||
});
|
||||
|
||||
layout->addWidget(header);
|
||||
if (filter_field_) {
|
||||
auto* filter_wrapper = new QWidget(this);
|
||||
filter_wrapper->setObjectName("inspectorFilterWrapper");
|
||||
auto* filter_wrapper_layout = new QVBoxLayout(filter_wrapper);
|
||||
filter_wrapper_layout->setContentsMargins(10, 0, 10, 0);
|
||||
filter_wrapper_layout->setSpacing(0);
|
||||
filter_wrapper_layout->addWidget(filter_field_);
|
||||
layout->addWidget(filter_wrapper);
|
||||
}
|
||||
layout->addWidget(body_);
|
||||
}
|
||||
|
||||
void CollapsibleSection::addBodyWidget(QWidget* widget) {
|
||||
body_layout_->addWidget(widget);
|
||||
}
|
||||
|
||||
} // namespace ifcinterface::components::inspector
|
||||
@@ -0,0 +1,48 @@
|
||||
// This file was generated with the assistance of an AI coding tool.
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef IFCINTERFACE_COMPONENTS_INSPECTOR_COLLAPSIBLESECTION_H
|
||||
#define IFCINTERFACE_COMPONENTS_INSPECTOR_COLLAPSIBLESECTION_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QLineEdit;
|
||||
class QVBoxLayout;
|
||||
|
||||
namespace ifcinterface::components::inspector {
|
||||
|
||||
class CollapsibleSection : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CollapsibleSection(const QString& title,
|
||||
const QString& filter_placeholder = {},
|
||||
QWidget* parent = nullptr);
|
||||
|
||||
void addBodyWidget(QWidget* widget);
|
||||
|
||||
private:
|
||||
QWidget* body_ = nullptr;
|
||||
QVBoxLayout* body_layout_ = nullptr;
|
||||
QLineEdit* filter_field_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace ifcinterface::components::inspector
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,117 @@
|
||||
// This file was generated with the assistance of an AI coding tool.
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include "PanelChrome.h"
|
||||
|
||||
#include "SvgIcon.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QFrame>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace ifcinterface::components::panel {
|
||||
|
||||
namespace {
|
||||
|
||||
class DockTitleBar : public QWidget {
|
||||
public:
|
||||
explicit DockTitleBar(const QString& title, bool has_settings = false, QWidget* parent = nullptr)
|
||||
: QWidget(parent)
|
||||
{
|
||||
auto* layout = new QHBoxLayout(this);
|
||||
layout->setContentsMargins(10, 6, 6, 6);
|
||||
layout->setSpacing(6);
|
||||
|
||||
auto* text = new QLabel(title.toUpper(), this);
|
||||
text->setObjectName("dockTitleText");
|
||||
|
||||
layout->addWidget(text);
|
||||
layout->addStretch(1);
|
||||
if (has_settings) {
|
||||
auto* settings = new QToolButton(this);
|
||||
settings->setIcon(icons::makePanelSvgIcon(":/icons/settings.svg"));
|
||||
settings->setAutoRaise(true);
|
||||
settings->setCursor(Qt::ArrowCursor);
|
||||
settings->setFixedSize(18, 18);
|
||||
settings->setObjectName("dockTitleButton");
|
||||
settings->setToolTip(QString("%1 settings").arg(title));
|
||||
connect(settings, &QToolButton::clicked, this, [this, title]() {
|
||||
auto* anchor = parentWidget();
|
||||
QMenu menu(anchor);
|
||||
menu.addAction(QString("%1 settings coming soon").arg(title));
|
||||
menu.exec(QCursor::pos());
|
||||
});
|
||||
layout->addWidget(settings);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
QDockWidget* makeDock(const QString& title, QWidget* content, QWidget* parent, bool has_settings) {
|
||||
auto* dock = new QDockWidget(title, parent);
|
||||
dock->setObjectName(title);
|
||||
dock->setFeatures(QDockWidget::DockWidgetMovable |
|
||||
QDockWidget::DockWidgetFloatable |
|
||||
QDockWidget::DockWidgetClosable);
|
||||
dock->setTitleBarWidget(new DockTitleBar(title, has_settings, dock));
|
||||
dock->setWidget(content);
|
||||
return dock;
|
||||
}
|
||||
|
||||
QFrame* wrapPanel(QWidget* inner) {
|
||||
auto* outer = new QFrame();
|
||||
auto* outer_layout = new QVBoxLayout(outer);
|
||||
outer_layout->setContentsMargins(6, 6, 6, 6);
|
||||
outer_layout->setSpacing(0);
|
||||
|
||||
auto* frame = new QFrame(outer);
|
||||
frame->setObjectName("panelFrame");
|
||||
auto* layout = new QVBoxLayout(frame);
|
||||
layout->setContentsMargins(8, 8, 8, 8);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(inner);
|
||||
|
||||
outer_layout->addWidget(frame);
|
||||
return outer;
|
||||
}
|
||||
|
||||
QFrame* wrapInspectorPanel(QWidget* inner) {
|
||||
auto* outer = new QFrame();
|
||||
auto* outer_layout = new QVBoxLayout(outer);
|
||||
outer_layout->setContentsMargins(6, 6, 6, 6);
|
||||
outer_layout->setSpacing(0);
|
||||
|
||||
auto* frame = new QFrame(outer);
|
||||
frame->setObjectName("panelFrame");
|
||||
auto* layout = new QVBoxLayout(frame);
|
||||
layout->setContentsMargins(0, 8, 0, 8);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(inner);
|
||||
|
||||
outer_layout->addWidget(frame);
|
||||
return outer;
|
||||
}
|
||||
|
||||
} // namespace ifcinterface::components::panel
|
||||
@@ -0,0 +1,38 @@
|
||||
// This file was generated with the assistance of an AI coding tool.
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef IFCINTERFACE_COMPONENTS_PANEL_PANELCHROME_H
|
||||
#define IFCINTERFACE_COMPONENTS_PANEL_PANELCHROME_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class QDockWidget;
|
||||
class QFrame;
|
||||
class QWidget;
|
||||
|
||||
namespace ifcinterface::components::panel {
|
||||
|
||||
QDockWidget* makeDock(const QString& title, QWidget* content, QWidget* parent, bool has_settings = false);
|
||||
QFrame* wrapPanel(QWidget* inner);
|
||||
QFrame* wrapInspectorPanel(QWidget* inner);
|
||||
|
||||
} // namespace ifcinterface::components::panel
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
// This file was generated with the assistance of an AI coding tool.
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#include "SvgIcon.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QPainter>
|
||||
#include <QRegularExpression>
|
||||
#include <QSvgRenderer>
|
||||
|
||||
namespace ifcinterface::components::icons {
|
||||
|
||||
QPixmap renderTintedSvgPixmap(const QString& icon_path, const QString& color, const QSize& size) {
|
||||
QFile file(icon_path);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
return QIcon(icon_path).pixmap(size);
|
||||
}
|
||||
|
||||
QString svg = QString::fromUtf8(file.readAll());
|
||||
svg.replace("currentColor", color, Qt::CaseSensitive);
|
||||
svg.replace(QRegularExpression(R"(stroke="[^"]*")"), QString("stroke=\"%1\"").arg(color));
|
||||
svg.replace(QRegularExpression(R"(fill="none")"), "fill=\"none\"");
|
||||
|
||||
QSvgRenderer renderer(svg.toUtf8());
|
||||
QPixmap pixmap(size);
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter painter(&pixmap);
|
||||
renderer.render(&painter);
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QIcon makeTintedSvgIcon(const QString& icon_path, const QString& normal,
|
||||
const QString& active, const QString& disabled) {
|
||||
QFile file(icon_path);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
return QIcon(icon_path);
|
||||
}
|
||||
|
||||
QIcon icon;
|
||||
icon.addPixmap(renderTintedSvgPixmap(icon_path, normal, QSize(20, 20)), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap(renderTintedSvgPixmap(icon_path, active, QSize(20, 20)), QIcon::Active, QIcon::Off);
|
||||
icon.addPixmap(renderTintedSvgPixmap(icon_path, active, QSize(20, 20)), QIcon::Selected, QIcon::Off);
|
||||
icon.addPixmap(renderTintedSvgPixmap(icon_path, disabled, QSize(20, 20)), QIcon::Disabled, QIcon::Off);
|
||||
return icon;
|
||||
}
|
||||
|
||||
QIcon makePanelSvgIcon(const QString& icon_path) {
|
||||
return makeTintedSvgIcon(icon_path, "#e7ebf2", "#ffffff", "#6f7988");
|
||||
}
|
||||
|
||||
QPixmap makePanelSvgPixmap(const QString& icon_path, const QSize& size) {
|
||||
return renderTintedSvgPixmap(icon_path, "#e7ebf2", size);
|
||||
}
|
||||
|
||||
} // namespace ifcinterface::components::icons
|
||||
@@ -0,0 +1,41 @@
|
||||
// This file was generated with the assistance of an AI coding tool.
|
||||
/********************************************************************************
|
||||
* *
|
||||
* This file is part of IfcOpenShell. *
|
||||
* *
|
||||
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the Lesser GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3.0 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* IfcOpenShell is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* Lesser GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the Lesser GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef IFCINTERFACE_COMPONENTS_ICONS_SVGICON_H
|
||||
#define IFCINTERFACE_COMPONENTS_ICONS_SVGICON_H
|
||||
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QString>
|
||||
#include <QSize>
|
||||
|
||||
namespace ifcinterface::components::icons {
|
||||
|
||||
QPixmap renderTintedSvgPixmap(const QString& icon_path, const QString& color, const QSize& size);
|
||||
QIcon makeTintedSvgIcon(const QString& icon_path,
|
||||
const QString& normal = "#39b54a",
|
||||
const QString& active = "#53c763",
|
||||
const QString& disabled = "#6f7988");
|
||||
QIcon makePanelSvgIcon(const QString& icon_path);
|
||||
QPixmap makePanelSvgPixmap(const QString& icon_path, const QSize& size);
|
||||
|
||||
} // namespace ifcinterface::components::icons
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user