~ci-train-bot/ubuntu-ui-toolkit/ubuntu-ui-toolkit-ubuntu-yakkety-2069

« back to all changes in this revision

Viewing changes to src/Ubuntu/UbuntuToolkit/ucunits.cpp

  • Committer: Bileto Bot
  • Date: 2016-08-14 09:06:34 UTC
  • mfrom: (1000.985.35 OTA13-2016-06-29)
  • Revision ID: ci-train-bot@canonical.com-20160814090634-uoxtg7ektrlidwh6
* Fix OptionSelectorTestCase tests.
* Fix more OptionSelector autopilot tests
* Disable documentation building for GLES builds. Fixes LP: #1606222.
* Replace abs with qFabs due to GCC6 breakage. Fixes LP: #1610943.
* Limit s390x dependencies more due to upstart/s390x problems and removed
  packages in archives. Fixes LP: #1610951
* ListItemLayout doc: add elide mode change example and add section about
  labels default properties values. Fixes LP: #1603450.
* ListItemLayout doc: add explicit note about the need to bind ListItem's
  height to layout's height.
* More Scrollbar optimizations: 20% faster creation time. Fixes LP: #1606451
* Scrollbar: fix wrong thumb color on tap/mouse release and increase coverage
  of hover states unit tests. Fixes LP: #1608897
* Fix null pointer property initializer used with 1.3 PageWrapper. 
  Fixes LP: #1604780.
* Fix BottomEdge content URL preloading. Fixes LP: #1604509.
* UCUnits::resolveResource: Prefer image path if it exists. This saves
  searching the disk for @gu images, which is a big speedup. According to
  callgrind loading 100 images from a folder that contains 380 images goes
  from around 3 million instructions per UCUnits::resolveResource call down
  to around 10 thousand. This optimization is ok since it is not correct to
  ship both image.png and image@20.png. You either have to ship gu-enabled
  files or not, but mixing them is not allowed. Searched for cases in which
  that may be happening in my phone and found none. Fixes LP: #1604029.
* Configure colors of the buttons in the ActionBar and PageHeader through
  their Styles. Fixes LP: #1597774.
* Fix assigning of constant values to a grouped property in StyleHints.
  Fixes LP: #1602836.
* Fix list view keyboard navigation for RightToLeft and BottomToTop 
  directions. Fixes LP: #1605634
* Use external QML files instead of embedded QML strings for autopilot tests.
  Fixes LP: #1578319
* Fix failing autopilot header tests.
* Fix ActionSelectionPopover Autopilot CPO tests.
* Include indexes in "offline" docs and filter out link errors.
  Fixes LP: #1603937.
* Increase focus ring thickness from 1dp to 2dp. Fixes LP: #1602690.
* Add a snippet about tests to the toplevel README
* Enter/Return to trigger, Space to expand ComboButton. Fixes LP: #1523817.
* Initialize engine variable before using it in the _engine case.
* Use Qt.rgba instead of #0000 checking ListItem default color. 
  Fixes LP: #1560004
* Don't use a different .desktop file in the gallery tests.
  Fixes LP: #1578319
* Update scaling docs, set QT_SCALE_FACTOR and unset GRID_UNIT_PX.
  Fixes LP: #1610208
* Sections: load Icons asynchronously.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
*/
72
72
 
73
73
/*
74
 
 * Note on the interaction between GRID_UNIT_PX and QT_DEVICE_PIXEL_RATIO
 
74
 * In Qt5.6 the following variables affect scaling in QWidget and QML:
 
75
 *   1. QT_SCALE_FACTOR: global integer scale factor, including point-sized fonts
 
76
 *   2. QT_SCREEN_SCALE_FACTORS: a list of scale factors
 
77
 *   3. QT_AUTO_SCREEN_SCALE_FACTOR: enables automatic scaling heuristics
75
78
 *
76
79
 * In Qt5.4 there is a single means to scale the UI: the QT_DEVICE_PIXEL_RATIO environment
77
80
 * variable. This accepts only integer values, thus allowing a x2 or x3 scaling of any
78
81
 * Qt-based UI, that includes QWidget as well as any QML UI.
79
82
 *
80
 
 * Setting QT_DEVICE_PIXEL_RATIO=2 implies one density-independent pixel corresponds to 2
81
 
 * physical pixels. Developers describe their UI in terms of density-independent pixels.
82
 
 * Qt scales accordingly.
83
 
 *
84
83
 * The Ubuntu UI Toolkit has solved the scaling problem with the GRID_UNIT_PX variable.
85
84
 * It offers more flexibility, but only scales QML applications written to use the UITK
86
85
 * (since it uses this Units class) as it is built on top of QML.
184
183
        return QString();
185
184
    }
186
185
 
187
 
    QFileInfo fileInfo(path);
188
 
    if (fileInfo.exists() && !fileInfo.isFile()) {
189
 
        return QString();
 
186
    const QFileInfo fileInfo(path);
 
187
    if (fileInfo.exists()) {
 
188
        if (fileInfo.isFile()) {
 
189
            return QStringLiteral("1/") + path;
 
190
        } else {
 
191
            return QString();
 
192
        }
190
193
    }
191
194
 
192
 
    QString prefix = fileInfo.dir().absolutePath() + "/" + fileInfo.baseName();
193
 
    QString suffix = "." + fileInfo.completeSuffix();
 
195
    const QString prefix = fileInfo.dir().absolutePath() + "/" + fileInfo.baseName();
 
196
    const QString suffix = "." + fileInfo.completeSuffix();
194
197
 
195
198
    /* Use file with expected grid unit suffix if it exists.
196
199
       For example, if m_gridUnit = 10, look for resource@10.png.
198
201
 
199
202
    path = prefix + suffixForGridUnit(m_gridUnit) + suffix;
200
203
    if (QFile::exists(path)) {
201
 
        return QString("1") + "/" + path;
 
204
        return QStringLiteral("1/") + path;
202
205
    }
203
206
 
204
207
    /* No file with expected grid unit suffix exists.
219
222
    */
220
223
    QStringList nameFilters;
221
224
    nameFilters << fileInfo.baseName() + "@[0-9]*" + suffix;
222
 
    QStringList files = fileInfo.dir().entryList(nameFilters, QDir::Files);
 
225
    const QStringList files = fileInfo.dir().entryList(nameFilters, QDir::Files);
223
226
 
224
227
    if (!files.empty()) {
225
228
        float selectedGridUnitSuffix = gridUnitSuffixFromFileName(files.first());
237
240
        return QString::number(scaleFactor) + "/" + path;
238
241
    }
239
242
 
240
 
    path = prefix + suffix;
241
 
    if (QFile::exists(path)) {
242
 
        return QString("1") + "/" + path;
243
 
    }
244
 
 
245
243
    return QString();
246
244
}
247
245