1
0
Fork 0

toggle'able hold-last-look

This commit is contained in:
Kevin Matz 2022-12-10 13:20:39 -05:00
parent 986dc9b89e
commit 0b02bc3c14
8 changed files with 80 additions and 13 deletions

View File

@ -117,6 +117,13 @@ MultiverseWindow::MultiverseWindow(QWidget *parent, QSacnNode *node)
auto selected = ui->multiverseView->currentIndex();
openUniverseEditor(selected);
});
connect(ui->actionUniverseHoldLastLook, &QAction::toggled,
this, [this](bool state) {
auto selected = ui->multiverseView->currentIndex();
auto data = selected.data(Qt::EditRole);
auto univ = data.value<QSacnUniverse*>();
univ->setHoldLastLook(state);
});
connect(ui->actionAbout, &QAction::triggered,
this, [this](){
QString title = tr("About") % " " % qAppName();
@ -179,18 +186,24 @@ void MultiverseWindow::selectionChanged(const QModelIndex &current,
ui->actionTerminate->setEnabled(false);
ui->actionUnsubscribe->setEnabled(false);
ui->actionInspect->setEnabled(false);
ui->actionUniverseHoldLastLook->setEnabled(false);
auto data = current.data(Qt::EditRole);
// Data universes:
if (data.metaType().id() == qMetaTypeId<QSacnUniverse*>())
{
ui->actionInspect->setEnabled(true);
auto univ = data.value<QSacnUniverse*>();
ui->actionInspect->setEnabled(true);
ui->actionUniverseHoldLastLook->setChecked(univ->getHoldLastLook());
if (univ->isEditable())
ui->actionTerminate->setEnabled(true);
else
{
ui->actionUnsubscribe->setEnabled(true);
if (univ->hasSources())
ui->actionUniverseHoldLastLook->setEnabled(true);
}
return;
}
}

View File

@ -265,12 +265,6 @@
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Hold Last Look</string>
</property>

View File

@ -115,6 +115,16 @@ bool QSacnUniverse::isEditable() const
}
/**
* @brief QSacnUniverse::hasSources
* @return
*/
bool QSacnUniverse::hasSources() const
{
return universe_ ? universe_->hasSources() : false;
}
/**
* @brief QSacnUniverse::sources
* @return
@ -160,6 +170,30 @@ uint16_t QSacnUniverse::activeSlots() const
}
/**
* @brief QSacnUniverse::getHoldLastLook
* @return
*/
bool QSacnUniverse::getHoldLastLook() const
{
return universe_ ? universe_->getHoldLastLook() : false;
}
/**
* @brief QSacnUniverse::setHoldLastLook
* @param state
*/
void QSacnUniverse::setHoldLastLook(bool state)
{
if (isEditable())
return;
if (universe_)
universe_->setHoldLastLook(state);
}
/**
* @brief QSacnUniverse::setOptions
* @param o

View File

@ -31,10 +31,13 @@ public:
uint8_t slot(const uint16_t) const;
uint16_t activeSlots() const;
bool isEditable() const;
bool hasSources() const;
const QList<sACN::DATA::data_header> sources() const;
QSacnUniverse* sourceUniverse(const sACN::DATA::data_header&) const;
bool getHoldLastLook() const;
public slots:
void setHoldLastLook(bool state);
void setOptions(sACN::DATA::data_options o);
void setPriority(uint8_t p);
void setSyncAddress(uint16_t a);

View File

@ -146,6 +146,8 @@ void ArbitratingUniverse::deleteSourceUniverse(const DATA::data_header& src)
doListChangeCallbacks();
doStatusCallbacks(); // if the deleted universe was dominant, the status has changed
// if (sources_.empty())
// doDataCallbacks();
}

View File

@ -59,9 +59,6 @@ public:
uint16_t expectedUniverse; ///< Expected universe number
void setHoldLastLook(const bool);
bool getHoldLastLook() const;
// Source universes:
void deleteSourceUniverse(const DATA::data_header&);
void dataChangedNotifier(DMX::Universe* universe);
@ -79,10 +76,13 @@ public:
bool isEditable() const override;
uint16_t activeSlots() const override;
// api for poly-source universes
virtual bool hasSources() const override {return true;} //!< is a poly-source universe @return
const std::vector<DATA::data_header> sources() const override;
std::shared_ptr<Universe> sourceUniverse(const DATA::data_header&) override;
std::shared_ptr<Universe> addNewSource(const DATA::data_header&) override;
std::shared_ptr<void> onSourceListChange(std::function<void()>) override;
virtual void setHoldLastLook(const bool) override;
virtual bool getHoldLastLook() const override;
protected:
void doListChangeCallbacks();

View File

@ -175,9 +175,7 @@ uint16_t Universe::activeSlots() const
*/
const std::vector<DATA::data_header> Universe::sources() const
{
std::shared_lock lk_ctl(mtx_control);
std::vector<DATA::data_header> keys = {*metadata_};
return keys;
return std::vector<DATA::data_header>();
}
@ -218,6 +216,26 @@ std::shared_ptr<void> Universe::onSourceListChange(std::function<void()> callbac
};
/**
* @brief Universe::setHoldLastLook
* @param state
*/
void Universe::setHoldLastLook(const bool state)
{
(void)state;
}
/**
* @brief Universe::getHoldLastLook
* @return
*/
bool Universe::getHoldLastLook() const
{
return false;
}
void Universe::setValue (const uint16_t start, const uint16_t footprint,
const uint8_t* data)
{

View File

@ -64,10 +64,13 @@ public:
virtual uint16_t activeSlots() const;
// api for poly-source universes
virtual bool hasSources() const {return false;} //!< is not a poly-source universe @return
virtual const std::vector<DATA::data_header> sources() const;
virtual std::shared_ptr<Universe> sourceUniverse(const DATA::data_header&);
virtual std::shared_ptr<Universe> addNewSource(const DATA::data_header&);
virtual std::shared_ptr<void> onSourceListChange(std::function<void()>);
virtual void setHoldLastLook(const bool);
virtual bool getHoldLastLook() const;
// DMX::Universe overrides
virtual void setValue (const uint16_t start, const uint16_t footprint,