on xenial help sign in
Request images from thumbnailer for local results if icon_hint is left empty
fe05f00Michal Hruby
plugins/Unity/categoryresults.cpp+8
@@ -79,6 +79,14 @@ CategoryResults::data(const QModelIndex& index, int role) const
79 return DeeListModel::data(index, ResultsColumn::URI);
79 return DeeListModel::data(index, ResultsColumn::URI);
80 case RoleIconHint: {
80 case RoleIconHint: {
81 QString giconString(DeeListModel::data(index, ResultsColumn::ICON_HINT).toString());
81 QString giconString(DeeListModel::data(index, ResultsColumn::ICON_HINT).toString());
82+ if (giconString.isEmpty()) {
83+ QString uri(DeeListModel::data(index, ResultsColumn::URI).toString());
84+ if (uri.startsWith(QLatin1String("file:///"))) {
85+ QString thumbnailerUri("image://thumbnailer/");
86+ thumbnailerUri.append(uri.midRef(7));
87+ return QVariant::fromValue(thumbnailerUri);
88+ }
89+ }
82 return QVariant::fromValue(gIconToDeclarativeImageProviderString(giconString));
90 return QVariant::fromValue(gIconToDeclarativeImageProviderString(giconString));
83 }
91 }
84 case RoleCategory:
92 case RoleCategory:
tests/plugins/Unity/resultstest.cpp+13−9
@@ -65,26 +65,30 @@ void ResultsTest::testAllColumns()
65
65
66void ResultsTest::testIconColumn_data()
66void ResultsTest::testIconColumn_data()
67{
67{
68+ QTest::addColumn<QString>("uri");
68 QTest::addColumn<QString>("giconString");
69 QTest::addColumn<QString>("giconString");
69 QTest::addColumn<QString>("result");
70 QTest::addColumn<QString>("result");
70
71
72+ QTest::newRow("unspecified") << "test:uri" << "" << "";
71− QTest::newRow("absolute path") << "/usr/share/icons/example.png" << "/usr/share/icons/example.png";
73+ QTest::newRow("absolute path") << "test:uri" << "/usr/share/icons/example.png" << "/usr/share/icons/example.png";
72− QTest::newRow("file uri") << "file:///usr/share/icons/example.png" << "file:///usr/share/icons/example.png";
74+ QTest::newRow("file uri") << "test:uri" << "file:///usr/share/icons/example.png" << "file:///usr/share/icons/example.png";
73− QTest::newRow("http uri") << "http://images.ubuntu.com/example.jpg" << "http://images.ubuntu.com/example.jpg";
75+ QTest::newRow("http uri") << "test:uri" << "http://images.ubuntu.com/example.jpg" << "http://images.ubuntu.com/example.jpg";
74− QTest::newRow("image uri") << "image://thumbnail/with/arguments?passed_to=ImageProvider" << "image://thumbnail/with/arguments?passed_to=ImageProvider";
76+ QTest::newRow("image uri") << "test:uri" << "image://thumbnail/with/arguments?passed_to=ImageProvider" << "image://thumbnail/with/arguments?passed_to=ImageProvider";
75− QTest::newRow("themed icon") << "accessories-other" << "image://theme/accessories-other";
77+ QTest::newRow("themed icon") << "test:uri" << "accessories-other" << "image://theme/accessories-other";
76− QTest::newRow("fileicon") << ". GFileIcon http://example.org/resource.gif" << "http://example.org/resource.gif";
78+ QTest::newRow("fileicon") << "test:uri" << ". GFileIcon http://example.org/resource.gif" << "http://example.org/resource.gif";
77− QTest::newRow("themedicon") << ". GThemedIcon accessories-other accessories generic" << "image://theme/accessories-other,accessories,generic";
79+ QTest::newRow("themedicon") << "test:uri" << ". GThemedIcon accessories-other accessories generic" << "image://theme/accessories-other,accessories,generic";
78− QTest::newRow("annotatedicon") << ". UnityProtocolAnnotatedIcon %7B'base-icon':%20%3C'.%20GThemedIcon%20accessories-other%20accessories%20generic'%3E%7D" << "image://theme/accessories-other,accessories,generic";
80+ QTest::newRow("annotatedicon") << "test:uri" << ". UnityProtocolAnnotatedIcon %7B'base-icon':%20%3C'.%20GThemedIcon%20accessories-other%20accessories%20generic'%3E%7D" << "image://theme/accessories-other,accessories,generic";
81+ QTest::newRow("thumbnailer icon") << "file:///usr/share/samples/video/foo.avi" << "" << "image://thumbnailer//usr/share/samples/video/foo.avi";
79}
82}
80
83
81void ResultsTest::testIconColumn()
84void ResultsTest::testIconColumn()
82{
85{
86+ QFETCH(QString, uri);
83 QFETCH(QString, giconString);
87 QFETCH(QString, giconString);
84 QFETCH(QString, result);
88 QFETCH(QString, result);
85 auto deeModel = createBackendModel();
89 auto deeModel = createBackendModel();
86 dee_model_append (deeModel,
90 dee_model_append (deeModel,
87− "test:uri",
91+ uri.toLocal8Bit().constData(),
88 giconString.toLocal8Bit().constData(),
92 giconString.toLocal8Bit().constData(),
89 0,
93 0,
90 0,
94 0,