Skip to content
Snippets Groups Projects
Commit 0a44437c authored by Prince Gupta's avatar Prince Gupta :speech_balloon: Committed by Pierre Lamot
Browse files

qml: fix context menu for NetworkBrowseDisplay

parent 340b7386
No related branches found
No related tags found
No related merge requests found
......@@ -213,6 +213,7 @@ void MainUI::registerQMLTypes()
qmlRegisterType<QmlGlobalMenu>( "org.videolan.vlc", 0, 1, "QmlGlobalMenu" );
qmlRegisterType<NetworkMediaContextMenu>( "org.videolan.vlc", 0, 1, "NetworkMediaContextMenu" );
qmlRegisterType<NetworkDeviceContextMenu>( "org.videolan.vlc", 0, 1, "NetworkDeviceContextMenu" );
qmlRegisterType<PlaylistContextMenu>( "org.videolan.vlc", 0, 1, "PlaylistContextMenu" );
}
......
......@@ -25,6 +25,7 @@
#include "medialibrary/mlgenremodel.hpp"
#include "medialibrary/mlalbumtrackmodel.hpp"
#include "medialibrary/mlurlmodel.hpp"
#include "network/networkdevicemodel.hpp"
#include "network/networkmediamodel.hpp"
#include "playlist/playlist_controller.hpp"
#include "playlist/playlist_model.hpp"
......@@ -278,6 +279,33 @@ void NetworkMediaContextMenu::popup(const QModelIndexList& selected, QPoint pos)
menu->popup(pos);
}
NetworkDeviceContextMenu::NetworkDeviceContextMenu(QObject* parent)
: QObject(parent)
{}
void NetworkDeviceContextMenu::popup(const QModelIndexList& selected, QPoint pos)
{
if (!m_model)
return;
QMenu* menu = new QMenu();
QAction* action;
menu->setAttribute(Qt::WA_DeleteOnClose);
action = menu->addAction( qtr("Add and play") );
connect(action, &QAction::triggered, [this, selected]( ) {
m_model->addAndPlay(selected);
});
action = menu->addAction( qtr("Enqueue") );
connect(action, &QAction::triggered, [this, selected]( ) {
m_model->addToPlaylist(selected);
});
menu->popup(pos);
}
PlaylistContextMenu::PlaylistContextMenu(QObject* parent)
: QObject(parent)
{}
......
......@@ -32,6 +32,7 @@ class MLArtistModel;
class MLAlbumTrackModel;
class MLUrlModel;
class MLVideoModel;
class NetworkDeviceModel;
class NetworkMediaModel;
class QmlMainContext;
namespace vlc {
......@@ -156,6 +157,15 @@ public slots:
void popup(const QModelIndexList& selected, QPoint pos );
};
class NetworkDeviceContextMenu : public QObject {
Q_OBJECT
SIMPLE_MENU_PROPERTY(NetworkDeviceModel*, model, nullptr)
public:
NetworkDeviceContextMenu(QObject* parent = nullptr);
public slots:
void popup(const QModelIndexList& selected, QPoint pos );
};
class PlaylistContextMenu : public QObject {
Q_OBJECT
......
......@@ -33,6 +33,7 @@ Widgets.NavigableFocusScope {
id: root
property var providerModel
property var contextMenu
property var tree
onTreeChanged: providerModel.tree = tree
readonly property var currentIndex: view.currentItem.currentIndex
......@@ -48,11 +49,6 @@ Widgets.NavigableFocusScope {
model: providerModel
}
NetworkMediaContextMenu {
id: contextMenu
model: providerModel
}
function resetFocus() {
var initialIndex = root.initialIndex
if (initialIndex >= providerModel.count)
......
......@@ -47,7 +47,7 @@ Widgets.NavigableFocusScope {
page ="qrc:///network/NetworkHomeDisplay.qml"
else {
page = "qrc:///network/NetworkBrowseDisplay.qml"
props = { providerModel: mediaModel, tree: root.tree }
props = { providerModel: mediaModel, contextMenu: mediaContextMenu, tree: root.tree }
}
view.replace(page, props)
}
......@@ -58,6 +58,12 @@ Widgets.NavigableFocusScope {
ctx: mainctx
}
NetworkMediaContextMenu {
id: mediaContextMenu
model: mediaModel
}
Widgets.StackViewExt {
id: view
anchors.fill:parent
......
......@@ -21,6 +21,7 @@ import QtQml.Models 2.2
import QtQuick.Layouts 1.11
import QtQuick.Shapes 1.0
import org.videolan.vlc 0.1
import org.videolan.medialib 0.1
import "qrc:///widgets/" as Widgets
......@@ -76,6 +77,7 @@ Widgets.NavigableFocusScope {
property alias source_name: deviceModel.source_name
providerModel: deviceModel
contextMenu: contextMenu
function changeTree(new_tree) {
history.push(["mc", "discover", "services", "source_browse", { tree: new_tree }]);
......@@ -87,6 +89,12 @@ Widgets.NavigableFocusScope {
ctx: mainctx
sd_source: NetworkDeviceModel.CAT_INTERNET
}
NetworkDeviceContextMenu {
id: contextMenu
model: deviceModel
}
}
}
......@@ -95,6 +103,7 @@ Widgets.NavigableFocusScope {
NetworkBrowseDisplay {
providerModel: mediaModel
contextMenu: contextMenu
function changeTree(new_tree) {
history.push(["mc", "discover", "services", "source_browse", { tree: new_tree }]);
......@@ -105,6 +114,12 @@ Widgets.NavigableFocusScope {
ctx: mainctx
}
NetworkMediaContextMenu {
id: contextMenu
model: mediaModel
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment