- re-added full compatibility with Qt 5.9

This commit is contained in:
Dorian Zedler 2019-12-06 18:06:19 +01:00
parent c41624db5f
commit 8d0803217f
9 changed files with 135 additions and 16 deletions

View file

@ -0,0 +1,92 @@
import QtQuick 2.0
import QtQuick.Controls 2.1
import QtQuick.Controls.Material 2.1
Loader {
id: control
property QIconSource icon: QIconSource {}
property int fontPixelSize
property string text: ""
signal clicked
Connections {
target: icon
onNameChanged: {
control.syncProperties()
}
}
onTextChanged: {
control.syncProperties()
}
function syncProperties() {
if(QtCompatiblityMode) {
control.sourceComponent = ancientToolButtonCp
control.item.text = control.text
control.item.font = control.font
if(control.fontPixelSize !== undefined) {
control.item.font.pixelSize = control.fontPixelSize
}
}
else {
control.sourceComponent = modernToolButtonCp
control.item.icon.name = control.icon.name
control.item.icon.color = control.icon.color
control.item.icon.width = control.icon.width
control.item.icon.height = control.icon.height
}
}
onItemChanged: {
control.syncProperties()
}
Component.onCompleted: {
control.syncProperties()
}
Connections {
target: control.item
onClicked: {
control.clicked()
}
}
Component {
id: ancientToolButtonCp
ToolButton {
id: tb
opacity: enabled ? 1.0 : 0.3
contentItem: Text {
text: tb.text
font: tb.font
color: app.style.style.textColor
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
}
Component {
id: modernToolButtonCp
ToolButton {
height: implicitHeight
width: implicitWidth
}
}
}

View file

@ -17,7 +17,7 @@
*/ */
import QtQuick 2.9 import QtQuick 2.9
import QtQuick.Controls 2.4 import QtQuick.Controls 2.1
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
Item { Item {

View file

@ -0,0 +1,8 @@
import QtQuick 2.0
QtObject {
property string name: ""
property int height
property int width
property color color: "black"
}

View file

@ -281,7 +281,7 @@ Page {
} }
} }
ToolButton { CompatibleToolButton {
id: deleteButton id: deleteButton
anchors { anchors {
@ -294,6 +294,8 @@ Page {
icon.name: "delete" icon.name: "delete"
text: "X"
onClicked: { onClicked: {
deleteAnimation.start() deleteAnimation.start()
} }

View file

@ -140,7 +140,7 @@ Page {
rightMargin: root.width * 0.05 rightMargin: root.width * 0.05
} }
ToolButton{ CompatibleToolButton{
id: passwordHideShow id: passwordHideShow
anchors { anchors {
top: parent.top top: parent.top
@ -148,8 +148,6 @@ Page {
right: parent.right right: parent.right
} }
icon.height: parent.height * 0.5
icon.width: parent.height * 0.5
icon.color: app.style.style.textColor icon.color: app.style.style.textColor
onClicked: { onClicked: {
@ -169,6 +167,7 @@ Page {
PropertyChanges { PropertyChanges {
target: passwordHideShow target: passwordHideShow
icon.name: "hide" icon.name: "hide"
text: "show"
} }
PropertyChanges { PropertyChanges {
@ -181,6 +180,7 @@ Page {
PropertyChanges { PropertyChanges {
target: passwordHideShow target: passwordHideShow
icon.name: "view" icon.name: "view"
text: "hide"
} }
PropertyChanges { PropertyChanges {
target: tipasswd target: tipasswd

View file

@ -146,8 +146,8 @@ Page {
spacing: width * 0.02 spacing: width * 0.02
ToolButton { CompatibleToolButton {
id: toolButton id: backTb
enabled: !formStack.currentItem.locked enabled: !formStack.currentItem.locked
@ -156,6 +156,9 @@ Page {
icon.name: "back" icon.name: "back"
icon.color: app.style.style.textColor icon.color: app.style.style.textColor
text: "\u2039"
fontPixelSize: height * 0.7
onClicked: { onClicked: {
if(!formStack.currentItem.locked){ if(!formStack.currentItem.locked){
formStack.pop() formStack.pop()
@ -186,8 +189,8 @@ Page {
} }
} }
ToolButton { CompatibleToolButton {
id: pdfToolButton id: pdfTb
enabled: !formStack.currentItem.locked enabled: !formStack.currentItem.locked
@ -198,6 +201,8 @@ Page {
icon.name: "pdf" icon.name: "pdf"
icon.color: app.style.style.textColor icon.color: app.style.style.textColor
text: "pdf ansehen"
onClicked: { onClicked: {
if(formStack.currentItem.pdfAction !== undefined) { if(formStack.currentItem.pdfAction !== undefined) {
formStack.currentItem.pdfAction() formStack.currentItem.pdfAction()

View file

@ -91,16 +91,16 @@ ApplicationWindow {
mainStack.replace(currPage) mainStack.replace(currPage)
} }
//initialItem: mainPage
Component { Component {
id: loginPage id: loginPage
LoginPage {} LoginPage {
}
} }
Component { Component {
id: mainPage id: mainPage
MainPage {} MainPage {
}
} }
} }

View file

@ -18,5 +18,7 @@
<file>Components/FannyDataListView.qml</file> <file>Components/FannyDataListView.qml</file>
<file>Components/ProgressCircle.qml</file> <file>Components/ProgressCircle.qml</file>
<file>Components/PullRefresher.qml</file> <file>Components/PullRefresher.qml</file>
<file>Components/CompatibleToolButton.qml</file>
<file>Components/QIconSource.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -58,15 +58,25 @@ int main(int argc, char *argv[])
qmlRegisterType<AppStyle>("Backend", 1, 0, "AppStyle"); qmlRegisterType<AppStyle>("Backend", 1, 0, "AppStyle");
QQuickStyle::setStyle("Material"); QQuickStyle::setStyle("Material");
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) )
QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << ":/shared/icons"); QIcon::setFallbackSearchPaths(QIcon::fallbackSearchPaths() << ":/shared/icons");
QIcon::setThemeName("ibmaterial"); QIcon::setThemeName("ibmaterial");
#endif
QQmlApplicationEngine engine; QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
QQmlContext *context = engine.rootContext();
// context->setContextProperty("_cppServerConn", pServerConn); QQmlContext *context = engine.rootContext();
context->setContextProperty("_cppAppSettings", pAppSettings); context->setContextProperty("_cppAppSettings", pAppSettings);
context->setContextProperty("QtCompatiblityMode",
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) )
false
#else
true
#endif
);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty()) if (engine.rootObjects().isEmpty())
return -1; return -1;