ObjectInspector for dark themes has been fixed

This commit is contained in:
Arin Alexander
2016-10-19 17:33:26 +03:00
parent 2768d13301
commit b8ecc89ff0
3 changed files with 66 additions and 6 deletions

View File

@@ -30,6 +30,7 @@
#include "lrintpropitem.h"
#include <limits>
#include <QDoubleSpinBox>
#include <QHBoxLayout>
namespace{
LimeReport::ObjectPropItem * createIntPropItem(
@@ -44,21 +45,27 @@ namespace LimeReport{
QWidget *IntPropItem::createProperyEditor(QWidget *parent) const
{
QSpinBox *editor= new QSpinBox(parent);
editor->setMaximum(std::numeric_limits<int>::max());
editor->setMinimum(std::numeric_limits<int>::min());
return editor;
// QWidget* base = new QWidget(parent);
// QHBoxLayout* layout = new QHBoxLayout();
// base->setLayout(layout);
// QSpinBox *editor = new QSpinBox(parent);
// editor->setMaximum(std::numeric_limits<int>::max());
// editor->setMinimum(std::numeric_limits<int>::min());
// layout->addWidget(editor);
return new SpinBoxEditor(parent);
}
void IntPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const
{
QSpinBox *editor =qobject_cast<QSpinBox *>(propertyEditor);
SpinBoxEditor *editor =qobject_cast<SpinBoxEditor *>(propertyEditor);
editor->setValue(propertyValue().toInt());
}
void IntPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
{
model->setData(index,qobject_cast<QSpinBox*>(propertyEditor)->value());
model->setData(index,qobject_cast<SpinBoxEditor*>(propertyEditor)->value());
object()->setProperty(propertyName().toLatin1(),propertyValue());
foreach(QObject* item, *objects()){
if (item->metaObject()->indexOfProperty(propertyName().toLatin1())!=-1){
@@ -67,4 +74,29 @@ void IntPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *mode
}
}
SpinBoxEditor::SpinBoxEditor(QWidget *parent)
:QWidget(parent)
{
m_valueEditor = new QSpinBox(this);
m_valueEditor->setMinimum(std::numeric_limits<int>::min());
m_valueEditor->setMaximum(std::numeric_limits<int>::max());
setFocusProxy(m_valueEditor);
QHBoxLayout* hLayout = new QHBoxLayout(this);
hLayout->addWidget(m_valueEditor);
hLayout->setContentsMargins(1,1,1,1);
hLayout->setSpacing(0);
setAutoFillBackground(true);
connect(m_valueEditor, SIGNAL(editingFinished()), this, SIGNAL(editingFinished()));
}
int SpinBoxEditor::value()
{
return m_valueEditor->value();
}
void SpinBoxEditor::setValue(int value)
{
m_valueEditor->setValue(value);
}
} // namespace LimeReport

View File

@@ -31,8 +31,22 @@
#define LRINTPROPITEM_H
#include "lrobjectpropitem.h"
#include <QSpinBox>
namespace LimeReport {
class SpinBoxEditor : public QWidget{
Q_OBJECT
public:
SpinBoxEditor(QWidget* parent);
int value();
void setValue(int value);
signals:
void editingFinished();
private:
QSpinBox* m_valueEditor;
};
class IntPropItem : public ObjectPropItem
{
Q_OBJECT