Subversion Repositories tpanel

Rev

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

Rev 334 Rev 335
Line 587... Line 587...
587
    gPageManager->regCallbackResetSurface(bind(&MainWindow::_resetSurface, this));
587
    gPageManager->regCallbackResetSurface(bind(&MainWindow::_resetSurface, this));
588
    gPageManager->regCallbackShutdown(bind(&MainWindow::_shutdown, this));
588
    gPageManager->regCallbackShutdown(bind(&MainWindow::_shutdown, this));
589
    gPageManager->regCallbackPlaySound(bind(&MainWindow::_playSound, this, std::placeholders::_1));
589
    gPageManager->regCallbackPlaySound(bind(&MainWindow::_playSound, this, std::placeholders::_1));
590
    gPageManager->regCallbackStopSound(bind(&MainWindow::_stopSound, this));
590
    gPageManager->regCallbackStopSound(bind(&MainWindow::_stopSound, this));
591
    gPageManager->regCallbackMuteSound(bind(&MainWindow::_muteSound, this, std::placeholders::_1));
591
    gPageManager->regCallbackMuteSound(bind(&MainWindow::_muteSound, this, std::placeholders::_1));
-
 
592
    gPageManager->regCallbackSetVolume(bind(&MainWindow::_setVolume, this, std::placeholders::_1));
592
    gPageManager->registerCBsetVisible(bind(&MainWindow::_setVisible, this, std::placeholders::_1, std::placeholders::_2));
593
    gPageManager->registerCBsetVisible(bind(&MainWindow::_setVisible, this, std::placeholders::_1, std::placeholders::_2));
593
    gPageManager->regSendVirtualKeys(bind(&MainWindow::_sendVirtualKeys, this, std::placeholders::_1));
594
    gPageManager->regSendVirtualKeys(bind(&MainWindow::_sendVirtualKeys, this, std::placeholders::_1));
594
    gPageManager->regShowPhoneDialog(bind(&MainWindow::_showPhoneDialog, this, std::placeholders::_1));
595
    gPageManager->regShowPhoneDialog(bind(&MainWindow::_showPhoneDialog, this, std::placeholders::_1));
595
    gPageManager->regSetPhoneNumber(bind(&MainWindow::_setPhoneNumber, this, std::placeholders::_1));
596
    gPageManager->regSetPhoneNumber(bind(&MainWindow::_setPhoneNumber, this, std::placeholders::_1));
596
    gPageManager->regSetPhoneStatus(bind(&MainWindow::_setPhoneStatus, this, std::placeholders::_1));
597
    gPageManager->regSetPhoneStatus(bind(&MainWindow::_setPhoneStatus, this, std::placeholders::_1));
Line 665... Line 666...
665
        connect(this, &MainWindow::sigListBox, this, &MainWindow::listBox);
666
        connect(this, &MainWindow::sigListBox, this, &MainWindow::listBox);
666
        connect(this, &MainWindow::sigKeyboard, this, &MainWindow::showKeyboard);
667
        connect(this, &MainWindow::sigKeyboard, this, &MainWindow::showKeyboard);
667
        connect(this, &MainWindow::sigKeypad, this, &MainWindow::showKeypad);
668
        connect(this, &MainWindow::sigKeypad, this, &MainWindow::showKeypad);
668
        connect(this, &MainWindow::sigShowSetup, this, &MainWindow::showSetup);
669
        connect(this, &MainWindow::sigShowSetup, this, &MainWindow::showSetup);
669
        connect(this, &MainWindow::sigPlaySound, this, &MainWindow::playSound);
670
        connect(this, &MainWindow::sigPlaySound, this, &MainWindow::playSound);
-
 
671
        connect(this, &MainWindow::sigSetVolume, this, &MainWindow::setVolume);
670
        connect(this, &MainWindow::sigDropButton, this, &MainWindow::dropButton);
672
        connect(this, &MainWindow::sigDropButton, this, &MainWindow::dropButton);
671
        connect(this, &MainWindow::sigSetVisible, this, &MainWindow::SetVisible);
673
        connect(this, &MainWindow::sigSetVisible, this, &MainWindow::SetVisible);
672
        connect(this, &MainWindow::sigSendVirtualKeys, this, &MainWindow::sendVirtualKeys);
674
        connect(this, &MainWindow::sigSendVirtualKeys, this, &MainWindow::sendVirtualKeys);
673
        connect(this, &MainWindow::sigShowPhoneDialog, this, &MainWindow::showPhoneDialog);
675
        connect(this, &MainWindow::sigShowPhoneDialog, this, &MainWindow::showPhoneDialog);
674
        connect(this, &MainWindow::sigSetPhoneNumber, this, &MainWindow::setPhoneNumber);
676
        connect(this, &MainWindow::sigSetPhoneNumber, this, &MainWindow::setPhoneNumber);
Line 3153... Line 3155...
3153
    DECL_TRACER("MainWindow::_muteSound(bool state)");
3155
    DECL_TRACER("MainWindow::_muteSound(bool state)");
3154
 
3156
 
3155
    emit sigMuteSound(state);
3157
    emit sigMuteSound(state);
3156
}
3158
}
3157
 
3159
 
-
 
3160
void MainWindow::_setVolume(int volume)
-
 
3161
{
-
 
3162
    DECL_TRACER("MainWindow::_setVolume(int volume)");
-
 
3163
 
-
 
3164
    emit sigSetVolume(volume);
-
 
3165
}
-
 
3166
 
