Subversion Repositories tpanel

Rev

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

Rev 250 Rev 251
Line 70... Line 70...
70
#include <android/log.h>
70
#include <android/log.h>
71
#endif
71
#endif
72
#include "tpagemanager.h"
72
#include "tpagemanager.h"
73
#include "tqtmain.h"
73
#include "tqtmain.h"
74
#include "tconfig.h"
74
#include "tconfig.h"
75
#ifdef QTSETTINGS
75
#if !defined(Q_OS_IOS) && !defined(Q_OS_ANDROID)
76
#include "tqtsettings.h"
76
#include "tqtsettings.h"
77
#endif
77
#endif
78
#include "tqkeyboard.h"
78
#include "tqkeyboard.h"
79
#include "tqkeypad.h"
79
#include "tqkeypad.h"
80
#include "tcolor.h"
80
#include "tcolor.h"
Line 596... Line 596...
596
            MSG_ERROR("Unexpected exception occured [MainWindow::MainWindow()]");
596
            MSG_ERROR("Unexpected exception occured [MainWindow::MainWindow()]");
597
        }
597
        }
598
    }
598
    }
599
#endif
599
#endif
600
#ifdef Q_OS_IOS
600
#ifdef Q_OS_IOS
601
    START_TEMPORARY_TRACE();
-
 
602
    // To get the battery level periodicaly we setup a timer.
601
    // To get the battery level periodicaly we setup a timer.
603
    if (!mIosBattery)
602
    if (!mIosBattery)
604
        mIosBattery = new TIOSBattery;
603
        mIosBattery = new TIOSBattery;
605
 
604
 
606
    mIosBattery->update();
605
    mIosBattery->update();
Line 613... Line 612...
613
        // state will not be visible. To have the state at the moment a button
612
        // state will not be visible. To have the state at the moment a button
614
        // is registered, we tell the page manager to store the values.
613
        // is registered, we tell the page manager to store the values.
615
        gPageManager->setBattery(left, state);
614
        gPageManager->setBattery(left, state);
616
        MSG_DEBUG("Battery state was set to " << left << "% and state " << state);
615
        MSG_DEBUG("Battery state was set to " << left << "% and state " << state);
617
    }
616
    }
618
 
-
 
619
    if (!mBatTimer)
-
 
620
        mBatTimer = new QTimer(this);
-
 
621
 
-
 
622
    connect(mBatTimer, &QTimer::timeout, this, &MainWindow::onBatteryTimeout);
-
 
623
    mBatTimer->start(30000);    // Every 30 seconds
-
 
624
    END_TEMPORARY_LOG();
-
 
625
#endif  // Q_OS_IOS
617
#endif  // Q_OS_IOS
626
 
618
 
627
    _restart_ = false;
619
    _restart_ = false;
628
}
620
}
629
 
621
 
Line 1304... Line 1296...
1304
 * @brief MainWindow::settings initiates the configuration dialog.
1296
 * @brief MainWindow::settings initiates the configuration dialog.
1305
 */
1297
 */
1306
void MainWindow::settings()
1298
void MainWindow::settings()
1307
{
1299
{
1308
    DECL_TRACER("MainWindow::settings()");
1300
    DECL_TRACER("MainWindow::settings()");
1309
#ifndef QTSETTINGS
1301
#if defined(Q_OS_IOS) || defined(Q_OS_ANDROID)
1310
#ifndef Q_OS_IOS
1302
#ifndef Q_OS_IOS
1311
    if (gPageManager)
1303
    if (gPageManager)
1312
    {
1304
    {
1313
        gPageManager->showSetup();
1305
        gPageManager->showSetup();
1314
        return;
1306
        return;
Line 1326... Line 1318...
1326
    string oldSurface = TConfig::getFtpSurface();
1318
    string oldSurface = TConfig::getFtpSurface();
1327
    bool oldToolbar = TConfig::getToolbarForce();
1319
    bool oldToolbar = TConfig::getToolbarForce();
1328
    bool oldToolbarSuppress = TConfig::getToolbarSuppress();
1320
    bool oldToolbarSuppress = TConfig::getToolbarSuppress();
1329
    // Initialize and open the settings dialog.
1321
    // Initialize and open the settings dialog.
1330
    TQtSettings *dlg_settings = new TQtSettings(this);
1322
    TQtSettings *dlg_settings = new TQtSettings(this);
1331
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
-
 
1332
    // On mobile devices we set the scale factor always because otherwise the
-
 
1333
    // dialog will be unusable.
-
 
1334
    qreal ratio = 1.0;
-
 
1335
 
-
 
1336
    if (gPageManager->getSettings()->isPortrait())
-
 
1337
    {
-
 
1338
        if (gScreenWidth > gScreenHeight)
-
 
1339
        {
-
 
1340
            qreal refHeight = dlg_settings->geometry().height();
-
 
1341
            qreal refWidth = dlg_settings->geometry().width();
-
 
1342
            QRect rect = QGuiApplication::primaryScreen()->geometry();
-
 
1343
            qreal height = qMax(rect.width(), rect.height());
-
 
1344
            qreal width = qMin(rect.width(), rect.height());
-
 
1345
            ratio = qMin(height / refHeight, width / refWidth);
-
 
1346
        }
-
 
1347
        else
-
 
1348
        {
-
 
1349
            qreal refWidth = dlg_settings->geometry().height();
-
 
1350
            qreal refHeight = dlg_settings->geometry().width();
-
 
1351
            QRect rect = QGuiApplication::primaryScreen()->geometry();
-
 
1352
            qreal width = qMax(rect.width(), rect.height());
-
 
1353
            qreal height = qMin(rect.width(), rect.height());
-
 
1354
            ratio = qMin(height / refHeight, width / refWidth);
-
 
1355
        }
-
 
1356
    }
-
 
1357
    else
-
 
1358
        ratio = gScale;
-
 
1359
 
-
 
1360
    dlg_settings->setScaleFactor(ratio);
-
 
1361
    dlg_settings->doResize();
-
 
1362
#endif
-
 
1363
    int ret = dlg_settings->exec();
1323
    int ret = dlg_settings->exec();
1364
    bool rebootAnyway = false;
1324
    bool rebootAnyway = false;
1365
 
1325
 
1366
    if ((ret && dlg_settings->hasChanged()) || (ret && dlg_settings->downloadForce()))
1326
    if ((ret && dlg_settings->hasChanged()) || (ret && dlg_settings->downloadForce()))
1367
    {
1327
    {
Line 1447... Line 1407...
1447
    {
1407
    {
1448
        TConfig cf(TConfig::getConfigPath() + "/" + TConfig::getConfigFileName());
1408
        TConfig cf(TConfig::getConfigPath() + "/" + TConfig::getConfigFileName());
1449
    }
1409
    }
1450
 
1410
 
1451
    delete dlg_settings;
1411
    delete dlg_settings;
1452
#endif  // QTSETTINGS
1412
#endif  // defined(Q_OS_IOS) || defined(Q_OS_ANDROID)
1453
}
1413
}
1454
 
1414
 
1455
/**
1415
/**
1456
 * @brief MainWindow::writeSettings Writes the settings into the configuration file.
1416
 * @brief MainWindow::writeSettings Writes the settings into the configuration file.
1457
 */
1417
 */
Line 3761... Line 3721...
3761
}
3721
}
3762
 
3722
 
3763
void MainWindow::showSetup()
3723
void MainWindow::showSetup()
3764
{
3724
{
3765
    DECL_TRACER("MainWindow::showSetup()");
3725
    DECL_TRACER("MainWindow::showSetup()");
3766
#ifdef QTSETTINGS
3726
#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
3767
    settings();
3727
    settings();
3768
#else
3728
#else
3769
#ifndef Q_OS_IOS
3729
#ifndef Q_OS_IOS
3770
    if (gPageManager)
3730
    if (gPageManager)
3771
        gPageManager->showSetup();
3731
        gPageManager->showSetup();
3772
#else
3732
#else
3773
    QASettings::openSettings();
3733
    QASettings::openSettings();
3774
#endif  // Q_OS_IOS
3734
#endif  // Q_OS_IOS
3775
#endif  // QTSETTINGS
3735
#endif  // !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS)
3776
}
3736
}
3777
 
3737
 
3778
void MainWindow::playSound(const string& file)
3738
void MainWindow::playSound(const string& file)
3779
{
3739
{
3780
    DECL_TRACER("MainWindow::playSound(const string& file)");
3740
    DECL_TRACER("MainWindow::playSound(const string& file)");