mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 22:00:05 +00:00
Update collapsible icon styling to use native buttons for the header/title
This commit is contained in:
parent
6d9d923081
commit
6a92e7601e
2 changed files with 30 additions and 47 deletions
|
|
@ -17,7 +17,17 @@ public:
|
|||
void Initialize();
|
||||
void SetExpanded(bool expanded);
|
||||
|
||||
const QIcon kCollapsedIcon_ {
|
||||
":/res/icons/font-awesome-6/square-caret-right-regular.svg"};
|
||||
const QIcon kExpandedIcon_ {
|
||||
":/res/icons/font-awesome-6/square-caret-down-regular.svg"};
|
||||
|
||||
const std::map<bool, const QIcon&> kIcon_ {{false, kCollapsedIcon_},
|
||||
{true, kExpandedIcon_}};
|
||||
|
||||
CollapsibleGroup* self_;
|
||||
|
||||
bool expanded_ {true};
|
||||
};
|
||||
|
||||
CollapsibleGroup::CollapsibleGroup(QWidget* parent) :
|
||||
|
|
@ -48,9 +58,9 @@ void CollapsibleGroupImpl::Initialize()
|
|||
{
|
||||
QObject::connect(
|
||||
self_->ui->titleButton,
|
||||
&QAbstractButton::toggled,
|
||||
&QAbstractButton::clicked,
|
||||
self_,
|
||||
[this](bool checked) { SetExpanded(checked); },
|
||||
[this]() { SetExpanded(!expanded_); },
|
||||
Qt::DirectConnection);
|
||||
|
||||
self_->Expand();
|
||||
|
|
@ -74,25 +84,25 @@ void CollapsibleGroup::SetTitle(const QString& title)
|
|||
void CollapsibleGroup::Collapse()
|
||||
{
|
||||
// Update the title frame
|
||||
if (ui->titleButton->isChecked())
|
||||
{
|
||||
ui->titleButton->setChecked(false);
|
||||
}
|
||||
p->SetExpanded(false);
|
||||
}
|
||||
|
||||
void CollapsibleGroup::Expand()
|
||||
{
|
||||
// Update the title frame
|
||||
if (!ui->titleButton->isChecked())
|
||||
{
|
||||
ui->titleButton->setChecked(true);
|
||||
}
|
||||
p->SetExpanded(true);
|
||||
}
|
||||
|
||||
void CollapsibleGroupImpl::SetExpanded(bool expanded)
|
||||
{
|
||||
// Update icon
|
||||
self_->ui->titleButton->setIcon(kIcon_.at(expanded));
|
||||
|
||||
// Update contents visibility
|
||||
self_->ui->contentsFrame->setVisible(expanded);
|
||||
|
||||
// Update internal state
|
||||
expanded_ = expanded;
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
|
|
|||
|
|
@ -30,45 +30,18 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="titleFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
<widget class="QPushButton" name="titleButton">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">text-align: left;</string>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/square-caret-right-regular.svg</normaloff>
|
||||
<normalon>:/res/icons/font-awesome-6/square-caret-down-regular.svg</normalon>:/res/icons/font-awesome-6/square-caret-right-regular.svg</iconset>
|
||||
</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="QPushButton" name="titleButton">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background: transparent; border: none; color: palette(window-text); text-align: left;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../../scwx-qt.qrc">
|
||||
<normaloff>:/res/icons/font-awesome-6/square-caret-right-regular.svg</normaloff>
|
||||
<normalon>:/res/icons/font-awesome-6/square-caret-down-regular.svg</normalon>:/res/icons/font-awesome-6/square-caret-right-regular.svg</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue