Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • videolan/vlc
  • chouquette/vlc
  • bakiewicz.marek122/vlc
  • devnexen/vlc
  • rohanrajpal/vlc
  • blurrrb/vlc
  • gsoc/gsoc2019/darkapex/vlc
  • b1ue/vlc
  • fkuehne/vlc
  • magsoft/vlc
  • chub/vlc
  • cramiro9/vlc
  • robUx4/vlc
  • rom1v/vlc
  • akshayaky/vlc
  • tmk907/vlc
  • akymaster/vlc
  • govind.sharma/vlc
  • psilokos/vlc
  • xjbeta/vlc
  • jahan/vlc
  • 1480c1/vlc
  • amanchande/vlc
  • aaqib/vlc
  • rist/vlc
  • apol/vlc
  • mindfreeze/vlc
  • alexandre-janniaux/vlc
  • sandsmark/vlc
  • jagannatharjun/vlc
  • gsoc/gsoc2020/matiaslgonzalez/vlc
  • gsoc/gsoc2020/jagannatharjun/vlc
  • mstorsjo/vlc
  • gsoc/gsoc2020/vedenta/vlc
  • gsoc/gsoc2020/arnav-ishaan/vlc
  • gsoc/gsoc2020/andreduong/vlc
  • fuzun/vlc
  • gsoc/gsoc2020/vatsin/vlc
  • gsoc/gsoc2020/sagid/vlc
  • yaron/vlc
  • Phoenix/vlc
  • Garf/vlc
  • ePiratWorkarounds/vlc
  • tguillem/vlc
  • jnqnfe/vlc
  • mdc/vlc
  • Vedaa/vlc
  • rasa/vlc
  • quink/vlc
  • yealo/vlc
  • aleksey_ak/vlc
  • ePirat/vlc
  • ilya.yanok/vlc
  • asenat/vlc
  • m/vlc
  • bunjee/vlc
  • BLumia/vlc
  • sagudev/vlc
  • hamedmonji30/vlc
  • nullgemm/vlc
  • DivyamAhuja/vlc
  • thesamesam/vlc
  • dag7/vlc
  • snehil101/vlc
  • haasn/vlc
  • jbk/vlc
  • ValZapod/vlc
  • mfkl/vlc
  • WangChuan/vlc
  • core1024/vlc
  • GhostVaibhav/vlc
  • dfuhrmann/vlc
  • davide.prade/vlc
  • tmatth/vlc
  • Courmisch/vlc
  • zouya/vlc
  • hpi/vlc
  • EwoutH/vlc
  • aleung27/vlc
  • hengwu0/vlc
  • saladin/vlc
  • ashuio/vlc
  • richselwood/vlc
  • verma16Ayush/vlc
  • chemicalflash/vlc
  • PoignardAzur/vlc
  • huangjieNT/vlc
  • Blake-Haydon/vlc
  • AnuthaDev/vlc
  • gsoc/gsoc2021/mpd/vlc
  • nicolas_lequec/vlc
  • sambassaly/vlc
  • thresh/vlc
  • bonniegong/vlc
  • myaashish/vlc
  • stavros.vagionitis/vlc
  • ileoo/vlc
  • louis-santucci/vlc
  • cchristiansen/vlc
  • sabyasachi07/vlc
  • AbduAmeen/vlc
  • ashishb0410/vlc
  • urbanhusky/vlc
  • davidepietrasanta/vlc
  • riksleutelstad/vlc
  • jeremyVignelles/vlc
  • komh/vlc
  • iamjithinjohn/vlc
  • JohannesKauffmann/vlc2
  • kunglao/vlc
  • natzberg/vlc
  • jill/vlc
  • cwendling/vlc
  • adufou/vlc
  • ErwanAirone/vlc
  • HasinduDilshan10/vlc
  • vagrantc/vlc
  • rafiv/macos-bigsur-icon
  • Aymeriic/vlc
  • saranshg20/vlc
  • metzlove24/vlc
  • linkfanel/vlc
  • Ds886/vlc
  • metehan-arslan/vlc
  • Skantes/vlc
  • kgsandundananjaya96/vlc
  • mitchcapper/vlc
  • advaitgupta/vlc
  • StefanBruens/vlc
  • ratajs/vlc
  • T.M.F.B.3761/vlc
  • m222059/vlc
  • casemerrick/vlc
  • joshuaword2alt/vlc
  • sjwaddy/vlc
  • dima/vlc
  • Ybalrid/vlc
  • umxprime/vlc
  • eschmidt/vlc
  • vannieuwenhuysenmichelle/vlc
  • badcf00d/vlc
  • wesinator/vlc
  • louis/vlc
  • xqq/vlc
  • EmperorYP7/vlc
  • NicoLiam/vlc
  • loveleen/vlc
  • rofferom/vlc
  • rbultje/vlc
  • TheUnamed/vlc
  • pratiksharma341/vlc
  • Saurab17/vlc
  • purist.coder/vlc
  • Shuicheng/vlc
  • mdrrubel292/vlc
  • silverbleu00/vlc
  • metif12/vlc
  • asher-m/vlc
  • jeffk/vlc
  • Brandonbr1/vlc
  • beautyyuyanli/vlc
  • rego21/vlc
  • muyangren907/vlc
  • collectionbylawrencejason/vlc
  • evelez/vlc
  • GSMgeeth/vlc
  • Oneric/vlc
  • TJ5/vlc
  • XuanTung95/vlc
  • darrenjenny21/vlc
  • Trenly/vlc
  • RockyTDR/vlc
  • mjakubowski/vlc
  • caprica/vlc
  • ForteFrankie/vlc
  • seannamiller19/vlc
  • junlon2006/vlc
  • kiwiren6666/vlc
  • iuseiphonexs/vlc
  • fenngtun/vlc
  • Rajdutt999/vlc
  • typx/vlc
  • leon.vitanos/vlc
  • robertogarci0938/vlc
  • gsoc/gsoc2022/luc65r/vlc-mpd
  • skeller/vlc
  • MCJack123/vlc
  • luc65r/vlc-mpd
  • popov895/vlc
  • claucambra/vlc
  • brad/vlc
  • matthewmurua88/vlc
  • Tomas8874/vlc
  • philenotfound/vlc
  • makita-do3/vlc
  • LZXCorp/vlc
  • mar0x/vlc
  • senojetkennedy0102/vlc
  • shaneb243/vlc
  • ahmadbader/vlc
  • rajduttcse26/vlc-audio-filters
  • Juniorzito8415/vlc
  • achernyakov/vlc
  • lucasjetgroup/vlc
  • pupdoggy666/vlc
  • gmde9363/vlc
  • alexnwayne/vlc
  • bahareebrahimi781/vlc
  • hamad633666/vlc
  • umghof3112/vlc
  • joe0199771874/vlc
  • Octocats66666666/vlc
  • jjm_223/vlc
  • btech10110.19/vlc
  • sunnykfc028/vlc-audio-filters
  • loic/vlc
  • nguyenminhducmx1/vlc
  • JanekKrueger/vlc
  • bstubbington2/vlc
  • rcombs/vlc
  • Ordissimo/vlc
  • king7532/vlc
  • noobsauce101/vlc
  • schong0525/vlc
  • myQwil/vlc
  • apisbg91/vlc
  • geeboy0101017/vlc
  • kim.faughey/vlc
  • nurupo/vlc
  • yyusea/vlc
  • 0711235879.khco/vlc
  • ialo/vlc
  • iloveyeye2/vlc
  • gdtdftdqtd/vlc
  • leandroconsiglio/vlc
  • AndyHTML2012/vlc
  • ncz/vlc
  • lucenticus/vlc
  • knr1931/vlc
  • kjoonlee/vlc
  • chandrakant100/vlc-qt
  • johge42/vlc
  • polter/vlc
  • hexchain/vlc
  • Tushwrld/vlc
  • mztea928/vlc
  • jbelloncastro/vlc
  • alvinhochun/vlc
  • ghostpiratecrow/vlc
  • ujjwaltwitx/vlc
  • alexsonarin06/vlc
  • adrianbon76/vlc
  • altsod/vlc
  • damien.lucas44/vlc
  • dmytrivtaisa/vlc
  • utk202/vlc
  • aaxhrj/vlc
  • thomas.hermes/vlc
  • structurenewworldorder/vlc
  • slomo/vlc
  • wantlamy/vlc
  • musc.o3cminc/vlc
  • thebarshablog/vlc
  • kerrick/vlc
  • kratos142518/vlc
  • leogps/vlc
  • vacantron/vlc
  • luna_koly/vlc
  • Ratio2/vlc
  • anuoshemohammad/vlc
  • apsun/vlc
  • aaa1115910/vlc
  • alimotmoyo/vlc
  • Ambossmann/vlc
  • Sam-LearnsToCode/vlc
  • Chilledheart/vlc
  • Labnann/vlc
  • ktcoooot1/vlc
  • mohit-marathe/vlc
  • johnddx/vlc
  • manstabuk/vlc
  • Omar-ahmed314/vlc
  • vineethkm/vlc
  • 9Enemi86/vlc
  • radoslav.m.panteleev/vlc
  • ashishami2002/vlc
  • Corbax/vlc
  • firnasahmed/vlc
  • pelayarmalam4/vlc
  • c0ff330k/vlc
  • shikhindahikar/vlc
  • l342723951/vlc
  • christianschwandner/vlc
  • douniwan5788/vlc
  • 7damian7/vlc
  • ferdnyc/vlc
  • f.ales1/vlc
  • pandagby/vlc
  • BaaBaa/vlc
  • jewe37/vlc
  • w00drow/vlc
  • russelltg/vlc
  • ironicallygod/vlc
  • soumyaDghosh/vlc
  • linzihao1999/vlc
  • deyayush6/vlc
  • mibi88/vlc
  • newabdallah10/vlc
  • jhorbincolombia/vlc
  • rimvihaqueshupto/vlc
  • andrewkhon98/vlc
  • fab78/vlc
  • lapaz17/vlc
  • amanna13/vlc
  • mdakram28/vlc
  • 07jw1980/vlc
  • sohamgupta/vlc
  • Eson-Jia1/vlc
  • Sumou/vlc
  • vikram-kangotra/vlc
  • chalice191/vlc
  • olivercalder/vlc
  • aaasg4001/vlc
  • zipdox/vlc
  • kwizart/vlc
  • Dragon-S/vlc
  • jdemeule/vlc
  • gabriel_lt/vlc
  • locutusofborg/vlc
  • sammirata/vlc-librist
  • another/vlc
  • Benjamin_Loison/vlc
  • ahmedmoselhi/vlc
  • petergaal/vlc
  • huynhsontung/vlc
  • dariusmihut/vlc
  • tvermaashutosh/vlc
  • buti/vlc
  • Niram7777/vlc
  • rohan-here/vlc
  • balaji-sivasakthi/vlc
  • rlindner81/vlc
  • Kakadus/vlc
  • djain/vlc
  • ABBurmeister/vlc
  • craighuggins/vlc
  • orbea/vlc
  • maxos/vlc
  • aakarshmj/vlc
  • kblaschke/vlc
  • ankitm/vlc
  • advait-0/vlc
  • mohak2003/vlc
  • yselkowitz/vlc
  • AZM999/vlc-azm
  • andrey.turkin/vlc
  • Disha-Baghel/vlc
  • nowrep/vlc
  • Apeng/vlc
  • Choucroute_melba/vlc
  • autra/vlc
  • eclipseo/vlc
  • fhuber/vlc
  • olafhering/vlc
  • sdasda7777/vlc
  • 1div0/vlc
  • skosnits/vlc-extended-playlist-support
  • dnicolson/vlc
  • Timshel/vlc
  • octopols/vlc
  • MangalK/vlc
  • nima64/vlc
  • misawai/vlc
  • Alexander-Wilms/vlc
  • Maxime2/vlc-fork-for-visualizer
  • ww/vlc
  • jeske/vlc
  • sgross-emlix/vlc
  • morenonatural/vlc
  • freakingLovesVLC/vlc
  • borisgolovnev/vlc
  • mpromonet/vlc
  • diogo.simao-marques/vlc
  • masstock/vlc
  • pratikpatel8982/vlc
  • hugok79/vlc
  • longervision/vlc
  • abhiudaysurya/vlc
  • rishabhgarg/vlc
  • tumic/vlc
  • cart/vlc
  • shubham442/vlc
  • Aditya692005/vlc
  • sammirata/vlc4
  • syrykh/vlc
  • Vvorcun/macos-new-icon
  • AyaanshC/vlc
  • nasso/vlc
  • Quark/vlc
  • sebastinas/vlc
  • rhstone/vlc
  • talregev/vlc
  • Managor/vlc
  • abdsaber000/vlc
