123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- import QtQuick 1.0
- //full screen interstitial ad
- //(well should be used fullscreen but you need to specify width and height still
- //options:
- // message text: something like "A quick word from our sponsors
- // color: background color for panel
- // skip in: number of seconds before ad can be skipped
- Rectangle {
- id: adWrapper
- //specific to interstitials
- //default to a boring gray
- color: "#c0c0c0"
- property alias messageText: sponsorText.text
- property int skipIn: 0
- //screen width is important for getting the right ads showing
- property alias screenWidth: ad.screenWidth
- property alias screenHeight: ad.screenHeight
- //private
- property int __skippingIn: -1
- //aliased to the ad properties so they can be set here but reflected in the child
- property alias appid: ad.appid
- //these probably don't need to be specified
- property alias channelid: ad.channelid
- function loadAd() {
- ad.loadAd();
- //disable skip button and restart timer
- if(skipIn > 0) {
- __skippingIn = skipIn
- skipButton.disabled = true;
- skipTimer.start();
- }
- }
- function hide() {
- visible = false;
- }
- function show() {
- visible = true;
- }
- Text {
- id: sponsorText
- text: "A quick word from our sponsors..."
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.top: parent.top
- anchors.topMargin: 25
- font.pointSize: 14
- wrapMode: Text.Wrap
- color: "black"
- }
- Column {
- id: buttons
- spacing: 6
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.bottom: parent.bottom
- anchors.bottomMargin: 25
- //width: parent.width
- //height: 200
- //skip button
- Rectangle {
- id: skipButton
- property bool disabled: false
- border.width: 1
- radius: 2
- border.color: "#060606"
- color: "#cfcfcf"
- //color: "green"
- width: adWrapper.width * .70
- //width: 200
- height: 40
- Text {
- color: skipButton.disabled ? "#e0e0e0" : "black"
- font.pointSize: 14
- anchors.centerIn: parent
- text: __skippingIn > 0 ? "Skip in " + __skippingIn + " sec(s)" : "Skip"
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- console.log("skip pressed");
- if(parent.disabled == false)
- adWrapper.hide();
- }
- onPressed: { if(!parent.disabled) parent.color = Qt.lighter(parent.color,1.1); }
- onReleased: { if(!parent.disabled) parent.color = Qt.darker(parent.color, 1.1); }
- }
- }
- //visit link button
- Rectangle {
- border.width: 1
- radius: 2
- border.color: "#060606"
- color: "#cfcfcf"
- //color: "green"
- width: adWrapper.width * .70
- //width: 200
- height: 40
- Text {
- color: "black"
- font.pointSize: 14
- anchors.centerIn: parent
- text: "Open Link"
- }
- MouseArea {
- anchors.fill: parent
- onClicked: {
- console.log("visit ad button pressed");
- ad.adClicked();
- }
- onPressed: { parent.color = Qt.lighter(parent.color,1.2); }
- onReleased: { parent.color = Qt.darker(parent.color, 1.2); }
- }
- }
- }
- InnerActiveAd {
- id: ad
- width: parent.width
- anchors.bottom: buttons.top
- anchors.bottomMargin: 10
- anchors.top: sponsorText.bottom
- anchors.topMargin: 10
- }
- Timer {
- id: skipTimer
- interval: 1000 //countdown timer
- repeat: true
- onTriggered: {
- if(__skippingIn == 0) {
- skipTimer.stop();
- console.log("Ad finished");
- skipButton.disabled = false;
- } else
- __skippingIn = __skippingIn - 1;
- }
- }
- }
|