Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error handling for missing package selector / pattern selector icons #59

Merged
merged 8 commits into from
Nov 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ CMakeCache.txt
CMakeFiles
/CMakeLists.txt
Makefile
cmake_install.cmake
install_manifest.txt
**/*.cmake

# CMake project-bindir
build*/

# Misc
CMakeDoxyfile.in
Doxyfile
libyui-qt-pkg.pc
src/yui-qt-pkg_autogen

# Archives
# It's better to unpack these files and commit the raw source because
# git has its own built in compression methods.
Expand Down
2 changes: 1 addition & 1 deletion VERSION.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SET( VERSION_MAJOR "2" )
SET( VERSION_MINOR "45" )
SET( VERSION_PATCH "22" )
SET( VERSION_PATCH "23" )
SET( VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" )

##### This is need for the libyui core, ONLY.
Expand Down
2 changes: 1 addition & 1 deletion package/libyui-qt-pkg-doc.spec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
%define so_version 9

Name: %{parent}-doc
Version: 2.45.22
Version: 2.45.23
Release: 0
Source: %{parent}-%{version}.tar.bz2

Expand Down
8 changes: 8 additions & 0 deletions package/libyui-qt-pkg.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-------------------------------------------------------------------
Tue Nov 6 15:21:12 UTC 2018 - Stefan Hundhammer <shundhammer@suse.com>

- Better error handling for missing icons (bsc#1114654):
Error message in the y2log plus displaying a small red square for
missing icons.
- 2.45.23

-------------------------------------------------------------------
Mon Oct 29 06:00:36 UTC 2018 - Stasiek Michalski <hellcp@mailbox.org>

Expand Down
2 changes: 1 addition & 1 deletion package/libyui-qt-pkg.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: libyui-qt-pkg
Version: 2.45.22
Version: 2.45.23
Release: 0
Source: %{name}-%{version}.tar.bz2

Expand Down
48 changes: 39 additions & 9 deletions src/YQIconPool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,

#define YUILogComponent "qt-ui"
#include "YUILog.h"
#include "utf8.h"

#include "YQIconPool.h"

using std::endl;



YQIconPool * YQIconPool::_iconPool = 0;
Expand Down Expand Up @@ -113,19 +116,46 @@ YQIconPool::cachedIcon( const QString icon_name, const bool enabled )

if ( !iconPixmap )
{
if ( QIcon::hasThemeIcon(icon_name) )
{
QIcon icon = QIcon::fromTheme(icon_name, QIcon( ":/" + icon_name ));
iconPixmap = icon.pixmap(QSize(16,16), enabled ? QIcon::Normal : QIcon::Disabled);
}
else
iconPixmap = loadIcon( icon_name, enabled );

if ( !iconPixmap )
{
QIcon icon = QIcon( ":/" + icon_name );
iconPixmap = icon.pixmap(QSize(16,16), enabled ? QIcon::Normal : QIcon::Disabled);
// Create an icon for the cache to avoid more than one complaint
// and to have a clearly visible error icon (a small red square)
iconPixmap = QPixmap( 8, 8 );
iconPixmap.fill( Qt::red );
}
}

_iconCache.insert( icon_name + enabled, iconPixmap);
_iconCache.insert( icon_name + enabled, iconPixmap );

return iconPixmap;
}


QPixmap
YQIconPool::loadIcon( const QString icon_name, const bool enabled )
{
QPixmap iconPixmap = _iconCache[ icon_name + enabled ];

if ( QIcon::hasThemeIcon( icon_name ) )
{
yuiDebug() << "Loading theme icon " << icon_name << endl;

QIcon icon = QIcon::fromTheme( icon_name, QIcon( ":/" + icon_name ) );
iconPixmap = icon.pixmap( QSize( 16, 16 ), enabled ? QIcon::Normal : QIcon::Disabled );
}
else
{
yuiDebug() << "Loading built-in icon " << icon_name << endl;

QIcon icon = QIcon( ":/" + icon_name );
iconPixmap = icon.pixmap( QSize( 16, 16 ), enabled ? QIcon::Normal : QIcon::Disabled );
}

if ( !iconPixmap )
yuiError() << "Could not load icon " << icon_name << endl;

return iconPixmap;
}

20 changes: 14 additions & 6 deletions src/YQIconPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ class YQIconPool
static QPixmap disabledPkgProtected();
static QPixmap disabledPkgTaboo();
static QPixmap disabledPkgUpdate();

static QPixmap normalPkgConflict();

static QPixmap treePlus();
static QPixmap treeMinus();

static QPixmap warningSign();
static QPixmap pkgSatisfied();

Expand All @@ -92,12 +92,20 @@ class YQIconPool
static YQIconPool * iconPool();

/**
* Return the cached icon for 'xpm_data' ( an included XPM file ).
* If the icon isn't in the cache yet, create it and store it in the
* cache.
* Return the cached icon for 'icon_name'. If the icon isn't in the cache
* yet, load it and store it in the cache.
*
* Return a red square as an error icon if there is no icon by that name.
**/
QPixmap cachedIcon(const QString icon_name, const bool enabled );

/**
* Load the icon for 'icon_name' from the icon theme or, if that fails,
* from the compiled-in icons (using the Qt resource system). Return a null
* pixmap if there is no such icon.
**/
QPixmap loadIcon( const QString icon_name, const bool enabled );

private:

/**
Expand All @@ -111,7 +119,7 @@ class YQIconPool
**/
virtual ~YQIconPool();


//
// Data members
//
Expand Down
1 change: 0 additions & 1 deletion src/YQPackageSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1850,4 +1850,3 @@ void YQPackageSelector::normalCursor()
}


