Subversion Repositories tpanel

Rev

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

Rev 141 Rev 142
Line 377... Line 377...
377
    gPageManager->regSetPhoneStatus(bind(&MainWindow::_setPhoneStatus, this, std::placeholders::_1));
377
    gPageManager->regSetPhoneStatus(bind(&MainWindow::_setPhoneStatus, this, std::placeholders::_1));
378
    gPageManager->regSetPhoneState(bind(&MainWindow::_setPhoneState, this, std::placeholders::_1, std::placeholders::_2));
378
    gPageManager->regSetPhoneState(bind(&MainWindow::_setPhoneState, this, std::placeholders::_1, std::placeholders::_2));
379
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
379
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
380
    gPageManager->regOnOrientationChange(bind(&MainWindow::_orientationChanged, this, std::placeholders::_1));
380
    gPageManager->regOnOrientationChange(bind(&MainWindow::_orientationChanged, this, std::placeholders::_1));
381
#endif
381
#endif
-
 
382
    gPageManager->regRepaintWindows(bind(&MainWindow::_repaintWindows, this));
-
 
383
 
382
    gPageManager->deployCallbacks();
384
    gPageManager->deployCallbacks();
383
    createActions();
385
    createActions();
384
 
386
 
385
#ifndef QT_NO_SESSIONMANAGER
387
#ifndef QT_NO_SESSIONMANAGER
386
    QGuiApplication::setFallbackSessionManagementEnabled(false);
388
    QGuiApplication::setFallbackSessionManagementEnabled(false);
Line 417... Line 419...
417
        connect(this, &MainWindow::sigSendVirtualKeys, this, &MainWindow::sendVirtualKeys);
419
        connect(this, &MainWindow::sigSendVirtualKeys, this, &MainWindow::sendVirtualKeys);
418
        connect(this, &MainWindow::sigShowPhoneDialog, this, &MainWindow::showPhoneDialog);
420
        connect(this, &MainWindow::sigShowPhoneDialog, this, &MainWindow::showPhoneDialog);
419
        connect(this, &MainWindow::sigSetPhoneNumber, this, &MainWindow::setPhoneNumber);
421
        connect(this, &MainWindow::sigSetPhoneNumber, this, &MainWindow::setPhoneNumber);
420
        connect(this, &MainWindow::sigSetPhoneStatus, this, &MainWindow::setPhoneStatus);
422
        connect(this, &MainWindow::sigSetPhoneStatus, this, &MainWindow::setPhoneStatus);
421
        connect(this, &MainWindow::sigSetPhoneState, this, &MainWindow::setPhoneState);
423
        connect(this, &MainWindow::sigSetPhoneState, this, &MainWindow::setPhoneState);
-
 
424
        connect(this, &MainWindow::sigRepaintWindows, this, &MainWindow::repaintWindows);
422
        connect(qApp, &QGuiApplication::applicationStateChanged, this, &MainWindow::appStateChanged);
425
        connect(qApp, &QGuiApplication::applicationStateChanged, this, &MainWindow::appStateChanged);
423
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
426
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
424
        QScreen *screen = QGuiApplication::primaryScreen();
427
        QScreen *screen = QGuiApplication::primaryScreen();
425
        connect(screen, &QScreen::orientationChanged, this, &MainWindow::onScreenOrientationChanged);
428
        connect(screen, &QScreen::orientationChanged, this, &MainWindow::onScreenOrientationChanged);
426
#endif
429
#endif
Line 531... Line 534...
531
            _setOrientation((J_ORIENTATION)orientation);
534
            _setOrientation((J_ORIENTATION)orientation);
532
    }
535
    }
533
}
536
}
534
#endif
537
#endif
535
 
538
 
-
 
539
void MainWindow::_repaintWindows()
-
 
