Subversion Repositories tpanel

Rev

Rev 369 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 369 Rev 383
Line 1583... Line 1583...
1583
    MSG_DEBUG("User orientation: " << orientationToString((Qt::ScreenOrientation)currentOrientation));
1583
    MSG_DEBUG("User orientation: " << orientationToString((Qt::ScreenOrientation)currentOrientation));
1584
#else
1584
#else
1585
    Q_UNUSED(currentOrientation);
1585
    Q_UNUSED(currentOrientation);
1586
#endif
1586
#endif
1587
}
1587
}
-
 
1588
 
1588
/**
1589
/**
1589
 * @brief MainWindow::onPositionUpdated
1590
 * @brief MainWindow::onPositionUpdated
1590
 * This method is a callback function for the Qt framework. It is called
1591
 * This method is a callback function for the Qt framework. It is called
1591
 * whenever the geo position changes. The position information is never really
1592
 * whenever the geo position changes. The position information is never really
1592
 * used and is implemented only to keep the application on IOS running in the
1593
 * used and is implemented only to keep the application on IOS running in the
Line 1622... Line 1623...
1622
#endif
1623
#endif
1623
/**
1624
/**
1624
 * @brief Displays or hides a phone dialog window.
1625
 * @brief Displays or hides a phone dialog window.
1625
 * This method creates and displays a phone dialog window containing everything
1626
 * This method creates and displays a phone dialog window containing everything
1626
 * a simple phone needs. Depending on the parameter \p state the dialog is
1627
 * a simple phone needs. Depending on the parameter \p state the dialog is
1627
 * created or an exeisting dialog is closed.
1628
 * created or an existing dialog is closed.
1628
 * @param state     If TRUE the dialog is created or if it is not visible
1629
 * @param state     If TRUE the dialog is created or if it is not visible
1629
 * brought to front and is made visible.
1630
 * brought to front and is made visible.
1630
 * If this is FALSE an existing dialog window is destroid and disappears. If
1631
 * If this is FALSE an existing dialog window is destroid and disappears. If
1631
 * the window didn't exist nothing happens.
1632
 * the window didn't exist nothing happens.
1632
 */
1633
 */
Line 2660... Line 2661...
2660
#endif
2661
#endif
2661
        break;
2662
        break;
2662
#endif
2663
#endif
2663
        case Qt::ApplicationActive:
2664
        case Qt::ApplicationActive:
2664
            MSG_INFO("Switched to mode ACTIVE");
2665
            MSG_INFO("Switched to mode ACTIVE");
2665
/*
-
 
2666
#ifdef Q_OS_ANDROID
-
 
2667
            // On Android we must give the surface some time to recover.
-
 
2668
            // Otherwise it may freeze or stay black and the app doesn't
-
 
2669
            // react any more.
-
 
2670
            std::this_thread::sleep_for(std::chrono::seconds(1));
-
 
2671
#endif
-
 
2672
*/
-
 
2673
            mHasFocus = true;
2666
            mHasFocus = true;
2674
 
2667
 
2675
            if (!isRunning && gPageManager)
2668
            if (!isRunning && gPageManager)
2676
            {
2669
            {
2677
                // Start the core application
2670
                // Start the core application
Line 2729... Line 2722...
2729
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && defined(Q_OS_ANDROID)
2722
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && defined(Q_OS_ANDROID)
2730
                _freezeWorkaround();
2723
                _freezeWorkaround();
2731
#endif
2724
#endif
2732
//                playShowList();
2725
//                playShowList();
2733
 
2726
 
2734
//                if (mDoRepaint && mWasInactive)
2727
                if (mDoRepaint || mWasInactive)
2735
//                    repaintObjects();
2728
                    repaintObjects();
2736
 
2729
 
2737
                mDoRepaint = false;
2730
                mDoRepaint = false;
2738
                mWasInactive = false;
2731
                mWasInactive = false;
2739
            }
2732
            }
2740
#ifdef Q_OS_ANDROID
2733
#ifdef Q_OS_ANDROID
Line 2814... Line 2807...
2814
 
2807
 
