Unverified Commit ed0cf291 authored by Mikhail Tergoev's avatar Mikhail Tergoev Committed by GitHub

Merge pull request #2 from yageorgiy/main

QtQuick.Controls used for Button template, tabs switching with simple template, UI constants; Desktop files list, UI changes
parents dcaf96fa a76df063
import QtQuick import QtQuick
import QtQuick.Controls as C
Rectangle { C.Button {
id: rectangle
// control.down
// control.activeFocus
id: control
width: 150 width: 150
height: 50 height: 50
radius: 5 text: qsTr("Button")
color: "#ffffff"
Text { contentItem: Text {
id: text1 text: control.text
text: qsTr("Text") font: control.font
anchors.fill: parent opacity: enabled ? 1.0 : 0.3
font.pixelSize: 12 color: control.down ? "#000000" : (control.activeFocus ? "#ff0000" : "#555555")
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
background: Rectangle {
implicitWidth: 100
implicitHeight: 40
opacity: enabled ? 1 : 0.3
border.color: control.down ? "#000000" : (control.activeFocus ? "#ff0000" : "#555555")
border.width: 1
radius: 8
} }
} }
import QtQuick import QtQuick
import "../constants/tabs.js" as TabConstants
Rectangle { Rectangle {
// PROPERTIES
property string currentTab: TabConstants.systemManagementTab
// FIELDS
id: tabs id: tabs
x: 0 x: 0
y: 0 y: 0
...@@ -8,16 +13,52 @@ Rectangle { ...@@ -8,16 +13,52 @@ Rectangle {
height: 480 height: 480
color: "#ffffff" color: "#ffffff"
// COMPONENTS
Grid { Grid {
id: grid id: systemManagementGrid
y: 60 visible: tabs.currentTab == TabConstants.systemManagementTab
height: 420
columns: 3
spacing: 2
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.topMargin: 60
anchors.rightMargin: 0 anchors.rightMargin: 0
anchors.leftMargin: 0 anchors.leftMargin: 0
anchors.bottomMargin: 0 anchors.bottomMargin: 0
Rectangle { color: "red"; width: 50; height: 50 }
Rectangle { color: "green"; width: 20; height: 50 }
Rectangle { color: "blue"; width: 50; height: 20 }
Rectangle { color: "cyan"; width: 50; height: 50 }
Rectangle { color: "magenta"; width: 10; height: 10 }
}
Grid {
id: gamesGrid
visible: tabs.currentTab == TabConstants.gamesTab
columns: 3
spacing: 2
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.topMargin: 60
anchors.rightMargin: 0
anchors.leftMargin: 0
anchors.bottomMargin: 0
Text {
id: text2
text: qsTr("Text")
font.pixelSize: 12
}
} }
Rectangle { Rectangle {
...@@ -45,16 +86,28 @@ Rectangle { ...@@ -45,16 +86,28 @@ Rectangle {
topPadding: 5 topPadding: 5
Button { Button {
id: button1 id: buttonSystemManagement
text: "System management"
onClicked: function(){
tabs.currentTab = TabConstants.systemManagementTab;
// tabs.changeTab();
// console.log(tabs.currentTab);
} }
Button {
id: button2
} }
Button { Button {
id: button3 id: buttonGames
text: "Games"
onClicked: function(){
tabs.currentTab = TabConstants.gamesTab;
if(app === undefined) return;
app.get_games();
// tabs.changeTab();
// console.log(tabs.currentTab);
} }
} }
} }
}
} }
var backColor = "red";
\ No newline at end of file
var systemManagementTab = "systemManagement";
var gamesTab = "games";
\ No newline at end of file
import QtQuick import QtQuick
import QtQuick.Controls
import "../components" import "../components"
......
...@@ -5,13 +5,18 @@ from pathlib import Path ...@@ -5,13 +5,18 @@ from pathlib import Path
from PySide6.QtGui import QGuiApplication from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine from PySide6.QtQml import QQmlApplicationEngine
from src.models.App import App
# TODO: add VirtualKeyboard # TODO: add VirtualKeyboard
if __name__ == "__main__": if __name__ == "__main__":
app = QGuiApplication(sys.argv) app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
qml_file = Path(__file__).resolve().parent / "../qml/qml.qml" qml_file = Path(__file__).resolve().parent / "../qml/qml.qml"
engine = QQmlApplicationEngine()
engine.load(qml_file) engine.load(qml_file)
if not engine.rootObjects(): if not engine.rootObjects():
sys.exit(-1) sys.exit(-1)
appModel = App()
context = engine.rootContext()
context.setContextProperty("app", appModel)
sys.exit(app.exec()) sys.exit(app.exec())
from PySide6 import QtCore
from os.path import expanduser
import glob
from desktop_parser import DesktopFile
class GameShortcut:
def __init__(self, filename, product_name, icon):
self.filename = filename
self.product_name = product_name
self.icon = icon
class App(QtCore.QObject):
def __init__(self):
super().__init__()
self.home = expanduser('~')
self.config_location = '/.config/PortProton.conf'
self.portproton_location = ''
self.setup()
def setup(self):
try:
with open(self.home + self.config_location, 'r') as file:
self.portproton_location = file.read().strip()
print(f'Current PortProton location: {self.portproton_location}')
files = glob.glob(f"{self.portproton_location}/*.desktop")
# for val in files:
# print(val)
# desktop_file = DesktopFile.from_file("path/to/file.desktop")
except FileNotFoundError:
print('File not found')
except Exception:
print('An error occurred')
pass
### SLOTS ###
@QtCore.Slot()
def get_games(self):
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment