Example #1
0
void FormWindowBase::resourceSetActivated(QtResourceSet *resource, bool resourceSetChanged)
{
    if (resource == resourceSet() && resourceSetChanged) {
        reloadProperties();
        emit pixmapCache()->reloaded();
        emit iconCache()->reloaded();
        if (QDesignerPropertyEditor *propertyEditor = qobject_cast<QDesignerPropertyEditor *>(core()->propertyEditor()))
            propertyEditor->reloadResourceProperties();
    }
}
Example #2
0
void FormWindowBase::reloadProperties()
{
    pixmapCache()->clear();
    iconCache()->clear();
    QMapIterator<QDesignerPropertySheet *, QMap<int, bool> > itSheet(m_d->m_reloadableResources);
    while (itSheet.hasNext()) {
        QDesignerPropertySheet *sheet = itSheet.next().key();
        QMapIterator<int, bool> itIndex(itSheet.value());
        while (itIndex.hasNext()) {
            const int index = itIndex.next().key();
            const QVariant newValue = sheet->property(index);
            if (qobject_cast<QLabel *>(sheet->object()) && sheet->propertyName(index) == QLatin1String("text")) {
                const PropertySheetStringValue newString = qvariant_cast<PropertySheetStringValue>(newValue);
                // optimize a bit, reset only if the text value might contain a reference to qt resources
                // (however reloading of icons other than taken from resources might not work here)
                if (newString.value().contains(QLatin1String(":/"))) {
                    const QVariant resetValue = QVariant::fromValue(PropertySheetStringValue());
                    sheet->setProperty(index, resetValue);
                }
            }
            sheet->setProperty(index, newValue);
        }
        if (QTabWidget *tabWidget = qobject_cast<QTabWidget *>(sheet->object())) {
            const int count = tabWidget->count();
            const int current = tabWidget->currentIndex();
            const QString currentTabIcon = QLatin1String("currentTabIcon");
            for (int i = 0; i < count; i++) {
                tabWidget->setCurrentIndex(i);
                const int index = sheet->indexOf(currentTabIcon);
                sheet->setProperty(index, sheet->property(index));
            }
            tabWidget->setCurrentIndex(current);
        } else if (QToolBox *toolBox = qobject_cast<QToolBox *>(sheet->object())) {
            const int count = toolBox->count();
            const int current = toolBox->currentIndex();
            const QString currentItemIcon = QLatin1String("currentItemIcon");
            for (int i = 0; i < count; i++) {
                toolBox->setCurrentIndex(i);
                const int index = sheet->indexOf(currentItemIcon);
                sheet->setProperty(index, sheet->property(index));
            }
            toolBox->setCurrentIndex(current);
        }
    }
    QMapIterator<QDesignerPropertySheet *, QObject *> itSh(m_d->m_reloadablePropertySheets);
    while (itSh.hasNext()) {
        QObject *object = itSh.next().value();
        reloadIconResources(iconCache(), object);
    }
}
Example #3
0
void FormWindowBase::reloadProperties()
{
    pixmapCache()->clear();
    iconCache()->clear();
    QMapIterator<QDesignerPropertySheet *, QMap<int, bool> > itSheet(m_d->m_reloadableResources);
    while (itSheet.hasNext()) {
        QDesignerPropertySheet *sheet = itSheet.next().key();
        QMapIterator<int, bool> itIndex(itSheet.value());
        while (itIndex.hasNext()) {
            const int index = itIndex.next().key();
            sheet->setProperty(index, sheet->property(index));
        }
        if (QTabWidget *tabWidget = qobject_cast<QTabWidget *>(sheet->object())) {
            const int count = tabWidget->count();
            const int current = tabWidget->currentIndex();
            const QString currentTabIcon = QLatin1String("currentTabIcon");
            for (int i = 0; i < count; i++) {
                tabWidget->setCurrentIndex(i);
                const int index = sheet->indexOf(currentTabIcon);
                sheet->setProperty(index, sheet->property(index));
            }
            tabWidget->setCurrentIndex(current);
        } else if (QToolBox *toolBox = qobject_cast<QToolBox *>(sheet->object())) {
            const int count = toolBox->count();
            const int current = toolBox->currentIndex();
            const QString currentItemIcon = QLatin1String("currentItemIcon");
            for (int i = 0; i < count; i++) {
                toolBox->setCurrentIndex(i);
                const int index = sheet->indexOf(currentItemIcon);
                sheet->setProperty(index, sheet->property(index));
            }
            toolBox->setCurrentIndex(current);
        }
    }
    QMapIterator<QDesignerPropertySheet *, QObject *> itSh(m_d->m_reloadablePropertySheets);
    while (itSh.hasNext()) {
        QObject *object = itSh.next().value();
        reloadIconResources(iconCache(), object);
    }
}