mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 15:00:04 +00:00
Initial collapsible group layout
This commit is contained in:
parent
b198dc53ca
commit
300091dbe1
6 changed files with 253 additions and 0 deletions
1
scwx-qt/res/icons/font-awesome-6/angle-down-solid.svg
Normal file
1
scwx-qt/res/icons/font-awesome-6/angle-down-solid.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Pro 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M201.4 342.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 274.7 86.6 137.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z"/></svg>
|
||||
|
After Width: | Height: | Size: 416 B |
|
|
@ -147,6 +147,7 @@ set(HDR_UI source/scwx/qt/ui/about_dialog.hpp
|
|||
source/scwx/qt/ui/alert_dialog.hpp
|
||||
source/scwx/qt/ui/alert_dock_widget.hpp
|
||||
source/scwx/qt/ui/animation_dock_widget.hpp
|
||||
source/scwx/qt/ui/collapsible_group.hpp
|
||||
source/scwx/qt/ui/flow_layout.hpp
|
||||
source/scwx/qt/ui/imgui_debug_dialog.hpp
|
||||
source/scwx/qt/ui/imgui_debug_widget.hpp
|
||||
|
|
@ -160,6 +161,7 @@ set(SRC_UI source/scwx/qt/ui/about_dialog.cpp
|
|||
source/scwx/qt/ui/alert_dialog.cpp
|
||||
source/scwx/qt/ui/alert_dock_widget.cpp
|
||||
source/scwx/qt/ui/animation_dock_widget.cpp
|
||||
source/scwx/qt/ui/collapsible_group.cpp
|
||||
source/scwx/qt/ui/flow_layout.cpp
|
||||
source/scwx/qt/ui/imgui_debug_dialog.cpp
|
||||
source/scwx/qt/ui/imgui_debug_widget.cpp
|
||||
|
|
@ -173,6 +175,7 @@ set(UI_UI source/scwx/qt/ui/about_dialog.ui
|
|||
source/scwx/qt/ui/alert_dialog.ui
|
||||
source/scwx/qt/ui/alert_dock_widget.ui
|
||||
source/scwx/qt/ui/animation_dock_widget.ui
|
||||
source/scwx/qt/ui/collapsible_group.ui
|
||||
source/scwx/qt/ui/imgui_debug_dialog.ui
|
||||
source/scwx/qt/ui/radar_site_dialog.ui
|
||||
source/scwx/qt/ui/settings_dialog.ui
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
<file>res/fonts/din1451alt_g.ttf</file>
|
||||
<file>res/icons/scwx-256.ico</file>
|
||||
<file>res/icons/scwx-256.png</file>
|
||||
<file>res/icons/font-awesome-6/angle-down-solid.svg</file>
|
||||
<file>res/icons/font-awesome-6/angle-left-solid.svg</file>
|
||||
<file>res/icons/font-awesome-6/angle-right-solid.svg</file>
|
||||
<file>res/icons/font-awesome-6/backward-step-solid.svg</file>
|
||||
|
|
|
|||
88
scwx-qt/source/scwx/qt/ui/collapsible_group.cpp
Normal file
88
scwx-qt/source/scwx/qt/ui/collapsible_group.cpp
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
#include "collapsible_group.hpp"
|
||||
#include "ui_collapsible_group.h"
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
|
||||
class CollapsibleGroupImpl
|
||||
{
|
||||
public:
|
||||
explicit CollapsibleGroupImpl(CollapsibleGroup* self) : self_ {self} {}
|
||||
~CollapsibleGroupImpl() = default;
|
||||
|
||||
void Initialize();
|
||||
|
||||
const QIcon kCollapsedIcon_ {
|
||||
":/res/icons/font-awesome-6/angle-right-solid.svg"};
|
||||
const QIcon kExpandedIcon_ {
|
||||
":/res/icons/font-awesome-6/angle-down-solid.svg"};
|
||||
|
||||
CollapsibleGroup* self_;
|
||||
};
|
||||
|
||||
CollapsibleGroup::CollapsibleGroup(QWidget* parent) :
|
||||
QFrame(parent),
|
||||
p {std::make_unique<CollapsibleGroupImpl>(this)},
|
||||
ui(new Ui::CollapsibleGroup)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
p->Initialize();
|
||||
}
|
||||
|
||||
CollapsibleGroup::CollapsibleGroup(const QString& title, QWidget* parent) :
|
||||
QFrame(parent),
|
||||
p {std::make_unique<CollapsibleGroupImpl>(this)},
|
||||
ui(new Ui::CollapsibleGroup)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->titleLabel->setText(title);
|
||||
p->Initialize();
|
||||
}
|
||||
|
||||
CollapsibleGroup::~CollapsibleGroup()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CollapsibleGroupImpl::Initialize()
|
||||
{
|
||||
self_->Expand();
|
||||
}
|
||||
|
||||
void CollapsibleGroup::SetContentsLayout(QLayout* layout)
|
||||
{
|
||||
ui->contentsFrame->setLayout(layout);
|
||||
}
|
||||
|
||||
void CollapsibleGroup::SetTitle(const QString& title)
|
||||
{
|
||||
ui->titleLabel->setText(title);
|
||||
}
|
||||
|
||||
void CollapsibleGroup::Collapse()
|
||||
{
|
||||
// Update the title frame
|
||||
ui->arrowLabel->setMaximumSize(8, 16);
|
||||
ui->arrowLabel->setPixmap(p->kCollapsedIcon_.pixmap(8, 16));
|
||||
|
||||
// Hide the group contents
|
||||
ui->contentsFrame->setVisible(false);
|
||||
}
|
||||
|
||||
void CollapsibleGroup::Expand()
|
||||
{
|
||||
// Update the title frame
|
||||
ui->arrowLabel->setMaximumSize(16, 16);
|
||||
ui->arrowLabel->setPixmap(p->kExpandedIcon_.pixmap(16, 16));
|
||||
|
||||
// Show the group contents
|
||||
ui->contentsFrame->setVisible(true);
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
43
scwx-qt/source/scwx/qt/ui/collapsible_group.hpp
Normal file
43
scwx-qt/source/scwx/qt/ui/collapsible_group.hpp
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#pragma once
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class CollapsibleGroup;
|
||||
}
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
namespace qt
|
||||
{
|
||||
namespace ui
|
||||
{
|
||||
|
||||
class CollapsibleGroupImpl;
|
||||
|
||||
class CollapsibleGroup : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CollapsibleGroup(QWidget* parent = nullptr);
|
||||
explicit CollapsibleGroup(const QString& title, QWidget* parent = nullptr);
|
||||
~CollapsibleGroup();
|
||||
|
||||
void SetContentsLayout(QLayout* contents);
|
||||
void SetTitle(const QString& title);
|
||||
|
||||
public slots:
|
||||
void Collapse();
|
||||
void Expand();
|
||||
|
||||
private:
|
||||
friend class CollapsibleGroupImpl;
|
||||
std::unique_ptr<CollapsibleGroupImpl> p;
|
||||
Ui::CollapsibleGroup* ui;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
117
scwx-qt/source/scwx/qt/ui/collapsible_group.ui
Normal file
117
scwx-qt/source/scwx/qt/ui/collapsible_group.ui
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CollapsibleGroup</class>
|
||||
<widget class="QFrame" name="CollapsibleGroup">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="titleFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="arrowLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>8</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../../../../scwx-qt.qrc">:/res/icons/font-awesome-6/angle-down-solid.svg</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="titleLabel">
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="contentsFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../../../scwx-qt.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
Loading…
Add table
Add a link
Reference in a new issue