Skip to content
Snippets Groups Projects
Commit f65c7dde authored by alexandr.mruchok's avatar alexandr.mruchok
Browse files

[*] Disable shadow changing in disabled ComboBox

[+] CustomComboBoxPopup::setModel(QAbstractItemModel*) CustomComboBoxPopup::itemSelected(int) signal
[+] Properties::VISIBLE, VALID;
parent af5e8ab9
No related branches found
No related tags found
1 merge request!17Develop old
......@@ -10,6 +10,8 @@ namespace Properties
static const QString ENABLED = "enabled";
static const QString HOVER = "hover" ;
static const QString CHECKED = "checked";
static const QString VISIBLE = "visible";
static const QString VALID = "valid";
}
......
......@@ -30,6 +30,10 @@ void CustomComboBox::showPopup()
void CustomComboBox:: enterEvent(QEvent *event)
{
Q_UNUSED(event);
if (!this->isEnabled())
return;
m_styledshadow->updateStyle(HOVER_SHADOW);
setGraphicsEffect(m_styledshadow);
......
......@@ -6,11 +6,10 @@ CustomComboBoxPopup::CustomComboBoxPopup(QWidget *parent)
m_layout(new QVBoxLayout(this)),
m_layoutScroll(new QVBoxLayout(this)),
m_lblCaption(new QLabel(this)),
m_scaList(new QScrollArea(this)),
m_listButton(new QList<CustomPlacementButton_New*>())
m_scaList(new QScrollArea(this))
{
setFixedSize(parent->width(),parent->height());
setObjectName("wgtComboBoxPopup");
this->setObjectName("wgtComboBoxPopup");
m_scaList->setObjectName("scaList");
m_scaList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
......@@ -41,14 +40,14 @@ void CustomComboBoxPopup::setModel(QList<DataModel> *model)
for(int i=0; i<model->size();i++)
{
// CustomPlacementButton_New tmp;
m_listButton->append(new CustomPlacementButton_New());
m_listButton->last()->setIcon(model->at(i).iconPath);
m_listButton->last()->setText(model->at(i).text);
m_listButton->last()->setObjectName("btnServer");
m_listButton->last()->addSubcontrol("arrow");
m_layoutScroll->addWidget(m_listButton->last());
m_layoutScroll->setAlignment(m_listButton->last(),Qt::AlignHCenter);
m_listButton.append(new CustomPlacementButton_New());
m_listButton.last()->setIcon(model->at(i).iconPath);
m_listButton.last()->setText(model->at(i).text);
m_listButton.last()->setObjectName("btnServer");
m_listButton.last()->addSubcontrol("arrow");
m_layoutScroll->addWidget(m_listButton.last());
m_layoutScroll->setAlignment(m_listButton.last(),Qt::AlignHCenter);
QWidget *tmpWidget = new QWidget();
if(i<model->size()-1)
{
......@@ -60,8 +59,38 @@ void CustomComboBoxPopup::setModel(QList<DataModel> *model)
}
}
void CustomComboBoxPopup::setModel(QAbstractItemModel *a_model)
{
for(int i=0; i<a_model->rowCount(); i++)
{
// CustomPlacementButton_New tmp;
CustomPlacementButton_New *newButton = new CustomPlacementButton_New;
m_listButton.append(newButton);
// newButton->setIcon(a_model->at(i).iconPath);
newButton->setText(a_model->data(a_model->index(i, 0)).toString());
newButton->setObjectName("btnServer");
newButton->addSubcontrol("arrow");
m_layoutScroll->addWidget(newButton);
m_layoutScroll->setAlignment(newButton, Qt::AlignHCenter);
QWidget *tmpWidget = new QWidget();
if(i < a_model->rowCount() - 1)
{
tmpWidget->setProperty("state", "sizeFixed"); //This setting is for fixing gaps between widgets other than the last.
}
m_layoutScroll->addWidget(tmpWidget);
connect(newButton, &QPushButton::clicked, [this, i]{
emit this->itemSelected(i);
this->hide();
});
}
}
void CustomComboBoxPopup::setTextCapture(const QString &text)
void CustomComboBoxPopup::setCaption(const QString &text)
{
m_lblCaption->setText(text);
}
......@@ -18,22 +18,28 @@ struct DataModel
class CustomComboBoxPopup: public QWidget
{
Q_OBJECT
public:
CustomComboBoxPopup( QWidget *parent = nullptr);
/// Set model.
/// @param model Model date for button.
void setModel(QList<DataModel> *model);
/// Set capture name.
void setModel(QAbstractItemModel *a_model);
/// Set caption.
/// @param text Name.
void setTextCapture(const QString &text);
private:
void setCaption(const QString &text);
signals:
void itemSelected(int index);
private:
QVBoxLayout *m_layout;
QVBoxLayout *m_layoutScroll;
QLabel *m_lblCaption;
QScrollArea *m_scaList;
QList<CustomPlacementButton_New*> *m_listButton;
QList<CustomPlacementButton_New*> m_listButton;
};
#endif // CUSTOMCOMBOBOXPOPUP_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment