Skip to content

Commit

Permalink
improve busy indicator, and joy
Browse files Browse the repository at this point in the history
  • Loading branch information
Consti10 committed Feb 6, 2024
1 parent b42493b commit 949a960
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 26 deletions.
14 changes: 14 additions & 0 deletions app/util/qopenhd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ void QOpenHD::show_toast(QString message,bool long_toast)
emit signal_toast_add(message,long_toast);
}

void QOpenHD::set_busy_for_milliseconds(int milliseconds,QString reason)
{
set_is_busy(true);
set_busy_reason(reason);
const int timeout_ms = milliseconds;
QTimer::singleShot(timeout_ms, this, &QOpenHD::handle_busy_timeout);
}


void QOpenHD::handle_toast_timeout()
{
Expand All @@ -357,6 +365,12 @@ void QOpenHD::handle_toast_timeout()
}
}

void QOpenHD::handle_busy_timeout()
{
set_is_busy(false);
set_busy_reason("");
}

void QOpenHD::do_not_call_toast_add(QString text,bool long_toast)
{
qDebug()<<"do_not_call_toast_add"<<text;
Expand Down
6 changes: 6 additions & 0 deletions app/util/qopenhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class QOpenHD : public QObject
//
Q_INVOKABLE void show_toast(QString message,bool long_toast=false);
L_RO_PROP(QString,version_string,set_version_string,"2.5.4-evo-alpha");
// Notify that something is going on for a specified amount of time
public:
Q_INVOKABLE void set_busy_for_milliseconds(int milliseconds,QString reason);
L_RO_PROP(bool,is_busy,set_is_busy,false);
L_RO_PROP(QString,busy_reason,set_busy_reason,"");
public:
L_RO_PROP(QString,toast_text,set_toast_text,"NONE");
L_RO_PROP(bool,toast_visible,set_toast_visible,false);
Expand All @@ -93,6 +98,7 @@ class QOpenHD : public QObject
};
std::list<ToastMessage> m_toast_message_queue;
void handle_toast_timeout();
void handle_busy_timeout();
public:
signals:
void signal_toast_add(QString text,bool long_toast);
Expand Down
20 changes: 2 additions & 18 deletions qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -152,25 +152,9 @@ ApplicationWindow {
_qopenhd.disable_service_and_quit()
}
}
BusyIndicator{
id: any_param_busy_indiscator
width: 96
height: 96
anchors.centerIn: parent
running: _airCameraSettingsModel.ui_is_busy || _airCameraSettingsModel2.ui_is_busy || _ohdSystemAirSettingsModel.ui_is_busy || _ohdSystemGroundSettings.ui_is_busy
//visible: _xParamUI.is_busy
}
Text{
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: any_param_busy_indiscator.bottom
text: "FETCHING PARAMETERS.."
visible: any_param_busy_indiscator.running
font.pixelSize: 15
font.family: settings.font_text
style: Text.Outline
styleColor: settings.color_glow
AnyParamBusyIndicator{
z: 10
}

/*Rectangle {
width: 800
height: 600
Expand Down
1 change: 1 addition & 0 deletions qml/qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -288,5 +288,6 @@
<file>ui/configpopup/quick/InfoElement.qml</file>
<file>ui/configpopup/quick/EditFrequencyElement.qml</file>
<file>ui/configpopup/quick/TriangleButton.qml</file>
<file>ui/AnyParamBusyIndicator.qml</file>
</qresource>
</RCC>
42 changes: 42 additions & 0 deletions qml/ui/AnyParamBusyIndicator.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Controls.Styles 1.4
import QtQuick.Controls.Material 2.12
import QtQuick.Layouts 1.0
import QtGraphicalEffects 1.12
import Qt.labs.settings 1.0

import OpenHD 1.0

Item{
width: parent.width
height: parent.height

BusyIndicator{
id: any_param_busy_indiscator
width: 96
height: 96
anchors.centerIn: parent
running: _airCameraSettingsModel.ui_is_busy || _airCameraSettingsModel2.ui_is_busy || _ohdSystemAirSettingsModel.ui_is_busy || _ohdSystemGroundSettings.ui_is_busy ||
_qopenhd.is_busy
//visible: _xParamUI.is_busy
}
Text{
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: any_param_busy_indiscator.bottom
text: {
if(_qopenhd.is_busy){
return _qopenhd.busy_reason;
}
return "FETCHING PARAMETERS.."
}
visible: any_param_busy_indiscator.running
font.pixelSize: 15
font.family: settings.font_text
style: Text.Outline
styleColor: settings.color_glow
}
}


8 changes: 0 additions & 8 deletions qml/ui/configpopup/openhd_settings/MavlinkParamPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,4 @@ Rectangle {
ChooseResolutionDialoque{
id: dialoque_choose_resolution
}

BusyIndicator{
width: 96
height: 96
anchors.centerIn: parent
running: m_instanceMavlinkSettingsModel.ui_is_busy
//visible: _xParamUI.is_busy
}
}
1 change: 1 addition & 0 deletions qml/ui/configpopup/quick/EditChannelWidthElement.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ BaseJoyEditElement{
_hudLogMessagesModel.add_message_warning("Cannot change BW:"+channel_width_mhz+"Mhz, AIR not alive");
return;
}
_qopenhd.set_busy_for_milliseconds(2000,"CHANGING BW");
_wbLinkSettingsHelper.change_param_air_channel_width_async(channel_width_mhz,true);
}

Expand Down
1 change: 1 addition & 0 deletions qml/ui/configpopup/quick/EditFrequencyElement.qml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ BaseJoyEditElement{
new_model_index-=1;
}
const new_frequency=frequencies_model.get(new_model_index).frequency
_qopenhd.set_busy_for_milliseconds(2000,"CHANGING FREQUENCY");
_wbLinkSettingsHelper.change_param_air_and_ground_frequency(new_frequency)
}

Expand Down
1 change: 1 addition & 0 deletions qml/ui/configpopup/quick/EditRateElement.qml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ BaseJoyEditElement{
}

function set_air_only_mcs(mcs_index){
_qopenhd.set_busy_for_milliseconds(2000,"CHANGING RATE");
_wbLinkSettingsHelper.set_param_air_only_mcs_async(mcs_index)
}

Expand Down
1 change: 1 addition & 0 deletions qml/ui/configpopup/quick/EditResolutionElement.qml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ BaseJoyEditElement{
new_model_index-=1;
}
var new_resolution_string=resolutions_model.get(new_model_index).title;
_qopenhd.set_busy_for_milliseconds(1000,"CHANGING RESOLUTION");
_wbLinkSettingsHelper.set_param_video_resolution_framerate_async(true,new_resolution_string)
}

Expand Down
1 change: 1 addition & 0 deletions qml/ui/widgets/MessageHUD.qml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ BaseWidget {
// We do not want this widget to be dragable / touchable, it needs to be "hidden" otherwise
// clicking the secondary video becomes impossible
disable_dragging : true
z: 20

Item {
id: widgetInner
Expand Down

0 comments on commit 949a960

Please sign in to comment.