2815
void MainWindow::_displayButton(ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top, bool passthrough)
2808
void MainWindow::_displayButton(ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top, bool passthrough)
2816
{
2809
{
2817
    DECL_TRACER("MainWindow::_displayButton(ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top, bool passthrough)");
2810
    DECL_TRACER("MainWindow::_displayButton(ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top, bool passthrough)");
2818
 
2811
 
2819
    if (prg_stopped || ! mHasFocus)
2812
    if (prg_stopped)
-
 
2813
        return;
-
 
2814
 
-
 
2815
    if (!mHasFocus)
-
 
2816
    {
-
 
2817
        markDirty(handle);
2820
        return;
2818
        return;
-
 
2819
    }
-
 
2820
 
2821
/*
2821
/*
2822
    if (!mHasFocus)     // Suspended?
2822
    if (!mHasFocus)     // Suspended?
2823
    {
2823
    {
2824
        addButton(handle, parent, buffer, left, top, width, height, passthrough);
2824
        addButton(handle, parent, buffer, left, top, width, height, passthrough);
2825
        return;
2825
        return;
Line 2830... Line 2830...
2830
 
2830
 
2831
void MainWindow::_displayViewButton(ulong handle, ulong parent, bool vertical, TBitmap buffer, int width, int height, int left, int top, int space, TColor::COLOR_T fillColor)
2831
void MainWindow::_displayViewButton(ulong handle, ulong parent, bool vertical, TBitmap buffer, int width, int height, int left, int top, int space, TColor::COLOR_T fillColor)
2832
{
2832
{
2833
    DECL_TRACER("MainWindow::_displayViewButton(ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top)");
2833
    DECL_TRACER("MainWindow::_displayViewButton(ulong handle, ulong parent, TBitmap buffer, int width, int height, int left, int top)");
2834
 
2834
 
2835
    if (prg_stopped || !mHasFocus)
2835
    if (prg_stopped)
-
 
2836
        return;
-
 
2837
 
-
 
2838
    if (!mHasFocus)
-
 
2839
    {
-
 
2840
        markDirty(handle);
2836
        return;
2841
        return;
-
 
2842
    }
-
 
2843
 
2837
/*
2844
/*
2838
    if (!mHasFocus)     // Suspended?
2845
    if (!mHasFocus)     // Suspended?
2839
    {
2846
    {
2840
        addViewButton(handle, parent, vertical, buffer, left, top, width, height, space, fillColor);
2847
        addViewButton(handle, parent, vertical, buffer, left, top, width, height, space, fillColor);
2841
        return;
2848
        return;
Line 2846... Line 2853...
2846
 
2853
 
2847
void MainWindow::_addViewButtonItems(ulong parent, vector<PGSUBVIEWITEM_T> items)
2854
void MainWindow::_addViewButtonItems(ulong parent, vector<PGSUBVIEWITEM_T> items)
2848
{
2855
{
2849
    DECL_TRACER("MainWindow::_addViewButtonItems(ulong parent, vector<PGSUBVIEWITEM_T> items)");
2856
    DECL_TRACER("MainWindow::_addViewButtonItems(ulong parent, vector<PGSUBVIEWITEM_T> items)");
2850
 
2857
 
2851
    if (prg_stopped || !mHasFocus)
2858
    if (prg_stopped)
2852
        return;
2859
        return;
2853
 
2860
 
2854
    emit sigAddViewButtonItems(parent, items);
2861
    emit sigAddViewButtonItems(parent, items);
2855
}
2862
}
2856
 
2863
 
Line 2859... Line 2866...
2859
    DECL_TRACER("MainWindow::_updateViewButton(ulong handle, ulong parent, TBitmap buffer, TColor::COLOR_T fillColor)");
2866
    DECL_TRACER("MainWindow::_updateViewButton(ulong handle, ulong parent, TBitmap buffer, TColor::COLOR_T fillColor)");
2860
 
2867
 
2861
    if (prg_stopped || !mHasFocus)
2868
    if (prg_stopped || !mHasFocus)
2862
        return;
2869
        return;
2863
 
2870
 
2864
//    try
2871
    if (!mHasFocus)
2865
//    {
2872
    {
2866
        emit sigUpdateViewButton(handle, parent, buffer, fillColor);
2873
        markDirty(handle);
2867
//    }
2874
        return;
2868
//    catch (std::exception& e)
-
 
2869
//    {
2875
    }
-
 
2876
 
2870
//        MSG_ERROR("Error triggering function \"updateViewButton()\": " << e.what());
2877
    emit sigUpdateViewButton(handle, parent, buffer, fillColor);
2871
//    }
-
 
2872
}
2878
}
2873
 
2879
 
2874
void MainWindow::_updateViewButtonItem(PGSUBVIEWITEM_T& item, ulong parent)
2880
void MainWindow::_updateViewButtonItem(PGSUBVIEWITEM_T& item, ulong parent)
2875
{
2881
{
2876
    DECL_TRACER("MainWindow::_updateViewButtonItem(PGSUBVIEWITEM_T& item, ulong parent)");
2882
    DECL_TRACER("MainWindow::_updateViewButtonItem(PGSUBVIEWITEM_T& item, ulong parent)");
2877
 
2883
 
2878
    if (prg_stopped || !mHasFocus)
2884
    if (prg_stopped || !mHasFocus)
2879
        return;
2885
        return;
2880
 
2886
 
2881
//    try
-
 
2882
//    {
-
 
2883
        emit sigUpdateViewButtonItem(item, parent);
2887
    emit sigUpdateViewButtonItem(item, parent);
2884
//    }
-
 
2885
//    catch (std::exception& e)
-
 
2886
//    {
-
 
2887
//        MSG_ERROR("Error triggering function \"updateViewButtonItem()\": " << e.what());
-
 
2888
//    }
-
 
2889
}
2888
}
2890
 
2889
 
2891
void MainWindow::_showViewButtonItem(ulong handle, ulong parent, int position, int timer)
2890
void MainWindow::_showViewButtonItem(ulong handle, ulong parent, int position, int timer)
2892
{
2891
{
2893
    DECL_TRACER("MainWindow::_showViewButtonItem(ulong handle, ulong parent, int position, int timer)");
2892
    DECL_TRACER("MainWindow::_showViewButtonItem(ulong handle, ulong parent, int position, int timer)");
2894
 
2893
 
2895
    if (prg_stopped || !mHasFocus)
2894
    if (prg_stopped)
2896
        return;
2895
        return;
2897
 
2896
 
2898
//    try
2897
    if (!mHasFocus)
2899
//    {
2898
    {
2900
        emit sigShowViewButtonItem(handle, parent, position, timer);
2899
        markDirty(handle);
2901
//    }
2900
        return;
2902
//    catch (std::exception& e)
-
 
2903
//    {
2901
    }
-
 
2902
 
2904
//        MSG_ERROR("Error triggering function \"showViewButtonItem()\": " << e.what());
2903
    emit sigShowViewButtonItem(handle, parent, position, timer);
2905
//    }
-
 
2906
}
2904
}
2907
 
2905
 
2908
void MainWindow::_hideAllViewItems(ulong handle)
2906
void MainWindow::_hideAllViewItems(ulong handle)
2909
{
2907
{
2910
    DECL_TRACER("MainWindow::_hideAllViewItems(ulong handle)");
2908
    DECL_TRACER("MainWindow::_hideAllViewItems(ulong handle)");
Line 2917... Line 2915...
2917
 
2915
 
2918
void MainWindow::_toggleViewButtonItem(ulong handle, ulong parent, int position, int timer)
2916
void MainWindow::_toggleViewButtonItem(ulong handle, ulong parent, int position, int timer)
2919
{
2917
{
2920
    DECL_TRACER("MainWindow::_toggleViewButtonItem(ulong handle, ulong parent, int position, int timer)");
2918
    DECL_TRACER("MainWindow::_toggleViewButtonItem(ulong handle, ulong parent, int position, int timer)");
2921
 
2919
 
2922
    if (prg_stopped || !mHasFocus)
2920
    if (prg_stopped)
-
 
2921
        return;
-
 
2922
 
-
 
2923
    if (!mHasFocus)
-
 
2924
    {
-
 
2925
        markDirty(handle);
2923
        return;
2926
        return;
-
 
2927
    }
2924
 
2928
 
2925
    emit sigToggleViewButtonItem(handle, parent, position, timer);
2929
    emit sigToggleViewButtonItem(handle, parent, position, timer);
2926
}
2930
}
2927
 
2931
 
2928
void MainWindow::_hideViewItem(ulong handle, ulong parent)
2932
void MainWindow::_hideViewItem(ulong handle, ulong parent)
Line 2993... Line 2997...
2993
void MainWindow::_setBackground(ulong handle, TBitmap image, int width, int height, ulong color, int opacity)
2997
void MainWindow::_setBackground(ulong handle, TBitmap image, int width, int height, ulong color, int opacity)
2994
#endif
2998
#endif
2995
{
2999
{
2996
    DECL_TRACER("MainWindow::_setBackground(ulong handle, TBitmap image, int width, int height, ulong color [, int opacity])");
3000
    DECL_TRACER("MainWindow::_setBackground(ulong handle, TBitmap image, int width, int height, ulong color [, int opacity])");
2997
 
3001
 
2998
    if (prg_stopped || !mHasFocus)
3002
    if (prg_stopped)
2999
        return;
3003
        return;
-
 
3004
 
-
 
3005
    if (!mHasFocus)
-
 
3006
    {
-
 
3007
        markDirty(handle);
-
 
3008
        return;
-
 
3009
    }
-
 
3010
 
3000
/*
3011
/*
3001
    if (!mHasFocus)
3012
    if (!mHasFocus)
3002
    {
3013
    {
3003
#ifdef _OPAQUE_SKIA_
3014
#ifdef _OPAQUE_SKIA_
3004
        addBackground(handle, image, width, height, color);
3015
        addBackground(handle, image, width, height, color);
Line 3052... Line 3063...
3052
}
3063
}
3053
 
3064
 
3054
void MainWindow::_dropButton(ulong handle)
3065
void MainWindow::_dropButton(ulong handle)
3055
{
3066
{
3056
    DECL_TRACER("MainWindow::_dropButton(ulong handle)");
3067
    DECL_TRACER("MainWindow::_dropButton(ulong handle)");
3057
/*
3068
 
3058
    if (!mHasFocus)
3069
    if (!mHasFocus)
3059
    {
3070
    {
3060
        markDrop(handle);
3071
        markDrop(handle);
3061
        return;
3072
        return;
3062
    }
3073
    }
3063
*/
3074
 
3064
    if (mHasFocus)
-
 
3065
        emit sigDropButton(handle);
3075
    emit sigDropButton(handle);
3066
}
3076
}
3067
 