540
{
-
 
541
    DECL_TRACER("MainWindow::_repaintWindows()");
-
 
542
 
-
 
543
    emit repaintWindows();
-
 
544
}
536
/**
545
/**
537
 * @brief MainWindow::closeEvent called when the application receives an exit event.
546
 * @brief MainWindow::closeEvent called when the application receives an exit event.
538
 *
547
 *
539
 * If the user clicks on the exit icon or on the menu point _Exit_ this method
548
 * If the user clicks on the exit icon or on the menu point _Exit_ this method
540
 * is called. It makes sure everything is written to the configuration file
549
 * is called. It makes sure everything is written to the configuration file
Line 1046... Line 1055...
1046
    std::string msg = "Simulation of an AMX G4 panel\n";
1055
    std::string msg = "Simulation of an AMX G4 panel\n";
1047
    msg.append("Version v").append(VERSION_STRING()).append("\n");
1056
    msg.append("Version v").append(VERSION_STRING()).append("\n");
1048
    msg.append("(C) Copyright 2020 to 2022 by Andreas Theofilu <andreas@theosys.at>\n");
1057
    msg.append("(C) Copyright 2020 to 2022 by Andreas Theofilu <andreas@theosys.at>\n");
1049
    msg.append("This program is under the terms of GPL version 3");
1058
    msg.append("This program is under the terms of GPL version 3");
1050
 
1059
 
1051
    QMessageBox::about(this, tr(std::string("About ").append(TConfig::getProgName()).c_str()),
1060
    QMessageBox::about(this, tr("About TPanel"),
1052
                       tr(msg.c_str()));
1061
                       tr(msg.c_str()));
1053
}
1062
}
1054
 
1063
 
1055
void MainWindow::arrowUp()
1064
void MainWindow::arrowUp()
1056
{
1065
{
Line 1267... Line 1276...
1267
 
1276
 
1268
    if (gPageManager)
1277
    if (gPageManager)
1269
        gPageManager->setTextToButton(obj->handle, text.toStdString());
1278
        gPageManager->setTextToButton(obj->handle, text.toStdString());
1270
}
1279
}
1271
 
1280
 
-
 
1281
void MainWindow::repaintWindows()
-
 
1282
{
-
 
1283
    DECL_TRACER("MainWindow::repaintWindows()");
-
 
1284
 
-
 
1285
    if (mWasInactive)
-
 
1286
        mDoRepaint = true;
-
 
1287
}
-
 
1288
 
1272
/**
1289
/**
1273
 * @brief MainWindow::appStateChanged - Is called whenever the state of the app changes.
1290
 * @brief MainWindow::appStateChanged - Is called whenever the state of the app changes.
1274
 * This callback method is called whenever the state of the application
1291
 * This callback method is called whenever the state of the application
1275
 * changes. This is mostly usefull on mobile devices. Whenever the main window
1292
 * changes. This is mostly usefull on mobile devices. Whenever the main window
1276
 * looses the focus (screen closed, application is put into background, ...)
1293
 * looses the focus (screen closed, application is put into background, ...)
Line 1294... Line 1311...
1294
        break;
1311
        break;
1295
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)      // On a normal desktop we can ignore this signals
1312
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)      // On a normal desktop we can ignore this signals
1296
        case Qt::ApplicationInactive:
1313
        case Qt::ApplicationInactive:
1297
            MSG_INFO("Switched to mode INACTIVE");
1314
            MSG_INFO("Switched to mode INACTIVE");
1298
            mHasFocus = false;
1315
            mHasFocus = false;
-
 
1316
            mWasInactive = true;
1299
            QAndroidJniObject::callStaticMethod<void>("org/qtproject/theosys/Orientation", "pauseOrientationListener", "()V");
1317
            QAndroidJniObject::callStaticMethod<void>("org/qtproject/theosys/Orientation", "pauseOrientationListener", "()V");
1300
        break;
1318
        break;
1301
 
1319
 
1302
        case Qt::ApplicationHidden:
1320
        case Qt::ApplicationHidden:
1303
            MSG_INFO("Switched to mode HIDDEN");
1321
            MSG_INFO("Switched to mode HIDDEN");
Line 1313... Line 1331...
1313
            {
1331
            {
1314
                // Start the core application
1332
                // Start the core application
1315
                gPageManager->startUp();
1333
                gPageManager->startUp();
1316
                gPageManager->run();
1334
                gPageManager->run();
1317
                isRunning = true;
1335
                isRunning = true;
-
 
1336
                mWasInactive = false;
1318
            }
1337
            }
1319
            else
1338
            else
-
 
1339
            {
1320
                playShowList();
1340
                playShowList();
-
 
1341
 
-
 
1342
                if (mDoRepaint && mWasInactive)
-
 
1343
                    repaintObjects();
-
 
1344
 
-
 
1345
                mDoRepaint = false;
-
 
1346
                mWasInactive = false;
-
 
1347
            }
1321
#ifdef Q_OS_ANDROID
1348
#ifdef Q_OS_ANDROID
1322
            QAndroidJniObject::callStaticMethod<void>("org/qtproject/theosys/Orientation", "resumeOrientationListener", "()V");
1349
            QAndroidJniObject::callStaticMethod<void>("org/qtproject/theosys/Orientation", "resumeOrientationListener", "()V");
1323
#endif
1350
#endif
1324
        break;
1351
        break;
1325
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
1352
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
Line 1713... Line 1740...
1713
    }
1740
    }
1714
 
1741
 
1715
    mLastPressX = mLastPressY = -1;
1742
    mLastPressX = mLastPressY = -1;
1716
}
1743
}
1717
 
1744
 
-
 
1745
/**
-
 
1746
 * @brief MainWindow::repaintObjects
-
 
1747
 * On a mobile device it is possible that the content, mostly the background, of
-
 
1748
 * a window becomes destroyed and it is not repainted. This may be the case at
-
 
1749
 * the moment where the device was disconnected from the controller and
-
 
1750
 * reconnected while the application was inactive. In such a case usualy the
-
 
1751
 * surface is completely repainted. But because of inactivity this was not
-
 
1752
 * possible and some components may look destroyed. They are still functional
-
 
1753
 * allthough.
-
 
1754
 */
-
 
1755
void MainWindow::repaintObjects()
-
 
1756
{
-
 
1757
    DECL_TRACER("MainWindow::repaintObjects()");
-
 
1758
 
-
 
1759
    if (!gObject)
-
 
1760
    {
-
 
1761
        MSG_ERROR(_NO_OBJECT);
-
 
1762
        return;
-
 
1763
    }
-
 
1764
 
-
 
1765
    draw_mutex.lock();
-
 
1766
 
-
 
1767
    TObject::OBJECT_t *obj = gObject->findFirstWindow();
-
 
1768
 
-
 
1769
    while (obj)
-
 
1770
    {
-
 
1771
        if (!obj->remove && obj->object.widget)
-
 
1772
            obj->object.widget->repaint();
-
 
1773
 
-
 
1774
        obj = gObject->findNextWindow(obj);
-
 
1775
    }
-
 
1776
 
-
 
1777
    draw_mutex.unlock();
-
 
1778
}
-
 
1779
 
1718
int MainWindow::calcVolume(int value)
1780
int MainWindow::calcVolume(int value)
1719
{
1781
{
1720
    DECL_TRACER("TQtSettings::calcVolume(int value)");
1782
    DECL_TRACER("TQtSettings::calcVolume(int value)");
1721
 
1783
 
1722
    // volumeSliderValue is in the range [0..100]
1784
    // volumeSliderValue is in the range [0..100]