summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <[email protected]>2015-03-25 00:46:02 +0300
committerJasem Mutlaq <[email protected]>2015-03-25 00:46:02 +0300
commitdb3e3fd683e0e9cc2ee46cd23f237ae283b79014 (patch)
tree3dc4a40faf46ae8b21fc9c7e67ca2c8212856c6a
parent009c57d6633eb685da1832b92798cff4b2726476 (diff)
Better representation of Read Only switches in the INDI GUI
-rw-r--r--kstars/indi/indielement.cpp20
-rw-r--r--kstars/indi/indiproperty.cpp21
-rw-r--r--kstars/indi/indiproperty.h1
3 files changed, 40 insertions, 2 deletions
diff --git a/kstars/indi/indielement.cpp b/kstars/indi/indielement.cpp
index 24b3690..baac413 100644
--- a/kstars/indi/indielement.cpp
+++ b/kstars/indi/indielement.cpp
@@ -113,6 +113,9 @@ void INDI_E::buildSwitch(QButtonGroup* groupB, ISwitch *sw)
push_w->show();
+ if (sw->svp->p == IP_RO)
+ push_w->setEnabled(sw->s == ISS_ON);
+
break;
case PG_RADIO:
@@ -125,6 +128,9 @@ void INDI_E::buildSwitch(QButtonGroup* groupB, ISwitch *sw)
check_w->show();
+ if (sw->svp->p == IP_RO)
+ check_w->setEnabled(sw->s == ISS_ON);
+
break;
default:
@@ -224,6 +230,9 @@ void INDI_E::syncSwitch()
buttonFont = push_w->font();
buttonFont.setBold(true);
push_w->setFont(buttonFont);
+
+ if (sp->svp->p == IP_RO)
+ push_w->setEnabled(true);
}
else
{
@@ -232,14 +241,25 @@ void INDI_E::syncSwitch()
buttonFont = push_w->font();
buttonFont.setBold(false);
push_w->setFont(buttonFont);
+
+ if (sp->svp->p == IP_RO)
+ push_w->setEnabled(false);
}
break;
case PG_RADIO:
if (sp->s == ISS_ON)
+ {
check_w->setChecked(true);
+ if (sp->svp->p == IP_RO)
+ check_w->setEnabled(true);
+ }
else
+ {
check_w->setChecked(false);
+ if (sp->svp->p == IP_RO)
+ check_w->setEnabled(false);
+ }
break;
default:
diff --git a/kstars/indi/indiproperty.cpp b/kstars/indi/indiproperty.cpp
index bb13bb8..bb774fb 100644
--- a/kstars/indi/indiproperty.cpp
+++ b/kstars/indi/indiproperty.cpp
@@ -207,7 +207,8 @@ void INDI_P::buildSwitchGUI()
else if (guiType == PG_RADIO)
groupB->setExclusive(false);
- QObject::connect(groupB, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(newSwitch(QAbstractButton *)));
+ if (svp->p != IP_RO)
+ QObject::connect(groupB, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(newSwitch(QAbstractButton *)));
for (int i=0; i < svp->nsp; i++)
{
@@ -382,6 +383,19 @@ void INDI_P::newSwitch(QAbstractButton * button)
}
+void INDI_P::resetSwitch()
+{
+ ISwitchVectorProperty *svp = dataProp->getSwitch();
+
+ if (svp == NULL)
+ return;
+
+ if (menuC)
+ {
+ menuC->setCurrentIndex(IUFindOnSwitchIndex(svp));
+ }
+}
+
void INDI_P::newSwitch(int index)
{
ISwitchVectorProperty *svp = dataProp->getSwitch();
@@ -509,7 +523,10 @@ void INDI_P::buildMenuGUI()
menuC = new QComboBox(pg->getContainer());
- QObject::connect(menuC, SIGNAL(activated(int)), this, SLOT(newSwitch(int)));
+ if (svp->p == IP_RO)
+ QObject::connect(menuC, SIGNAL(activated(int)), this, SLOT(resetSwitch()));
+ else
+ QObject::connect(menuC, SIGNAL(activated(int)), this, SLOT(newSwitch(int)));
for (int i=0; i < svp->nsp; i++)
{
diff --git a/kstars/indi/indiproperty.h b/kstars/indi/indiproperty.h
index f6291ab..65ee814 100644
--- a/kstars/indi/indiproperty.h
+++ b/kstars/indi/indiproperty.h
@@ -113,6 +113,7 @@ public slots:
void newSwitch(QAbstractButton * button);
void newSwitch(int index);
void newSwitch(const QString & name);
+ void resetSwitch();
void sendBlob();