1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-15 06:52:34 +02:00

Add rightclick open containing folder

This commit is contained in:
kelteseth 2018-02-23 19:39:12 +01:00
parent 4d1a4c8330
commit 5901ec592a
3 changed files with 38 additions and 5 deletions

View File

@ -1,5 +1,6 @@
import QtQuick 2.9
import QtGraphicalEffects 1.0
import QtQuick.Controls 2.3
Item {
id: screenPlayItem
@ -9,11 +10,12 @@ Item {
property string customTitle: "name here"
property url absoluteStoragePath
property string type
property bool hasMenuOpen: false
onTypeChanged: {
if (type === "widget") {
icnType.source = "qrc:/assets/icons/icon_widgets.svg"
} else if(type === "qmlScene"){
icnType.source = "qrc:/assets/icons/icon_scene.svg"
} else if (type === "qmlScene") {
icnType.source = "qrc:/assets/icons/icon_code.svg"
}
}
@ -125,15 +127,34 @@ Item {
MouseArea {
anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
onEntered: {
screenPlayItem.state = "hover"
if (!hasMenuOpen)
screenPlayItem.state = "hover"
}
onExited: {
screenPlayItem.state = "visible"
if (!hasMenuOpen)
screenPlayItem.state = "visible"
}
onClicked: {
itemClicked(screenId, type)
if (mouse.button === Qt.LeftButton) {
itemClicked(screenId, type)
} else if (mouse.button === Qt.RightButton) {
contextMenu.popup()
hasMenuOpen = true
}
}
}
}
Menu {
id: contextMenu
onClosed: hasMenuOpen = false
MenuItem {
text: qsTr("Open containing folder")
onClicked: {
screenPlaySettings.openFolderInExplorer(absoluteStoragePath)
}
}
}

View File

@ -294,6 +294,17 @@ QString Settings::fixWindowsPath(QString url)
return url.replace("/", "\\\\");
}
void Settings::openFolderInExplorer(QString url)
{
QProcess explorer;
explorer.setProgram("explorer.exe");
QStringList args;
args.append(QDir::toNativeSeparators(url));
explorer.setArguments(args);
explorer.startDetached();
}
void Settings::removeWallpaperAt(int pos)
{
if (pos > 0 && pos > m_wallpapers.size())

View File

@ -54,6 +54,7 @@ public:
Q_INVOKABLE void setPlayAll(bool isPlaying);
Q_INVOKABLE QUrl getPreviewImageByMonitorID(QString id);
Q_INVOKABLE QString fixWindowsPath(QString url);
Q_INVOKABLE void openFolderInExplorer(QString url);
void loadActiveProfiles();