404 results
Show changes
Commits on Source (9)
Showing
with 307 additions and 478 deletions
......@@ -36,12 +36,6 @@ import "qrc:///dialogs/" as DG
FocusScope {
id: g_mainDisplay
//name and properties of the tab to be initially loaded
property var view: ({
"name": "",
"properties": {}
})
// Properties
property bool hasMiniPlayer: miniPlayer.visible
......@@ -49,6 +43,9 @@ FocusScope {
// NOTE: The main view must be above the indexing bar and the mini player.
property real displayMargin: (height - miniPlayer.y) + (loaderProgress.active ? loaderProgress.height : 0)
//MainDisplay behave as a PageLoader
property alias pagePrefix: stackView.pagePrefix
readonly property int positionSliderY: {
var size = miniPlayer.y + miniPlayer.sliderY
......@@ -61,22 +58,16 @@ FocusScope {
property bool _showMiniPlayer: false
property var _oldViewProperties: ({}) // saves last state of the views
onViewChanged: {
_oldViewProperties[view.name] = view.properties
loadView()
}
Component.onCompleted: {
loadView()
}
// functions
function loadView() {
const found = stackView.loadView(g_mainDisplay.pageModel, g_mainDisplay.view.name, g_mainDisplay.view.properties)
//MainDisplay behave as a PageLoader
function loadView(path, properties, focusReason) {
const found = stackView.loadView(path, properties, focusReason)
if (!found)
return
const item = stackView.currentItem
item.Navigation.parentItem = stackView
sourcesBanner.localMenuDelegate = Qt.binding(function () {
return !!item.localMenuDelegate ? item.localMenuDelegate : null
})
......@@ -95,13 +86,6 @@ FocusScope {
MainCtx.sort.model = Qt.binding(function () { return item.sortModel })
MainCtx.sort.available = Qt.binding(function () { return Array.isArray(item.sortModel) && item.sortModel.length > 0 })
// Restore sourcesBanner state
sourcesBanner.selectedIndex = pageModel.filter(function (e) {
return e.listed
}).findIndex(function (e) {
return e.name === g_mainDisplay.view.name
})
if (Player.hasVideoOutput && MainCtx.hasEmbededVideo)
_showMiniPlayer = true
}
......@@ -242,7 +226,7 @@ FocusScope {
if (_oldViewProperties[name] === undefined)
History.push(["mc", name])
else
History.push(["mc", name, _oldViewProperties[name]])
History.push(["mc", name], _oldViewProperties[name])
}
Navigation.parentItem: medialibId
......@@ -254,7 +238,7 @@ FocusScope {
Layout.fillHeight: true
z: 0
Widgets.StackViewExt {
Widgets.PageLoader {
id: stackView
focus: true
......@@ -271,6 +255,8 @@ FocusScope {
: parent.right
}
pageModel: g_mainDisplay.pageModel
leftPadding: VLCStyle.applicationHorizontalMargin
rightPadding: (MainCtx.playlistDocked && MainCtx.playlistVisible)
......
......@@ -31,6 +31,7 @@ import "qrc:///util/" as Util
import "qrc:///playlist/" as PL
Item {
id: root
property bool _interfaceReady: false
property bool _playlistReady: false
......@@ -49,15 +50,16 @@ Item {
//set the initial view
const loadPlayer = !MainPlaylistController.empty;
if (MainCtx.mediaLibraryAvailable)
History.push(["mc", "video"],
Qt.OtherFocusReason, loadPlayer ? History.Stay : History.Go)
else
History.push(["mc", "home"],
Qt.OtherFocusReason, loadPlayer ? History.Stay : History.Go)
if (loadPlayer)
{
if (MainCtx.mediaLibraryAvailable)
History.update(["mc", "video"])
else
History.update(["mc", "home"])
History.push(["player"])
}
else
_pushHome()
}
function _pushHome() {
......@@ -67,20 +69,13 @@ Item {
History.push(["mc", "home"])
}
function loadCurrentHistoryView() {
const current = History.current
if ( !current || !current.name || !current.properties ) {
console.warn("unable to load requested view, undefined")
return
}
function loadCurrentHistoryView(focusReason) {
contextSaver.save(_oldHistoryPath)
stackView.loadView(_pageModel, current.name, current.properties)
stackView.loadView(History.viewPath, History.viewProp, focusReason)
contextSaver.restore(History.viewPath)
_oldHistoryPath = History.viewPath
MainCtx.mediaLibraryVisible = !History.match(History.viewPath, ["player"])
}
Util.ModelSortSettingHandler {
......@@ -162,7 +157,10 @@ Item {
Connections {
target: History
onCurrentChanged: loadCurrentHistoryView()
onNavigate: (focusReason) => {
loadCurrentHistoryView(focusReason)
MainCtx.mediaLibraryVisible = !History.match(History.viewPath, ["player"])
}
}
Connections {
......@@ -239,12 +237,14 @@ Item {
}
}
Widgets.StackViewExt {
Widgets.PageLoader {
id: stackView
anchors.fill: parent
focus: true
clip: _extendedFrameVisible
pageModel: _pageModel
Connections {
target: Player
onPlayingStateChanged: {
......
......@@ -26,11 +26,9 @@ import "qrc:///widgets/" as Widgets
MusicAlbums {
id: root
onCurrentIndexChanged: {
History.update(["mc","music", "albums", {"initialIndex": currentIndex}])
}
searchPattern: MainCtx.search.pattern
sortCriteria: MainCtx.sort.criteria
sortOrder: MainCtx.sort.order
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
}
......@@ -34,40 +34,28 @@ Widgets.PageLoader {
pageModel: [{
name: "all",
default: true,
component: allArtistsComponent
}, {
name: "albums",
component: artistAlbumsComponent
}]
loadDefaultView: function () {
History.update(["mc", "music", "artists", "all"])
loadPage("all")
}
function _updateArtistsAllHistory(currentIndex) {
History.update(["mc", "music", "artists", "all", { "initialIndex": currentIndex }])
}
function _updateArtistsAlbumsHistory(currentIndex, initialAlbumIndex) {
History.update(["mc","music", "artists", "albums", {
"initialIndex": currentIndex,
"initialAlbumIndex": initialAlbumIndex,
}])
}
Component {
id: allArtistsComponent
MusicAllArtists {
onCurrentIndexChanged: _updateArtistsAllHistory(currentIndex)
searchPattern: MainCtx.search.pattern
sortOrder: MainCtx.sort.order
sortCriteria: MainCtx.sort.criteria
onRequestArtistAlbumView: History.push(["mc", "music", "artists", "albums",
{ initialIndex: currentIndex }], reason)
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
onRequestArtistAlbumView: (reason) => {
History.push([...root.pagePrefix, "albums"], { initialIndex: currentIndex }, reason)
}
}
}
......@@ -75,15 +63,12 @@ Widgets.PageLoader {
id: artistAlbumsComponent
MusicArtistsAlbums {
Navigation.parentItem: root
searchPattern: MainCtx.search.pattern
sortOrder: MainCtx.sort.order
sortCriteria: MainCtx.sort.criteria
onCurrentIndexChanged: _updateArtistsAlbumsHistory(currentIndex, currentAlbumIndex)
onCurrentAlbumIndexChanged: _updateArtistsAlbumsHistory(currentIndex, currentAlbumIndex)
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
onCurrentAlbumIndexChanged: History.viewProp.initialAlbumIndex = currentAlbumIndex
}
}
}
......@@ -35,6 +35,7 @@ Widgets.PageLoader {
pageModel: [{
displayText: I18n.qtr("Artists"),
name: "artists",
default: true,
url: "qrc:///medialibrary/MusicArtistsDisplay.qml"
}, {
displayText: I18n.qtr("Albums"),
......@@ -55,13 +56,8 @@ Widgets.PageLoader {
}
]
loadDefaultView: function () {
History.update(["mc", "music", "artists"])
loadPage("artists")
}
function loadIndex(index) {
History.push(["mc", "music", root.pageModel[index].name])
History.push([...root.pagePrefix, root.pageModel[index].name])
}
property ListModel tabModel: ListModel {
......@@ -75,14 +71,11 @@ Widgets.PageLoader {
}
}
property Component localMenuDelegate: Widgets.LocalTabBar {
currentView: root.view
localMenuDelegate: Widgets.LocalTabBar {
currentView: root.pageName
model: tabModel
onClicked: {
if (root.pageModel[index].name === currentView.name)
return
root.loadIndex(index)
}
}
......
......@@ -30,42 +30,26 @@ Widgets.PageLoader {
pageModel: [{
name: "all",
default: true,
component: genresComponent
}, {
name: "albums",
component: albumGenreComponent
}]
loadDefaultView: function () {
History.update(["mc", "music", "genres", "all"])
loadPage("all")
}
function _updateGenresAllHistory(currentIndex) {
History.update(["mc", "music", "genres", "all", { "initialIndex": currentIndex }])
}
function _updateGenresAlbumsHistory(currentIndex, parentId, genreName) {
History.update(["mc","music", "genres", "albums", {
"initialIndex": currentIndex,
"parentId": parentId,
"genreName": genreName,
}])
}
Component {
id: genresComponent
/* List View */
MusicGenres {
onCurrentIndexChanged: _updateGenresAllHistory(currentIndex)
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
searchPattern: MainCtx.search.pattern
sortOrder: MainCtx.sort.order
sortCriteria: MainCtx.sort.criteria
onShowAlbumView: History.push(["mc", "music", "genres", "albums",
{ parentId: id, genreName: name }], reason)
onShowAlbumView: (id, name, reason) => {
History.push([...root.pagePrefix, "albums"], { parentId: id, genreName: name }, reason)
}
}
}
......@@ -93,9 +77,7 @@ Widgets.PageLoader {
sortOrder: MainCtx.sort.order
sortCriteria: MainCtx.sort.criteria
onParentIdChanged: _updateGenresAlbumsHistory(currentIndex, parentId, genreName)
onGenreNameChanged: _updateGenresAlbumsHistory(currentIndex, parentId, genreName)
onCurrentIndexChanged: _updateGenresAlbumsHistory(currentIndex, parentId, genreName)
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
}
}
}
......@@ -36,34 +36,13 @@ Widgets.PageLoader {
pageModel: [{
name: "all",
default: true,
component: componentAll
}, {
name: "list",
component: componentList
}]
loadDefaultView: function () {
History.update(["mc", "music", "playlists", "all"])
loadPage("all")
}
//---------------------------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------------------------
// Private
function _updateHistoryList(index) {
History.update(["mc", "music", "playlists", "all", { "initialIndex": index }]);
}
function _updateHistoryPlaylist(playlist) {
History.update(["mc", "music", "playlists", "list", {
"initialIndex": playlist.currentIndex,
"parentId" : playlist.parentId,
"name" : playlist.name
}]);
}
//---------------------------------------------------------------------------------------------
// Childs
//---------------------------------------------------------------------------------------------
......@@ -74,16 +53,15 @@ Widgets.PageLoader {
PlaylistMediaList {
isMusic: true
onCurrentIndexChanged: _updateHistoryList(currentIndex)
onShowList: (model, reason) => {
History.push(["mc", "music", "playlists", "list",
{ parentId: model.id, name: model.name }], reason)
}
searchPattern: MainCtx.search.pattern
sortOrder: MainCtx.sort.order
sortCriteria: MainCtx.sort.criteria
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
onShowList: (model, reason) => {
History.push([...root.pagePrefix, "list"], { parentId: model.id, name: model.name }, reason)
}
}
}
......@@ -99,9 +77,7 @@ Widgets.PageLoader {
sortOrder: MainCtx.sort.order
sortCriteria: MainCtx.sort.criteria
onCurrentIndexChanged: _updateHistoryPlaylist(playlist)
onParentIdChanged : _updateHistoryPlaylist(playlist)
onNameChanged : _updateHistoryPlaylist(playlist)
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
}
}
}
......@@ -38,6 +38,7 @@ Widgets.PageLoader {
pageModel: [{
name: "base",
default: true,
component: componentBase
}, {
name: "group",
......@@ -47,29 +48,11 @@ Widgets.PageLoader {
component: componentRecentVideos
}]
loadDefaultView: function () {
History.update(["mc", "video", "all", "base"])
loadPage("base")
}
// Events
onCurrentItemChanged: {
sortMenu = currentItem.sortMenu
}
// Functions private
function _updateHistoryAll(index) {
History.update(["mc", "video", "all", "base", { "initialIndex": index }])
}
function _updateHistoryGroup(group) {
History.update(["mc", "video", "all", "group", {
"initialIndex": group.currentIndex,
"parentId" : group.parentId,
"title" : group.title
}])
}
// Children
......@@ -80,12 +63,10 @@ Widgets.PageLoader {
// Events
onShowList: (model, reason) => {
History.push(["mc", "video", "all", "group",
{ parentId: model.id, title: model.title }], reason)
History.push([...root.pagePrefix, "group"], { parentId: model.id, title: model.title }, reason)
}
onCurrentIndexChanged: root._updateHistoryAll(currentIndex)
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
}
}
......@@ -95,9 +76,7 @@ Widgets.PageLoader {
MediaGroupDisplay {
id: group
onCurrentIndexChanged: root._updateHistoryGroup(group)
onParentIdChanged : root._updateHistoryGroup(group)
onTitleChanged : root._updateHistoryGroup(group)
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
function isInfoExpandPanelAvailable(/* modelIndexData */) {
return true
......
......@@ -46,17 +46,12 @@ Widgets.PageLoader {
}
}
property Component localMenuDelegate: Widgets.LocalTabBar {
currentView: root.view
localMenuDelegate: Widgets.LocalTabBar {
currentView: root.pageName
model: tabModel
onClicked: {
if (root.pageModel[index].name === currentView.name)
return
root.loadIndex(index)
}
onClicked: (index) => History.push([...root.pagePrefix, root.pageModel[index].name])
}
//---------------------------------------------------------------------------------------------
......@@ -65,6 +60,7 @@ Widgets.PageLoader {
pageModel: [{
name: "all",
default: true,
displayText: I18n.qtr("All"),
url: "qrc:///medialibrary/VideoAllDisplay.qml"
},{
......@@ -74,11 +70,6 @@ Widgets.PageLoader {
}
]
loadDefaultView: function () {
History.update(["mc", "video", "all"])
loadPage("all")
}
Accessible.role: Accessible.Client
Accessible.name: I18n.qtr("Video view")
......@@ -86,12 +77,4 @@ Widgets.PageLoader {
// NOTE: We need bindings because the VideoAll model can change over time.
sortMenu = Qt.binding(function () { return currentItem.sortMenu; })
}
//---------------------------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------------------------
function loadIndex(index) {
History.push(["mc", "video", root.pageModel[index].name]);
}
}
......@@ -36,34 +36,13 @@ Widgets.PageLoader {
pageModel: [{
name: "all",
default: true,
component: componentAll
}, {
name: "list",
component: componentList
}]
loadDefaultView: function () {
History.update(["mc", "video", "playlists", "all"])
loadPage("all")
}
//---------------------------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------------------------
// Private
function _updateHistoryList(index) {
History.update(["mc", "video", "playlists", "all", { "initialIndex": index }]);
}
function _updateHistoryPlaylist(playlist) {
History.update(["mc", "video", "playlists", "list", {
"currentIndex": playlist.currentIndex,
"parentId" : playlist.parentId,
"name" : playlist.name
}]);
}
//---------------------------------------------------------------------------------------------
// Childs
//---------------------------------------------------------------------------------------------
......@@ -79,11 +58,10 @@ Widgets.PageLoader {
sortOrder: MainCtx.sort.order
sortCriteria: MainCtx.sort.criteria
onCurrentIndexChanged: _updateHistoryList(currentIndex)
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
onShowList: (model, reason) => {
History.push(["mc", "video", "playlists", "list",
{ parentId: model.id, name: model.name }], reason);
History.push([...root.pagePrefix, "list"], { parentId: model.id, name: model.name }, reason)
}
}
}
......@@ -100,9 +78,7 @@ Widgets.PageLoader {
sortOrder: MainCtx.sort.order
sortCriteria: MainCtx.sort.criteria
onCurrentIndexChanged: _updateHistoryPlaylist(playlist)
onParentIdChanged : _updateHistoryPlaylist(playlist)
onNameChanged : _updateHistoryPlaylist(playlist)
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
}
}
}
......@@ -33,7 +33,8 @@ Widgets.PageLoader {
pageModel: [{
name: "home",
url: "qrc:///network/BrowseHomeDisplay.qml"
default: true,
component: browseHome
}, {
name: "folders",
component: browseFolders,
......@@ -46,37 +47,49 @@ Widgets.PageLoader {
guard: function (prop) { return !!prop.tree }
}]
loadDefaultView: function() {
History.update(["mc", "network", "home"])
loadPage("home")
}
localMenuDelegate: (view.name !== "home") ? componentBar : null
localMenuDelegate: (pageName !== "home") ? componentBar : null
Accessible.role: Accessible.Client
Accessible.name: I18n.qtr("Browse view")
// Connections
Connections {
target: (Helpers.isValidInstanceOf(currentItem, BrowseHomeDisplay)) ? currentItem
: null
onSeeAll: {
if (sd_source === -1)
History.push(["mc", "network", "folders", { title: title }], reason)
else
History.push(["mc", "network", "device", { title: title, sd_source: sd_source }],
reason)
}
//functions
function _showBrowseNode(tree, reason) {
History.push([...root.pagePrefix, "browse"], { tree: tree }, reason)
}
Connections {
target: root.currentItem
function _showHome(reason) {
History.push([...root.pagePrefix, "home"], reason)
}
function _showBrowseFolder(title, reason) {
History.push([...root.pagePrefix, "folders"], { title: title }, reason)
}
onBrowse: History.push(["mc", "network", "browse", { tree: tree }], reason)
function _showBrowseDevices(title, sd_source, reason) {
History.push([...root.pagePrefix, "device"], { title: title, sd_source: sd_source }, reason)
}
// Children
Component {
id: browseHome
BrowseHomeDisplay {
onSeeAllDevices: (title, sd_source, reason) => {
root._showBrowseDevices(title, sd_source, reason)
}
onSeeAllFolders:(title, reason) => {
root._showBrowseFolder(title, reason)
}
onBrowse: (tree, reason) => {
root._showBrowseNode(tree, reason)
}
}
}
Component {
id: browseFolders
......@@ -94,6 +107,10 @@ Widgets.PageLoader {
sortOrder: MainCtx.sort.order
searchPattern: MainCtx.search.pattern
}
onBrowse: (tree, reason) => { root._showBrowseNode(tree, reason) }
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
}
}
......@@ -103,7 +120,7 @@ Widgets.PageLoader {
BrowseDeviceView {
id: viewDevice
property var sd_source
/*required*/ property var sd_source
property var sortModel: [
{ text: I18n.qtr("Alphabetic"), criteria: "name" },
......@@ -122,6 +139,12 @@ Widgets.PageLoader {
sortOrder: MainCtx.sort.order
searchPattern: MainCtx.search.pattern
}
onBrowse: (tree, reason) => {
root._showBrowseNode(tree, reason)
}
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
}
}
......@@ -129,6 +152,9 @@ Widgets.PageLoader {
id: browseComponent
BrowseTreeDisplay {
property alias tree: mediaModel.tree
model: NetworkMediaModel {
id: mediaModel
......@@ -146,6 +172,12 @@ Widgets.PageLoader {
Navigation.cancelAction: function() {
History.previous(Qt.BacktabFocusReason)
}
onBrowse: (tree, reason) => {
root._showBrowseNode(tree, reason)
}
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
}
}
......@@ -153,11 +185,11 @@ Widgets.PageLoader {
id: componentBar
NetworkAddressbar {
path: view.name === "browse" ? root.currentItem.model.path : []
path: root.pageName === "browse" ? root.currentItem.model.path : []
onHomeButtonClicked: History.push(["mc", "network", "home"], reason)
onHomeButtonClicked: root._showHome(reason)
onBrowse: History.push(["mc", "network", "browse", { "tree": tree }], reason)
onBrowse: (tree, reason) => { root._showBrowseNode(tree, reason) }
}
}
}
......@@ -59,7 +59,8 @@ FocusScope {
// Signals
signal seeAll(var title, var sd_source, int reason)
signal seeAllDevices(var title, var sd_source, int reason)
signal seeAllFolders(var title, int reason)
signal browse(var tree, int reason)
......@@ -171,7 +172,7 @@ FocusScope {
onBrowse: root.browse(tree, reason)
onSeeAll: root.seeAll(title, -1, reason)
onSeeAll: root.seeAllFolders(title, reason)
onActiveFocusChanged: _centerFlickableOnItem(foldersSection)
onCurrentIndexChanged: _centerFlickableOnItem(foldersSection)
......@@ -221,7 +222,7 @@ FocusScope {
onBrowse: root.browse(tree, reason)
onSeeAll: root.seeAll(title, model.sd_source, reason)
onSeeAll: root.seeAllDevices(title, model.sd_source, reason)
onActiveFocusChanged: _centerFlickableOnItem(deviceSection)
onCurrentIndexChanged: _centerFlickableOnItem(deviceSection)
......@@ -265,7 +266,7 @@ FocusScope {
onBrowse: root.browse(tree, reason)
onSeeAll: root.seeAll(title, model.sd_source, reason)
onSeeAll: root.seeAllDevices(title, model.sd_source, reason)
onActiveFocusChanged: _centerFlickableOnItem(lanSection)
onCurrentIndexChanged: _centerFlickableOnItem(lanSection)
......
......@@ -32,7 +32,6 @@ MainInterface.MainViewLoader {
// Properties
property var contextMenu
property var tree
readonly property var currentIndex: _currentView.currentIndex
......@@ -66,8 +65,6 @@ MainInterface.MainViewLoader {
History.previous(Qt.BacktabFocusReason)
}
onTreeChanged: model.tree = tree
function playSelected() {
model.addAndPlay(selectionModel.selectedIndexes)
}
......
......@@ -31,6 +31,7 @@ Widgets.PageLoader {
pageModel: [{
displayText: I18n.qtr("Services"),
default: true,
name: "services",
url: "qrc:///network/ServicesHomeDisplay.qml"
}, {
......@@ -40,18 +41,13 @@ Widgets.PageLoader {
}
]
loadDefaultView: function () {
History.update(["mc", "discover", "services"])
loadPage("services")
}
localMenuDelegate: menuDelegate
Accessible.role: Accessible.Client
Accessible.name: I18n.qtr("Discover view")
function loadIndex(index) {
History.push(["mc", "discover", root.pageModel[index].name])
History.push([...root.pagePrefix, root.pageModel[index].name])
}
......@@ -70,11 +66,11 @@ Widgets.PageLoader {
id: menuDelegate
Widgets.LocalTabBar {
currentView: root.view
currentView: root.pageName
model: tabModel
onClicked: {
if (root.pageModel[index].name === currentView.name)
if (root.pageModel[index].name === root.pageName)
return
root.loadIndex(index)
......
......@@ -32,7 +32,8 @@ Widgets.PageLoader {
pageModel: [{
name: "all",
url: "qrc:///network/ServicesSources.qml"
default: true,
component: serviceSourceComponent
}, {
name: "services_manage",
url: "qrc:///network/ServicesManage.qml"
......@@ -45,15 +46,39 @@ Widgets.PageLoader {
guard: function (prop) { return !!prop.tree }
}]
loadDefaultView: function() {
History.update(["mc", "discover", "services", "all"])
loadPage("all")
function _showServiceHome(reason) {
History.push([...root.pagePrefix, "services"], reason)
}
function _showServiceManage(reason) {
History.push([...root.pagePrefix, "services_manage"], reason)
}
function _showServiceRoot(source_name, reason) {
History.push([...root.pagePrefix, "source_root"], { source_name: source_name }, reason)
}
function _showServiceNode(tree, source_name, reason) {
History.push(
[...root.pagePrefix, "source_browse"],
{
tree: tree,
source_name: source_name
},
reason)
}
function setCurrentItemFocus(reason) {
stackView.currentItem.setCurrentItemFocus(reason);
Component {
id: serviceSourceComponent
ServicesSources {
onBrowseServiceManage: (reason) => root._showServiceManage(reason)
onBrowseSourceRoot: (name, reason) => root. _showServiceRoot(name, reason)
}
}
Component {
id: sourceRootComponent
......@@ -63,15 +88,17 @@ Widgets.PageLoader {
property Component localMenuDelegate: NetworkAddressbar {
path: [{display: deviceModel.name, tree: {}}]
onHomeButtonClicked: History.push(["mc", "discover", "services"], reason)
onHomeButtonClicked: _showServiceHome(reason)
}
model: deviceModel
contextMenu: contextMenu
onBrowse: History.push(["mc", "discover", "services", "source_browse",
{ tree: tree, "root_name": deviceModel.name,
"source_name": source_name }], reason)
onBrowse: (tree, reason) => {
root._showServiceNode(tree, deviceModel.source_name, reason)
}
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
NetworkDeviceModel {
id: deviceModel
......@@ -92,7 +119,7 @@ Widgets.PageLoader {
id: sourceBrowseComponent
BrowseTreeDisplay {
property string root_name
property alias tree: mediaModel.tree
property string source_name
property Component localMenuDelegate: NetworkAddressbar {
......@@ -102,20 +129,19 @@ Widgets.PageLoader {
return _path
}
onHomeButtonClicked: History.push(["mc", "discover", "services"], reason)
onHomeButtonClicked: root._showServiceHome(reason)
onBrowse: {
if (!!tree.isRoot)
History.push(["mc", "discover", "services", "source_root",
{ source_name: tree.source_name }], reason)
onBrowse: (tree, reason) => {
if (tree.isRoot)
root._showServiceRoot(source_name, reason)
else
History.push(["mc", "discover", "services", "source_browse",
{ tree: tree, "root": root_name }], reason)
root._showServiceNode(tree, source_name, reason)
}
}
onBrowse: History.push(["mc", "discover", "services", "source_browse",
{ tree: tree, "root": root_name }], reason)
onBrowse: root._showServiceNode(tree, source_name, reason)
onCurrentIndexChanged: History.viewProp.initialIndex = currentIndex
model: NetworkMediaModel {
id: mediaModel
......
......@@ -29,9 +29,18 @@ import "qrc:///style/"
MainInterface.MainGridView {
id: root
//properties
readonly property bool hasGridListMode: false
readonly property bool isSearchable: true
//signals
signal browseServiceManage(int reason)
signal browseSourceRoot(string sourceName, int reason)
//settings
selectionDelegateModel: selectionModel
model: sourcesModel
topMargin: VLCStyle.margin_large
......@@ -82,11 +91,9 @@ MainInterface.MainGridView {
onItemDoubleClicked: {
if (is_dummy)
History.push(["mc", "discover", "services", "services_manage"],
Qt.MouseFocusReason)
root.browseServiceManage(Qt.MouseFocusReason)
else
History.push(["mc", "discover", "services", "source_root",
{ source_name: model.name }], Qt.MouseFocusReason)
root.browseSourceRoot(model.name, Qt.TabFocusReason)
}
onItemClicked : {
......@@ -100,10 +107,9 @@ MainInterface.MainGridView {
const itemData = sourcesModel.getDataAt(index);
if (itemData.type === NetworkSourcesModel.TYPE_DUMMY)
History.push(["mc", "discover", "services", "services_manage"], Qt.TabFocusReason)
browseServiceManage(Qt.TabFocusReason)
else
History.push(["mc", "discover", "services", "source_root",
{ source_name: itemData.name }], Qt.TabFocusReason)
browseSourceRoot(itemData.name, Qt.TabFocusReason)
}
Navigation.cancelAction: function() {
......
......@@ -3,96 +3,46 @@
#include "network/networkmediamodel.hpp"
#include "medialibrary/mlqmltypes.hpp"
NavigationHistory::NavigationHistory(QObject *parent)
: QObject(parent),
m_reason(Qt::OtherFocusReason)
: QObject(parent)
{
}
QVariant NavigationHistory::getCurrent()
{
assert(m_history.isEmpty() == false);
return m_history.back();
}
bool NavigationHistory::isPreviousEmpty()
{
return m_history.count() <= 1;
return m_history.size() <= 1;
}
void NavigationHistory::push(QVariantMap item, Qt::FocusReason reason, PostAction postAction)
void NavigationHistory::push(QStringList path, const QVariantMap& properties, Qt::FocusReason focusReason)
{
m_history.push_back(item);
emit previousEmptyChanged(false);
if (postAction == PostAction::Go)
{
updateViewPath();
auto prop = std::make_unique<QQmlPropertyMap>();
for (auto it = properties.keyValueBegin(); it != properties.keyValueEnd(); ++it)
prop->insert((*it).first, (*it).second);
m_reason = reason;
m_history.emplace_back(path, std::move(prop));
emit currentChanged(m_history.back());
}
}
updateCurrent();
static void pushListRec(QVariantMap& itemMap, QVariantList::const_iterator it, QVariantList::const_iterator end )
{
if (it == end)
return;
if(it->canConvert<QString>())
{
QVariantMap subViewMap;
subViewMap["name"] = it->toString();
QVariantMap subViewProperties;
pushListRec(subViewProperties, ++it, end);
subViewMap["properties"] = subViewProperties;
itemMap["view"] = subViewMap;
}
else if ( it->canConvert<QVariantMap>() )
{
QVariantMap varMap = it->toMap();
for (auto kv = varMap.constBegin(); kv != varMap.constEnd(); ++kv )
itemMap[kv.key()] = kv.value();
pushListRec(itemMap, ++it, end);
}
if (m_history.size() == 2)
emit previousEmptyChanged(false);
emit navigate(focusReason);
}
static void addLeafRec(QVariant &item, const QVariantMap &leaf)
void NavigationHistory::push(QStringList path, Qt::FocusReason focusReason)
{
auto itemMap = item.toMap();
if (itemMap.contains("view"))
{
QVariant viewProps = itemMap.value("view");
addLeafRec(viewProps, leaf);
itemMap["view"] = viewProps;
}
else if (itemMap.contains("properties"))
{
QVariant propsVar = itemMap.value("properties");
const auto propsMap = propsVar.toMap();
if (propsMap.empty())
{
itemMap["properties"] = leaf;
}
else
{
addLeafRec(propsVar, leaf);
itemMap["properties"] = propsVar;
}
}
else
{
// invalid node?
return;
}
m_history.emplace_back(path, std::make_unique<QQmlPropertyMap>());
//overwrite item QVariant
item = itemMap;
}
updateCurrent();
if (m_history.size() == 2)
emit previousEmptyChanged(false);
emit navigate(focusReason);
}
static bool isNodeValid(QVariant& value)
static bool isNodeValid(const QVariant& value)
{
if (value.canConvert(QVariant::StringList)
|| value.canConvert(QVariant::StringList)
......@@ -107,7 +57,8 @@ static bool isNodeValid(QVariant& value)
else if ( value.canConvert(QVariant::List) )
{
QVariantList valueList = value.toList();
for (QVariant& v : valueList) {
for (QVariant& v : valueList)
{
if (!isNodeValid(v))
return false;
}
......@@ -117,18 +68,17 @@ static bool isNodeValid(QVariant& value)
{
NetworkTreeItem item = value.value<NetworkTreeItem>();
if ( ! item.isValid() )
{
return false;
}
return true;
}
else if ( value.canConvert(QVariant::Map) )
{
QVariantMap valueList = value.toMap();
for (QVariant& v : valueList.values()) {
if (!isNodeValid(v)) {
for (QVariant& v : valueList.values())
{
if (!isNodeValid(v))
return false;
}
}
return true;
}
......@@ -137,91 +87,81 @@ static bool isNodeValid(QVariant& value)
return false;
}
static QStringList getViewPath(QVariantMap map)
static bool isNodeValid(const QQmlPropertyMap& value)
{
QStringList r;
if (map.contains("view"))
return getViewPath(map.value("view").toMap());
else if (map.contains("name"))
for (auto it: value.keys())
{
r = QStringList( map.value("name").toString() );
r.append(std::move(getViewPath(map.value("properties").toMap())));
if (!isNodeValid(value[it]))
return false;
}
return r;
return true;
}
void NavigationHistory::push(QVariantList itemList, Qt::FocusReason reason,
NavigationHistory::PostAction postAction)
{
QVariantMap itemMap;
pushListRec(itemMap, itemList.cbegin(), itemList.cend());
if (!itemMap.contains("view"))
return;
QVariant rootView = itemMap["view"];
if (!rootView.canConvert(QVariant::Map))
return;
push(rootView.toMap(), reason, postAction);
}
void NavigationHistory::update(QVariantMap item)
void NavigationHistory::update(QStringList path)
{
assert(m_history.size() >= 1);
m_history.back() = item;
updateViewPath();
if (m_history.size() == 0)
{
m_history.emplace_back(path, std::make_unique<QQmlPropertyMap>());
}
else
{
auto& last = *m_history.rbegin();
last.first = path;
}
updateCurrent();
}
void NavigationHistory::update(QVariantList itemList)
void NavigationHistory::update(QStringList path, const QVariantMap& properties)
{
QVariantMap itemMap;
pushListRec(itemMap, itemList.cbegin(), itemList.cend());
if (!itemMap.contains("view"))
return;
QVariant rootView = itemMap["view"];
if (!rootView.canConvert(QVariant::Map))
return;
update(rootView.toMap());
if (m_history.size() == 0)
{
auto prop = std::make_unique<QQmlPropertyMap>();
for (auto it = properties.keyValueBegin(); it != properties.keyValueEnd(); ++it)
{
prop->insert((*it).first, (*it).second);
}
m_history.emplace_back(path, std::move(prop));
}
else
{
auto& last = *m_history.rbegin();
last.first = path;
}
updateCurrent();
}
void NavigationHistory::addLeaf(QVariantMap itemMap)
{
assert(m_history.size() >= 1);
addLeafRec(m_history.back(), itemMap);
updateViewPath();
}
void NavigationHistory::previous(Qt::FocusReason reason, PostAction postAction)
void NavigationHistory::previous(Qt::FocusReason reason)
{
if (m_history.count() == 1)
if (m_history.size() == 1)
return;
m_history.pop_back();
while (!isNodeValid(m_history.back())) {
while (!isNodeValid(*m_history.back().second)) {
m_history.pop_back();
if (m_history.count() == 1)
if (m_history.size() == 1)
break;
}
if (m_history.count() == 1)
if (m_history.size() == 1)
emit previousEmptyChanged(true);
if (postAction == PostAction::Go) {
updateViewPath();
m_reason = reason;
emit currentChanged( m_history.back() );
}
updateCurrent();
emit navigate(reason);
}
void NavigationHistory::updateViewPath()
void NavigationHistory::updateCurrent()
{
const auto viewPath = getViewPath(getCurrent().toMap());
if (viewPath == m_viewPath)
return;
assert(m_history.size() >= 1);
const auto it = m_history.rbegin();
m_viewPath = viewPath;
emit viewPathChanged( m_viewPath );
m_viewPath = it->first;
m_viewProperties = it->second.get();
emit viewPathChanged(m_viewPath);
emit viewPropChanged(m_viewProperties);
}
QStringList NavigationHistory::viewPath() const
......@@ -229,13 +169,9 @@ QStringList NavigationHistory::viewPath() const
return m_viewPath;
}
Qt::FocusReason NavigationHistory::takeFocusReason()
QQmlPropertyMap* NavigationHistory::viewProp() const
{
Qt::FocusReason reason = m_reason;
m_reason = Qt::OtherFocusReason;
return reason;
return m_viewProperties;
}
Q_INVOKABLE bool NavigationHistory::match(const QStringList& path, const QStringList& pattern)
......
#ifndef NAVIGATION_HISTORY_HPP
#define NAVIGATION_HISTORY_HPP
#include <memory>
#include <QObject>
#include <QtQml/QQmlPropertyMap>
......@@ -8,9 +10,17 @@ class NavigationHistory : public QObject
{
Q_OBJECT
public:
Q_PROPERTY(QVariant current READ getCurrent NOTIFY currentChanged FINAL)
Q_PROPERTY(bool previousEmpty READ isPreviousEmpty NOTIFY previousEmptyChanged FINAL)
/**
* current path
*/
Q_PROPERTY(QStringList viewPath READ viewPath NOTIFY viewPathChanged FINAL)
/**
* properties of the current view,
* * properties that are pushed will be accessible thru this property
* * views may store values in this property, they will be restored when navigating back
*/
Q_PROPERTY(QQmlPropertyMap* viewProp READ viewProp NOTIFY viewPropChanged FINAL)
enum class PostAction{
Stay,
......@@ -24,90 +34,57 @@ public:
QVariant getCurrent();
bool isPreviousEmpty();
QStringList viewPath() const;
// NOTE: The first item to call this takes ownership over the focus reason.
Q_INVOKABLE Qt::FocusReason takeFocusReason();
QQmlPropertyMap* viewProp() const;
Q_INVOKABLE bool match(const QStringList& path, const QStringList& pattern);
Q_INVOKABLE bool exactMatch(const QStringList& path, const QStringList& pattern);
signals:
void currentChanged(QVariant current);
void navigate(Qt::FocusReason);
void previousEmptyChanged(bool empty);
void viewPathChanged(const QStringList& viewPath);
void viewPropChanged(QQmlPropertyMap*);
public slots:
/**
* Push a
*
* \code
* push({
* name: "foo", //push the view foo
* properties: {
* view: { //the sub view "bar"
* name: "bar",
* properties: {
* baz: "plop" //the property baz will be set in the view "bar"
* }
* }
* }
* }, History.Go)
* \endcode
*/
Q_INVOKABLE void push( QVariantMap, Qt::FocusReason = Qt::OtherFocusReason,
PostAction = PostAction::Go );
/**
* provide a short version of the history push({k:v}), which implicitly create a dictonnary tree from the input list
*
* List items are interpreted as
* * strings will push a dict with "view" key to the value of the string and
* a "viewProperties" dict configured with the tail of the list
* navigate to a new page
*
* * dict: values will be added to the current viewProperty
* @param path: path of the page to load
* @param properties: values that will be set to the current viewProp
*
* example:
* \code
* //push the view foo, then bar, set baz to plop in the view "bar"
* push(["foo", "bar", {baz: "plop"} ], History.Go)
* push(["foo", "bar"], {baz: "plop"})
* \endcode
*/
Q_INVOKABLE void push(QVariantList itemList, Qt::FocusReason = Qt::OtherFocusReason,
PostAction = PostAction::Go );
Q_INVOKABLE void push(QStringList path, const QVariantMap& properties, Qt::FocusReason focusReason = Qt::OtherFocusReason);
Q_INVOKABLE void push(QStringList path, Qt::FocusReason focusReason = Qt::OtherFocusReason);
/**
* @brief same as @a push(QVariantMap) but modify the last (current) item instead of insterting a new one
*
* @see push
*/
Q_INVOKABLE void update(QVariantMap itemList);
/**
* @brief same as @a push(QVariantList) but modify the last (current) item instead of insterting a new one
* @brief modify the current history path
*
* @see push
* @note:
* * invoking update won't cause page to be reloaded, this mainly affects history
* * invoking update when there is no path will create a node (the initial history node)
*/
Q_INVOKABLE void update(QVariantList itemList);
Q_INVOKABLE void update(QStringList path);
/**
* @brief same as @a push(QVariantList) but modify the last (current) item's tail instead of insterting a new one
*
* @see push
*/
Q_INVOKABLE void addLeaf(QVariantMap itemMap);
Q_INVOKABLE void update(QStringList path, const QVariantMap& properties);
// Go to previous page
void previous( Qt::FocusReason = Qt::OtherFocusReason, PostAction = PostAction::Go );
/// Go to previous page
void previous(Qt::FocusReason = Qt::OtherFocusReason);
private:
void updateViewPath();
void updateCurrent();
QVariantList m_history;
std::vector<std::pair<QStringList, std::unique_ptr<QQmlPropertyMap>>> m_history;
QStringList m_viewPath;
Qt::FocusReason m_reason;
QQmlPropertyMap* m_viewProperties = nullptr;
};
#endif // NAVIGATION_HISTORY_HPP
......@@ -77,7 +77,7 @@ T.TabButton {
id: theme
colorSet: ColorContext.TabButton
focused: control.activeFocus
focused: control.visualFocus
hovered: control.hovered
pressed: control.down
enabled: control.enabled
......
......@@ -158,7 +158,7 @@ T.ItemDelegate {
id: theme
colorSet: ColorContext.Item
focused: root.activeFocus
focused: root.visualFocus
hovered: root.hovered
}
......