3077
 
3068
void MainWindow::_playVideo(ulong handle, ulong parent, int left, int top, int width, int height, const string& url, const string& user, const string& pw)
3078
void MainWindow::_playVideo(ulong handle, ulong parent, int left, int top, int width, int height, const string& url, const string& user, const string& pw)
3069
{
3079
{
3070
    DECL_TRACER("MainWindow::_playVideo(ulong handle, const string& url)");
3080
    DECL_TRACER("MainWindow::_playVideo(ulong handle, const string& url)");
Line 3142... Line 3152...
3142
 
3152
 
3143
void MainWindow::_showKeypad(const std::string& init, const std::string& prompt, bool priv)
3153
void MainWindow::_showKeypad(const std::string& init, const std::string& prompt, bool priv)
3144
{
3154
{
3145
    DECL_TRACER("MainWindow::_showKeypad(std::string &init, std::string &prompt, bool priv)");
3155
    DECL_TRACER("MainWindow::_showKeypad(std::string &init, std::string &prompt, bool priv)");
3146
 
3156
 
3147
    if (prg_stopped || mHasFocus)
3157
    if (prg_stopped || !mHasFocus)
3148
        return;
3158
        return;
3149
 
3159
 
3150
    doReleaseButton();
3160
    doReleaseButton();
3151
    emit sigKeypad(init, prompt, priv);
3161
    emit sigKeypad(init, prompt, priv);
3152
}
3162
}
Line 3343... Line 3353...
3343
    {
3353
    {
3344
        MSG_WARNING("Invalid parameters for scroll area!");
3354
        MSG_WARNING("Invalid parameters for scroll area!");
3345
        return;
3355
        return;
3346
    }
3356
    }
3347
 
3357
 
3348
    if (mHasFocus)
3358
    if (!mHasFocus)
-
 
3359
    {
-
 
3360
        markDirty(handle);
-
 
3361
        return;
-
 
3362
    }
-
 
3363
 
3349
        emit sigListViewArea(handle, parent, button, list);
3364
    emit sigListViewArea(handle, parent, button, list);
3350
}
3365
}
3351
 
