Commit a2eadc9f authored by David Thompson's avatar David Thompson

Propagate highlightOnHover across the UI.

Have qtUIManager and qtAssociationWidget respond to changes
in the highlightOnHover preference exposed in SMTK's ParaView extension.
parent 16760e83
......@@ -16,6 +16,8 @@
#include "smtk/extension/paraview/appcomponents/pqSMTKResource.h"
#include "smtk/extension/paraview/appcomponents/pqSMTKWrapper.h"
#include "smtk/extension/paraview/server/vtkSMTKSettings.h"
#include "smtk/io/Logger.h"
#include "smtk/resource/Manager.h"
......@@ -26,8 +28,18 @@
#include "pqActiveObjects.h"
#include "pqApplicationCore.h"
#include "pqCoreUtilities.h"
#include "pqPipelineSource.h"
#include "vtkSMGlobalPropertiesProxy.h"
#include "vtkSMProperty.h"
#include "vtkSMPropertyHelper.h"
#include "vtkSMProxy.h"
#include "vtkSMSessionProxyManager.h"
#include "vtkCommand.h"
#include "vtkVector.h"
#include <QPointer>
#include <QVBoxLayout>
......@@ -50,6 +62,9 @@ pqSMTKAttributePanel::pqSMTKAttributePanel(QWidget* parent)
{
pqCore->registerManager("smtk attribute panel", this);
}
auto smtkSettings = vtkSMTKSettings::GetInstance();
pqCoreUtilities::connect(smtkSettings, vtkCommand::ModifiedEvent, this, SLOT(updateSettings()));
}
pqSMTKAttributePanel::~pqSMTKAttributePanel()
......@@ -129,6 +144,9 @@ bool pqSMTKAttributePanel::displayResource(smtk::attribute::ResourcePtr rsrc)
auto hoverBit = m_seln->findOrCreateLabeledValue("hovered");
m_attrUIMgr->setHoverBit(hoverBit);
// Fetch the current user preferences and update the UI manager with them.
this->updateSettings();
smtk::view::ViewPtr view = rsrc ? rsrc->findTopLevelView() : nullptr;
if (view)
{
......@@ -204,3 +222,14 @@ bool pqSMTKAttributePanel::updatePipeline()
auto dataSource = pqActiveObjects::instance().activeSource();
return this->displayPipelineSource(dataSource);
}
void pqSMTKAttributePanel::updateSettings()
{
if (!m_attrUIMgr)
{
return;
}
auto smtkSettings = vtkSMTKSettings::GetInstance();
m_attrUIMgr->setHighlightOnHover(smtkSettings->GetHighlightOnHover());
}
......@@ -78,6 +78,17 @@ public slots:
*/
virtual bool updatePipeline();
protected slots:
/**\brief Called when vtkSMTKSettings is modified, indicating user preferences have changed.
*
* The attribute panel listens for changes to the highlight-on-hover
* preference as well as default-value and error-value colors.
* This slot notifies the qtUIManager when these have changed
* and it in turn emits a signal that views or items can listen to
* for updates.
*/
virtual void updateSettings();
protected:
smtk::extension::qtUIManager* m_attrUIMgr;
smtk::resource::ResourcePtr m_rsrc;
......
......@@ -90,21 +90,9 @@ qtAssociationWidget::qtAssociationWidget(QWidget* _p, qtBaseView* bview)
return;
}
if (uiManager->highlightOnHover())
{
QObject::connect(this->Internals->CurrentList, SIGNAL(entered(const QModelIndex&)), this,
SLOT(hoverRow(const QModelIndex&)));
QObject::connect(this->Internals->AvailableList, SIGNAL(entered(const QModelIndex&)), this,
SLOT(hoverRow(const QModelIndex&)));
}
else
{
QObject::disconnect(this->Internals->CurrentList, SIGNAL(entered(const QModelIndex&)), this,
SLOT(hoverRow(const QModelIndex&)));
QObject::disconnect(this->Internals->AvailableList, SIGNAL(entered(const QModelIndex&)), this,
SLOT(hoverRow(const QModelIndex&)));
this->resetHover();
}
this->highlightOnHoverChanged(uiManager->highlightOnHover());
QObject::connect(
uiManager, SIGNAL(highlightOnHoverChanged(bool)), this, SLOT(highlightOnHoverChanged(bool)));
auto opManager = uiManager->operationManager();
if (opManager != nullptr)
......@@ -651,3 +639,22 @@ void qtAssociationWidget::resetHover()
}
selection->resetSelectionBits(m_selectionSourceName, uiManager->hoverBit());
}
void qtAssociationWidget::highlightOnHoverChanged(bool shouldHighlight)
{
if (shouldHighlight)
{
QObject::connect(this->Internals->CurrentList, SIGNAL(entered(const QModelIndex&)), this,
SLOT(hoverRow(const QModelIndex&)));
QObject::connect(this->Internals->AvailableList, SIGNAL(entered(const QModelIndex&)), this,
SLOT(hoverRow(const QModelIndex&)));
}
else
{
QObject::disconnect(this->Internals->CurrentList, SIGNAL(entered(const QModelIndex&)), this,
SLOT(hoverRow(const QModelIndex&)));
QObject::disconnect(this->Internals->AvailableList, SIGNAL(entered(const QModelIndex&)), this,
SLOT(hoverRow(const QModelIndex&)));
this->resetHover();
}
}
......@@ -66,6 +66,7 @@ protected slots:
virtual void removeObservers();
virtual void hoverRow(const QModelIndex& idx);
virtual void resetHover();
virtual void highlightOnHoverChanged(bool);
protected:
virtual void initWidget();
......
......@@ -1042,3 +1042,13 @@ std::string qtUIManager::activeTabInfo(const std::string& groupViewName) const
}
return it->second;
}
void qtUIManager::setHighlightOnHover(bool val)
{
if (val == m_highlightOnHover)
{
return;
}
m_highlightOnHover = val;
emit highlightOnHoverChanged(val);
}
......@@ -202,7 +202,7 @@ public:
bool highlightOnHover() const { return m_highlightOnHover; }
void setHighlightOnHover(bool val) { m_highlightOnHover = val; }
void setHighlightOnHover(bool val);
static qtItem* defaultItemConstructor(const AttributeItemInfo& info);
......@@ -224,6 +224,7 @@ signals:
void fileItemCreated(smtk::extension::qtFileItem* fileItem);
void modelEntityItemCreated(smtk::extension::qtModelEntityItem* entItem);
void viewUIChanged(smtk::extension::qtBaseView*, smtk::attribute::ItemPtr);
void highlightOnHoverChanged(bool);
void refreshEntityItems();
friend class qtBaseView;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment