uic: Fix pixmap functions for QIcon
Task-number: QTBUG-8563 Change-Id: I69b16ac2327fee6dd6f26845bdda60ad4dde56fa Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>bb10
parent
dc73a691bf
commit
550d2a0a15
|
|
@ -1645,6 +1645,53 @@ static void writeResourceIcon(QTextStream &output,
|
|||
}
|
||||
}
|
||||
|
||||
void WriteInitialization::writePixmapFunctionIcon(QTextStream &output,
|
||||
const QString &iconName,
|
||||
const QString &indent,
|
||||
const DomResourceIcon *i) const
|
||||
{
|
||||
if (i->hasElementNormalOff()) {
|
||||
output << indent << iconName << ".addPixmap("
|
||||
<< pixCall(QLatin1String("QPixmap"), i->elementNormalOff()->text())
|
||||
<< ", QIcon::Normal, QIcon::Off);\n";
|
||||
}
|
||||
if (i->hasElementNormalOn()) {
|
||||
output << indent << iconName << ".addPixmap("
|
||||
<< pixCall(QLatin1String("QPixmap"), i->elementNormalOn()->text())
|
||||
<< ", QIcon::Normal, QIcon::On);\n";
|
||||
}
|
||||
if (i->hasElementDisabledOff()) {
|
||||
output << indent << iconName << ".addPixmap("
|
||||
<< pixCall(QLatin1String("QPixmap"), i->elementDisabledOff()->text())
|
||||
<< ", QIcon::Disabled, QIcon::Off);\n";
|
||||
}
|
||||
if (i->hasElementDisabledOn()) {
|
||||
output << indent << iconName << ".addPixmap("
|
||||
<< pixCall(QLatin1String("QPixmap"), i->elementDisabledOn()->text())
|
||||
<< ", QIcon::Disabled, QIcon::On);\n";
|
||||
}
|
||||
if (i->hasElementActiveOff()) {
|
||||
output << indent << iconName << ".addPixmap("
|
||||
<< pixCall(QLatin1String("QPixmap"), i->elementActiveOff()->text())
|
||||
<< ", QIcon::Active, QIcon::Off);\n";
|
||||
}
|
||||
if (i->hasElementActiveOn()) {
|
||||
output << indent << iconName << ".addPixmap("
|
||||
<< pixCall(QLatin1String("QPixmap"), i->elementActiveOn()->text())
|
||||
<< ", QIcon::Active, QIcon::On);\n";
|
||||
}
|
||||
if (i->hasElementSelectedOff()) {
|
||||
output << indent << iconName << ".addPixmap("
|
||||
<< pixCall(QLatin1String("QPixmap"), i->elementSelectedOff()->text())
|
||||
<< ", QIcon::Selected, QIcon::Off);\n";
|
||||
}
|
||||
if (i->hasElementSelectedOn()) {
|
||||
output << indent << iconName << ".addPixmap("
|
||||
<< pixCall(QLatin1String("QPixmap"), i->elementSelectedOn()->text())
|
||||
<< ", QIcon::Selected, QIcon::On);\n";
|
||||
}
|
||||
}
|
||||
|
||||
QString WriteInitialization::writeIconProperties(const DomResourceIcon *i)
|
||||
{
|
||||
// check cache
|
||||
|
|
@ -1661,7 +1708,10 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i)
|
|||
if (i->attributeTheme().isEmpty()) {
|
||||
// No theme: Write resource icon as is
|
||||
m_output << m_indent << "QIcon " << iconName << ";\n";
|
||||
writeResourceIcon(m_output, iconName, m_indent, i);
|
||||
if (m_uic->pixmapFunction().isEmpty())
|
||||
writeResourceIcon(m_output, iconName, m_indent, i);
|
||||
else
|
||||
writePixmapFunctionIcon(m_output, iconName, m_indent, i);
|
||||
} else {
|
||||
// Theme: Generate code to check the theme and default to resource
|
||||
const QString themeIconName = fixString(i->attributeTheme(), QString());
|
||||
|
|
@ -1683,7 +1733,10 @@ QString WriteInitialization::writeIconProperties(const DomResourceIcon *i)
|
|||
<< ")) {\n"
|
||||
<< m_dindent << iconName << " = QIcon::fromTheme(" << themeNameStringVariableC << ");\n"
|
||||
<< m_indent << "} else {\n";
|
||||
writeResourceIcon(m_output, iconName, m_dindent, i);
|
||||
if (m_uic->pixmapFunction().isEmpty())
|
||||
writeResourceIcon(m_output, iconName, m_dindent, i);
|
||||
else
|
||||
writePixmapFunctionIcon(m_output, iconName, m_dindent, i);
|
||||
m_output << m_indent << "}\n";
|
||||
} else {
|
||||
// Theme, but no state pixmaps: Construct from theme directly.
|
||||
|
|
|
|||
|
|
@ -230,6 +230,8 @@ private:
|
|||
private:
|
||||
QString writeFontProperties(const DomFont *f);
|
||||
QString writeIconProperties(const DomResourceIcon *i);
|
||||
void writePixmapFunctionIcon(QTextStream &output, const QString &iconName,
|
||||
const QString &indent, const DomResourceIcon *i) const;
|
||||
QString writeSizePolicy(const DomSizePolicy *sp);
|
||||
QString writeBrushInitialization(const DomBrush *brush);
|
||||
void addButtonGroup(const DomWidget *node, const QString &varName);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>149</width>
|
||||
<height>112</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap>labelPixmap</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>buttonIconNormalOff</normaloff>
|
||||
<normalon>buttonIconNormalOn</normalon>
|
||||
<disabledoff>buttonIconDisabledOff</disabledoff>
|
||||
<disabledon>buttonIconDisabledOn</disabledon>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<pixmapfunction>pixmapFunction</pixmapfunction>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
/********************************************************************************
|
||||
** Form generated from reading UI file 'pixmapfunction.ui'
|
||||
**
|
||||
** Created by: Qt User Interface Compiler version 5.12.0
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost when recompiling UI file!
|
||||
********************************************************************************/
|
||||
|
||||
#ifndef PIXMAPFUNCTION_H
|
||||
#define PIXMAPFUNCTION_H
|
||||
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtWidgets/QLabel>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Ui_Form
|
||||
{
|
||||
public:
|
||||
QVBoxLayout *verticalLayout;
|
||||
QLabel *label;
|
||||
QPushButton *pushButton;
|
||||
|
||||
void setupUi(QWidget *Form)
|
||||
{
|
||||
if (Form->objectName().isEmpty())
|
||||
Form->setObjectName(QString::fromUtf8("Form"));
|
||||
Form->resize(149, 112);
|
||||
verticalLayout = new QVBoxLayout(Form);
|
||||
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
|
||||
label = new QLabel(Form);
|
||||
label->setObjectName(QString::fromUtf8("label"));
|
||||
label->setPixmap(QPixmap(pixmapFunction("labelPixmap")));
|
||||
|
||||
verticalLayout->addWidget(label);
|
||||
|
||||
pushButton = new QPushButton(Form);
|
||||
pushButton->setObjectName(QString::fromUtf8("pushButton"));
|
||||
QIcon icon;
|
||||
icon.addPixmap(QPixmap(pixmapFunction("buttonIconNormalOff")), QIcon::Normal, QIcon::Off);
|
||||
icon.addPixmap(QPixmap(pixmapFunction("buttonIconNormalOn")), QIcon::Normal, QIcon::On);
|
||||
icon.addPixmap(QPixmap(pixmapFunction("buttonIconDisabledOff")), QIcon::Disabled, QIcon::Off);
|
||||
icon.addPixmap(QPixmap(pixmapFunction("buttonIconDisabledOn")), QIcon::Disabled, QIcon::On);
|
||||
pushButton->setIcon(icon);
|
||||
|
||||
verticalLayout->addWidget(pushButton);
|
||||
|
||||
|
||||
retranslateUi(Form);
|
||||
|
||||
QMetaObject::connectSlotsByName(Form);
|
||||
} // setupUi
|
||||
|
||||
void retranslateUi(QWidget *Form)
|
||||
{
|
||||
Form->setWindowTitle(QApplication::translate("Form", "Form", nullptr));
|
||||
label->setText(QString());
|
||||
pushButton->setText(QApplication::translate("Form", "PushButton", nullptr));
|
||||
} // retranslateUi
|
||||
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class Form: public Ui_Form {};
|
||||
} // namespace Ui
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // PIXMAPFUNCTION_H
|
||||
Loading…
Reference in New Issue