3366
 
3352
void MainWindow::doReleaseButton()
3367
void MainWindow::doReleaseButton()
3353
{
3368
{
3354
    DECL_TRACER("MainWindow::doReleaseButton()");
3369
    DECL_TRACER("MainWindow::doReleaseButton()");
Line 3370... Line 3385...
3370
    }
3385
    }
3371
}
3386
}
3372
 
3387
 
3373
/**
3388
/**
3374
 * @brief MainWindow::repaintObjects
3389
 * @brief MainWindow::repaintObjects
3375
 * On a mobile device it is possible that the content, mostly the background, of
3390
 * If the application was suspended, which is only on mobile devices possible,
3376
 * a window becomes destroyed and it is not repainted. This may be the case at
3391
 * the surface can't be drawn. If there was a change on a visible object it
3377
 * the moment where the device was disconnected from the controller and
3392
 * was marked "dirty". This methos searches for all dirty marked objects and
3378
 * reconnected while the application was inactive. In such a case usualy the
3393
 * asks the TPageManager to resend the last drawn graphic of the object. If the
3379
 * surface is completely repainted. But because of inactivity this was not
3394
 * object was a page or subpage, the whole page or subpage is redrawn. Otherwise
3380
 * possible and some components may look destroyed. They are still functional
-
 
3381
 * allthough.
3395
 * only the changed object.
3382
 */
