From de589d6d365160d3678d78e955d022a3153b1f28 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 14 Dec 2016 17:26:37 +0100 Subject: Restructure Change-Id: I63af251b05686f78daf441b1ed7a999bf6685bf6 Reviewed-by: J-P Nurmi --- src/android/android.pri | 15 + src/android/android.pro | 19 +- src/android/app/app.pri | 15 + src/android/app/qqmlandroidactionbar.cpp | 162 ++++ src/android/app/qqmlandroidactionbar_p.h | 110 +++ src/android/app/qqmlandroidactivity.cpp | 202 +++++ src/android/app/qqmlandroidactivity_p.h | 102 +++ src/android/app/qqmlandroidalertdialog.cpp | 92 +++ src/android/app/qqmlandroidalertdialog_p.h | 85 ++ src/android/app/qqmlandroiddialog.cpp | 79 ++ src/android/app/qqmlandroiddialog_p.h | 75 ++ src/android/app/qqmlandroidservice.cpp | 175 ++++ src/android/app/qqmlandroidservice_p.h | 93 +++ src/android/content/content.pri | 11 + src/android/content/qqmlandroidcontext.cpp | 51 ++ src/android/content/qqmlandroidcontext_p.h | 66 ++ src/android/content/qqmlandroidcontextual.cpp | 123 +++ src/android/content/qqmlandroidcontextual_p.h | 87 ++ src/android/content/qqmlandroidcontextwrapper.cpp | 51 ++ src/android/content/qqmlandroidcontextwrapper_p.h | 66 ++ src/android/core/core.pri | 11 + src/android/core/qqmlandroidobject.cpp | 189 +++++ src/android/core/qqmlandroidobject_p.h | 118 +++ src/android/core/qqmlandroidoptional_p.h | 107 +++ src/android/core/qtqmlandroidfunctions.cpp | 103 +++ src/android/core/qtqmlandroidfunctions_p.h | 71 ++ src/android/core/qtqmlandroidglobal_p.h | 76 ++ src/android/graphics/drawable/drawable.pri | 9 + .../graphics/drawable/qqmlandroidcolordrawable.cpp | 78 ++ .../graphics/drawable/qqmlandroidcolordrawable_p.h | 80 ++ .../graphics/drawable/qqmlandroiddrawable.cpp | 56 ++ .../graphics/drawable/qqmlandroiddrawable_p.h | 69 ++ src/android/graphics/graphics.pri | 9 + src/android/graphics/qqmlandroidcolor.cpp | 84 ++ src/android/graphics/qqmlandroidcolor_p.h | 92 +++ src/android/java/java.pri | 20 + src/android/java/java.pro | 22 - src/android/qqmlandroidr.cpp | 250 ++++++ src/android/qqmlandroidr_p.h | 142 ++++ src/android/support/support.pri | 2 + src/android/support/v4/v4.pri | 1 + .../support/v4/widget/qqmlandroiddrawerlayout.cpp | 84 ++ .../support/v4/widget/qqmlandroiddrawerlayout_p.h | 78 ++ .../v4/widget/qqmlandroiddrawerlayoutparams.cpp | 76 ++ .../v4/widget/qqmlandroiddrawerlayoutparams_p.h | 79 ++ .../v4/widget/qqmlandroidswiperefreshlayout.cpp | 110 +++ .../v4/widget/qqmlandroidswiperefreshlayout_p.h | 86 ++ src/android/support/v4/widget/widget.pri | 11 + src/android/support/v7/app/app.pri | 7 + .../v7/app/qqmlandroidactionbardrawertoggle.cpp | 59 ++ .../v7/app/qqmlandroidactionbardrawertoggle_p.h | 67 ++ src/android/support/v7/v7.pri | 2 + .../support/v7/widget/qqmlandroidcardview.cpp | 58 ++ .../support/v7/widget/qqmlandroidcardview_p.h | 69 ++ .../v7/widget/qqmlandroidrecycleradapter.cpp | 181 +++++ .../v7/widget/qqmlandroidrecycleradapter_p.h | 97 +++ .../support/v7/widget/qqmlandroidrecyclerview.cpp | 110 +++ .../support/v7/widget/qqmlandroidrecyclerview_p.h | 87 ++ src/android/support/v7/widget/widget.pri | 11 + src/android/view/animation/animation.pri | 39 + ...qqmlandroidacceleratedecelerateinterpolator.cpp | 51 ++ ...qqmlandroidacceleratedecelerateinterpolator_p.h | 75 ++ .../qqmlandroidaccelerateinterpolator.cpp | 71 ++ .../qqmlandroidaccelerateinterpolator_p.h | 79 ++ .../view/animation/qqmlandroidalphaanimation.cpp | 79 ++ .../view/animation/qqmlandroidalphaanimation_p.h | 84 ++ .../view/animation/qqmlandroidanimation.cpp | 281 +++++++ .../view/animation/qqmlandroidanimation_p.h | 168 ++++ .../view/animation/qqmlandroidanimationset.cpp | 80 ++ .../view/animation/qqmlandroidanimationset_p.h | 79 ++ .../qqmlandroidanticipateinterpolator.cpp | 71 ++ .../qqmlandroidanticipateinterpolator_p.h | 79 ++ .../qqmlandroidanticipateovershootinterpolator.cpp | 92 +++ .../qqmlandroidanticipateovershootinterpolator_p.h | 85 ++ .../animation/qqmlandroidbounceinterpolator.cpp | 51 ++ .../animation/qqmlandroidbounceinterpolator_p.h | 75 ++ .../animation/qqmlandroidcycleinterpolator.cpp | 71 ++ .../animation/qqmlandroidcycleinterpolator_p.h | 79 ++ .../qqmlandroiddecelerateinterpolator.cpp | 71 ++ .../qqmlandroiddecelerateinterpolator_p.h | 79 ++ .../view/animation/qqmlandroidinterpolator.cpp | 51 ++ .../view/animation/qqmlandroidinterpolator_p.h | 68 ++ .../animation/qqmlandroidlinearinterpolator.cpp | 51 ++ .../animation/qqmlandroidlinearinterpolator_p.h | 75 ++ .../animation/qqmlandroidovershootinterpolator.cpp | 71 ++ .../animation/qqmlandroidovershootinterpolator_p.h | 79 ++ .../view/animation/qqmlandroidpathinterpolator.cpp | 125 +++ .../view/animation/qqmlandroidpathinterpolator_p.h | 97 +++ .../view/animation/qqmlandroidrotateanimation.cpp | 133 +++ .../view/animation/qqmlandroidrotateanimation_p.h | 109 +++ .../view/animation/qqmlandroidscaleanimation.cpp | 159 ++++ .../view/animation/qqmlandroidscaleanimation_p.h | 120 +++ .../animation/qqmlandroidtranslateanimation.cpp | 159 ++++ .../animation/qqmlandroidtranslateanimation_p.h | 120 +++ src/android/view/qqmlandroidgravity_p.h | 101 +++ src/android/view/qqmlandroidlayoutparams.cpp | 123 +++ src/android/view/qqmlandroidlayoutparams_p.h | 107 +++ src/android/view/qqmlandroidmenu.cpp | 72 ++ src/android/view/qqmlandroidmenu_p.h | 73 ++ src/android/view/qqmlandroidmenuitem.cpp | 251 ++++++ src/android/view/qqmlandroidmenuitem_p.h | 137 ++++ src/android/view/qqmlandroidview.cpp | 898 +++++++++++++++++++++ src/android/view/qqmlandroidview_p.h | 346 ++++++++ src/android/view/qqmlandroidviewgroup.cpp | 100 +++ src/android/view/qqmlandroidviewgroup_p.h | 75 ++ src/android/view/qqmlandroidwindow.cpp | 76 ++ src/android/view/qqmlandroidwindow_p.h | 79 ++ src/android/view/view.pri | 20 + src/android/widget/qqmlandroidabsseekbar.cpp | 58 ++ src/android/widget/qqmlandroidabsseekbar_p.h | 69 ++ src/android/widget/qqmlandroidadapterview.cpp | 141 ++++ src/android/widget/qqmlandroidadapterview_p.h | 94 +++ src/android/widget/qqmlandroidarrayadapter.cpp | 110 +++ src/android/widget/qqmlandroidarrayadapter_p.h | 92 +++ src/android/widget/qqmlandroidbaseadapter.cpp | 56 ++ src/android/widget/qqmlandroidbaseadapter_p.h | 78 ++ src/android/widget/qqmlandroidbutton.cpp | 58 ++ src/android/widget/qqmlandroidbutton_p.h | 69 ++ src/android/widget/qqmlandroidcalendarview.cpp | 58 ++ src/android/widget/qqmlandroidcalendarview_p.h | 69 ++ src/android/widget/qqmlandroidcheckbox.cpp | 58 ++ src/android/widget/qqmlandroidcheckbox_p.h | 69 ++ src/android/widget/qqmlandroidcompoundbutton.cpp | 117 +++ src/android/widget/qqmlandroidcompoundbutton_p.h | 89 ++ src/android/widget/qqmlandroiddatepicker.cpp | 58 ++ src/android/widget/qqmlandroiddatepicker_p.h | 69 ++ src/android/widget/qqmlandroidedittext.cpp | 58 ++ src/android/widget/qqmlandroidedittext_p.h | 69 ++ src/android/widget/qqmlandroidframelayout.cpp | 66 ++ src/android/widget/qqmlandroidframelayout_p.h | 74 ++ .../widget/qqmlandroidframelayoutparams.cpp | 78 ++ .../widget/qqmlandroidframelayoutparams_p.h | 79 ++ src/android/widget/qqmlandroidimageview.cpp | 136 ++++ src/android/widget/qqmlandroidimageview_p.h | 95 +++ src/android/widget/qqmlandroidlinearlayout.cpp | 163 ++++ src/android/widget/qqmlandroidlinearlayout_p.h | 120 +++ .../widget/qqmlandroidlinearlayoutparams.cpp | 96 +++ .../widget/qqmlandroidlinearlayoutparams_p.h | 85 ++ src/android/widget/qqmlandroidlistview.cpp | 58 ++ src/android/widget/qqmlandroidlistview_p.h | 69 ++ .../widget/qqmlandroidmarginlayoutparams.cpp | 146 ++++ .../widget/qqmlandroidmarginlayoutparams_p.h | 103 +++ src/android/widget/qqmlandroidnumberpicker.cpp | 112 +++ src/android/widget/qqmlandroidnumberpicker_p.h | 86 ++ src/android/widget/qqmlandroidpopupmenu.cpp | 137 ++++ src/android/widget/qqmlandroidpopupmenu_p.h | 94 +++ src/android/widget/qqmlandroidprogressbar.cpp | 143 ++++ src/android/widget/qqmlandroidprogressbar_p.h | 118 +++ src/android/widget/qqmlandroidradiobutton.cpp | 58 ++ src/android/widget/qqmlandroidradiobutton_p.h | 69 ++ src/android/widget/qqmlandroidradiogroup.cpp | 131 +++ src/android/widget/qqmlandroidradiogroup_p.h | 92 +++ src/android/widget/qqmlandroidratingbar.cpp | 112 +++ src/android/widget/qqmlandroidratingbar_p.h | 86 ++ src/android/widget/qqmlandroidrelativelayout.cpp | 66 ++ src/android/widget/qqmlandroidrelativelayout_p.h | 99 +++ .../widget/qqmlandroidrelativelayoutparams.cpp | 445 ++++++++++ .../widget/qqmlandroidrelativelayoutparams_p.h | 213 +++++ src/android/widget/qqmlandroidscrollview.cpp | 131 +++ src/android/widget/qqmlandroidscrollview_p.h | 92 +++ src/android/widget/qqmlandroidsearchview.cpp | 58 ++ src/android/widget/qqmlandroidsearchview_p.h | 69 ++ src/android/widget/qqmlandroidseekbar.cpp | 88 ++ src/android/widget/qqmlandroidseekbar_p.h | 75 ++ src/android/widget/qqmlandroidspace.cpp | 58 ++ src/android/widget/qqmlandroidspace_p.h | 69 ++ src/android/widget/qqmlandroidspinner.cpp | 58 ++ src/android/widget/qqmlandroidspinner_p.h | 69 ++ src/android/widget/qqmlandroidswitch.cpp | 58 ++ src/android/widget/qqmlandroidswitch_p.h | 69 ++ src/android/widget/qqmlandroidtabhost.cpp | 96 +++ src/android/widget/qqmlandroidtabhost_p.h | 78 ++ src/android/widget/qqmlandroidtabspec.cpp | 101 +++ src/android/widget/qqmlandroidtabspec_p.h | 88 ++ src/android/widget/qqmlandroidtabwidget.cpp | 59 ++ src/android/widget/qqmlandroidtabwidget_p.h | 69 ++ src/android/widget/qqmlandroidtextview.cpp | 163 ++++ src/android/widget/qqmlandroidtextview_p.h | 111 +++ src/android/widget/qqmlandroidtimepicker.cpp | 58 ++ src/android/widget/qqmlandroidtimepicker_p.h | 69 ++ src/android/widget/qqmlandroidtoast.cpp | 119 +++ src/android/widget/qqmlandroidtoast_p.h | 88 ++ src/android/widget/qqmlandroidtogglebutton.cpp | 92 +++ src/android/widget/qqmlandroidtogglebutton_p.h | 85 ++ src/android/widget/qqmlandroidviewanimator.cpp | 134 +++ src/android/widget/qqmlandroidviewanimator_p.h | 95 +++ src/android/widget/qqmlandroidviewflipper.cpp | 58 ++ src/android/widget/qqmlandroidviewflipper_p.h | 69 ++ src/android/widget/qqmlandroidviewswitcher.cpp | 58 ++ src/android/widget/qqmlandroidviewswitcher_p.h | 69 ++ src/android/widget/widget.pri | 87 ++ src/qmlandroid/app/app.pri | 15 - src/qmlandroid/app/qqmlandroidactionbar.cpp | 162 ---- src/qmlandroid/app/qqmlandroidactionbar_p.h | 110 --- src/qmlandroid/app/qqmlandroidactivity.cpp | 202 ----- src/qmlandroid/app/qqmlandroidactivity_p.h | 102 --- src/qmlandroid/app/qqmlandroidalertdialog.cpp | 92 --- src/qmlandroid/app/qqmlandroidalertdialog_p.h | 85 -- src/qmlandroid/app/qqmlandroiddialog.cpp | 79 -- src/qmlandroid/app/qqmlandroiddialog_p.h | 75 -- src/qmlandroid/app/qqmlandroidservice.cpp | 175 ---- src/qmlandroid/app/qqmlandroidservice_p.h | 93 --- src/qmlandroid/content/content.pri | 11 - src/qmlandroid/content/qqmlandroidcontext.cpp | 51 -- src/qmlandroid/content/qqmlandroidcontext_p.h | 66 -- src/qmlandroid/content/qqmlandroidcontextual.cpp | 123 --- src/qmlandroid/content/qqmlandroidcontextual_p.h | 87 -- .../content/qqmlandroidcontextwrapper.cpp | 51 -- .../content/qqmlandroidcontextwrapper_p.h | 66 -- src/qmlandroid/core/core.pri | 11 - src/qmlandroid/core/qqmlandroidobject.cpp | 189 ----- src/qmlandroid/core/qqmlandroidobject_p.h | 118 --- src/qmlandroid/core/qqmlandroidoptional_p.h | 107 --- src/qmlandroid/core/qtqmlandroidfunctions.cpp | 103 --- src/qmlandroid/core/qtqmlandroidfunctions_p.h | 71 -- src/qmlandroid/core/qtqmlandroidglobal_p.h | 76 -- src/qmlandroid/graphics/drawable/drawable.pri | 9 - .../graphics/drawable/qqmlandroidcolordrawable.cpp | 78 -- .../graphics/drawable/qqmlandroidcolordrawable_p.h | 80 -- .../graphics/drawable/qqmlandroiddrawable.cpp | 56 -- .../graphics/drawable/qqmlandroiddrawable_p.h | 69 -- src/qmlandroid/graphics/graphics.pri | 9 - src/qmlandroid/graphics/qqmlandroidcolor.cpp | 84 -- src/qmlandroid/graphics/qqmlandroidcolor_p.h | 92 --- src/qmlandroid/qmlandroid.pri | 15 - src/qmlandroid/qmlandroid.pro | 16 - src/qmlandroid/qqmlandroidr.cpp | 250 ------ src/qmlandroid/qqmlandroidr_p.h | 142 ---- src/qmlandroid/support/support.pri | 2 - src/qmlandroid/support/v4/v4.pri | 1 - .../support/v4/widget/qqmlandroiddrawerlayout.cpp | 84 -- .../support/v4/widget/qqmlandroiddrawerlayout_p.h | 78 -- .../v4/widget/qqmlandroiddrawerlayoutparams.cpp | 76 -- .../v4/widget/qqmlandroiddrawerlayoutparams_p.h | 79 -- .../v4/widget/qqmlandroidswiperefreshlayout.cpp | 110 --- .../v4/widget/qqmlandroidswiperefreshlayout_p.h | 86 -- src/qmlandroid/support/v4/widget/widget.pri | 11 - src/qmlandroid/support/v7/app/app.pri | 7 - .../v7/app/qqmlandroidactionbardrawertoggle.cpp | 59 -- .../v7/app/qqmlandroidactionbardrawertoggle_p.h | 67 -- src/qmlandroid/support/v7/v7.pri | 2 - .../support/v7/widget/qqmlandroidcardview.cpp | 58 -- .../support/v7/widget/qqmlandroidcardview_p.h | 69 -- .../v7/widget/qqmlandroidrecycleradapter.cpp | 181 ----- .../v7/widget/qqmlandroidrecycleradapter_p.h | 97 --- .../support/v7/widget/qqmlandroidrecyclerview.cpp | 110 --- .../support/v7/widget/qqmlandroidrecyclerview_p.h | 87 -- src/qmlandroid/support/v7/widget/widget.pri | 11 - src/qmlandroid/view/animation/animation.pri | 39 - ...qqmlandroidacceleratedecelerateinterpolator.cpp | 51 -- ...qqmlandroidacceleratedecelerateinterpolator_p.h | 75 -- .../qqmlandroidaccelerateinterpolator.cpp | 71 -- .../qqmlandroidaccelerateinterpolator_p.h | 79 -- .../view/animation/qqmlandroidalphaanimation.cpp | 79 -- .../view/animation/qqmlandroidalphaanimation_p.h | 84 -- .../view/animation/qqmlandroidanimation.cpp | 281 ------- .../view/animation/qqmlandroidanimation_p.h | 168 ---- .../view/animation/qqmlandroidanimationset.cpp | 80 -- .../view/animation/qqmlandroidanimationset_p.h | 79 -- .../qqmlandroidanticipateinterpolator.cpp | 71 -- .../qqmlandroidanticipateinterpolator_p.h | 79 -- .../qqmlandroidanticipateovershootinterpolator.cpp | 92 --- .../qqmlandroidanticipateovershootinterpolator_p.h | 85 -- .../animation/qqmlandroidbounceinterpolator.cpp | 51 -- .../animation/qqmlandroidbounceinterpolator_p.h | 75 -- .../animation/qqmlandroidcycleinterpolator.cpp | 71 -- .../animation/qqmlandroidcycleinterpolator_p.h | 79 -- .../qqmlandroiddecelerateinterpolator.cpp | 71 -- .../qqmlandroiddecelerateinterpolator_p.h | 79 -- .../view/animation/qqmlandroidinterpolator.cpp | 51 -- .../view/animation/qqmlandroidinterpolator_p.h | 68 -- .../animation/qqmlandroidlinearinterpolator.cpp | 51 -- .../animation/qqmlandroidlinearinterpolator_p.h | 75 -- .../animation/qqmlandroidovershootinterpolator.cpp | 71 -- .../animation/qqmlandroidovershootinterpolator_p.h | 79 -- .../view/animation/qqmlandroidpathinterpolator.cpp | 125 --- .../view/animation/qqmlandroidpathinterpolator_p.h | 97 --- .../view/animation/qqmlandroidrotateanimation.cpp | 133 --- .../view/animation/qqmlandroidrotateanimation_p.h | 109 --- .../view/animation/qqmlandroidscaleanimation.cpp | 159 ---- .../view/animation/qqmlandroidscaleanimation_p.h | 120 --- .../animation/qqmlandroidtranslateanimation.cpp | 159 ---- .../animation/qqmlandroidtranslateanimation_p.h | 120 --- src/qmlandroid/view/qqmlandroidgravity_p.h | 101 --- src/qmlandroid/view/qqmlandroidlayoutparams.cpp | 123 --- src/qmlandroid/view/qqmlandroidlayoutparams_p.h | 107 --- src/qmlandroid/view/qqmlandroidmenu.cpp | 72 -- src/qmlandroid/view/qqmlandroidmenu_p.h | 73 -- src/qmlandroid/view/qqmlandroidmenuitem.cpp | 251 ------ src/qmlandroid/view/qqmlandroidmenuitem_p.h | 137 ---- src/qmlandroid/view/qqmlandroidview.cpp | 898 --------------------- src/qmlandroid/view/qqmlandroidview_p.h | 346 -------- src/qmlandroid/view/qqmlandroidviewgroup.cpp | 100 --- src/qmlandroid/view/qqmlandroidviewgroup_p.h | 75 -- src/qmlandroid/view/qqmlandroidwindow.cpp | 76 -- src/qmlandroid/view/qqmlandroidwindow_p.h | 79 -- src/qmlandroid/view/view.pri | 20 - src/qmlandroid/widget/qqmlandroidabsseekbar.cpp | 58 -- src/qmlandroid/widget/qqmlandroidabsseekbar_p.h | 69 -- src/qmlandroid/widget/qqmlandroidadapterview.cpp | 141 ---- src/qmlandroid/widget/qqmlandroidadapterview_p.h | 94 --- src/qmlandroid/widget/qqmlandroidarrayadapter.cpp | 110 --- src/qmlandroid/widget/qqmlandroidarrayadapter_p.h | 92 --- src/qmlandroid/widget/qqmlandroidbaseadapter.cpp | 56 -- src/qmlandroid/widget/qqmlandroidbaseadapter_p.h | 78 -- src/qmlandroid/widget/qqmlandroidbutton.cpp | 58 -- src/qmlandroid/widget/qqmlandroidbutton_p.h | 69 -- src/qmlandroid/widget/qqmlandroidcalendarview.cpp | 58 -- src/qmlandroid/widget/qqmlandroidcalendarview_p.h | 69 -- src/qmlandroid/widget/qqmlandroidcheckbox.cpp | 58 -- src/qmlandroid/widget/qqmlandroidcheckbox_p.h | 69 -- .../widget/qqmlandroidcompoundbutton.cpp | 117 --- .../widget/qqmlandroidcompoundbutton_p.h | 89 -- src/qmlandroid/widget/qqmlandroiddatepicker.cpp | 58 -- src/qmlandroid/widget/qqmlandroiddatepicker_p.h | 69 -- src/qmlandroid/widget/qqmlandroidedittext.cpp | 58 -- src/qmlandroid/widget/qqmlandroidedittext_p.h | 69 -- src/qmlandroid/widget/qqmlandroidframelayout.cpp | 66 -- src/qmlandroid/widget/qqmlandroidframelayout_p.h | 74 -- .../widget/qqmlandroidframelayoutparams.cpp | 78 -- .../widget/qqmlandroidframelayoutparams_p.h | 79 -- src/qmlandroid/widget/qqmlandroidimageview.cpp | 136 ---- src/qmlandroid/widget/qqmlandroidimageview_p.h | 95 --- src/qmlandroid/widget/qqmlandroidlinearlayout.cpp | 163 ---- src/qmlandroid/widget/qqmlandroidlinearlayout_p.h | 120 --- .../widget/qqmlandroidlinearlayoutparams.cpp | 96 --- .../widget/qqmlandroidlinearlayoutparams_p.h | 85 -- src/qmlandroid/widget/qqmlandroidlistview.cpp | 58 -- src/qmlandroid/widget/qqmlandroidlistview_p.h | 69 -- .../widget/qqmlandroidmarginlayoutparams.cpp | 146 ---- .../widget/qqmlandroidmarginlayoutparams_p.h | 103 --- src/qmlandroid/widget/qqmlandroidnumberpicker.cpp | 112 --- src/qmlandroid/widget/qqmlandroidnumberpicker_p.h | 86 -- src/qmlandroid/widget/qqmlandroidpopupmenu.cpp | 137 ---- src/qmlandroid/widget/qqmlandroidpopupmenu_p.h | 94 --- src/qmlandroid/widget/qqmlandroidprogressbar.cpp | 143 ---- src/qmlandroid/widget/qqmlandroidprogressbar_p.h | 118 --- src/qmlandroid/widget/qqmlandroidradiobutton.cpp | 58 -- src/qmlandroid/widget/qqmlandroidradiobutton_p.h | 69 -- src/qmlandroid/widget/qqmlandroidradiogroup.cpp | 131 --- src/qmlandroid/widget/qqmlandroidradiogroup_p.h | 92 --- src/qmlandroid/widget/qqmlandroidratingbar.cpp | 112 --- src/qmlandroid/widget/qqmlandroidratingbar_p.h | 86 -- .../widget/qqmlandroidrelativelayout.cpp | 66 -- .../widget/qqmlandroidrelativelayout_p.h | 99 --- .../widget/qqmlandroidrelativelayoutparams.cpp | 445 ---------- .../widget/qqmlandroidrelativelayoutparams_p.h | 213 ----- src/qmlandroid/widget/qqmlandroidscrollview.cpp | 131 --- src/qmlandroid/widget/qqmlandroidscrollview_p.h | 92 --- src/qmlandroid/widget/qqmlandroidsearchview.cpp | 58 -- src/qmlandroid/widget/qqmlandroidsearchview_p.h | 69 -- src/qmlandroid/widget/qqmlandroidseekbar.cpp | 88 -- src/qmlandroid/widget/qqmlandroidseekbar_p.h | 75 -- src/qmlandroid/widget/qqmlandroidspace.cpp | 58 -- src/qmlandroid/widget/qqmlandroidspace_p.h | 69 -- src/qmlandroid/widget/qqmlandroidspinner.cpp | 58 -- src/qmlandroid/widget/qqmlandroidspinner_p.h | 69 -- src/qmlandroid/widget/qqmlandroidswitch.cpp | 58 -- src/qmlandroid/widget/qqmlandroidswitch_p.h | 69 -- src/qmlandroid/widget/qqmlandroidtabhost.cpp | 96 --- src/qmlandroid/widget/qqmlandroidtabhost_p.h | 78 -- src/qmlandroid/widget/qqmlandroidtabspec.cpp | 101 --- src/qmlandroid/widget/qqmlandroidtabspec_p.h | 88 -- src/qmlandroid/widget/qqmlandroidtabwidget.cpp | 59 -- src/qmlandroid/widget/qqmlandroidtabwidget_p.h | 69 -- src/qmlandroid/widget/qqmlandroidtextview.cpp | 163 ---- src/qmlandroid/widget/qqmlandroidtextview_p.h | 111 --- src/qmlandroid/widget/qqmlandroidtimepicker.cpp | 58 -- src/qmlandroid/widget/qqmlandroidtimepicker_p.h | 69 -- src/qmlandroid/widget/qqmlandroidtoast.cpp | 119 --- src/qmlandroid/widget/qqmlandroidtoast_p.h | 88 -- src/qmlandroid/widget/qqmlandroidtogglebutton.cpp | 92 --- src/qmlandroid/widget/qqmlandroidtogglebutton_p.h | 85 -- src/qmlandroid/widget/qqmlandroidviewanimator.cpp | 134 --- src/qmlandroid/widget/qqmlandroidviewanimator_p.h | 95 --- src/qmlandroid/widget/qqmlandroidviewflipper.cpp | 58 -- src/qmlandroid/widget/qqmlandroidviewflipper_p.h | 69 -- src/qmlandroid/widget/qqmlandroidviewswitcher.cpp | 58 -- src/qmlandroid/widget/qqmlandroidviewswitcher_p.h | 69 -- src/qmlandroid/widget/widget.pri | 87 -- src/src.pro | 7 +- sync.profile | 2 +- 382 files changed, 17941 insertions(+), 17947 deletions(-) create mode 100644 src/android/android.pri create mode 100644 src/android/app/app.pri create mode 100644 src/android/app/qqmlandroidactionbar.cpp create mode 100644 src/android/app/qqmlandroidactionbar_p.h create mode 100644 src/android/app/qqmlandroidactivity.cpp create mode 100644 src/android/app/qqmlandroidactivity_p.h create mode 100644 src/android/app/qqmlandroidalertdialog.cpp create mode 100644 src/android/app/qqmlandroidalertdialog_p.h create mode 100644 src/android/app/qqmlandroiddialog.cpp create mode 100644 src/android/app/qqmlandroiddialog_p.h create mode 100644 src/android/app/qqmlandroidservice.cpp create mode 100644 src/android/app/qqmlandroidservice_p.h create mode 100644 src/android/content/content.pri create mode 100644 src/android/content/qqmlandroidcontext.cpp create mode 100644 src/android/content/qqmlandroidcontext_p.h create mode 100644 src/android/content/qqmlandroidcontextual.cpp create mode 100644 src/android/content/qqmlandroidcontextual_p.h create mode 100644 src/android/content/qqmlandroidcontextwrapper.cpp create mode 100644 src/android/content/qqmlandroidcontextwrapper_p.h create mode 100644 src/android/core/core.pri create mode 100644 src/android/core/qqmlandroidobject.cpp create mode 100644 src/android/core/qqmlandroidobject_p.h create mode 100644 src/android/core/qqmlandroidoptional_p.h create mode 100644 src/android/core/qtqmlandroidfunctions.cpp create mode 100644 src/android/core/qtqmlandroidfunctions_p.h create mode 100644 src/android/core/qtqmlandroidglobal_p.h create mode 100644 src/android/graphics/drawable/drawable.pri create mode 100644 src/android/graphics/drawable/qqmlandroidcolordrawable.cpp create mode 100644 src/android/graphics/drawable/qqmlandroidcolordrawable_p.h create mode 100644 src/android/graphics/drawable/qqmlandroiddrawable.cpp create mode 100644 src/android/graphics/drawable/qqmlandroiddrawable_p.h create mode 100644 src/android/graphics/graphics.pri create mode 100644 src/android/graphics/qqmlandroidcolor.cpp create mode 100644 src/android/graphics/qqmlandroidcolor_p.h create mode 100644 src/android/java/java.pri delete mode 100644 src/android/java/java.pro create mode 100644 src/android/qqmlandroidr.cpp create mode 100644 src/android/qqmlandroidr_p.h create mode 100644 src/android/support/support.pri create mode 100644 src/android/support/v4/v4.pri create mode 100644 src/android/support/v4/widget/qqmlandroiddrawerlayout.cpp create mode 100644 src/android/support/v4/widget/qqmlandroiddrawerlayout_p.h create mode 100644 src/android/support/v4/widget/qqmlandroiddrawerlayoutparams.cpp create mode 100644 src/android/support/v4/widget/qqmlandroiddrawerlayoutparams_p.h create mode 100644 src/android/support/v4/widget/qqmlandroidswiperefreshlayout.cpp create mode 100644 src/android/support/v4/widget/qqmlandroidswiperefreshlayout_p.h create mode 100644 src/android/support/v4/widget/widget.pri create mode 100644 src/android/support/v7/app/app.pri create mode 100644 src/android/support/v7/app/qqmlandroidactionbardrawertoggle.cpp create mode 100644 src/android/support/v7/app/qqmlandroidactionbardrawertoggle_p.h create mode 100644 src/android/support/v7/v7.pri create mode 100644 src/android/support/v7/widget/qqmlandroidcardview.cpp create mode 100644 src/android/support/v7/widget/qqmlandroidcardview_p.h create mode 100644 src/android/support/v7/widget/qqmlandroidrecycleradapter.cpp create mode 100644 src/android/support/v7/widget/qqmlandroidrecycleradapter_p.h create mode 100644 src/android/support/v7/widget/qqmlandroidrecyclerview.cpp create mode 100644 src/android/support/v7/widget/qqmlandroidrecyclerview_p.h create mode 100644 src/android/support/v7/widget/widget.pri create mode 100644 src/android/view/animation/animation.pri create mode 100644 src/android/view/animation/qqmlandroidacceleratedecelerateinterpolator.cpp create mode 100644 src/android/view/animation/qqmlandroidacceleratedecelerateinterpolator_p.h create mode 100644 src/android/view/animation/qqmlandroidaccelerateinterpolator.cpp create mode 100644 src/android/view/animation/qqmlandroidaccelerateinterpolator_p.h create mode 100644 src/android/view/animation/qqmlandroidalphaanimation.cpp create mode 100644 src/android/view/animation/qqmlandroidalphaanimation_p.h create mode 100644 src/android/view/animation/qqmlandroidanimation.cpp create mode 100644 src/android/view/animation/qqmlandroidanimation_p.h create mode 100644 src/android/view/animation/qqmlandroidanimationset.cpp create mode 100644 src/android/view/animation/qqmlandroidanimationset_p.h create mode 100644 src/android/view/animation/qqmlandroidanticipateinterpolator.cpp create mode 100644 src/android/view/animation/qqmlandroidanticipateinterpolator_p.h create mode 100644 src/android/view/animation/qqmlandroidanticipateovershootinterpolator.cpp create mode 100644 src/android/view/animation/qqmlandroidanticipateovershootinterpolator_p.h create mode 100644 src/android/view/animation/qqmlandroidbounceinterpolator.cpp create mode 100644 src/android/view/animation/qqmlandroidbounceinterpolator_p.h create mode 100644 src/android/view/animation/qqmlandroidcycleinterpolator.cpp create mode 100644 src/android/view/animation/qqmlandroidcycleinterpolator_p.h create mode 100644 src/android/view/animation/qqmlandroiddecelerateinterpolator.cpp create mode 100644 src/android/view/animation/qqmlandroiddecelerateinterpolator_p.h create mode 100644 src/android/view/animation/qqmlandroidinterpolator.cpp create mode 100644 src/android/view/animation/qqmlandroidinterpolator_p.h create mode 100644 src/android/view/animation/qqmlandroidlinearinterpolator.cpp create mode 100644 src/android/view/animation/qqmlandroidlinearinterpolator_p.h create mode 100644 src/android/view/animation/qqmlandroidovershootinterpolator.cpp create mode 100644 src/android/view/animation/qqmlandroidovershootinterpolator_p.h create mode 100644 src/android/view/animation/qqmlandroidpathinterpolator.cpp create mode 100644 src/android/view/animation/qqmlandroidpathinterpolator_p.h create mode 100644 src/android/view/animation/qqmlandroidrotateanimation.cpp create mode 100644 src/android/view/animation/qqmlandroidrotateanimation_p.h create mode 100644 src/android/view/animation/qqmlandroidscaleanimation.cpp create mode 100644 src/android/view/animation/qqmlandroidscaleanimation_p.h create mode 100644 src/android/view/animation/qqmlandroidtranslateanimation.cpp create mode 100644 src/android/view/animation/qqmlandroidtranslateanimation_p.h create mode 100644 src/android/view/qqmlandroidgravity_p.h create mode 100644 src/android/view/qqmlandroidlayoutparams.cpp create mode 100644 src/android/view/qqmlandroidlayoutparams_p.h create mode 100644 src/android/view/qqmlandroidmenu.cpp create mode 100644 src/android/view/qqmlandroidmenu_p.h create mode 100644 src/android/view/qqmlandroidmenuitem.cpp create mode 100644 src/android/view/qqmlandroidmenuitem_p.h create mode 100644 src/android/view/qqmlandroidview.cpp create mode 100644 src/android/view/qqmlandroidview_p.h create mode 100644 src/android/view/qqmlandroidviewgroup.cpp create mode 100644 src/android/view/qqmlandroidviewgroup_p.h create mode 100644 src/android/view/qqmlandroidwindow.cpp create mode 100644 src/android/view/qqmlandroidwindow_p.h create mode 100644 src/android/view/view.pri create mode 100644 src/android/widget/qqmlandroidabsseekbar.cpp create mode 100644 src/android/widget/qqmlandroidabsseekbar_p.h create mode 100644 src/android/widget/qqmlandroidadapterview.cpp create mode 100644 src/android/widget/qqmlandroidadapterview_p.h create mode 100644 src/android/widget/qqmlandroidarrayadapter.cpp create mode 100644 src/android/widget/qqmlandroidarrayadapter_p.h create mode 100644 src/android/widget/qqmlandroidbaseadapter.cpp create mode 100644 src/android/widget/qqmlandroidbaseadapter_p.h create mode 100644 src/android/widget/qqmlandroidbutton.cpp create mode 100644 src/android/widget/qqmlandroidbutton_p.h create mode 100644 src/android/widget/qqmlandroidcalendarview.cpp create mode 100644 src/android/widget/qqmlandroidcalendarview_p.h create mode 100644 src/android/widget/qqmlandroidcheckbox.cpp create mode 100644 src/android/widget/qqmlandroidcheckbox_p.h create mode 100644 src/android/widget/qqmlandroidcompoundbutton.cpp create mode 100644 src/android/widget/qqmlandroidcompoundbutton_p.h create mode 100644 src/android/widget/qqmlandroiddatepicker.cpp create mode 100644 src/android/widget/qqmlandroiddatepicker_p.h create mode 100644 src/android/widget/qqmlandroidedittext.cpp create mode 100644 src/android/widget/qqmlandroidedittext_p.h create mode 100644 src/android/widget/qqmlandroidframelayout.cpp create mode 100644 src/android/widget/qqmlandroidframelayout_p.h create mode 100644 src/android/widget/qqmlandroidframelayoutparams.cpp create mode 100644 src/android/widget/qqmlandroidframelayoutparams_p.h create mode 100644 src/android/widget/qqmlandroidimageview.cpp create mode 100644 src/android/widget/qqmlandroidimageview_p.h create mode 100644 src/android/widget/qqmlandroidlinearlayout.cpp create mode 100644 src/android/widget/qqmlandroidlinearlayout_p.h create mode 100644 src/android/widget/qqmlandroidlinearlayoutparams.cpp create mode 100644 src/android/widget/qqmlandroidlinearlayoutparams_p.h create mode 100644 src/android/widget/qqmlandroidlistview.cpp create mode 100644 src/android/widget/qqmlandroidlistview_p.h create mode 100644 src/android/widget/qqmlandroidmarginlayoutparams.cpp create mode 100644 src/android/widget/qqmlandroidmarginlayoutparams_p.h create mode 100644 src/android/widget/qqmlandroidnumberpicker.cpp create mode 100644 src/android/widget/qqmlandroidnumberpicker_p.h create mode 100644 src/android/widget/qqmlandroidpopupmenu.cpp create mode 100644 src/android/widget/qqmlandroidpopupmenu_p.h create mode 100644 src/android/widget/qqmlandroidprogressbar.cpp create mode 100644 src/android/widget/qqmlandroidprogressbar_p.h create mode 100644 src/android/widget/qqmlandroidradiobutton.cpp create mode 100644 src/android/widget/qqmlandroidradiobutton_p.h create mode 100644 src/android/widget/qqmlandroidradiogroup.cpp create mode 100644 src/android/widget/qqmlandroidradiogroup_p.h create mode 100644 src/android/widget/qqmlandroidratingbar.cpp create mode 100644 src/android/widget/qqmlandroidratingbar_p.h create mode 100644 src/android/widget/qqmlandroidrelativelayout.cpp create mode 100644 src/android/widget/qqmlandroidrelativelayout_p.h create mode 100644 src/android/widget/qqmlandroidrelativelayoutparams.cpp create mode 100644 src/android/widget/qqmlandroidrelativelayoutparams_p.h create mode 100644 src/android/widget/qqmlandroidscrollview.cpp create mode 100644 src/android/widget/qqmlandroidscrollview_p.h create mode 100644 src/android/widget/qqmlandroidsearchview.cpp create mode 100644 src/android/widget/qqmlandroidsearchview_p.h create mode 100644 src/android/widget/qqmlandroidseekbar.cpp create mode 100644 src/android/widget/qqmlandroidseekbar_p.h create mode 100644 src/android/widget/qqmlandroidspace.cpp create mode 100644 src/android/widget/qqmlandroidspace_p.h create mode 100644 src/android/widget/qqmlandroidspinner.cpp create mode 100644 src/android/widget/qqmlandroidspinner_p.h create mode 100644 src/android/widget/qqmlandroidswitch.cpp create mode 100644 src/android/widget/qqmlandroidswitch_p.h create mode 100644 src/android/widget/qqmlandroidtabhost.cpp create mode 100644 src/android/widget/qqmlandroidtabhost_p.h create mode 100644 src/android/widget/qqmlandroidtabspec.cpp create mode 100644 src/android/widget/qqmlandroidtabspec_p.h create mode 100644 src/android/widget/qqmlandroidtabwidget.cpp create mode 100644 src/android/widget/qqmlandroidtabwidget_p.h create mode 100644 src/android/widget/qqmlandroidtextview.cpp create mode 100644 src/android/widget/qqmlandroidtextview_p.h create mode 100644 src/android/widget/qqmlandroidtimepicker.cpp create mode 100644 src/android/widget/qqmlandroidtimepicker_p.h create mode 100644 src/android/widget/qqmlandroidtoast.cpp create mode 100644 src/android/widget/qqmlandroidtoast_p.h create mode 100644 src/android/widget/qqmlandroidtogglebutton.cpp create mode 100644 src/android/widget/qqmlandroidtogglebutton_p.h create mode 100644 src/android/widget/qqmlandroidviewanimator.cpp create mode 100644 src/android/widget/qqmlandroidviewanimator_p.h create mode 100644 src/android/widget/qqmlandroidviewflipper.cpp create mode 100644 src/android/widget/qqmlandroidviewflipper_p.h create mode 100644 src/android/widget/qqmlandroidviewswitcher.cpp create mode 100644 src/android/widget/qqmlandroidviewswitcher_p.h create mode 100644 src/android/widget/widget.pri delete mode 100644 src/qmlandroid/app/app.pri delete mode 100644 src/qmlandroid/app/qqmlandroidactionbar.cpp delete mode 100644 src/qmlandroid/app/qqmlandroidactionbar_p.h delete mode 100644 src/qmlandroid/app/qqmlandroidactivity.cpp delete mode 100644 src/qmlandroid/app/qqmlandroidactivity_p.h delete mode 100644 src/qmlandroid/app/qqmlandroidalertdialog.cpp delete mode 100644 src/qmlandroid/app/qqmlandroidalertdialog_p.h delete mode 100644 src/qmlandroid/app/qqmlandroiddialog.cpp delete mode 100644 src/qmlandroid/app/qqmlandroiddialog_p.h delete mode 100644 src/qmlandroid/app/qqmlandroidservice.cpp delete mode 100644 src/qmlandroid/app/qqmlandroidservice_p.h delete mode 100644 src/qmlandroid/content/content.pri delete mode 100644 src/qmlandroid/content/qqmlandroidcontext.cpp delete mode 100644 src/qmlandroid/content/qqmlandroidcontext_p.h delete mode 100644 src/qmlandroid/content/qqmlandroidcontextual.cpp delete mode 100644 src/qmlandroid/content/qqmlandroidcontextual_p.h delete mode 100644 src/qmlandroid/content/qqmlandroidcontextwrapper.cpp delete mode 100644 src/qmlandroid/content/qqmlandroidcontextwrapper_p.h delete mode 100644 src/qmlandroid/core/core.pri delete mode 100644 src/qmlandroid/core/qqmlandroidobject.cpp delete mode 100644 src/qmlandroid/core/qqmlandroidobject_p.h delete mode 100644 src/qmlandroid/core/qqmlandroidoptional_p.h delete mode 100644 src/qmlandroid/core/qtqmlandroidfunctions.cpp delete mode 100644 src/qmlandroid/core/qtqmlandroidfunctions_p.h delete mode 100644 src/qmlandroid/core/qtqmlandroidglobal_p.h delete mode 100644 src/qmlandroid/graphics/drawable/drawable.pri delete mode 100644 src/qmlandroid/graphics/drawable/qqmlandroidcolordrawable.cpp delete mode 100644 src/qmlandroid/graphics/drawable/qqmlandroidcolordrawable_p.h delete mode 100644 src/qmlandroid/graphics/drawable/qqmlandroiddrawable.cpp delete mode 100644 src/qmlandroid/graphics/drawable/qqmlandroiddrawable_p.h delete mode 100644 src/qmlandroid/graphics/graphics.pri delete mode 100644 src/qmlandroid/graphics/qqmlandroidcolor.cpp delete mode 100644 src/qmlandroid/graphics/qqmlandroidcolor_p.h delete mode 100644 src/qmlandroid/qmlandroid.pri delete mode 100644 src/qmlandroid/qmlandroid.pro delete mode 100644 src/qmlandroid/qqmlandroidr.cpp delete mode 100644 src/qmlandroid/qqmlandroidr_p.h delete mode 100644 src/qmlandroid/support/support.pri delete mode 100644 src/qmlandroid/support/v4/v4.pri delete mode 100644 src/qmlandroid/support/v4/widget/qqmlandroiddrawerlayout.cpp delete mode 100644 src/qmlandroid/support/v4/widget/qqmlandroiddrawerlayout_p.h delete mode 100644 src/qmlandroid/support/v4/widget/qqmlandroiddrawerlayoutparams.cpp delete mode 100644 src/qmlandroid/support/v4/widget/qqmlandroiddrawerlayoutparams_p.h delete mode 100644 src/qmlandroid/support/v4/widget/qqmlandroidswiperefreshlayout.cpp delete mode 100644 src/qmlandroid/support/v4/widget/qqmlandroidswiperefreshlayout_p.h delete mode 100644 src/qmlandroid/support/v4/widget/widget.pri delete mode 100644 src/qmlandroid/support/v7/app/app.pri delete mode 100644 src/qmlandroid/support/v7/app/qqmlandroidactionbardrawertoggle.cpp delete mode 100644 src/qmlandroid/support/v7/app/qqmlandroidactionbardrawertoggle_p.h delete mode 100644 src/qmlandroid/support/v7/v7.pri delete mode 100644 src/qmlandroid/support/v7/widget/qqmlandroidcardview.cpp delete mode 100644 src/qmlandroid/support/v7/widget/qqmlandroidcardview_p.h delete mode 100644 src/qmlandroid/support/v7/widget/qqmlandroidrecycleradapter.cpp delete mode 100644 src/qmlandroid/support/v7/widget/qqmlandroidrecycleradapter_p.h delete mode 100644 src/qmlandroid/support/v7/widget/qqmlandroidrecyclerview.cpp delete mode 100644 src/qmlandroid/support/v7/widget/qqmlandroidrecyclerview_p.h delete mode 100644 src/qmlandroid/support/v7/widget/widget.pri delete mode 100644 src/qmlandroid/view/animation/animation.pri delete mode 100644 src/qmlandroid/view/animation/qqmlandroidacceleratedecelerateinterpolator.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidacceleratedecelerateinterpolator_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidaccelerateinterpolator.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidaccelerateinterpolator_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidalphaanimation.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidalphaanimation_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidanimation.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidanimation_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidanimationset.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidanimationset_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidanticipateinterpolator.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidanticipateinterpolator_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidanticipateovershootinterpolator.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidanticipateovershootinterpolator_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidbounceinterpolator.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidbounceinterpolator_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidcycleinterpolator.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidcycleinterpolator_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroiddecelerateinterpolator.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroiddecelerateinterpolator_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidinterpolator.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidinterpolator_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidlinearinterpolator.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidlinearinterpolator_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidovershootinterpolator.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidovershootinterpolator_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidpathinterpolator.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidpathinterpolator_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidrotateanimation.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidrotateanimation_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidscaleanimation.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidscaleanimation_p.h delete mode 100644 src/qmlandroid/view/animation/qqmlandroidtranslateanimation.cpp delete mode 100644 src/qmlandroid/view/animation/qqmlandroidtranslateanimation_p.h delete mode 100644 src/qmlandroid/view/qqmlandroidgravity_p.h delete mode 100644 src/qmlandroid/view/qqmlandroidlayoutparams.cpp delete mode 100644 src/qmlandroid/view/qqmlandroidlayoutparams_p.h delete mode 100644 src/qmlandroid/view/qqmlandroidmenu.cpp delete mode 100644 src/qmlandroid/view/qqmlandroidmenu_p.h delete mode 100644 src/qmlandroid/view/qqmlandroidmenuitem.cpp delete mode 100644 src/qmlandroid/view/qqmlandroidmenuitem_p.h delete mode 100644 src/qmlandroid/view/qqmlandroidview.cpp delete mode 100644 src/qmlandroid/view/qqmlandroidview_p.h delete mode 100644 src/qmlandroid/view/qqmlandroidviewgroup.cpp delete mode 100644 src/qmlandroid/view/qqmlandroidviewgroup_p.h delete mode 100644 src/qmlandroid/view/qqmlandroidwindow.cpp delete mode 100644 src/qmlandroid/view/qqmlandroidwindow_p.h delete mode 100644 src/qmlandroid/view/view.pri delete mode 100644 src/qmlandroid/widget/qqmlandroidabsseekbar.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidabsseekbar_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidadapterview.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidadapterview_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidarrayadapter.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidarrayadapter_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidbaseadapter.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidbaseadapter_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidbutton.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidbutton_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidcalendarview.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidcalendarview_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidcheckbox.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidcheckbox_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidcompoundbutton.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidcompoundbutton_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroiddatepicker.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroiddatepicker_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidedittext.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidedittext_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidframelayout.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidframelayout_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidframelayoutparams.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidframelayoutparams_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidimageview.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidimageview_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidlinearlayout.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidlinearlayout_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidlinearlayoutparams.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidlinearlayoutparams_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidlistview.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidlistview_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidmarginlayoutparams.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidmarginlayoutparams_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidnumberpicker.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidnumberpicker_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidpopupmenu.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidpopupmenu_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidprogressbar.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidprogressbar_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidradiobutton.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidradiobutton_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidradiogroup.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidradiogroup_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidratingbar.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidratingbar_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidrelativelayout.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidrelativelayout_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidrelativelayoutparams.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidrelativelayoutparams_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidscrollview.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidscrollview_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidsearchview.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidsearchview_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidseekbar.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidseekbar_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidspace.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidspace_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidspinner.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidspinner_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidswitch.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidswitch_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidtabhost.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidtabhost_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidtabspec.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidtabspec_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidtabwidget.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidtabwidget_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidtextview.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidtextview_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidtimepicker.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidtimepicker_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidtoast.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidtoast_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidtogglebutton.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidtogglebutton_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidviewanimator.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidviewanimator_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidviewflipper.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidviewflipper_p.h delete mode 100644 src/qmlandroid/widget/qqmlandroidviewswitcher.cpp delete mode 100644 src/qmlandroid/widget/qqmlandroidviewswitcher_p.h delete mode 100644 src/qmlandroid/widget/widget.pri diff --git a/src/android/android.pri b/src/android/android.pri new file mode 100644 index 0000000..d7ecc31 --- /dev/null +++ b/src/android/android.pri @@ -0,0 +1,15 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qqmlandroidr_p.h + +SOURCES += \ + $$PWD/qqmlandroidr.cpp + +include(app/app.pri) +include(core/core.pri) +include(content/content.pri) +include(graphics/graphics.pri) +include(support/support.pri) +include(view/view.pri) +include(widget/widget.pri) diff --git a/src/android/android.pro b/src/android/android.pro index 5221a4c..bfc111f 100644 --- a/src/android/android.pro +++ b/src/android/android.pro @@ -1,3 +1,16 @@ -TEMPLATE = subdirs -SUBDIRS += \ - java +TARGET = QtQmlAndroid + +QT += androidextras qml +QT += core-private # qjnihelpers + +CONFIG += c++11 +CONFIG -= create_cmake + +features.files = $$QMLANDROID_PREFIX/features/qmlandroid.prf +features.path = $$[QT_HOST_DATA]/mkspecs/features +!prefix_build: COPIES += features +INSTALLS += features + +include(qmlandroid.pri) + +load(qt_module) diff --git a/src/android/app/app.pri b/src/android/app/app.pri new file mode 100644 index 0000000..f7951c0 --- /dev/null +++ b/src/android/app/app.pri @@ -0,0 +1,15 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qqmlandroidactionbar_p.h \ + $$PWD/qqmlandroidactivity_p.h \ + $$PWD/qqmlandroidalertdialog_p.h \ + $$PWD/qqmlandroiddialog_p.h \ + $$PWD/qqmlandroidservice_p.h + +SOURCES += \ + $$PWD/qqmlandroidactionbar.cpp \ + $$PWD/qqmlandroidactivity.cpp \ + $$PWD/qqmlandroidalertdialog.cpp \ + $$PWD/qqmlandroiddialog.cpp \ + $$PWD/qqmlandroidservice.cpp diff --git a/src/android/app/qqmlandroidactionbar.cpp b/src/android/app/qqmlandroidactionbar.cpp new file mode 100644 index 0000000..6b6893b --- /dev/null +++ b/src/android/app/qqmlandroidactionbar.cpp @@ -0,0 +1,162 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidactionbar_p.h" +#include "qqmlandroiddrawable_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidActionBar::QQmlAndroidActionBar(QObject *parent) : + QQmlAndroidObject(parent), m_visible(true), m_elevation(0.0), m_background(0) +{ +} + +bool QQmlAndroidActionBar::isVisible() const +{ + return m_visible; +} + +void QQmlAndroidActionBar::setVisible(bool arg) +{ + if (arg != isVisible()) { + m_visible = arg; + if (arg) + QtQmlAndroid::callVoidMethod(instance(), "show"); + else + QtQmlAndroid::callVoidMethod(instance(), "hide"); + emit visibleChanged(); + } +} + +qreal QQmlAndroidActionBar::elevation() const +{ + return m_elevation; +} + +void QQmlAndroidActionBar::setElevation(qreal elevation) +{ + if (m_elevation != elevation) { + m_elevation = elevation; + QtQmlAndroid::callRealMethod(instance(), "setElevation", elevation); + emit elevationChanged(); + } +} + +QString QQmlAndroidActionBar::title() const +{ + return m_title; +} + +void QQmlAndroidActionBar::setTitle(const QString &title) +{ + if (m_title != title) { + m_title = title; + QtQmlAndroid::callTextMethod(instance(), "setTitle", title); + emit titleChanged(); + } +} + +QString QQmlAndroidActionBar::subtitle() const +{ + return m_subtitle; +} + +void QQmlAndroidActionBar::setSubtitle(const QString &subtitle) +{ + if (m_subtitle != subtitle) { + m_subtitle = subtitle; + QtQmlAndroid::callTextMethod(instance(), "setSubtitle", subtitle); + emit subtitleChanged(); + } +} + +QQmlAndroidDrawable *QQmlAndroidActionBar::background() const +{ + return m_background; +} + +void QQmlAndroidActionBar::setBackground(QQmlAndroidDrawable *background) +{ + if (m_background != background) { + if (m_background) { + disconnect(m_background, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidActionBar::updateBackground); + m_background->destruct(); + } + m_background = background; + if (m_background) { + connect(m_background, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidActionBar::updateBackground); + m_background->construct(); + } + emit backgroundChanged(); + } +} + +void QQmlAndroidActionBar::onInflate(QAndroidJniObject &instance) +{ + instance.callMethod(m_visible ? "show" : "hide"); + + if (!m_title.isNull()) + instance.callMethod("setTitle", "(Ljava/lang/CharSequence;)V", QAndroidJniObject::fromString(m_title).object()); + if (!m_subtitle.isNull()) + instance.callMethod("setSubtitle", "(Ljava/lang/CharSequence;)V", QAndroidJniObject::fromString(m_subtitle).object()); + + // TODO: properties + instance.callMethod("setElevation", "(F)V", m_elevation); + instance.callMethod("setDisplayHomeAsUpEnabled", "(Z)V", true); + instance.callMethod("setHomeButtonEnabled", "(Z)V", true); +} + +void QQmlAndroidActionBar::objectChange(ObjectChange change) +{ + QQmlAndroidObject::objectChange(change); + if (change == InstanceChange) + updateBackground(); +} + +void QQmlAndroidActionBar::updateBackground() +{ + if (!isValid() || !m_background) + return; + + QAndroidJniObject bar = instance(); + QAndroidJniObject background = m_background->instance(); + QtQmlAndroid::callFunction([=]() { + bar.callMethod("setBackgroundDrawable", "(Landroid/graphics/drawable/Drawable;)V", background.object()); + }); +} + +QT_END_NAMESPACE diff --git a/src/android/app/qqmlandroidactionbar_p.h b/src/android/app/qqmlandroidactionbar_p.h new file mode 100644 index 0000000..2bc70a2 --- /dev/null +++ b/src/android/app/qqmlandroidactionbar_p.h @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDACTIONBAR_P_H +#define QQMLANDROIDACTIONBAR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QQmlAndroidDrawable; + +class Q_QMLANDROID_EXPORT QQmlAndroidActionBar : public QQmlAndroidObject +{ + Q_OBJECT + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(qreal elevation READ elevation WRITE setElevation NOTIFY elevationChanged) + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + Q_PROPERTY(QString subtitle READ subtitle WRITE setSubtitle NOTIFY subtitleChanged) + Q_PROPERTY(QQmlAndroidDrawable *background READ background WRITE setBackground NOTIFY backgroundChanged) + +public: + explicit QQmlAndroidActionBar(QObject *parent = nullptr); + + bool isVisible() const; + void setVisible(bool visible); + + qreal elevation() const; + void setElevation(qreal elevation); + + QString title() const; + void setTitle(const QString &title); + + QString subtitle() const; + void setSubtitle(const QString &subtitle); + + QQmlAndroidDrawable *background() const; + void setBackground(QQmlAndroidDrawable *background); + +Q_SIGNALS: + void visibleChanged(); + void elevationChanged(); + void titleChanged(); + void subtitleChanged(); + void backgroundChanged(); + +protected: + void onInflate(QAndroidJniObject &instance) override; + + void objectChange(ObjectChange change) override; + +private Q_SLOTS: + void updateBackground(); + +private: + bool m_visible; + qreal m_elevation; + QString m_title; + QString m_subtitle; + QQmlAndroidDrawable *m_background; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDACTIONBAR_P_H diff --git a/src/android/app/qqmlandroidactivity.cpp b/src/android/app/qqmlandroidactivity.cpp new file mode 100644 index 0000000..b740efb --- /dev/null +++ b/src/android/app/qqmlandroidactivity.cpp @@ -0,0 +1,202 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidactivity_p.h" +#include "qqmlandroidactionbar_p.h" +#include "qqmlandroidmenuitem_p.h" +#include "qqmlandroidmenu_p.h" +#include "qqmlandroidview_p.h" +#include "qqmlandroidwindow_p.h" +#include "qtqmlandroidfunctions_p.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QQmlAndroidActivity::QQmlAndroidActivity(QObject *parent) : + QQmlAndroidContextWrapper(parent), m_window(new QQmlAndroidWindow(this)), + m_contentView(0), m_optionsMenu(0), m_actionBar(0) +{ + // TODO: multiple activities? + setInstance(QtAndroid::androidActivity()); +} + +QQmlAndroidWindow *QQmlAndroidActivity::window() const +{ + return m_window; +} + +QQmlAndroidActionBar *QQmlAndroidActivity::actionBar() const +{ + return m_actionBar; +} + +void QQmlAndroidActivity::setActionBar(QQmlAndroidActionBar *bar) +{ + if (m_actionBar != bar) { + if (m_actionBar) + m_actionBar->destruct(); + m_actionBar = bar; + if (m_actionBar) + setupActionBar(); + } +} + +QQmlAndroidMenu *QQmlAndroidActivity::optionsMenu() const +{ + return m_optionsMenu; +} + +void QQmlAndroidActivity::setOptionsMenu(QQmlAndroidMenu *menu) +{ + if (m_optionsMenu != menu) { + if (m_optionsMenu) { + disconnect(m_optionsMenu, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidActivity::updateOptionsMenu); + m_optionsMenu->destruct(); + } + m_optionsMenu = menu; + if (m_optionsMenu) { + connect(m_optionsMenu, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidActivity::updateOptionsMenu); + if (isComponentComplete()) + m_optionsMenu->construct(); + } + } +} + +QQmlAndroidView *QQmlAndroidActivity::contentView() const +{ + return m_contentView; +} + +void QQmlAndroidActivity::setContentView(QQmlAndroidView *view) +{ + if (m_contentView != view) { + if (m_contentView) { + disconnect(m_contentView, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidActivity::updateContentView); + m_contentView->destruct(); + } + m_contentView = view; + if (m_contentView) { + connect(m_contentView, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidActivity::updateContentView); + if (isComponentComplete()) + m_contentView->construct(); + } + } +} + +void QQmlAndroidActivity::classBegin() +{ + QQmlAndroidContextWrapper::classBegin(); +} + +void QQmlAndroidActivity::componentComplete() +{ + QQmlAndroidContextWrapper::componentComplete(); + + foreach (QObject *child, children()) { + QQmlAndroidObject *object = qobject_cast(child); + if (object) + object->construct(); + } + + if (m_actionBar) + setupActionBar(); + + if (m_window) + setupWindow(); +} + +void QQmlAndroidActivity::setupWindow() +{ + if (!isValid()) + return; + + QAndroidJniObject activity = instance(); + QtQmlAndroid::callFunction([=]() { + QAndroidJniObject wnd = activity.callObjectMethod("getWindow", "()Landroid/view/Window;"); + m_window->inflate(wnd); + }); +} + +void QQmlAndroidActivity::setupActionBar() +{ + if (!isValid()) + return; + + QAndroidJniObject activity = instance(); + QtQmlAndroid::callFunction([=]() { + QAndroidJniObject bar = activity.callObjectMethod("getActionBar", "()Landroid/app/ActionBar;"); + m_actionBar->inflate(bar); + }); +} + +void QQmlAndroidActivity::updateOptionsMenu() +{ + if (!isValid()) + return; + + QAndroidJniObject menu; + if (m_optionsMenu) + menu = m_optionsMenu->instance(); + + QAndroidJniObject activity = instance(); + QtQmlAndroid::callFunction([=]() { + activity.callMethod("setOptionsMenu", "(Lqt/android/view/QmlMenu;)V", menu.object()); + }); +} + +void QQmlAndroidActivity::invalidateOptionsMenu() +{ + QtQmlAndroid::callVoidMethod(instance(), "invalidateOptionsMenu"); +} + +void QQmlAndroidActivity::updateContentView() +{ + if (!isValid()) + return; + + QAndroidJniObject content; + if (m_contentView) + content = m_contentView->instance(); + + QAndroidJniObject activity = instance(); + QtQmlAndroid::callFunction([=]() { + activity.callMethod("setContentView", "(Landroid/view/View;)V", content.object()); + }); +} + +QT_END_NAMESPACE diff --git a/src/android/app/qqmlandroidactivity_p.h b/src/android/app/qqmlandroidactivity_p.h new file mode 100644 index 0000000..58d119f --- /dev/null +++ b/src/android/app/qqmlandroidactivity_p.h @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDACTIVITY_P_H +#define QQMLANDROIDACTIVITY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QQmlAndroidView; +class QQmlAndroidMenu; +class QQmlAndroidWindow; +class QQmlAndroidActionBar; + +class Q_QMLANDROID_EXPORT QQmlAndroidActivity : public QQmlAndroidContextWrapper +{ + Q_OBJECT + Q_PROPERTY(QQmlAndroidWindow *window READ window CONSTANT) + Q_PROPERTY(QQmlAndroidActionBar *actionBar READ actionBar WRITE setActionBar) + Q_PROPERTY(QQmlAndroidMenu *optionsMenu READ optionsMenu WRITE setOptionsMenu) + Q_PROPERTY(QQmlAndroidView *contentView READ contentView WRITE setContentView) + +public: + explicit QQmlAndroidActivity(QObject *parent = nullptr); + + QQmlAndroidWindow *window() const; + + QQmlAndroidActionBar *actionBar() const; + void setActionBar(QQmlAndroidActionBar *bar); + + QQmlAndroidMenu *optionsMenu() const; + void setOptionsMenu(QQmlAndroidMenu *menu); + + QQmlAndroidView *contentView() const; + void setContentView(QQmlAndroidView *view); + +protected: + void classBegin() override; + void componentComplete() override; + +private Q_SLOTS: + void setupWindow(); + void setupActionBar(); + void updateOptionsMenu(); + void invalidateOptionsMenu(); + void updateContentView(); + +private: + QQmlAndroidWindow *m_window; + QQmlAndroidView *m_contentView; + QQmlAndroidMenu *m_optionsMenu; + QQmlAndroidActionBar *m_actionBar; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDACTIVITY_P_H diff --git a/src/android/app/qqmlandroidalertdialog.cpp b/src/android/app/qqmlandroidalertdialog.cpp new file mode 100644 index 0000000..84dff83 --- /dev/null +++ b/src/android/app/qqmlandroidalertdialog.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidalertdialog_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidAlertDialog::QQmlAndroidAlertDialog(QObject *parent) : + QQmlAndroidDialog(parent) +{ +} + +QString QQmlAndroidAlertDialog::title() const +{ + return m_title; +} + +void QQmlAndroidAlertDialog::setTitle(const QString &title) +{ + if (m_title != title) { + m_title = title; + QtQmlAndroid::callTextMethod(instance(), "setTitle", title); + emit titleChanged(); + } +} + +QString QQmlAndroidAlertDialog::message() const +{ + return m_message; +} + +void QQmlAndroidAlertDialog::setMessage(const QString &message) +{ + if (m_message != message) { + m_message = message; + QtQmlAndroid::callTextMethod(instance(), "setMessage", message); + emit messageChanged(); + } +} + +QAndroidJniObject QQmlAndroidAlertDialog::onCreate() +{ + return QAndroidJniObject("android/app/AlertDialog", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidAlertDialog::onInflate(QAndroidJniObject& instance) +{ + QQmlAndroidDialog::onInflate(instance); + + if (!m_title.isNull()) + instance.callMethod("setTitle", "(Ljava/lang/CharSequence;)V", QAndroidJniObject::fromString(m_title).object()); + if (!m_message.isNull()) + instance.callMethod("setMessage", "(Ljava/lang/CharSequence;)V", QAndroidJniObject::fromString(m_message).object()); +} + +QT_END_NAMESPACE diff --git a/src/android/app/qqmlandroidalertdialog_p.h b/src/android/app/qqmlandroidalertdialog_p.h new file mode 100644 index 0000000..129a1c1 --- /dev/null +++ b/src/android/app/qqmlandroidalertdialog_p.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDALERTDIALOG_P_H +#define QQMLANDROIDALERTDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidAlertDialog : public QQmlAndroidDialog +{ + Q_OBJECT + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + Q_PROPERTY(QString message READ message WRITE setMessage NOTIFY messageChanged) + +public: + explicit QQmlAndroidAlertDialog(QObject *parent = nullptr); + + QString title() const; + void setTitle(const QString &title); + + QString message() const; + void setMessage(const QString &message); + +Q_SIGNALS: + void titleChanged(); + void messageChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject& instance) override; + +private: + QString m_title; + QString m_message; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDALERTDIALOG_P_H diff --git a/src/android/app/qqmlandroiddialog.cpp b/src/android/app/qqmlandroiddialog.cpp new file mode 100644 index 0000000..397ee60 --- /dev/null +++ b/src/android/app/qqmlandroiddialog.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroiddialog_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidDialog::QQmlAndroidDialog(QObject *parent) : + QQmlAndroidContextual(parent) +{ +} + +void QQmlAndroidDialog::cancel() +{ + QtQmlAndroid::callVoidMethod(instance(), "cancel"); +} + +void QQmlAndroidDialog::dismiss() +{ + QtQmlAndroid::callVoidMethod(instance(), "dismiss"); +} + +void QQmlAndroidDialog::hide() +{ + QtQmlAndroid::callVoidMethod(instance(), "hide"); +} + +void QQmlAndroidDialog::show() +{ + QtQmlAndroid::callVoidMethod(instance(), "show"); +} + +QAndroidJniObject QQmlAndroidDialog::onCreate() +{ + return QAndroidJniObject("android/app/Dialog", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidDialog::onInflate(QAndroidJniObject& instance) +{ + QQmlAndroidContextual::onInflate(instance); +} + +QT_END_NAMESPACE diff --git a/src/android/app/qqmlandroiddialog_p.h b/src/android/app/qqmlandroiddialog_p.h new file mode 100644 index 0000000..fdacdfe --- /dev/null +++ b/src/android/app/qqmlandroiddialog_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDDIALOG_P_H +#define QQMLANDROIDDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidDialog : public QQmlAndroidContextual +{ + Q_OBJECT + +public: + explicit QQmlAndroidDialog(QObject *parent = nullptr); + +public Q_SLOTS: + void cancel(); + void dismiss(); + void hide(); + void show(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject& instance) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDDIALOG_P_H diff --git a/src/android/app/qqmlandroidservice.cpp b/src/android/app/qqmlandroidservice.cpp new file mode 100644 index 0000000..6db3d51 --- /dev/null +++ b/src/android/app/qqmlandroidservice.cpp @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidservice_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidService::QQmlAndroidService(QObject *parent) : + QQmlAndroidContextWrapper(0, parent), m_sticky(true) +{ +} + +bool QQmlAndroidService::isSticky() const +{ + return m_sticky; +} + +void QQmlAndroidService::setSticky(bool sticky) +{ + if (m_sticky != sticky) { + m_sticky = sticky; + emit stickyChanged(); + } +} + +void QQmlAndroidService::start() +{ + QAndroidJniObject context = ctx(); + QAndroidJniObject service = instance(); + + if (!context.isValid() || !service.isValid()) + return; // TODO: warn + + QtQmlAndroid::callFunction([=]() { + QAndroidJniObject cls = service.callObjectMethod("getClass", "()Ljava/lang/Class;"); + QAndroidJniObject intent = QAndroidJniObject("android/content/Intent", + "(Landroid/content/Context;Ljava/lang/Class;)V", + context.object(), + cls.object()); + intent.callObjectMethod("putExtra", + "(Ljava/lang/String;J)Landroid/content/Intent;", + QAndroidJniObject::fromString(QStringLiteral("QmlService")).object(), + reinterpret_cast(this)); + QAndroidJniObject component = context.callObjectMethod("startService", + "(Landroid/content/Intent;)Landroid/content/ComponentName;", + intent.object()); + Q_UNUSED(component); + }); +} + +void QQmlAndroidService::stop() +{ + QAndroidJniObject context = ctx(); + QAndroidJniObject service = instance(); + + if (!context.isValid() || !service.isValid()) + return; // TODO: warn + + QtQmlAndroid::callFunction([=]() { + QAndroidJniObject cls = service.callObjectMethod("getClass", "()Ljava/lang/Class;"); + QAndroidJniObject intent = QAndroidJniObject("android/content/Intent", + "(Landroid/content/Context;Ljava/lang/Class;)V", + context.object(), + cls.object()); + intent.callObjectMethod("putExtra", + "(Ljava/lang/String;J)Landroid/content/Intent;", + QAndroidJniObject::fromString(QStringLiteral("QmlService")).object(), + reinterpret_cast(this)); + context.callMethod("stopService", + "(Landroid/content/Intent;)Z", + intent.object()); + }); +} + +QAndroidJniObject QQmlAndroidService::onCreate() +{ + return QAndroidJniObject("qt/android/app/QmlService"); +} + +void QQmlAndroidService::onInflate(QAndroidJniObject& instance) +{ + QQmlAndroidContextWrapper::onInflate(instance); + + static bool nativeMethodsRegistered = false; + if (!nativeMethodsRegistered) { + onRegisterNativeMethods(instance.object()); + nativeMethodsRegistered = true; + } +} + +void QQmlAndroidService::onRegisterNativeMethods(jobject service) +{ + JNINativeMethod methods[] {{"onCreated", "(J)V", reinterpret_cast(onCreated)}, + {"onDestroyed", "(J)V", reinterpret_cast(onDestroyed)}, + {"onStartCommand", "(JII)Z", reinterpret_cast(onStartCommand)}}; + + QAndroidJniEnvironment env; + jclass cls = env->GetObjectClass(service); + env->RegisterNatives(cls, methods, sizeof(methods) / sizeof(methods[0])); + env->DeleteLocalRef(cls); +} + +void QQmlAndroidService::onCreated(JNIEnv *env, jobject object, jlong instance) +{ + Q_UNUSED(env); + Q_UNUSED(object); +// QQmlAndroidService *service = reinterpret_cast(instance); +// if (service) +// QMetaObject::invokeMethod(service, "created", Qt::QueuedConnection); +} + +void QQmlAndroidService::onDestroyed(JNIEnv *env, jobject object, jlong instance) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidService *service = reinterpret_cast(instance); + if (service) + QMetaObject::invokeMethod(service, "stopped", Qt::QueuedConnection); +} + +jboolean QQmlAndroidService::onStartCommand(JNIEnv *env, jobject object, jlong instance, jint flags, jint startId) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidService *service = reinterpret_cast(instance); + bool ret = false; + if (service) { + QMetaObject::invokeMethod(service, "startCommand", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, ret), Q_ARG(int, flags), Q_ARG(int, startId)); + QMetaObject::invokeMethod(service, "started", Qt::QueuedConnection); + } + return ret; +} + +bool QQmlAndroidService::startCommand(int flags, int startId) +{ + Q_UNUSED(flags); + Q_UNUSED(startId); + return m_sticky; +} + +QT_END_NAMESPACE diff --git a/src/android/app/qqmlandroidservice_p.h b/src/android/app/qqmlandroidservice_p.h new file mode 100644 index 0000000..8c5c01e --- /dev/null +++ b/src/android/app/qqmlandroidservice_p.h @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDSERVICE_P_H +#define QQMLANDROIDSERVICE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidService : public QQmlAndroidContextWrapper +{ + Q_OBJECT + Q_PROPERTY(bool sticky READ isSticky WRITE setSticky NOTIFY stickyChanged) + +public: + explicit QQmlAndroidService(QObject *parent = nullptr); + + bool isSticky() const; + void setSticky(bool sticky); + +public Q_SLOTS: + void start(); + void stop(); + +Q_SIGNALS: + void stickyChanged(); + void started(); + void stopped(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject& instance) override; + + static void onRegisterNativeMethods(jobject service); + static void onCreated(JNIEnv *env, jobject object, jlong instance); + static void onDestroyed(JNIEnv *env, jobject object, jlong instance); + static jboolean onStartCommand(JNIEnv *env, jobject object, jlong instance, jint flags, jint startId); + +private Q_SLOTS: + bool startCommand(int flags, int startId); + +private: + bool m_sticky; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDSERVICE_P_H diff --git a/src/android/content/content.pri b/src/android/content/content.pri new file mode 100644 index 0000000..6a48b09 --- /dev/null +++ b/src/android/content/content.pri @@ -0,0 +1,11 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qqmlandroidcontext_p.h \ + $$PWD/qqmlandroidcontextual_p.h \ + $$PWD/qqmlandroidcontextwrapper_p.h + +SOURCES += \ + $$PWD/qqmlandroidcontext.cpp \ + $$PWD/qqmlandroidcontextual.cpp \ + $$PWD/qqmlandroidcontextwrapper.cpp diff --git a/src/android/content/qqmlandroidcontext.cpp b/src/android/content/qqmlandroidcontext.cpp new file mode 100644 index 0000000..5156e08 --- /dev/null +++ b/src/android/content/qqmlandroidcontext.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidcontext_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidContext::QQmlAndroidContext(QObject *parent) : + QQmlAndroidContextual(this, parent) +{ +} + +QQmlAndroidContext::QQmlAndroidContext(QQmlAndroidContext *context, QObject *parent) : + QQmlAndroidContextual(context, parent) +{ +} + +QT_END_NAMESPACE diff --git a/src/android/content/qqmlandroidcontext_p.h b/src/android/content/qqmlandroidcontext_p.h new file mode 100644 index 0000000..6bb6736 --- /dev/null +++ b/src/android/content/qqmlandroidcontext_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDCONTEXT_P_H +#define QQMLANDROIDCONTEXT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidContext : public QQmlAndroidContextual +{ + Q_OBJECT + +public: + explicit QQmlAndroidContext(QObject *parent = nullptr); + explicit QQmlAndroidContext(QQmlAndroidContext *context, QObject *parent = nullptr); +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDCONTEXT_P_H diff --git a/src/android/content/qqmlandroidcontextual.cpp b/src/android/content/qqmlandroidcontextual.cpp new file mode 100644 index 0000000..60af40c --- /dev/null +++ b/src/android/content/qqmlandroidcontextual.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidcontextual_p.h" +#include "qqmlandroidcontext_p.h" +#include + +QT_BEGIN_NAMESPACE + +QQmlAndroidContextual::QQmlAndroidContextual(QObject *parent) : + QQmlAndroidObject(parent), m_context(0) +{ + if (!initContext()) + QMetaObject::invokeMethod(this, "resolveContext", Qt::QueuedConnection); +} + +QQmlAndroidContextual::QQmlAndroidContextual(QQmlAndroidContext* context, QObject *parent) : + QQmlAndroidObject(parent), m_context(0) +{ + if (!initContext(context)) + QMetaObject::invokeMethod(this, "resolveContext", Qt::QueuedConnection); +} + +QAndroidJniObject QQmlAndroidContextual::ctx() const +{ + if (!m_context) + return QAndroidJniObject(); + return m_context->instance(); +} + +QQmlAndroidContext *QQmlAndroidContextual::context() const +{ + return m_context; +} + +void QQmlAndroidContextual::setContext(QQmlAndroidContext *context) +{ + if (m_context != context) { + m_context = context; + propagateContext(); + emit contextChanged(); + } +} + +void QQmlAndroidContextual::componentComplete() +{ + QQmlAndroidObject::componentComplete(); + propagateContext(); +} + +static QQmlAndroidContext *findContext(QQmlAndroidObject *object) +{ + QQmlAndroidContext *context = qobject_cast(object); + QObject *p = object->parent(); + while (p && !context) { + QQmlAndroidContextual *contextual = qobject_cast(p); + if (contextual) + context = contextual->context(); + p = p->parent(); + } + return context; +} + +bool QQmlAndroidContextual::initContext(QQmlAndroidContext *context) +{ + if (!context) + context = findContext(this); + setContext(context); + return context; +} + +void QQmlAndroidContextual::resolveContext() +{ + if (!m_context) { + setContext(findContext(this)); + if (!m_context) + qWarning() << "QQmlAndroidContextual: could not resolve context for" << this; + } +} + +void QQmlAndroidContextual::propagateContext() +{ + foreach (QObject *child, children()) { + QQmlAndroidContextual *contextual = qobject_cast(child); + if (contextual) + contextual->setContext(m_context); + } +} + +QT_END_NAMESPACE diff --git a/src/android/content/qqmlandroidcontextual_p.h b/src/android/content/qqmlandroidcontextual_p.h new file mode 100644 index 0000000..de9691b --- /dev/null +++ b/src/android/content/qqmlandroidcontextual_p.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDCONTEXTUAL_P_H +#define QQMLANDROIDCONTEXTUAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QQmlAndroidContext; + +class Q_QMLANDROID_EXPORT QQmlAndroidContextual : public QQmlAndroidObject +{ + Q_OBJECT + Q_PROPERTY(QQmlAndroidContext *context READ context NOTIFY contextChanged) + +public: + explicit QQmlAndroidContextual(QObject *parent = nullptr); + explicit QQmlAndroidContextual(QQmlAndroidContext *context, QObject *parent = nullptr); + + QAndroidJniObject ctx() const; + QQmlAndroidContext *context() const; + void setContext(QQmlAndroidContext *context); + +Q_SIGNALS: + void contextChanged(); + +protected: + void componentComplete() override; + +private Q_SLOTS: + bool initContext(QQmlAndroidContext *context = nullptr); + void resolveContext(); + void propagateContext(); + +private: + QQmlAndroidContext *m_context; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDCONTEXTUAL_P_H diff --git a/src/android/content/qqmlandroidcontextwrapper.cpp b/src/android/content/qqmlandroidcontextwrapper.cpp new file mode 100644 index 0000000..576ee28 --- /dev/null +++ b/src/android/content/qqmlandroidcontextwrapper.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidcontextwrapper_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidContextWrapper::QQmlAndroidContextWrapper(QObject *parent) : + QQmlAndroidContext(parent) +{ +} + +QQmlAndroidContextWrapper::QQmlAndroidContextWrapper(QQmlAndroidContext *context, QObject *parent) : + QQmlAndroidContext(context, parent) +{ +} + +QT_END_NAMESPACE diff --git a/src/android/content/qqmlandroidcontextwrapper_p.h b/src/android/content/qqmlandroidcontextwrapper_p.h new file mode 100644 index 0000000..59e73a5 --- /dev/null +++ b/src/android/content/qqmlandroidcontextwrapper_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDCONTEXTWRAPPER_P_H +#define QQMLANDROIDCONTEXTWRAPPER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidContextWrapper : public QQmlAndroidContext +{ + Q_OBJECT + +public: + explicit QQmlAndroidContextWrapper(QObject *parent = nullptr); + explicit QQmlAndroidContextWrapper(QQmlAndroidContext *context, QObject *parent = nullptr); +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDCONTEXTWRAPPER_P_H diff --git a/src/android/core/core.pri b/src/android/core/core.pri new file mode 100644 index 0000000..f3eb64f --- /dev/null +++ b/src/android/core/core.pri @@ -0,0 +1,11 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qqmlandroidobject_p.h \ + $$PWD/qqmlandroidoptional_p.h \ + $$PWD/qtqmlandroidfunctions_p.h \ + $$PWD/qtqmlandroidglobal_p.h + +SOURCES += \ + $$PWD/qqmlandroidobject.cpp \ + $$PWD/qtqmlandroidfunctions.cpp diff --git a/src/android/core/qqmlandroidobject.cpp b/src/android/core/qqmlandroidobject.cpp new file mode 100644 index 0000000..c760260 --- /dev/null +++ b/src/android/core/qqmlandroidobject.cpp @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidobject_p.h" +#include "qtqmlandroidfunctions_p.h" +#include +#include + +QT_BEGIN_NAMESPACE + +Q_GLOBAL_STATIC(QReadWriteLock, instanceLock) + +QQmlAndroidObject::QQmlAndroidObject(QObject *parent) : + QObject(parent), m_complete(false) +{ +} + +bool QQmlAndroidObject::isValid() const +{ + QReadLocker locker(instanceLock()); + return m_instance.isValid(); +} + +QAndroidJniObject QQmlAndroidObject::instance() const +{ + QReadLocker locker(instanceLock()); + return m_instance; +} + +void QQmlAndroidObject::setInstance(const QAndroidJniObject &instance) +{ + QWriteLocker locker(instanceLock()); + if (m_instance != instance) { + m_instance = instance; + // queue to Qt thread if necessary + QMetaObject::invokeMethod(this, "changeInstance", Qt::AutoConnection); + } +} + +void QQmlAndroidObject::changeInstance() +{ + Q_ASSERT(QtQmlAndroid::isMainQtThread()); + objectChange(InstanceChange); + emit instanceChanged(); +} + +void QQmlAndroidObject::construct() +{ + foreach (QObject *obj, children()) { + QQmlAndroidObject *child = qobject_cast(obj); + if (child) + child->construct(); + } + + std::function method = [=]() { + inflate(onCreate()); + }; + + if (QtQmlAndroid::isMainQtThread()) + QtQmlAndroid::callFunction(method); + else + method(); +} + +void QQmlAndroidObject::inflate(const QAndroidJniObject &instance) +{ + std::function method = [=]() { + QAndroidJniObject object(instance); + if (object.isValid()) + onInflate(object); + setInstance(object); + }; + + if (QtQmlAndroid::isMainQtThread()) + QtQmlAndroid::callFunction(method); + else + method(); +} + +void QQmlAndroidObject::destruct() +{ + foreach (QObject *obj, children()) { + QQmlAndroidObject *child = qobject_cast(obj); + if (child) + child->destruct(); + } + + setInstance(QAndroidJniObject()); +} + +QAndroidJniObject QQmlAndroidObject::onCreate() +{ + return QAndroidJniObject(); +} + +void QQmlAndroidObject::onInflate(QAndroidJniObject &instance) +{ + Q_UNUSED(instance); + Q_ASSERT(!QtQmlAndroid::isMainQtThread()); +} + +bool QQmlAndroidObject::isComponentComplete() const +{ + return m_complete; +} + +void QQmlAndroidObject::classBegin() +{ +} + +void QQmlAndroidObject::componentComplete() +{ + m_complete = true; +} + +void QQmlAndroidObject::objectChange(ObjectChange change) +{ + Q_ASSERT(QtQmlAndroid::isMainQtThread()); + Q_UNUSED(change); +} + +QQmlListProperty QQmlAndroidObject::data() +{ + return QQmlListProperty(this, 0, &QQmlAndroidObject::data_append, + &QQmlAndroidObject::data_count, &QQmlAndroidObject::data_at, 0); +} + +void QQmlAndroidObject::data_append(QQmlListProperty *list, QObject *object) +{ + if (QQmlAndroidObject *that = qobject_cast(list->object)) + object->setParent(that); +} + +int QQmlAndroidObject::data_count(QQmlListProperty *list) +{ + if (QQmlAndroidObject *that = qobject_cast(list->object)) + return that->children().count(); + return 0; +} + +QObject *QQmlAndroidObject::data_at(QQmlListProperty *list, int index) +{ + if (QQmlAndroidObject *that = qobject_cast(list->object)) + return that->children().value(index); + return 0; +} + +void QQmlAndroidObject::childEvent(QChildEvent *event) +{ + if (event->added()) + emit dataChanged(); + else if (event->removed()) + emit dataChanged(); +} + +QT_END_NAMESPACE diff --git a/src/android/core/qqmlandroidobject_p.h b/src/android/core/qqmlandroidobject_p.h new file mode 100644 index 0000000..17056c9 --- /dev/null +++ b/src/android/core/qqmlandroidobject_p.h @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDOBJECT_P_H +#define QQMLANDROIDOBJECT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidObject : public QObject, public QQmlParserStatus +{ + Q_OBJECT + Q_PROPERTY(QQmlListProperty data READ data NOTIFY dataChanged) + Q_CLASSINFO("DefaultProperty", "data") + Q_INTERFACES(QQmlParserStatus) + +public: + explicit QQmlAndroidObject(QObject *parent = nullptr); + + bool isValid() const; + QAndroidJniObject instance() const; + + void construct(); + void inflate(const QAndroidJniObject &instance); + void destruct(); + + QQmlListProperty data(); + + enum ObjectChange { + InstanceChange + }; + +Q_SIGNALS: + void dataChanged(); + void instanceChanged(); + +protected: + virtual QAndroidJniObject onCreate(); + virtual void onInflate(QAndroidJniObject &instance); + + bool isComponentComplete() const; + void classBegin() override; + void componentComplete() override; + + virtual void objectChange(ObjectChange change); + + static void data_append(QQmlListProperty *list, QObject *object); + static int data_count(QQmlListProperty *list); + static QObject *data_at(QQmlListProperty *list, int index); + + void childEvent(QChildEvent *event) override; + +private Q_SLOTS: + void changeInstance(); + +private: + void setInstance(const QAndroidJniObject &instance); + + bool m_complete; + QAndroidJniObject m_instance; + friend class QQmlAndroidActivity; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDOBJECT_P_H diff --git a/src/android/core/qqmlandroidoptional_p.h b/src/android/core/qqmlandroidoptional_p.h new file mode 100644 index 0000000..aea3316 --- /dev/null +++ b/src/android/core/qqmlandroidoptional_p.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDOPTIONAL_P_H +#define QQMLANDROIDOPTIONAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +template +class QQmlAndroidOptional +{ +public: + QQmlAndroidOptional() : t(), exists(false) {} + explicit QQmlAndroidOptional(const T &t) : t(t), exists(true) {} + explicit QQmlAndroidOptional(T &&t) : t(std::move(t)), exists(true) {} + QQmlAndroidOptional &operator=(const T &o) { t = o; exists = true; return *this; } + + operator T&() Q_DECL_NOTHROW { return t; } + operator const T&() const Q_DECL_NOTHROW { return t; } + + bool isNull() const Q_DECL_NOTHROW { return !exists; } + +private: + T t; + bool exists; +}; + +template +inline bool operator==(const QQmlAndroidOptional &lhs, const QQmlAndroidOptional &rhs) + Q_DECL_NOEXCEPT_EXPR(noexcept(static_cast(lhs) == static_cast(rhs))) +{ return lhs.isNull() == rhs.isNull() && !lhs.isNull() && static_cast(lhs) == static_cast(rhs); } + +template +inline bool operator==(const QQmlAndroidOptional &lhs, const T &rhs) + Q_DECL_NOEXCEPT_EXPR(noexcept(static_cast(lhs) == rhs)) +{ return !lhs.isNull() && static_cast(lhs) == rhs; } + +template +inline bool operator==(const T &lhs, const QQmlAndroidOptional &rhs) + Q_DECL_NOEXCEPT_EXPR(noexcept(lhs == static_cast(rhs))) +{ return !rhs.isNull() && lhs == static_cast(rhs); } + +template +inline bool operator!=(const QQmlAndroidOptional &lhs, const QQmlAndroidOptional &rhs) + Q_DECL_NOEXCEPT_EXPR(noexcept(lhs == rhs)) +{ return !operator==(lhs, rhs); } + +template +inline bool operator!=(const QQmlAndroidOptional &lhs, const T &rhs) + Q_DECL_NOEXCEPT_EXPR(noexcept(lhs == rhs)) +{ return !operator==(lhs, rhs); } + +template +inline bool operator!=(const T &lhs, const QQmlAndroidOptional &rhs) + Q_DECL_NOEXCEPT_EXPR(noexcept(lhs == rhs)) +{ return !operator==(lhs, rhs); } + +QT_END_NAMESPACE + +#endif // QQMLANDROIDOPTIONAL_P_H diff --git a/src/android/core/qtqmlandroidfunctions.cpp b/src/android/core/qtqmlandroidfunctions.cpp new file mode 100644 index 0000000..628737c --- /dev/null +++ b/src/android/core/qtqmlandroidfunctions.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qtqmlandroidfunctions_p.h" +#include +#include +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +namespace QtQmlAndroid { + +void callFunction(std::function method) +{ + QAndroidJniEnvironment env; + QRunnable *runnable = new QtConcurrent::StoredFunctorCall0(method); + QtAndroidPrivate::runOnUiThread(runnable, env); +} + +void callTextMethod(const QAndroidJniObject &obj, const char *method, const QString &text) +{ + if (obj.isValid()) { + callFunction([=]() { + obj.callMethod(method, "(Ljava/lang/CharSequence;)V", QAndroidJniObject::fromString(text).object()); + }); + } +} + +void callRealMethod(const QAndroidJniObject &obj, const char *method, qreal value) +{ + if (obj.isValid()) { + callFunction([=]() { + obj.callMethod(method, "(F)V", value); + }); + } +} + +void callIntMethod(const QAndroidJniObject &obj, const char *method, int value) +{ + if (obj.isValid()) { + callFunction([=]() { + obj.callMethod(method, "(I)V", value); + }); + } +} + +void callBoolMethod(const QAndroidJniObject &obj, const char *method, bool value) +{ + if (obj.isValid()) { + callFunction([=]() { + obj.callMethod(method, "(Z)V", value); + }); + } +} + +void callVoidMethod(const QAndroidJniObject &obj, const char *method) +{ + if (obj.isValid()) { + callFunction([=]() { + obj.callMethod(method); + }); + } +} + +} + +QT_END_NAMESPACE diff --git a/src/android/core/qtqmlandroidfunctions_p.h b/src/android/core/qtqmlandroidfunctions_p.h new file mode 100644 index 0000000..b9b9e35 --- /dev/null +++ b/src/android/core/qtqmlandroidfunctions_p.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTQMLANDROIDFUNCTIONS_P_H +#define QTQMLANDROIDFUNCTIONS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QString; +class QAndroidJniObject; + +namespace QtQmlAndroid +{ + void callFunction(std::function method); + void callTextMethod(const QAndroidJniObject &obj, const char *method, const QString &text); + void callRealMethod(const QAndroidJniObject &obj, const char *method, qreal value); + void callIntMethod(const QAndroidJniObject &obj, const char *method, int value); + void callBoolMethod(const QAndroidJniObject &obj, const char *method, bool value); + void callVoidMethod(const QAndroidJniObject &obj, const char *method); +} + +QT_END_NAMESPACE + +#endif // QTQMLANDROIDFUNCTIONS_P_H diff --git a/src/android/core/qtqmlandroidglobal_p.h b/src/android/core/qtqmlandroidglobal_p.h new file mode 100644 index 0000000..2737a4d --- /dev/null +++ b/src/android/core/qtqmlandroidglobal_p.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTQMLANDROIDGLOBAL_P_H +#define QTQMLANDROIDGLOBAL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +#ifndef QT_STATIC +# if defined(QT_BUILD_QMLANDROID_LIB) +# define Q_QMLANDROID_EXPORT Q_DECL_EXPORT +# else +# define Q_QMLANDROID_EXPORT Q_DECL_IMPORT +# endif +#else +# define Q_QMLANDROID_EXPORT +#endif + +namespace QtQmlAndroid { + static inline bool isMainQtThread() + { + return QThread::currentThread() == qApp->thread(); + } +} + +QT_END_NAMESPACE + +#endif // QTQMLANDROIDGLOBAL_P_H diff --git a/src/android/graphics/drawable/drawable.pri b/src/android/graphics/drawable/drawable.pri new file mode 100644 index 0000000..6c04e80 --- /dev/null +++ b/src/android/graphics/drawable/drawable.pri @@ -0,0 +1,9 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qqmlandroidcolordrawable_p.h \ + $$PWD/qqmlandroiddrawable_p.h + +SOURCES += \ + $$PWD/qqmlandroidcolordrawable.cpp \ + $$PWD/qqmlandroiddrawable.cpp diff --git a/src/android/graphics/drawable/qqmlandroidcolordrawable.cpp b/src/android/graphics/drawable/qqmlandroidcolordrawable.cpp new file mode 100644 index 0000000..6dcf2b8 --- /dev/null +++ b/src/android/graphics/drawable/qqmlandroidcolordrawable.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidcolordrawable_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidColorDrawable::QQmlAndroidColorDrawable(QObject *parent) : + QQmlAndroidDrawable(parent), m_color(0) +{ +} + +QQmlAndroidColorDrawable::QQmlAndroidColorDrawable(int color, QObject *parent) : + QQmlAndroidDrawable(parent), m_color(color) +{ +} + +int QQmlAndroidColorDrawable::color() const +{ + return m_color; +} + +void QQmlAndroidColorDrawable::setColor(int color) +{ + if (m_color != color) { + m_color = color; + QtQmlAndroid::callIntMethod(instance(), "setColor", color); + emit colorChanged(); + } +} + +QAndroidJniObject QQmlAndroidColorDrawable::onCreate() +{ + return QAndroidJniObject("android/graphics/drawable/ColorDrawable"); +} + +void QQmlAndroidColorDrawable::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidDrawable::onInflate(instance); + + instance.callMethod("setColor", "(I)V", m_color); +} + +QT_END_NAMESPACE diff --git a/src/android/graphics/drawable/qqmlandroidcolordrawable_p.h b/src/android/graphics/drawable/qqmlandroidcolordrawable_p.h new file mode 100644 index 0000000..b0bf19f --- /dev/null +++ b/src/android/graphics/drawable/qqmlandroidcolordrawable_p.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDCOLORDRAWABLE_P_H +#define QQMLANDROIDCOLORDRAWABLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidColorDrawable : public QQmlAndroidDrawable +{ + Q_OBJECT + Q_PROPERTY(int color READ color WRITE setColor NOTIFY colorChanged) + +public: + explicit QQmlAndroidColorDrawable(QObject *parent = nullptr); + explicit QQmlAndroidColorDrawable(int color, QObject *parent = nullptr); + + int color() const; + void setColor(int color); + +Q_SIGNALS: + void colorChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + +private: + int m_color; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDCOLORDRAWABLE_P_H diff --git a/src/android/graphics/drawable/qqmlandroiddrawable.cpp b/src/android/graphics/drawable/qqmlandroiddrawable.cpp new file mode 100644 index 0000000..68414b7 --- /dev/null +++ b/src/android/graphics/drawable/qqmlandroiddrawable.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroiddrawable_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidDrawable::QQmlAndroidDrawable(QObject *parent) : + QQmlAndroidObject(parent) +{ +} + +QAndroidJniObject QQmlAndroidDrawable::onCreate() +{ + return QAndroidJniObject("android/graphics/drawable/Drawable"); +} + +void QQmlAndroidDrawable::onInflate(QAndroidJniObject &instance) +{ + Q_UNUSED(instance); +} + +QT_END_NAMESPACE diff --git a/src/android/graphics/drawable/qqmlandroiddrawable_p.h b/src/android/graphics/drawable/qqmlandroiddrawable_p.h new file mode 100644 index 0000000..52f2386 --- /dev/null +++ b/src/android/graphics/drawable/qqmlandroiddrawable_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDDRAWABLE_P_H +#define QQMLANDROIDDRAWABLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidDrawable : public QQmlAndroidObject +{ + Q_OBJECT + +public: + explicit QQmlAndroidDrawable(QObject *parent = nullptr); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDDRAWABLE_P_H diff --git a/src/android/graphics/graphics.pri b/src/android/graphics/graphics.pri new file mode 100644 index 0000000..7061563 --- /dev/null +++ b/src/android/graphics/graphics.pri @@ -0,0 +1,9 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qqmlandroidcolor_p.h + +SOURCES += \ + $$PWD/qqmlandroidcolor.cpp + +include(drawable/drawable.pri) diff --git a/src/android/graphics/qqmlandroidcolor.cpp b/src/android/graphics/qqmlandroidcolor.cpp new file mode 100644 index 0000000..0327c58 --- /dev/null +++ b/src/android/graphics/qqmlandroidcolor.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidcolor_p.h" +#include + +QT_BEGIN_NAMESPACE + +int QQmlAndroidColor::alpha(int color) +{ + return static_cast(color) >> 24; +} + +int QQmlAndroidColor::argb(int alpha, int red, int green, int blue) +{ + return (alpha << 24) | (red << 16) | (green << 8) | blue; +} + +int QQmlAndroidColor::blue(int color) +{ + return color & 0xFF; +} + +int QQmlAndroidColor::green(int color) +{ + return (color >> 8) & 0xFF; +} + +int QQmlAndroidColor::red(int color) +{ + return (color >> 16) & 0xFF; +} + +int QQmlAndroidColor::rgb(int red, int green, int blue) +{ + return (0xFF << 24) | (red << 16) | (green << 8) | blue; +} + +int QQmlAndroidColor::name(const QString &name) +{ + return QColor(name).rgba(); +} + +QObject *QQmlAndroidColor::provider(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(scriptEngine); + return new QQmlAndroidColor; +} + +QT_END_NAMESPACE diff --git a/src/android/graphics/qqmlandroidcolor_p.h b/src/android/graphics/qqmlandroidcolor_p.h new file mode 100644 index 0000000..74f9961 --- /dev/null +++ b/src/android/graphics/qqmlandroidcolor_p.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDCOLOR_P_H +#define QQMLANDROIDCOLOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidColor : public QObject +{ + Q_OBJECT + Q_ENUMS(Constants) + +public: + enum Constants { + BLACK = 0xFF000000, + DKGRAY = 0xFF444444, + GRAY = 0xFF888888, + LTGRAY = 0xFFCCCCCC, + WHITE = 0xFFFFFFFF, + RED = 0xFFFF0000, + GREEN = 0xFF00FF00, + BLUE = 0xFF0000FF, + YELLOW = 0xFFFFFF00, + CYAN = 0xFF00FFFF, + MAGENTA = 0xFFFF00FF, + TRANSPARENT = 0 + }; + + Q_INVOKABLE static int alpha(int color); + Q_INVOKABLE static int argb(int alpha, int red, int green, int blue); + Q_INVOKABLE static int blue(int color); + Q_INVOKABLE static int green(int color); + Q_INVOKABLE static int red(int color); + Q_INVOKABLE static int rgb(int red, int green, int blue); + Q_INVOKABLE static int name(const QString &name); + + static QObject *provider(QQmlEngine *engine, QJSEngine *scriptEngine); +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDCOLOR_P_H diff --git a/src/android/java/java.pri b/src/android/java/java.pri new file mode 100644 index 0000000..73ba60d --- /dev/null +++ b/src/android/java/java.pri @@ -0,0 +1,20 @@ +OTHER_FILES += \ + $$PWD/qml/qt/android/app/QmlActivity.java \ + $$PWD/qml/qt/android/app/QmlService.java \ + $$PWD/qml/qt/android/support/v4/widget/QmlSwipeRefreshLayoutListener.java \ + $$PWD/qml/qt/android/support/v7/widget/QmlRecyclerAdapter.java \ + $$PWD/qml/qt/android/view/QmlMenu.java \ + $$PWD/qml/qt/android/view/QmlMenuItem.java \ + $$PWD/qml/qt/android/view/QmlViewListener.java \ + $$PWD/qml/qt/android/widget/QmlCompoundButtonListener.java \ + $$PWD/qml/qt/android/widget/QmlNumberPickerListener.java \ + $$PWD/qml/qt/android/widget/QmlRadioGroupListener.java \ + $$PWD/qml/qt/android/widget/QmlRatingBarListener.java \ + $$PWD/qml/qt/android/widget/QmlScrollView.java \ + $$PWD/qml/qt/android/widget/QmlSeekBarListener.java \ + $$PWD/qml/qt/android/widget/QmlTabHostListener.java + +java.files = $$PWD/qml +java.path = $$[QT_INSTALL_PREFIX]/src/android/java +!prefix_build: COPIES += java +INSTALLS += java diff --git a/src/android/java/java.pro b/src/android/java/java.pro deleted file mode 100644 index 9eaf2ae..0000000 --- a/src/android/java/java.pro +++ /dev/null @@ -1,22 +0,0 @@ -CONFIG -= qt android_install - -OTHER_FILES += \ - $$PWD/qml/qt/android/app/QmlActivity.java \ - $$PWD/qml/qt/android/app/QmlService.java \ - $$PWD/qml/qt/android/support/v4/widget/QmlSwipeRefreshLayoutListener.java \ - $$PWD/qml/qt/android/support/v7/widget/QmlRecyclerAdapter.java \ - $$PWD/qml/qt/android/view/QmlMenu.java \ - $$PWD/qml/qt/android/view/QmlMenuItem.java \ - $$PWD/qml/qt/android/view/QmlViewListener.java \ - $$PWD/qml/qt/android/widget/QmlCompoundButtonListener.java \ - $$PWD/qml/qt/android/widget/QmlNumberPickerListener.java \ - $$PWD/qml/qt/android/widget/QmlRadioGroupListener.java \ - $$PWD/qml/qt/android/widget/QmlRatingBarListener.java \ - $$PWD/qml/qt/android/widget/QmlScrollView.java \ - $$PWD/qml/qt/android/widget/QmlSeekBarListener.java \ - $$PWD/qml/qt/android/widget/QmlTabHostListener.java - -java.files = $$PWD/qml -java.path = $$[QT_INSTALL_PREFIX]/src/android/java -!prefix_build: COPIES += java -INSTALLS += java diff --git a/src/android/qqmlandroidr.cpp b/src/android/qqmlandroidr.cpp new file mode 100644 index 0000000..d50a142 --- /dev/null +++ b/src/android/qqmlandroidr.cpp @@ -0,0 +1,250 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidr_p.h" +#include +#include + +QT_BEGIN_NAMESPACE + +QQmlAndroidR::QQmlAndroidR() : + m_anim(0), + m_animator(0), + m_array(0), + m_attr(0), + m_boolean(0), + m_color(0), + m_dimen(0), + m_drawable(0), + m_fraction(0), + m_id(0), + m_integer(0), + m_interpolator(0), + m_layout(0), + m_menu(0), + m_mipmap(0), + m_plurals(0), + m_raw(0), + m_string(0), + m_style(0), + m_styleable(0), + m_transition(0), + m_xml(0) +{ +} + +static QQmlPropertyMap *getFields(const char *className, QObject *parent) +{ + QQmlPropertyMap *map = new QQmlPropertyMap(parent); + + QAndroidJniEnvironment env; + QAndroidJniObject anim(className); + QAndroidJniObject clazz = anim.callObjectMethod("getClass", "()Ljava/lang/Class;"); + QAndroidJniObject fields = clazz.callObjectMethod("getFields", "()[Ljava/lang/reflect/Field;"); + + jobjectArray array = fields.object(); + int length = env->GetArrayLength(array); + for (int i = 0; i < length; ++i) { + QAndroidJniObject field(env->GetObjectArrayElement(array, i)); + QString name = field.callObjectMethod("getName", "()Ljava/lang/String;").toString(); + jint value = field.callMethod("getInt", "(Ljava/lang/Object;)I", field.object()); + map->insert(name, value); + } + return map; +} + +QQmlPropertyMap *QQmlAndroidR::anim() +{ + if (!m_anim) + m_anim = getFields("android/R$anim", this); + return m_anim; +} + +QQmlPropertyMap *QQmlAndroidR::animator() +{ + if (!m_animator) + m_animator = getFields("android/R$animator", this); + return m_animator; +} + +QQmlPropertyMap *QQmlAndroidR::array() +{ + if (!m_array) + m_array = getFields("android/R$array", this); + return m_array; +} + +QQmlPropertyMap *QQmlAndroidR::attr() +{ + if (!m_attr) + m_attr = getFields("android/R$attr", this); + return m_attr; +} + +QQmlPropertyMap *QQmlAndroidR::boolean() +{ + if (!m_boolean) + m_boolean = getFields("android/R$boolean", this); + return m_boolean; +} + +QQmlPropertyMap *QQmlAndroidR::color() +{ + if (!m_color) + m_color = getFields("android/R$color", this); + return m_color; +} + +QQmlPropertyMap *QQmlAndroidR::dimen() +{ + if (!m_dimen) + m_dimen = getFields("android/R$dimen", this); + return m_dimen; +} + +QQmlPropertyMap *QQmlAndroidR::drawable() +{ + if (!m_drawable) + m_drawable = getFields("android/R$drawable", this); + return m_drawable; +} + +QQmlPropertyMap *QQmlAndroidR::fraction() +{ + if (!m_fraction) + m_fraction = getFields("android/R$fraction", this); + return m_fraction; +} + +QQmlPropertyMap *QQmlAndroidR::id() +{ + if (!m_id) + m_id = getFields("android/R$id", this); + return m_id; +} + +QQmlPropertyMap *QQmlAndroidR::integer() +{ + if (!m_integer) + m_integer = getFields("android/R$integer", this); + return m_integer; +} + +QQmlPropertyMap *QQmlAndroidR::interpolator() +{ + if (!m_interpolator) + m_interpolator = getFields("android/R$interpolator", this); + return m_interpolator; +} + +QQmlPropertyMap *QQmlAndroidR::layout() +{ + if (!m_layout) + m_layout = getFields("android/R$layout", this); + return m_layout; +} + +QQmlPropertyMap *QQmlAndroidR::menu() +{ + if (!m_menu) + m_menu = getFields("android/R$menu", this); + return m_menu; +} + +QQmlPropertyMap *QQmlAndroidR::mipmap() +{ + if (!m_mipmap) + m_mipmap = getFields("android/R$mipmap", this); + return m_mipmap; +} + +QQmlPropertyMap *QQmlAndroidR::plurals() +{ + if (!m_plurals) + m_plurals = getFields("android/R$plurals", this); + return m_plurals; +} + +QQmlPropertyMap *QQmlAndroidR::raw() +{ + if (!m_raw) + m_raw = getFields("android/R$raw", this); + return m_raw; +} + +QQmlPropertyMap *QQmlAndroidR::string() +{ + if (!m_string) + m_string = getFields("android/R$string", this); + return m_string; +} + +QQmlPropertyMap *QQmlAndroidR::style() +{ + if (!m_style) + m_style = getFields("android/R$style", this); + return m_style; +} + +QQmlPropertyMap *QQmlAndroidR::styleable() +{ + if (!m_styleable) + m_styleable = getFields("android/R$styleable", this); + return m_styleable; +} + +QQmlPropertyMap *QQmlAndroidR::transition() +{ + if (!m_transition) + m_transition = getFields("android/R$transition", this); + return m_transition; +} + +QQmlPropertyMap *QQmlAndroidR::xml() +{ + if (!m_xml) + m_xml = getFields("android/R$xml", this); + return m_xml; +} + +QObject *QQmlAndroidR::provider(QQmlEngine *engine, QJSEngine *scriptEngine) +{ + Q_UNUSED(engine); + Q_UNUSED(scriptEngine); + return new QQmlAndroidR; +} + +QT_END_NAMESPACE diff --git a/src/android/qqmlandroidr_p.h b/src/android/qqmlandroidr_p.h new file mode 100644 index 0000000..07c4f36 --- /dev/null +++ b/src/android/qqmlandroidr_p.h @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDR_P_H +#define QQMLANDROIDR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include +#include + +QT_BEGIN_NAMESPACE + +class QJSEngine; +class QQmlEngine; + +class Q_QMLANDROID_EXPORT QQmlAndroidR : public QObject +{ + Q_OBJECT + Q_PROPERTY(QQmlPropertyMap *anim READ anim CONSTANT) + Q_PROPERTY(QQmlPropertyMap *animator READ animator CONSTANT) + Q_PROPERTY(QQmlPropertyMap *array READ anim CONSTANT) + Q_PROPERTY(QQmlPropertyMap *attr READ attr CONSTANT) + Q_PROPERTY(QQmlPropertyMap *boolean READ boolean CONSTANT) + Q_PROPERTY(QQmlPropertyMap *color READ color CONSTANT) + Q_PROPERTY(QQmlPropertyMap *dimen READ dimen CONSTANT) + Q_PROPERTY(QQmlPropertyMap *drawable READ drawable CONSTANT) + Q_PROPERTY(QQmlPropertyMap *fraction READ fraction CONSTANT) + Q_PROPERTY(QQmlPropertyMap *id READ id CONSTANT) + Q_PROPERTY(QQmlPropertyMap *integer READ integer CONSTANT) + Q_PROPERTY(QQmlPropertyMap *interpolator READ interpolator CONSTANT) + Q_PROPERTY(QQmlPropertyMap *layout READ layout CONSTANT) + Q_PROPERTY(QQmlPropertyMap *menu READ menu CONSTANT) + Q_PROPERTY(QQmlPropertyMap *mipmap READ mipmap CONSTANT) + Q_PROPERTY(QQmlPropertyMap *plurals READ plurals CONSTANT) + Q_PROPERTY(QQmlPropertyMap *raw READ raw CONSTANT) + Q_PROPERTY(QQmlPropertyMap *string READ string CONSTANT) + Q_PROPERTY(QQmlPropertyMap *style READ style CONSTANT) + Q_PROPERTY(QQmlPropertyMap *styleable READ styleable CONSTANT) + Q_PROPERTY(QQmlPropertyMap *transition READ transition CONSTANT) + Q_PROPERTY(QQmlPropertyMap *xml READ xml CONSTANT) + +public: + QQmlAndroidR(); + + QQmlPropertyMap *anim(); + QQmlPropertyMap *animator(); + QQmlPropertyMap *array(); + QQmlPropertyMap *attr(); + QQmlPropertyMap *boolean(); + QQmlPropertyMap *color(); + QQmlPropertyMap *dimen(); + QQmlPropertyMap *drawable(); + QQmlPropertyMap *fraction(); + QQmlPropertyMap *id(); + QQmlPropertyMap *integer(); + QQmlPropertyMap *interpolator(); + QQmlPropertyMap *layout(); + QQmlPropertyMap *menu(); + QQmlPropertyMap *mipmap(); + QQmlPropertyMap *plurals(); + QQmlPropertyMap *raw(); + QQmlPropertyMap *string(); + QQmlPropertyMap *style(); + QQmlPropertyMap *styleable(); + QQmlPropertyMap *transition(); + QQmlPropertyMap *xml(); + + static QObject *provider(QQmlEngine *engine, QJSEngine *scriptEngine); + +private: + QQmlPropertyMap *m_anim; + QQmlPropertyMap *m_animator; + QQmlPropertyMap *m_array; + QQmlPropertyMap *m_attr; + QQmlPropertyMap *m_boolean; + QQmlPropertyMap *m_color; + QQmlPropertyMap *m_dimen; + QQmlPropertyMap *m_drawable; + QQmlPropertyMap *m_fraction; + QQmlPropertyMap *m_id; + QQmlPropertyMap *m_integer; + QQmlPropertyMap *m_interpolator; + QQmlPropertyMap *m_layout; + QQmlPropertyMap *m_menu; + QQmlPropertyMap *m_mipmap; + QQmlPropertyMap *m_plurals; + QQmlPropertyMap *m_raw; + QQmlPropertyMap *m_string; + QQmlPropertyMap *m_style; + QQmlPropertyMap *m_styleable; + QQmlPropertyMap *m_transition; + QQmlPropertyMap *m_xml; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDR_P_H diff --git a/src/android/support/support.pri b/src/android/support/support.pri new file mode 100644 index 0000000..6c62701 --- /dev/null +++ b/src/android/support/support.pri @@ -0,0 +1,2 @@ +include(v4/v4.pri) +include(v7/v7.pri) diff --git a/src/android/support/v4/v4.pri b/src/android/support/v4/v4.pri new file mode 100644 index 0000000..014f027 --- /dev/null +++ b/src/android/support/v4/v4.pri @@ -0,0 +1 @@ +include(widget/widget.pri) diff --git a/src/android/support/v4/widget/qqmlandroiddrawerlayout.cpp b/src/android/support/v4/widget/qqmlandroiddrawerlayout.cpp new file mode 100644 index 0000000..4f7a50e --- /dev/null +++ b/src/android/support/v4/widget/qqmlandroiddrawerlayout.cpp @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroiddrawerlayout_p.h" +#include "qqmlandroidactionbardrawertoggle_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidDrawerLayout::QQmlAndroidDrawerLayout(QQmlAndroidView *parent) : + QQmlAndroidViewGroup(parent) +{ +} + +QQmlAndroidDrawerLayoutParams *QQmlAndroidDrawerLayout::qmlAttachedProperties(QObject *object) +{ + QQmlAndroidView *view = qobject_cast(object); + if (view) + return new QQmlAndroidDrawerLayoutParams(view); + return 0; +} + +void QQmlAndroidDrawerLayout::closeDrawers() +{ + QtQmlAndroid::callVoidMethod(instance(), "closeDrawers"); +} + +void QQmlAndroidDrawerLayout::closeDrawer(int gravity) +{ + QtQmlAndroid::callIntMethod(instance(), "closeDrawer", gravity); +} + +QAndroidJniObject QQmlAndroidDrawerLayout::onCreate() +{ + return QAndroidJniObject("android/support/v4/widget/DrawerLayout", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidDrawerLayout::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidViewGroup::onInflate(instance); + + foreach (QObject *child, QObject::children()) { + QQmlAndroidActionBarDrawerToggle *toggle = qobject_cast(child); + if (toggle) + toggle->onCreate(ctx(), instance); + } +} + +QT_END_NAMESPACE diff --git a/src/android/support/v4/widget/qqmlandroiddrawerlayout_p.h b/src/android/support/v4/widget/qqmlandroiddrawerlayout_p.h new file mode 100644 index 0000000..cb9dd84 --- /dev/null +++ b/src/android/support/v4/widget/qqmlandroiddrawerlayout_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDDRAWERLAYOUT_P_H +#define QQMLANDROIDDRAWERLAYOUT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidDrawerLayout : public QQmlAndroidViewGroup +{ + Q_OBJECT + +public: + explicit QQmlAndroidDrawerLayout(QQmlAndroidView *parent = nullptr); + + static QQmlAndroidDrawerLayoutParams *qmlAttachedProperties(QObject *object); + +public Q_SLOTS: + void closeDrawers(); + void closeDrawer(int gravity); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPEINFO(QQmlAndroidDrawerLayout, QML_HAS_ATTACHED_PROPERTIES) + +#endif // QQMLANDROIDDRAWERLAYOUT_P_H diff --git a/src/android/support/v4/widget/qqmlandroiddrawerlayoutparams.cpp b/src/android/support/v4/widget/qqmlandroiddrawerlayoutparams.cpp new file mode 100644 index 0000000..908d42b --- /dev/null +++ b/src/android/support/v4/widget/qqmlandroiddrawerlayoutparams.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroiddrawerlayoutparams_p.h" +#include "qqmlandroiddrawerlayout_p.h" +#include "qqmlandroidview_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidDrawerLayoutParams::QQmlAndroidDrawerLayoutParams(QQmlAndroidView *view) : + QQmlAndroidMarginLayoutParams(view), m_gravity(0) +{ +} + +int QQmlAndroidDrawerLayoutParams::gravity() const +{ + return m_gravity; +} + +void QQmlAndroidDrawerLayoutParams::setGravity(int value) +{ + if (m_gravity != value) { + m_gravity = value; + invalidate(); + emit gravityChanged(); + } +} + +QAndroidJniObject QQmlAndroidDrawerLayoutParams::onCreate() +{ + return QAndroidJniObject("android/support/v4/widget/DrawerLayout$LayoutParams", + "(III)V", + MATCH_PARENT, MATCH_PARENT, m_gravity); +} + +void QQmlAndroidDrawerLayoutParams::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidMarginLayoutParams::onInflate(instance); + + instance.setField("gravity", m_gravity); +} + +QT_END_NAMESPACE diff --git a/src/android/support/v4/widget/qqmlandroiddrawerlayoutparams_p.h b/src/android/support/v4/widget/qqmlandroiddrawerlayoutparams_p.h new file mode 100644 index 0000000..54816f4 --- /dev/null +++ b/src/android/support/v4/widget/qqmlandroiddrawerlayoutparams_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDDRAWERLAYOUTPARAMS_P_H +#define QQMLANDROIDDRAWERLAYOUTPARAMS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidDrawerLayoutParams : public QQmlAndroidMarginLayoutParams +{ + Q_OBJECT + Q_PROPERTY(int gravity READ gravity WRITE setGravity NOTIFY gravityChanged) // TODO Gravity + +public: + explicit QQmlAndroidDrawerLayoutParams(QQmlAndroidView *view); + + int gravity() const; + void setGravity(int gravity); + +Q_SIGNALS: + void gravityChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + +private: + int m_gravity; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDDRAWERLAYOUTPARAMS_P_H diff --git a/src/android/support/v4/widget/qqmlandroidswiperefreshlayout.cpp b/src/android/support/v4/widget/qqmlandroidswiperefreshlayout.cpp new file mode 100644 index 0000000..80b631c --- /dev/null +++ b/src/android/support/v4/widget/qqmlandroidswiperefreshlayout.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidswiperefreshlayout_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidSwipeRefreshLayout::QQmlAndroidSwipeRefreshLayout(QQmlAndroidView *parent) : + QQmlAndroidViewGroup(parent), m_refreshing(false) +{ +} + +bool QQmlAndroidSwipeRefreshLayout::isRefreshing() const +{ + return m_refreshing; +} + +void QQmlAndroidSwipeRefreshLayout::setRefreshing(bool refreshing) +{ + if (updateRefreshing(refreshing)) + QtQmlAndroid::callBoolMethod(instance(), "setRefreshing", refreshing); +} + +bool QQmlAndroidSwipeRefreshLayout::updateRefreshing(bool refreshing) +{ + if (m_refreshing != refreshing) { + m_refreshing = refreshing; + emit refreshingChanged(); + return true; + } + return false; +} + +QAndroidJniObject QQmlAndroidSwipeRefreshLayout::onCreate() +{ + return QAndroidJniObject("android/support/v4/widget/SwipeRefreshLayout", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidSwipeRefreshLayout::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidViewGroup::onInflate(instance); + + m_listener = QAndroidJniObject("qt/android/support/v4/widget/QmlSwipeRefreshLayoutListener", + "(Landroid/support/v4/widget/SwipeRefreshLayout;J)V", + instance.object(), + reinterpret_cast(this)); + + static bool nativeMethodsRegistered = false; + if (!nativeMethodsRegistered) { + onRegisterNativeMethods(m_listener.object()); + nativeMethodsRegistered = true; + } +} + +void QQmlAndroidSwipeRefreshLayout::onRegisterNativeMethods(jobject listener) +{ + JNINativeMethod methods[] {{"onRefresh", "(J)V", reinterpret_cast(onRefresh)}}; + + QAndroidJniEnvironment env; + jclass cls = env->GetObjectClass(listener); + env->RegisterNatives(cls, methods, sizeof(methods) / sizeof(methods[0])); + env->DeleteLocalRef(cls); +} + +void QQmlAndroidSwipeRefreshLayout::onRefresh(JNIEnv *env, jobject object, jlong instance) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidSwipeRefreshLayout *layout = reinterpret_cast(instance); + if (layout) + QMetaObject::invokeMethod(layout, "updateRefreshing", Qt::QueuedConnection, Q_ARG(bool, true)); +} + +QT_END_NAMESPACE diff --git a/src/android/support/v4/widget/qqmlandroidswiperefreshlayout_p.h b/src/android/support/v4/widget/qqmlandroidswiperefreshlayout_p.h new file mode 100644 index 0000000..79b9f51 --- /dev/null +++ b/src/android/support/v4/widget/qqmlandroidswiperefreshlayout_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDSWIPEREFRESHLAYOUT_P_H +#define QQMLANDROIDSWIPEREFRESHLAYOUT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidSwipeRefreshLayout : public QQmlAndroidViewGroup +{ + Q_OBJECT + Q_PROPERTY(bool refreshing READ isRefreshing WRITE setRefreshing NOTIFY refreshingChanged) + +public: + explicit QQmlAndroidSwipeRefreshLayout(QQmlAndroidView *parent = nullptr); + + bool isRefreshing() const; + void setRefreshing(bool refreshing); + +Q_SIGNALS: + void refreshingChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + + static void onRegisterNativeMethods(jobject listener); + static void onRefresh(JNIEnv *env, jobject object, jlong instance); + +private Q_SLOTS: + bool updateRefreshing(bool refreshing); + +private: + bool m_refreshing; + QAndroidJniObject m_listener; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDSWIPEREFRESHLAYOUT_P_H diff --git a/src/android/support/v4/widget/widget.pri b/src/android/support/v4/widget/widget.pri new file mode 100644 index 0000000..cbf1b84 --- /dev/null +++ b/src/android/support/v4/widget/widget.pri @@ -0,0 +1,11 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qqmlandroiddrawerlayout_p.h \ + $$PWD/qqmlandroiddrawerlayoutparams_p.h \ + $$PWD/qqmlandroidswiperefreshlayout_p.h + +SOURCES += \ + $$PWD/qqmlandroiddrawerlayout.cpp \ + $$PWD/qqmlandroiddrawerlayoutparams.cpp \ + $$PWD/qqmlandroidswiperefreshlayout.cpp diff --git a/src/android/support/v7/app/app.pri b/src/android/support/v7/app/app.pri new file mode 100644 index 0000000..a203273 --- /dev/null +++ b/src/android/support/v7/app/app.pri @@ -0,0 +1,7 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qqmlandroidactionbardrawertoggle_p.h + +SOURCES += \ + $$PWD/qqmlandroidactionbardrawertoggle.cpp diff --git a/src/android/support/v7/app/qqmlandroidactionbardrawertoggle.cpp b/src/android/support/v7/app/qqmlandroidactionbardrawertoggle.cpp new file mode 100644 index 0000000..16bb0bb --- /dev/null +++ b/src/android/support/v7/app/qqmlandroidactionbardrawertoggle.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidactionbardrawertoggle_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidActionBarDrawerToggle::QQmlAndroidActionBarDrawerToggle(QObject *parent) : + QQmlAndroidObject(parent) +{ +} + +void QQmlAndroidActionBarDrawerToggle::onCreate(const QAndroidJniObject &activity, const QAndroidJniObject &drawer) +{ + QAndroidJniObject toggle("android/support/v7/app/ActionBarDrawerToggle", + "(Landroid/app/Activity;Landroid/support/v4/widget/DrawerLayout;II)V", + activity.object(), + drawer.object(), + 17039375, // TODO: R.string.drawer_open + 17039375); // TODO: R.string.drawer_close + drawer.callMethod("setDrawerListener", "(Landroid/support/v4/widget/DrawerLayout$DrawerListener;)V", toggle.object()); + toggle.callMethod("syncState"); + inflate(toggle); +} + +QT_END_NAMESPACE diff --git a/src/android/support/v7/app/qqmlandroidactionbardrawertoggle_p.h b/src/android/support/v7/app/qqmlandroidactionbardrawertoggle_p.h new file mode 100644 index 0000000..b649219 --- /dev/null +++ b/src/android/support/v7/app/qqmlandroidactionbardrawertoggle_p.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDACTIONBARDRAWERTOGGLE_P_H +#define QQMLANDROIDACTIONBARDRAWERTOGGLE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidActionBarDrawerToggle : public QQmlAndroidObject +{ + Q_OBJECT + +public: + explicit QQmlAndroidActionBarDrawerToggle(QObject *parent = nullptr); + + void onCreate(const QAndroidJniObject &activity, const QAndroidJniObject &drawer); +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDACTIONBARDRAWERTOGGLE_P_H diff --git a/src/android/support/v7/v7.pri b/src/android/support/v7/v7.pri new file mode 100644 index 0000000..9d185ab --- /dev/null +++ b/src/android/support/v7/v7.pri @@ -0,0 +1,2 @@ +include(app/app.pri) +include(widget/widget.pri) diff --git a/src/android/support/v7/widget/qqmlandroidcardview.cpp b/src/android/support/v7/widget/qqmlandroidcardview.cpp new file mode 100644 index 0000000..1a49bbb --- /dev/null +++ b/src/android/support/v7/widget/qqmlandroidcardview.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidcardview_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidCardView::QQmlAndroidCardView(QQmlAndroidView *parent) : + QQmlAndroidFrameLayout(parent) +{ +} + +QAndroidJniObject QQmlAndroidCardView::onCreate() +{ + return QAndroidJniObject("android/support/v7/widget/CardView", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidCardView::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidFrameLayout::onInflate(instance); +} + +QT_END_NAMESPACE diff --git a/src/android/support/v7/widget/qqmlandroidcardview_p.h b/src/android/support/v7/widget/qqmlandroidcardview_p.h new file mode 100644 index 0000000..6916eda --- /dev/null +++ b/src/android/support/v7/widget/qqmlandroidcardview_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDCARDVIEW_P_H +#define QQMLANDROIDCARDVIEW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidCardView : public QQmlAndroidFrameLayout +{ + Q_OBJECT + +public: + explicit QQmlAndroidCardView(QQmlAndroidView *parent = nullptr); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDCARDVIEW_P_H diff --git a/src/android/support/v7/widget/qqmlandroidrecycleradapter.cpp b/src/android/support/v7/widget/qqmlandroidrecycleradapter.cpp new file mode 100644 index 0000000..54056ca --- /dev/null +++ b/src/android/support/v7/widget/qqmlandroidrecycleradapter.cpp @@ -0,0 +1,181 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidrecycleradapter_p.h" +#include "qtqmlandroidfunctions_p.h" +#include "qqmlandroidview_p.h" +#include +#include + +QT_BEGIN_NAMESPACE + +QQmlAndroidRecyclerAdapter::QQmlAndroidRecyclerAdapter(QObject *parent) : + QQmlAndroidContextual(parent), m_count(0), m_delegate(0) +{ +} + +int QQmlAndroidRecyclerAdapter::count() const +{ + return m_count; +} + +void QQmlAndroidRecyclerAdapter::setCount(int count) +{ + if (m_count != count) { + m_count = count; + QtQmlAndroid::callIntMethod(instance(), "setItemCount", count); + emit countChanged(); + } +} + +QQmlComponent *QQmlAndroidRecyclerAdapter::delegate() const +{ + return m_delegate; +} + +void QQmlAndroidRecyclerAdapter::setDelegate(QQmlComponent *delegate) +{ + if (m_delegate != delegate) { + m_delegate = delegate; + QtQmlAndroid::callVoidMethod(instance(), "notifyDataSetChanged"); + emit delegateChanged(); + } +} + +QAndroidJniObject QQmlAndroidRecyclerAdapter::onCreate() +{ + return QAndroidJniObject("qt/android/support/v7/widget/QmlRecyclerAdapter", + "(IJ)V", + m_count, + reinterpret_cast(this)); +} + +void QQmlAndroidRecyclerAdapter::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidContextual::onInflate(instance); + + static bool nativeMethodsRegistered = false; + if (!nativeMethodsRegistered) { + onRegisterNativeMethods(instance.object()); + nativeMethodsRegistered = true; + } + + if (m_count > 0) + instance.callMethod("setItemCount", "(I)V", m_count); +} + +void QQmlAndroidRecyclerAdapter::onRegisterNativeMethods(jobject adapter) +{ + JNINativeMethod methods[] {{"onCreateViewHolder", "(JLandroid/view/ViewGroup;I)Lqt/android/support/v7/widget/QmlRecyclerAdapter$ViewHolder;", reinterpret_cast(onCreateViewHolder)}, + {"onBindViewHolder", "(JLqt/android/support/v7/widget/QmlRecyclerAdapter$ViewHolder;I)V", reinterpret_cast(onBindViewHolder)}}; + + QAndroidJniEnvironment env; + jclass cls = env->GetObjectClass(adapter); + env->RegisterNatives(cls, methods, sizeof(methods) / sizeof(methods[0])); + env->DeleteLocalRef(cls); +} + +jobject QQmlAndroidRecyclerAdapter::onCreateViewHolder(JNIEnv *env, jobject object, jlong instance, jobject parent, jint viewType) +{ + Q_UNUSED(env); + Q_UNUSED(object); + Q_UNUSED(parent); + Q_UNUSED(viewType); + QQmlAndroidRecyclerAdapter *adapter = reinterpret_cast(instance); + if (adapter) { + QQmlAndroidView *item = nullptr; + QMetaObject::invokeMethod(adapter, "createItem", Qt::BlockingQueuedConnection, Q_RETURN_ARG(QQmlAndroidView *, item)); + item->construct(); + adapter->m_holders += QAndroidJniObject("qt/android/support/v7/widget/QmlRecyclerAdapter$ViewHolder", + "(Landroid/view/View;J)V", + item->instance().object(), + reinterpret_cast(item)); + return adapter->m_holders.last().object(); + } + return 0; +} + +void QQmlAndroidRecyclerAdapter::onBindViewHolder(JNIEnv *env, jobject object, jlong instance, jobject holder, jint position) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidRecyclerAdapter *adapter = reinterpret_cast(instance); + if (adapter) { + jlong vi = QAndroidJniObject(holder).callMethod("getInstance"); + QQmlAndroidView *item = reinterpret_cast(vi); + if (item) + QMetaObject::invokeMethod(adapter, "setItemPosition", Qt::BlockingQueuedConnection, Q_ARG(QQmlAndroidView *, item), Q_ARG(int, position)); + } +} + +QQmlAndroidView *QQmlAndroidRecyclerAdapter::createItem() +{ + QQmlAndroidView *item = nullptr; + if (m_delegate) { + QQmlContext *creationContext = m_delegate->creationContext(); + QQmlContext *context = new QQmlContext(creationContext ? creationContext : qmlContext(this)); + QObject *object = m_delegate->beginCreate(context); + if (object) { + context->setParent(object); + item = qobject_cast(object); + if (!item) + delete object; + } else { + delete context; + } + } else { + item = new QQmlAndroidView; + } + if (item) { + item->setContext(context()); + item->setParentView(qobject_cast(parent())); // TODO + setItemPosition(item, -1); + } + if (m_delegate) + m_delegate->completeCreate(); + return item; +} + +void QQmlAndroidRecyclerAdapter::setItemPosition(QQmlAndroidView *item, int position) +{ + QQmlContext *context = qmlContext(item); + if (context) + context = context->parentContext(); + if (context) + context->setContextProperty("position", position); +} + +QT_END_NAMESPACE diff --git a/src/android/support/v7/widget/qqmlandroidrecycleradapter_p.h b/src/android/support/v7/widget/qqmlandroidrecycleradapter_p.h new file mode 100644 index 0000000..1e2b9ea --- /dev/null +++ b/src/android/support/v7/widget/qqmlandroidrecycleradapter_p.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDRECYCLERADAPTER_P_H +#define QQMLANDROIDRECYCLERADAPTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QQmlComponent; +class QQmlAndroidView; + +class Q_QMLANDROID_EXPORT QQmlAndroidRecyclerAdapter : public QQmlAndroidContextual +{ + Q_OBJECT + Q_PROPERTY(int count READ count WRITE setCount NOTIFY countChanged) + Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) + +public: + explicit QQmlAndroidRecyclerAdapter(QObject *parent = nullptr); + + int count() const; + void setCount(int count); + + QQmlComponent *delegate() const; + void setDelegate(QQmlComponent *delegate); + +Q_SIGNALS: + void countChanged(); + void delegateChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + + static void onRegisterNativeMethods(jobject adapter); + static jobject onCreateViewHolder(JNIEnv *env, jobject object, jlong instance, jobject parent, jint viewType); + static void onBindViewHolder(JNIEnv *env, jobject object, jlong instance, jobject holder, jint position); + +private Q_SLOTS: + QQmlAndroidView *createItem(); + void setItemPosition(QQmlAndroidView *item, int position); + +private: + int m_count; + QQmlComponent *m_delegate; + QList m_holders; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDRECYCLERADAPTER_P_H diff --git a/src/android/support/v7/widget/qqmlandroidrecyclerview.cpp b/src/android/support/v7/widget/qqmlandroidrecyclerview.cpp new file mode 100644 index 0000000..684ccda --- /dev/null +++ b/src/android/support/v7/widget/qqmlandroidrecyclerview.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidrecyclerview_p.h" +#include "qqmlandroidrecycleradapter_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidRecyclerView::QQmlAndroidRecyclerView(QQmlAndroidView *parent) : + QQmlAndroidViewGroup(parent), m_adapter(0) +{ +} + +QQmlAndroidRecyclerAdapter *QQmlAndroidRecyclerView::adapter() const +{ + return m_adapter; +} + +void QQmlAndroidRecyclerView::setAdapter(QQmlAndroidRecyclerAdapter *adapter) +{ + if (m_adapter != adapter) { + if (m_adapter) { + m_adapter->setContext(0); + disconnect(m_adapter, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidRecyclerView::updateAdapter); + m_adapter->destruct(); + } + m_adapter = adapter; + if (m_adapter) { + m_adapter->setContext(context()); + connect(m_adapter, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidRecyclerView::updateAdapter); + if (isValid()) + m_adapter->construct(); + } + emit adapterChanged(); + }} + +QAndroidJniObject QQmlAndroidRecyclerView::onCreate() +{ + return QAndroidJniObject("android/support/v7/widget/RecyclerView", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidRecyclerView::onInflate(QAndroidJniObject& instance) +{ + m_layoutManager = QAndroidJniObject("android/support/v7/widget/LinearLayoutManager", + "(Landroid/content/Context;)V", + ctx().object()); + + instance.callMethod("setLayoutManager", + "(Landroid/support/v7/widget/RecyclerView$LayoutManager;)V", + m_layoutManager.object()); + + QQmlAndroidViewGroup::onInflate(instance); +} + +void QQmlAndroidRecyclerView::objectChange(ObjectChange change) +{ + QQmlAndroidViewGroup::objectChange(change); + if (change == InstanceChange) + updateAdapter(); +} + +void QQmlAndroidRecyclerView::updateAdapter() +{ + if (!isValid() || !m_adapter) + return; + + QAndroidJniObject view = instance(); + QAndroidJniObject adapter = m_adapter->instance(); + QtQmlAndroid::callFunction([=]() { + view.callMethod("setAdapter", "(Landroid/support/v7/widget/RecyclerView$Adapter;)V", adapter.object()); + }); +} + +QT_END_NAMESPACE diff --git a/src/android/support/v7/widget/qqmlandroidrecyclerview_p.h b/src/android/support/v7/widget/qqmlandroidrecyclerview_p.h new file mode 100644 index 0000000..a56a5cd --- /dev/null +++ b/src/android/support/v7/widget/qqmlandroidrecyclerview_p.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDRECYCLERVIEW_P_H +#define QQMLANDROIDRECYCLERVIEW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QQmlAndroidRecyclerAdapter; + +class Q_QMLANDROID_EXPORT QQmlAndroidRecyclerView : public QQmlAndroidViewGroup +{ + Q_OBJECT + Q_PROPERTY(QQmlAndroidRecyclerAdapter *adapter READ adapter WRITE setAdapter NOTIFY adapterChanged) + +public: + explicit QQmlAndroidRecyclerView(QQmlAndroidView *parent = nullptr); + + QQmlAndroidRecyclerAdapter *adapter() const; + void setAdapter(QQmlAndroidRecyclerAdapter *adapter); + +Q_SIGNALS: + void adapterChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject& instance) override; + + void objectChange(ObjectChange change) override; + +private Q_SLOTS: + void updateAdapter(); + +private: + QQmlAndroidRecyclerAdapter *m_adapter; + QAndroidJniObject m_layoutManager; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDRECYCLERVIEW_P_H diff --git a/src/android/support/v7/widget/widget.pri b/src/android/support/v7/widget/widget.pri new file mode 100644 index 0000000..3f67ebc --- /dev/null +++ b/src/android/support/v7/widget/widget.pri @@ -0,0 +1,11 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qqmlandroidcardview_p.h \ + $$PWD/qqmlandroidrecycleradapter_p.h \ + $$PWD/qqmlandroidrecyclerview_p.h + +SOURCES += \ + $$PWD/qqmlandroidcardview.cpp \ + $$PWD/qqmlandroidrecycleradapter.cpp \ + $$PWD/qqmlandroidrecyclerview.cpp diff --git a/src/android/view/animation/animation.pri b/src/android/view/animation/animation.pri new file mode 100644 index 0000000..0a90fd9 --- /dev/null +++ b/src/android/view/animation/animation.pri @@ -0,0 +1,39 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qqmlandroidacceleratedecelerateinterpolator_p.h \ + $$PWD/qqmlandroidaccelerateinterpolator_p.h \ + $$PWD/qqmlandroidalphaanimation_p.h \ + $$PWD/qqmlandroidanimation_p.h \ + $$PWD/qqmlandroidanimationset_p.h \ + $$PWD/qqmlandroidanticipateinterpolator_p.h \ + $$PWD/qqmlandroidanticipateovershootinterpolator_p.h \ + $$PWD/qqmlandroidbounceinterpolator_p.h \ + $$PWD/qqmlandroidcycleinterpolator_p.h \ + $$PWD/qqmlandroiddecelerateinterpolator_p.h \ + $$PWD/qqmlandroidinterpolator_p.h \ + $$PWD/qqmlandroidlinearinterpolator_p.h \ + $$PWD/qqmlandroidovershootinterpolator_p.h \ + $$PWD/qqmlandroidpathinterpolator_p.h \ + $$PWD/qqmlandroidrotateanimation_p.h \ + $$PWD/qqmlandroidscaleanimation_p.h \ + $$PWD/qqmlandroidtranslateanimation_p.h + +SOURCES += \ + $$PWD/qqmlandroidacceleratedecelerateinterpolator.cpp \ + $$PWD/qqmlandroidaccelerateinterpolator.cpp \ + $$PWD/qqmlandroidalphaanimation.cpp \ + $$PWD/qqmlandroidanimation.cpp \ + $$PWD/qqmlandroidanimationset.cpp \ + $$PWD/qqmlandroidanticipateinterpolator.cpp \ + $$PWD/qqmlandroidanticipateovershootinterpolator.cpp \ + $$PWD/qqmlandroidbounceinterpolator.cpp \ + $$PWD/qqmlandroidcycleinterpolator.cpp \ + $$PWD/qqmlandroiddecelerateinterpolator.cpp \ + $$PWD/qqmlandroidinterpolator.cpp \ + $$PWD/qqmlandroidlinearinterpolator.cpp \ + $$PWD/qqmlandroidovershootinterpolator.cpp \ + $$PWD/qqmlandroidpathinterpolator.cpp \ + $$PWD/qqmlandroidrotateanimation.cpp \ + $$PWD/qqmlandroidscaleanimation.cpp \ + $$PWD/qqmlandroidtranslateanimation.cpp diff --git a/src/android/view/animation/qqmlandroidacceleratedecelerateinterpolator.cpp b/src/android/view/animation/qqmlandroidacceleratedecelerateinterpolator.cpp new file mode 100644 index 0000000..43088da --- /dev/null +++ b/src/android/view/animation/qqmlandroidacceleratedecelerateinterpolator.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidacceleratedecelerateinterpolator_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidAccelerateDecelerateInterpolator::QQmlAndroidAccelerateDecelerateInterpolator(QObject *parent) : + QQmlAndroidInterpolator(parent) +{ +} + +QAndroidJniObject QQmlAndroidAccelerateDecelerateInterpolator::onCreate() +{ + return QAndroidJniObject("android/view/animation/AccelerateDecelerateInterpolator"); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidacceleratedecelerateinterpolator_p.h b/src/android/view/animation/qqmlandroidacceleratedecelerateinterpolator_p.h new file mode 100644 index 0000000..91a9055 --- /dev/null +++ b/src/android/view/animation/qqmlandroidacceleratedecelerateinterpolator_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDACCELERATEDECELERATEINTERPOLATOR_P_H +#define QQMLANDROIDACCELERATEDECELERATEINTERPOLATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidAccelerateDecelerateInterpolator : public QQmlAndroidInterpolator +{ + Q_OBJECT + +public: + explicit QQmlAndroidAccelerateDecelerateInterpolator(QObject *parent = nullptr); + +Q_SIGNALS: + +protected: + QAndroidJniObject onCreate() override; + +private: +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDACCELERATEDECELERATEINTERPOLATOR_P_H diff --git a/src/android/view/animation/qqmlandroidaccelerateinterpolator.cpp b/src/android/view/animation/qqmlandroidaccelerateinterpolator.cpp new file mode 100644 index 0000000..cc983fb --- /dev/null +++ b/src/android/view/animation/qqmlandroidaccelerateinterpolator.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidaccelerateinterpolator_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidAccelerateInterpolator::QQmlAndroidAccelerateInterpolator(QObject *parent) : + QQmlAndroidInterpolator(parent) +{ +} + +qreal QQmlAndroidAccelerateInterpolator::factor() const +{ + if (m_factor.isNull()) + return 1.0; + return m_factor; +} + +void QQmlAndroidAccelerateInterpolator::setFactor(qreal factor) +{ + if (m_factor.isNull() || m_factor != factor) { + m_factor = factor; + emit factorChanged(); + } +} + +QAndroidJniObject QQmlAndroidAccelerateInterpolator::onCreate() +{ + if (m_factor.isNull()) + return QAndroidJniObject("android/view/animation/AccelerateInterpolator"); + + return QAndroidJniObject("android/view/animation/AccelerateInterpolator", + "(F)V", + m_factor); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidaccelerateinterpolator_p.h b/src/android/view/animation/qqmlandroidaccelerateinterpolator_p.h new file mode 100644 index 0000000..ab2ab14 --- /dev/null +++ b/src/android/view/animation/qqmlandroidaccelerateinterpolator_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDACCELERATEINTERPOLATOR_P_H +#define QQMLANDROIDACCELERATEINTERPOLATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidAccelerateInterpolator : public QQmlAndroidInterpolator +{ + Q_OBJECT + Q_PROPERTY(qreal factor READ factor WRITE setFactor NOTIFY factorChanged) + +public: + explicit QQmlAndroidAccelerateInterpolator(QObject *parent = nullptr); + + qreal factor() const; + void setFactor(qreal factor); + +Q_SIGNALS: + void factorChanged(); + +protected: + QAndroidJniObject onCreate() override; + +private: + QQmlAndroidOptional m_factor; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDACCELERATEINTERPOLATOR_P_H diff --git a/src/android/view/animation/qqmlandroidalphaanimation.cpp b/src/android/view/animation/qqmlandroidalphaanimation.cpp new file mode 100644 index 0000000..833b7fe --- /dev/null +++ b/src/android/view/animation/qqmlandroidalphaanimation.cpp @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidalphaanimation_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidAlphaAnimation::QQmlAndroidAlphaAnimation(QObject *parent) : + QQmlAndroidAnimation(parent), m_fromAlpha(0), m_toAlpha(0) +{ +} + +qreal QQmlAndroidAlphaAnimation::fromAlpha() const +{ + return m_fromAlpha; +} + +void QQmlAndroidAlphaAnimation::setFromAlpha(qreal alpha) +{ + if (m_fromAlpha != alpha) { + m_fromAlpha = alpha; + emit fromAlphaChanged(); + } +} + +qreal QQmlAndroidAlphaAnimation::toAlpha() const +{ + return m_toAlpha; +} + +void QQmlAndroidAlphaAnimation::setToAlpha(qreal alpha) +{ + if (m_toAlpha != alpha) { + m_toAlpha = alpha; + emit toAlphaChanged(); + } +} + +QAndroidJniObject QQmlAndroidAlphaAnimation::onCreate() +{ + return QAndroidJniObject("android/view/animation/AlphaAnimation", + "(FF)V", + m_fromAlpha, m_toAlpha); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidalphaanimation_p.h b/src/android/view/animation/qqmlandroidalphaanimation_p.h new file mode 100644 index 0000000..0bddd50 --- /dev/null +++ b/src/android/view/animation/qqmlandroidalphaanimation_p.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDALPHAANIMATION_P_H +#define QQMLANDROIDALPHAANIMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidAlphaAnimation : public QQmlAndroidAnimation +{ + Q_OBJECT + Q_PROPERTY(qreal fromAlpha READ fromAlpha WRITE setFromAlpha NOTIFY fromAlphaChanged) + Q_PROPERTY(qreal toAlpha READ toAlpha WRITE setToAlpha NOTIFY toAlphaChanged) + +public: + explicit QQmlAndroidAlphaAnimation(QObject *parent = nullptr); + + qreal fromAlpha() const; + void setFromAlpha(qreal alpha); + + qreal toAlpha() const; + void setToAlpha(qreal alpha); + +Q_SIGNALS: + void fromAlphaChanged(); + void toAlphaChanged(); + +protected: + QAndroidJniObject onCreate() override; + +private: + qreal m_fromAlpha; + qreal m_toAlpha; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDALPHAANIMATION_P_H diff --git a/src/android/view/animation/qqmlandroidanimation.cpp b/src/android/view/animation/qqmlandroidanimation.cpp new file mode 100644 index 0000000..6dd43c3 --- /dev/null +++ b/src/android/view/animation/qqmlandroidanimation.cpp @@ -0,0 +1,281 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidanimation_p.h" +#include "qtqmlandroidfunctions_p.h" +#include "qqmlandroidinterpolator_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidAnimation::QQmlAndroidAnimation(QObject *parent) : + QQmlAndroidContextual(parent), m_interpolator(0) +{ +} + +int QQmlAndroidAnimation::resource() const +{ + if (m_resource.isNull()) + return 0; + return m_resource; +} + +void QQmlAndroidAnimation::setResource(int resource) +{ + if (m_resource.isNull() || m_resource != resource) { + m_resource = resource; + emit resourceChanged(); + } +} + +int QQmlAndroidAnimation::duration() const +{ + if (m_duration.isNull()) + return 0; + return m_duration; +} + +void QQmlAndroidAnimation::setDuration(int duration) +{ + if (m_duration.isNull() || m_duration != duration) { + m_duration = duration; + QtQmlAndroid::callIntMethod(instance(), "setDuration", duration); + emit durationChanged(); + } +} + +bool QQmlAndroidAnimation::fillAfter() const +{ + if (m_fillAfter.isNull()) + return false; + return m_fillAfter; +} + +void QQmlAndroidAnimation::setFillAfter(bool fill) +{ + if (m_fillAfter.isNull() || m_fillAfter != fill) { + m_fillAfter = fill; + QtQmlAndroid::callBoolMethod(instance(), "setFillAfter", fill); + emit fillAfterChanged(); + } +} + +bool QQmlAndroidAnimation::fillBefore() const +{ + if (m_fillBefore.isNull()) + return true; + return m_fillBefore; +} + +void QQmlAndroidAnimation::setFillBefore(bool fill) +{ + if (m_fillBefore.isNull() || m_fillBefore != fill) { + m_fillBefore = fill; + QtQmlAndroid::callBoolMethod(instance(), "setFillBefore", fill); + emit fillBeforeChanged(); + } +} + +bool QQmlAndroidAnimation::fillEnabled() const +{ + if (!m_fillEnabled.isNull()) + return false; + return m_fillEnabled; +} + +void QQmlAndroidAnimation::setFillEnabled(bool fill) +{ + if (m_fillEnabled.isNull() || m_fillEnabled != fill) { + m_fillEnabled = fill; + QtQmlAndroid::callBoolMethod(instance(), "setFillEnabled", fill); + emit fillEnabledChanged(); + } +} + +QQmlAndroidInterpolator *QQmlAndroidAnimation::interpolator() const +{ + return m_interpolator; +} + +void QQmlAndroidAnimation::setInterpolator(QQmlAndroidInterpolator *interpolator) +{ + if (m_interpolator != interpolator) { + if (m_interpolator) { + disconnect(m_interpolator, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidAnimation::updateInterpolator); + m_interpolator->destruct(); + } + m_interpolator = interpolator; + if (m_interpolator) { + connect(m_interpolator, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidAnimation::updateInterpolator); + if (isValid()) + m_interpolator->construct(); + } + } +} + +int QQmlAndroidAnimation::repeatCount() const +{ + if (m_repeatCount.isNull()) + return 0; + return m_repeatCount; +} + +void QQmlAndroidAnimation::setRepeatCount(int count) +{ + if (m_repeatCount.isNull() || m_repeatCount != count) { + m_repeatCount = count; + QtQmlAndroid::callIntMethod(instance(), "setRepeatCount", count); + emit repeatCountChanged(); + } +} + +QQmlAndroidAnimation::RepeatMode QQmlAndroidAnimation::repeatMode() const +{ + if (m_repeatMode.isNull()) + return RESTART; + return m_repeatMode; +} + +void QQmlAndroidAnimation::setRepeatMode(RepeatMode mode) +{ + if (m_repeatMode.isNull() || m_repeatMode != mode) { + m_repeatMode = mode; + QtQmlAndroid::callIntMethod(instance(), "setRepeatMode", mode); + emit repeatModeChanged(); + } +} + +int QQmlAndroidAnimation::startOffset() const +{ + if (m_startOffset.isNull()) + return 0; + return m_startOffset; +} + +void QQmlAndroidAnimation::setStartOffset(int offset) +{ + if (m_startOffset.isNull() || m_startOffset != offset) { + m_startOffset = offset; + QtQmlAndroid::callIntMethod(instance(), "setStartOffset", offset); + emit startOffsetChanged(); + } +} + +QQmlAndroidAnimation::ZAdjustment QQmlAndroidAnimation::zAdjustment() const +{ + if (m_zAdjustment.isNull()) + return ZORDER_NORMAL; + return m_zAdjustment; +} + +void QQmlAndroidAnimation::setZAdjustment(ZAdjustment adjustment) +{ + if (m_zAdjustment.isNull() || m_zAdjustment != adjustment) { + m_zAdjustment = adjustment; + QtQmlAndroid::callIntMethod(instance(), "setZAdjustment", adjustment); + emit zAdjustmentChanged(); + } +} + +void QQmlAndroidAnimation::cancel() +{ + QtQmlAndroid::callVoidMethod(instance(), "cancel"); +} + +void QQmlAndroidAnimation::start() +{ + QtQmlAndroid::callVoidMethod(instance(), "start"); +} + +void QQmlAndroidAnimation::startNow() +{ + QtQmlAndroid::callVoidMethod(instance(), "startNow"); +} + +QAndroidJniObject QQmlAndroidAnimation::onCreate() +{ + if (m_resource.isNull()) + return QAndroidJniObject("android/view/animation/Animation"); + + return QAndroidJniObject::callStaticObjectMethod("android/view/animation/AnimationUtils", + "loadAnimation", + "(Landroid/content/Context;I)Landroid/view/animation/Animation;", + ctx().object(), + m_resource); +} + +void QQmlAndroidAnimation::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidContextual::onInflate(instance); + + if (m_resource.isNull()) { + if (!m_duration.isNull()) + instance.callMethod("setDuration", "(J)V", static_cast(m_duration)); + if (!m_fillAfter.isNull()) + instance.callMethod("setFillAfter", "(Z)V", m_fillAfter); + if (!m_fillBefore.isNull()) + instance.callMethod("setFillBefore", "(Z)V", m_fillBefore); + if (!m_fillEnabled.isNull()) + instance.callMethod("setFillEnabled", "(Z)V", m_fillEnabled); + if (!m_repeatCount.isNull()) + instance.callMethod("setRepeatCount", "(I)V", m_repeatCount); + if (!m_repeatMode.isNull()) + instance.callMethod("setRepeatMode", "(I)V", m_repeatMode); + if (!m_startOffset.isNull()) + instance.callMethod("setStartOffset", "(J)V", static_cast(m_startOffset)); + if (!m_zAdjustment.isNull()) + instance.callMethod("setZAdjustment", "(I)V", m_zAdjustment); + } +} + +void QQmlAndroidAnimation::objectChange(ObjectChange change) +{ + if (change == InstanceChange) + updateInterpolator(); +} + +void QQmlAndroidAnimation::updateInterpolator() +{ + if (!isValid() || !m_interpolator || !m_interpolator->isValid()) + return; + + QAndroidJniObject animation = instance(); + QAndroidJniObject interpolator = m_interpolator->instance(); + QtQmlAndroid::callFunction([=]() { + animation.callMethod("setInterpolator", "(Landroid/view/animation/Interpolator;)V", interpolator.object()); + }); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidanimation_p.h b/src/android/view/animation/qqmlandroidanimation_p.h new file mode 100644 index 0000000..47717e6 --- /dev/null +++ b/src/android/view/animation/qqmlandroidanimation_p.h @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDANIMATION_P_H +#define QQMLANDROIDANIMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QQmlAndroidInterpolator; + +class Q_QMLANDROID_EXPORT QQmlAndroidAnimation : public QQmlAndroidContextual +{ + Q_OBJECT + Q_PROPERTY(int resource READ resource WRITE setResource NOTIFY resourceChanged) + Q_PROPERTY(int duration READ duration WRITE setDuration NOTIFY durationChanged) + Q_PROPERTY(bool fillAfter READ fillAfter WRITE setFillAfter NOTIFY fillAfterChanged) + Q_PROPERTY(bool fillBefore READ fillBefore WRITE setFillBefore NOTIFY fillBeforeChanged) + Q_PROPERTY(bool fillEnabled READ fillEnabled WRITE setFillEnabled NOTIFY fillEnabledChanged) + Q_PROPERTY(QQmlAndroidInterpolator *interpolator READ interpolator WRITE setInterpolator NOTIFY interpolatorChanged) + Q_PROPERTY(int repeatCount READ repeatCount WRITE setRepeatCount NOTIFY repeatCountChanged) + Q_PROPERTY(RepeatMode repeatMode READ repeatMode WRITE setRepeatMode NOTIFY repeatModeChanged) + Q_PROPERTY(int startOffset READ startOffset WRITE setStartOffset NOTIFY startOffsetChanged) + Q_PROPERTY(ZAdjustment zAdjustment READ zAdjustment WRITE setZAdjustment NOTIFY zAdjustmentChanged) + Q_ENUMS(RepeatMode ZAdjustment Infinity Relation) + +public: + explicit QQmlAndroidAnimation(QObject *parent = nullptr); + + int resource() const; + void setResource(int resource); + + enum Relation { + ABSOLUTE = 0, + RELATIVE_TO_SELF = 1, + RELATIVE_TO_PARENT = 2 + }; + + enum Infinity { + INFINITE = -1 + }; + + int duration() const; + void setDuration(int duration); + + bool fillAfter() const; + void setFillAfter(bool fill); + + bool fillBefore() const; + void setFillBefore(bool fill); + + bool fillEnabled() const; + void setFillEnabled(bool enabled); + + QQmlAndroidInterpolator *interpolator() const; + void setInterpolator(QQmlAndroidInterpolator *interpolator); + + int repeatCount() const; + void setRepeatCount(int count); + + enum RepeatMode { + RESTART = 1, + REVERSE = 2 + }; + + RepeatMode repeatMode() const; + void setRepeatMode(RepeatMode mode); + + int startOffset() const; + void setStartOffset(int offset); + + enum ZAdjustment { + ZORDER_NORMAL = 0, + ZORDER_TOP = 1, + ZORDER_BOTTOM = -1 + }; + + ZAdjustment zAdjustment() const; + void setZAdjustment(ZAdjustment adjustment); + +public Q_SLOTS: + void cancel(); + void start(); + void startNow(); + +Q_SIGNALS: + void resourceChanged(); + void durationChanged(); + void fillAfterChanged(); + void fillBeforeChanged(); + void fillEnabledChanged(); + void interpolatorChanged(); + void repeatCountChanged(); + void repeatModeChanged(); + void startOffsetChanged(); + void zAdjustmentChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + + void objectChange(ObjectChange change) override; + +private Q_SLOTS: + void updateInterpolator(); + +private: + QQmlAndroidOptional m_resource; + QQmlAndroidOptional m_duration; + QQmlAndroidOptional m_fillAfter; + QQmlAndroidOptional m_fillBefore; + QQmlAndroidOptional m_fillEnabled; + QQmlAndroidInterpolator *m_interpolator; + QQmlAndroidOptional m_repeatCount; + QQmlAndroidOptional m_repeatMode; + QQmlAndroidOptional m_startOffset; + QQmlAndroidOptional m_zAdjustment; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDANIMATION_P_H diff --git a/src/android/view/animation/qqmlandroidanimationset.cpp b/src/android/view/animation/qqmlandroidanimationset.cpp new file mode 100644 index 0000000..f5c85b5 --- /dev/null +++ b/src/android/view/animation/qqmlandroidanimationset.cpp @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidanimationset_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidAnimationSet::QQmlAndroidAnimationSet(QObject *parent) : + QQmlAndroidAnimation(parent), m_shareInterpolator(false) +{ +} + +bool QQmlAndroidAnimationSet::shareInterpolator() const +{ + return m_shareInterpolator; +} + +void QQmlAndroidAnimationSet::setShareInterpolator(bool share) +{ + if (m_shareInterpolator != share) { + m_shareInterpolator = share; + emit shareInterpolatorChanged(); + } +} + +QAndroidJniObject QQmlAndroidAnimationSet::onCreate() +{ + return QAndroidJniObject("android/view/animation/AnimationSet", + "(Z)V", + m_shareInterpolator); +} + +void QQmlAndroidAnimationSet::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidAnimation::onInflate(instance); + + foreach (QObject *object, children()) { + QQmlAndroidAnimation *child = qobject_cast(object); + if (child) { + QAndroidJniObject animation = child->instance(); + if (animation.isValid()) + instance.callMethod("addAnimation", "(Landroid/view/animation/Animation;)V", animation.object()); + } + } +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidanimationset_p.h b/src/android/view/animation/qqmlandroidanimationset_p.h new file mode 100644 index 0000000..2891e86 --- /dev/null +++ b/src/android/view/animation/qqmlandroidanimationset_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDANIMATIONSET_P_H +#define QQMLANDROIDANIMATIONSET_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidAnimationSet : public QQmlAndroidAnimation +{ + Q_OBJECT + Q_PROPERTY(bool shareInterpolator READ shareInterpolator WRITE setShareInterpolator NOTIFY shareInterpolatorChanged) + +public: + explicit QQmlAndroidAnimationSet(QObject *parent = nullptr); + + bool shareInterpolator() const; + void setShareInterpolator(bool share); + +Q_SIGNALS: + void shareInterpolatorChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + +private: + bool m_shareInterpolator; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDANIMATIONSET_P_H diff --git a/src/android/view/animation/qqmlandroidanticipateinterpolator.cpp b/src/android/view/animation/qqmlandroidanticipateinterpolator.cpp new file mode 100644 index 0000000..5588dec --- /dev/null +++ b/src/android/view/animation/qqmlandroidanticipateinterpolator.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidanticipateinterpolator_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidAnticipateInterpolator::QQmlAndroidAnticipateInterpolator(QObject *parent) : + QQmlAndroidInterpolator(parent) +{ +} + +qreal QQmlAndroidAnticipateInterpolator::tension() const +{ + if (m_tension.isNull()) + return 1.0; + return m_tension; +} + +void QQmlAndroidAnticipateInterpolator::setTension(qreal tension) +{ + if (m_tension.isNull() || m_tension != tension) { + m_tension = tension; + emit tensionChanged(); + } +} + +QAndroidJniObject QQmlAndroidAnticipateInterpolator::onCreate() +{ + if (m_tension.isNull()) + return QAndroidJniObject("android/view/animation/AnticipateInterpolator"); + + return QAndroidJniObject("android/view/animation/AnticipateInterpolator", + "(F)V", + m_tension); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidanticipateinterpolator_p.h b/src/android/view/animation/qqmlandroidanticipateinterpolator_p.h new file mode 100644 index 0000000..2a524b8 --- /dev/null +++ b/src/android/view/animation/qqmlandroidanticipateinterpolator_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDANTICIPATEINTERPOLATOR_P_H +#define QQMLANDROIDANTICIPATEINTERPOLATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidAnticipateInterpolator : public QQmlAndroidInterpolator +{ + Q_OBJECT + Q_PROPERTY(qreal tension READ tension WRITE setTension NOTIFY tensionChanged) + +public: + explicit QQmlAndroidAnticipateInterpolator(QObject *parent = nullptr); + + qreal tension() const; + void setTension(qreal tension); + +Q_SIGNALS: + void tensionChanged(); + +protected: + QAndroidJniObject onCreate() override; + +private: + QQmlAndroidOptional m_tension; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDANTICIPATEINTERPOLATOR_P_H diff --git a/src/android/view/animation/qqmlandroidanticipateovershootinterpolator.cpp b/src/android/view/animation/qqmlandroidanticipateovershootinterpolator.cpp new file mode 100644 index 0000000..6e2b21b --- /dev/null +++ b/src/android/view/animation/qqmlandroidanticipateovershootinterpolator.cpp @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidanticipateovershootinterpolator_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidAnticipateOvershootInterpolator::QQmlAndroidAnticipateOvershootInterpolator(QObject *parent) : + QQmlAndroidInterpolator(parent) +{ +} + +qreal QQmlAndroidAnticipateOvershootInterpolator::tension() const +{ + if (m_tension.isNull()) + return 1.0; + return m_tension; +} + +void QQmlAndroidAnticipateOvershootInterpolator::setTension(qreal tension) +{ + if (m_tension.isNull() || m_tension != tension) { + m_tension = tension; + emit tensionChanged(); + } +} + +qreal QQmlAndroidAnticipateOvershootInterpolator::extraTension() const +{ + if (m_extraTension.isNull()) + return 1.0; + return m_extraTension; +} + +void QQmlAndroidAnticipateOvershootInterpolator::setExtraTension(qreal tension) +{ + if (m_extraTension.isNull() || m_extraTension != tension) { + m_extraTension = tension; + emit extraTensionChanged(); + } +} + +QAndroidJniObject QQmlAndroidAnticipateOvershootInterpolator::onCreate() +{ + if (m_tension.isNull() && m_extraTension.isNull()) + return QAndroidJniObject("android/view/animation/AnticipateOvershootInterpolator"); + + if (!m_tension.isNull()) + return QAndroidJniObject("android/view/animation/AnticipateOvershootInterpolator", + "(F)V", + m_tension); + + return QAndroidJniObject("android/view/animation/AnticipateOvershootInterpolator", + "(FF)V", + m_tension, + m_extraTension); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidanticipateovershootinterpolator_p.h b/src/android/view/animation/qqmlandroidanticipateovershootinterpolator_p.h new file mode 100644 index 0000000..05a4092 --- /dev/null +++ b/src/android/view/animation/qqmlandroidanticipateovershootinterpolator_p.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDANTICIPATEOVERSHOOTINTERPOLATOR_P_H +#define QQMLANDROIDANTICIPATEOVERSHOOTINTERPOLATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidAnticipateOvershootInterpolator : public QQmlAndroidInterpolator +{ + Q_OBJECT + Q_PROPERTY(qreal tension READ tension WRITE setTension NOTIFY tensionChanged) + Q_PROPERTY(qreal extraTension READ extraTension WRITE setExtraTension NOTIFY extraTensionChanged) + +public: + explicit QQmlAndroidAnticipateOvershootInterpolator(QObject *parent = nullptr); + + qreal tension() const; + void setTension(qreal tension); + + qreal extraTension() const; + void setExtraTension(qreal tension); + +Q_SIGNALS: + void tensionChanged(); + void extraTensionChanged(); + +protected: + QAndroidJniObject onCreate() override; + +private: + QQmlAndroidOptional m_tension; + QQmlAndroidOptional m_extraTension; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDANTICIPATEOVERSHOOTINTERPOLATOR_P_H diff --git a/src/android/view/animation/qqmlandroidbounceinterpolator.cpp b/src/android/view/animation/qqmlandroidbounceinterpolator.cpp new file mode 100644 index 0000000..c615d2d --- /dev/null +++ b/src/android/view/animation/qqmlandroidbounceinterpolator.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidbounceinterpolator_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidBounceInterpolator::QQmlAndroidBounceInterpolator(QObject *parent) : + QQmlAndroidInterpolator(parent) +{ +} + +QAndroidJniObject QQmlAndroidBounceInterpolator::onCreate() +{ + return QAndroidJniObject("android/view/animation/BounceInterpolator"); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidbounceinterpolator_p.h b/src/android/view/animation/qqmlandroidbounceinterpolator_p.h new file mode 100644 index 0000000..4a9da71 --- /dev/null +++ b/src/android/view/animation/qqmlandroidbounceinterpolator_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDBOUNCEINTERPOLATOR_P_H +#define QQMLANDROIDBOUNCEINTERPOLATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidBounceInterpolator : public QQmlAndroidInterpolator +{ + Q_OBJECT + +public: + explicit QQmlAndroidBounceInterpolator(QObject *parent = nullptr); + +Q_SIGNALS: + +protected: + QAndroidJniObject onCreate() override; + +private: +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDBOUNCEINTERPOLATOR_P_H diff --git a/src/android/view/animation/qqmlandroidcycleinterpolator.cpp b/src/android/view/animation/qqmlandroidcycleinterpolator.cpp new file mode 100644 index 0000000..6c88540 --- /dev/null +++ b/src/android/view/animation/qqmlandroidcycleinterpolator.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidcycleinterpolator_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidCycleInterpolator::QQmlAndroidCycleInterpolator(QObject *parent) : + QQmlAndroidInterpolator(parent) +{ +} + +qreal QQmlAndroidCycleInterpolator::cycles() const +{ + if (m_cycles.isNull()) + return 1.0; + return m_cycles; +} + +void QQmlAndroidCycleInterpolator::setCycles(qreal cycles) +{ + if (m_cycles.isNull() || m_cycles != cycles) { + m_cycles = cycles; + emit cyclesChanged(); + } +} + +QAndroidJniObject QQmlAndroidCycleInterpolator::onCreate() +{ + if (m_cycles.isNull()) + return QAndroidJniObject("android/view/animation/CycleInterpolator"); + + return QAndroidJniObject("android/view/animation/CycleInterpolator", + "(F)V", + m_cycles); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidcycleinterpolator_p.h b/src/android/view/animation/qqmlandroidcycleinterpolator_p.h new file mode 100644 index 0000000..6fbeeeb --- /dev/null +++ b/src/android/view/animation/qqmlandroidcycleinterpolator_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDCYCLEINTERPOLATOR_P_H +#define QQMLANDROIDCYCLEINTERPOLATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidCycleInterpolator : public QQmlAndroidInterpolator +{ + Q_OBJECT + Q_PROPERTY(qreal cycles READ cycles WRITE setCycles NOTIFY cyclesChanged) + +public: + explicit QQmlAndroidCycleInterpolator(QObject *parent = nullptr); + + qreal cycles() const; + void setCycles(qreal cycles); + +Q_SIGNALS: + void cyclesChanged(); + +protected: + QAndroidJniObject onCreate() override; + +private: + QQmlAndroidOptional m_cycles; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDCYCLEINTERPOLATOR_P_H diff --git a/src/android/view/animation/qqmlandroiddecelerateinterpolator.cpp b/src/android/view/animation/qqmlandroiddecelerateinterpolator.cpp new file mode 100644 index 0000000..e634367 --- /dev/null +++ b/src/android/view/animation/qqmlandroiddecelerateinterpolator.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroiddecelerateinterpolator_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidDecelerateInterpolator::QQmlAndroidDecelerateInterpolator(QObject *parent) : + QQmlAndroidInterpolator(parent) +{ +} + +qreal QQmlAndroidDecelerateInterpolator::factor() const +{ + if (m_factor.isNull()) + return 1.0; + return m_factor; +} + +void QQmlAndroidDecelerateInterpolator::setFactor(qreal factor) +{ + if (m_factor.isNull() || m_factor != factor) { + m_factor = factor; + emit factorChanged(); + } +} + +QAndroidJniObject QQmlAndroidDecelerateInterpolator::onCreate() +{ + if (m_factor.isNull()) + return QAndroidJniObject("android/view/animation/DecelerateInterpolator"); + + return QAndroidJniObject("android/view/animation/DecelerateInterpolator", + "(F)V", + m_factor); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroiddecelerateinterpolator_p.h b/src/android/view/animation/qqmlandroiddecelerateinterpolator_p.h new file mode 100644 index 0000000..3fa2800 --- /dev/null +++ b/src/android/view/animation/qqmlandroiddecelerateinterpolator_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDDECELERATEINTERPOLATOR_P_H +#define QQMLANDROIDDECELERATEINTERPOLATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidDecelerateInterpolator : public QQmlAndroidInterpolator +{ + Q_OBJECT + Q_PROPERTY(qreal factor READ factor WRITE setFactor NOTIFY factorChanged) + +public: + explicit QQmlAndroidDecelerateInterpolator(QObject *parent = nullptr); + + qreal factor() const; + void setFactor(qreal factor); + +Q_SIGNALS: + void factorChanged(); + +protected: + QAndroidJniObject onCreate() override; + +private: + QQmlAndroidOptional m_factor; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDDECELERATEINTERPOLATOR_P_H diff --git a/src/android/view/animation/qqmlandroidinterpolator.cpp b/src/android/view/animation/qqmlandroidinterpolator.cpp new file mode 100644 index 0000000..9764bda --- /dev/null +++ b/src/android/view/animation/qqmlandroidinterpolator.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidinterpolator_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidInterpolator::QQmlAndroidInterpolator(QObject *parent) : + QQmlAndroidObject(parent) +{ +} + +QAndroidJniObject QQmlAndroidInterpolator::onCreate() +{ + return QAndroidJniObject(); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidinterpolator_p.h b/src/android/view/animation/qqmlandroidinterpolator_p.h new file mode 100644 index 0000000..cd27e0b --- /dev/null +++ b/src/android/view/animation/qqmlandroidinterpolator_p.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDINTERPOLATOR_P_H +#define QQMLANDROIDINTERPOLATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidInterpolator : public QQmlAndroidObject +{ + Q_OBJECT + +public: + explicit QQmlAndroidInterpolator(QObject *parent = nullptr); + +protected: + QAndroidJniObject onCreate() override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDINTERPOLATOR_P_H diff --git a/src/android/view/animation/qqmlandroidlinearinterpolator.cpp b/src/android/view/animation/qqmlandroidlinearinterpolator.cpp new file mode 100644 index 0000000..57dcfa6 --- /dev/null +++ b/src/android/view/animation/qqmlandroidlinearinterpolator.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidlinearinterpolator_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidLinearInterpolator::QQmlAndroidLinearInterpolator(QObject *parent) : + QQmlAndroidInterpolator(parent) +{ +} + +QAndroidJniObject QQmlAndroidLinearInterpolator::onCreate() +{ + return QAndroidJniObject("android/view/animation/LinearInterpolator"); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidlinearinterpolator_p.h b/src/android/view/animation/qqmlandroidlinearinterpolator_p.h new file mode 100644 index 0000000..4ccc2d3 --- /dev/null +++ b/src/android/view/animation/qqmlandroidlinearinterpolator_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDLINEARINTERPOLATOR_P_H +#define QQMLANDROIDLINEARINTERPOLATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidLinearInterpolator : public QQmlAndroidInterpolator +{ + Q_OBJECT + +public: + explicit QQmlAndroidLinearInterpolator(QObject *parent = nullptr); + +Q_SIGNALS: + +protected: + QAndroidJniObject onCreate() override; + +private: +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDLINEARINTERPOLATOR_P_H diff --git a/src/android/view/animation/qqmlandroidovershootinterpolator.cpp b/src/android/view/animation/qqmlandroidovershootinterpolator.cpp new file mode 100644 index 0000000..595a209 --- /dev/null +++ b/src/android/view/animation/qqmlandroidovershootinterpolator.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidovershootinterpolator_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidOvershootInterpolator::QQmlAndroidOvershootInterpolator(QObject *parent) : + QQmlAndroidInterpolator(parent) +{ +} + +qreal QQmlAndroidOvershootInterpolator::tension() const +{ + if (m_tension.isNull()) + return 2.0; + return m_tension; +} + +void QQmlAndroidOvershootInterpolator::setTension(qreal tension) +{ + if (m_tension.isNull() || m_tension != tension) { + m_tension = tension; + emit tensionChanged(); + } +} + +QAndroidJniObject QQmlAndroidOvershootInterpolator::onCreate() +{ + if (m_tension.isNull()) + return QAndroidJniObject("android/view/animation/OvershootInterpolator"); + + return QAndroidJniObject("android/view/animation/OvershootInterpolator", + "(F)V", + m_tension); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidovershootinterpolator_p.h b/src/android/view/animation/qqmlandroidovershootinterpolator_p.h new file mode 100644 index 0000000..b7eebb0 --- /dev/null +++ b/src/android/view/animation/qqmlandroidovershootinterpolator_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDOVERSHOOTINTERPOLATOR_P_H +#define QQMLANDROIDOVERSHOOTINTERPOLATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidOvershootInterpolator : public QQmlAndroidInterpolator +{ + Q_OBJECT + Q_PROPERTY(qreal tension READ tension WRITE setTension NOTIFY tensionChanged) + +public: + explicit QQmlAndroidOvershootInterpolator(QObject *parent = nullptr); + + qreal tension() const; + void setTension(qreal tension); + +Q_SIGNALS: + void tensionChanged(); + +protected: + QAndroidJniObject onCreate() override; + +private: + QQmlAndroidOptional m_tension; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDOVERSHOOTINTERPOLATOR_P_H diff --git a/src/android/view/animation/qqmlandroidpathinterpolator.cpp b/src/android/view/animation/qqmlandroidpathinterpolator.cpp new file mode 100644 index 0000000..ae6a56c --- /dev/null +++ b/src/android/view/animation/qqmlandroidpathinterpolator.cpp @@ -0,0 +1,125 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidpathinterpolator_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidPathInterpolator::QQmlAndroidPathInterpolator(QObject *parent) : + QQmlAndroidInterpolator(parent) +{ +} + +qreal QQmlAndroidPathInterpolator::controlX() const +{ + if (m_controlX.isNull()) + return 0.0; + return m_controlX; +} + +void QQmlAndroidPathInterpolator::setControlX(qreal x) +{ + if (m_controlX.isNull() || m_controlX != x) { + m_controlX = x; + emit controlXChanged(); + } +} + +qreal QQmlAndroidPathInterpolator::controlY() const +{ + if (m_controlY.isNull()) + return 0.0; + return m_controlY; +} + +void QQmlAndroidPathInterpolator::setControlY(qreal y) +{ + if (m_controlY.isNull() || m_controlY != y) { + m_controlY = y; + emit controlYChanged(); + } +} + +qreal QQmlAndroidPathInterpolator::controlX2() const +{ + if (m_controlX2.isNull()) + return 0.0; + return m_controlX2; +} + +void QQmlAndroidPathInterpolator::setControlX2(qreal x) +{ + if (m_controlX2.isNull() || m_controlX2 != x) { + m_controlX2 = x; + emit controlX2Changed(); + } +} + +qreal QQmlAndroidPathInterpolator::controlY2() const +{ + if (m_controlY2.isNull()) + return 0.0; + return m_controlY2; +} + +void QQmlAndroidPathInterpolator::setControlY2(qreal y) +{ + if (m_controlY2.isNull() || m_controlY2 != y) { + m_controlY2 = y; + emit controlY2Changed(); + } +} + +QAndroidJniObject QQmlAndroidPathInterpolator::onCreate() +{ + if (!m_controlX.isNull() && !m_controlY.isNull() && !m_controlX2.isNull() && !m_controlY2.isNull()) + return QAndroidJniObject("android/view/animation/PathInterpolator", + "(FFFF)V", + m_controlX, + m_controlY, + m_controlX2, + m_controlY2); + + if (!m_controlX.isNull() && !m_controlY.isNull()) + return QAndroidJniObject("android/view/animation/PathInterpolator", + "(FF)V", + m_controlX, + m_controlY); + + return QAndroidJniObject(); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidpathinterpolator_p.h b/src/android/view/animation/qqmlandroidpathinterpolator_p.h new file mode 100644 index 0000000..7e80fcf --- /dev/null +++ b/src/android/view/animation/qqmlandroidpathinterpolator_p.h @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDAPATHINTERPOLATOR_P_H +#define QQMLANDROIDAPATHINTERPOLATOR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidPathInterpolator : public QQmlAndroidInterpolator +{ + Q_OBJECT + Q_PROPERTY(qreal controlX READ controlX WRITE setControlX NOTIFY controlXChanged) + Q_PROPERTY(qreal controlY READ controlY WRITE setControlY NOTIFY controlYChanged) + Q_PROPERTY(qreal controlX2 READ controlX2 WRITE setControlX2 NOTIFY controlX2Changed) + Q_PROPERTY(qreal controlY2 READ controlY2 WRITE setControlY2 NOTIFY controlY2Changed) + +public: + explicit QQmlAndroidPathInterpolator(QObject *parent = nullptr); + + qreal controlX() const; + void setControlX(qreal x); + + qreal controlY() const; + void setControlY(qreal y); + + qreal controlX2() const; + void setControlX2(qreal x); + + qreal controlY2() const; + void setControlY2(qreal y); + +Q_SIGNALS: + void controlXChanged(); + void controlYChanged(); + void controlX2Changed(); + void controlY2Changed(); + +protected: + QAndroidJniObject onCreate() override; + +private: + QQmlAndroidOptional m_controlX; + QQmlAndroidOptional m_controlY; + QQmlAndroidOptional m_controlX2; + QQmlAndroidOptional m_controlY2; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDAPATHINTERPOLATOR_P_H diff --git a/src/android/view/animation/qqmlandroidrotateanimation.cpp b/src/android/view/animation/qqmlandroidrotateanimation.cpp new file mode 100644 index 0000000..03c921f --- /dev/null +++ b/src/android/view/animation/qqmlandroidrotateanimation.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidrotateanimation_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidRotateAnimation::QQmlAndroidRotateAnimation(QObject *parent) : + QQmlAndroidAnimation(parent), m_from(0), m_to(0), + m_pivotX(0), m_pivotY(0), m_pivotXType(ABSOLUTE), m_pivotYType(ABSOLUTE) +{ +} + +qreal QQmlAndroidRotateAnimation::fromDegrees() const +{ + return m_from; +} + +void QQmlAndroidRotateAnimation::setFromDegrees(qreal degrees) +{ + if (m_from != degrees) { + m_from = degrees; + emit fromDegreesChanged(); + } +} + +qreal QQmlAndroidRotateAnimation::toDegrees() const +{ + return m_to; +} + +void QQmlAndroidRotateAnimation::setToDegrees(qreal degrees) +{ + if (m_to != degrees) { + m_to = degrees; + emit toDegreesChanged(); + } +} + +qreal QQmlAndroidRotateAnimation::pivotX() const +{ + return m_pivotX; +} + +void QQmlAndroidRotateAnimation::setPivotX(qreal pivotX) +{ + if (m_pivotX != pivotX) { + m_pivotX = pivotX; + emit pivotXChanged(); + } +} + +qreal QQmlAndroidRotateAnimation::pivotY() const +{ + return m_pivotY; +} + +void QQmlAndroidRotateAnimation::setPivotY(qreal pivotY) +{ + if (m_pivotY != pivotY) { + m_pivotY = pivotY; + emit pivotYChanged(); + } +} + +QQmlAndroidRotateAnimation::Relation QQmlAndroidRotateAnimation::pivotXType() const +{ + return m_pivotXType; +} + +void QQmlAndroidRotateAnimation::setPivotXType(Relation type) +{ + if (m_pivotXType != type) { + m_pivotXType = type; + emit pivotXTypeChanged(); + } +} + +QQmlAndroidRotateAnimation::Relation QQmlAndroidRotateAnimation::pivotYType() const +{ + return m_pivotYType; +} + +void QQmlAndroidRotateAnimation::setPivotYType(Relation type) +{ + if (m_pivotYType != type) { + m_pivotYType = type; + emit pivotYTypeChanged(); + } +} + +QAndroidJniObject QQmlAndroidRotateAnimation::onCreate() +{ + return QAndroidJniObject("android/view/animation/RotateAnimation", + "(FFIFIF)V", + m_from, m_to, + m_pivotXType, m_pivotX, m_pivotYType, m_pivotY); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidrotateanimation_p.h b/src/android/view/animation/qqmlandroidrotateanimation_p.h new file mode 100644 index 0000000..7615a42 --- /dev/null +++ b/src/android/view/animation/qqmlandroidrotateanimation_p.h @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDROTATEANIMATION_P_H +#define QQMLANDROIDROTATEANIMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidRotateAnimation : public QQmlAndroidAnimation +{ + Q_OBJECT + Q_PROPERTY(qreal fromDegrees READ fromDegrees WRITE setFromDegrees NOTIFY fromDegreesChanged) + Q_PROPERTY(qreal toDegrees READ toDegrees WRITE setToDegrees NOTIFY toDegreesChanged) + Q_PROPERTY(qreal pivotX READ pivotX WRITE setPivotX NOTIFY pivotXChanged) + Q_PROPERTY(qreal pivotY READ pivotY WRITE setPivotY NOTIFY pivotYChanged) + Q_PROPERTY(Relation pivotXType READ pivotXType WRITE setPivotXType NOTIFY pivotXTypeChanged) + Q_PROPERTY(Relation pivotYType READ pivotYType WRITE setPivotYType NOTIFY pivotYTypeChanged) + Q_ENUMS(Relation) + +public: + explicit QQmlAndroidRotateAnimation(QObject *parent = nullptr); + + qreal fromDegrees() const; + void setFromDegrees(qreal degrees); + + qreal toDegrees() const; + void setToDegrees(qreal degrees); + + qreal pivotX() const; + void setPivotX(qreal x); + + qreal pivotY() const; + void setPivotY(qreal y); + + Relation pivotXType() const; + void setPivotXType(Relation type); + + Relation pivotYType() const; + void setPivotYType(Relation type); + +Q_SIGNALS: + void fromDegreesChanged(); + void toDegreesChanged(); + void pivotXChanged(); + void pivotYChanged(); + void pivotXTypeChanged(); + void pivotYTypeChanged(); + +protected: + QAndroidJniObject onCreate() override; + +private: + qreal m_from; + qreal m_to; + qreal m_pivotX; + qreal m_pivotY; + Relation m_pivotXType; + Relation m_pivotYType; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDROTATEANIMATION_P_H diff --git a/src/android/view/animation/qqmlandroidscaleanimation.cpp b/src/android/view/animation/qqmlandroidscaleanimation.cpp new file mode 100644 index 0000000..4c21bdc --- /dev/null +++ b/src/android/view/animation/qqmlandroidscaleanimation.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidscaleanimation_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidScaleAnimation::QQmlAndroidScaleAnimation(QObject *parent) : + QQmlAndroidAnimation(parent), m_fromX(0), m_fromY(0), m_toX(0), m_toY(0), + m_pivotX(0), m_pivotY(0), m_pivotXType(ABSOLUTE), m_pivotYType(ABSOLUTE) +{ +} + +qreal QQmlAndroidScaleAnimation::fromXScale() const +{ + return m_fromX; +} + +void QQmlAndroidScaleAnimation::setFromXScale(qreal x) +{ + if (m_fromX != x) { + m_fromX = x; + emit fromXScaleChanged(); + } +} + +qreal QQmlAndroidScaleAnimation::fromYScale() const +{ + return m_fromY; +} + +void QQmlAndroidScaleAnimation::setFromYScale(qreal y) +{ + if (m_fromY != y) { + m_fromY = y; + emit fromYScaleChanged(); + } +} + +qreal QQmlAndroidScaleAnimation::toXScale() const +{ + return m_toX; +} + +void QQmlAndroidScaleAnimation::setToXScale(qreal x) +{ + if (m_toX != x) { + m_toX = x; + emit toXScaleChanged(); + } +} + +qreal QQmlAndroidScaleAnimation::toYScale() const +{ + return m_toY; +} + +void QQmlAndroidScaleAnimation::setToYScale(qreal y) +{ + if (m_toY != y) { + m_toY = y; + emit toYScaleChanged(); + } +} + +qreal QQmlAndroidScaleAnimation::pivotX() const +{ + return m_pivotX; +} + +void QQmlAndroidScaleAnimation::setPivotX(qreal pivotX) +{ + if (m_pivotX != pivotX) { + m_pivotX = pivotX; + emit pivotXChanged(); + } +} + +qreal QQmlAndroidScaleAnimation::pivotY() const +{ + return m_pivotY; +} + +void QQmlAndroidScaleAnimation::setPivotY(qreal pivotY) +{ + if (m_pivotY != pivotY) { + m_pivotY = pivotY; + emit pivotYChanged(); + } +} + +QQmlAndroidAnimation::Relation QQmlAndroidScaleAnimation::pivotXType() const +{ + return m_pivotXType; +} + +void QQmlAndroidScaleAnimation::setPivotXType(Relation type) +{ + if (m_pivotXType != type) { + m_pivotXType = type; + emit pivotXTypeChanged(); + } +} + +QQmlAndroidAnimation::Relation QQmlAndroidScaleAnimation::pivotYType() const +{ + return m_pivotYType; +} + +void QQmlAndroidScaleAnimation::setPivotYType(Relation type) +{ + if (m_pivotYType != type) { + m_pivotYType = type; + emit pivotYTypeChanged(); + } +} + +QAndroidJniObject QQmlAndroidScaleAnimation::onCreate() +{ + return QAndroidJniObject("android/view/animation/ScaleAnimation", + "(FFFFIFIF)V", + m_fromX, m_toX, m_fromY, m_toY, + m_pivotXType, m_pivotX, m_pivotYType, m_pivotY); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidscaleanimation_p.h b/src/android/view/animation/qqmlandroidscaleanimation_p.h new file mode 100644 index 0000000..7dd118d --- /dev/null +++ b/src/android/view/animation/qqmlandroidscaleanimation_p.h @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDSCALEANIMATION_P_H +#define QQMLANDROIDSCALEANIMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidScaleAnimation : public QQmlAndroidAnimation +{ + Q_OBJECT + Q_PROPERTY(qreal fromXScale READ fromXScale WRITE setFromXScale NOTIFY fromXScaleChanged) + Q_PROPERTY(qreal fromYScale READ fromYScale WRITE setFromYScale NOTIFY fromYScaleChanged) + Q_PROPERTY(qreal toXScale READ toXScale WRITE setToXScale NOTIFY toXScaleChanged) + Q_PROPERTY(qreal toYScale READ toYScale WRITE setToYScale NOTIFY toYScaleChanged) + Q_PROPERTY(qreal pivotX READ pivotX WRITE setPivotX NOTIFY pivotXChanged) + Q_PROPERTY(qreal pivotY READ pivotY WRITE setPivotY NOTIFY pivotYChanged) + Q_PROPERTY(Relation pivotXType READ pivotXType WRITE setPivotXType NOTIFY pivotXTypeChanged) + Q_PROPERTY(Relation pivotYType READ pivotYType WRITE setPivotYType NOTIFY pivotYTypeChanged) + +public: + explicit QQmlAndroidScaleAnimation(QObject *parent = nullptr); + + qreal fromXScale() const; + void setFromXScale(qreal scale); + + qreal fromYScale() const; + void setFromYScale(qreal scale); + + qreal toXScale() const; + void setToXScale(qreal scale); + + qreal toYScale() const; + void setToYScale(qreal scale); + + qreal pivotX() const; + void setPivotX(qreal x); + + qreal pivotY() const; + void setPivotY(qreal y); + + Relation pivotXType() const; + void setPivotXType(Relation type); + + Relation pivotYType() const; + void setPivotYType(Relation type); + +Q_SIGNALS: + void fromXScaleChanged(); + void fromYScaleChanged(); + void toXScaleChanged(); + void toYScaleChanged(); + void pivotXChanged(); + void pivotYChanged(); + void pivotXTypeChanged(); + void pivotYTypeChanged(); + +protected: + QAndroidJniObject onCreate() override; + +private: + qreal m_fromX; + qreal m_fromY; + qreal m_toX; + qreal m_toY; + qreal m_pivotX; + qreal m_pivotY; + Relation m_pivotXType; + Relation m_pivotYType; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDSCALEANIMATION_P_H diff --git a/src/android/view/animation/qqmlandroidtranslateanimation.cpp b/src/android/view/animation/qqmlandroidtranslateanimation.cpp new file mode 100644 index 0000000..f432c22 --- /dev/null +++ b/src/android/view/animation/qqmlandroidtranslateanimation.cpp @@ -0,0 +1,159 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidtranslateanimation_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidTranslateAnimation::QQmlAndroidTranslateAnimation(QObject *parent) : + QQmlAndroidAnimation(parent), m_fromX(0), m_fromY(0), m_toX(0), m_toY(0), + m_fromXType(ABSOLUTE), m_fromYType(ABSOLUTE), m_toXType(ABSOLUTE), m_toYType(ABSOLUTE) +{ +} + +qreal QQmlAndroidTranslateAnimation::fromX() const +{ + return m_fromX; +} + +void QQmlAndroidTranslateAnimation::setFromX(qreal x) +{ + if (m_fromX != x) { + m_fromX = x; + emit fromXChanged(); + } +} + +qreal QQmlAndroidTranslateAnimation::fromY() const +{ + return m_fromY; +} + +void QQmlAndroidTranslateAnimation::setFromY(qreal y) +{ + if (m_fromY != y) { + m_fromY = y; + emit fromYChanged(); + } +} + +qreal QQmlAndroidTranslateAnimation::toX() const +{ + return m_toX; +} + +void QQmlAndroidTranslateAnimation::setToX(qreal x) +{ + if (m_toX != x) { + m_toX = x; + emit toXChanged(); + } +} + +qreal QQmlAndroidTranslateAnimation::toY() const +{ + return m_toY; +} + +void QQmlAndroidTranslateAnimation::setToY(qreal y) +{ + if (m_toY != y) { + m_toY = y; + emit toYChanged(); + } +} + +QQmlAndroidAnimation::Relation QQmlAndroidTranslateAnimation::fromXType() const +{ + return m_fromXType; +} + +void QQmlAndroidTranslateAnimation::setFromXType(Relation type) +{ + if (m_fromXType != type) { + m_fromXType = type; + emit fromXTypeChanged(); + } +} + +QQmlAndroidAnimation::Relation QQmlAndroidTranslateAnimation::fromYType() const +{ + return m_fromYType; +} + +void QQmlAndroidTranslateAnimation::setFromYType(Relation type) +{ + if (m_fromYType != type) { + m_fromYType = type; + emit fromYTypeChanged(); + } +} + +QQmlAndroidAnimation::Relation QQmlAndroidTranslateAnimation::toXType() const +{ + return m_toXType; +} + +void QQmlAndroidTranslateAnimation::setToXType(Relation type) +{ + if (m_toXType != type) { + m_toXType = type; + emit toXTypeChanged(); + } +} + +QQmlAndroidAnimation::Relation QQmlAndroidTranslateAnimation::toYType() const +{ + return m_toYType; +} + +void QQmlAndroidTranslateAnimation::setToYType(Relation type) +{ + if (m_toYType != type) { + m_toYType = type; + emit toYTypeChanged(); + } +} + +QAndroidJniObject QQmlAndroidTranslateAnimation::onCreate() +{ + return QAndroidJniObject("android/view/animation/TranslateAnimation", + "(IFIFIFIF)V", + m_fromXType, m_fromX, m_toXType, m_toX, + m_fromYType, m_fromY, m_toYType, m_toY); +} + +QT_END_NAMESPACE diff --git a/src/android/view/animation/qqmlandroidtranslateanimation_p.h b/src/android/view/animation/qqmlandroidtranslateanimation_p.h new file mode 100644 index 0000000..6c3859b --- /dev/null +++ b/src/android/view/animation/qqmlandroidtranslateanimation_p.h @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDTRANSLATEANIMATION_P_H +#define QQMLANDROIDTRANSLATEANIMATION_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidTranslateAnimation : public QQmlAndroidAnimation +{ + Q_OBJECT + Q_PROPERTY(qreal fromX READ fromX WRITE setFromX NOTIFY fromXChanged) + Q_PROPERTY(qreal fromY READ fromY WRITE setFromY NOTIFY fromYChanged) + Q_PROPERTY(qreal toX READ toX WRITE setToX NOTIFY toXChanged) + Q_PROPERTY(qreal toY READ toY WRITE setToY NOTIFY toYChanged) + Q_PROPERTY(Relation fromXType READ fromXType WRITE setFromXType NOTIFY fromXTypeChanged) + Q_PROPERTY(Relation fromYType READ fromYType WRITE setFromYType NOTIFY fromYTypeChanged) + Q_PROPERTY(Relation toXType READ toXType WRITE setToXType NOTIFY toXTypeChanged) + Q_PROPERTY(Relation toYType READ toYType WRITE setToYType NOTIFY toYTypeChanged) + +public: + explicit QQmlAndroidTranslateAnimation(QObject *parent = nullptr); + + qreal fromX() const; + void setFromX(qreal x); + + qreal fromY() const; + void setFromY(qreal y); + + qreal toX() const; + void setToX(qreal x); + + qreal toY() const; + void setToY(qreal y); + + Relation fromXType() const; + void setFromXType(Relation type); + + Relation fromYType() const; + void setFromYType(Relation type); + + Relation toXType() const; + void setToXType(Relation type); + + Relation toYType() const; + void setToYType(Relation type); + +Q_SIGNALS: + void fromXChanged(); + void fromYChanged(); + void toXChanged(); + void toYChanged(); + void fromXTypeChanged(); + void fromYTypeChanged(); + void toXTypeChanged(); + void toYTypeChanged(); + +protected: + QAndroidJniObject onCreate() override; + +private: + qreal m_fromX; + qreal m_fromY; + qreal m_toX; + qreal m_toY; + Relation m_fromXType; + Relation m_fromYType; + Relation m_toXType; + Relation m_toYType; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDTRANSLATEANIMATION_P_H diff --git a/src/android/view/qqmlandroidgravity_p.h b/src/android/view/qqmlandroidgravity_p.h new file mode 100644 index 0000000..331e7e4 --- /dev/null +++ b/src/android/view/qqmlandroidgravity_p.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDGRAVITY_P_H +#define QQMLANDROIDGRAVITY_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidGravity : public QObject +{ + Q_OBJECT + Q_FLAGS(Flags) + +public: + enum Flag { + NO_GRAVITY = 0x0000, + AXIS_SPECIFIED = 0x0001, + AXIS_PULL_BEFORE = 0x0002, + AXIS_PULL_AFTER = 0x0004, + AXIS_CLIP = 0x0008, + AXIS_X_SHIFT = 0, + AXIS_Y_SHIFT = 4, + TOP = (AXIS_PULL_BEFORE|AXIS_SPECIFIED)<setLayoutParams(this); +} + +QQmlAndroidLayoutParams *QQmlAndroidLayoutParams::qmlAttachedProperties(QObject *object) +{ + QQmlAndroidView *view = qobject_cast(object); + if (view) + return new QQmlAndroidLayoutParams(view); + return 0; +} + +int QQmlAndroidLayoutParams::width() const +{ + if (m_width.isNull()) + return MATCH_PARENT; + return m_width; +} + +void QQmlAndroidLayoutParams::setWidth(int value) +{ + if (value != width()) { + m_width = value; + invalidate(); + emit widthChanged(); + } +} + +int QQmlAndroidLayoutParams::height() const +{ + if (m_height.isNull()) + return MATCH_PARENT; + return m_height; +} + +void QQmlAndroidLayoutParams::setHeight(int value) +{ + if (value != height()) { + m_height = value; + invalidate(); + emit heightChanged(); + } +} + +void QQmlAndroidLayoutParams::invalidate() +{ + if (!m_dirty && isValid()) { + m_dirty = true; + QCoreApplication::postEvent(this, new QEvent(QEvent::LayoutRequest)); + } +} + +QAndroidJniObject QQmlAndroidLayoutParams::onCreate() +{ + return QAndroidJniObject("android/view/ViewGroup$LayoutParams", + "(II)V", + MATCH_PARENT, MATCH_PARENT); +} + +void QQmlAndroidLayoutParams::onInflate(QAndroidJniObject &instance) +{ + if (!m_width.isNull()) + instance.setField("width", m_width); + if (!m_height.isNull()) + instance.setField("height", m_height); +} + +bool QQmlAndroidLayoutParams::event(QEvent *event) +{ + if (event->type() == QEvent::LayoutRequest) { + if (m_dirty && isValid()) { + construct(); + m_dirty = false; + } + } + return QQmlAndroidObject::event(event); +} + +QT_END_NAMESPACE diff --git a/src/android/view/qqmlandroidlayoutparams_p.h b/src/android/view/qqmlandroidlayoutparams_p.h new file mode 100644 index 0000000..3c87699 --- /dev/null +++ b/src/android/view/qqmlandroidlayoutparams_p.h @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDLAYOUTPARAMS_P_H +#define QQMLANDROIDLAYOUTPARAMS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QQmlAndroidView; + +class Q_QMLANDROID_EXPORT QQmlAndroidLayoutParams : public QQmlAndroidObject +{ + Q_OBJECT + Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) + Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) + Q_ENUMS(Size) + +public: + explicit QQmlAndroidLayoutParams(QQmlAndroidView *view); + + static QQmlAndroidLayoutParams *qmlAttachedProperties(QObject *object); + + enum Size { + FILL_PARENT = -1, + MATCH_PARENT = -1, + WRAP_CONTENT = -2 + }; + + int width() const; + void setWidth(int width); + + int height() const; + void setHeight(int height); + +public Q_SLOTS: + void invalidate(); + +Q_SIGNALS: + void widthChanged(); + void heightChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + + bool event(QEvent *event) override; + +private: + bool m_dirty; + QQmlAndroidView *m_view; + QQmlAndroidOptional m_width; + QQmlAndroidOptional m_height; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPEINFO(QQmlAndroidLayoutParams, QML_HAS_ATTACHED_PROPERTIES) + +#endif // QQMLANDROIDLAYOUTPARAMS_P_H diff --git a/src/android/view/qqmlandroidmenu.cpp b/src/android/view/qqmlandroidmenu.cpp new file mode 100644 index 0000000..a571cde --- /dev/null +++ b/src/android/view/qqmlandroidmenu.cpp @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidmenu_p.h" +#include "qqmlandroidmenuitem_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidMenu::QQmlAndroidMenu(QObject *parent) : + QQmlAndroidContextual(parent) +{ +} + +QList QQmlAndroidMenu::items() const +{ + QList lst; + foreach (QObject *child, children()) { + QQmlAndroidMenuItem *item = qobject_cast(child); + if (item) + lst += item; + } + return lst; +} + +QAndroidJniObject QQmlAndroidMenu::onCreate() +{ + return QAndroidJniObject("qt/android/view/QmlMenu"); +} + +void QQmlAndroidMenu::onInflate(QAndroidJniObject &instance) +{ + foreach (QQmlAndroidMenuItem *item, items()) { + item->construct(); + if (item->isValid()) + instance.callMethod("add", "(Lqt/android/view/QmlMenuItem;)V", item->instance().object()); + } +} + +QT_END_NAMESPACE diff --git a/src/android/view/qqmlandroidmenu_p.h b/src/android/view/qqmlandroidmenu_p.h new file mode 100644 index 0000000..5e4a087 --- /dev/null +++ b/src/android/view/qqmlandroidmenu_p.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDMENU_P_H +#define QQMLANDROIDMENU_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QQmlAndroidMenuItem; + +class Q_QMLANDROID_EXPORT QQmlAndroidMenu : public QQmlAndroidContextual +{ + Q_OBJECT + +public: + explicit QQmlAndroidMenu(QObject *parent = nullptr); + + QList items() const; + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDMENU_P_H diff --git a/src/android/view/qqmlandroidmenuitem.cpp b/src/android/view/qqmlandroidmenuitem.cpp new file mode 100644 index 0000000..5982073 --- /dev/null +++ b/src/android/view/qqmlandroidmenuitem.cpp @@ -0,0 +1,251 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidmenuitem_p.h" +#include "qtqmlandroidfunctions_p.h" +#include "qqmlandroidcontext_p.h" +#include "qqmlandroidview_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidMenuItem::QQmlAndroidMenuItem(QObject *parent) : + QQmlAndroidContextual(parent), m_enabled(true), m_visible(true), + m_checkable(false), m_checked(false), + m_showAs(0), // TODO: SHOW_AS_ACTION_NEVER + m_actionView(0) +{ +} + +QString QQmlAndroidMenuItem::title() const +{ + return m_title; +} + +void QQmlAndroidMenuItem::setTitle(const QString &title) +{ + if (m_title != title) { + m_title = title; + QtQmlAndroid::callTextMethod(instance(), "setTitle", title); + emit titleChanged(); + } +} + +bool QQmlAndroidMenuItem::isEnabled() const +{ + return m_enabled; +} + +void QQmlAndroidMenuItem::setEnabled(bool enabled) +{ + if (m_enabled != enabled) { + m_enabled = enabled; + QtQmlAndroid::callBoolMethod(instance(), "setEnabled", enabled); + emit enabledChanged(); + } +} + +bool QQmlAndroidMenuItem::isVisible() const +{ + return m_visible; +} + +void QQmlAndroidMenuItem::setVisible(bool visible) +{ + if (m_visible != visible) { + m_visible = visible; + QtQmlAndroid::callBoolMethod(instance(), "setVisible", visible); + if (isValid() && context()) + QMetaObject::invokeMethod(context(), "invalidateOptionsMenu"); + emit visibleChanged(); + } +} + +bool QQmlAndroidMenuItem::isCheckable() const +{ + return m_checkable; +} + +void QQmlAndroidMenuItem::setCheckable(bool checkable) +{ + if (m_checkable != checkable) { + m_checkable = checkable; + QtQmlAndroid::callBoolMethod(instance(), "setCheckable", checkable); + emit checkableChanged(); + } +} + +bool QQmlAndroidMenuItem::isChecked() const +{ + return m_checked; +} + +void QQmlAndroidMenuItem::setChecked(bool checked) +{ + if (m_checked != checked) { + m_checked = checked; + QtQmlAndroid::callBoolMethod(instance(), "setChecked", checked); + emit checkedChanged(); + } +} + +int QQmlAndroidMenuItem::showAs() const +{ + return m_showAs; +} + +void QQmlAndroidMenuItem::setShowAs(int showAs) +{ + if (m_showAs != showAs) { + m_showAs = showAs; + QtQmlAndroid::callIntMethod(instance(), "setShowAs", showAs); + emit showAsChanged(); + } +} + +QQmlAndroidView *QQmlAndroidMenuItem::actionView() const +{ + return m_actionView; +} + +void QQmlAndroidMenuItem::setActionView(QQmlAndroidView *view) +{ + if (m_actionView != view) { + if (m_actionView) { + disconnect(m_actionView, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidMenuItem::updateActionView); + m_actionView->destruct(); + } + m_actionView = view; + if (m_actionView) { + connect(m_actionView, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidMenuItem::updateActionView); + if (isValid()) + m_actionView->construct(); + } + emit actionViewChanged(); + } +} + +QAndroidJniObject QQmlAndroidMenuItem::onCreate() +{ + return QAndroidJniObject("qt/android/view/QmlMenuItem", + "(J)V", + reinterpret_cast(this)); +} + +void QQmlAndroidMenuItem::onInflate(QAndroidJniObject &instance) +{ + instance.callMethod("setTitle", "(Ljava/lang/CharSequence;)V", QAndroidJniObject::fromString(m_title).object()); + instance.callMethod("setEnabled", "(Z)V", m_enabled); + instance.callMethod("setVisible", "(Z)V", m_visible); + instance.callMethod("setCheckable", "(Z)V", m_checkable); + instance.callMethod("setChecked", "(Z)V", m_enabled); + instance.callMethod("setShowAs", "(I)V", m_showAs); + + static bool nativeMethodsRegistered = false; + if (!nativeMethodsRegistered) { + onRegisterNativeMethods(instance.object()); + nativeMethodsRegistered = true; + } +} + +void QQmlAndroidMenuItem::onRegisterNativeMethods(jobject item) +{ + JNINativeMethod methods[] {{"onClick", "(J)Z", reinterpret_cast(onClick)}, + {"onMenuItemActionCollapse", "(J)Z", reinterpret_cast(onMenuItemActionCollapse)}, + {"onMenuItemActionExpand", "(J)Z", reinterpret_cast(onMenuItemActionExpand)}}; + + QAndroidJniEnvironment env; + jclass cls = env->GetObjectClass(item); + env->RegisterNatives(cls, methods, sizeof(methods) / sizeof(methods[0])); + env->DeleteLocalRef(cls); +} + +bool QQmlAndroidMenuItem::onClick(JNIEnv *env, jobject object, jlong instance) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidMenuItem *item = reinterpret_cast(instance); + if (item) { + QMetaObject::invokeMethod(item, "click", Qt::QueuedConnection); + return true; + } + return false; +} + +bool QQmlAndroidMenuItem::onMenuItemActionCollapse(JNIEnv *env, jobject object, jlong instance) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidMenuItem *item = reinterpret_cast(instance); + if (item) { + // TODO + return true; + } + return false; +} + +bool QQmlAndroidMenuItem::onMenuItemActionExpand(JNIEnv *env, jobject object, jlong instance) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidMenuItem *item = reinterpret_cast(instance); + if (item) { + // TODO + return true; + } + return false; + +} + +void QQmlAndroidMenuItem::objectChange(ObjectChange change) +{ + QQmlAndroidContextual::objectChange(change); + if (change == InstanceChange) + updateActionView(); +} + +void QQmlAndroidMenuItem::updateActionView() +{ + if (!isValid() || !m_actionView) + return; + + QAndroidJniObject item = instance(); + QAndroidJniObject view = m_actionView->instance(); + QtQmlAndroid::callFunction([=]() { + item.callMethod("setActionView", "(Landroid/view/View;)V", view.object()); + }); +} + +QT_END_NAMESPACE diff --git a/src/android/view/qqmlandroidmenuitem_p.h b/src/android/view/qqmlandroidmenuitem_p.h new file mode 100644 index 0000000..b3c9be2 --- /dev/null +++ b/src/android/view/qqmlandroidmenuitem_p.h @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDMENUITEM_P_H +#define QQMLANDROIDMENUITEM_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QQmlAndroidView; + +class Q_QMLANDROID_EXPORT QQmlAndroidMenuItem : public QQmlAndroidContextual +{ + Q_OBJECT + Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged) + Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged) + Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged) + Q_PROPERTY(int showAs READ showAs WRITE setShowAs NOTIFY showAsChanged) + Q_PROPERTY(QQmlAndroidView *actionView READ actionView WRITE setActionView NOTIFY actionViewChanged) + Q_ENUMS(ShowAs) + +public: + explicit QQmlAndroidMenuItem(QObject *parent = nullptr); + + QString title() const; + void setTitle(const QString &title); + + bool isEnabled() const; + void setEnabled(bool enabled); + + bool isVisible() const; + void setVisible(bool visible); + + bool isCheckable() const; + void setCheckable(bool checkable); + + bool isChecked() const; + void setChecked(bool checked); + + enum ShowAs { + SHOW_AS_ACTION_NEVER = 0, + SHOW_AS_ACTION_IF_ROOM = 1, + SHOW_AS_ACTION_ALWAYS = 2, + SHOW_AS_ACTION_WITH_TEXT = 4, + SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW = 8 + }; + + int showAs() const; + void setShowAs(int showAs); + + QQmlAndroidView *actionView() const; + void setActionView(QQmlAndroidView *view); + +Q_SIGNALS: + void click(); + void titleChanged(); + void enabledChanged(); + void visibleChanged(); + void checkableChanged(); + void checkedChanged(); + void showAsChanged(); + void actionViewChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + + static void onRegisterNativeMethods(jobject item); + static bool onClick(JNIEnv *env, jobject object, jlong instance); + static bool onMenuItemActionCollapse(JNIEnv *env, jobject object, jlong instance); + static bool onMenuItemActionExpand(JNIEnv *env, jobject object, jlong instance); + + void objectChange(ObjectChange change) override; + +private Q_SLOTS: + void updateActionView(); + +private: + QString m_title; + bool m_enabled; + bool m_visible; + bool m_checkable; + bool m_checked; + int m_showAs; + QQmlAndroidView *m_actionView; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDMENUITEM_P_H diff --git a/src/android/view/qqmlandroidview.cpp b/src/android/view/qqmlandroidview.cpp new file mode 100644 index 0000000..23e8e46 --- /dev/null +++ b/src/android/view/qqmlandroidview.cpp @@ -0,0 +1,898 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidview_p.h" +#include "qqmlandroiddrawable_p.h" +#include "qqmlandroidcolordrawable_p.h" +#include "qqmlandroidlayoutparams_p.h" +#include "qqmlandroidanimation_p.h" +#include "qtqmlandroidfunctions_p.h" +#include +#include +#include + +QT_BEGIN_NAMESPACE + +QQmlAndroidView::QQmlAndroidView(QQmlAndroidView *parent) : + QQmlAndroidContextual(parent), m_parent(0), m_background(0), m_backgroundResource(0), + m_animation(0), m_polishing(false), m_visible(true), m_layoutParams(0), + m_top(0), m_left(0), m_right(0), m_bottom(0) +{ + static int id = 0; + m_id = ++id; + + if (parent) + setParentView(parent); + + // TODO: find a better place for this (upon construction of the native control perhaps?) + requestPolish(); +} + +QQmlAndroidView::~QQmlAndroidView() +{ + foreach (QQmlAndroidView *child, m_children) + child->setParentView(0); + if (m_parent) + setParentView(0); +} + +int QQmlAndroidView::identifier() const +{ + return m_id; +} + +void QQmlAndroidView::setIdentifier(int identifier) +{ + m_id = identifier; +} + +QQmlAndroidView *QQmlAndroidView::parentView() const +{ + return m_parent; +} + +void QQmlAndroidView::setParentView(QQmlAndroidView *parent) +{ + if (m_parent != parent) { + if (m_parent) + m_parent->removeChild(this); + m_parent = parent; + viewChange(ViewParentChange, parent); + if (parent) + parent->addChild(this); + emit parentChanged(); + } +} + +QList QQmlAndroidView::childViews() const +{ + return m_children; +} + +QQmlListProperty QQmlAndroidView::children() +{ + return QQmlListProperty(this, 0, &QQmlAndroidView::children_append, &QQmlAndroidView::children_count, + &QQmlAndroidView::children_at, &QQmlAndroidView::children_clear); +} + +QQmlAndroidLayoutParams *QQmlAndroidView::layoutParams() const +{ + return m_layoutParams; +} + +void QQmlAndroidView::setLayoutParams(QQmlAndroidLayoutParams *params) +{ + if (m_layoutParams != params) { + if (m_layoutParams) { + disconnect(m_layoutParams, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidView::updateLayoutParams); + m_layoutParams->destruct(); + } + m_layoutParams = params; + if (m_layoutParams) { + connect(m_layoutParams, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidView::updateLayoutParams); + if (isValid()) + m_layoutParams->construct(); + } + } +} + +QQmlAndroidDrawable *QQmlAndroidView::background() const +{ + return m_background; +} + +void QQmlAndroidView::setBackground(QQmlAndroidDrawable *background, int resource) +{ + if (m_background != background) { + if (m_background) { + disconnect(m_background, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidView::updateBackground); + m_background->destruct(); + } + m_background = background; + m_backgroundResource = resource; + if (m_background) { + connect(m_background, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidView::updateBackground); + if (!resource) + m_background->construct(); + } + emit backgroundChanged(); + } +} + +QQmlAndroidAnimation *QQmlAndroidView::animation() const +{ + return m_animation; +} + +void QQmlAndroidView::setAnimation(QQmlAndroidAnimation *animation) +{ + if (m_animation != animation) { + if (m_animation) { + disconnect(m_animation, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidView::updateAnimation); + m_animation->destruct(); + } + m_animation = animation; + if (m_animation) { + connect(m_animation, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidView::updateAnimation); + if (isValid()) + m_animation->construct(); + } + emit animationChanged(); + } +} + +int QQmlAndroidView::backgroundColor() const +{ + QQmlAndroidColorDrawable *drawable = qobject_cast(m_background); + if (drawable) + return drawable->color(); + return 0; // TODO +} + +void QQmlAndroidView::setBackgroundColor(int color) +{ + setBackground(new QQmlAndroidColorDrawable(color, this)); +} + +int QQmlAndroidView::backgroundResource() const +{ + return m_backgroundResource; +} + +void QQmlAndroidView::setBackgroundResource(int resource) +{ + if (m_backgroundResource != resource) { + setBackground(new QQmlAndroidDrawable(this), resource); + emit backgroundResourceChanged(); + } +} + +bool QQmlAndroidView::isVisible() const +{ + return m_visible; +} + +void QQmlAndroidView::setVisible(bool visible) +{ + if (m_visible != visible) { + m_visible = visible; + // TODO: VISIBLE(0), INVISIBLE(4), GONE(8) + QtQmlAndroid::callIntMethod(instance(), "setVisibility", visible ? 0 : 4); + emit visibleChanged(); + } +} + +bool QQmlAndroidView::hasFocus() const +{ + if (m_focus.isNull()) + return false; + return m_focus; +} + +bool QQmlAndroidView::updateFocus(bool arg) +{ + if (arg != hasFocus()) { + m_focus = arg; + emit focusChanged(); + return true; + } + return false; +} + +qreal QQmlAndroidView::x() const +{ + return left() + translationX(); +} + +void QQmlAndroidView::setX(qreal x) +{ + setTranslationX(x - left()); +} + +qreal QQmlAndroidView::y() const +{ + return top() + translationY(); +} + +void QQmlAndroidView::setY(qreal y) +{ + setTranslationY(y - top()); +} + +qreal QQmlAndroidView::z() const +{ + return elevation() + translationZ(); +} + +void QQmlAndroidView::setZ(qreal z) +{ + setTranslationZ(z - elevation()); +} + +int QQmlAndroidView::top() const +{ + if (m_top.isNull()) + return 0; + return m_top; +} + +void QQmlAndroidView::setTop(int top) +{ + if (m_top.isNull() || m_top != top) { + m_top = top; + QtQmlAndroid::callIntMethod(instance(), "setTop", top); + emit topChanged(); + emit yChanged(); + } +} + +int QQmlAndroidView::left() const +{ + if (m_left.isNull()) + return 0; + return m_left; +} + +void QQmlAndroidView::setLeft(int left) +{ + if (m_left.isNull() || m_left != left) { + m_left = left; + QtQmlAndroid::callIntMethod(instance(), "setLeft", left); + emit leftChanged(); + emit xChanged(); + } +} + +int QQmlAndroidView::right() const +{ + if (m_right.isNull()) + return 0; + return m_right; +} + +void QQmlAndroidView::setRight(int right) +{ + if (m_right.isNull() || m_right != right) { + m_right = right; + QtQmlAndroid::callIntMethod(instance(), "setRight", right); + emit rightChanged(); + } +} + +int QQmlAndroidView::bottom() const +{ + if (m_bottom.isNull()) + return 0; + return m_bottom; +} + +void QQmlAndroidView::setBottom(int bottom) +{ + if (m_bottom.isNull() || m_bottom != bottom) { + m_bottom = bottom; + QtQmlAndroid::callIntMethod(instance(), "setBottom", bottom); + emit bottomChanged(); + } +} + +int QQmlAndroidView::width() const +{ + return right() - left(); +} + +void QQmlAndroidView::setWidth(int width) +{ + setRight(left() + width); +} + +int QQmlAndroidView::height() const +{ + return bottom() - top(); +} + +void QQmlAndroidView::setHeight(int height) +{ + setBottom(top() + height); +} + +void QQmlAndroidView::updateGeometry(int t, int l, int r, int b) +{ + if (t != top()) { + m_top = t; + emit topChanged(); + emit yChanged(); + } + if (l != left()) { + m_left = l; + emit leftChanged(); + emit xChanged(); + } + if (r != right()) { + m_right = r; + emit rightChanged(); + emit widthChanged(); + } + if (b != bottom()) { + m_bottom = b; + emit bottomChanged(); + emit heightChanged(); + } +} + +int QQmlAndroidView::padding() const +{ + if (!m_padding.isNull()) + return m_padding; + return 0; +} + +void QQmlAndroidView::setPadding(int padding) +{ + if (m_padding.isNull() || m_padding != padding) { + m_padding = padding; + emit paddingChanged(); + } +} + +int QQmlAndroidView::paddingTop() const +{ + if (m_paddingTop.isNull()) + return padding(); + return m_paddingTop; +} + +void QQmlAndroidView::setPaddingTop(int padding) +{ + if (m_paddingTop.isNull() || m_paddingTop != padding) { + m_paddingTop = padding; + emit paddingTopChanged(); + } +} + +int QQmlAndroidView::paddingLeft() const +{ + if (m_paddingLeft.isNull()) + return padding(); + return m_paddingLeft; +} + +void QQmlAndroidView::setPaddingLeft(int padding) +{ + if (m_paddingLeft.isNull() || m_paddingLeft != padding) { + m_paddingLeft = padding; + emit paddingLeftChanged(); + } +} + +int QQmlAndroidView::paddingRight() const +{ + if (m_paddingRight.isNull()) + return padding(); + return m_paddingRight; +} + +void QQmlAndroidView::setPaddingRight(int padding) +{ + if (m_paddingRight.isNull() || m_paddingRight != padding) { + m_paddingRight = padding; + emit paddingRightChanged(); + } +} + +int QQmlAndroidView::paddingBottom() const +{ + if (m_paddingBottom.isNull()) + return padding(); + return m_paddingBottom; +} + +void QQmlAndroidView::setPaddingBottom(int padding) +{ + if (m_paddingBottom.isNull() || m_paddingBottom != padding) { + m_paddingBottom = padding; + emit paddingBottomChanged(); + } +} + +qreal QQmlAndroidView::alpha() const +{ + if (!m_alpha.isNull()) + return m_alpha; + return 0; +} + +void QQmlAndroidView::setAlpha(qreal alpha) +{ + if (m_alpha.isNull() || m_alpha != alpha) { + m_alpha = alpha; + QtQmlAndroid::callRealMethod(instance(), "setAlpha", alpha); + emit alphaChanged(); + } +} + +qreal QQmlAndroidView::scaleX() const +{ + if (!m_scaleX.isNull()) + return m_scaleX; + return 0; +} + +void QQmlAndroidView::setScaleX(qreal scaleX) +{ + if (m_scaleX.isNull() || m_scaleX != scaleX) { + m_scaleX = scaleX; + QtQmlAndroid::callRealMethod(instance(), "setScaleX", scaleX); + emit scaleXChanged(); + } +} + +qreal QQmlAndroidView::scaleY() const +{ + if (!m_scaleY.isNull()) + return m_scaleY; + return 0; +} + +void QQmlAndroidView::setScaleY(qreal scaleY) +{ + if (m_scaleY.isNull() || m_scaleY != scaleY) { + m_scaleY = scaleY; + QtQmlAndroid::callRealMethod(instance(), "setScaleY", scaleY); + emit scaleYChanged(); + } +} + +qreal QQmlAndroidView::pivotX() const +{ + if (!m_pivotX.isNull()) + return m_pivotX; + return 0; +} + +void QQmlAndroidView::setPivotX(qreal pivotX) +{ + if (m_pivotX.isNull() || m_pivotX != pivotX) { + m_pivotX = pivotX; + QtQmlAndroid::callRealMethod(instance(), "setPivotX", pivotX); + emit pivotXChanged(); + } +} + +qreal QQmlAndroidView::pivotY() const +{ + if (!m_pivotY.isNull()) + return m_pivotY; + return 0; +} + +void QQmlAndroidView::setPivotY(qreal pivotY) +{ + if (m_pivotY.isNull() || m_pivotY != pivotY) { + m_pivotY = pivotY; + QtQmlAndroid::callRealMethod(instance(), "setPivotY", pivotY); + emit pivotYChanged(); + } +} + +qreal QQmlAndroidView::rotation() const +{ + if (!m_rotation.isNull()) + return m_rotation; + return 0; +} + +void QQmlAndroidView::setRotation(qreal rotation) +{ + if (m_rotation.isNull() || m_rotation != rotation) { + m_rotation = rotation; + QtQmlAndroid::callRealMethod(instance(), "setRotation", rotation); + emit rotationChanged(); + } +} + +qreal QQmlAndroidView::rotationX() const +{ + if (!m_rotationX.isNull()) + return m_rotationX; + return 0; +} + +void QQmlAndroidView::setRotationX(qreal rotationX) +{ + if (m_rotationX.isNull() || m_rotationX != rotationX) { + m_rotationX = rotationX; + QtQmlAndroid::callRealMethod(instance(), "setRotationX", rotationX); + emit rotationXChanged(); + } +} + +qreal QQmlAndroidView::rotationY() const +{ + if (!m_rotationY.isNull()) + return m_rotationY; + return 0; +} + +void QQmlAndroidView::setRotationY(qreal rotationY) +{ + if (m_rotationY.isNull() || m_rotationY != rotationY) { + m_rotationY = rotationY; + QtQmlAndroid::callRealMethod(instance(), "setRotationY", rotationY); + emit rotationYChanged(); + } +} + +qreal QQmlAndroidView::translationX() const +{ + if (!m_translationX.isNull()) + return m_translationX; + return 0; +} + +void QQmlAndroidView::setTranslationX(qreal translationX) +{ + if (m_translationX.isNull() || m_translationX != translationX) { + m_translationX = translationX; + QtQmlAndroid::callRealMethod(instance(), "setTranslationX", translationX); + emit translationXChanged(); + emit xChanged(); + } +} + +qreal QQmlAndroidView::translationY() const +{ + if (!m_translationY.isNull()) + return m_translationY; + return 0; +} + +void QQmlAndroidView::setTranslationY(qreal translationY) +{ + if (m_translationY.isNull() || m_translationY != translationY) { + m_translationY = translationY; + QtQmlAndroid::callRealMethod(instance(), "setTranslationY", translationY); + emit translationYChanged(); + emit yChanged(); + } +} + +qreal QQmlAndroidView::translationZ() const +{ + if (!m_translationZ.isNull()) + return m_translationZ; + return 0; +} + +void QQmlAndroidView::setTranslationZ(qreal translationZ) +{ + if (m_translationZ.isNull() || m_translationZ != translationZ) { + m_translationZ = translationZ; + QtQmlAndroid::callRealMethod(instance(), "setTranslationZ", translationZ); + emit translationZChanged(); + emit zChanged(); + } +} + +qreal QQmlAndroidView::elevation() const +{ + if (!m_elevation.isNull()) + return m_elevation; + return 0; +} + +void QQmlAndroidView::setElevation(qreal elevation) +{ + if (m_elevation.isNull() || m_elevation != elevation) { + m_elevation = elevation; + QtQmlAndroid::callRealMethod(instance(), "setElevation", elevation); + emit elevationChanged(); + emit zChanged(); + } +} + +void QQmlAndroidView::viewChange(ViewChange change, const ViewChangeData &data) +{ + switch (change) { + case ViewParentChange: // data.view + case ViewChildAddedChange: // data.view + case ViewChildRemovedChange: // data.view + case ViewVisibilityChange: // data.boolean + default: + break; + } +} + +void QQmlAndroidView::addChild(QQmlAndroidView *child) +{ + if (!m_children.contains(child)) { + m_children.append(child); + viewChange(ViewChildAddedChange, child); + emit childrenChanged(); + } +} + +void QQmlAndroidView::removeChild(QQmlAndroidView *child) +{ + if (m_children.removeOne(child)) { + viewChange(ViewChildRemovedChange, child); + emit childrenChanged(); + } +} + +void QQmlAndroidView::children_append(QQmlListProperty *list, QQmlAndroidView *child) +{ + if (QQmlAndroidView *that = qobject_cast(list->object)) + that->addChild(child); +} + +int QQmlAndroidView::children_count(QQmlListProperty *list) +{ + if (QQmlAndroidView *that = qobject_cast(list->object)) + return that->m_children.count(); + return 0; +} + +QQmlAndroidView *QQmlAndroidView::children_at(QQmlListProperty *list, int index) +{ + if (QQmlAndroidView *that = qobject_cast(list->object)) + return that->m_children.at(index); + return 0; +} + +void QQmlAndroidView::children_clear(QQmlListProperty *list) +{ + if (QQmlAndroidView *that = qobject_cast(list->object)) { + while (!that->m_children.isEmpty()) + that->m_children.first()->setParentView(0); + } +} + +QAndroidJniObject QQmlAndroidView::onCreate() +{ + Q_ASSERT(!QtQmlAndroid::isMainQtThread()); + + return QAndroidJniObject("android/view/View", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidView::onInflate(QAndroidJniObject &instance) +{ + Q_ASSERT(!QtQmlAndroid::isMainQtThread()); + + QQmlAndroidContextual::onInflate(instance); + + m_listener = QAndroidJniObject("qt/android/view/QmlViewListener", + "(Landroid/view/View;J)V", + instance.object(), + reinterpret_cast(this)); + + instance.callMethod("setId", "(I)V", m_id); + + static bool nativeMethodsRegistered = false; + if (!nativeMethodsRegistered) { + onRegisterNativeMethods(m_listener.object()); + nativeMethodsRegistered = true; + } + + // TODO: VISIBLE(0), INVISIBLE(4), GONE(8) + instance.callMethod("setVisibility", "(I)V", m_visible ? 0 : 4); + if (!m_padding.isNull() || !m_paddingTop.isNull() || !m_paddingLeft.isNull() || !m_paddingRight.isNull() || !m_paddingBottom.isNull()) + instance.callMethod("setPadding", "(IIII)V", paddingLeft(), paddingTop(), paddingRight(), paddingBottom()); + if (!m_top.isNull()) + instance.callMethod("setTop", "(I)V", m_top); + if (!m_left.isNull()) + instance.callMethod("setLeft", "(I)V", m_left); + if (!m_right.isNull()) + instance.callMethod("setRight", "(I)V", m_right); + if (!m_bottom.isNull()) + instance.callMethod("setBottom", "(I)V", m_bottom); + if (!m_alpha.isNull()) + instance.callMethod("setAlpha", "(F)V", m_alpha); + if (!m_scaleX.isNull()) + instance.callMethod("setScaleX", "(F)V", m_scaleX); + if (!m_scaleY.isNull()) + instance.callMethod("setScaleY", "(F)V", m_scaleY); + if (!m_pivotX.isNull()) + instance.callMethod("setPivotX", "(F)V", m_pivotX); + if (!m_pivotY.isNull()) + instance.callMethod("setPivotY", "(F)V", m_pivotY); + if (!m_rotation.isNull()) + instance.callMethod("setRotation", "(F)V", m_rotation); + if (!m_rotationX.isNull()) + instance.callMethod("setRotationX", "(F)V", m_rotationX); + if (!m_rotationY.isNull()) + instance.callMethod("setRotationY", "(F)V", m_rotationY); + if (!m_translationX.isNull()) + instance.callMethod("setTranslationX", "(F)V", m_translationX); + if (!m_translationY.isNull()) + instance.callMethod("setTranslationY", "(F)V", m_translationY); + if (!m_translationZ.isNull()) + instance.callMethod("setTranslationZ", "(F)V", m_translationZ); + if (!m_elevation.isNull()) + instance.callMethod("setElevation", "(F)V", m_elevation); + + if (m_backgroundResource != 0) { + QAndroidJniObject background = ctx().callObjectMethod("getDrawable", "(I)Landroid/graphics/drawable/Drawable;", m_backgroundResource); + m_background->inflate(background); + } +} + +void QQmlAndroidView::onRegisterNativeMethods(jobject listener) +{ + JNINativeMethod methods[] {{"onClick", "(J)V", reinterpret_cast(onClick)}, + {"onFocusChange", "(JZ)V", reinterpret_cast(onFocusChange)}, + {"onLayoutChange", "(JIIII)V", reinterpret_cast(onLayoutChange)} + /*{"onLongClick", "(J)V", reinterpret_cast(onLongClick)}*/}; + + QAndroidJniEnvironment env; + jclass cls = env->GetObjectClass(listener); + env->RegisterNatives(cls, methods, sizeof(methods) / sizeof(methods[0])); + env->DeleteLocalRef(cls); +} + +void QQmlAndroidView::onClick(JNIEnv *env, jobject object, jlong instance) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidView *view = reinterpret_cast(instance); + if (view) + QMetaObject::invokeMethod(view, "click", Qt::QueuedConnection); +} + +void QQmlAndroidView::onFocusChange(JNIEnv *env, jobject object, jlong instance, jboolean hasFocus) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidView *view = reinterpret_cast(instance); + if (view) + QMetaObject::invokeMethod(view, "updateFocus", Qt::QueuedConnection, Q_ARG(bool, hasFocus)); +} + +void QQmlAndroidView::onLayoutChange(JNIEnv *env, jobject object, jlong instance, jint left, jint top, jint right, jint bottom) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidView *view = reinterpret_cast(instance); + if (view) + QMetaObject::invokeMethod(view, "updateGeometry", Qt::QueuedConnection, Q_ARG(int, top), Q_ARG(int, left), Q_ARG(int, right), Q_ARG(int, bottom)); +} + +bool QQmlAndroidView::onLongClick(JNIEnv *env, jobject object, jlong instance) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidView *view = reinterpret_cast(instance); + if (view) { + //qDebug() << "onLongClick:" << view; + QMetaObject::invokeMethod(view, "longClick", Qt::QueuedConnection); + } + return true; // TODO: accept +} + +void QQmlAndroidView::requestPolish() +{ + if (!m_polishing) { + m_polishing = true; + QCoreApplication::postEvent(this, new QEvent(QEvent::PolishRequest)); + } +} + +void QQmlAndroidView::polish() +{ +} + +bool QQmlAndroidView::event(QEvent *event) +{ + if (event->type() == QEvent::PolishRequest) { + QQmlAndroidView *view = qobject_cast(parent()); + if (view) + setParentView(view); + polish(); + m_polishing = false; + } + return QQmlAndroidContextual::event(event); +} + +void QQmlAndroidView::objectChange(ObjectChange change) +{ + QQmlAndroidContextual::objectChange(change); + if (change == InstanceChange) { + updateLayoutParams(); + updateBackground(); + updateAnimation(); + } +} + +void QQmlAndroidView::updateBackground() +{ + if (!isValid() || !m_background) + return; + + QAndroidJniObject view = instance(); + QAndroidJniObject background = m_background->instance(); + QtQmlAndroid::callFunction([=]() { + view.callMethod("setBackground", "(Landroid/graphics/drawable/Drawable;)V", background.object()); + }); +} + +void QQmlAndroidView::updateAnimation() +{ + if (!isValid() || !m_animation || !m_animation->isValid()) + return; + + QAndroidJniObject view = instance(); + QAndroidJniObject animation = m_animation->instance(); + QtQmlAndroid::callFunction([=]() { + view.callMethod("startAnimation", "(Landroid/view/animation/Animation;)V", animation.object()); + }); +} + +void QQmlAndroidView::updateLayoutParams() +{ + if (!isValid() || !m_layoutParams) + return; + + QAndroidJniObject view = instance(); + QAndroidJniObject params = m_layoutParams->instance(); + QtQmlAndroid::callFunction([=]() { + view.callMethod("setLayoutParams", + "(Landroid/view/ViewGroup$LayoutParams;)V", + params.object()); + }); +} + +QT_END_NAMESPACE diff --git a/src/android/view/qqmlandroidview_p.h b/src/android/view/qqmlandroidview_p.h new file mode 100644 index 0000000..5f4a3cb --- /dev/null +++ b/src/android/view/qqmlandroidview_p.h @@ -0,0 +1,346 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDVIEW_P_H +#define QQMLANDROIDVIEW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QQmlAndroidDrawable; +class QQmlAndroidAnimation; +class QQmlAndroidLayoutParams; + +class Q_QMLANDROID_EXPORT QQmlAndroidView : public QQmlAndroidContextual +{ + Q_OBJECT + Q_PROPERTY(QQmlAndroidView *parent READ parentView WRITE setParentView NOTIFY parentChanged) + Q_PROPERTY(QQmlListProperty children READ children NOTIFY childrenChanged) + + Q_PROPERTY(QQmlAndroidDrawable *background READ background WRITE setBackground NOTIFY backgroundChanged) + Q_PROPERTY(int backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged) + Q_PROPERTY(int backgroundResource READ backgroundResource WRITE setBackgroundResource NOTIFY backgroundResourceChanged) + + Q_PROPERTY(QQmlAndroidAnimation *animation READ animation WRITE setAnimation NOTIFY animationChanged) + + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(bool focus READ hasFocus NOTIFY focusChanged) + + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) + Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) + Q_PROPERTY(qreal z READ z WRITE setZ NOTIFY zChanged) + + Q_PROPERTY(int top READ top WRITE setTop NOTIFY topChanged) + Q_PROPERTY(int left READ left WRITE setLeft NOTIFY leftChanged) + Q_PROPERTY(int right READ right WRITE setRight NOTIFY rightChanged) + Q_PROPERTY(int bottom READ bottom WRITE setBottom NOTIFY bottomChanged) + Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) + Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) + + Q_PROPERTY(int padding READ padding WRITE setPadding NOTIFY paddingChanged) + Q_PROPERTY(int paddingTop READ paddingTop WRITE setPaddingTop NOTIFY paddingTopChanged) + Q_PROPERTY(int paddingLeft READ paddingLeft WRITE setPaddingLeft NOTIFY paddingLeftChanged) + Q_PROPERTY(int paddingRight READ paddingRight WRITE setPaddingRight NOTIFY paddingRightChanged) + Q_PROPERTY(int paddingBottom READ paddingBottom WRITE setPaddingBottom NOTIFY paddingBottomChanged) + + Q_PROPERTY(qreal alpha READ alpha WRITE setAlpha NOTIFY alphaChanged) + + Q_PROPERTY(qreal scaleX READ scaleX WRITE setScaleX NOTIFY scaleXChanged) + Q_PROPERTY(qreal scaleY READ scaleY WRITE setScaleY NOTIFY scaleYChanged) + Q_PROPERTY(qreal pivotX READ pivotX WRITE setPivotX NOTIFY pivotXChanged) + Q_PROPERTY(qreal pivotY READ pivotY WRITE setPivotY NOTIFY pivotYChanged) + Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) + Q_PROPERTY(qreal rotationX READ rotationX WRITE setRotationX NOTIFY rotationXChanged) + Q_PROPERTY(qreal rotationY READ rotationY WRITE setRotationY NOTIFY rotationYChanged) + Q_PROPERTY(qreal translationX READ translationX WRITE setTranslationX NOTIFY translationXChanged) + Q_PROPERTY(qreal translationY READ translationY WRITE setTranslationY NOTIFY translationYChanged) + Q_PROPERTY(qreal translationZ READ translationZ WRITE setTranslationZ NOTIFY translationZChanged) + +public: + explicit QQmlAndroidView(QQmlAndroidView *parent = nullptr); + ~QQmlAndroidView(); + + int identifier() const; + void setIdentifier(int id); + + QQmlAndroidView *parentView() const; + void setParentView(QQmlAndroidView *parent); + + QList childViews() const; + QQmlListProperty children(); + + QQmlAndroidLayoutParams *layoutParams() const; + void setLayoutParams(QQmlAndroidLayoutParams *params); + + QQmlAndroidDrawable *background() const; + void setBackground(QQmlAndroidDrawable *background, int resource = 0); + + int backgroundColor() const; + void setBackgroundColor(int color); + + int backgroundResource() const; + void setBackgroundResource(int resource); + + QQmlAndroidAnimation *animation() const; + void setAnimation(QQmlAndroidAnimation *animation); + + bool isVisible() const; + void setVisible(bool visible); + + bool hasFocus() const; + + qreal x() const; + void setX(qreal x); + + qreal y() const; + void setY(qreal y); + + qreal z() const; + void setZ(qreal z); + + int top() const; + void setTop(int top); + + int left() const; + void setLeft(int left); + + int right() const; + void setRight(int right); + + int bottom() const; + void setBottom(int bottom); + + int width() const; + void setWidth(int width); + + int height() const; + void setHeight(int height); + + int padding() const; + void setPadding(int padding); + + int paddingTop() const; + void setPaddingTop(int padding); + + int paddingLeft() const; + void setPaddingLeft(int padding); + + int paddingRight() const; + void setPaddingRight(int padding); + + int paddingBottom() const; + void setPaddingBottom(int padding); + + qreal alpha() const; + void setAlpha(qreal alpha); + + qreal scaleX() const; + void setScaleX(qreal scaleX); + + qreal scaleY() const; + void setScaleY(qreal scaleY); + + qreal pivotX() const; + void setPivotX(qreal pivotX); + + qreal pivotY() const; + void setPivotY(qreal pivotY); + + qreal rotation() const; + void setRotation(qreal rotation); + + qreal rotationX() const; + void setRotationX(qreal rotationY); + + qreal rotationY() const; + void setRotationY(qreal rotationY); + + qreal translationX() const; + void setTranslationX(qreal translationY); + + qreal translationY() const; + void setTranslationY(qreal translationY); + + qreal translationZ() const; + void setTranslationZ(qreal translationZ); + + qreal elevation() const; + void setElevation(qreal elevation); + + void requestPolish(); + + enum ViewChange { + ViewParentChange, // data.view + ViewChildAddedChange, // data.view + ViewChildRemovedChange, // data.view + ViewVisibilityChange, // data.boolean + }; + + union ViewChangeData { + ViewChangeData(QQmlAndroidView *v) : view(v) {} + ViewChangeData(qreal n) : number(n) {} + ViewChangeData(bool b) : boolean(b) {} + + QQmlAndroidView *view; + qreal number; + bool boolean; + }; + +Q_SIGNALS: + void parentChanged(); + void backgroundChanged(); + void backgroundColorChanged(); + void backgroundResourceChanged(); + void animationChanged(); + void childrenChanged(); + void visibleChanged(); + void focusChanged(); + void click(); + void xChanged(); + void yChanged(); + void zChanged(); + void topChanged(); + void leftChanged(); + void rightChanged(); + void bottomChanged(); + void widthChanged(); + void heightChanged(); + void paddingChanged(); + void paddingTopChanged(); + void paddingLeftChanged(); + void paddingRightChanged(); + void paddingBottomChanged(); + void alphaChanged(); + void scaleXChanged(); + void scaleYChanged(); + void pivotXChanged(); + void pivotYChanged(); + void rotationChanged(); + void rotationXChanged(); + void rotationYChanged(); + void translationXChanged(); + void translationYChanged(); + void translationZChanged(); + void elevationChanged(); + void longClick(); // TODO: accept + +protected: + virtual void polish(); + virtual void viewChange(ViewChange change, const ViewChangeData &data); + + void addChild(QQmlAndroidView *child); + void removeChild(QQmlAndroidView *child); + + static void children_append(QQmlListProperty *list, QQmlAndroidView *child); + static int children_count(QQmlListProperty *list); + static QQmlAndroidView *children_at(QQmlListProperty *list, int index); + static void children_clear(QQmlListProperty *list); + + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + + static void onRegisterNativeMethods(jobject listener); + static void onClick(JNIEnv *env, jobject object, jlong instance); + static void onFocusChange(JNIEnv *env, jobject object, jlong instance, jboolean hasFocus); + static void onLayoutChange(JNIEnv *env, jobject object, jlong instance, jint left, jint top, jint right, jint bottom); + static bool onLongClick(JNIEnv *env, jobject object, jlong instance); + + bool event(QEvent *event) override; + + void objectChange(ObjectChange change) override; + +private Q_SLOTS: + void updateBackground(); + void updateAnimation(); + bool updateFocus(bool focus); + void updateLayoutParams(); + void updateGeometry(int top, int left, int right, int bottom); + +private: + int m_id; + QQmlAndroidView *m_parent; + QList m_children; + QQmlAndroidDrawable *m_background; + int m_backgroundResource; + QQmlAndroidAnimation *m_animation; + bool m_polishing; + bool m_visible; + + QAndroidJniObject m_listener; + + QQmlAndroidLayoutParams *m_layoutParams; + + QQmlAndroidOptional m_focus; + QQmlAndroidOptional m_top; + QQmlAndroidOptional m_left; + QQmlAndroidOptional m_right; + QQmlAndroidOptional m_bottom; + QQmlAndroidOptional m_padding; + QQmlAndroidOptional m_paddingTop; + QQmlAndroidOptional m_paddingLeft; + QQmlAndroidOptional m_paddingRight; + QQmlAndroidOptional m_paddingBottom; + QQmlAndroidOptional m_alpha; + QQmlAndroidOptional m_scaleX; + QQmlAndroidOptional m_scaleY; + QQmlAndroidOptional m_pivotX; + QQmlAndroidOptional m_pivotY; + QQmlAndroidOptional m_rotation; + QQmlAndroidOptional m_rotationX; + QQmlAndroidOptional m_rotationY; + QQmlAndroidOptional m_translationX; + QQmlAndroidOptional m_translationY; + QQmlAndroidOptional m_translationZ; + QQmlAndroidOptional m_elevation; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDVIEW_P_H diff --git a/src/android/view/qqmlandroidviewgroup.cpp b/src/android/view/qqmlandroidviewgroup.cpp new file mode 100644 index 0000000..60defbe --- /dev/null +++ b/src/android/view/qqmlandroidviewgroup.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidviewgroup_p.h" +#include "qqmlandroidlayoutparams_p.h" +#include "qtqmlandroidfunctions_p.h" +#include "qqmlandroidcontext_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidViewGroup::QQmlAndroidViewGroup(QQmlAndroidView *parent) : + QQmlAndroidView(parent) +{ +} + +QQmlAndroidLayoutParams *QQmlAndroidViewGroup::qmlAttachedProperties(QObject *object) +{ + QQmlAndroidView *view = qobject_cast(object); + if (view) + return new QQmlAndroidLayoutParams(view); + return 0; +} + +QAndroidJniObject QQmlAndroidViewGroup::onCreate() +{ + return QAndroidJniObject("android/view/ViewGroup", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidViewGroup::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidView::onInflate(instance); + + foreach (QQmlAndroidView *child, childViews()) + instance.callMethod("addView", "(Landroid/view/View;)V", child->instance().object()); +} + +void QQmlAndroidViewGroup::viewChange(ViewChange change, const ViewChangeData &data) +{ + QAndroidJniObject group = instance(); + switch (change) { + case ViewChildAddedChange: // data.view + if (group.isValid()) { +// QtQmlAndroid::callFunction([=]() { +// QAndroidJniObject child = data.view->onCreate(); +// data.view->onInflate(child); +// data.view->setInstance(child); +// group.callMethod("addView", "(Landroid/view/View;)V", child.object()); +// }); + } + break; + case ViewChildRemovedChange: // data.view + if (group.isValid()) { +// QAndroidJniObject child = data.view->instance(); +// QtQmlAndroid::callFunction([=]() { +// group.callMethod("removeView", "(Landroid/view/View;)V", child.object()); +// }); +// data.view->setInstance(QAndroidJniObject()); + } + break; + default: + break; + } +} + +QT_END_NAMESPACE diff --git a/src/android/view/qqmlandroidviewgroup_p.h b/src/android/view/qqmlandroidviewgroup_p.h new file mode 100644 index 0000000..8d72ea3 --- /dev/null +++ b/src/android/view/qqmlandroidviewgroup_p.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDVIEWGROUP_P_H +#define QQMLANDROIDVIEWGROUP_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidViewGroup : public QQmlAndroidView +{ + Q_OBJECT + +public: + explicit QQmlAndroidViewGroup(QQmlAndroidView *parent = nullptr); + + static QQmlAndroidLayoutParams *qmlAttachedProperties(QObject *object); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + + void viewChange(ViewChange change, const ViewChangeData &data) override; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPEINFO(QQmlAndroidViewGroup, QML_HAS_ATTACHED_PROPERTIES) + +#endif // QQMLANDROIDVIEWGROUP_P_H diff --git a/src/android/view/qqmlandroidwindow.cpp b/src/android/view/qqmlandroidwindow.cpp new file mode 100644 index 0000000..14fc5ae --- /dev/null +++ b/src/android/view/qqmlandroidwindow.cpp @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidwindow_p.h" +#include "qqmlandroidcontext_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidWindow::QQmlAndroidWindow(QQmlAndroidContext *context) : + QQmlAndroidContextual(context) +{ + setContext(context); +} + +int QQmlAndroidWindow::statusBarColor() const +{ + if (m_statusBarColor.isNull()) + return 0; // TODO + return m_statusBarColor; +} + +void QQmlAndroidWindow::setStatusBarColor(int color) +{ + if (m_statusBarColor.isNull() || m_statusBarColor != color) { + m_statusBarColor = color; + QtQmlAndroid::callIntMethod(instance(), "setStatusBarColor", color); + emit statusBarColorChanged(); + } +} + +void QQmlAndroidWindow::onInflate(QAndroidJniObject &instance) +{ + if (!m_statusBarColor.isNull()) { + // TODO: WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS + instance.callMethod("addFlags", "(I)V", 0x80000000); + // TODO: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS + instance.callMethod("clearFlags", "(I)V", 0x04000000); + instance.callMethod("setStatusBarColor", "(I)V", m_statusBarColor); + } +} + +QT_END_NAMESPACE diff --git a/src/android/view/qqmlandroidwindow_p.h b/src/android/view/qqmlandroidwindow_p.h new file mode 100644 index 0000000..41a0fca --- /dev/null +++ b/src/android/view/qqmlandroidwindow_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDWINDOW_P_H +#define QQMLANDROIDWINDOW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidWindow : public QQmlAndroidContextual +{ + Q_OBJECT + Q_PROPERTY(int statusBarColor READ statusBarColor WRITE setStatusBarColor NOTIFY statusBarColorChanged) + +public: + explicit QQmlAndroidWindow(QQmlAndroidContext *context); + + int statusBarColor() const; + void setStatusBarColor(int color); + +Q_SIGNALS: + void statusBarColorChanged(); + +protected: + void onInflate(QAndroidJniObject &instance) override; + +private: + QQmlAndroidOptional m_statusBarColor; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDWINDOW_P_H diff --git a/src/android/view/view.pri b/src/android/view/view.pri new file mode 100644 index 0000000..1647d73 --- /dev/null +++ b/src/android/view/view.pri @@ -0,0 +1,20 @@ +INCLUDEPATH += $$PWD + +HEADERS += \ + $$PWD/qqmlandroidgravity_p.h \ + $$PWD/qqmlandroidlayoutparams_p.h \ + $$PWD/qqmlandroidmenu_p.h \ + $$PWD/qqmlandroidmenuitem_p.h \ + $$PWD/qqmlandroidview_p.h \ + $$PWD/qqmlandroidviewgroup_p.h \ + $$PWD/qqmlandroidwindow_p.h + +SOURCES += \ + $$PWD/qqmlandroidlayoutparams.cpp \ + $$PWD/qqmlandroidmenu.cpp \ + $$PWD/qqmlandroidmenuitem.cpp \ + $$PWD/qqmlandroidview.cpp \ + $$PWD/qqmlandroidviewgroup.cpp \ + $$PWD/qqmlandroidwindow.cpp + +include(animation/animation.pri) diff --git a/src/android/widget/qqmlandroidabsseekbar.cpp b/src/android/widget/qqmlandroidabsseekbar.cpp new file mode 100644 index 0000000..c03457f --- /dev/null +++ b/src/android/widget/qqmlandroidabsseekbar.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidabsseekbar_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidAbsSeekBar::QQmlAndroidAbsSeekBar(QQmlAndroidView *parent) : + QQmlAndroidProgressBar(parent) +{ +} + +QAndroidJniObject QQmlAndroidAbsSeekBar::onCreate() +{ + return QAndroidJniObject("android/widget/AbsSeekBar", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidAbsSeekBar::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidProgressBar::onInflate(instance); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidabsseekbar_p.h b/src/android/widget/qqmlandroidabsseekbar_p.h new file mode 100644 index 0000000..f7bb356 --- /dev/null +++ b/src/android/widget/qqmlandroidabsseekbar_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDABSSEEKBAR_P_H +#define QQMLANDROIDABSSEEKBAR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidAbsSeekBar : public QQmlAndroidProgressBar +{ + Q_OBJECT + +public: + explicit QQmlAndroidAbsSeekBar(QQmlAndroidView *parent = nullptr); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDABSSEEKBAR_P_H diff --git a/src/android/widget/qqmlandroidadapterview.cpp b/src/android/widget/qqmlandroidadapterview.cpp new file mode 100644 index 0000000..09bffb2 --- /dev/null +++ b/src/android/widget/qqmlandroidadapterview.cpp @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidadapterview_p.h" +#include "qqmlandroidbaseadapter_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidAdapterView::QQmlAndroidAdapterView(QQmlAndroidView *parent) : + QQmlAndroidViewGroup(parent), m_adapter(0) +{ +} + +QQmlAndroidBaseAdapter *QQmlAndroidAdapterView::adapter() const +{ + return m_adapter; +} + +void QQmlAndroidAdapterView::setAdapter(QQmlAndroidBaseAdapter *adapter) +{ + if (m_adapter != adapter) { + if (m_adapter) { + m_adapter->setContext(0); + disconnect(m_adapter, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidAdapterView::updateAdapter); + m_adapter->destruct(); + } + m_adapter = adapter; + if (m_adapter) { + m_adapter->setContext(context()); + connect(m_adapter, &QQmlAndroidObject::instanceChanged, this, &QQmlAndroidAdapterView::updateAdapter); + if (isValid()) + m_adapter->construct(); + } + emit adapterChanged(); + } +} + +void QQmlAndroidAdapterView::setSelection(int position) +{ + QtQmlAndroid::callIntMethod(instance(), "setSelection", position); +} + +QAndroidJniObject QQmlAndroidAdapterView::onCreate() +{ + return QAndroidJniObject("android/widget/AdapterView", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidAdapterView::onInflate(QAndroidJniObject &instance) +{ + m_listener = QAndroidJniObject("qt/android/widget/QmlAdapterViewListener", + "(Landroid/widget/AdapterView;J)V", + instance.object(), + reinterpret_cast(this)); + + QQmlAndroidViewGroup::onInflate(instance); + + static bool nativeMethodsRegistered = false; + if (!nativeMethodsRegistered) { + onRegisterNativeMethods(m_listener.object()); + nativeMethodsRegistered = true; + } +} + +void QQmlAndroidAdapterView::onRegisterNativeMethods(jobject listener) +{ + JNINativeMethod methods[] {{"onItemClick", "(JI)V", reinterpret_cast(onItemClick)}}; + + QAndroidJniEnvironment env; + jclass cls = env->GetObjectClass(listener); + env->RegisterNatives(cls, methods, sizeof(methods) / sizeof(methods[0])); + env->DeleteLocalRef(cls); +} + +void QQmlAndroidAdapterView::onItemClick(JNIEnv *env, jobject object, jlong instance, jint position) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidAdapterView *view = reinterpret_cast(instance); + if (view) + QMetaObject::invokeMethod(view, "click", Qt::QueuedConnection, Q_ARG(int, position)); +} + +void QQmlAndroidAdapterView::objectChange(ObjectChange change) +{ + QQmlAndroidViewGroup::objectChange(change); + if (change == InstanceChange) + updateAdapter(); +} + +void QQmlAndroidAdapterView::updateAdapter() +{ + if (!isValid()) + return; + + QAndroidJniObject adapter; + if (m_adapter) + adapter = m_adapter->instance(); + + QAndroidJniObject view = instance(); + QtQmlAndroid::callFunction([=]() { + view.callMethod("setAdapter", "(Landroid/widget/Adapter;)V", adapter.object()); + }); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidadapterview_p.h b/src/android/widget/qqmlandroidadapterview_p.h new file mode 100644 index 0000000..8418e30 --- /dev/null +++ b/src/android/widget/qqmlandroidadapterview_p.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDADAPTERVIEW_P_H +#define QQMLANDROIDADAPTERVIEW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QQmlAndroidBaseAdapter; + +class Q_QMLANDROID_EXPORT QQmlAndroidAdapterView : public QQmlAndroidViewGroup +{ + Q_OBJECT + Q_PROPERTY(QQmlAndroidBaseAdapter *adapter READ adapter WRITE setAdapter NOTIFY adapterChanged) // TODO: Adapter + +public: + explicit QQmlAndroidAdapterView(QQmlAndroidView *parent = nullptr); + + QQmlAndroidBaseAdapter *adapter() const; + void setAdapter(QQmlAndroidBaseAdapter *adapter); + +public Q_SLOTS: + void setSelection(int position); + +Q_SIGNALS: + void adapterChanged(); + void click(int position); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + + static void onRegisterNativeMethods(jobject listener); + static void onItemClick(JNIEnv *env, jobject object, jlong instance, jint position); + + void objectChange(ObjectChange change) override; + +private Q_SLOTS: + void updateAdapter(); + +private: + QAndroidJniObject m_listener; + QQmlAndroidBaseAdapter *m_adapter; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDADAPTERVIEW_P_H diff --git a/src/android/widget/qqmlandroidarrayadapter.cpp b/src/android/widget/qqmlandroidarrayadapter.cpp new file mode 100644 index 0000000..066f44d --- /dev/null +++ b/src/android/widget/qqmlandroidarrayadapter.cpp @@ -0,0 +1,110 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidarrayadapter_p.h" +#include "qqmlandroidadapterview_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidArrayAdapter::QQmlAndroidArrayAdapter(QObject *parent) : + QQmlAndroidBaseAdapter(parent), m_style(17367043) // TODO: android.R.layout.simple_list_item_1 +{ +} + +int QQmlAndroidArrayAdapter::style() const +{ + return m_style; +} + +void QQmlAndroidArrayAdapter::setStyle(int style) +{ + if (m_style != style) { + m_style = style; + emit styleChanged(); + } +} + +QStringList QQmlAndroidArrayAdapter::array() const +{ + return m_array; +} + +void QQmlAndroidArrayAdapter::setArray(const QStringList &array) +{ + if (m_array != array) { + m_array = array; // TODO: sync + emit countChanged(); + emit arrayChanged(); + } +} + +int QQmlAndroidArrayAdapter::count() const +{ + return m_array.count(); +} + +QString QQmlAndroidArrayAdapter::getItem(int position) const +{ + return m_array.value(position); +} + +void QQmlAndroidArrayAdapter::clear() +{ + if (!m_array.isEmpty()) { + m_array.clear(); // TODO: sync + emit countChanged(); + emit arrayChanged(); + } +} + +QAndroidJniObject QQmlAndroidArrayAdapter::onCreate() +{ + return QAndroidJniObject("android/widget/ArrayAdapter", + "(Landroid/content/Context;I)V", + ctx().object(), + m_style); +} + +void QQmlAndroidArrayAdapter::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidBaseAdapter::onInflate(instance); + + foreach (const QString &str, m_array) + instance.callMethod("add", "(Ljava/lang/Object;)V", QAndroidJniObject::fromString(str).object()); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidarrayadapter_p.h b/src/android/widget/qqmlandroidarrayadapter_p.h new file mode 100644 index 0000000..06110c3 --- /dev/null +++ b/src/android/widget/qqmlandroidarrayadapter_p.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDARRAYADAPTER_P_H +#define QQMLANDROIDARRAYADAPTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidArrayAdapter : public QQmlAndroidBaseAdapter +{ + Q_OBJECT + Q_PROPERTY(int style READ style WRITE setStyle NOTIFY styleChanged) + Q_PROPERTY(QStringList array READ array WRITE setArray NOTIFY arrayChanged) + +public: + explicit QQmlAndroidArrayAdapter(QObject *parent = nullptr); + + int style() const; + void setStyle(int style); + + QStringList array() const; + void setArray(const QStringList &array); + + int count() const override; + Q_INVOKABLE QString getItem(int position) const; + +public Q_SLOTS: + void clear() override; + +Q_SIGNALS: + void styleChanged(); + void arrayChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + +private: + int m_style; + QStringList m_array; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDARRAYADAPTER_P_H diff --git a/src/android/widget/qqmlandroidbaseadapter.cpp b/src/android/widget/qqmlandroidbaseadapter.cpp new file mode 100644 index 0000000..8282500 --- /dev/null +++ b/src/android/widget/qqmlandroidbaseadapter.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidbaseadapter_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidBaseAdapter::QQmlAndroidBaseAdapter(QObject *parent) : + QQmlAndroidContextual(parent) +{ +} + +QAndroidJniObject QQmlAndroidBaseAdapter::onCreate() +{ + return QAndroidJniObject("android/widget/BaseAdapter"); +} + +void QQmlAndroidBaseAdapter::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidContextual::onInflate(instance); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidbaseadapter_p.h b/src/android/widget/qqmlandroidbaseadapter_p.h new file mode 100644 index 0000000..a32cd61 --- /dev/null +++ b/src/android/widget/qqmlandroidbaseadapter_p.h @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDBASEADAPTER_P_H +#define QQMLANDROIDBASEADAPTER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidBaseAdapter : public QQmlAndroidContextual +{ + Q_OBJECT + Q_PROPERTY(int count READ count NOTIFY countChanged) + +public: + explicit QQmlAndroidBaseAdapter(QObject *parent = nullptr); + + virtual int count() const = 0; + +public Q_SLOTS: + virtual void clear() = 0; + +Q_SIGNALS: + void countChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDBASEADAPTER_P_H diff --git a/src/android/widget/qqmlandroidbutton.cpp b/src/android/widget/qqmlandroidbutton.cpp new file mode 100644 index 0000000..36e4937 --- /dev/null +++ b/src/android/widget/qqmlandroidbutton.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidbutton_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidButton::QQmlAndroidButton(QQmlAndroidView *parent) : + QQmlAndroidTextView(parent) +{ +} + +QAndroidJniObject QQmlAndroidButton::onCreate() +{ + return QAndroidJniObject("android/widget/Button", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidButton::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidTextView::onInflate(instance); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidbutton_p.h b/src/android/widget/qqmlandroidbutton_p.h new file mode 100644 index 0000000..888dd0e --- /dev/null +++ b/src/android/widget/qqmlandroidbutton_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDBUTTON_P_H +#define QQMLANDROIDBUTTON_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidButton : public QQmlAndroidTextView +{ + Q_OBJECT + +public: + explicit QQmlAndroidButton(QQmlAndroidView *parent = nullptr); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDBUTTON_P_H diff --git a/src/android/widget/qqmlandroidcalendarview.cpp b/src/android/widget/qqmlandroidcalendarview.cpp new file mode 100644 index 0000000..7c1a627 --- /dev/null +++ b/src/android/widget/qqmlandroidcalendarview.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidcalendarview_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidCalendarView::QQmlAndroidCalendarView(QQmlAndroidView *parent) : + QQmlAndroidFrameLayout(parent) +{ +} + +QAndroidJniObject QQmlAndroidCalendarView::onCreate() +{ + return QAndroidJniObject("android/widget/CalendarView", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidCalendarView::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidViewGroup::onInflate(instance); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidcalendarview_p.h b/src/android/widget/qqmlandroidcalendarview_p.h new file mode 100644 index 0000000..cf39cc6 --- /dev/null +++ b/src/android/widget/qqmlandroidcalendarview_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDCALENDARVIEW_P_H +#define QQMLANDROIDCALENDARVIEW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidCalendarView : public QQmlAndroidFrameLayout +{ + Q_OBJECT + +public: + explicit QQmlAndroidCalendarView(QQmlAndroidView *parent = nullptr); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDCALENDARVIEW_P_H diff --git a/src/android/widget/qqmlandroidcheckbox.cpp b/src/android/widget/qqmlandroidcheckbox.cpp new file mode 100644 index 0000000..806da94 --- /dev/null +++ b/src/android/widget/qqmlandroidcheckbox.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidcheckbox_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidCheckBox::QQmlAndroidCheckBox(QQmlAndroidView *parent) : + QQmlAndroidCompoundButton(parent) +{ +} + +QAndroidJniObject QQmlAndroidCheckBox::onCreate() +{ + return QAndroidJniObject("android/widget/CheckBox", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidCheckBox::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidCompoundButton::onInflate(instance); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidcheckbox_p.h b/src/android/widget/qqmlandroidcheckbox_p.h new file mode 100644 index 0000000..947487a --- /dev/null +++ b/src/android/widget/qqmlandroidcheckbox_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDCHECKBOX_P_H +#define QQMLANDROIDCHECKBOX_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidCheckBox : public QQmlAndroidCompoundButton +{ + Q_OBJECT + +public: + explicit QQmlAndroidCheckBox(QQmlAndroidView *parent = nullptr); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDCHECKBOX_P_H diff --git a/src/android/widget/qqmlandroidcompoundbutton.cpp b/src/android/widget/qqmlandroidcompoundbutton.cpp new file mode 100644 index 0000000..617f61e --- /dev/null +++ b/src/android/widget/qqmlandroidcompoundbutton.cpp @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidcompoundbutton_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidCompoundButton::QQmlAndroidCompoundButton(QQmlAndroidView *parent) : + QQmlAndroidButton(parent), m_checked(false) +{ +} + +bool QQmlAndroidCompoundButton::isChecked() const +{ + return m_checked; +} + +void QQmlAndroidCompoundButton::setChecked(bool checked) +{ + if (updateChecked(checked)) + QtQmlAndroid::callBoolMethod(instance(), "setChecked", checked); +} + +bool QQmlAndroidCompoundButton::updateChecked(bool arg) +{ + if (arg != isChecked()) { + m_checked = arg; + emit checkedChanged(); + return true; + } + return false; +} + +void QQmlAndroidCompoundButton::toggle() +{ + QtQmlAndroid::callVoidMethod(instance(), "toggle"); +} + +QAndroidJniObject QQmlAndroidCompoundButton::onCreate() +{ + return QAndroidJniObject("android/widget/CompoundButton", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidCompoundButton::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidButton::onInflate(instance); + + m_listener = QAndroidJniObject("qt/android/widget/QmlCompoundButtonListener", + "(Landroid/widget/CompoundButton;J)V", + instance.object(), + reinterpret_cast(this)); + + static bool nativeMethodsRegistered = false; + if (!nativeMethodsRegistered) { + onRegisterNativeMethods(m_listener.object()); + nativeMethodsRegistered = true; + } + + instance.callMethod("setChecked", "(Z)V", m_checked); +} + +void QQmlAndroidCompoundButton::onRegisterNativeMethods(jobject listener) +{ + JNINativeMethod methods[] {{"onCheckedChanged", "(JZ)V", reinterpret_cast(onCheckedChanged)}}; + + QAndroidJniEnvironment env; + jclass cls = env->GetObjectClass(listener); + env->RegisterNatives(cls, methods, sizeof(methods) / sizeof(methods[0])); + env->DeleteLocalRef(cls); +} + +void QQmlAndroidCompoundButton::onCheckedChanged(JNIEnv *env, jobject object, jlong instance, jboolean isChecked) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidCompoundButton *button = reinterpret_cast(instance); + if (button) + QMetaObject::invokeMethod(button, "updateChecked", Qt::QueuedConnection, Q_ARG(bool, isChecked)); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidcompoundbutton_p.h b/src/android/widget/qqmlandroidcompoundbutton_p.h new file mode 100644 index 0000000..81f7830 --- /dev/null +++ b/src/android/widget/qqmlandroidcompoundbutton_p.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDCOMPOUNDBUTTON_P_H +#define QQMLANDROIDCOMPOUNDBUTTON_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidCompoundButton : public QQmlAndroidButton +{ + Q_OBJECT + Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged) + +public: + explicit QQmlAndroidCompoundButton(QQmlAndroidView *parent = nullptr); + + bool isChecked() const; + void setChecked(bool checked); + +public Q_SLOTS: + void toggle(); + +Q_SIGNALS: + void checkedChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + + static void onRegisterNativeMethods(jobject listener); + static void onCheckedChanged(JNIEnv *env, jobject object, jlong instance, jboolean isChecked); + +private Q_SLOTS: + bool updateChecked(bool checked); + +private: + bool m_checked; + QAndroidJniObject m_listener; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDCOMPOUNDBUTTON_P_H diff --git a/src/android/widget/qqmlandroiddatepicker.cpp b/src/android/widget/qqmlandroiddatepicker.cpp new file mode 100644 index 0000000..6487766 --- /dev/null +++ b/src/android/widget/qqmlandroiddatepicker.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroiddatepicker_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidDatePicker::QQmlAndroidDatePicker(QQmlAndroidView *parent) : + QQmlAndroidFrameLayout(parent) +{ +} + +QAndroidJniObject QQmlAndroidDatePicker::onCreate() +{ + return QAndroidJniObject("android/widget/DatePicker", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidDatePicker::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidFrameLayout::onInflate(instance); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroiddatepicker_p.h b/src/android/widget/qqmlandroiddatepicker_p.h new file mode 100644 index 0000000..56626a6 --- /dev/null +++ b/src/android/widget/qqmlandroiddatepicker_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDDATEPICKER_P_H +#define QQMLANDROIDDATEPICKER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidDatePicker : public QQmlAndroidFrameLayout +{ + Q_OBJECT + +public: + explicit QQmlAndroidDatePicker(QQmlAndroidView *parent = nullptr); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDDATEPICKER_P_H diff --git a/src/android/widget/qqmlandroidedittext.cpp b/src/android/widget/qqmlandroidedittext.cpp new file mode 100644 index 0000000..6697ac9 --- /dev/null +++ b/src/android/widget/qqmlandroidedittext.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidedittext_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidEditText::QQmlAndroidEditText(QQmlAndroidView *parent) : + QQmlAndroidTextView(parent) +{ +} + +QAndroidJniObject QQmlAndroidEditText::onCreate() +{ + return QAndroidJniObject("android/widget/EditText", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidEditText::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidTextView::onInflate(instance); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidedittext_p.h b/src/android/widget/qqmlandroidedittext_p.h new file mode 100644 index 0000000..5263a90 --- /dev/null +++ b/src/android/widget/qqmlandroidedittext_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDEDITTEXT_P_H +#define QQMLANDROIDEDITTEXT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidEditText : public QQmlAndroidTextView +{ + Q_OBJECT + +public: + explicit QQmlAndroidEditText(QQmlAndroidView *parent = nullptr); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDEDITTEXT_P_H diff --git a/src/android/widget/qqmlandroidframelayout.cpp b/src/android/widget/qqmlandroidframelayout.cpp new file mode 100644 index 0000000..b240433 --- /dev/null +++ b/src/android/widget/qqmlandroidframelayout.cpp @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidframelayout_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidFrameLayout::QQmlAndroidFrameLayout(QQmlAndroidView *parent) : + QQmlAndroidViewGroup(parent) +{ +} + +QQmlAndroidFrameLayoutParams *QQmlAndroidFrameLayout::qmlAttachedProperties(QObject *object) +{ + QQmlAndroidView *view = qobject_cast(object); + if (view) + return new QQmlAndroidFrameLayoutParams(view); + return 0; +} + +QAndroidJniObject QQmlAndroidFrameLayout::onCreate() +{ + return QAndroidJniObject("android/widget/FrameLayout", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidFrameLayout::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidViewGroup::onInflate(instance); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidframelayout_p.h b/src/android/widget/qqmlandroidframelayout_p.h new file mode 100644 index 0000000..f7debd5 --- /dev/null +++ b/src/android/widget/qqmlandroidframelayout_p.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDFRAMELAYOUT_P_H +#define QQMLANDROIDFRAMELAYOUT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidFrameLayout : public QQmlAndroidViewGroup +{ + Q_OBJECT + +public: + explicit QQmlAndroidFrameLayout(QQmlAndroidView *parent = nullptr); + + static QQmlAndroidFrameLayoutParams *qmlAttachedProperties(QObject *object); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPEINFO(QQmlAndroidFrameLayout, QML_HAS_ATTACHED_PROPERTIES) + +#endif // QQMLANDROIDFRAMELAYOUT_P_H diff --git a/src/android/widget/qqmlandroidframelayoutparams.cpp b/src/android/widget/qqmlandroidframelayoutparams.cpp new file mode 100644 index 0000000..2c8f5aa --- /dev/null +++ b/src/android/widget/qqmlandroidframelayoutparams.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidframelayoutparams_p.h" +#include "qqmlandroidview_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidFrameLayoutParams::QQmlAndroidFrameLayoutParams(QQmlAndroidView *view) : + QQmlAndroidMarginLayoutParams(view) +{ +} + +int QQmlAndroidFrameLayoutParams::gravity() const +{ + if (m_gravity.isNull()) + return 0; // TODO + return m_gravity; +} + +void QQmlAndroidFrameLayoutParams::setGravity(int value) +{ + if (value != gravity()) { + m_gravity = value; + invalidate(); + emit gravityChanged(); + } +} + +QAndroidJniObject QQmlAndroidFrameLayoutParams::onCreate() +{ + return QAndroidJniObject("android/widget/FrameLayout$LayoutParams", + "(II)V", + MATCH_PARENT, MATCH_PARENT); +} + +void QQmlAndroidFrameLayoutParams::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidMarginLayoutParams::onInflate(instance); + + if (!m_gravity.isNull()) + instance.callMethod("setGravity", "(I)V", m_gravity); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidframelayoutparams_p.h b/src/android/widget/qqmlandroidframelayoutparams_p.h new file mode 100644 index 0000000..db3709a --- /dev/null +++ b/src/android/widget/qqmlandroidframelayoutparams_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDFRAMELAYOUTPARAMS_P_H +#define QQMLANDROIDFRAMELAYOUTPARAMS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidFrameLayoutParams : public QQmlAndroidMarginLayoutParams +{ + Q_OBJECT + Q_PROPERTY(int gravity READ gravity WRITE setGravity NOTIFY gravityChanged) + +public: + explicit QQmlAndroidFrameLayoutParams(QQmlAndroidView *view); + + int gravity() const; + void setGravity(int gravity); + +Q_SIGNALS: + void gravityChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + +private: + QQmlAndroidOptional m_gravity; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDFRAMELAYOUTPARAMS_P_H diff --git a/src/android/widget/qqmlandroidimageview.cpp b/src/android/widget/qqmlandroidimageview.cpp new file mode 100644 index 0000000..fe76930 --- /dev/null +++ b/src/android/widget/qqmlandroidimageview.cpp @@ -0,0 +1,136 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidimageview_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidImageView::QQmlAndroidImageView(QQmlAndroidView *parent) : + QQmlAndroidView(parent), m_resource(0) +{ +} + +QUrl QQmlAndroidImageView::imageURI() const +{ + return m_uri; +} + +void QQmlAndroidImageView::setImageURI(const QUrl &uri) +{ + if (m_uri != uri) { + m_uri = uri; + if (isValid()) { + QAndroidJniObject v = instance(); + QAndroidJniObject u = getUri(); + QtQmlAndroid::callFunction([=]() { + v.callMethod("setImageURI", "(Landroid/net/Uri;)V", u.object()); + }); + } + emit imageURIChanged(); + } +} + +int QQmlAndroidImageView::imageResource() const +{ + return m_resource; +} + +void QQmlAndroidImageView::setImageResource(int resource) +{ + if (m_resource != resource) { + m_resource = resource; + QtQmlAndroid::callIntMethod(instance(), "setImageResource", resource); + emit imageResourceChanged(); + } +} + +int QQmlAndroidImageView::imageTintColor() const +{ + if (m_tint.isNull()) + return 0; // TODO + return m_tint; +} + +void QQmlAndroidImageView::setImageTintColor(int color) +{ + if (m_tint.isNull() || m_tint != color) { + m_tint = color; + if (isValid()) { + QAndroidJniObject view = instance(); + QtQmlAndroid::callFunction([=]() { + QAndroidJniObject tint = QAndroidJniObject::callStaticObjectMethod("android/content/res/ColorStateList", + "valueOf", + "(I)Landroid/content/res/ColorStateList;", + color); + view.callMethod("setImageTintList", "(Landroid/content/res/ColorStateList;)v", tint.object()); + }); + } + emit imageTintColorChanged(); + } +} + +QAndroidJniObject QQmlAndroidImageView::onCreate() +{ + return QAndroidJniObject("android/widget/ImageView", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidImageView::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidView::onInflate(instance); + + if (m_uri.isValid()) + instance.callMethod("setImageURI", "(Landroid/net/Uri;)V", getUri().object()); + if (m_resource > 0) + instance.callMethod("setImageResource", "(I)V", m_resource); + if (!m_tint.isNull()) { + QAndroidJniObject tint = QAndroidJniObject::callStaticObjectMethod("android/content/res/ColorStateList", + "valueOf", + "(I)Landroid/content/res/ColorStateList;", + m_tint); + instance.callMethod("setImageTintList", "(Landroid/content/res/ColorStateList;)v", tint.object()); + } +} + +QAndroidJniObject QQmlAndroidImageView::getUri() const +{ + QAndroidJniObject str = QAndroidJniObject::fromString(m_uri.toString()); + return QAndroidJniObject::callStaticObjectMethod("android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;", str.object()); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidimageview_p.h b/src/android/widget/qqmlandroidimageview_p.h new file mode 100644 index 0000000..ab933d2 --- /dev/null +++ b/src/android/widget/qqmlandroidimageview_p.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDIMAGEVIEW_P_H +#define QQMLANDROIDIMAGEVIEW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidImageView : public QQmlAndroidView +{ + Q_OBJECT + Q_PROPERTY(QUrl imageURI READ imageURI WRITE setImageURI NOTIFY imageURIChanged) + Q_PROPERTY(int imageResource READ imageResource WRITE setImageResource NOTIFY imageResourceChanged) + Q_PROPERTY(int imageTintColor READ imageTintColor WRITE setImageTintColor NOTIFY imageTintColorChanged) + +public: + explicit QQmlAndroidImageView(QQmlAndroidView *parent = nullptr); + + QUrl imageURI() const; + void setImageURI(const QUrl &uri); + + int imageResource() const; + void setImageResource(int resource); + + int imageTintColor() const; + void setImageTintColor(int color); + +Q_SIGNALS: + void imageURIChanged(); + void imageResourceChanged(); + void imageTintColorChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + +private: + QAndroidJniObject getUri() const; + + QUrl m_uri; + int m_resource; + QQmlAndroidOptional m_tint; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDTEXTVIEW_P_H diff --git a/src/android/widget/qqmlandroidlinearlayout.cpp b/src/android/widget/qqmlandroidlinearlayout.cpp new file mode 100644 index 0000000..a1732dc --- /dev/null +++ b/src/android/widget/qqmlandroidlinearlayout.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidlinearlayout_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidLinearLayout::QQmlAndroidLinearLayout(QQmlAndroidView *parent) : + QQmlAndroidViewGroup(parent) +{ +} + +QQmlAndroidLinearLayoutParams *QQmlAndroidLinearLayout::qmlAttachedProperties(QObject *object) +{ + QQmlAndroidView *view = qobject_cast(object); + if (view) + return new QQmlAndroidLinearLayoutParams(view); + return 0; +} + +bool QQmlAndroidLinearLayout::isBaselineAligned() const +{ + if (m_baselineAligned.isNull()) + return true; + return m_baselineAligned; +} + +void QQmlAndroidLinearLayout::setBaselineAligned(bool aligned) +{ + if (aligned != isBaselineAligned()) { + m_baselineAligned = aligned; +// if (isValid()) +// jniObject().callMethod("setBaselineAligned", "(Z)V", aligned); + emit baselineAlignedChanged(); + } +} + +int QQmlAndroidLinearLayout::baselineAlignedChildIndex() const +{ + if (m_baselineAlignedChildIndex.isNull()) + return -1; + return m_baselineAlignedChildIndex; +} + +void QQmlAndroidLinearLayout::setBaselineAlignedChildIndex(int index) +{ + if (index != baselineAlignedChildIndex()) { + m_baselineAlignedChildIndex = index; +// if (isValid()) +// jniObject().callMethod("setBaselineAlignedChildIndex", "(I)V", index); + emit baselineAlignedChildIndexChanged(); + } +} + +bool QQmlAndroidLinearLayout::isMeasureWithLargestChildEnabled() const +{ + if (m_measureWithLargestChild.isNull()) + return false; + return m_measureWithLargestChild; +} + +void QQmlAndroidLinearLayout::setMeasureWithLargestChildEnabled(bool enabled) +{ + if (enabled != isMeasureWithLargestChildEnabled()) { + m_measureWithLargestChild = enabled; +// if (isValid()) +// jniObject().callMethod("setMeasureWithLargestChildEnabled", "(Z)V", enabled); + emit measureWithLargestChildEnabledChanged(); + } +} + +QQmlAndroidLinearLayout::Orientation QQmlAndroidLinearLayout::orientation() const +{ + if (m_orientation.isNull()) + return HORIZONTAL; + return m_orientation; +} + +void QQmlAndroidLinearLayout::setOrientation(Orientation value) +{ + if (value != orientation()) { + m_orientation = value; +// if (isValid()) +// jniObject().callMethod("setOrientation", "(I)V", value); + emit orientationChanged(); + } +} + +qreal QQmlAndroidLinearLayout::weightSum() const +{ + if (m_weightSum.isNull()) + return -1.0f; + return m_weightSum; +} + +void QQmlAndroidLinearLayout::setWeightSum(qreal sum) +{ + if (sum != weightSum()) { + m_weightSum = sum; +// if (isValid()) +// jniObject().callMethod("setWeightSum", "(J)V", sum); + emit weightSumChanged(); + } +} + +QAndroidJniObject QQmlAndroidLinearLayout::onCreate() +{ + return QAndroidJniObject("android/widget/LinearLayout", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidLinearLayout::onInflate(QAndroidJniObject &instance) +{ + if (!m_baselineAligned.isNull()) + instance.callMethod("setBaselineAligned", "(Z)V", m_baselineAligned); + if (!m_measureWithLargestChild.isNull()) + instance.callMethod("setMeasureWithLargestChildEnabled", "(Z)V", m_measureWithLargestChild); + if (!m_orientation.isNull()) + instance.callMethod("setOrientation", "(I)V", m_orientation); + if (!m_weightSum.isNull()) + instance.callMethod("setWeightSum", "(J)V", m_weightSum); + + QQmlAndroidViewGroup::onInflate(instance); + + if (!m_baselineAlignedChildIndex.isNull()) + instance.callMethod("setBaselineAlignedChildIndex", "(I)V", m_baselineAlignedChildIndex); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidlinearlayout_p.h b/src/android/widget/qqmlandroidlinearlayout_p.h new file mode 100644 index 0000000..104af96 --- /dev/null +++ b/src/android/widget/qqmlandroidlinearlayout_p.h @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDLINEARLAYOUT_P_H +#define QQMLANDROIDLINEARLAYOUT_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidLinearLayout : public QQmlAndroidViewGroup +{ + Q_OBJECT + Q_PROPERTY(bool baselineAligned READ isBaselineAligned WRITE setBaselineAligned NOTIFY baselineAlignedChanged) + Q_PROPERTY(int baselineAlignedChildIndex READ baselineAlignedChildIndex WRITE setBaselineAlignedChildIndex NOTIFY baselineAlignedChildIndexChanged) + Q_PROPERTY(bool measureWithLargestChildEnabled READ isMeasureWithLargestChildEnabled WRITE setMeasureWithLargestChildEnabled NOTIFY measureWithLargestChildEnabledChanged) + Q_PROPERTY(Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) + Q_PROPERTY(qreal weightSum READ weightSum WRITE setWeightSum NOTIFY weightSumChanged) + Q_ENUMS(Orientation) + +public: + explicit QQmlAndroidLinearLayout(QQmlAndroidView *parent = nullptr); + + static QQmlAndroidLinearLayoutParams *qmlAttachedProperties(QObject *object); + + enum Orientation { + HORIZONTAL = 0, + VERTICAL = 1 + }; + + bool isBaselineAligned() const; + void setBaselineAligned(bool aligned); + + int baselineAlignedChildIndex() const; + void setBaselineAlignedChildIndex(int index); + + // TODO: Drawable divider + // TODO: int gravity + + bool isMeasureWithLargestChildEnabled() const; + void setMeasureWithLargestChildEnabled(bool enabled); + + Orientation orientation() const; + void setOrientation(Orientation orientation); + + qreal weightSum() const; + void setWeightSum(qreal sum); + +Q_SIGNALS: + void baselineAlignedChanged(); + void baselineAlignedChildIndexChanged(); + void measureWithLargestChildEnabledChanged(); + void orientationChanged(); + void weightSumChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + +private: + QQmlAndroidOptional m_baselineAligned; + QQmlAndroidOptional m_baselineAlignedChildIndex; + // TODO: Drawable divider + // TODO: int gravity + QQmlAndroidOptional m_measureWithLargestChild; + QQmlAndroidOptional m_orientation; + QQmlAndroidOptional m_weightSum; +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPEINFO(QQmlAndroidLinearLayout, QML_HAS_ATTACHED_PROPERTIES) + +#endif // QQMLANDROIDLINEARLAYOUT_P_H diff --git a/src/android/widget/qqmlandroidlinearlayoutparams.cpp b/src/android/widget/qqmlandroidlinearlayoutparams.cpp new file mode 100644 index 0000000..d700450 --- /dev/null +++ b/src/android/widget/qqmlandroidlinearlayoutparams.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidlinearlayoutparams_p.h" +#include "qqmlandroidview_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidLinearLayoutParams::QQmlAndroidLinearLayoutParams(QQmlAndroidView *view) : + QQmlAndroidMarginLayoutParams(view) +{ +} + +int QQmlAndroidLinearLayoutParams::gravity() const +{ + if (m_gravity.isNull()) + return 0; // TODO + return m_gravity; +} + +void QQmlAndroidLinearLayoutParams::setGravity(int value) +{ + if (value != gravity()) { + m_gravity = value; + invalidate(); + emit gravityChanged(); + } +} + +qreal QQmlAndroidLinearLayoutParams::weight() const +{ + if (m_weight.isNull()) + return 0.0; // TODO + return m_weight; +} + +void QQmlAndroidLinearLayoutParams::setWeight(qreal value) +{ + if (value != weight()) { + m_weight = value; + invalidate(); + emit weightChanged(); + } +} + +QAndroidJniObject QQmlAndroidLinearLayoutParams::onCreate() +{ + return QAndroidJniObject("android/widget/LinearLayout$LayoutParams", + "(II)V", + MATCH_PARENT, MATCH_PARENT); +} + +void QQmlAndroidLinearLayoutParams::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidMarginLayoutParams::onInflate(instance); + + if (!m_gravity.isNull()) + instance.setField("gravity", m_gravity); + if (!m_weight.isNull()) + instance.setField("weight", m_weight); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidlinearlayoutparams_p.h b/src/android/widget/qqmlandroidlinearlayoutparams_p.h new file mode 100644 index 0000000..a6084e8 --- /dev/null +++ b/src/android/widget/qqmlandroidlinearlayoutparams_p.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDLINEARLAYOUTPARAMS_P_H +#define QQMLANDROIDLINEARLAYOUTPARAMS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidLinearLayoutParams : public QQmlAndroidMarginLayoutParams +{ + Q_OBJECT + Q_PROPERTY(int gravity READ gravity WRITE setGravity NOTIFY gravityChanged) + Q_PROPERTY(qreal weight READ weight WRITE setWeight NOTIFY weightChanged) + +public: + explicit QQmlAndroidLinearLayoutParams(QQmlAndroidView *view); + + int gravity() const; + void setGravity(int gravity); + + qreal weight() const; + void setWeight(qreal weight); + +Q_SIGNALS: + void gravityChanged(); + void weightChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + +private: + QQmlAndroidOptional m_gravity; + QQmlAndroidOptional m_weight; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDLINEARLAYOUTPARAMS_P_H diff --git a/src/android/widget/qqmlandroidlistview.cpp b/src/android/widget/qqmlandroidlistview.cpp new file mode 100644 index 0000000..8b04e6c --- /dev/null +++ b/src/android/widget/qqmlandroidlistview.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidlistview_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidListView::QQmlAndroidListView(QQmlAndroidView *parent) : + QQmlAndroidAdapterView(parent) +{ +} + +QAndroidJniObject QQmlAndroidListView::onCreate() +{ + return QAndroidJniObject("android/widget/ListView", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidListView::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidAdapterView::onInflate(instance); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidlistview_p.h b/src/android/widget/qqmlandroidlistview_p.h new file mode 100644 index 0000000..5262a24 --- /dev/null +++ b/src/android/widget/qqmlandroidlistview_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDLISTVIEW_P_H +#define QQMLANDROIDLISTVIEW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidListView : public QQmlAndroidAdapterView // TODO: AbsListView +{ + Q_OBJECT + +public: + explicit QQmlAndroidListView(QQmlAndroidView *parent = nullptr); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDLISTVIEW_P_H diff --git a/src/android/widget/qqmlandroidmarginlayoutparams.cpp b/src/android/widget/qqmlandroidmarginlayoutparams.cpp new file mode 100644 index 0000000..9e3fd1f --- /dev/null +++ b/src/android/widget/qqmlandroidmarginlayoutparams.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidmarginlayoutparams_p.h" +#include "qqmlandroidview_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidMarginLayoutParams::QQmlAndroidMarginLayoutParams(QQmlAndroidView *view) : + QQmlAndroidLayoutParams(view) +{ +} + +int QQmlAndroidMarginLayoutParams::margin() const +{ + if (m_margin.isNull()) + return 0; + return m_margin; +} + +void QQmlAndroidMarginLayoutParams::setMargin(int margin) +{ + if (m_margin.isNull() || m_margin != margin) { + m_margin = margin; + invalidate(); + emit marginChanged(); + } +} + +int QQmlAndroidMarginLayoutParams::topMargin() const +{ + if (m_topMargin.isNull()) + return margin(); + return m_topMargin; +} + +void QQmlAndroidMarginLayoutParams::setTopMargin(int margin) +{ + if (m_topMargin.isNull() || m_topMargin != margin) { + m_topMargin = margin; + invalidate(); + emit topMarginChanged(); + } +} + +int QQmlAndroidMarginLayoutParams::leftMargin() const +{ + if (m_leftMargin.isNull()) + return margin(); + return m_leftMargin; +} + +void QQmlAndroidMarginLayoutParams::setLeftMargin(int margin) +{ + if (m_leftMargin.isNull() || m_leftMargin != margin) { + m_leftMargin = margin; + invalidate(); + emit leftMarginChanged(); + } +} + +int QQmlAndroidMarginLayoutParams::rightMargin() const +{ + if (m_rightMargin.isNull()) + return margin(); + return m_rightMargin; +} + +void QQmlAndroidMarginLayoutParams::setRightMargin(int margin) +{ + if (m_rightMargin.isNull() || m_rightMargin != margin) { + m_rightMargin = margin; + invalidate(); + emit rightMarginChanged(); + } +} + +int QQmlAndroidMarginLayoutParams::bottomMargin() const +{ + if (m_bottomMargin.isNull()) + return margin(); + return m_bottomMargin; +} + +void QQmlAndroidMarginLayoutParams::setBottomMargin(int margin) +{ + if (m_bottomMargin.isNull() || m_bottomMargin != margin) { + m_bottomMargin = margin; + invalidate(); + emit bottomMarginChanged(); + } +} + +QAndroidJniObject QQmlAndroidMarginLayoutParams::onCreate() +{ + return QAndroidJniObject("android/view/ViewGroup$MarginLayoutParams", + "(II)V", + MATCH_PARENT, MATCH_PARENT); +} + +void QQmlAndroidMarginLayoutParams::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidLayoutParams::onInflate(instance); + + instance.callMethod("setMargins", + "(IIII)V", + leftMargin(), + topMargin(), + rightMargin(), + bottomMargin()); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidmarginlayoutparams_p.h b/src/android/widget/qqmlandroidmarginlayoutparams_p.h new file mode 100644 index 0000000..f608bb7 --- /dev/null +++ b/src/android/widget/qqmlandroidmarginlayoutparams_p.h @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDMARGINLAYOUTPARAMS_P_H +#define QQMLANDROIDMARGINLAYOUTPARAMS_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidMarginLayoutParams : public QQmlAndroidLayoutParams +{ + Q_OBJECT + Q_PROPERTY(int margin READ margin WRITE setMargin NOTIFY marginChanged) + Q_PROPERTY(int topMargin READ topMargin WRITE setTopMargin NOTIFY topMarginChanged) + Q_PROPERTY(int leftMargin READ leftMargin WRITE setLeftMargin NOTIFY leftMarginChanged) + Q_PROPERTY(int rightMargin READ rightMargin WRITE setRightMargin NOTIFY rightMarginChanged) + Q_PROPERTY(int bottomMargin READ bottomMargin WRITE setBottomMargin NOTIFY bottomMarginChanged) + +public: + explicit QQmlAndroidMarginLayoutParams(QQmlAndroidView *view); + + int margin() const; + void setMargin(int margin); + + int topMargin() const; + void setTopMargin(int margin); + + int leftMargin() const; + void setLeftMargin(int margin); + + int rightMargin() const; + void setRightMargin(int margin); + + int bottomMargin() const; + void setBottomMargin(int margin); + +Q_SIGNALS: + void marginChanged(); + void topMarginChanged(); + void leftMarginChanged(); + void rightMarginChanged(); + void bottomMarginChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + +private: + QQmlAndroidOptional m_margin; + QQmlAndroidOptional m_topMargin; + QQmlAndroidOptional m_leftMargin; + QQmlAndroidOptional m_rightMargin; + QQmlAndroidOptional m_bottomMargin; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDMARGINLAYOUTPARAMS_P_H diff --git a/src/android/widget/qqmlandroidnumberpicker.cpp b/src/android/widget/qqmlandroidnumberpicker.cpp new file mode 100644 index 0000000..b96f0a1 --- /dev/null +++ b/src/android/widget/qqmlandroidnumberpicker.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidnumberpicker_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidNumberPicker::QQmlAndroidNumberPicker(QQmlAndroidView *parent) : + QQmlAndroidLinearLayout(parent), m_value(0) +{ +} + +int QQmlAndroidNumberPicker::value() const +{ + return m_value; +} + +void QQmlAndroidNumberPicker::setValue(int value) +{ + if (updateValue(value)) + QtQmlAndroid::callIntMethod(instance(), "setValue", value); +} + +bool QQmlAndroidNumberPicker::updateValue(int value) +{ + if (m_value != value) { + m_value = value; + emit valueChanged(); + return true; + } + return false; +} + +QAndroidJniObject QQmlAndroidNumberPicker::onCreate() +{ + return QAndroidJniObject("android/widget/NumberPicker", + "(Landroid/content/Context;)V", + ctx().object()); +} + +void QQmlAndroidNumberPicker::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidLinearLayout::onInflate(instance); + + m_listener = QAndroidJniObject("qt/android/widget/QmlNumberPickerListener", + "(Landroid/widget/NumberPicker;J)V", + instance.object(), + reinterpret_cast(this)); + + static bool nativeMethodsRegistered = false; + if (!nativeMethodsRegistered) { + onRegisterNativeMethods(m_listener.object()); + nativeMethodsRegistered = true; + } + + instance.callMethod("setValue", "(I)V", m_value); +} + +void QQmlAndroidNumberPicker::onRegisterNativeMethods(jobject listener) +{ + JNINativeMethod methods[] {{"onValueChange", "(JI)V", reinterpret_cast(onValueChange)}}; + + QAndroidJniEnvironment env; + jclass cls = env->GetObjectClass(listener); + env->RegisterNatives(cls, methods, sizeof(methods) / sizeof(methods[0])); + env->DeleteLocalRef(cls); +} + +void QQmlAndroidNumberPicker::onValueChange(JNIEnv *env, jobject object, jlong instance, jint value) +{ + Q_UNUSED(env); + Q_UNUSED(object); + QQmlAndroidNumberPicker *picker = reinterpret_cast(instance); + if (picker) + QMetaObject::invokeMethod(picker, "updateValue", Qt::QueuedConnection, Q_ARG(int, value)); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidnumberpicker_p.h b/src/android/widget/qqmlandroidnumberpicker_p.h new file mode 100644 index 0000000..1b21354 --- /dev/null +++ b/src/android/widget/qqmlandroidnumberpicker_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDNUMBERPICKER_P_H +#define QQMLANDROIDNUMBERPICKER_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidNumberPicker : public QQmlAndroidLinearLayout +{ + Q_OBJECT + Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged) + +public: + explicit QQmlAndroidNumberPicker(QQmlAndroidView *parent = nullptr); + + int value() const; + void setValue(int value); + +Q_SIGNALS: + void valueChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + + static void onRegisterNativeMethods(jobject listener); + static void onValueChange(JNIEnv *env, jobject object, jlong instance, jint value); + +private Q_SLOTS: + bool updateValue(int value); + +private: + int m_value; + QAndroidJniObject m_listener; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDNUMBERPICKER_P_H diff --git a/src/android/widget/qqmlandroidpopupmenu.cpp b/src/android/widget/qqmlandroidpopupmenu.cpp new file mode 100644 index 0000000..bf2a32f --- /dev/null +++ b/src/android/widget/qqmlandroidpopupmenu.cpp @@ -0,0 +1,137 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidpopupmenu_p.h" +#include "qtqmlandroidfunctions_p.h" +#include "qqmlandroidmenuitem_p.h" +#include "qqmlandroidcontext_p.h" +#include "qqmlandroidview_p.h" +#include + +QT_BEGIN_NAMESPACE + +QQmlAndroidPopupMenu::QQmlAndroidPopupMenu(QObject *parent) : + QQmlAndroidObject(parent), m_anchor(0) +{ +} + +QList QQmlAndroidPopupMenu::items() const +{ + QList lst; + foreach (QObject *child, children()) { + QQmlAndroidMenuItem *item = qobject_cast(child); + if (item) + lst += item; + } + return lst; +} + +QQmlAndroidView *QQmlAndroidPopupMenu::anchor() const +{ + return m_anchor; +} + +void QQmlAndroidPopupMenu::setAnchor(QQmlAndroidView *anchor) +{ + if (m_anchor != anchor) { + m_anchor = anchor; + emit anchorChanged(); + } +} + +int QQmlAndroidPopupMenu::gravity() const +{ + if (m_gravity.isNull()) + return 0; // TODO + return m_gravity; +} + +void QQmlAndroidPopupMenu::setGravity(int value) +{ + if (value != gravity()) { + m_gravity = value; + emit gravityChanged(); + } +} + +void QQmlAndroidPopupMenu::show() +{ + QQmlAndroidView *anchor = m_anchor ? m_anchor : qobject_cast(parent()); + if (!anchor) { + qWarning() << "PopupMenu parent must be either anchored or in a view."; + return; + } + + QQmlAndroidContext *context = anchor->context(); + if (!context) { + qWarning() << "PopupMenu is not ready - no context."; + return; + } + + QAndroidJniObject c = context->instance(); + QAndroidJniObject a = anchor->instance(); + + QtQmlAndroid::callFunction([=]() { + QAndroidJniObject popup; + if (!m_gravity.isNull()) { + popup = QAndroidJniObject("android/widget/PopupMenu", + "(Landroid/content/Context;Landroid/view/View;I)V", + c.object(), a.object(), m_gravity); + } else { + popup = QAndroidJniObject("android/widget/PopupMenu", + "(Landroid/content/Context;Landroid/view/View;)V", + c.object(), a.object()); + } + inflate(popup); + + QAndroidJniObject menu = popup.callObjectMethod("getMenu", "()Landroid/view/Menu;"); + foreach (QQmlAndroidMenuItem *item, items()) { + QAndroidJniObject it = menu.callObjectMethod("add", + "(Ljava/lang/CharSequence;)Landroid/view/MenuItem;", + QAndroidJniObject::fromString(item->title()).object()); + //it.callMethod("..."); + } + + popup.callMethod("show"); + }); +} + +void QQmlAndroidPopupMenu::dismiss() +{ + QtQmlAndroid::callVoidMethod(instance(), "dismiss"); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidpopupmenu_p.h b/src/android/widget/qqmlandroidpopupmenu_p.h new file mode 100644 index 0000000..1f96d7b --- /dev/null +++ b/src/android/widget/qqmlandroidpopupmenu_p.h @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDPOPUPMENU_P_H +#define QQMLANDROIDPOPUPMENU_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class QQmlAndroidView; +class QQmlAndroidMenuItem; + +class Q_QMLANDROID_EXPORT QQmlAndroidPopupMenu : public QQmlAndroidObject +{ + Q_OBJECT + Q_PROPERTY(QQmlAndroidView *anchor READ anchor WRITE setAnchor NOTIFY anchorChanged) + Q_PROPERTY(int gravity READ gravity WRITE setGravity NOTIFY gravityChanged) + +public: + explicit QQmlAndroidPopupMenu(QObject *parent = nullptr); + + QList items() const; + + QQmlAndroidView *anchor() const; + void setAnchor(QQmlAndroidView *anchor); + + int gravity() const; + void setGravity(int gravity); + +public Q_SLOTS: + void show(); + void dismiss(); + +Q_SIGNALS: + void anchorChanged(); + void gravityChanged(); + void dismissed(); + void itemClick(); + +private: + QQmlAndroidView *m_anchor; + QQmlAndroidOptional m_gravity; + QAndroidJniObject m_listener; +}; + +QT_END_NAMESPACE + +#endif // QQMLANDROIDPOPUPMENU_P_H diff --git a/src/android/widget/qqmlandroidprogressbar.cpp b/src/android/widget/qqmlandroidprogressbar.cpp new file mode 100644 index 0000000..c5871c9 --- /dev/null +++ b/src/android/widget/qqmlandroidprogressbar.cpp @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qqmlandroidprogressbar_p.h" +#include "qtqmlandroidfunctions_p.h" + +QT_BEGIN_NAMESPACE + +QQmlAndroidProgressBar::QQmlAndroidProgressBar(QQmlAndroidView *parent) : + QQmlAndroidView(parent), m_max(100), m_progress(0), m_secondary(0), m_indeterminate(false) +{ +} + +bool QQmlAndroidProgressBar::isIndeterminate() const +{ + return m_indeterminate; +} + +void QQmlAndroidProgressBar::setIndeterminate(bool indeterminate) +{ + if (m_indeterminate != indeterminate) { + m_indeterminate = indeterminate; + QtQmlAndroid::callBoolMethod(instance(), "setIndeterminate", indeterminate); + emit indeterminateChanged(); + } +} + +int QQmlAndroidProgressBar::progress() const +{ + return m_progress; +} + +void QQmlAndroidProgressBar::setProgress(int progress) +{ + if (updateProgress(progress)) + QtQmlAndroid::callIntMethod(instance(), "setProgress", progress); +} + +bool QQmlAndroidProgressBar::updateProgress(int progress) +{ + if (m_progress != progress) { + m_progress = progress; + emit progressChanged(); + return true; + } + return false; +} + +int QQmlAndroidProgressBar::secondaryProgress() const +{ + return m_secondary; +} + +void QQmlAndroidProgressBar::setSecondaryProgress(int progress) +{ + if (m_secondary != progress) { + m_secondary = progress; + QtQmlAndroid::callIntMethod(instance(), "setSecondaryProgress", progress); + emit secondaryProgressChanged(); + } +} + +int QQmlAndroidProgressBar::max() const +{ + return m_max; +} + +void QQmlAndroidProgressBar::setMax(int max) +{ + if (m_max != max) { + m_max = max; + QtQmlAndroid::callIntMethod(instance(), "setMax", max); + emit maxChanged(); + } +} + +QQmlAndroidProgressBar::Style QQmlAndroidProgressBar::style() const +{ + if (m_style.isNull()) + return Medium; + return m_style; +} + +void QQmlAndroidProgressBar::setStyle(Style style) +{ + m_style = style; // TODO: warning after construction or re-construct? +} + +QAndroidJniObject QQmlAndroidProgressBar::onCreate() +{ + return QAndroidJniObject("android/widget/ProgressBar", + "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", + ctx().object(), 0, style()); +} + +void QQmlAndroidProgressBar::onInflate(QAndroidJniObject &instance) +{ + QQmlAndroidView::onInflate(instance); + + if (m_progress > 0) + instance.callMethod("setProgress", "(I)V", m_progress); + if (m_secondary > 0) + instance.callMethod("setSecondaryProgress", "(I)V", m_secondary); + if (m_indeterminate) + instance.callMethod("setIndeterminate", "(Z)V", m_indeterminate); + if (m_max != 100) + instance.callMethod("setMax", "(I)V", m_max); +} + +QT_END_NAMESPACE diff --git a/src/android/widget/qqmlandroidprogressbar_p.h b/src/android/widget/qqmlandroidprogressbar_p.h new file mode 100644 index 0000000..ddd54b0 --- /dev/null +++ b/src/android/widget/qqmlandroidprogressbar_p.h @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the Qt QML Android module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQMLANDROIDPROGRESSBAR_P_H +#define QQMLANDROIDPROGRESSBAR_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include + +QT_BEGIN_NAMESPACE + +class Q_QMLANDROID_EXPORT QQmlAndroidProgressBar : public QQmlAndroidView +{ + Q_OBJECT + Q_PROPERTY(bool indeterminate READ isIndeterminate WRITE setIndeterminate NOTIFY indeterminateChanged) + Q_PROPERTY(int progress READ progress WRITE setProgress NOTIFY progressChanged) + Q_PROPERTY(int secondaryProgress READ secondaryProgress WRITE setSecondaryProgress NOTIFY secondaryProgressChanged) + Q_PROPERTY(int max READ max WRITE setMax NOTIFY maxChanged) + Q_PROPERTY(Style style READ style WRITE setStyle) + Q_ENUMS(Style) + +public: + explicit QQmlAndroidProgressBar(QQmlAndroidView *parent = nullptr); + + bool isIndeterminate() const; + void setIndeterminate(bool indeterminate); + + int progress() const; + void setProgress(int progress); + + int secondaryProgress() const; + void setSecondaryProgress(int progress); + + int max() const; + void setMax(int max); + + enum Style { + Medium = 16842871, + Horizontal = 16842872, + MediumInverse = 16843399, + Large = 16842874, + LargeInverse = 16843401, + Small = 16842873, + SmallInverse = 16843400, + SmallTitle = 16843279 + }; + + Style style() const; + void setStyle(Style style); + +Q_SIGNALS: + void indeterminateChanged(); + void progressChanged(); + void secondaryProgressChanged(); + void maxChanged(); + +protected: + QAndroidJniObject onCreate() override; + void onInflate(QAndroidJniObject &instance) override; + +private Q_SLOTS: + bool updateProgress(int progress); + +private: + int m_max; + int m_progress; + int m_secondary; + bool m_indeterminate; + QQmlAndroidOptional