Skip to content

Commit

Permalink
Update utils & UI components
Browse files Browse the repository at this point in the history
  • Loading branch information
emericg committed Sep 22, 2022
1 parent d28e7c3 commit 666b2cb
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 31 deletions.
26 changes: 14 additions & 12 deletions qml/components_generic/RoundButtonIcon.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Item {
implicitWidth: Theme.componentHeight
implicitHeight: Theme.componentHeight

property url source
property int sourceSize: UtilsNumber.alignTo(height * 0.666, 2)

// actions
signal clicked()
signal pressed()
Expand All @@ -17,13 +20,10 @@ Item {
property bool selected: false

// settings
property url source
property int sourceSize: UtilsNumber.alignTo(height * 0.666, 2)
property int rotation: 0
property string highlightMode: "circle" // available: border, circle, color, both (circle+color), off

property bool border: false
property bool background: false
property int rotation: 0
property string highlightMode: "circle" // available: border, circle, color, both (circle+color), off

// colors
property string iconColor: Theme.colorIcon
Expand Down Expand Up @@ -62,13 +62,6 @@ Item {
visible: (control.highlightMode === "circle" || control.highlightMode === "both" || control.background)
color: control.backgroundColor

border.width: {
if (control.border || ((mouseArea.containsMouse || control.selected) && control.highlightMode === "border"))
return Theme.componentBorderWidth
return 0
}
border.color: control.borderColor

opacity: {
if (mouseArea.containsMouse) {
return (control.highlightMode === "circle" || control.highlightMode === "both" || control.background) ? 1 : 0.75
Expand All @@ -78,6 +71,15 @@ Item {
}
Behavior on opacity { NumberAnimation { duration: 333 } }
}
Rectangle { // border
anchors.fill: control
radius: width

visible: control.border
color: "transparent"
border.width: Theme.componentBorderWidth
border.color: control.borderColor
}

////////////////////////////////////////////////////////////////////////////

Expand Down
24 changes: 13 additions & 11 deletions qml/components_generic/RoundButtonText.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Item {
implicitWidth: Theme.componentHeight
implicitHeight: Theme.componentHeight

property string text
property int textSize: Math.round(width * 0.333)

// actions
signal clicked()
signal pressed()
Expand All @@ -17,12 +20,9 @@ Item {
property bool selected: false

// settings
property string text
property int textSize: Math.round(width * 0.33)
property string highlightMode: "circle" // available: border, circle, color, both (circle+color), off

property bool border: false
property bool background: false
property string highlightMode: "circle" // available: border, circle, color, both (circle+color), off

// colors
property string textColor: Theme.colorText
Expand Down Expand Up @@ -57,13 +57,6 @@ Item {
visible: (control.highlightMode === "circle" || control.highlightMode === "both" || control.background)
color: control.backgroundColor

border.width: {
if (control.border || ((mouseArea.containsMouse || control.selected) && control.highlightMode === "border"))
return Theme.componentBorderWidth
return 0
}
border.color: control.borderColor

opacity: {
if (mouseArea.containsMouse) {
return (control.highlightMode === "circle" || control.highlightMode === "both" || control.background) ? 1 : 0.75
Expand All @@ -73,6 +66,15 @@ Item {
}
Behavior on opacity { NumberAnimation { duration: 333 } }
}
Rectangle { // border
anchors.fill: control
radius: width

visible: control.border
color: "transparent"
border.width: Theme.componentBorderWidth
border.color: control.borderColor
}

////////////////////////////////////////////////////////////////////////////

Expand Down
4 changes: 1 addition & 3 deletions qml/components_themed/ComboBoxThemed.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ T.ComboBox {
rightPadding: 16

font.pixelSize: Theme.fontSizeComponent
opacity: enabled ? 1.0 : 0.4

////////////////////////////////////////////////////////////////////////////

Expand All @@ -26,7 +27,6 @@ T.ComboBox {

radius: Theme.componentRadius
color: control.down ? Theme.colorComponentDown : Theme.colorComponent
opacity: enabled ? 1.0 : 0.33
border.width: 1
border.color: Theme.colorComponentBorder
}
Expand All @@ -42,7 +42,6 @@ T.ComboBox {
verticalAlignment: Text.AlignVCenter

color: Theme.colorComponentContent
opacity: enabled ? 1.0 : 0.33
}

////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -83,7 +82,6 @@ T.ComboBox {
implicitHeight: Theme.componentHeight

radius: Theme.componentRadius
opacity: enabled ? 1 : 0.3
color: highlighted ? "#F6F6F6" : "white"
}

Expand Down
6 changes: 2 additions & 4 deletions qml/components_themed/SpinBoxThemed.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ T.SpinBox {

value: 50
editable: true

font.pixelSize: Theme.fontSizeComponent
opacity: enabled ? 1 : 0.4

property string legend

Expand All @@ -27,7 +29,6 @@ T.SpinBox {

radius: Theme.componentRadius
color: Theme.colorComponentBackground
opacity: enabled ? 1 : 0.33

Rectangle {
width: control.height
Expand Down Expand Up @@ -76,7 +77,6 @@ T.SpinBox {
anchors.verticalCenter: parent.verticalCenter

color: Theme.colorComponentText
opacity: enabled ? 1.0 : 0.33
selectionColor: Theme.colorPrimary
selectedTextColor: "white"
selectByMouse: control.editable
Expand Down Expand Up @@ -132,7 +132,6 @@ T.SpinBox {
height: control.height
anchors.verticalCenter: control.verticalCenter
x: control.mirrored ? 0 : control.width - width
opacity: enabled ? 1.0 : 0.33

Rectangle {
anchors.centerIn: parent
Expand All @@ -158,7 +157,6 @@ T.SpinBox {
height: control.height
anchors.verticalCenter: control.verticalCenter
x: control.mirrored ? control.width - width : 0
opacity: enabled ? 1.0 : 0.33

Rectangle {
anchors.centerIn: parent
Expand Down
24 changes: 24 additions & 0 deletions src/thirdparty/AppUtils/utils_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,30 @@ bool UtilsApp::getMobilePhoneStatePermission()

/* ************************************************************************** */

bool UtilsApp::checkMobileCameraPermission()
{
#if defined(Q_OS_ANDROID)
return UtilsAndroid::checkPermission_camera();
#elif defined(Q_OS_IOS)
return false;
#else
return true;
#endif
}

bool UtilsApp::getMobileCameraPermission()
{
#if defined(Q_OS_ANDROID)
return UtilsAndroid::getPermission_camera();
#elif defined(Q_OS_IOS)
return false;
#else
return true;
#endif
}

/* ************************************************************************** */

bool UtilsApp::isMobileGpsEnabled()
{
#if defined(Q_OS_ANDROID)
Expand Down
3 changes: 3 additions & 0 deletions src/thirdparty/AppUtils/utils_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ class UtilsApp : public QObject
static Q_INVOKABLE bool checkMobilePhoneStatePermission();
static Q_INVOKABLE bool getMobilePhoneStatePermission();

static Q_INVOKABLE bool checkMobileCameraPermission();
static Q_INVOKABLE bool getMobileCameraPermission();

static Q_INVOKABLE bool isMobileGpsEnabled();

static Q_INVOKABLE QString getMobileDeviceModel();
Expand Down
2 changes: 1 addition & 1 deletion src/thirdparty/AppUtils/utils_os_android_qt5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

int UtilsAndroid::getSdkVersion()
{
return QtAndroid::sdkVersion();
return QtAndroid::androidSdkVersion();
}

/* ************************************************************************** */
Expand Down

0 comments on commit 666b2cb

Please sign in to comment.