3396
 */
3383
void MainWindow::repaintObjects()
3397
void MainWindow::repaintObjects()
3384
{
3398
{
3385
    DECL_TRACER("MainWindow::repaintObjects()");
3399
    DECL_TRACER("MainWindow::repaintObjects()");
3386
 
3400
 
3387
//    TLOCKER(draw_mutex);
-
 
3388
#ifdef Q_OS_ANDROID
-
 
3389
    std::this_thread::sleep_for(std::chrono::milliseconds(200));    // Necessary for slow devices
-
 
3390
#endif
-
 
3391
    TObject::OBJECT_t *obj = findFirstWindow();
3401
    TObject::OBJECT_t *obj = getFirstDirty();
3392
 
3402
 
3393
    while (obj)
3403
    while (obj)
3394
    {
3404
    {
3395
        if (!obj->remove && !obj->invalid && obj->object.widget)
3405
        if (!obj->remove && !obj->invalid && obj->dirty)
3396
        {
3406
        {
3397
            MSG_PROTOCOL("Refreshing widget " << handleToString (obj->handle));
3407
            MSG_PROTOCOL("Refreshing widget " << handleToString (obj->handle));
-
 
3408
 
-
 
3409
            if (gPageManager)
-
 
3410
                gPageManager->redrawObject(obj->handle);
-
 
3411
 
3398
            obj->object.widget->repaint();
3412
            obj->dirty = false;
3399
        }
3413
        }
3400
 
3414
 
3401
        obj = findNextWindow(obj);
3415
        obj = getNextDirty(obj);
3402
    }
3416
    }
3403
}
3417
}
3404
 
3418
 
3405
void MainWindow::refresh(ulong handle)
3419
void MainWindow::refresh(ulong handle)
3406
{
3420
{
Line 3440... Line 3454...
3440
 
3454
 
3441
        obj = findNextChild(obj->handle);
3455
        obj = findNextChild(obj->handle);
3442
    }
3456
    }
3443
}
3457
}
3444
 
3458
 
-
 
3459
void MainWindow::markDirty(ulong handle)
-
 
3460
{
-
 
3461
    DECL_TRACER("MainWindow::markDirty(ulong handle)");
-
 
3462
 
-
 
3463
    OBJECT_t *obj = findObject(handle);
-
 
3464
 
-
 
3465
    if (!obj)
-
 
3466
        return;
-
 
3467
 
-
 
3468
    MSG_DEBUG("Object " << handleToString(handle) << " marked dirty.");
-
 
3469
    obj->dirty = true;
-
 
3470
}
3445
 
3471
 
3446
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
3472
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
3447
int MainWindow::calcVolume(int value)
3473
int MainWindow::calcVolume(int value)
3448
#else
3474
#else
3449
double MainWindow::calcVolume(int value)
3475
double MainWindow::calcVolume(int value)