Guest User

Untitled

a guest
Aug 11th, 2013
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import QtQuick 2.1
  2. import QtQuick.Controls 1.0
  3. import QtQuick.Particles 2.0
  4.  
  5. Rectangle {
  6.     signal clicked
  7.     property string title
  8.     property string message1
  9.     property string message2
  10.     id: dialog
  11.     visible: false
  12.     anchors.fill: parent
  13.     color: Qt.rgba(0, 0, 0, 0);
  14.     state: "hidden"
  15.  
  16.     states: [
  17.         State {
  18.             name: "shown"
  19.             PropertyChanges {
  20.                 target: dialog
  21.                 color: Qt.rgba(0, 0, 0, 0.5)
  22.                 visible: true
  23.             }
  24.             PropertyChanges {
  25.                 target: shaderEffect
  26.                 amplitude: 0.02
  27.             }
  28.  
  29.             PropertyChanges {
  30.                 target: emitter
  31.                 enabled: true
  32.  
  33.             }
  34.             PropertyChanges {
  35.                 target: dialogContent
  36.                 opacity: 1
  37.             }
  38.  
  39.             PropertyChanges {
  40.                 target: translate
  41.                 y: 0
  42.             }
  43.  
  44.             PropertyChanges {
  45.                 target: shaderAnim
  46.                 isRunning: true
  47.             }
  48.         }
  49.     ]
  50.  
  51.     Translate {
  52.         id: translate
  53.         y: -dialogContent.height*2
  54.  
  55.     }
  56.  
  57.     transitions: [
  58.         Transition {
  59.             from: "hidden"
  60.             to: "shown"
  61.             SequentialAnimation{
  62.                 ParallelAnimation {
  63.                     PropertyAnimation { target:  translate;  property:'y'; duration : 300 }
  64.                     PropertyAnimation { target: dialogContent; property: 'opacity'; duration: 300 }
  65.                 }
  66.                 ColorAnimation { target:  dialog;  property:'color'; duration : 500 }
  67.             }
  68.         },
  69.         Transition {
  70.             from: "shown"
  71.             to: "hidden"
  72.             SequentialAnimation{
  73.                 ParallelAnimation {
  74.                     PropertyAnimation { target:  translate;  property:'y'; duration : 300 }
  75.                     PropertyAnimation { target: dialogContent; property: 'opacity'; duration: 300 }
  76.                 }
  77.                 ColorAnimation { target:  dialog;  property:'color'; duration : 500 }
  78.                 PropertyAction { target: emitter; property: 'enabled' }
  79.                 PropertyAction { target: dialog; property: 'visible'; }
  80.             }
  81.         }
  82.     ]
  83.  
  84.     function show()
  85.     {
  86.         dialog.state = "shown";
  87.     }
  88.  
  89.     function hide()
  90.     {
  91.         dialog.state = "hidden"
  92.     }
  93.  
  94.     MouseArea {
  95.         anchors.fill: dialog
  96.         onClicked: {
  97.             dialog.clicked();
  98.         }
  99.     }
  100.  
  101.     ParticleSystem{ id: bubbles }
  102.  
  103.     ImageParticle{
  104.         system: bubbles
  105.         source: "bubble.png"
  106.         opacity: 0.5
  107.     }
  108.     Emitter{
  109.         id: emitter
  110.         enabled: false
  111.         system: bubbles
  112.         anchors.fill: parent
  113.         size: 4
  114.  
  115.         sizeVariation: 14
  116.         acceleration: PointDirection{ y: -6; xVariation: 4 }
  117.         emitRate: 50
  118.         lifeSpan: 3000
  119.     }
  120.  
  121.  
  122.     Rectangle {
  123.         id: dialogContent
  124.         color: "#4fa46b"
  125.         opacity: 0
  126.         height: parent.height/2
  127.         width: parent.width/2
  128.         anchors.centerIn: parent
  129.         transform: translate
  130.         border.width: 5
  131.         border.color: "#2e5f3e"
  132.  
  133.  
  134.  
  135.         ScrollView {
  136.             id: scroll
  137.             anchors.fill: parent
  138.             anchors.margins: 24
  139.  
  140.  
  141.             Column  {
  142.                 spacing: 20
  143.  
  144.                 Text {
  145.                     id: txt
  146.                     color: 'white'
  147.                     text: dialog.title
  148.                     width: scroll.width
  149.                     wrapMode: Text.WordWrap
  150.                     font {
  151.                         pointSize: 22
  152.                         bold: true
  153.                     }
  154.                 }
  155.  
  156.                 Text {
  157.                     color: 'white'
  158.                     text: dialog.message1
  159.                     width: scroll.width
  160.                     wrapMode: Text.WordWrap
  161.                     font.pointSize: 12
  162.                 }
  163.  
  164.                 Text {
  165.                     color: 'white'
  166.                     text: dialog.message2
  167.                     width: scroll.width
  168.                     wrapMode: Text.WordWrap
  169.                     font.pointSize: 12
  170.                 }
  171.             }
  172.         }
  173.  
  174.         ShaderEffect{
  175.             id: shaderEffect
  176.             anchors.fill: scroll
  177.             property var source: ShaderEffectSource {
  178.                 sourceItem: scroll
  179.                 smooth: true
  180.                 hideSource: true
  181.             }
  182.             property real amplitude: 0
  183.             property real frequency: 20
  184.             property real time: 0
  185.             NumberAnimation {
  186.                 property bool isRunning: false
  187.                 onIsRunningChanged: isRunning ? shaderAnim.start() : shaderAnim.stop();
  188.                 id: shaderAnim
  189.                 target: shaderEffect
  190.                 property: 'time'
  191.                 from: 0
  192.                 to: Math.PI * 2
  193.                 duration: 600
  194.                 loops: Animation.Infinite;
  195.             }
  196.             fragmentShader: "
  197.                    uniform highp float amplitude;
  198.                    uniform highp float frequency;
  199.                    uniform highp float time;
  200.                    uniform sampler2D source;
  201.                    uniform lowp float qt_Opacity;
  202.                    varying highp vec2 qt_TexCoord0;
  203.                    void main() {
  204.                        highp vec2 p = sin(time + frequency * qt_TexCoord0);
  205.                        gl_FragColor = qt_Opacity * texture2D(source, qt_TexCoord0 + amplitude * vec2(p.y, -p.x));
  206.                    }"
  207.         }
  208.  
  209.     }
  210. }
Advertisement
Add Comment
Please, Sign In to add comment