69 for (
int c = 0; c < item->columnCount(); c++) {
70 const QVariant v = item->data(c, Qt::DecorationPropertyRole);
71 if (v.canConvert<PropertySheetIconValue>())
96 void reloadIconResources(DesignerIconCache *iconCache, QObject *object)
98 if (QListWidget *listWidget = qobject_cast<QListWidget *>(object)) {
99 for (
int i = 0; i < listWidget->count(); i++)
100 reloadListItem(iconCache, listWidget->item(i));
101 }
else if (QComboBox *comboBox = qobject_cast<QComboBox *>(object)) {
102 for (
int i = 0; i < comboBox->count(); i++) {
103 const QVariant v = comboBox->itemData(i, Qt::DecorationPropertyRole);
104 if (v.canConvert<PropertySheetIconValue>()) {
105 QIcon icon = iconCache->icon(qvariant_cast<PropertySheetIconValue>(v));
106 comboBox->setItemIcon(i, icon);
107 comboBox->setItemData(i, icon);
110 }
else if (QTreeWidget *treeWidget = qobject_cast<QTreeWidget *>(object)) {
111 reloadTreeItem(iconCache, treeWidget->headerItem());
112 QQueue<QTreeWidgetItem *> itemsQueue;
113 for (
int i = 0; i < treeWidget->topLevelItemCount(); i++)
114 itemsQueue.enqueue(treeWidget->topLevelItem(i));
115 while (!itemsQueue.isEmpty()) {
116 QTreeWidgetItem *item = itemsQueue.dequeue();
117 for (
int i = 0; i < item->childCount(); i++)
118 itemsQueue.enqueue(item->child(i));
119 reloadTreeItem(iconCache, item);
121 }
else if (QTableWidget *tableWidget = qobject_cast<QTableWidget *>(object)) {
122 const int columnCount = tableWidget->columnCount();
123 const int rowCount = tableWidget->rowCount();
124 for (
int c = 0; c < columnCount; c++)
125 reloadTableItem(iconCache, tableWidget->horizontalHeaderItem(c));
126 for (
int r = 0; r < rowCount; r++)
127 reloadTableItem(iconCache, tableWidget->verticalHeaderItem(r));
128 for (
int c = 0; c < columnCount; c++)
129 for (
int r = 0; r < rowCount; r++)
130 reloadTableItem(iconCache, tableWidget->item(r, c));
329 const PropertySheetIconValue &rhs)
noexcept
331 const auto *lhsd = lhs.m_data.constData();
332 const auto *rhsd = rhs.m_data.constData();
334 || (lhsd->m_themeEnum == rhsd->m_themeEnum
335 && lhsd->m_theme == rhsd->m_theme && lhsd->m_paths == rhsd->m_paths);
541 case QIcon::Disabled:
542 return state == QIcon::On ? DisabledOnIconMask : DisabledOffIconMask;
544 return state == QIcon::On ? ActiveOnIconMask : ActiveOffIconMask;
545 case QIcon::Selected:
546 return state == QIcon::On ? SelectedOnIconMask : SelectedOffIconMask;
550 return state == QIcon::On ? NormalOnIconMask : NormalOffIconMask;
556 case NormalOnIconMask:
557 return {QIcon::Normal, QIcon::On};
558 case DisabledOffIconMask:
559 return {QIcon::Disabled, QIcon::Off};
560 case DisabledOnIconMask:
561 return {QIcon::Disabled, QIcon::On};
562 case ActiveOffIconMask:
563 return {QIcon::Active, QIcon::Off};
564 case ActiveOnIconMask:
565 return {QIcon::Active, QIcon::On};
566 case SelectedOffIconMask:
567 return {QIcon::Selected, QIcon::Off};
568 case SelectedOnIconMask:
569 return {QIcon::Selected, QIcon::On};
574 return {QIcon::Normal, QIcon::Off};
701 QByteArray& ba, QString &errorMessage)
704 QStringList arguments;
705 static constexpr auto uicBinary =
706 QOperatingSystemVersion::currentType() != QOperatingSystemVersion::Windows
707 ?
"/uic"_L1 :
"/uic.exe"_L1;
708 QString binary = QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath) + uicBinary;
711 if (!QFileInfo::exists(binary))
712 binary = QCoreApplication::applicationDirPath() + uicBinary;
713 if (!QFileInfo::exists(binary)) {
714 errorMessage = QApplication::translate(
"Designer",
"%1 does not exist.").
715 arg(QDir::toNativeSeparators(binary));
722 case UicLanguage::Python:
723 arguments << u"-g"_s << u"python"_s;
726 arguments << fileName;
728 uic.start(binary, arguments);
729 if (!uic.waitForStarted()) {
730 errorMessage = QApplication::translate(
"Designer",
"Unable to launch %1: %2").
731 arg(QDir::toNativeSeparators(binary), uic.errorString());
734 if (!uic.waitForFinished()) {
735 errorMessage = QApplication::translate(
"Designer",
"%1 timed out.").arg(binary);
738 if (uic.exitCode()) {
739 errorMessage = QString::fromLatin1(uic.readAllStandardError());
742 ba = uic.readAllStandardOutput();
782quint64 paletteResolveMask(QPalette::ColorGroup colorGroup,
783 QPalette::ColorRole colorRole)
785 if (colorRole == QPalette::Accent)
786 colorRole = QPalette::NoRole;
787 const auto offset = quint64(QPalette::NColorRoles - 1) * quint64(colorGroup);
788 const auto bitPos = quint64(colorRole) + offset;
789 return 1ull << bitPos;
792quint64 paletteResolveMask(QPalette::ColorRole colorRole)
794 return paletteResolveMask(QPalette::Active, colorRole)
795 | paletteResolveMask(QPalette::Inactive, colorRole)
796 | paletteResolveMask(QPalette::Disabled, colorRole);