#include "YQPackageSelector.moc"
1 change: 0 additions & 1 deletion src/YQPackageSelectorBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -514,4 +514,3 @@ YQPkgSelWmCloseHandler::filter( YEvent * event )
}


#include "YQPackageSelectorBase.moc"
1 change: 0 additions & 1 deletion src/YQPatternSelector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,4 +341,3 @@ YQPatternSelector::debugTrace()



#include "YQPatternSelector.moc"
1 change: 0 additions & 1 deletion src/YQPkgChangeLogView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,3 @@ QString YQPkgChangeLogView::notDisplayedChanges(int missing, const std::string &
return msg.arg(QString::number(missing), cmd);
}

#include "YQPkgChangeLogView.moc"
1 change: 0 additions & 1 deletion src/YQPkgChangesDialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,3 @@ YQPkgUnsupportedPackagesDialog::showUnsupportedPackagesDialog( QWidget * parent,
}


#include "YQPkgChangesDialog.moc"
1 change: 0 additions & 1 deletion src/YQPkgConflictDialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -444,4 +444,3 @@ YQPkgConflictDialog::keyPressEvent( QKeyEvent * event )



#include "YQPkgConflictDialog.moc"
1 change: 0 additions & 1 deletion src/YQPkgConflictList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -416,4 +416,3 @@ YQPkgConflict::saveToFile( QFile &file ) const
file.write( "\n\n" );
}

#include "YQPkgConflictList.moc"
1 change: 0 additions & 1 deletion src/YQPkgDependenciesView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,3 @@ YQPkgDependenciesView::htmlLines( const zypp::Capabilities & capSet )
}


#include "YQPkgDependenciesView.moc"
1 change: 0 additions & 1 deletion src/YQPkgDescriptionDialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,3 @@ YQPkgDescriptionDialog::showDescriptionDialog( const QString & pkgName )



#include "YQPkgDescriptionDialog.moc"
1 change: 0 additions & 1 deletion src/YQPkgDescriptionView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,3 @@ void YQPkgDescriptionView::initLang()
}


#include "YQPkgDescriptionView.moc"
1 change: 0 additions & 1 deletion src/YQPkgDiskUsageList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,3 @@ YQPkgWarningRangeNotifier::needWarning() const



#include "YQPkgDiskUsageList.moc"
1 change: 0 additions & 1 deletion src/YQPkgDiskUsageWarningDialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,3 @@ YQPkgDiskUsageWarningDialog::diskUsageWarning( const QString & message,



#include "YQPkgDiskUsageWarningDialog.moc"
1 change: 0 additions & 1 deletion src/YQPkgFileListView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,3 @@ QString YQPkgFileListView::formatFileList( const list<string> & fileList ) const
}


#include "YQPkgFileListView.moc"
1 change: 0 additions & 1 deletion src/YQPkgFilterTab.cc
Original file line number Diff line number Diff line change
Expand Up @@ -728,4 +728,3 @@ YQPkgFilterTab::saveSettings()



#include "YQPkgFilterTab.moc"
1 change: 0 additions & 1 deletion src/YQPkgGenericDetailsView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,3 @@ YQPkgGenericDetailsView::hcell( QString contents )
}


#include "YQPkgGenericDetailsView.moc"
1 change: 0 additions & 1 deletion src/YQPkgHistoryDialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,3 @@ YQPkgHistoryDialog::moveToAction ()
}
}

#include "YQPkgHistoryDialog.moc"
1 change: 0 additions & 1 deletion src/YQPkgLangList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,3 @@ bool YQPkgLangListItem::operator<( const QTreeWidgetItem & otherListViewItem ) c

return QY2ListViewItem::operator<( otherListViewItem );
}
#include "YQPkgLangList.moc"
1 change: 0 additions & 1 deletion src/YQPkgList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -965,4 +965,3 @@ bool YQPkgListItem::operator< ( const QTreeWidgetItem & otherListViewItem ) cons
return YQPkgObjListItem::operator<( otherListViewItem );
}

#include "YQPkgList.moc"
13 changes: 9 additions & 4 deletions src/YQPkgObjList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,12 @@ YQPkgObjList::createActions()
actionSetCurrentKeepInstalled = createAction( S_KeepInstalled, "[<], [-]" );
actionSetCurrentDelete = createAction( S_Del, "[-]" );
actionSetCurrentUpdate = createAction( S_Update, "[>], [+]" );
actionSetCurrentUpdateForce = createAction( _( "Update unconditionally" ), statusIcon( S_Update, true ) ,statusIcon( S_Update, false ) , "", true ) ;

actionSetCurrentUpdateForce = createAction( _( "Update unconditionally" ),
statusIcon( S_Update, true ),
statusIcon( S_Update, false ) ,
"",
true ) ;



Expand Down Expand Up @@ -557,7 +562,7 @@ void
YQPkgObjList::updateActions( YQPkgObjListItem * item )
{
if ( !item)
item = dynamic_cast<YQPkgObjListItem *> ( currentItem() );
item = dynamic_cast<YQPkgObjListItem *> ( currentItem() );

if ( item )
{
Expand Down Expand Up @@ -799,6 +804,7 @@ YQPkgObjList::logExcludeStatistics()
}
}


void
YQPkgObjList::applyExcludeRules( QTreeWidgetItem * listViewItem )
{
Expand Down Expand Up @@ -1655,7 +1661,7 @@ void YQPkgObjList::slotCustomContextMenu(const QPoint& pos)

QMenu * contextMenu =
! item->selectable()->installedEmpty() ?
installedContextMenu() : notInstalledContextMenu();
installedContextMenu() : notInstalledContextMenu();

if ( contextMenu )
contextMenu->popup( viewport()->mapToGlobal( pos ) );
Expand All @@ -1675,4 +1681,3 @@ QTreeWidgetItem * YQPkgObjList::ExcludedItems::oldParentItem( QTreeWidgetItem *



#include "YQPkgObjList.moc"
3 changes: 0 additions & 3 deletions src/YQPkgPackageKitGroupsFilterView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ YQPkgPackageKitGroupsFilterView::fillGroups()
group = itg->second;
}

//std::cout << it.asString() << std::endl;

if ( _groupsMap.find(group) == _groupsMap.end() )
{
_groupsMap[group] = new YQPkgPackageKitGroup( this, group );
Expand Down Expand Up @@ -462,4 +460,3 @@ YQPkgPackageKitGroup::operator< ( const QTreeWidgetItem & otherListViewItem ) co
}


#include "YQPkgPackageKitGroupsFilterView.moc"
1 change: 0 additions & 1 deletion src/YQPkgPatchFilterView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,3 @@ YQPkgPatchFilterView::fillPatchList()
}


#include "YQPkgPatchFilterView.moc"
1 change: 0 additions & 1 deletion src/YQPkgPatchList.cc
Original file line number Diff line number Diff line change
Expand Up @@ -672,4 +672,3 @@ bool YQPkgPatchCategoryItem::operator< ( const QTreeWidgetItem & otherListViewIt



#include "YQPkgPatchList.moc"
Loading