mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 13: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 Initialize(); | ||||||
|    void SetExpanded(bool expanded); |    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_; |    CollapsibleGroup* self_; | ||||||
|  | 
 | ||||||
|  |    bool expanded_ {true}; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| CollapsibleGroup::CollapsibleGroup(QWidget* parent) : | CollapsibleGroup::CollapsibleGroup(QWidget* parent) : | ||||||
|  | @ -48,9 +58,9 @@ void CollapsibleGroupImpl::Initialize() | ||||||
| { | { | ||||||
|    QObject::connect( |    QObject::connect( | ||||||
|       self_->ui->titleButton, |       self_->ui->titleButton, | ||||||
|       &QAbstractButton::toggled, |       &QAbstractButton::clicked, | ||||||
|       self_, |       self_, | ||||||
|       [this](bool checked) { SetExpanded(checked); }, |       [this]() { SetExpanded(!expanded_); }, | ||||||
|       Qt::DirectConnection); |       Qt::DirectConnection); | ||||||
| 
 | 
 | ||||||
|    self_->Expand(); |    self_->Expand(); | ||||||
|  | @ -74,25 +84,25 @@ void CollapsibleGroup::SetTitle(const QString& title) | ||||||
| void CollapsibleGroup::Collapse() | void CollapsibleGroup::Collapse() | ||||||
| { | { | ||||||
|    // Update the title frame
 |    // Update the title frame
 | ||||||
|    if (ui->titleButton->isChecked()) |    p->SetExpanded(false); | ||||||
|    { |  | ||||||
|       ui->titleButton->setChecked(false); |  | ||||||
|    } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CollapsibleGroup::Expand() | void CollapsibleGroup::Expand() | ||||||
| { | { | ||||||
|    // Update the title frame
 |    // Update the title frame
 | ||||||
|    if (!ui->titleButton->isChecked()) |    p->SetExpanded(true); | ||||||
|    { |  | ||||||
|       ui->titleButton->setChecked(true); |  | ||||||
|    } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CollapsibleGroupImpl::SetExpanded(bool expanded) | void CollapsibleGroupImpl::SetExpanded(bool expanded) | ||||||
| { | { | ||||||
|  |    // Update icon
 | ||||||
|  |    self_->ui->titleButton->setIcon(kIcon_.at(expanded)); | ||||||
|  | 
 | ||||||
|    // Update contents visibility
 |    // Update contents visibility
 | ||||||
|    self_->ui->contentsFrame->setVisible(expanded); |    self_->ui->contentsFrame->setVisible(expanded); | ||||||
|  | 
 | ||||||
|  |    // Update internal state
 | ||||||
|  |    expanded_ = expanded; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } // namespace ui
 | } // namespace ui
 | ||||||
|  |  | ||||||
|  | @ -29,31 +29,10 @@ | ||||||
|    <property name="bottomMargin"> |    <property name="bottomMargin"> | ||||||
|     <number>0</number> |     <number>0</number> | ||||||
|    </property> |    </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> |    <item> | ||||||
|     <widget class="QPushButton" name="titleButton"> |     <widget class="QPushButton" name="titleButton"> | ||||||
|      <property name="styleSheet"> |      <property name="styleSheet"> | ||||||
|          <string notr="true">background: transparent; border: none; color: palette(window-text); text-align: left;</string> |       <string notr="true">text-align: left;</string> | ||||||
|      </property> |      </property> | ||||||
|      <property name="text"> |      <property name="text"> | ||||||
|       <string>Title</string> |       <string>Title</string> | ||||||
|  | @ -63,12 +42,6 @@ | ||||||
|        <normaloff>:/res/icons/font-awesome-6/square-caret-right-regular.svg</normaloff> |        <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> |        <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> | ||||||
|         <property name="checkable"> |  | ||||||
|          <bool>true</bool> |  | ||||||
|         </property> |  | ||||||
|        </widget> |  | ||||||
|       </item> |  | ||||||
|      </layout> |  | ||||||
|     </widget> |     </widget> | ||||||
|    </item> |    </item> | ||||||
|    <item> |    <item> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat