1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00

Cleanup and sidebar integration

This commit is contained in:
kelteseth 2017-04-05 13:04:13 +02:00
parent 502582e5a3
commit 9e49474960
4 changed files with 91 additions and 43 deletions

View File

@ -2,18 +2,18 @@
#include <QDir>
#include <QGuiApplication>
#include <QLibrary>
#include <QModelIndex>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQuickView>
#include <QScreen>
#include <QUrl>
#include <QVariant>
#include <QWindow>
#include <qt_windows.h>
#include <QQmlContext>
#include <QModelIndex>
#include <QVariant>
#include "screenplay.h"
#include "installedlistmodel.h"
#include "screenplay.h"
int main(int argc, char* argv[])
{
@ -25,14 +25,12 @@ int main(int argc, char* argv[])
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
InstalledListModel ilm;
ilm.setData(QModelIndex(),QVariant("ascb"),0);
QQmlApplicationEngine mainWindow;
mainWindow.rootContext()->setContextProperty("installedListModel", &ilm);
mainWindow.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
//ScreenPlay sp(GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN));
int status = app.exec();

View File

@ -3,38 +3,45 @@ import QtGraphicalEffects 1.0
import QtQuick.Controls 2.2
Item {
id:sidebar
id: sidebar
height: 768
width:400
width: 400
state: "inactive"
focus: true
property string activeScreen: ""
onActiveScreenChanged:{
print(activeScreen)
MouseArea {
id: mouseAreaHelper
anchors.fill: parent
enabled: true
}
property string activeScreen: ""
onActiveScreenChanged: {
text1.text = installedListModel.get(activeScreen).screenTitle
image.source = Qt.resolvedUrl(
"file:///" + installedListModel._screensPath + activeScreen
+ "/" + installedListModel.get(activeScreen).screenPreview)
}
Item {
id: sidebarWrapper
anchors {
top:sidebar.top
right:sidebar.right
bottom:sidebar.bottom
left:sidebar.left
top: sidebar.top
right: sidebar.right
bottom: sidebar.bottom
left: sidebar.left
}
Rectangle {
id:sidebarBackground
color: "grey"
id: sidebarBackground
color: "white"
anchors {
top:parent.top
right:parent.right
bottom:parent.bottom
left:parent.left
top: parent.top
right: parent.right
bottom: parent.bottom
left: parent.left
leftMargin: 5
}
@ -47,6 +54,13 @@ Item {
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
Image {
id: image
fillMode: Image.PreserveAspectCrop
asynchronous: true
anchors.fill: parent
}
}
Button {
@ -74,37 +88,53 @@ Item {
}
}
Text {
id: text1
text: ""
anchors.left: parent.left
anchors.leftMargin: 20
anchors.top: parent.top
anchors.topMargin: 267
font.pixelSize: 12
}
}
Rectangle {
id:shadow
id: shadow
anchors {
top:parent.top
right:sidebarBackground.left
bottom:parent.bottom
left:parent.left
top: parent.top
right: sidebarBackground.left
bottom: parent.bottom
left: parent.left
}
LinearGradient {
anchors.fill: parent
start: Qt.point(0, 0)
end: Qt.point(0, 5)
gradient: Gradient {
GradientStop { position: 0.0; color: "#00000000" }
GradientStop { position: 1.0; color: "#22000000" }
GradientStop {
position: 0.0
color: "#00000000"
}
GradientStop {
position: 1.0
color: "#22000000"
}
}
}
}
}
states: [
State {
name: "active"
PropertyChanges {
target: mouseAreaHelper
enabled: true
}
PropertyChanges {
target: sidebarWrapper
anchors.leftMargin: 0
@ -113,6 +143,11 @@ Item {
State {
name: "inactive"
PropertyChanges {
target: mouseAreaHelper
enabled: false
}
PropertyChanges {
target: sidebarWrapper
anchors.leftMargin: sidebar.width
@ -125,6 +160,7 @@ Item {
to: "active"
NumberAnimation {
target: sidebarWrapper
properties: "anchors.leftMargin"
duration: 300
easing.type: Easing.InOutQuad
@ -134,11 +170,11 @@ Item {
to: "inactive"
NumberAnimation {
target: sidebarWrapper
properties: "anchors.leftMargin"
duration: 300
easing.type: Easing.InOutQuad
}
}
]
}

View File

@ -20,10 +20,6 @@ InstalledListModel::InstalledListModel(QObject* parent)
int InstalledListModel::rowCount(const QModelIndex& parent) const
{
// For list models only the root node (an invalid parent) should return the
// list's size. For all
// other (valid) parents, rowCount() should return 0 so that it does not
// become a tree model.
return _screenPlayFiles.count();
}
@ -91,6 +87,24 @@ void InstalledListModel::loadScreens()
if (!(parseError.error == QJsonParseError::NoError))
continue;
append(jsonProject.object(),item.baseName());
append(jsonProject.object(), item.baseName());
}
}
QVariantMap InstalledListModel::get(QString folderId)
{
QVariantMap map;
if (_screenPlayFiles.count() == 0)
return map;
for (int i = 0; i < _screenPlayFiles.count(); i++) {
if (_screenPlayFiles[i]._folderId == folderId) {
map.insert("screenTitle", _screenPlayFiles[i]._title);
map.insert("screenPreview", _screenPlayFiles[i]._preview);
}
}
return map;
}

View File

@ -32,6 +32,7 @@ public:
QHash<int, QByteArray> roleNames() const;
Q_INVOKABLE void loadScreens();
Q_INVOKABLE QVariantMap get(QString folderId);
Q_PROPERTY(QString _screensPath READ name CONSTANT)
enum InstalledRole {
@ -49,7 +50,6 @@ public:
private:
QList<ScreenPlayFile> _screenPlayFiles;
QString _screensPath;
};
class ScreenPlayFile {