Skip to content

Commit 345dda9

Browse files
authored
Add GroupTitleSmall to Description (#5881)
* Add GroupTitleSmall to Description Implements jasp-stats/INTERNAL-jasp#2317 * fix margins and only show icon if specified
1 parent 02ac658 commit 345dda9

File tree

9 files changed

+50
-18
lines changed

9 files changed

+50
-18
lines changed

Desktop/components/JASP/Theme/Theme.qml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ JaspTheme
4949
fontGroupTitle.pixelSize: Math.round(14 * uiScale)
5050
fontGroupTitle.family: preferencesModel.interfaceFont
5151
fontGroupTitle.weight: Font.Medium
52+
53+
fontGroupTitleSmall.bold: true
54+
fontGroupTitleSmall.pixelSize: Math.round(12 * uiScale)
55+
fontGroupTitleSmall.family: preferencesModel.interfaceFont
56+
fontGroupTitleSmall.weight: Font.Medium
5257

5358
fontALTNavTag.bold: true
5459
fontALTNavTag.pixelSize: Math.round(15 * uiScale)

Desktop/components/JASP/Widgets/CustomMenu.qml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ FocusScope
176176
z : menuShadow.z + 1
177177
color : jaspTheme.fileMenuColorBackground
178178
focus : true
179-
width : column.maxWidth + (itemScrollbar.visible ? itemScrollbar.width : 0)
179+
width : column.maxWidth + jaspTheme.menuPadding + itemScrollbar.width
180180
height : menuOffset.y + column.maxHeight > menuMaxPos.y ? menuMaxPos.y - menuOffset.y : column.maxHeight
181181

182182
MouseArea
@@ -238,7 +238,7 @@ FocusScope
238238
anchors.fill : parent
239239
anchors.topMargin : jaspTheme.menuPadding / 2
240240
anchors.leftMargin : jaspTheme.menuPadding / 2
241-
anchors.rightMargin : itemScrollbar.width + anchors.margins
241+
anchors.rightMargin : itemScrollbar.width + jaspTheme.menuPadding / 2
242242
clip : true
243243
boundsBehavior : Flickable.StopAtBounds
244244
contentWidth : column.width
@@ -315,9 +315,9 @@ FocusScope
315315
? jaspTheme.buttonColorHovered
316316
: "transparent"
317317

318-
property bool itemEnabled: menu.props.hasOwnProperty("enabled") ? menu.props["enabled"][index] : (model.modelData !== undefined || model.isEnabled)
319-
property int padding: 4 + (menu.hasIcons ? 1 : 0) + (menuItemShortcut.text ? 1 : 0)
320-
property double initWidth: (menu.hasIcons ? menuItemImage.width : 0) + menuItemText.implicitWidth + menuItemShortcut.implicitWidth + menu._iconPad * padding
318+
property bool itemEnabled: menu.props.hasOwnProperty("enabled") ? menu.props["enabled"][index] : (model.modelData !== undefined || model.isEnabled)
319+
property int padding: 4 + (menu.hasIcons ? 1 : 0) + (menuItemShortcut.text ? 1 : 0)
320+
property double initWidth: (menu.hasIcons ? menuItemImage.width : 0) + menuItemText.implicitWidth + menuItemShortcut.implicitWidth + menu._iconPad * padding
321321

322322
Image
323323
{
@@ -381,7 +381,7 @@ FocusScope
381381
{
382382
id : menuItem
383383
width : initWidth
384-
height : (isSmall ? 0.5 : 1) * jaspTheme.menuGroupTitleHeight
384+
height : (isSmall ? 0.666 : 1) * jaspTheme.menuGroupTitleHeight
385385

386386
property double initWidth: menuItemImage.width + menuItemText.implicitWidth + 15 * preferencesModel.uiScale
387387

@@ -410,12 +410,15 @@ FocusScope
410410
{
411411
id : menuItemText
412412
text : model.modelData !== undefined ? model.modelData.substring(3) : displayText
413-
font : jaspTheme.fontGroupTitle
413+
font : isSmall ? jaspTheme.fontGroupTitleSmall : jaspTheme.fontGroupTitle
414414
color : jaspTheme.textEnabled
415+
verticalAlignment : Text.AlignVCenter
415416
anchors
416417
{
417-
left : menuItemImage.right
418+
left : menuItemImage.visible ? menuItemImage.right : parent.left
419+
right : parent.right
418420
leftMargin : menu._iconPad
421+
rightMargin : menu._iconPad
419422
verticalCenter : parent.verticalCenter
420423
}
421424
}

Desktop/modules/analysisentry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ std::string AnalysisEntry::qmlFilePath() const
6565
std::string AnalysisEntry::icon() const
6666
{
6767
if(_icon == "")
68-
return _isGroupTitle ? fq(JaspTheme::currentIconPath()) + "large-arrow-right.png" : "";
69-
68+
return "";
69+
7070
return _dynamicModule ? "file:" + _dynamicModule->iconFilePath(_icon) : fq(JaspTheme::currentIconPath()) + _icon;
7171
}
7272

Desktop/modules/description/entrybase.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ QString EntryBase::toString() const
3939
{
4040
switch(_entryType)
4141
{
42-
case EntryType::separator: return "-- separator --";
43-
case EntryType::groupTitle: return "-- groupTitle '" + title() + "' icon: '" + icon() + "' --";
42+
case EntryType::separator: return "-- separator --";
43+
case EntryType::groupTitle: return "-- groupTitle '" + title() + "' icon: '" + icon() + "' --";
44+
case EntryType::groupTitleSmall: return "-- groupTitleSmall '" + title() + "' icon: '" + icon() + "' --";
4445
case EntryType::analysis:
4546
return "-- analysis '" + title()
4647
+ ( menu() != title() ? " menu: '" + menu() + "'" : "" )
@@ -174,7 +175,8 @@ AnalysisEntry * EntryBase::convertToAnalysisEntry(bool requiresDataDefault, bool
174175
entry->_isEnabled = _enabled;
175176
entry->_isAnalysis = _entryType == EntryType::analysis;
176177
entry->_isSeparator = _entryType == EntryType::separator;
177-
entry->_isGroupTitle = _entryType == EntryType::groupTitle;
178+
entry->_isGroupTitle = _entryType == EntryType::groupTitle || _entryType == EntryType::groupTitleSmall;
179+
entry->_smallIcon = _entryType == EntryType::groupTitleSmall;
178180
entry->_hasWrapper = _description->hasWrappers() || _hasWrapper;
179181
entry->_dynamicModule = _description->dynMod();
180182

Desktop/modules/description/entrybase.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class EntryBase : public DescriptionChildBase
3636
Q_PROPERTY(bool hasWrapper READ hasWrapper WRITE setHasWrapper NOTIFY hasWrapperChanged )
3737

3838
public:
39-
enum class EntryType {unknown, separator, groupTitle, analysis};
39+
enum class EntryType {unknown, separator, groupTitle, groupTitleSmall, analysis};
4040
Q_ENUM(EntryType);
4141

4242
EntryBase(EntryType entryType);
@@ -108,8 +108,9 @@ public: \
108108
{}\
109109
}
110110

111-
MAKE_ENTRY_CLASS(Separator, separator);
112-
MAKE_ENTRY_CLASS(AnalysisItem, analysis);
113-
MAKE_ENTRY_CLASS(GroupTitle, groupTitle);
111+
MAKE_ENTRY_CLASS(Separator, separator);
112+
MAKE_ENTRY_CLASS(AnalysisItem, analysis);
113+
MAKE_ENTRY_CLASS(GroupTitle, groupTitle);
114+
MAKE_ENTRY_CLASS(GroupTitleSmall, groupTitleSmall);
114115
}
115116
#endif // ENTRYBASE_H

Desktop/modules/dynamicmodules.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ void DynamicModules::registerQMLTypes()
902902
qmlRegisterType<Modules::AnalysisItem> ("JASP.Module", 1, 0, "Analysis" );
903903
qmlRegisterType<Modules::Separator> ("JASP.Module", 1, 0, "Separator" );
904904
qmlRegisterType<Modules::GroupTitle> ("JASP.Module", 1, 0, "GroupTitle" );
905+
qmlRegisterType<Modules::GroupTitleSmall> ("JASP.Module", 1, 0, "GroupTitleSmall" );
905906
qmlRegisterType<Modules::Upgrades> ("JASP.Module", 1, 0, "Upgrades" );
906907
qmlRegisterType<Modules::Upgrade> ("JASP.Module", 1, 0, "Upgrade" );
907908
qmlRegisterType<Modules::ChangeJS> ("JASP.Module", 1, 0, "ChangeJS" );

Modules/jaspTestModule

QMLComponents/jasptheme.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,3 +1331,16 @@ void JaspTheme::setColumnTypeScaleHovered(float newColumnTypeScaleHovered)
13311331
_columnTypeScaleHovered = newColumnTypeScaleHovered;
13321332
emit columnTypeScaleHoveredChanged();
13331333
}
1334+
1335+
QFont JaspTheme::fontGroupTitleSmall() const
1336+
{
1337+
return _fontGroupTitleSmall;
1338+
}
1339+
1340+
void JaspTheme::setFontGroupTitleSmall(const QFont &newFontGroupTitleSmall)
1341+
{
1342+
if (_fontGroupTitleSmall == newFontGroupTitleSmall)
1343+
return;
1344+
_fontGroupTitleSmall = newFontGroupTitleSmall;
1345+
emit fontGroupTitleSmallChanged();
1346+
}

QMLComponents/jasptheme.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ class JaspTheme : public QQuickItem
167167
Q_PROPERTY(QFont fontLabel READ fontLabel WRITE setFontLabel NOTIFY fontLabelChanged )
168168
Q_PROPERTY(QFont fontRibbon READ fontRibbon WRITE setFontRibbon NOTIFY fontRibbonChanged )
169169
Q_PROPERTY(QFont fontGroupTitle READ fontGroupTitle WRITE setFontGroupTitle NOTIFY fontGroupTitleChanged )
170+
Q_PROPERTY(QFont fontGroupTitleSmall READ fontGroupTitleSmall WRITE setFontGroupTitleSmall NOTIFY fontGroupTitleSmallChanged )
170171
Q_PROPERTY(QFont fontPrefOptionsGroupTitle READ fontPrefOptionsGroupTitle WRITE setFontPrefOptionsGroupTitle NOTIFY fontPrefOptionsGroupTitleChanged )
171172
Q_PROPERTY(QFont fontALTNavTag READ fontALTNavTag WRITE setFontALTNavTag NOTIFY fontALTNavTagChanged )
172173

@@ -327,6 +328,9 @@ class JaspTheme : public QQuickItem
327328
float columnTypeScaleHovered() const;
328329
void setColumnTypeScaleHovered(float newColumnTypeScaleHovered);
329330

331+
QFont fontGroupTitleSmall() const;
332+
void setFontGroupTitleSmall(const QFont &newFontGroupTitleSmall);
333+
330334
signals:
331335
void currentThemeReady(JaspTheme * newTheme);
332336
void uiScaleChanged(float uiScale);
@@ -464,6 +468,8 @@ class JaspTheme : public QQuickItem
464468

465469
void columnTypeScaleHoveredChanged();
466470

471+
void fontGroupTitleSmallChanged();
472+
467473
public slots:
468474
void setRibbonScaleHovered(float ribbonScaleHovered);
469475
void setWhite(QColor white);
@@ -738,6 +744,7 @@ private slots:
738744
_fontRCode,
739745
_fontCode,
740746
_fontGroupTitle,
747+
_fontGroupTitleSmall,
741748
_fontPrefOptionsGroupTitle,
742749
_fontALTNavTag;
743750

0 commit comments

Comments
 (0)