3158
void MainWindow::_setOrientation(J_ORIENTATION ori)
3167
void MainWindow::_setOrientation(J_ORIENTATION ori)
3159
{
3168
{
3160
#ifdef Q_OS_ANDROID
3169
#ifdef Q_OS_ANDROID
3161
    DECL_TRACER("MainWindow::_setOriantation(J_ORIENTATION ori)");
3170
    DECL_TRACER("MainWindow::_setOriantation(J_ORIENTATION ori)");
3162
 
3171
 
Line 3393... Line 3402...
3393
int MainWindow::calcVolume(int value)
3402
int MainWindow::calcVolume(int value)
3394
{
3403
{
3395
    DECL_TRACER("TQtSettings::calcVolume(int value)");
3404
    DECL_TRACER("TQtSettings::calcVolume(int value)");
3396
 
3405
 
3397
    // volumeSliderValue is in the range [0..100]
3406
    // volumeSliderValue is in the range [0..100]
3398
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
3407
//#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
3399
    qreal linearVolume = QAudio::convertVolume(value / qreal(100.0),
3408
    qreal linearVolume = QAudio::convertVolume(value / qreal(100.0),
3400
                                               QAudio::LogarithmicVolumeScale,
3409
                                               QAudio::LogarithmicVolumeScale,
3401
                                               QAudio::LinearVolumeScale);
3410
                                               QAudio::LinearVolumeScale);
3402
 
3411
 
3403
    return qRound(linearVolume * 100);
3412
    return qRound(linearVolume * 100);
3404
#else
3413
//#else
3405
    return value;
3414
//    return value;
3406
#endif
3415
//#endif
3407
}
3416
}
3408
 
3417
 
3409
/**
3418
/**
3410
 * @brief MainWindow::convertMask
3419
 * @brief MainWindow::convertMask
3411
 * Converts the AMX mask for input lines into Qt mask sympols for input lines.
3420
 * Converts the AMX mask for input lines into Qt mask sympols for input lines.
Line 4756... Line 4765...
4756
    OBJECT_t *obj = findObject(handle);
4765
    OBJECT_t *obj = findObject(handle);
4757
 
4766
 
4758
    if (!obj)
4767
    if (!obj)
4759
    {
4768
    {
4760
        MSG_WARNING("Object " << handleToString(handle) << " (SubPage) does not exist. Ignoring!");
4769
        MSG_WARNING("Object " << handleToString(handle) << " (SubPage) does not exist. Ignoring!");
-
 
4770
#if TESTMODE == 1
-
 
4771
        setScreenDone();
-
 
4772
#endif
4761
        return;
4773
        return;
4762
    }
4774
    }
4763
 
4775
 
4764
    if (obj->type != OBJ_SUBPAGE)
4776
    if (obj->type != OBJ_SUBPAGE)
4765
    {
4777
    {
4766
        MSG_WARNING("Object " << handleToString(handle) << " is not a SubPage!");
4778
        MSG_WARNING("Object " << handleToString(handle) << " is not a SubPage!");
-
 
4779
#if TESTMODE == 1
-
 
4780
        setScreenDone();
-
 
4781
#endif
4767
        return;
4782
        return;
4768
    }
4783
    }
4769
 
4784
 
4770
    MSG_DEBUG("Dropping subpage " << handleToString(handle));
4785
    MSG_DEBUG("Dropping subpage " << handleToString(handle));
4771
    invalidateAllSubObjects(handle);
4786
    invalidateAllSubObjects(handle);
Line 4780... Line 4795...
4780
    {
4795
    {
4781
        obj->invalid = true;
4796
        obj->invalid = true;
4782
        obj->remove = false;
4797
        obj->remove = false;
4783
 
4798
 
4784
        if (obj->object.widget)
4799
        if (obj->object.widget)
-
 
4800
        {
4785
            obj->object.widget->hide();
4801
            obj->object.widget->hide();
-
 
4802
#if TESTMODE == 1
-
 
4803
            __success = true;
-
 
4804
            setScreenDone();
-
 
4805
#endif
-
 
4806
        }
4786
    }
4807
    }
4787
}
4808
}
4788
 
4809
 
4789
void MainWindow::dropButton(ulong handle)
4810
void MainWindow::dropButton(ulong handle)
4790
{
4811
{
Line 5418... Line 5439...
5418
    if (!mMediaPlayer)
5439
    if (!mMediaPlayer)
5419
    {
5440
    {
5420
        mMediaPlayer = new QMediaPlayer;
5441
        mMediaPlayer = new QMediaPlayer;
5421
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
5442
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
5422
        mAudioOutput = new QAudioOutput;
5443
        mAudioOutput = new QAudioOutput;
-
 
5444
        mMediaPlayer->setAudioOutput(mAudioOutput);
5423
#endif
5445
#endif
5424
    }
5446
    }
5425
 
5447
 
5426
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
5448
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
5427
    mMediaPlayer->setMedia(QUrl::fromLocalFile(file.c_str()));
5449
    mMediaPlayer->setMedia(QUrl::fromLocalFile(file.c_str()));
5428
    mMediaPlayer->setVolume(calcVolume(TConfig::getSystemVolume()));
5450
    mMediaPlayer->setVolume(calcVolume(TConfig::getSystemVolume()));
-
 
5451
 
-
 
5452
    if (mMediaPlayer->playbackState() != QMediaPlayer::StoppedState)
-
 
5453
        mMediaPlayer->stop();
5429
#else
5454
#else
5430
    mMediaPlayer->setSource(QUrl::fromLocalFile(file.c_str()));
5455
    mMediaPlayer->setSource(QUrl::fromLocalFile(file.c_str()));
5431
    mAudioOutput->setVolume(TConfig::getSystemVolume());
5456
    mAudioOutput->setVolume(calcVolume(TConfig::getSystemVolume()));
-
 
5457
 
-
 
5458
    if (!mMediaPlayer->isAvailable())
-
 
5459
    {
-
 
5460
        MSG_WARNING("No audio modul found!");
-
 
5461
#if TESTMODE == 1
-
 
5462
        setAllDone();
5432
#endif
5463
#endif
-
 
5464
        return;
-
 
5465
    }
-
 
5466
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
-
 
5467
    if (mMediaPlayer->isPlaying())
-
 
5468
        mMediaPlayer->stop();
-
 
5469
#else
-
 
5470
    if (mMediaPlayer->playbackState() != QMediaPlayer::StoppedState)
-
 
5471
        mMediaPlayer->stop();
-
 
5472
#endif  // #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
-
 
5473
#endif  // QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-
 
5474
 
5433
    mMediaPlayer->play();
5475
    mMediaPlayer->play();
5434
#if TESTMODE == 1
5476
#if TESTMODE == 1
-
 
5477
    QMediaPlayer::Error err = QMediaPlayer::NoError;
-
 
5478
 
-
 
5479
    if ((err = mMediaPlayer->error()) != QMediaPlayer::NoError)
-
 
5480
    {
-
 
5481
        MSG_ERROR("Error playing \"" << file << "\": " << mMediaPlayer->errorString().toStdString());
-
 
5482
    }
-
 
5483
    else
5435
    __success = true;
5484
        __success = true;
-
 
5485
 
5436
    setAllDone();
5486
    setAllDone();
5437
#endif
5487
#endif
5438
}
5488
}
5439
 
5489
 
5440
void MainWindow::stopSound()
5490
void MainWindow::stopSound()
Line 5454... Line 5504...
5454
        mMediaPlayer->setMuted(state);
5504
        mMediaPlayer->setMuted(state);
5455
#else
5505
#else
5456
    if (mAudioOutput)
5506
    if (mAudioOutput)
5457
        mAudioOutput->setMuted(state);
5507
        mAudioOutput->setMuted(state);
5458
#endif
5508
#endif
-
 
5509
#if TESTMODE == 1
-
 
5510
    __success = true;
-
 
5511
    setAllDone();
-
 
5512
#endif
-
 
5513
}
-
 
5514
 
-
 
5515
void MainWindow::setVolume(int volume)
-
 
5516
{
-
 
5517
    DECL_TRACER("MainWindow::setVolume(int volume)");
-
 
5518
 
-
 
5519
    if (!mMediaPlayer)
-
 
5520
    {
-
 
5521
#if TESTMODE == 1
-
 
5522
        setAllDone();
-
 
5523
#endif
-
 
5524
        return;
-
 
5525
    }
-
 
5526
 
-
 
5527
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
-
 
5528
    mMediaPlayer->setVolume(calcVolume(volume));
-
 
5529
#else
-
 
5530
    if (!mMediaPlayer || !mAudioOutput)
-
 
5531
    {
-
 
5532
#if TESTMODE == 1
-
 
5533
        setAllDone();
-
 
5534
#endif
-
 
5535
        return;
-
 
5536
    }
-
 
5537
 
-
 
5538
    mAudioOutput->setVolume(calcVolume(volume));
-
 
5539
#if TESTMODE == 1
-
 
5540
    MSG_DEBUG("Volume was set to " << volume);
-
 
5541
    __success = true;
-
 
5542
    setAllDone();
-
 
5543
#endif
-
 
5544
#endif  // QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
5459
}
5545
}
5460
 
5546
 
5461
void MainWindow::playShowList()
5547
void MainWindow::playShowList()
5462
{
5548
{
5463
    DECL_TRACER("MainWindow::playShowList()");
5549
    DECL_TRACER("MainWindow::playShowList()");
Line 5827... Line 5913...
5827
 
5913
 
5828
        default:
5914
        default:
5829
            MSG_WARNING("Subpage effect " << ani.showEffect << " is not supported.");
5915
            MSG_WARNING("Subpage effect " << ani.showEffect << " is not supported.");
5830
            delete obj->animation;
5916
            delete obj->animation;
5831
            obj->animation = nullptr;
5917
            obj->animation = nullptr;
5832
#if TESTMODE == 1
-
 
5833
            setScreenDone();
-
 
5834
#endif
-
 
5835
            return false;
5918
            return false;
5836
    }
5919
    }
5837
 
5920
 
5838
    return true;
5921
    return true;
5839
}
5922
}