~elopio/gallery-app/revert_workaround-1302706-click_toolbar_button_failure

« back to all changes in this revision

Viewing changes to rc/qml/AlbumEditor/AlbumEditor.qml

  • Committer: Leo Arias
  • Date: 2015-05-15 08:05:23 UTC
  • mfrom: (954.1.241 gallery-app)
  • Revision ID: leo.arias@canonical.com-20150515080523-i2of3vr8h7dioj59
Now the toolbar object is not needed at all.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import QtQuick 2.0
22
22
import Gallery 1.0
23
 
import Ubuntu.Components 0.1
 
23
import Ubuntu.Components 1.1
 
24
import Ubuntu.Components.Popups 0.1
24
25
import "../../js/GalleryUtility.js" as GalleryUtility
25
26
import "../../js/GraphicsRoutines.js" as GraphicsRoutines
26
27
import "../AlbumViewer"
32
33
    id: albumEditor
33
34
    objectName: "mainAlbumEditor"
34
35
 
35
 
    title: "Edit album"
36
 
    tools: ToolbarItems {
37
 
        back: Button {
38
 
            objectName: "cancelButton"
39
 
            anchors.verticalCenter: parent.verticalCenter
40
 
            text: i18n.tr("Cancel")
41
 
            width: units.gu(10)
42
 
            onClicked: {
43
 
                albumEditor.closeRequested(albumEditor.album, false);
44
 
            }
 
36
    title: i18n.tr("Edit album")
 
37
    head.backAction: Action {
 
38
        objectName: "cancelButton"
 
39
        text: i18n.tr("Cancel")
 
40
        iconName: "back"
 
41
        onTriggered: {
 
42
            if(album.newAlbum)
 
43
                albumModel.destroyAlbum(album);
 
44
            albumEditor.closeRequested(albumEditor.album, false);
45
45
        }
46
46
    }
47
47
 
77
77
    property variant editorRect
78
78
    /*!
79
79
    */
80
 
    property alias animationRunning: mediaSelector.animationRunning
 
80
    property bool animationRunning: overview.currentPage.animationRunning ? overview.currentPage.animationRunning : false
81
81
 
82
82
    // internal
83
83
    /*!
87
87
    */
88
88
    property real canonicalHeight: units.gu(80)
89
89
 
90
 
    /*!
91
 
    */
92
 
    function editNewAlbum() {
93
 
        albumEditor.album = albumModel.createOrphan();
94
 
        coverMenu.hide()
95
 
    }
 
90
    property Rectangle backgroundGlass: overviewGlass
96
91
 
97
 
    /*!
98
 
    */
99
 
    function editAlbum(album) {
100
 
        albumEditor.album = album;
101
 
        coverMenu.hide()
102
 
    }
 
92
    property bool showAlbumCover: true
103
93
 
104
94
    /*!
105
95
    */
106
96
    function setMediaSelectorScrollPos(newScrollPos) {
107
 
        mediaSelector.setCheckerboardScrollPos(newScrollPos);
 
97
        mediaSelectorComponent.setCheckerboardScrollPos(newScrollPos);
108
98
    }
109
99
 
110
100
    // internal
129
119
        editorRect = GalleryUtility.getRectRelativeTo(cover.internalRect, albumEditor);
130
120
    }
131
121
 
 
122
    Rectangle {
 
123
        id: overviewGlass
 
124
        width: parent.width
 
125
        height: header ? parent.height - header.height : parent.height
 
126
        y: header.height
 
127
 
 
128
        color: "black"
 
129
        opacity: 0.0
 
130
    }
 
131
 
132
132
    onAlbumChanged: resetEditorRect() // HACK: works, but not conceptually correct.
133
133
    onWidthChanged: resetEditorRect()
134
134
    onHeightChanged: resetEditorRect()
135
135
 
136
 
    AlbumCollectionModel {
 
136
    property AlbumCollectionModel model: AlbumCollectionModel {
137
137
        id: albumModel
138
138
    }
139
139
 
172
172
 
173
173
            album: albumEditor.album
174
174
            isPreview: false
 
175
            visible: showAlbumCover
175
176
 
176
177
            onPressed: {
177
178
                mouse.accepted = true;
178
179
                if (!isTextEditing) {
179
 
                    coverMenu.show();
 
180
                    coverMenu = PopupUtils.open(Qt.resolvedUrl("AlbumCoverMenu.qml"), null);
 
181
                    coverMenu.newCoverSelected.connect(function(coverName) {
 
182
                        albumEditor.album.coverNickname = coverName;
 
183
                    });
180
184
                } else {
181
185
                    cover.editingDone()
182
186
                }
184
188
 
185
189
            onIsTextEditingChanged: {
186
190
                // Hide menu when we start editing text.
187
 
                if (isTextEditing && coverMenu.visible)
188
 
                    coverMenu.hide();
189
 
            }
190
 
 
191
 
            onAddPhotos: mediaSelector.show();
192
 
        }
193
 
    }
194
 
 
195
 
    // Cover picker
196
 
    AlbumCoverMenu {
197
 
        id: coverMenu
198
 
        onNewCoverSelected: albumEditor.album.coverNickname = coverName;
199
 
    }
200
 
 
201
 
    MediaSelector {
202
 
        id: mediaSelector
203
 
 
204
 
        onAddClicked: {
205
 
            var album  = albumEditor.album;
206
 
            var firstPhoto = album.addSelectedMediaSources(selection.model.selectedMedias);
207
 
        }
208
 
 
209
 
        onHidden: {
210
 
            albumEditor.closeRequested(albumEditor.album, true);
 
191
                if (isTextEditing && coverMenu.visible) {
 
192
                    PopupUtils.close(coverMenu);
 
193
                }
 
194
            }
 
195
 
 
196
            onAddPhotos: {
 
197
                if (isTextEditing)
 
198
                    cover.editingDone();
 
199
                overview.pushPage(mediaSelectorComponent);
 
200
            }
 
201
        }
 
202
    }
 
203
 
 
204
    property AlbumCoverMenu coverMenu: null
 
205
 
 
206
    Component {
 
207
        id: mediaSelectorComponent
 
208
 
 
209
        MediaSelector {
 
210
            id: mediaSelector
 
211
 
 
212
            onAddClicked: {
 
213
                var album  = albumEditor.album;
 
214
                var firstPhoto = album.addSelectedMediaSources(selection.model.selectedMedias);
 
215
                if(album.newAlbum && selection.model.selectedCount > 0)
 
216
                    album.newAlbum = false;
 
217
            }
 
218
 
 
219
            onHidden: {
 
220
                if(album.newAlbum)
 
221
                    albumModel.destroyAlbum(album);
 
222
                else
 
223
                    albumCollectionModel.addOrphan(album);
 
224
 
 
225
                overview.popPage();
 
226
                albumEditor.closeRequested(albumEditor.album, true);
 
227
            }
211
228
        }
212
229
    }
213
230
}