mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 07:00:06 +00:00 
			
		
		
		
	Change collapsible title from labels to buttons, connect toggled signal to expand/collapse
This commit is contained in:
		
							parent
							
								
									300091dbe1
								
							
						
					
					
						commit
						7ff9feba25
					
				
					 2 changed files with 36 additions and 56 deletions
				
			
		|  | @ -39,7 +39,7 @@ CollapsibleGroup::CollapsibleGroup(const QString& title, QWidget* parent) : | ||||||
|     ui(new Ui::CollapsibleGroup) |     ui(new Ui::CollapsibleGroup) | ||||||
| { | { | ||||||
|    ui->setupUi(this); |    ui->setupUi(this); | ||||||
|    ui->titleLabel->setText(title); |    ui->titleButton->setText(title); | ||||||
|    p->Initialize(); |    p->Initialize(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -51,6 +51,21 @@ CollapsibleGroup::~CollapsibleGroup() | ||||||
| void CollapsibleGroupImpl::Initialize() | void CollapsibleGroupImpl::Initialize() | ||||||
| { | { | ||||||
|    self_->Expand(); |    self_->Expand(); | ||||||
|  | 
 | ||||||
|  |    QObject::connect(self_->ui->titleButton, | ||||||
|  |                     &QAbstractButton::toggled, | ||||||
|  |                     self_, | ||||||
|  |                     [this](bool checked) | ||||||
|  |                     { | ||||||
|  |                        if (checked) | ||||||
|  |                        { | ||||||
|  |                           self_->Expand(); | ||||||
|  |                        } | ||||||
|  |                        else | ||||||
|  |                        { | ||||||
|  |                           self_->Collapse(); | ||||||
|  |                        } | ||||||
|  |                     }); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CollapsibleGroup::SetContentsLayout(QLayout* layout) | void CollapsibleGroup::SetContentsLayout(QLayout* layout) | ||||||
|  | @ -60,14 +75,16 @@ void CollapsibleGroup::SetContentsLayout(QLayout* layout) | ||||||
| 
 | 
 | ||||||
| void CollapsibleGroup::SetTitle(const QString& title) | void CollapsibleGroup::SetTitle(const QString& title) | ||||||
| { | { | ||||||
|    ui->titleLabel->setText(title); |    ui->titleButton->setText(title); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void CollapsibleGroup::Collapse() | void CollapsibleGroup::Collapse() | ||||||
| { | { | ||||||
|    // Update the title frame
 |    // Update the title frame
 | ||||||
|    ui->arrowLabel->setMaximumSize(8, 16); |    if (ui->titleButton->isChecked()) | ||||||
|    ui->arrowLabel->setPixmap(p->kCollapsedIcon_.pixmap(8, 16)); |    { | ||||||
|  |       ui->titleButton->setChecked(false); | ||||||
|  |    } | ||||||
| 
 | 
 | ||||||
|    // Hide the group contents
 |    // Hide the group contents
 | ||||||
|    ui->contentsFrame->setVisible(false); |    ui->contentsFrame->setVisible(false); | ||||||
|  | @ -76,8 +93,10 @@ void CollapsibleGroup::Collapse() | ||||||
| void CollapsibleGroup::Expand() | void CollapsibleGroup::Expand() | ||||||
| { | { | ||||||
|    // Update the title frame
 |    // Update the title frame
 | ||||||
|    ui->arrowLabel->setMaximumSize(16, 16); |    if (!ui->titleButton->isChecked()) | ||||||
|    ui->arrowLabel->setPixmap(p->kExpandedIcon_.pixmap(16, 16)); |    { | ||||||
|  |       ui->titleButton->setChecked(true); | ||||||
|  |    } | ||||||
| 
 | 
 | ||||||
|    // Show the group contents
 |    // Show the group contents
 | ||||||
|    ui->contentsFrame->setVisible(true); |    ui->contentsFrame->setVisible(true); | ||||||
|  |  | ||||||
|  | @ -17,18 +17,6 @@ | ||||||
|    <property name="spacing"> |    <property name="spacing"> | ||||||
|     <number>0</number> |     <number>0</number> | ||||||
|    </property> |    </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> |    <item> | ||||||
|     <widget class="QFrame" name="titleFrame"> |     <widget class="QFrame" name="titleFrame"> | ||||||
|      <property name="frameShape"> |      <property name="frameShape"> | ||||||
|  | @ -51,50 +39,23 @@ | ||||||
|        <number>1</number> |        <number>1</number> | ||||||
|       </property> |       </property> | ||||||
|       <item> |       <item> | ||||||
|        <widget class="QLabel" name="arrowLabel"> |        <widget class="QPushButton" name="titleButton"> | ||||||
|         <property name="minimumSize"> |         <property name="styleSheet"> | ||||||
|          <size> |          <string notr="true">background: transparent; border: none; color: palette(window-text); text-align: left;</string> | ||||||
|           <width>16</width> |  | ||||||
|           <height>0</height> |  | ||||||
|          </size> |  | ||||||
|         </property> |         </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"> |         <property name="text"> | ||||||
|          <string>Title</string> |          <string>Title</string> | ||||||
|         </property> |         </property> | ||||||
|  |         <property name="icon"> | ||||||
|  |          <iconset resource="../../../../scwx-qt.qrc"> | ||||||
|  |           <normaloff>:/res/icons/font-awesome-6/angle-right-solid.svg</normaloff> | ||||||
|  |           <normalon>:/res/icons/font-awesome-6/angle-down-solid.svg</normalon>:/res/icons/font-awesome-6/angle-right-solid.svg</iconset> | ||||||
|  |         </property> | ||||||
|  |         <property name="checkable"> | ||||||
|  |          <bool>true</bool> | ||||||
|  |         </property> | ||||||
|        </widget> |        </widget> | ||||||
|       </item> |       </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> |      </layout> | ||||||
|     </widget> |     </widget> | ||||||
|    </item> |    </item> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat