Skip to content

Commit

Permalink
Adds a scale for the height of the ribbonbar
Browse files Browse the repository at this point in the history
Implements jasp-stats/jasp-issues#2952
See the interface preferences
  • Loading branch information
JorisGoosen committed Nov 27, 2024
1 parent aae799b commit dbbf57d
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 16 deletions.
20 changes: 18 additions & 2 deletions Desktop/components/JASP/Widgets/FileMenu/PrefsUI.qml
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,25 @@ ScrollView
decimals: 0
text: qsTr("Zoom (%): ")
toolTip: qsTr("Increase or decrease the size of the interface elements (text, buttons, etc).")
KeyNavigation.tab: ribbonBarSpinBox

widthLabel: Math.max(uiScaleSpinBox.implicitWidthLabel,Math.max(ribbonBarSpinBox.implicitWidthLabel, uiMaxFlickVelocity.implicitWidthLabel))
}

SpinBox
{
id: ribbonBarSpinBox
value: Math.round(preferencesModel.ribbonBarHeightScale * 100)
onValueChanged: if(value!= "") preferencesModel.ribbonBarHeightScale = value / 100
from: 10
to: 500
stepSize: 10
decimals: 0
text: qsTr("Ribbon scale (%): ")
toolTip: qsTr("Set the scale of height of the ribbon.")
KeyNavigation.tab: uiMaxFlickVelocity

widthLabel: Math.max(uiScaleSpinBox.implicitWidthLabel, uiMaxFlickVelocity.implicitWidthLabel)
widthLabel: uiScaleSpinBox.widthLabel
}

SpinBox
Expand All @@ -294,7 +310,7 @@ ScrollView
checked: preferencesModel.safeGraphics
onCheckedChanged: preferencesModel.safeGraphics = checked
toolTip: qsTr("Switches to a \"safer\" mode for graphics aka software rendering.\nIt will make your interface slower but if you have some problems (weird glitches, cannot see results or anything even) might fix them.\nAnalyses will still be just as fast though.")

KeyNavigation.tab: disableAnimations

}
Expand Down
20 changes: 11 additions & 9 deletions Desktop/components/JASP/Widgets/Ribbon/RibbonButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import QtQuick.Controls 2.4
import JASP 1.0
import JASP.Widgets 1.0

Rectangle
Item
{
id : ribbonButton
width : separator ? 2 * jaspTheme.ribbonButtonPadding : (innerText.width > _imgIndWidth ? innerText.width : _imgIndWidth) + (2 * jaspTheme.ribbonButtonPadding) // + 2*tbutton.width
height : jaspTheme.ribbonButtonHeight
color : separator || !showPressed ? "transparent" : jaspTheme.grayLighter
width : implicitWidth * preferencesModel.ribbonBarHeightScale
implicitWidth : separator ? 2 * jaspTheme.ribbonButtonPadding : (innerText.width > _imgIndWidth ? innerText.width : _imgIndWidth) + (2 * jaspTheme.ribbonButtonPadding) // + 2*tbutton.width
height : jaspTheme.ribbonButtonHeight * preferencesModel.ribbonBarHeightScale

z : 1
objectName : "ribbonButton"

Expand Down Expand Up @@ -210,14 +211,15 @@ Rectangle
}
}

Item
Rectangle
{
anchors.centerIn : parent
width : parent.width
height : parent.height
scale : mice.containsMouse && !ribbonButton.showPressed ? jaspTheme.ribbonScaleHovered : 1
width : parent.implicitWidth
height : jaspTheme.ribbonButtonHeight
scale : preferencesModel.ribbonBarHeightScale * (mice.containsMouse && !ribbonButton.showPressed ? jaspTheme.ribbonScaleHovered : 1)
visible : !separator

color : separator || !showPressed ? "transparent" : jaspTheme.grayLighter

Image
{
id: backgroundImage
Expand Down
3 changes: 2 additions & 1 deletion Desktop/components/JASP/Widgets/Ribbon/Ribbons.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Item
id: jaspRibbons
objectName: "jaspRibbon"
width: 500
height: jaspTheme.ribbonButtonHeight
height: jaspTheme.ribbonButtonHeight * preferencesModel.ribbonBarHeightScale

onActiveFocusChanged: buttonList.focus = true;

Expand Down Expand Up @@ -186,6 +186,7 @@ Item
visible: model.ribbonButton
ready: model.ribbonButton && (model.ribbonButton.ready || model.ribbonButton.special || model.ribbonButton.error)
separator: model.ribbonButton && model.ribbonButton.separator


ALTNavigation.enabled: !separator
// ALTNavigation.y: 10
Expand Down
6 changes: 4 additions & 2 deletions Desktop/gui/preferencesmodel.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ PreferencesModel::PreferencesModel(QObject *parent) :
connect(this, &PreferencesModel::safeGraphicsChanged, this, &PreferencesModel::animationsOnChanged ); // So animationsOn *might* not be changed, but it doesnt matter
connect(this, &PreferencesModel::disableAnimationsChanged, this, &PreferencesModel::animationsOnChanged );
connect(this, &PreferencesModel::dataLabelNAChanged, this, &PreferencesModel::dataLabelNAChangedSlot );

connect(this, &PreferencesModel::guiQtTextRenderChanged, this, &PreferencesModel::onGuiQtTextRenderChanged, Qt::QueuedConnection);

connect(LanguageModel::lang(), &LanguageModel::currentLanguageChanged, this, &PreferencesModel::languageCodeChanged );

_loadDatabaseFont();
Expand Down Expand Up @@ -113,13 +112,15 @@ void PreferencesModel::browseDeveloperLibPathFolder()
#define GET_PREF_FUNC_INT(NAME, SETTING) GET_PREF_FUNC(int, NAME, SETTING, toInt())
#define GET_PREF_FUNC_STR(NAME, SETTING) GET_PREF_FUNC(QString, NAME, SETTING, toString())
#define GET_PREF_FUNC_DBL(NAME, SETTING) GET_PREF_FUNC(double, NAME, SETTING, toDouble())
#define GET_PREF_FUNC_FLT(NAME, SETTING) GET_PREF_FUNC(float, NAME, SETTING, toFloat())
#define GET_PREF_FUNC_WHT(NAME, SETTING) GET_PREF_FUNC(bool, NAME, SETTING, toString() == "white")


GET_PREF_FUNC_BOOL( fixedDecimals, Settings::FIXED_DECIMALS )
GET_PREF_FUNC_INT( numDecimals, Settings::NUM_DECIMALS )
GET_PREF_FUNC_BOOL( exactPValues, Settings::EXACT_PVALUES )
GET_PREF_FUNC_BOOL( normalizedNotation, Settings::NORMALIZED_NOTATION )
GET_PREF_FUNC_FLT( ribbonBarHeightScale, Settings::RIBBON_BAR_HEIGHT_SCALE )
GET_PREF_FUNC_BOOL( useDefaultEditor, Settings::USE_DEFAULT_SPREADSHEET_EDITOR )
GET_PREF_FUNC_STR( customEditor, Settings::SPREADSHEET_EDITOR_NAME )
GET_PREF_FUNC_STR( developerFolder, Settings::DEVELOPER_FOLDER )
Expand Down Expand Up @@ -307,6 +308,7 @@ SET_PREF_FUNCTION( bool, setUseDefaultPPI, useDefaultPPI, useDefaultPPI
SET_PREF_FUNCTION( bool, setDeveloperMode, developerMode, developerModeChanged, Settings::DEVELOPER_MODE )
SET_PREF_FUNCTION( QString, setDeveloperFolder, developerFolder, developerFolderChanged, Settings::DEVELOPER_FOLDER )
SET_PREF_FUNCTION( int, setCustomPPI, customPPI, customPPIChanged, Settings::PPI_CUSTOM_VALUE )
SET_PREF_FUNCTION( float, setRibbonBarHeightScale, ribbonBarHeightScale, ribbonBarHeightScaleChanged, Settings::RIBBON_BAR_HEIGHT_SCALE )
SET_PREF_FUNCTION( bool, setLogToFile, logToFile, logToFileChanged, Settings::LOG_TO_FILE )
SET_PREF_FUNCTION( int, setLogFilesMax, logFilesMax, logFilesMaxChanged, Settings::LOG_FILES_MAX )
SET_PREF_FUNCTION_EMIT_NO_ARG( int, setMaxFlickVelocity, maxFlickVelocity, maxFlickVelocityChanged, Settings::QML_MAX_FLICK_VELOCITY )
Expand Down
3 changes: 3 additions & 0 deletions Desktop/gui/preferencesmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class PreferencesModel : public PreferencesModelBase
Q_PROPERTY(bool whiteBackground READ whiteBackground WRITE setWhiteBackground NOTIFY whiteBackgroundChanged )
Q_PROPERTY(QString plotBackground READ plotBackground WRITE setPlotBackground NOTIFY plotBackgroundChanged )
Q_PROPERTY(double uiScale READ uiScale WRITE setUiScale NOTIFY uiScaleChanged )
Q_PROPERTY(float ribbonBarHeightScale READ ribbonBarHeightScale WRITE setRibbonBarHeightScale NOTIFY ribbonBarHeightScaleChanged )
Q_PROPERTY(int defaultPPI READ defaultPPI WRITE setDefaultPPI NOTIFY defaultPPIChanged )
Q_PROPERTY(bool developerMode READ developerMode WRITE setDeveloperMode NOTIFY developerModeChanged )
Q_PROPERTY(QString developerFolder READ developerFolder WRITE setDeveloperFolder NOTIFY developerFolderChanged )
Expand Down Expand Up @@ -99,6 +100,7 @@ class PreferencesModel : public PreferencesModelBase
bool whiteBackground() const;
QString plotBackground() const;
double uiScale() override;
float ribbonBarHeightScale() const override;
QString customEditor() const;
QString developerFolder() const;
QString fixedDecimalsForJS() const;
Expand Down Expand Up @@ -167,6 +169,7 @@ public slots:
void setNumDecimals( int numDecimals);
void setExactPValues( bool exactPValues);
void setNormalizedNotation( bool normalizedNotation);
void setRibbonBarHeightScale( float ribbonBarHeightScale);
void setCustomEditor( QString customEditor);
void setFixedDecimals( bool fixedDecimals);
void setUseDefaultPPI( bool useDefaultPPI);
Expand Down
3 changes: 2 additions & 1 deletion Desktop/utilities/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ const Settings::Setting Settings::Values[] = {
{"pdfPageSize", int(pdfPageSize::A4) },
{"directLibpathEnabled", true },
{"directLibpathFolder", "" },
{"directDevModName", "" }
{"directDevModName", "" },
{"ribbonBarHeightScale", 1.0 }

};

Expand Down
3 changes: 2 additions & 1 deletion Desktop/utilities/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class Settings {
PDF_PAGESIZE,
DIRECT_LIBPATH_ENABLED,
DIRECT_LIBPATH_FOLDER,
DIRECT_DEVMOD_NAME
DIRECT_DEVMOD_NAME,
RIBBON_BAR_HEIGHT_SCALE
};

static QVariant value(Settings::Type key);
Expand Down
2 changes: 2 additions & 0 deletions QMLComponents/preferencesmodelbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class PreferencesModelBase : public QObject
virtual bool showRSyntax() const { return false; }
virtual bool showAllROptions() const { return false; }
virtual int maxScaleLevels() const { return 100; }
virtual float ribbonBarHeightScale() const { return 1.0; }

static PreferencesModelBase* preferences();

Expand All @@ -25,6 +26,7 @@ public slots:
virtual void setShowAllROptions(bool showAllROptions) {}

signals:
void ribbonBarHeightScaleChanged(float height);
void uiScaleChanged();
void maxFlickVelocityChanged();
void currentJaspThemeChanged();
Expand Down

0 comments on commit dbbf57d

Please sign in to comment.