add PrefUnitSpinBox to designer plugin
This commit is contained in:
@@ -22,8 +22,11 @@
|
||||
|
||||
|
||||
#include <QtGui>
|
||||
#include <QApplication>
|
||||
#include <QColorDialog>
|
||||
#include <QCursor>
|
||||
#include <QFileDialog>
|
||||
#include <QHeaderView>
|
||||
#include <QMessageBox>
|
||||
#include <QStyleOptionButton>
|
||||
#include <QStylePainter>
|
||||
@@ -33,7 +36,7 @@
|
||||
using namespace Gui;
|
||||
|
||||
|
||||
UrlLabel::UrlLabel ( QWidget * parent, Qt::WFlags f )
|
||||
UrlLabel::UrlLabel ( QWidget * parent, Qt::WindowFlags f )
|
||||
: QLabel("TextLabel", parent, f)
|
||||
{
|
||||
_url = "http://localhost";
|
||||
@@ -280,49 +283,49 @@ void AccelLineEdit::keyPressEvent ( QKeyEvent * e)
|
||||
case Qt::ControlModifier:
|
||||
{
|
||||
QKeySequence key(Qt::CTRL+key);
|
||||
txt += (QString)(key);
|
||||
txt += key.toString(QKeySequence::NativeText);
|
||||
setText(txt);
|
||||
} break;
|
||||
case Qt::AltModifier:
|
||||
{
|
||||
QKeySequence key(Qt::ALT+key);
|
||||
txt += (QString)(key);
|
||||
txt += key.toString(QKeySequence::NativeText);
|
||||
setText(txt);
|
||||
} break;
|
||||
case Qt::ShiftModifier:
|
||||
{
|
||||
QKeySequence key(Qt::SHIFT+key);
|
||||
txt += (QString)(key);
|
||||
txt += key.toString(QKeySequence::NativeText);
|
||||
setText(txt);
|
||||
} break;
|
||||
case Qt::ControlModifier+Qt::AltModifier:
|
||||
{
|
||||
QKeySequence key(Qt::CTRL+Qt::ALT+key);
|
||||
txt += (QString)(key);
|
||||
txt += key.toString(QKeySequence::NativeText);
|
||||
setText(txt);
|
||||
} break;
|
||||
case Qt::ControlModifier+Qt::ShiftModifier:
|
||||
{
|
||||
QKeySequence key(Qt::CTRL+Qt::SHIFT+key);
|
||||
txt += (QString)(key);
|
||||
txt += key.toString(QKeySequence::NativeText);
|
||||
setText(txt);
|
||||
} break;
|
||||
case Qt::ShiftModifier+Qt::AltModifier:
|
||||
{
|
||||
QKeySequence key(Qt::SHIFT+Qt::ALT+key);
|
||||
txt += (QString)(key);
|
||||
txt += key.toString(QKeySequence::NativeText);
|
||||
setText(txt);
|
||||
} break;
|
||||
case Qt::ControlModifier+Qt::AltModifier+Qt::ShiftModifier:
|
||||
{
|
||||
QKeySequence key(Qt::CTRL+Qt::ALT+Qt::SHIFT+key);
|
||||
txt += (QString)(key);
|
||||
txt += key.toString(QKeySequence::NativeText);
|
||||
setText(txt);
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
QKeySequence key(key);
|
||||
txt += (QString)(key);
|
||||
txt += key.toString(QKeySequence::NativeText);
|
||||
setText(txt);
|
||||
} break;
|
||||
}
|
||||
@@ -404,12 +407,12 @@ ActionSelector::ActionSelector(QWidget* parent)
|
||||
upButton->setText(QString());
|
||||
downButton->setText(QString());
|
||||
|
||||
labelAvailable->setText(QApplication::translate("Gui::ActionSelector", "Available:", 0, QApplication::UnicodeUTF8));
|
||||
labelSelected->setText(QApplication::translate("Gui::ActionSelector", "Selected:", 0, QApplication::UnicodeUTF8));
|
||||
addButton->setToolTip(QApplication::translate("Gui::ActionSelector", "Add", 0, QApplication::UnicodeUTF8));
|
||||
removeButton->setToolTip(QApplication::translate("Gui::ActionSelector", "Remove", 0, QApplication::UnicodeUTF8));
|
||||
upButton->setToolTip(QApplication::translate("Gui::ActionSelector", "Move up", 0, QApplication::UnicodeUTF8));
|
||||
downButton->setToolTip(QApplication::translate("Gui::ActionSelector", "Move down", 0, QApplication::UnicodeUTF8));
|
||||
labelAvailable->setText(QApplication::translate("Gui::ActionSelector", "Available:"));
|
||||
labelSelected->setText(QApplication::translate("Gui::ActionSelector", "Selected:"));
|
||||
addButton->setToolTip(QApplication::translate("Gui::ActionSelector", "Add"));
|
||||
removeButton->setToolTip(QApplication::translate("Gui::ActionSelector", "Remove"));
|
||||
upButton->setToolTip(QApplication::translate("Gui::ActionSelector", "Move up"));
|
||||
downButton->setToolTip(QApplication::translate("Gui::ActionSelector", "Move down"));
|
||||
}
|
||||
|
||||
ActionSelector::~ActionSelector()
|
||||
@@ -620,6 +623,37 @@ QString QuantitySpinBox::unitText(void)
|
||||
return UnitStr;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
PrefUnitSpinBox::PrefUnitSpinBox ( QWidget * parent )
|
||||
: QuantitySpinBox(parent)
|
||||
{
|
||||
}
|
||||
|
||||
PrefUnitSpinBox::~PrefUnitSpinBox()
|
||||
{
|
||||
}
|
||||
|
||||
QByteArray PrefUnitSpinBox::entryName () const
|
||||
{
|
||||
return m_sPrefName;
|
||||
}
|
||||
|
||||
QByteArray PrefUnitSpinBox::paramGrpPath () const
|
||||
{
|
||||
return m_sPrefGrp;
|
||||
}
|
||||
|
||||
void PrefUnitSpinBox::setEntryName ( const QByteArray& name )
|
||||
{
|
||||
m_sPrefName = name;
|
||||
}
|
||||
|
||||
void PrefUnitSpinBox::setParamGrpPath ( const QByteArray& name )
|
||||
{
|
||||
m_sPrefGrp = name;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
CommandIconView::CommandIconView ( QWidget * parent )
|
||||
@@ -643,7 +677,7 @@ void CommandIconView::startDrag ( Qt::DropActions /*supportedActions*/ )
|
||||
dataStream << items.count();
|
||||
for (QList<QListWidgetItem*>::ConstIterator it = items.begin(); it != items.end(); ++it) {
|
||||
if (it == items.begin())
|
||||
pixmap = qVariantValue<QPixmap>((*it)->data(Qt::UserRole));
|
||||
pixmap = ((*it)->data(Qt::UserRole)).value<QPixmap>();
|
||||
dataStream << (*it)->text();
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class UrlLabel : public QLabel
|
||||
Q_PROPERTY( QString url READ url WRITE setUrl)
|
||||
|
||||
public:
|
||||
UrlLabel ( QWidget * parent = 0, Qt::WFlags f = 0 );
|
||||
UrlLabel ( QWidget * parent = 0, Qt::WindowFlags f = 0 );
|
||||
virtual ~UrlLabel();
|
||||
|
||||
QString url() const;
|
||||
@@ -302,6 +302,29 @@ private:
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
class PrefUnitSpinBox : public QuantitySpinBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( QByteArray prefEntry READ entryName WRITE setEntryName )
|
||||
Q_PROPERTY( QByteArray prefPath READ paramGrpPath WRITE setParamGrpPath )
|
||||
|
||||
public:
|
||||
PrefUnitSpinBox ( QWidget * parent = 0 );
|
||||
virtual ~PrefUnitSpinBox();
|
||||
|
||||
QByteArray entryName () const;
|
||||
QByteArray paramGrpPath () const;
|
||||
void setEntryName ( const QByteArray& name );
|
||||
void setParamGrpPath ( const QByteArray& name );
|
||||
|
||||
private:
|
||||
QByteArray m_sPrefName;
|
||||
QByteArray m_sPrefGrp;
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
class CommandIconView : public QListWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -619,6 +619,54 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class PrefUnitSpinBoxPlugin : public QDesignerCustomWidgetInterface
|
||||
{
|
||||
Q_INTERFACES(QDesignerCustomWidgetInterface)
|
||||
public:
|
||||
PrefUnitSpinBoxPlugin()
|
||||
{
|
||||
}
|
||||
QWidget *createWidget(QWidget *parent)
|
||||
{
|
||||
return new Gui::PrefUnitSpinBox(parent);
|
||||
}
|
||||
QString group() const
|
||||
{
|
||||
return QLatin1String("Preference Widgets");
|
||||
}
|
||||
QIcon icon() const
|
||||
{
|
||||
return QIcon( QPixmap( quantityspinbox_pixmap ) );
|
||||
}
|
||||
QString includeFile() const
|
||||
{
|
||||
return QLatin1String("Gui/PrefWidgets.h");
|
||||
}
|
||||
QString toolTip() const
|
||||
{
|
||||
return QLatin1String("Quantity Spin Box");
|
||||
}
|
||||
QString whatsThis() const
|
||||
{
|
||||
return QLatin1String("Quantity Spin box widget.");
|
||||
}
|
||||
bool isContainer() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
QString domXml() const
|
||||
{
|
||||
return "<ui language=\"c++\">\n"
|
||||
" <widget class=\"Gui::PrefUnitSpinBox\" name=\"unitSpinBox\">\n"
|
||||
" </widget>\n"
|
||||
"</ui>";
|
||||
}
|
||||
QString name() const
|
||||
{
|
||||
return QLatin1String("Gui::PrefUnitSpinBox");
|
||||
}
|
||||
};
|
||||
|
||||
/* XPM */
|
||||
static const char *iconview_pixmap[]={
|
||||
"22 22 10 1",
|
||||
@@ -1514,6 +1562,7 @@ QList<QDesignerCustomWidgetInterface *> CustomWidgetPlugin::customWidgets () con
|
||||
cw.append(new PrefLineEditPlugin);
|
||||
cw.append(new PrefDoubleSpinBoxPlugin);
|
||||
cw.append(new PrefFontBoxPlugin);
|
||||
cw.append(new PrefUnitSpinBoxPlugin);
|
||||
return cw;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
TEMPLATE = lib
|
||||
CONFIG += designer plugin
|
||||
CONFIG += plugin
|
||||
QT += designer
|
||||
TARGET = FreeCAD_widgets
|
||||
DEPENDPATH += .
|
||||
INCLUDEPATH += .
|
||||
|
||||
Reference in New Issue
Block a user