Warning, /plasma-mobile/mycroft-plasmoid-mobile/plasmoid/contents/ui/DashNewsDelegate.qml is written in an unsupported language. File is not indexed.
0001 /* Copyright 2016 Aditya Mehra <aix.m@outlook.com>
0002
0003 This library is free software; you can redistribute it and/or
0004 modify it under the terms of the GNU Lesser General Public
0005 License as published by the Free Software Foundation; either
0006 version 2.1 of the License, or (at your option) version 3, or any
0007 later version accepted by the membership of KDE e.V. (or its
0008 successor approved by the membership of KDE e.V.), which shall
0009 act as a proxy defined in Section 6 of version 3 of the license.
0010
0011 This library is distributed in the hope that it will be useful,
0012 but WITHOUT ANY WARRANTY; without even the implied warranty of
0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014 Lesser General Public License for more details.
0015
0016 You should have received a copy of the GNU Lesser General Public
0017 License along with this library. If not, see <http://www.gnu.org/licenses/>.
0018 */
0019
0020 import QtQuick 2.9
0021 import QtQml.Models 2.2
0022 import QtQuick.Controls 2.2
0023 import QtQuick.Layouts 1.3
0024 import org.kde.plasma.core 2.0 as PlasmaCore
0025 import org.kde.plasma.plasmoid 2.0
0026 import org.kde.plasma.components 2.0 as PlasmaComponents
0027 import QtGraphicalEffects 1.0
0028
0029 Rectangle {
0030 id: dashDelegateItm
0031 height: skillTopRowLayout.height + dashinner.height + dashItemSrcMeta.height + units.gridUnit * 0.5
0032 width: cbwidth - units.gridUnit * 0.50
0033 border.width: 1
0034 border.color: Qt.darker(PlasmaCore.ColorScope.backgroundColor, 1.2)
0035 color: Qt.darker(PlasmaCore.ColorScope.backgroundColor, 1.2)
0036 layer.enabled: true
0037 layer.effect: DropShadow {
0038 horizontalOffset: 0
0039 verticalOffset: 1
0040 radius: 10
0041 samples: 32
0042 spread: 0.1
0043 color: Qt.rgba(0, 0, 0, 0.3)
0044 }
0045
0046 Item {
0047 id: contentdlgtitem
0048 width: parent.width - units.gridUnit * 0.05
0049 height: parent.height
0050
0051 Item {
0052 id: skillTopRowLayout
0053 anchors.top: parent.top
0054 anchors.left: parent.left
0055 anchors.right: parent.right
0056 implicitHeight: dashHeader.implicitHeight + units.gridUnit * 0.5
0057
0058 Text {
0059 id: dashHeader
0060 anchors.left: dashHeaderSeprtr.right
0061 anchors.leftMargin: units.gridUnit * 0.25
0062 anchors.verticalCenter: parent.verticalCenter
0063 width: parent.width - Math.round(contxtnewsitemmenu.width + units.gridUnit * 1.25)
0064 wrapMode: Text.Wrap;
0065 font.bold: true;
0066 font.pointSize: theme.defaultFont.pointSize
0067 font.letterSpacing: theme.defaultFont.letterSpacing
0068 font.wordSpacing: theme.defaultFont.wordSpacing
0069 font.family: theme.defaultFont.family
0070 renderType: Text.NativeRendering
0071 color: PlasmaCore.ColorScope.textColor
0072 text: model.contents.newsTitle
0073
0074 MouseArea {
0075 anchors.fill: parent
0076 hoverEnabled: true
0077
0078 onEntered: {
0079 dashHeader.color = theme.linkColor
0080 dashHeader.font.underline = true
0081 }
0082 onExited: {
0083 dashHeader.color = PlasmaCore.ColorScope.textColor
0084 dashHeader.font.underline = false
0085 }
0086 onClicked: {
0087 Qt.openUrlExternally(model.contents.newsURL)
0088 }
0089 }
0090 }
0091
0092 PlasmaCore.SvgItem {
0093 id: dashHeaderSeprtr
0094 anchors {
0095 left: contxtnewsitemmenu.right
0096 leftMargin: units.gridUnit * 0.25
0097 verticalCenter: parent.verticalCenter
0098 }
0099 height: units.gridUnit * 1
0100 width: dashhdrvertSvg.elementSize("vertical-line").width
0101 z: 110
0102 elementId: "vertical-line"
0103
0104 svg: PlasmaCore.Svg {
0105 id: dashhdrvertSvg;
0106 imagePath: "widgets/line"
0107 }
0108 }
0109
0110 ToolButton {
0111 id: contxtnewsitemmenu
0112 anchors.verticalCenter: parent.verticalCenter
0113 anchors.left: parent.left
0114 width: units.gridUnit * 1
0115 height: units.gridUnit * 1
0116 Image {
0117 id: innrnewitemcontxmenuimage
0118 source: "../images/ctxmenu.png"
0119 anchors.verticalCenter: parent.verticalCenter
0120 anchors.horizontalCenter: parent.horizontalCenter
0121 width: units.gridUnit * 0.60
0122 height: units.gridUnit * 0.50
0123 }
0124 ColorOverlay {
0125 anchors.fill: innrnewitemcontxmenuimage
0126 source: innrnewitemcontxmenuimage
0127 color: theme.textColor
0128 }
0129 onClicked: {
0130 mcmenuItem.open()
0131 }
0132 }
0133 }
0134
0135 Rectangle {
0136 id: nwsseprator
0137 width: parent.width
0138 anchors.top: skillTopRowLayout.bottom
0139 anchors.topMargin: 1
0140 height: 2
0141 color: theme.linkColor
0142 }
0143
0144 Item {
0145 id: dashinner
0146 width: parent.width
0147 implicitHeight: nwsdesc.height
0148 Layout.minimumHeight: units.gridUnit * 2
0149 anchors.top: nwsseprator.bottom
0150 anchors.topMargin: 1
0151
0152 Text {
0153 id: nwsdesc
0154 wrapMode: Text.Wrap;
0155 anchors.right: ctxImgIcon.left
0156 anchors.left: parent.left
0157 anchors.leftMargin: 2
0158 font.pointSize: theme.defaultFont.pointSize
0159 font.letterSpacing: theme.defaultFont.letterSpacing
0160 font.wordSpacing: theme.defaultFont.wordSpacing
0161 font.family: theme.defaultFont.family
0162 renderType: Text.NativeRendering
0163 color: PlasmaCore.ColorScope.textColor
0164 text: model.contents.newsDescription
0165
0166 Component.onCompleted: {
0167 if (!nwsdesc.text) {
0168 nwsdesc.text = model.contents.newsTitle
0169 }
0170 }
0171 }
0172
0173 Image {
0174 id: ctxImgIcon
0175 anchors.right: parent.right
0176 anchors.margins: units.gridUnit * 0.5
0177 source: model.contents.newsImgURL
0178 width: 64
0179 height: parent.height
0180
0181 Component.onCompleted: {
0182 if (ctxImgIcon.source == "") {
0183 ctxImgIcon.source = "../images/newsicon.png"
0184 }
0185 }
0186
0187 }
0188 }
0189
0190 Rectangle {
0191 id: nwsseprator2
0192 width: parent.width
0193 anchors.top: dashinner.bottom
0194 anchors.topMargin: 1
0195 height: 2
0196 color: theme.linkColor
0197 }
0198
0199 Rectangle {
0200 id: dashItemSrcMeta
0201 implicitWidth: dashItemSrcName.implicitWidth + units.gridUnit * 1
0202 anchors.left: parent.left
0203 anchors.leftMargin: units.gridUnit * 0.05
0204 anchors.top: nwsseprator2.bottom
0205 anchors.topMargin: 1
0206 color: theme.linkColor
0207 height: units.gridUnit * 1.25
0208
0209 Text {
0210 id: dashItemSrcName
0211 wrapMode: Text.Wrap;
0212 anchors.centerIn: parent
0213 font.pointSize: theme.defaultFont.pointSize
0214 font.letterSpacing: theme.defaultFont.letterSpacing
0215 font.wordSpacing: theme.defaultFont.wordSpacing
0216 font.family: theme.defaultFont.family
0217 renderType: Text.NativeRendering
0218 color: PlasmaCore.ColorScope.textColor
0219 text: model.contents.newsSource
0220
0221 MouseArea {
0222 anchors.fill: parent
0223 hoverEnabled: true
0224
0225 onEntered: {
0226 dashItemSrcMeta.color = theme.textColor
0227 dashItemSrcName.color = theme.backgroundColor
0228 }
0229 onExited: {
0230 dashItemSrcMeta.color = theme.linkColor
0231 dashItemSrcName.color = theme.textColor
0232 }
0233 onClicked: {
0234 Qt.openUrlExternally("https://" + model.contents.newsSource)
0235 }
0236 }
0237 }
0238 }
0239
0240 Text {
0241 id: dashItemPwrBy
0242 anchors.top: nwsseprator2.bottom
0243 anchors.topMargin: 1
0244 wrapMode: Text.Wrap;
0245 anchors.right: parent.right
0246 font.letterSpacing: theme.defaultFont.letterSpacing
0247 font.wordSpacing: theme.defaultFont.wordSpacing
0248 font.family: theme.defaultFont.family
0249 renderType: Text.NativeRendering
0250 color: PlasmaCore.ColorScope.textColor
0251 font.pixelSize: 10
0252 text: i18n("<i>Powered By: NewsAPI</i>")
0253 }
0254 }
0255
0256 Drawer {
0257 id: mcmenuItem
0258 width: dwrpaddedwidth
0259 height: audionewsCardRectbtn.height + shareCardRectbtn.height + removeCardRectbtn.height + disableCardRectbtn.height
0260 edge: Qt.TopEdge
0261 dragMargin: 0
0262
0263 Rectangle {
0264 id: menuRectItem
0265 anchors.fill: parent
0266 color: theme.backgroundColor
0267
0268 Column {
0269 id: menuRectColumn
0270 anchors.fill: parent
0271
0272 Rectangle {
0273 id: audionewsCardRectbtn
0274 width: parent.width
0275 height: units.gridUnit * 2
0276 color: theme.backgroundColor
0277
0278 Row {
0279 spacing: 5
0280 PlasmaCore.IconItem {
0281 id: audionewsCardIcon
0282 anchors.verticalCenter: parent.verticalCenter
0283 source: "media-playback-start"
0284 width: units.gridUnit * 2
0285 height: units.gridUnit * 2
0286 }
0287 Rectangle {
0288 id: audionewsCardSeperater
0289 width: 1
0290 height: parent.height
0291 color: theme.linkColor
0292 }
0293 PlasmaComponents.Label {
0294 id: audionewsCardLabel
0295 anchors.verticalCenter: parent.verticalCenter
0296 text: i18n("Play / Listen To News Article")
0297 }
0298 }
0299 MouseArea {
0300 anchors.fill: parent
0301 hoverEnabled: true
0302 onEntered: {
0303 audionewsCardLabel.color = theme.linkColor
0304 }
0305 onExited:{
0306 audionewsCardLabel.color = theme.textColor
0307 }
0308 onClicked:{
0309 mcmenuItem.close()
0310 var sendnewsurl = "getarticle newsurl " + model.contents.newsURL
0311 var socketmessage = {};
0312 socketmessage.type = "recognizer_loop:utterance";
0313 socketmessage.data = {};
0314 socketmessage.data.utterances = [sendnewsurl];
0315 socket.sendTextMessage(JSON.stringify(socketmessage));
0316 }
0317 }
0318 }
0319
0320 Rectangle {
0321 id: btnshorzSepr1
0322 width: parent.width
0323 height: 1
0324 color: theme.linkColor
0325 }
0326
0327 Rectangle {
0328 id: shareCardRectbtn
0329 width: parent.width
0330 height: units.gridUnit * 2
0331 color: theme.backgroundColor
0332
0333 Row {
0334 spacing: 5
0335 PlasmaCore.IconItem {
0336 id: shareCardIcon
0337 anchors.verticalCenter: parent.verticalCenter
0338 source: "retweet"
0339 width: units.gridUnit * 2
0340 height: units.gridUnit * 2
0341 }
0342 Rectangle {
0343 id: shareCardSeperater
0344 width: 1
0345 height: parent.height
0346 color: theme.linkColor
0347 }
0348 PlasmaComponents.Label {
0349 id: shareCardLabel
0350 anchors.verticalCenter: parent.verticalCenter
0351 text: i18n("Share News Link")
0352 }
0353 }
0354 MouseArea {
0355 anchors.fill: parent
0356 hoverEnabled: true
0357 onEntered: {
0358 shareCardLabel.color = theme.linkColor
0359 }
0360 onExited:{
0361 shareCardLabel.color = theme.textColor
0362 }
0363 onClicked:{
0364 mcmenuItem.close()
0365 sharePagePopup.open()
0366 }
0367 }
0368 }
0369
0370
0371 Rectangle {
0372 id: btnshorzSepr2
0373 width: parent.width
0374 height: 1
0375 color: theme.linkColor
0376 }
0377
0378 Rectangle {
0379 id: removeCardRectbtn
0380 width: parent.width
0381 height: units.gridUnit * 2
0382 color: theme.backgroundColor
0383
0384 Row {
0385 spacing: 5
0386 PlasmaCore.IconItem {
0387 id: removeCardIcon
0388 anchors.verticalCenter: parent.verticalCenter
0389 source: "archive-remove"
0390 width: units.gridUnit * 2
0391 height: units.gridUnit * 2
0392 }
0393 Rectangle {
0394 id: removeCardSeperater
0395 width: 1
0396 height: parent.height
0397 color: theme.linkColor
0398 }
0399 PlasmaComponents.Label {
0400 id: removeCardLabel
0401 anchors.verticalCenter: parent.verticalCenter
0402 text: i18n("Remove Card")
0403 }
0404 }
0405 MouseArea {
0406 anchors.fill: parent
0407 hoverEnabled: true
0408 onEntered: {
0409 removeCardLabel.color = theme.linkColor
0410 }
0411 onExited:{
0412 removeCardLabel.color = theme.textColor
0413 }
0414 onClicked:{
0415 dashCardCollectionModel.remove(index)
0416 }
0417 }
0418 }
0419
0420 Rectangle {
0421 id: btnshorzSepr3
0422 width: parent.width
0423 height: 1
0424 color: theme.linkColor
0425 }
0426
0427 Rectangle {
0428 id: disableCardRectbtn
0429 width: parent.width
0430 height: units.gridUnit * 2
0431 color: theme.backgroundColor
0432
0433 Row {
0434 spacing: 5
0435 PlasmaCore.IconItem {
0436 id: disableCardIcon
0437 anchors.verticalCenter: parent.verticalCenter
0438 source: "document-close"
0439 width: units.gridUnit * 2
0440 height: units.gridUnit * 2
0441 }
0442 Rectangle {
0443 id: disableCardSeperater
0444 width: 1
0445 height: parent.height
0446 color: theme.linkColor
0447 }
0448 PlasmaComponents.Label {
0449 id: disableCardLabel
0450 anchors.verticalCenter: parent.verticalCenter
0451 text: i18n("Disable News Cards")
0452 }
0453 }
0454 MouseArea {
0455 anchors.fill: parent
0456 hoverEnabled: true
0457 onEntered: {
0458 disableCardLabel.color = theme.linkColor
0459 }
0460 onExited:{
0461 disableCardLabel.color = theme.textColor
0462 }
0463 onClicked:{
0464 dashCardCollectionModel.remove(index)
0465 removeChildCard()
0466 newscardswitch.checked = false
0467 }
0468 }
0469 }
0470 Rectangle {
0471 id: btnshorzSeprEnd
0472 width: parent.width
0473 height: units.gridUnit * 0.75
0474 color: theme.linkColor
0475
0476 PlasmaCore.IconItem {
0477 id: closemenuDrawer
0478 anchors.centerIn: parent
0479 source: "go-up"
0480 width: units.gridUnit * 2
0481 height: units.gridUnit * 2
0482 }
0483 }
0484 }
0485 }
0486 }
0487 }