Skip to content

Commit

Permalink
Icons are not loaded properly with Qt 5.7.x;
Browse files Browse the repository at this point in the history
  • Loading branch information
brezerk committed Dec 21, 2016
1 parent 1a4afc6 commit e243648
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 32 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Version 1.3.4
Added:
- Add WINE env var to console environment [BUG-91];
Fixed:
- Icons are not loaded properly with Qt 5.7.x;
- Console launch environment uses dead setting fields [BUG-90];
- Q4Wine file selectors filters files with upper case extension [BUG-94][QTBUG-51712];
- Refactor winetrkics parser: use direct parser + transactions;
Expand Down
16 changes: 2 additions & 14 deletions src/q4wine-gui/iconsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,8 @@ void IconSettings::getIconReccord(){
iconPath = iconRec.value("icon_path");

if (!iconPath.isEmpty()){
if (QFile(iconPath).exists()){
cmdGetIcon->setIcon (QIcon(iconPath));
} else {
QIcon ico = CoreLib->loadIcon(iconPath);

// Do not work due to: https://bugreports.qt-project.org/browse/QTBUG-999
//if (ico.isNull()){
if (ico.availableSizes().isEmpty()){
ico = CoreLib->loadIcon("application-x-ms-dos-executable");
iconPath="";
}

cmdGetIcon->setIcon(ico);
}
QIcon ico = CoreLib->loadAppIcon(iconPath);
cmdGetIcon->setIcon(ico);
}

txtDesc->setText(iconRec.value("desc"));
Expand Down
19 changes: 2 additions & 17 deletions src/q4wine-gui/widgets/iconlistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,13 @@ void IconListWidget::showContents(QString filterString){
iconItem->setText(iconsList.at(i));
iconItem->setToolTip(iconsList.at(i));


//Seting icon. If no icon or icon file does not exist -- setting default
QString icon_path = db_icon.getPixmapIcon(this->prefixName, this->dirName, iconsList.at(i));
if (icon_path.isEmpty()){
iconItem->setIcon(defIcon);
} else {
if (QFile::exists (icon_path)){
iconItem->setIcon(QIcon(icon_path));
} else {
icon_path = QString("%1/.local/share/icons/%2").arg(QDir::homePath()).arg(icon_path);
if (QFile::exists (icon_path)){
iconItem->setIcon(QIcon(icon_path));
} else {
QIcon ico = CoreLib->loadIcon(iconsList.at(i));
// Do not work due to: https://bugreports.qt-project.org/browse/QTBUG-999
//if (ico.isNull()){
if (ico.availableSizes().isEmpty())
ico = defIcon;

iconItem->setIcon(ico);
}
}
QIcon ico = CoreLib->loadAppIcon(icon_path);
iconItem->setIcon(ico);
}
iconItem.release();
}
Expand Down
22 changes: 21 additions & 1 deletion src/q4wine-lib/q4wine-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,27 @@ void corelib::checkSettings(){
QIcon corelib::loadIcon(QString iconName, bool fromTheme){
// Function tryes to load icon image from theme dir
// If it fails -> load default from rsource file
return QIcon::fromTheme(iconName, QIcon(QString(":%1").arg(iconName)));
return QIcon::fromTheme(iconName, QIcon(QString(":/%1").arg(iconName)));
}

QIcon corelib::loadAppIcon(QString iconName){
// Function tryes to load icon image from theme dir
// If it fails -> load default from rsource file
QIcon ico;

if (QFile(iconName).exists()){
ico = QIcon(iconName);
} else {
ico = QIcon::fromTheme(iconName, QIcon(QString(":/%1").arg(iconName)));
#if QT_VERSION >= 0x050700
if (ico.isNull()){
#else
if (ico.availableSizes().isEmpty()){
#endif
return loadIcon("application-x-ms-dos-executable");
}
}
return ico;
}

QPixmap corelib::loadPixmap(QString iconName){
Expand Down
1 change: 1 addition & 0 deletions src/q4wine-lib/q4wine-lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class corelib {
void checkSettings(void);

QIcon loadIcon(QString iconName, bool fromTheme = true);
QIcon loadAppIcon(QString iconName);
QPixmap loadPixmap(QString pixmapName);

QString getTranslationLang();
Expand Down

0 comments on commit e243648

Please sign in to comment.