Skip to content

Commit

Permalink
Merge pull request #119 from MycroftAI/feat/skill_view_animations_config
Browse files Browse the repository at this point in the history
add config options to enable/disable skill view animations
  • Loading branch information
krisgesling authored Aug 22, 2022
2 parents 22652c3 + 1921b92 commit 53fb4a1
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 6 deletions.
60 changes: 60 additions & 0 deletions import/globalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,63 @@ void GlobalSettings::setUseHivemindProtocol(bool useHivemindProtocol)
m_settings.setValue(QStringLiteral("useHivemindProtocol"), useHivemindProtocol);
emit useHivemindProtocolChanged();
}

bool GlobalSettings::useEntryNameSpaceAnimation() const
{
return m_settings.value(QStringLiteral("useEntryNameSpaceAnimation"), true).toBool();
}

void GlobalSettings::setUseEntryNameSpaceAnimation(bool useEntryNameSpaceAnimation)
{
if (GlobalSettings::useEntryNameSpaceAnimation() == useEntryNameSpaceAnimation) {
return;
}

m_settings.setValue(QStringLiteral("useEntryNameSpaceAnimation"), useEntryNameSpaceAnimation);
emit useEntryNameSpaceAnimationChanged();
}

bool GlobalSettings::useExitNameSpaceAnimation() const
{
return m_settings.value(QStringLiteral("useExitNameSpaceAnimation"), true).toBool();
}

void GlobalSettings::setUseExitNameSpaceAnimation(bool useExitNameSpaceAnimation)
{
if (GlobalSettings::useExitNameSpaceAnimation() == useExitNameSpaceAnimation) {
return;
}

m_settings.setValue(QStringLiteral("useExitNameSpaceAnimation"), useExitNameSpaceAnimation);
emit useExitNameSpaceAnimationChanged();
}

bool GlobalSettings::useFocusAnimation() const
{
return m_settings.value(QStringLiteral("useFocusAnimation"), true).toBool();
}

void GlobalSettings::setUseFocusAnimation(bool useFocusAnimation)
{
if (GlobalSettings::useFocusAnimation() == useFocusAnimation) {
return;
}

m_settings.setValue(QStringLiteral("useFocusAnimation"), useFocusAnimation);
emit useFocusAnimationChanged();
}

bool GlobalSettings::useDelegateAnimation() const
{
return m_settings.value(QStringLiteral("useDelegateAnimation"), true).toBool();
}

void GlobalSettings::setUseDelegateAnimation(bool useDelegateAnimation)
{
if (GlobalSettings::useDelegateAnimation() == useDelegateAnimation) {
return;
}

m_settings.setValue(QStringLiteral("useDelegateAnimation"), useDelegateAnimation);
emit useDelegateAnimationChanged();
}
16 changes: 16 additions & 0 deletions import/globalsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class GlobalSettings : public QObject
Q_PROPERTY(bool displayRemoteConfig READ displayRemoteConfig WRITE setDisplayRemoteConfig NOTIFY displayRemoteConfigChanged)
Q_PROPERTY(bool usePTTClient READ usePTTClient WRITE setUsePTTClient NOTIFY usePTTClient)
Q_PROPERTY(bool useHivemindProtocol READ useHivemindProtocol WRITE setUseHivemindProtocol NOTIFY useHivemindProtocolChanged)
Q_PROPERTY(bool useEntryNameSpaceAnimation READ useEntryNameSpaceAnimation WRITE setUseEntryNameSpaceAnimation NOTIFY useEntryNameSpaceAnimationChanged)
Q_PROPERTY(bool useExitNameSpaceAnimation READ useExitNameSpaceAnimation WRITE setUseExitNameSpaceAnimation NOTIFY useExitNameSpaceAnimationChanged)
Q_PROPERTY(bool useFocusAnimation READ useFocusAnimation WRITE setUseFocusAnimation NOTIFY useFocusAnimationChanged)
Q_PROPERTY(bool useDelegateAnimation READ useDelegateAnimation WRITE setUseDelegateAnimation NOTIFY useDelegateAnimationChanged)

public:
explicit GlobalSettings(QObject *parent=0);
Expand All @@ -55,6 +59,14 @@ class GlobalSettings : public QObject
void setUsePTTClient(bool usePttClient);
bool useHivemindProtocol() const;
void setUseHivemindProtocol(bool useHivemindProtocol);
bool useEntryNameSpaceAnimation() const;
void setUseEntryNameSpaceAnimation(bool useEntryNameSpaceAnimation);
bool useExitNameSpaceAnimation() const;
void setUseExitNameSpaceAnimation(bool useExitNameSpaceAnimation);
bool useFocusAnimation() const;
void setUseFocusAnimation(bool useFocusAnimation);
bool useDelegateAnimation() const;
void setUseDelegateAnimation(bool useDelegateAnimation);

Q_SIGNALS:
void webSocketChanged();
Expand All @@ -63,6 +75,10 @@ class GlobalSettings : public QObject
void displayRemoteConfigChanged();
void usePTTClientChanged();
void useHivemindProtocolChanged();
void useEntryNameSpaceAnimationChanged();
void useExitNameSpaceAnimationChanged();
void useFocusAnimationChanged();
void useDelegateAnimationChanged();

private:
QSettings m_settings;
Expand Down
24 changes: 18 additions & 6 deletions import/qml/SkillView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,19 @@ Mycroft.AbstractSkillView {

onOpenChanged: {
if (open) {
closeAnimation.running = false;
openAnimation.restart();
if(Mycroft.GlobalSettings.useExitNameSpaceAnimation) {
closeAnimation.running = false;
}
if(Mycroft.GlobalSettings.useEntryNameSpaceAnimation) {
openAnimation.restart();
}
} else {
openAnimation.running = false;
closeAnimation.restart();
if(Mycroft.GlobalSettings.useEntryNameSpaceAnimation) {
openAnimation.running = false;
}
if(Mycroft.GlobalSettings.useExitNameSpaceAnimation) {
closeAnimation.restart();
}
}
}

Expand Down Expand Up @@ -183,7 +191,9 @@ Mycroft.AbstractSkillView {
activeSkillsRepeater.currentDelegate = delegate;
if (root.open === false) {
root.open = true;
enterAnim.restart();
if(Mycroft.GlobalSettings.useDelegateAnimation) {
enterAnim.restart();
}
}
}

Expand Down Expand Up @@ -252,7 +262,9 @@ Mycroft.AbstractSkillView {
if (model.delegateUi.focus) {
delegatesView.currentIndex = index;
if (root.width >= root.switchWidth) {
focusAnim.restart();
if(Mycroft.GlobalSettings.useFocusAnimation) {
focusAnim.restart();
}
}
}
}
Expand Down

0 comments on commit 53fb4a1

Please sign in to comment.