on xenial help sign in
Merge lp:~unity-team/unity8/carouselTool
commit6239b89edb33ca95100a2ab16ea689ee7aa826dc authorMichał Sawicz <michal.sawicz@canonical.com> dateWed 12 Mar 2014, 11:58 (13 years ago) parentdf249c7a252165
3 files changed+79−19
po/tr.po+15−13 qml/Dash/CardTool.qml+44−6 tests/qmltests/Dash/tst_CardTool.qml+20
po/tr.po+15−13
@@ -8,15 +8,15 @@ msgstr ""
88"Project-Id-Version: unity\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2014-02-13 18:37+0000\n"
11−"PO-Revision-Date: 2014-01-14 19:05+0000\n"
12−"Last-Translator: Osman Coşkun <Unknown>\n"
11+"PO-Revision-Date: 2014-03-05 08:54+0000\n"
12+"Last-Translator: Muhammed Yüce <muhammedyuceee@gmail.com>\n"
1313"Language-Team: Turkish <tr@li.org>\n"
1414"MIME-Version: 1.0\n"
1515"Content-Type: text/plain; charset=UTF-8\n"
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=2; plural=n != 1;\n"
18−"X-Launchpad-Export-Date: 2014-02-19 05:44+0000\n"
19−"X-Generator: Launchpad (build 16916)\n"
18+"X-Launchpad-Export-Date: 2014-03-06 06:19+0000\n"
19+"X-Generator: Launchpad (build 16948)\n"
2020
2121#: plugins/Unity/Launcher/launcheritem.cpp:43
2222#: plugins/Unity/Launcher/launcheritem.cpp:73
@@ -29,7 +29,7 @@ msgstr "Başlatıcıdan Ayır"
2929
3030#: qml/Components/EdgeDemoOverlay.qml:151
3131msgid "Skip intro"
32−msgstr "İntro'yu geç"
32+msgstr "Tanıtımı geç"
3333
3434#: qml/Components/EdgeDemo.qml:113
3535msgid "Right edge"
@@ -37,7 +37,7 @@ msgstr "Sağ kenar"
3737
3838#: qml/Components/EdgeDemo.qml:114
3939msgid "Try swiping from the right edge to unlock the phone"
40−msgstr "Kilidi açmak için sağ kenara sürüklemeyi deneyin"
40+msgstr "Kilidi açmak için sağ kenardan sürüklemeyi deneyin"
4141
4242#: qml/Components/EdgeDemo.qml:145
4343msgid "Top edge"
@@ -45,7 +45,7 @@ msgstr "Üst kenar"
4545
4646#: qml/Components/EdgeDemo.qml:146
4747msgid "Try swiping from the top edge to access the indicators"
48−msgstr "Bildiricilere erişmek için üst kenarı sürüklemeyi deneyin"
48+msgstr "Bildiricilere erişmek için üst kenarı sürükleyin"
4949
5050#: qml/Components/EdgeDemo.qml:171
5151msgid "Close"
@@ -73,18 +73,20 @@ msgid ""
7373"You have now mastered the edge gestures and can start using the "
7474"phone<br><br>Tap on the screen to start"
7575msgstr ""
76+"Kenar haraketlerini öğrendiniz ve telefonu kullanmaya "
77+"başlayabilirsiniz<br><br>Başlamak için ekrana dokunun"
7678
7779#: qml/Components/PageHeader.qml:340
7880msgid "Recent searches"
79−msgstr "Son Arananlar"
81+msgstr "Son aramalar"
8082
8183#: qml/Components/SeeMore.qml:35
8284msgid "See more"
83−msgstr ""
85+msgstr "Daha fazlası"
8486
8587#: qml/Components/SeeMore.qml:57
8688msgid "See less"
87−msgstr ""
89+msgstr "Daha azını gör"
8890
8991#: qml/Dash/Apps/AppPreview.qml:136 qml/Dash/Previews/PreviewRating.qml:70
9092msgid "Rate this"
@@ -106,11 +108,11 @@ msgstr[1] "%1 inceleme"
106108
107109#: qml/Dash/Previews/PreviewActionCombo.qml:34
108110msgid "More..."
109−msgstr ""
111+msgstr "Daha fazlası..."
110112
111113#: qml/Dash/Previews/PreviewActionCombo.qml:34
112114msgid "Less..."
113−msgstr ""
115+msgstr "Daha az.."
114116
115117#: qml/Dash/Previews/PreviewRating.qml:114 qml/Dash/Previews/Reviews.qml:74
116118msgid "Add a review"
@@ -167,7 +169,7 @@ msgstr "Parolayı göster"
167169
168170#: qml/Notifications/NotificationMenuItemFactory.qml:103
169171msgid "Please enter SIM PIN"
170−msgstr ""
172+msgstr "Lütfen SIM PIN'inizi girin"
171173
172174#: qml/Panel/SearchIndicator.qml:27
173175msgid "Search"
qml/Dash/CardTool.qml+44−6
@@ -28,6 +28,22 @@ import QtQuick 2.0
2828
2929Item {
3030 id: cardTool
31+
32+ /*!
33+ \brief Number of cards.
34+ */
35+ property int count
36+
37+ /*!
38+ \brief Width of the category view.
39+ */
40+ property real viewWidth
41+
42+ /*!
43+ \brief Scaling factor of selected Carousel item.
44+ */
45+ readonly property real carouselSelectedItemScaleFactor: 1.38 // XXX assuming 1.38 carousel scaling factor for cards
46+
3147 /*!
3248 \brief Template supplied for the category.
3349 */
@@ -39,9 +55,15 @@ Item {
3955 property var components
4056
4157 /*!
42− \brief Width of the view, based on which carousel width is calculated.
58+ \brief The category layout for this card tool.
4359 */
44− property var viewWidth
60+ property string categoryLayout: {
61+ var layout = template["category-layout"];
62+
63+ // carousel fallback mode to grid
64+ if (layout === "carousel" && count <= Math.ceil(carouselTool.realPathItemCount)) layout = "grid";
65+ return layout;
66+ }
4567
4668 /*!
4769 \brief The category layout for this card tool
@@ -71,10 +93,7 @@ Item {
7193 }
7294 return units.gu(18.5);
7395 case "carousel":
74− if (viewWidth === undefined) return undefined
75− if (viewWidth <= units.gu(40)) return units.gu(18)
76− if (viewWidth >= units.gu(128)) return units.gu(26)
77− return units.gu(18 + Math.round((viewWidth - units.gu(40))/ units.gu(11)))
96+ return carouselTool.minimumTileWidth;
7897 case undefined:
7998 case "organic-grid":
8099 case "journal":
@@ -128,6 +147,25 @@ Item {
128147 return (template["card-layout"] === "horizontal") ? Text.AlignLeft : Text.AlignHCenter;
129148 }
130149
150+ QtObject {
151+ id: carouselTool
152+
153+ property real minimumTileWidth: {
154+ if (cardTool.viewWidth === undefined) return undefined;
155+ if (cardTool.viewWidth <= units.gu(40)) return units.gu(18);
156+ if (cardTool.viewWidth >= units.gu(128)) return units.gu(26);
157+ return units.gu(18 + Math.round((cardTool.viewWidth - units.gu(40)) / units.gu(11)));
158+ }
159+
160+ readonly property real pathItemCount: 4.8457 /// (848 / 175) reference values
161+
162+ property real realPathItemCount: {
163+ var scaledMinimumTileWidth = minimumTileWidth / cardTool.carouselSelectedItemScaleFactor;
164+ var tileWidth = Math.max(cardTool.viewWidth / pathItemCount, scaledMinimumTileWidth);
165+ return Math.min(cardTool.viewWidth / tileWidth, pathItemCount);
166+ }
167+ }
168+
131169 Card {
132170 id: card
133171 objectName: "card"
tests/qmltests/Dash/tst_CardTool.qml+20
@@ -93,6 +93,7 @@ Rectangle {
9393 CardTool {
9494 id: cardTool
9595
96+ count: 8
9697 template: Helpers.update(JSON.parse(Helpers.defaultLayout), Helpers.tryParse(layoutArea.text, layoutError))['template'];
9798 components: Helpers.update(JSON.parse(Helpers.defaultLayout), Helpers.tryParse(layoutArea.text, layoutError))['components'];
9899 viewWidth: units.gu(Math.round(widthSlider.value))
@@ -343,5 +344,24 @@ Rectangle {
343344 tryCompare(cardTool, data.property, data.value);
344345 }
345346 }
347+
348+ function test_categoryLayout_data() {
349+ return [
350+ { tag: "Default Grid", layout_index: 0, count: 2, viewWidth: units.gu(40), layout: "grid" },
351+ { tag: "Long carousel", layout_index: 4, count: 6, viewWidth: units.gu(140), layout: "carousel" },
352+ { tag: "Long carousel fallback", layout_index: 4, count: 5, viewWidth: units.gu(140), layout: "grid" },
353+ { tag: "Short carousel", layout_index: 4, count: 4, viewWidth: units.gu(30), layout: "carousel" },
354+ { tag: "Short carousel fallback", layout_index: 4, count: 3, viewWidth: units.gu(30), layout: "grid" },
355+ { tag: "Journal", layout_index: 2, count: 8, viewWidth: units.gu(30), layout: "journal" }
356+ ]
357+ }
358+
359+ function test_categoryLayout(data) {
360+ selector.selectedIndex = 0;
361+ layoutSelector.selectedIndex = data.layout_index;
362+ cardTool.viewWidth = data.viewWidth;
363+ cardTool.count = data.count;
364+ compare(cardTool.categoryLayout, data.layout);
365+ }
346366 }
347367}