Skip to content

Commit dfa4879

Browse files
committed
initial commit
0 parents  commit dfa4879

File tree

11 files changed

+259
-0
lines changed

11 files changed

+259
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
package-lock.json

background/Button.qml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import QtQuick 2.0
2+
3+
Rectangle {
4+
id: buttonBackground
5+
color: parent.enabled ? parent.Material.primary : "#E0E0E0"
6+
radius: 4
7+
clip: true
8+
9+
Component.onCompleted: {
10+
buttonBackground.dom.style.boxShadow = "rgba(0, 0, 0, 0.2) 0px 3px 1px -2px, rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px";
11+
buttonBackground.dom.style.cursor = "pointer";
12+
}
13+
14+
// Ripple
15+
Rectangle {
16+
id: ripple
17+
color: "white"
18+
anchors.centerIn: parent
19+
radius: 999
20+
width: 1
21+
height: 1
22+
opacity: 0
23+
}
24+
NumberAnimation {
25+
id: rippleAnimationPart1
26+
target: ripple
27+
properties: "height,width"
28+
from: 0
29+
to: Math.max(buttonBackground.width, buttonBackground.height) * 1.25
30+
onFinished: rippleAnimationPart2.start()
31+
}
32+
NumberAnimation {
33+
id: rippleAnimationPart2
34+
target: ripple
35+
properties: "opacity"
36+
from: 0.32
37+
to: 0
38+
}
39+
Connections {
40+
target: buttonBackground.parent
41+
onDownChanged: {
42+
if (buttonBackground.parent.down) {
43+
ripple.opacity = 0.32;
44+
ripple.height = ripple.width = 1;
45+
rippleAnimationPart1.start();
46+
}
47+
}
48+
}
49+
}

background/Popup.qml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import QtQuick 2.0
2+
3+
Rectangle {
4+
color: "white"
5+
border.width: 1
6+
border.color: "gray"
7+
}

background/ScrollBar.qml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import QtQuick 2.0
2+
3+
Rectangle {
4+
color: "transparent"
5+
height: parent.orientation == Qt.Vertical ? parent.height : 20
6+
width: parent.orientation == Qt.Vertical ? 20 : parent.width
7+
anchors {
8+
bottom: parent.bottom
9+
right: parent.right
10+
}
11+
}

content/Button.qml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import QtQuick 2.0
2+
3+
Text {
4+
anchors.centerIn: parent
5+
text: parent.$formatLabel(parent.text.toUpperCase(), parent.display, parent.icon)
6+
color: parent.enabled ? "white" : "grey"
7+
font.size: 14
8+
font.weight: 500
9+
font.family: "Roboto"
10+
horizontalAlignment: Text.AlignHCenter
11+
}

content/ScrollBar.qml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import QtQuick 2.0
2+
3+
Rectangle {
4+
color: "lightgrey"
5+
opacity: parent.active ? 1 : 0
6+
radius: 25
7+
implicitWidth: parent.orientation == Qt.Vertical ? 20 : null
8+
implicitHeight: parent.orientation == Qt.Horizontal ? 20 : null
9+
Behavior on opacity {
10+
NumberAnimation { duration: 300 }
11+
}
12+
}

dist/controls2.material.js

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var gulp = require("gulp");
2+
var qrc = require("gulp-qmlweb");
3+
var concat = require("gulp-concat");
4+
var sources = ["material.js"];
5+
var resourceFile = "material.qrc";
6+
7+
gulp.task("rcc", function() {
8+
return gulp.src(resourceFile)
9+
.pipe(qrc({
10+
filename: "controls2.material.rc.js",
11+
src: "QmlWeb.newControls2Style(\"Material\", QtQuick_Controls_Material, {{object}});"
12+
}))
13+
.pipe(gulp.dest("./dist"));
14+
});
15+
16+
gulp.task("build", gulp.series("rcc", function() {
17+
return gulp.src(sources.concat(["dist/controls2.material.rc.js"]))
18+
.pipe(concat("controls2.material.js"))
19+
.pipe(gulp.dest("./dist"));
20+
}));
21+
22+
gulp.task("watch", gulp.series("build", function() {
23+
return gulp.watch(sources.concat([qrc]), gulp.series("build"));
24+
}));

material.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
const materialColors = {
2+
Red: new QmlWeb.QColor("#F44336"),
3+
Pink: new QmlWeb.QColor("#E91E63"),
4+
Purple: new QmlWeb.QColor("#9C27B0"),
5+
DeepPurple: new QmlWeb.QColor("#673AB7"),
6+
Indigo: new QmlWeb.QColor("#3F51B5"),
7+
Blue: new QmlWeb.QColor("#21963F"),
8+
LightBlue: new QmlWeb.QColor("#03A9F4"),
9+
Cyan: new QmlWeb.QColor("#00BCD4"),
10+
Teal: new QmlWeb.QColor("#009688"),
11+
Green: new QmlWeb.QColor("#4CAF50"),
12+
LightGreen: new QmlWeb.QColor("#88C34A"),
13+
Lime: new QmlWeb.QColor("#CDDC39"),
14+
Yellow: new QmlWeb.QColor("#FFEB3B"),
15+
Amber: new QmlWeb.QColor("#FFC107"),
16+
Orange: new QmlWeb.QColor("#FF9800"),
17+
DeepOrange: new QmlWeb.QColor("#FF5722"),
18+
Brown: new QmlWeb.QColor("#795548"),
19+
Grey: new QmlWeb.QColor("#9E9E9E"),
20+
BlueGrey: new QmlWeb.QColor("#607D8B")
21+
};
22+
23+
function prepareRoboto() {
24+
if (!window._roboto_initialized) {
25+
const link = document.createElement("link");
26+
link.setAttribute("rel", "stylesheet");
27+
link.setAttribute("type", "text/css");
28+
link.setAttribute("href", "http://fonts.cdnfonts.com/css/roboto");
29+
document.head.append(link);
30+
window._roboto_initialized = true;
31+
}
32+
}
33+
34+
class QtQuick_Controls_Material {
35+
static getAttachedObject() {
36+
if (!this.$Material) {
37+
prepareRoboto();
38+
this.$Material = new QmlWeb.QObject(this);
39+
this.$Material.Light = 0;
40+
this.$Material.Dark = 1;
41+
this.$Material.System = 2;
42+
for (const color in materialColors) {
43+
this.$Material[color] = materialColors[color];
44+
}
45+
QmlWeb.createProperties(this.$Material, {
46+
accent: { type: "color", initialValue: materialColors.Pink },
47+
background: { type: "color", initialValue: materialColors.Teal },
48+
elevation: { type: "int", initialValue: null },
49+
foreground: { type: "color", initialValue: "transparent" },
50+
primary: { type: "color", initialValue: materialColors.Indigo },
51+
theme: "enum"
52+
});
53+
QmlWeb.createProperties(this, {
54+
Material: { type: "QtObject", initialValue: this.$Material, readOnly: true }
55+
});
56+
}
57+
return this.$Material;
58+
}
59+
}

material.qrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<RCC>
2+
<qresource prefix="/">
3+
<file>background/Popup.qml</file>
4+
<file>background/Button.qml</file>
5+
<file>background/ScrollBar.qml</file>
6+
<file>content/Button.qml</file>
7+
<file>content/ScrollBar.qml</file>
8+
</qresource>
9+
</RCC>

0 commit comments

Comments
 (0)