Subversion Repositories tpanel

Rev

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

Rev 119 Rev 120
Line 179... Line 179...
179
        {
179
        {
180
            width = std::max(screenGeometry.width(), screenGeometry.height());
180
            width = std::max(screenGeometry.width(), screenGeometry.height());
181
            height = std::min(screenGeometry.height(), screenGeometry.width());
181
            height = std::min(screenGeometry.height(), screenGeometry.width());
182
        }
182
        }
183
 
183
 
-
 
184
        if (TConfig::getToolbarForce())
-
 
185
            minWidth += 48;
-
 
186
 
184
        MSG_INFO("Dimension of AMX screen:" << minWidth << " x " << minHeight);
187
        MSG_INFO("Dimension of AMX screen:" << minWidth << " x " << minHeight);
185
        MSG_INFO("Screen size: " << width << " x " << height);
188
        MSG_INFO("Screen size: " << width << " x " << height);
186
        // The scale factor is always calculated in difference to the prefered
189
        // The scale factor is always calculated in difference to the prefered
187
        // size of the original AMX panel.
190
        // size of the original AMX panel.
188
        double scaleW = width / minWidth;
191
        double scaleW = width / minWidth;
189
        double scaleH = height / minHeight;
192
        double scaleH = height / minHeight;
190
        scale = std::min(scaleW, scaleH);
193
        scale = std::min(scaleW, scaleH);
-
 
194
 
191
        gScale = scale;     // The calculated scale factor
195
        gScale = scale;     // The calculated scale factor
192
        gFullWidth = width;
196
        gFullWidth = width;
193
        // This preprocessor variable allows the scaling to be done by the Skia
197
        // This preprocessor variable allows the scaling to be done by the Skia
194
        // library, which is used to draw everything. In comparison to Qt this
198
        // library, which is used to draw everything. In comparison to Qt this
195
        // library is a bit slower and sometimes does not honor the aspect ratio
199
        // library is a bit slower and sometimes does not honor the aspect ratio
Line 584... Line 588...
584
    {
588
    {
585
        int width = (int)((double)gPageManager->getSettings()->getWith() * gScale);
589
        int width = (int)((double)gPageManager->getSettings()->getWith() * gScale);
586
        int tbWidth = (int)(48.0 * gScale);
590
        int tbWidth = (int)(48.0 * gScale);
587
        int icWidth = (int)(40.0 * gScale);
591
        int icWidth = (int)(40.0 * gScale);
588
 
592
 
589
        if ((gFullWidth - width) < tbWidth)
593
        if ((gFullWidth - width) < tbWidth && !TConfig::getToolbarForce())
590
        {
594
        {
591
            delete mToolbar;
595
            delete mToolbar;
592
            mToolbar = nullptr;
596
            mToolbar = nullptr;
593
            return;
597
            return;
594
        }
598
        }
Line 735... Line 739...
735
    // Save some old values to decide whether to start over or not.
739
    // Save some old values to decide whether to start over or not.
736
    string oldHost = TConfig::getController();
740
    string oldHost = TConfig::getController();
737
    int oldPort = TConfig::getPort();
741
    int oldPort = TConfig::getPort();
738
    int oldChannelID = TConfig::getChannel();
742
    int oldChannelID = TConfig::getChannel();
739
    string oldSurface = TConfig::getFtpSurface();
743
    string oldSurface = TConfig::getFtpSurface();
-
 
744
    bool oldToolbar = TConfig::getToolbarForce();
740
    // Initialize and open the settings dialog.
745
    // Initialize and open the settings dialog.
741
    TQtSettings *dlg_settings = new TQtSettings(this);
746
    TQtSettings *dlg_settings = new TQtSettings(this);
742
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
747
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
743
    // On mobile devices we set the scale factor always because otherwise the
748
    // On mobile devices we set the scale factor always because otherwise the
744
    // dialog will be unusable.
749
    // dialog will be unusable.
Line 750... Line 755...
750
 
755
 
751
    if (ret && dlg_settings->hasChanged())
756
    if (ret && dlg_settings->hasChanged())
752
    {
757
    {
753
        writeSettings();
758
        writeSettings();
754
 
759
 
-
 
760
        if (oldToolbar != TConfig::getToolbarForce())
-
 
761
        {
-
 
762
            QMessageBox msgBox;
-
 
763
            msgBox.setText("The change for the visibility of the toolbar will be active on the next start of TPanel!");
-
 
764
            msgBox.exec();
-
 
765
        }
-
 
766
 
755
        if (TConfig::getFtpSurface() != oldSurface)
767
        if (TConfig::getFtpSurface() != oldSurface)
756
        {
768
        {
757
            TTPInit tpinit;
769
            TTPInit tpinit;
758
            string msg = "Loading file <b>" + TConfig::getFtpSurface() + "<b>.<br>Please wait ...";
-
 
759
            Ui::TQtBusy *dlg_busy = new Ui::TQtBusy(msg, this);
770
            tpinit.regCallbackProcessEvents(bind(&MainWindow::runEvents, this));
760
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
-
 
761
            dlg_busy->setScaleFactor(gScale);
-
 
762
            dlg_busy->doResize();
-
 
763
#endif
-
 
764
            dlg_busy->show();
-
 
765
            tpinit.setPath(TConfig::getProjectPath());
771
            tpinit.setPath(TConfig::getProjectPath());
-
 
772
            string msg = "Loading file <b>" + TConfig::getFtpSurface() + "</b>.<br>Please wait ...";
-
 
773
 
-
 
774
            busyIndicator(msg, this);
766
 
775
 
767
            if (tpinit.loadSurfaceFromController(true))
776
            if (tpinit.loadSurfaceFromController(true))
768
                rebootAnyway = true;
777
                rebootAnyway = true;
769
 
778
 
770
            dlg_busy->close();
779
            mBusyDialog->close();
771
            delete dlg_busy;
780
            mBusy = false;
772
        }
781
        }
773
 
782
 
774
        if (TConfig::getController() != oldHost ||
783
        if (TConfig::getController() != oldHost ||
775
            TConfig::getChannel() != oldChannelID ||
784
            TConfig::getChannel() != oldChannelID ||
776
            TConfig::getPort() != oldPort || rebootAnyway)
785
            TConfig::getPort() != oldPort || rebootAnyway)
Line 2176... Line 2185...
2176
#endif
2185
#endif
2177
    mQKeyboard->setPrivate(priv);
2186
    mQKeyboard->setPrivate(priv);
2178
    mQKeyboard->doResize();
2187
    mQKeyboard->doResize();
2179
    mQKeyboard->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
2188
    mQKeyboard->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
2180
    int ret = mQKeyboard->exec();
2189
    int ret = mQKeyboard->exec();
-
 
2190
    string text = "KEYB-";
2181
 
2191
 
2182
    if (ret == QDialog::Accepted)
2192
    if (ret == QDialog::Accepted)
2183
    {
-
 
2184
        string text = "KEYB-";
-
 
2185
        text.append(mQKeyboard->getText());
2193
        text.append(mQKeyboard->getText());
2186
 
-
 
2187
        if (gPageManager)
-
 
2188
            gPageManager->sendKeyboard(text);
-
 
2189
    }
-
 
2190
    else
2194
    else
2191
    {
-
 
2192
        string text = "KEYB-ABORT";
2195
        text = "KEYB-ABORT";
2193
 
2196
 
2194
        if (gPageManager)
2197
    if (gPageManager)
2195
            gPageManager->sendKeyboard(text);
2198
        gPageManager->sendKeyboard(text);
2196
    }
-
 
2197
 
2199
 
2198
    delete mQKeyboard;
2200
    delete mQKeyboard;
2199
    mQKeyboard = nullptr;
2201
    mQKeyboard = nullptr;
2200
    mKeyboard = false;
2202
    mKeyboard = false;
2201
}
2203
}
Line 2561... Line 2563...
2561
        default:
2563
        default:
2562
            MSG_WARNING("Subpage effect " << ani.showEffect << " is not supported.");
2564
            MSG_WARNING("Subpage effect " << ani.showEffect << " is not supported.");
2563
    }
2565
    }
2564
}
2566
}
2565
 
2567
 
-
 
2568
void MainWindow::busyIndicator(const string& msg, QWidget* parent)
-
 
2569
{
-
 
2570
    DECL_TRACER("MainWindow::busyIndicator(const string& msg, QWidget* parent)");
-
 
2571
 
-
 
2572
    if (mBusy)
-
 
2573
        return;
-
 
2574
 
-
 
2575
    mBusy = true;
-
 
2576
    mBusyDialog = new TQBusy(msg, parent);
-
 
2577
#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS)
-
 
2578
    mBusyDialog->setScaleFactor(gScale);
-
 
2579
    mBusyDialog->doResize();
-
 
2580
#endif
-
 
2581
    mBusyDialog->show();
-
 
2582
}
-
 
2583
 
-
 
2584
void MainWindow::runEvents()
-
 
2585
{
-
 
2586
    DECL_TRACER("MainWindow::runEvents()");
-
 
2587
 
-
 
2588
    QApplication::processEvents();
-
 
2589
}
-
 
2590
 
2566
#ifndef QT_NO_SESSIONMANAGER
2591
#ifndef QT_NO_SESSIONMANAGER
2567
void MainWindow::commitData(QSessionManager &manager)
2592
void MainWindow::commitData(QSessionManager &manager)
2568
{
2593
{
2569
    if (manager.allowsInteraction())
2594
    if (manager.allowsInteraction())
2570
    {
2595
    {