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