mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
AppFwk : Combo box prev/next buttons - Disable icon when relevant
This commit is contained in:
parent
ead1e2af29
commit
18f1baea1a
@ -38,6 +38,7 @@
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiItem.h"
|
||||
#include "cafPdmUiComboBoxEditor.h"
|
||||
|
||||
|
||||
|
||||
@ -343,6 +344,14 @@ protected:
|
||||
attr->fieldToReceiveCurrentItemValue = &m_highlightedEnum;
|
||||
}
|
||||
}
|
||||
else if (field == &m_proxyEnumField)
|
||||
{
|
||||
caf::PdmUiComboBoxEditorAttribute* attr = dynamic_cast<caf::PdmUiComboBoxEditorAttribute*>(attribute);
|
||||
if (attr)
|
||||
{
|
||||
attr->showPreviousAndNextButtons = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,19 +112,38 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName)
|
||||
connect(m_previousItemButton, SIGNAL(clicked()), this, SLOT(slotPreviousButtonPressed()));
|
||||
|
||||
m_previousItemButton->setToolTip("Previous");
|
||||
m_previousItemButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowUp));
|
||||
}
|
||||
|
||||
if (m_nextItemButton.isNull())
|
||||
{
|
||||
m_nextItemButton = new QToolButton(m_placeholder);
|
||||
connect(m_nextItemButton, SIGNAL(clicked()), this, SLOT(slotNextButtonPressed()));
|
||||
|
||||
m_nextItemButton->setToolTip("Next");
|
||||
m_nextItemButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown));
|
||||
}
|
||||
|
||||
m_layout->insertWidget(1, m_previousItemButton);
|
||||
m_layout->insertWidget(2, m_nextItemButton);
|
||||
|
||||
if (m_comboBox->count() == 0 || m_comboBox->currentIndex() <= 0)
|
||||
{
|
||||
QIcon disabledIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowUp).pixmap(16, 16, QIcon::Disabled));
|
||||
m_previousItemButton->setIcon(disabledIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_previousItemButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowUp));
|
||||
}
|
||||
|
||||
if (m_comboBox->count() == 0 || m_comboBox->currentIndex() >= m_comboBox->count() - 1)
|
||||
{
|
||||
QIcon disabledIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown).pixmap(16, 16, QIcon::Disabled));
|
||||
m_nextItemButton->setIcon(disabledIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nextItemButton->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -233,8 +252,6 @@ void PdmUiComboBoxEditor::slotIndexActivated(int index)
|
||||
this->setValueToField(uintValue);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -39,7 +39,6 @@
|
||||
|
||||
#include "cafPdmUiFieldEditorHandle.h"
|
||||
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
@ -52,9 +51,8 @@ namespace caf
|
||||
{
|
||||
|
||||
//==================================================================================================
|
||||
/// The default editor for several PdmFields.
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
class PdmUiComboBoxEditorAttribute : public PdmUiEditorAttribute
|
||||
{
|
||||
public:
|
||||
@ -70,6 +68,9 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class PdmUiComboBoxEditor : public PdmUiFieldEditorHandle
|
||||
{
|
||||
Q_OBJECT
|
||||
|
Loading…
Reference in New Issue
Block a user