mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 17:20:04 +00:00
Update collapsible group interface for signals/slots
This commit is contained in:
parent
1e4e2ba1b4
commit
b0375c4790
2 changed files with 15 additions and 21 deletions
|
|
@ -15,7 +15,6 @@ public:
|
|||
~CollapsibleGroupImpl() = default;
|
||||
|
||||
void Initialize();
|
||||
void SetExpanded(bool expanded);
|
||||
|
||||
const QIcon kCollapsedIcon_ {
|
||||
":/res/icons/font-awesome-6/square-caret-right-regular.svg"};
|
||||
|
|
@ -60,10 +59,10 @@ void CollapsibleGroupImpl::Initialize()
|
|||
self_->ui->titleButton,
|
||||
&QAbstractButton::clicked,
|
||||
self_,
|
||||
[this]() { SetExpanded(!expanded_); },
|
||||
[this]() { self_->SetExpanded(!expanded_); },
|
||||
Qt::DirectConnection);
|
||||
|
||||
self_->Expand();
|
||||
self_->SetExpanded(true);
|
||||
}
|
||||
|
||||
QLayout* CollapsibleGroup::GetContentsLayout()
|
||||
|
|
@ -81,28 +80,21 @@ void CollapsibleGroup::SetTitle(const QString& title)
|
|||
ui->titleButton->setText(title);
|
||||
}
|
||||
|
||||
void CollapsibleGroup::Collapse()
|
||||
{
|
||||
// Update the title frame
|
||||
p->SetExpanded(false);
|
||||
}
|
||||
|
||||
void CollapsibleGroup::Expand()
|
||||
{
|
||||
// Update the title frame
|
||||
p->SetExpanded(true);
|
||||
}
|
||||
|
||||
void CollapsibleGroupImpl::SetExpanded(bool expanded)
|
||||
void CollapsibleGroup::SetExpanded(bool expanded)
|
||||
{
|
||||
// Update icon
|
||||
self_->ui->titleButton->setIcon(kIcon_.at(expanded));
|
||||
ui->titleButton->setIcon(p->kIcon_.at(expanded));
|
||||
|
||||
// Update contents visibility
|
||||
self_->ui->contentsFrame->setVisible(expanded);
|
||||
ui->contentsFrame->setVisible(expanded);
|
||||
|
||||
// Update internal state
|
||||
expanded_ = expanded;
|
||||
if (p->expanded_ != expanded)
|
||||
{
|
||||
p->expanded_ = expanded;
|
||||
|
||||
Q_EMIT StateChanged(expanded);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
|
|
|
|||
|
|
@ -30,8 +30,10 @@ public:
|
|||
void SetTitle(const QString& title);
|
||||
|
||||
public slots:
|
||||
void Collapse();
|
||||
void Expand();
|
||||
void SetExpanded(bool expanded);
|
||||
|
||||
signals:
|
||||
void StateChanged(bool expanded);
|
||||
|
||||
private:
|
||||
friend class CollapsibleGroupImpl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue