added styles

This commit is contained in:
Yuri Kozyrev 2022-08-06 19:26:01 +04:00
parent e75bcd277b
commit 01b98dc5e6
14 changed files with 235 additions and 144 deletions

View File

@ -23,13 +23,15 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS
${CMAKE_CURRENT_SOURCE_DIR}/src/alterator_loader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/new_interface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/dbus_property_map.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/dbus_qml_connector)
${CMAKE_CURRENT_SOURCE_DIR}/src/dbus_qml_connector.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/style.cpp)
set(HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/include/alterator_loader.h
${CMAKE_CURRENT_SOURCE_DIR}/include/new_interface.h
${CMAKE_CURRENT_SOURCE_DIR}/include/dbus_property_map.h
${CMAKE_CURRENT_SOURCE_DIR}/include/dbus_qml_connector.h)
${CMAKE_CURRENT_SOURCE_DIR}/include/dbus_qml_connector.h
${CMAKE_CURRENT_SOURCE_DIR}/include/style.h)
set(ALTERATORLIB_VERSION 0.0.1)
set(ALTERATORLIB_SOVERSION 1)

35
alterator/include/style.h Normal file
View File

@ -0,0 +1,35 @@
#ifndef STYLE_H
#define STYLE_H
#include <QQmlComponent>
#include <QQmlPropertyMap>
#include <QtQuick>
namespace Alterator{
class Style : public QQmlComponent{
Q_OBJECT
Q_PROPERTY(QObject *child READ getChild WRITE setChild NOTIFY childChanged)
Q_PROPERTY(QQmlPropertyMap *properties READ getProperties WRITE setProperties NOTIFY propertiesChanged)
Q_CLASSINFO("DefaultProperty", "child")
QML_ELEMENT
public:
QObject *getChild();
void setChild(QObject *c);
QQmlPropertyMap *getProperties();
void setProperties(QQmlPropertyMap *p);
Style(QObject *parent = 0);
Style(QQmlEngine *, QObject *parent=0);
signals:
void childChanged(QObject *c);
void propertiesChanged(QObject *b);
void created();
private slots:
void createChild(QObject *c);
private:
QObject *child;
QQmlPropertyMap *properties;
};
}
#endif // STYLE_H

View File

@ -10,15 +10,17 @@
#include <QFontDatabase>
#include <QGuiApplication>
#include "new_interface.h"
#include "style.h"
namespace Alterator {
Loader::Loader(QObject *p):QObject(p)
{
QFontDatabase::addApplicationFont("../shared/Montserrat-VariableFont_wght.ttf");
QQuickStyle::setStyle("abc");
QQuickStyle::setStyle("Basic");
engine = new QQmlApplicationEngine(this);
engine->addImportPath("../../new_alterator/");
qmlRegisterType<Alterator::DBusInterface>("Alterator.DBusInterface", 1, 0, "DBusInterface");
qmlRegisterType<Alterator::Style>("Alterator.Style", 1, 0, "Style");
qmlRegisterType<Alterator::DistInfo>("Alterator.DistInfo", 1, 0, "DistInfo");
QString startingPage = "../resources/SystemInformation.qml";
past = QHash<QString, QVector<QString>>();

35
alterator/src/style.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <QDebug>
#include <QQmlContext>
#include <QList>
#include "style.h"
namespace Alterator{
Style::Style(QObject *parent) :
QQmlComponent(parent){
properties = new QQmlPropertyMap();
connect(this, SIGNAL(childChanged(QObject *)), this, SLOT(createChild(QObject *)));
}
void Style::setChild(QObject *c){
child = c;
emit childChanged(c);
}
void Style::setProperties(QQmlPropertyMap *p){properties = p;}
QObject *Style::getChild(){return child;}
QQmlPropertyMap *Style::getProperties(){return properties;}
void Style::createChild(QObject *c){
QVariantMap props;
auto t1 = QQmlEngine::contextForObject(this)->engine();
QObject *target = beginCreate(QQmlEngine::contextForObject(this));
QStringList::iterator i;
for(i = properties->keys().begin(); i != properties->keys().end(); i++){
auto t = i->toLocal8Bit();
const char *name = t.data();
if (target->metaObject()->indexOfProperty(name) != -1){
target->setProperty(name, properties->value(name));
}
}
completeCreate();
}
}

View File

@ -6,16 +6,31 @@ import Alterator.DistInfo 1.0
import Alterator.DBusInterface 1.0
import shared 1.0
import "../shared/font_styles/Font_styles.js" as Font_styles;
import "../shared/someStyle.js" as SomeStyle;
import "../shared/Colors.js" as Colors;
import Alterator.Style 1.0
Item {
id: systemInfo
anchors.fill: parent
// anchors.fill: parent
property int keyWidth: 130
property int valWidth: 280
property int columnSpacing: -10
Style{
id: redSquare
Rectangle {
color: "red"
width: 10
height: 10
}
// onCompleted: console.log(2)
}
DBusInterface{
id: hostname
initialServiceName: "org.freedesktop.hostname1"
@ -32,11 +47,12 @@ Item {
ScrollView{
anchors.fill: parent
contentWidth: width
contentHeight: height
Component.onCompleted: SomeStyle.DefaultScrollView.style(this)
ColumnLayout{
anchors.fill: parent
// anchors.fill: parent
height: systemInfo.height
TextWithHeader{
id: editionArea
@ -67,18 +83,15 @@ Item {
keys: ["Chassis", "Vendor", "Device name", "Processor", "RAM", "GPU"]
vals: [ hostname.properties.Chassis,
hostname.properties.HardwareVendor,
hostname.properties.HardwareModel,
"TODO", "TODO", "TODO" ]
hostname.properties.HardwareModel, "TODO", "TODO", "TODO" ]
n: 6
comp: Component{
Button{
id: cba
text: 'More information'
ButtonStyler{id:a; style: "default"}
Component.onCompleted: console.log(a.parent)
Component.onCompleted: SomeStyle. DefaultButton.style(cba)
}
}
function getSysType() { return "qwerty" }
}
TextWithHeader{
@ -88,16 +101,13 @@ Item {
Layout.preferredWidth: currentPage.width
headerS: "Computer name, domain..."
keys: ["Hostname", "Realm", "Domain role", "Workgroup"]
vals: [hostname.properties.Hostname,
"TODO", "TODO", "TODO"]
vals: [hostname.properties.Hostname,"TODO", "TODO", "TODO"]
n: 4
comp: Component{
Button{
text: '<font color="blue"><u>Domain settings</u></font>'
font.pointSize: 10
background: Rectangle{
color: "white"//Universal.theme === Universal.Light ? "white" : "black"
}
id: domainSettigsButton
text: 'Domain settings'
Component.onCompleted: SomeStyle.HyperlinkButton.style(domainSettigsButton)
}
}
}

View File

@ -0,0 +1,6 @@
import QtQuick 2.0
import Alterator.Style 1.0
Style{
}

View File

@ -1,13 +1,12 @@
import QtQuick 2.0
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import "../shared/font_styles/Font_styles.js" as Font_styles;
import "../shared/someStyle.js" as SomeStyle;
ToolBar{
id: toolBar
Layout.fillWidth: true
Layout.minimumHeight: 30
Layout.maximumHeight: 30
background: Rectangle{
color: "white"
}
@ -24,6 +23,7 @@ ToolBar{
onClicked: backS(windowId)
Layout.maximumHeight: parent.height
Layout.preferredWidth: toolBar.height
Component.onCompleted: SomeStyle.DefaultButton.style(backButtton)
}
ToolButton{
@ -33,6 +33,7 @@ ToolBar{
onClicked: forvardS(windowId)
Layout.maximumHeight: parent.height
Layout.preferredWidth: toolBar.height
Component.onCompleted: SomeStyle.DefaultButton.style(forvardButton)
}
ToolButton{
@ -42,6 +43,7 @@ ToolBar{
onClicked: moveReqS(windowId, "../../new_alterator/resources/Test.qml")
Layout.maximumHeight: parent.height
Layout.preferredWidth: toolBar.height
Component.onCompleted: SomeStyle.DefaultButton.style(upButton)
}
// TextArea{
@ -67,6 +69,7 @@ ToolBar{
text: "log"
onClicked: stack.state = "log"
Layout.maximumHeight: parent.height
Component.onCompleted: SomeStyle.DefaultButton.style(logsButton)
}
}
}

View File

@ -2,20 +2,23 @@ import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import "qrc:/InfoBlock_styles.js" as Element_styles;
import "qrc:/font_styles/Font_styles.js" as Font_styles;
import "qrc:/someStyle.js" as Style;
import "qrc:/someStyle.js" as SomeStyle;
Window{
ApplicationWindow{
id: window
property string url
property string windowId
property int state: 0
property var log: ["abc", "qwerty", "cba"]
property var log:[]
width: 600
height: 650
header: AlteratorToolBar{
width: parent.width
height: 30
}
visible: true
@ -34,11 +37,6 @@ Window{
logRepeater.model++
}
FontLoader{
id: webFont
source: Font_styles.info_text__font_name
}
// onHeightChanged: {
// openReqS("../resources/DistInfo.qml")
// }
@ -47,6 +45,7 @@ Window{
id: windowRect
anchors.fill: parent
padding: 0
StackLayout{
id: stack
@ -54,7 +53,6 @@ Window{
anchors.fill: parent
currentIndex: 0
states:[
State{
name: "log"
@ -68,14 +66,6 @@ Window{
ColumnLayout{
id: layout1
// anchors.fill: parent
AlteratorToolBar{
id: toolBar
z: 1
}
RowLayout{
id: layout2
@ -107,7 +97,6 @@ Window{
spacing: -10
Repeater{
id:logRepeater

View File

@ -3,17 +3,13 @@ import "someStyle.js" as SomeStyle;
import "font_styles/Font_styles.js" as Font_styles;
QtObject {
property string style
onStyleChanged: {
function transform(style, target){
if(style === "default"){
console.log(parent)
parent.background = SomeStyle.defaultBackground
target.background = SomeStyle.defaultBackground
}else if(style === "hyperlink"){
console.log(parent)
parent.background = SomeStyle.hyperlinkLikeBackground
parent.contentItem.font = Font_styles.hyperLink
parent.contentItem.color = "blue"
target.background = SomeStyle.hyperlinkLikeBackground
target.contentItem.font = Font_styles.hyperLink
target.contentItem.color = "blue"
}
}
}

View File

@ -1,5 +0,0 @@
.pragma library;
var info_block__height = 400;
var info_block__width = 400;
var info_block__bottom_margin = 40;

View File

@ -5,104 +5,80 @@ import QtQuick.Controls 2.15
import Qt.labs.qmlmodels 1.0
import QtQml 2.15
import "../shared/font_styles/Font_styles.js" as Font_styles;
import "../shared/someStyle.js" as SomeStyle
import "../shared/Colors.js" as Colors
Pane{
id: rect
Page{
property var keys
property var vals
property string headerS
property int n
property Component comp
Layout.minimumHeight: l1.height
Layout.maximumHeight: l1.height
Layout.fillWidth: true
header: RowLayout {
id: headerLayout
TextArea{
id: header
ColumnLayout{
id: l1
width: parent.width
spacing: -2
RowLayout {
id: headerLayout
Layout.bottomMargin: 10
TextArea{
id: header
selectByMouse: true
selectByKeyboard: true
text: qsTr(headerS)
font: Font_styles.header1
background: Rectangle {
color: "white"//Universal.theme === Universal.Light ? "white" : "black"
border.color: "white"//Universal.theme === Universal.Light ? "white" : "black"
}
}
Rectangle{
Layout.fillWidth: true
Layout.minimumHeight: 1
Layout.maximumHeight: 1
Layout.topMargin: 4
color: "grey"
Layout.rightMargin: 10
}
text: qsTr(headerS)
font: Font_styles.header1
Component.onCompleted: SomeStyle.DefaultTextArea.style(this)
}
RowLayout{
Rectangle{
Layout.fillWidth: true
Layout.minimumHeight: 1
Layout.maximumHeight: 1
Layout.topMargin: 4
color: "grey"
Layout.rightMargin: 10
}
}
background: Rectangle{color: Colors.window_background}
ColumnLayout{
RowLayout{
anchors.fill: parent
spacing: -2
ColumnLayout{
Repeater{
Layout.fillWidth: true
model: n
spacing: -2
RowLayout{
Layout.leftMargin: 20
TextArea{
id: key
Repeater{
Layout.fillWidth: true
model: n
text: keys[index] + ":"
Layout.minimumWidth: 100
font.pointSize: 10
background: Rectangle {
color: "white"//Universal.theme === Universal.Light ? "white" : "black"
border.color: "white"//Universal.theme === Universal.Light ? "white" : "black"
}
}
RowLayout{
Layout.leftMargin: 20
TextArea{
id: key
TextArea{
id: val
text: keys[index] + ":"
font: Font_styles.justText
Layout.minimumWidth: 100
Component.onCompleted: SomeStyle.DefaultTextArea.style(this)
}
selectByMouse: true
selectByKeyboard: true
text: vals[index]
font.pointSize: 10
background: Rectangle {
color: "white"//Universal.theme === Universal.Light ? "white" : "black"
border.color: "white"//Universal.theme === Universal.Light ? "white" : "black"
}
}
TextArea{
id: val
Item{
Layout.minimumWidth: 0
Layout.fillWidth: true
}
text: vals[index]
font: Font_styles.justText
Component.onCompleted: SomeStyle.DefaultTextArea.style(this)
}
Item{
Layout.minimumWidth: 0
Layout.fillWidth: true
}
}
}
}
Loader{
Layout.rightMargin: 20
sourceComponent: comp
}
Item{Layout.fillWidth: true}
Loader{
Layout.rightMargin: 20
sourceComponent: comp
}
}
}

View File

@ -2,11 +2,12 @@
Qt.include("Colors.js");
var header1 = Qt.font({family: info_text__font_family,
pointSize: 12,
italic: true})
pointSize: 12})
var hyperLink = Qt.font({family: info_text__font_family,
pointSize: 10,
underline: true})
var justText = Qt.font({family: info_text__font_family,
pointSize: 10})
var info_text__font_size = 36;
var info_text__font_name = "./Montserrat-VariableFont_wght.ttf"
var info_text__font_boldness = 560;

View File

@ -5,10 +5,9 @@
<file>AlteratorWindow.qml</file>
<file>someStyle.js</file>
<file>Montserrat-VariableFont_wght.ttf</file>
<file>InfoBlock_styles.js</file>
<file>font_styles/Font_styles.js</file>
<file>Colors.js</file>
<file>shared.qrc</file>
<file>ButtonStyler.qml</file>
<file>AlteratorStyle.qml</file>
</qresource>
</RCC>

View File

@ -1,12 +1,54 @@
.pragma library;
Qt.include("font_styles/Font_styles.js")
Qt.include("Colors.js")
var defaultBackground = Qt.createComponent("Rectangle.qml")
defaultBackground.radius = someStyle_default_buttonRadius
defaultBackground.color = someStyle_default_buttonColor
const DefaultButton = {
radius: 7,
color: "white",
style: function(target){
var background = Qt.createQmlObject(
"import QtQuick 2.15; Rectangle{color: \'" +
this.color + "\'; radius: " + this.radius + "}", target)
target.background = background
}
}
var hyperlinkLikeBackground = Qt.createComponent("Rectangle.qml")
hyperlinkLikeBackground.color = someStyle_hyperlinkLike_buttonColor
const HyperlinkButton = {
font: hyperLink,
contentColor: "blue",
backgroundColor: "white",
style: function(target){
var content = Qt.createQmlObject("import QtQuick 2.15; Text{}", target)
content.text = target.text
content.color = this.contentColor
content.font = this.font
target.contentItem = content
var background = Qt.createQmlObject(
"import QtQuick 2.15; Rectangle{color: \'" +
this.backgroundColor + "\'}", target)
target.background = background
}
}
var someStyle_default_buttonRadius = 7
var someStyle_default_buttonColor = "blue"
var someStyle_hyperlinkLike_buttonColor = "white"
const DefaultScrollView = {
color: window_background,
style: function(target){
var background = Qt.createQmlObject("import QtQuick 2.15; Rectangle{}", target)
background.color = this.color
target.background = background
}
}
const DefaultTextArea = {
textColor: info_text,
color: window_background,
style: function(target){
target.color = info_text
target.selectByMouse = true
target.selectByKeyboard = true
var background = Qt.createQmlObject(
"import QtQuick 2.15; Rectangle{}", target)
background.color = window_background
target.background = background
}
}