Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit c1c3175

Browse files
committed
Core: added expandable dialog widget with "More Options" button
1 parent a754ddb commit c1c3175

File tree

4 files changed

+219
-0
lines changed

4 files changed

+219
-0
lines changed

Libs/libMacGitverCore/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ SET( SRC_FILES
5353

5454
SHMParser/ShellExpand.cpp
5555

56+
Widgets/ExpandableDlg.cpp
5657
Widgets/FontSelectWidget.cpp
5758
Widgets/LineEdit.cpp
5859
Widgets/StringSelectorWidget.cpp
@@ -105,6 +106,7 @@ SET( PUB_HDR_FILES
105106

106107
SHMParser/ShellExpand.hpp
107108

109+
Widgets/ExpandableDlg.hpp
108110
Widgets/FontSelectWidget.h
109111
Widgets/LineEdit.h
110112
Widgets/StringSelectorWidget.h
@@ -158,6 +160,7 @@ SET( UI_FILES
158160

159161
RepoMan/Config/RepoManConfigPage.ui
160162

163+
Widgets/ExpandableDlg.ui
161164
)
162165

163166
SET( HID_FILES
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* MacGitver
3+
* Copyright (C) 2015 The MacGitver-Developers <[email protected]>
4+
*
5+
* (C) Sascha Cunz <[email protected]>
6+
* (C) Nils Fenner <[email protected]>
7+
*
8+
* This program is free software; you can redistribute it and/or modify it under the terms of the
9+
* GNU General Public License (Version 2) as published by the Free Software Foundation.
10+
*
11+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
12+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License along with this program; if
16+
* not, see <http://www.gnu.org/licenses/>.
17+
*
18+
*/
19+
20+
#include "ExpandableDlg.hpp"
21+
#include "ui_ExpandableDlg.h"
22+
23+
ExpandableDlg::ExpandableDlg()
24+
: ui(new Ui::ExpandableDlg)
25+
{
26+
ui->setupUi(this);
27+
}
28+
29+
void ExpandableDlg::setDialogWidgets(QWidget* mainWdgt, QWidget* optsWdgt)
30+
{
31+
Q_ASSERT(mainWdgt);
32+
ui->optsLayout->addWidget(mainWdgt);
33+
34+
mOptsWdgt = optsWdgt;
35+
Q_ASSERT(mOptsWdgt && mOptsWdgt->layout());
36+
37+
// the margin is already defined by ui->optsLayout
38+
mOptsWdgt->layout()->setMargin(0);
39+
40+
}
41+
42+
void ExpandableDlg::on_btnShowOpts_toggled(bool checked)
43+
{
44+
Q_ASSERT(mOptsWdgt);
45+
46+
if ( checked ) {
47+
ui->optsLayout->addWidget( mOptsWdgt );
48+
mOptsWdgt->show();
49+
}
50+
else {
51+
ui->optsLayout->removeWidget( mOptsWdgt );
52+
if ( mOptsWdgt ) {
53+
mOptsWdgt->hide();
54+
}
55+
56+
layout()->activate();
57+
resize( width(), minimumSizeHint().height() );
58+
}
59+
}
60+
61+
/**
62+
* @internal
63+
*
64+
* @brief Set the enabled state of the dialogs OK button.
65+
*
66+
* @param valid controls the dialogs acceptable state
67+
*/
68+
void ExpandableDlg::setAcceptable(bool valid)
69+
{
70+
ui->buttonBox->button( QDialogButtonBox::Ok )->setEnabled( valid );
71+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* MacGitver
3+
* Copyright (C) 2015 The MacGitver-Developers <[email protected]>
4+
*
5+
* (C) Sascha Cunz <[email protected]>
6+
* (C) Nils Fenner <[email protected]>
7+
*
8+
* This program is free software; you can redistribute it and/or modify it under the terms of the
9+
* GNU General Public License (Version 2) as published by the Free Software Foundation.
10+
*
11+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
12+
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License along with this program; if
16+
* not, see <http://www.gnu.org/licenses/>.
17+
*
18+
*/
19+
20+
#pragma once
21+
22+
#include "libMacGitverCore/MacGitverApi.hpp"
23+
#include "libBlueSky/Dialog.hpp"
24+
25+
namespace Ui
26+
{
27+
class ExpandableDlg;
28+
}
29+
30+
class MGV_CORE_API ExpandableDlg : public BlueSky::Dialog
31+
{
32+
Q_OBJECT
33+
34+
public:
35+
ExpandableDlg();
36+
37+
protected:
38+
void setDialogWidgets(QWidget* mainWdgt, QWidget* optsWdgt);
39+
40+
protected:
41+
void setAcceptable(bool valid);
42+
43+
private slots:
44+
void on_btnShowOpts_toggled(bool checked);
45+
46+
private:
47+
Ui::ExpandableDlg* ui;
48+
49+
private:
50+
QWidget* mOptsWdgt = nullptr;
51+
};
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>ExpandableDlg</class>
4+
<widget class="QDialog" name="ExpandableDlg">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>602</width>
10+
<height>49</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Clone repository</string>
15+
</property>
16+
<layout class="QGridLayout" name="gridLayout">
17+
<item row="1" column="0" colspan="2">
18+
<widget class="QPushButton" name="btnShowOpts">
19+
<property name="text">
20+
<string>More Options</string>
21+
</property>
22+
<property name="checkable">
23+
<bool>true</bool>
24+
</property>
25+
</widget>
26+
</item>
27+
<item row="1" column="2">
28+
<spacer name="horizontalSpacer">
29+
<property name="orientation">
30+
<enum>Qt::Horizontal</enum>
31+
</property>
32+
<property name="sizeHint" stdset="0">
33+
<size>
34+
<width>40</width>
35+
<height>20</height>
36+
</size>
37+
</property>
38+
</spacer>
39+
</item>
40+
<item row="0" column="0" colspan="5">
41+
<layout class="QVBoxLayout" name="optsLayout">
42+
<property name="spacing">
43+
<number>0</number>
44+
</property>
45+
</layout>
46+
</item>
47+
<item row="1" column="3" colspan="2">
48+
<widget class="QDialogButtonBox" name="buttonBox">
49+
<property name="orientation">
50+
<enum>Qt::Horizontal</enum>
51+
</property>
52+
<property name="standardButtons">
53+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
54+
</property>
55+
</widget>
56+
</item>
57+
</layout>
58+
</widget>
59+
<resources/>
60+
<connections>
61+
<connection>
62+
<sender>buttonBox</sender>
63+
<signal>accepted()</signal>
64+
<receiver>ExpandableDlg</receiver>
65+
<slot>accept()</slot>
66+
<hints>
67+
<hint type="sourcelabel">
68+
<x>222</x>
69+
<y>342</y>
70+
</hint>
71+
<hint type="destinationlabel">
72+
<x>157</x>
73+
<y>274</y>
74+
</hint>
75+
</hints>
76+
</connection>
77+
<connection>
78+
<sender>buttonBox</sender>
79+
<signal>rejected()</signal>
80+
<receiver>ExpandableDlg</receiver>
81+
<slot>reject()</slot>
82+
<hints>
83+
<hint type="sourcelabel">
84+
<x>290</x>
85+
<y>348</y>
86+
</hint>
87+
<hint type="destinationlabel">
88+
<x>286</x>
89+
<y>274</y>
90+
</hint>
91+
</hints>
92+
</connection>
93+
</connections>
94+
</ui>

0 commit comments

Comments
 (0)