Subversion Repositories tpanel

Rev

Rev 446 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
446 andreas 1
/*
2
 * Copyright (C) 2020, 2023 by Andreas Theofilu <andreas@theosys.at>
3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
#include <QFileDialog>
19
#include <QComboBox>
20
#include <QMessageBox>
21
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
22
#include <QAudioOutput>
23
#elif QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && defined(Q_OS_ANDROID)
24
#include <QJniObject>
25
//#include <QtCore/private/qandroidextras_p.h>
26
#endif
27
#include <QScreen>
28
#include <QGuiApplication>
29
#include <QFont>
30
 
31
#include <unistd.h>
32
 
33
#include "tqtsettings.h"
34
#include "tdirectory.h"
35
#include "tresources.h"
36
#include "tpagemanager.h"
37
#include "terror.h"
38
#include "ui_tqtsettings.h"
39
 
40
#ifdef Q_OS_ANDROID
41
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
42
#       include <QtAndroidExtras/QAndroidJniObject>
43
#       include <QtAndroidExtras/QtAndroid>
44
#   endif
45
#   include <QtQml/QQmlFile>
46
#   include <android/log.h>
47
#endif
48
 
49
#include "tconfig.h"
50
#include "ttpinit.h"
51
 
52
#define RLOG_INFO           0x00fe
53
#define RLOG_WARNING        0x00fd
54
#define RLOG_ERROR          0x00fb
55
#define RLOG_TRACE          0x00f7
56
#define RLOG_DEBUG          0x00ef
57
#define RLOG_PROTOCOL       0x00f8
58
#define RLOG_ALL            0x00e0
59
 
60
using std::string;
61
using std::vector;
62
using std::sort;
63
 
64
extern TPageManager *gPageManager;
65
 
66
TQtSettings::TQtSettings(QWidget *parent)
67
	: QDialog(parent),
68
	  ui(new Ui::TQtSettings)
69
{
70
	DECL_TRACER("TQtSettings::TQtSettings(QWidget *parent)");
71
 
72
    mInitRun = true;
73
	ui->setupUi(this);
74
 
75
    ui->lineEdit_logFile->setText(TConfig::getLogFile().c_str());
76
    ui->lineEdit_Controller->setText(TConfig::getController().c_str());
77
    ui->lineEdit_PType->setText(TConfig::getPanelType().c_str());
78
    ui->spinBox_Port->setValue(TConfig::getPort());
79
    ui->spinBox_Channel->setValue(TConfig::getChannel());
80
    ui->lineEdit_FTPuser->setText(TConfig::getFtpUser().c_str());
81
    ui->lineEdit_FTPpassword->setText(TConfig::getFtpPassword().c_str());
82
 
83
    TTPInit tinit;
84
    tinit.setPath(TConfig::getProjectPath());
85
    mFileList = tinit.getFileList(".tp4");
86
    ui->comboBox_FTPsurface->clear();
87
    string curSurface = TConfig::getFtpSurface();
88
 
89
    if (mFileList.size() == 0)
90
        ui->comboBox_FTPsurface->addItem(curSurface.c_str());
91
    else
92
    {
93
        ui->comboBox_FTPsurface->clear();
94
        vector<TTPInit::FILELIST_t>::iterator iter;
95
        int idx = 0;
96
        int newIdx = -1;
97
 
98
        for (iter = mFileList.begin(); iter != mFileList.end(); ++iter)
99
        {
100
            ui->comboBox_FTPsurface->addItem(iter->fname.c_str());
101
 
102
            if (iter->fname.compare(curSurface) == 0)
103
                newIdx = idx;
104
 
105
            idx++;
106
        }
107
 
108
        if (newIdx != -1)
109
        {
110
            ui->comboBox_FTPsurface->setCurrentIndex(newIdx);
111
            mIndex = newIdx;
112
        }
113
    }
114
 
115
    ui->checkBox_FTPpassive->setCheckState((TConfig::getFtpPassive() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
116
 
117
    mLogLevel = TConfig::getLogLevelBits();
118
    ui->checkBox_LogInfo->setCheckState((mLogLevel & HLOG_INFO) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
119
    ui->checkBox_LogWarning->setCheckState((mLogLevel & HLOG_WARNING) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
120
    ui->checkBox_LogError->setCheckState((mLogLevel & HLOG_ERROR) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
121
    ui->checkBox_LogTrace->setCheckState((mLogLevel & HLOG_TRACE) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
122
    ui->checkBox_LogDebug->setCheckState((mLogLevel & HLOG_DEBUG) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
123
    ui->checkBox_LogProtocol->setCheckState(((mLogLevel & HLOG_PROTOCOL) == HLOG_PROTOCOL) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
124
    ui->checkBox_LogAll->setCheckState(((mLogLevel & HLOG_ALL) == HLOG_ALL) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
125
 
126
    ui->checkBox_Format->setCheckState((TConfig::isLongFormat() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
127
    ui->checkBox_Scale->setCheckState((TConfig::getScale() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
128
#ifndef __ANDROID__
129
    ui->checkBox_Scale->setDisabled(true);
130
#endif
131
    ui->checkBox_Banner->setCheckState((TConfig::showBanner() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
132
#ifdef __ANDROID__
133
    ui->checkBox_Banner->setDisabled(true);
134
#endif
135
    ui->checkBox_Toolbar->setCheckState((TConfig::getToolbarForce() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
136
    ui->checkBox_ToolbarSuppress->setCheckState((TConfig::getToolbarSuppress() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
137
 
138
    if (TConfig::getToolbarSuppress())
139
        ui->checkBox_Toolbar->setDisabled(true);
140
 
141
    ui->lineEdit_SIPproxy->setText(TConfig::getSIPproxy().c_str());
142
    ui->spinBox_SIPport->setValue(TConfig::getSIPport());
143
    ui->spinBox_SIPportTLS->setValue(TConfig::getSIPportTLS());
144
    ui->lineEdit_SIPstun->setText(TConfig::getSIPstun().c_str());
145
    ui->lineEdit_SIPdomain->setText(TConfig::getSIPdomain().c_str());
146
    ui->lineEdit_SIPuser->setText(TConfig::getSIPuser().c_str());
147
    ui->lineEdit_SIPpassword->setText(TConfig::getSIPpassword().c_str());
148
    ui->checkBox_SIPnetworkIPv4->setCheckState(TConfig::getSIPnetworkIPv4() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
149
    ui->checkBox_SIPnetworkIPv6->setCheckState(TConfig::getSIPnetworkIPv6() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
150
    ui->checkBox_SIPiphone->setCheckState(TConfig::getSIPiphone() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
151
 
152
    int fwIdx = 0;
153
 
154
    switch(TConfig::getSIPfirewall())
155
    {
156
        case TConfig::SIP_NO_FIREWALL:  fwIdx = 0; break;
157
        case TConfig::SIP_STUN:         fwIdx = 1; break;
158
        case TConfig::SIP_ICE:          fwIdx = 2; break;
159
        case TConfig::SIP_UPNP:         fwIdx = 3; break;
160
 
161
        default:
162
            fwIdx = 0;
163
    }
164
 
165
    ui->comboBox_SIPfirewall->setCurrentIndex(fwIdx);
166
    ui->checkBox_SIPenabled->setCheckState((TConfig::getSIPstatus() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
167
 
168
    // Sound settings
169
    string sySound = TConfig::getSystemSound();
170
    size_t pos = sySound.find_last_of(".");
171
    int numpos = 0;
172
 
173
    if (pos != string::npos)
174
        numpos = atoi(sySound.substr(pos - 2, 2).c_str());
175
 
176
    dir::TDirectory dir;
177
    int num = dir.readDir(TConfig::getProjectPath() + "/__system/graphics/sounds");
178
    vector<string> tmpFiles;
179
 
180
    for (int i = 0; i < num; i++)
181
    {
182
        dir::DFILES_T entry = dir.getEntry(i);
183
        pos = entry.name.find_last_of("/");
184
        string file;
185
 
186
        if (pos != string::npos)
187
            file = entry.name.substr(pos + 1);
188
 
189
        if ((pos = file.find_last_of(".")) != string::npos)
190
            file = file.substr(0, pos);
191
 
192
        if (startsWith(file, "singleBeep"))
193
            tmpFiles.push_back(file);
194
    }
195
 
196
    sort(tmpFiles.begin(), tmpFiles.end());
197
    vector<string>::iterator iter;
198
 
199
    for (iter = tmpFiles.begin(); iter != tmpFiles.end(); ++iter)
200
        ui->comboBox_SystemSound->addItem(iter->c_str());
201
 
202
    ui->comboBox_SystemSound->setCurrentIndex(numpos);
203
 
204
    string siBeep = TConfig::getSingleBeepSound();
205
    pos = siBeep.find_last_of(".");
206
 
207
    if (pos != string::npos)
208
    {
209
        int num = atoi(siBeep.substr(pos - 2, 2).c_str());
210
 
211
        if (num > 0)
212
            siBeep = "Single Beep " + std::to_string(num);
213
    }
214
 
215
    int sel = 0;
216
 
217
    for (int i = 1; i <= 10; i++)
218
    {
219
        QString e = QString("Single Beep %1").arg(i);
220
        ui->comboBox_SingleBeep->addItem(e);
221
 
222
        if (e == QString(siBeep.c_str()))
223
            sel = i - 1;
224
    }
225
 
226
    ui->comboBox_SingleBeep->setCurrentIndex(sel);
227
 
228
    string siDBeep = TConfig::getDoubleBeepSound();
229
    pos = siDBeep.find_last_of(".");
230
 
231
    if (pos != string::npos)
232
    {
233
        int num = atoi(siDBeep.substr(pos - 2, 2).c_str());
234
 
235
        if (num > 0)
236
            siBeep = "Double Beep " + std::to_string(num);
237
    }
238
 
239
    sel = 0;
240
 
241
    for (int i = 1; i <= 10; i++)
242
    {
243
        QString e = QString("Double Beep %1").arg(i);
244
        ui->comboBox_DoubleBeep->addItem(e);
245
 
246
        if (e == QString(siBeep.c_str()))
247
            sel = i - 1;
248
    }
249
 
250
    ui->comboBox_DoubleBeep->setCurrentIndex(sel);
251
    ui->checkBox_SystemSound->setCheckState((TConfig::getSystemSoundState() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
252
 
253
    int volume = TConfig::getSystemVolume();
254
    int gain = TConfig::getSystemGain();
255
    ui->horizontalSlider_Volume->setValue(volume);
256
    ui->horizontalSlider_Gain->setValue(gain);
257
 
258
#ifdef __ANDROID__
259
    ui->tabWidget->setPalette(qt_fusionPalette());
260
    ui->tabCtrl->setPalette(qt_fusionPalette());
261
    ui->tabLog->setPalette(qt_fusionPalette());
262
    ui->tabSIP->setPalette(qt_fusionPalette());
263
    ui->tabView->setPalette(qt_fusionPalette());
264
#endif
265
 
266
    // Passwords
267
    ui->lineEdit_Password1->setText(TConfig::getPassword1().c_str());
268
    ui->lineEdit_Password2->setText(TConfig::getPassword2().c_str());
269
    ui->lineEdit_Password3->setText(TConfig::getPassword3().c_str());
270
    ui->lineEdit_Password4->setText(TConfig::getPassword4().c_str());
271
 
272
    mInitRun = false;
273
    mSetChanged = false;
274
}
275
 
276
TQtSettings::~TQtSettings()
277
{
278
	DECL_TRACER("TQtSettings::~TQtSettings()");
279
	delete ui;
280
}
281
 
282
#ifdef __ANDROID__
283
QPalette TQtSettings::qt_fusionPalette()
284
{
285
    QColor backGround(239, 239, 239);
286
    QColor light = backGround.lighter(150);
287
    QColor mid(backGround.darker(130));
288
    QColor midLight = mid.lighter(110);
289
    QColor base = Qt::white;
290
    QColor disabledBase(backGround);
291
    QColor dark = backGround.darker(150);
292
    QColor darkDisabled = QColor(209, 209, 209).darker(110);
293
    QColor text = Qt::black;
294
    QColor hightlightedText = Qt::darkGray;
295
    QColor disabledText = QColor(190, 190, 190);
296
    QColor button = backGround;
297
    QColor shadow = dark.darker(135);
298
    QColor disabledShadow = shadow.lighter(150);
299
 
300
    QPalette fusionPalette(Qt::black,backGround,light,dark,mid,text,base);
301
    fusionPalette.setBrush(QPalette::Midlight, midLight);
302
    fusionPalette.setBrush(QPalette::Button, button);
303
    fusionPalette.setBrush(QPalette::Shadow, shadow);
304
    fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText);
305
 
306
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText);
307
    fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText);
308
    fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText);
309
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase);
310
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
311
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
312
 
313
    fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198));
314
    fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(48, 140, 198));
315
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 145, 145));
316
    return fusionPalette;
317
}
318
#endif
319
 
320
void TQtSettings::on_kiconbutton_logFile_clicked()
321
{
322
    DECL_TRACER("TQtSettings::on_kiconbutton_logFile_clicked()");
323
 
324
    std::string pt = TConfig::getLogFile();
325
    size_t pos = pt.find_last_of("/");
326
 
327
    if (pos != std::string::npos)
328
        pt = pt.substr(0, pos);
329
    else
330
    {
331
        char hv0[4096];
332
        getcwd(hv0, sizeof(hv0));
333
        pt = hv0;
334
    }
335
 
336
    QString actPath(pt.c_str());
337
    QFileDialog fdialog(this, tr("Logfile"), actPath, tr("TPanel.log (*.log)"));
338
    fdialog.setAcceptMode(QFileDialog::AcceptSave);
339
    fdialog.setDefaultSuffix("log");
340
    fdialog.setOption(QFileDialog::DontConfirmOverwrite);
341
    QString fname;
342
 
343
    if (fdialog.exec())
344
    {
345
        QDir dir = fdialog.directory();
346
        QStringList list = fdialog.selectedFiles();
347
 
348
        if (list.size() > 0)
349
            fname = dir.absoluteFilePath(list.at(0));
350
        else
351
            return;
352
    }
353
    else
354
        return;
355
 
356
#ifdef Q_OS_ANDROID
357
    QString fileName = fname;
358
 
359
    if (fileName.contains("content://"))
360
    {
361
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
362
        QAndroidJniObject uri = QAndroidJniObject::callStaticObjectMethod(
363
              "android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;",
364
              QAndroidJniObject::fromString(fileName).object<jstring>());
365
 
366
        fileName =
367
              QAndroidJniObject::callStaticObjectMethod(
368
                  "org/qtproject/theosys/UriToPath", "getFileName",
369
                  "(Landroid/net/Uri;Landroid/content/Context;)Ljava/lang/String;",
370
                  uri.object(), QtAndroid::androidContext().object()).toString();
371
#else
372
        QJniObject uri = QJniObject::callStaticObjectMethod(
373
              "android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;",
374
              QJniObject::fromString(fileName).object<jstring>());
375
 
482 andreas 376
        QJniObject context = QNativeInterface::QAndroidApplication::context();
377
 
446 andreas 378
        fileName =
379
              QJniObject::callStaticObjectMethod(
380
                  "org/qtproject/theosys/UriToPath", "getFileName",
381
                  "(Landroid/net/Uri;Landroid/content/Context;)Ljava/lang/String;",
482 andreas 382
                  uri.object(), &context).toString();
446 andreas 383
#endif
384
        if (fileName.length() > 0)
385
            fname = fileName;
386
    }
387
    else
388
    {
389
        MSG_WARNING("Not an Uri? (" << fname.toStdString() << ")");
390
    }
391
#endif
392
    ui->lineEdit_logFile->setText(fname);
393
 
394
    if (TConfig::getLogFile().compare(fname.toStdString()) != 0)
395
    {
396
        mSetChanged = true;
397
        TConfig::saveLogFile(fname.toStdString());
398
    }
399
}
400
 
401
template<typename T>
402
void TQtSettings::scaleObject(T *obj)
403
{
404
    DECL_TRACER("TQtSettings::scaleObject(T *obj)");
405
 
406
    QSize size = obj->size();
407
    QFont font = obj->font();
408
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
409
    obj->resize(size);
410
    QRect rect = obj->geometry();
411
    obj->move(scale(rect.left()), scale(rect.top()));
412
 
413
    double fontSize = -1.0;
414
    int pixelSize = -1;
415
 
416
    if (font.pointSizeF() > 0.0 && mRatioFont != 1.0)
417
        fontSize = font.pointSizeF() * mRatioFont;
418
    else if (font.pointSize() > 0 && mRatioFont != 1.0)
419
        fontSize = font.pointSize() * mRatioFont;
420
    else if (font.pixelSize() > 0 && mRatioFont != 1.0)
421
        pixelSize = (int)((double)font.pixelSize() * mRatioFont);
422
    else if (font.pixelSize() >= 8)
423
        return;
424
 
425
    if (fontSize >= 6.0)
426
        font.setPointSizeF(fontSize);
427
    else if (pixelSize >= 8)
428
        font.setPixelSize(pixelSize);
429
    else
430
        font.setPointSizeF(11.0);
431
 
432
    obj->setFont(font);
433
}
434
 
435
void TQtSettings::doResize()
436
{
437
    DECL_TRACER("TQtSettings::doResize()");
438
 
439
    // The main dialog window
440
    QSize size = this->size();
441
    QRect rect = this->geometry();
442
    QRect rectGui = QGuiApplication::primaryScreen()->geometry();
443
    qreal height = 0.0;
444
    qreal width = 0.0;
445
 
446
    if (gPageManager->getSettings()->isPortrait())
447
    {
448
        height = qMax(rectGui.width(), rectGui.height());
449
        width = qMin(rectGui.width(), rectGui.height());
450
 
451
        if (rectGui.width() > rectGui.height())
452
            mScaleFactor = qMin(height / rect.height(), width / rect.width());
453
    }
454
    else
455
    {
456
        height = qMin(rectGui.width(), rectGui.height());
457
        width = qMax(rectGui.width(), rectGui.height());
458
 
459
        if (rectGui.width() < rectGui.height())
460
            mScaleFactor = qMax(height / rect.height(), width / rect.width());
461
    }
462
 
463
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
464
    this->resize(size);
465
 
466
    QWidget *parent = this->parentWidget();
467
 
468
    if (rect.width() > rectGui.width() || rect.height() > rectGui.height())
469
        this->move(0, 0);
470
    else if (parent && rect.width() < rectGui.width() && rect.height() < rectGui.height())
471
    {
472
        rect = parent->geometry();
473
        this->move(rect.center() - this->rect().center());
474
    }
475
    else
476
        this->move(scale(rect.left()), scale(rect.top()));
477
 
478
    // Font size calculation
479
    double refWidth = gPageManager->getSettings()->getWidth();
480
    double refHeight = gPageManager->getSettings()->getHeight();
481
    double dpi = QGuiApplication::primaryScreen()->logicalDotsPerInch();
482
    double amxDpi = dpi / ((width > height) ? width : height) * ((refWidth > refHeight) ? refWidth : refHeight);
483
    mRatioFont = qMin(height * amxDpi / (dpi * refHeight), width * amxDpi / (dpi * refWidth));
484
//    MSG_PROTOCOL("qMin(" << height << " * " << amxDpi << " / " << "(" << dpi << " * " << refHeight << "), " << width << " * " << amxDpi << " / " << "(" << dpi << " * " << refWidth << "))");
485
//    MSG_PROTOCOL("Original DPI: " << dpi << ", initial AMX DPI: " << amxDpi << ", font scale factor: " << mRatioFont);
486
    // Layout
487
    // Iterate through childs and resize them
488
    QObjectList childs = children();
489
    QList<QObject *>::Iterator iter;
490
 
491
    for (iter = childs.begin(); iter != childs.end(); ++iter)
492
    {
493
        QObject *obj = *iter;
494
        QString name = obj->objectName();
495
 
496
        if (name.startsWith("tabWidget"))
497
        {
498
            QTabWidget *tw = dynamic_cast<QTabWidget *>(obj);
499
            scaleObject(tw);
500
#ifdef __ANDROID__
501
            QColor txt = qt_fusionPalette().Text;
502
            tw->setStyleSheet(QString("color: %1").arg(txt.name()));
503
#endif
504
            QObjectList childsTab = obj->children();
505
            QList<QObject *>::Iterator iterTab;
506
 
507
            for (iterTab = childsTab.begin(); iterTab != childsTab.end(); ++iterTab)
508
            {
509
                QObject *objt = *iterTab;
510
                QString namet = objt->objectName();
511
 
512
                if (namet.startsWith("qt_tabwidget_stackedwidget"))
513
                {
514
                    QObjectList childsStack = objt->children();
515
                    QList<QObject *>::Iterator iterStack;
516
 
517
                    for (iterStack = childsStack.begin(); iterStack != childsStack.end(); ++iterStack)
518
                    {
519
                        QObject *objStack = *iterStack;
520
                        QObjectList tabStack = objStack->children();
521
                        QList<QObject *>::Iterator tabIter;
522
 
523
                        for (tabIter = tabStack.begin(); tabIter != tabStack.end(); ++tabIter)
524
                        {
525
                            QObject *on = *tabIter;
526
                            QString n = on->objectName();
527
 
528
                            if (n.startsWith("kiconbutton") || n.startsWith("toolButton"))
529
                                scaleObject(dynamic_cast<QToolButton *>(on));
530
                            else if (n.startsWith("pushButton"))
531
                                scaleObject(dynamic_cast<QPushButton *>(on));
532
                            else if (n.startsWith("checkBox"))
533
                            {
534
                                QCheckBox *cb = dynamic_cast<QCheckBox *>(on);
535
                                scaleObject(cb);
536
#ifdef __ANDROID__
537
                                cb->setPalette(qt_fusionPalette());
538
                                QSize size = cb->size();
539
                                QString ss = QString("spacing:%1;indicator:{width:%2px;height:%3px;}").arg(scale(5)).arg(size.height()).arg(size.height());
540
                                MSG_PROTOCOL("CheckBox style sheet: " << ss.toStdString());
541
                                cb->setStyleSheet(ss);
542
#endif
543
                            }
544
                            else if (n.startsWith("lineEdit"))
545
                            {
546
                                QLineEdit *le = dynamic_cast<QLineEdit *>(on);
547
                                scaleObject(le);
548
                            }
549
                            else if (n.startsWith("spinBox"))
550
                            {
551
                                QSpinBox *sb = dynamic_cast<QSpinBox *>(on);
552
                                scaleObject(sb);
553
                                QFont font = sb->font();
554
 
555
                                if (font.pixelSize() > 0)
556
                                    sb->setStyleSheet(QString("font-size: %1px").arg(font.pixelSize()));
557
                            }
558
                            else if (n.startsWith("comboBox"))
559
                            {
560
                                QComboBox *cb = dynamic_cast<QComboBox *>(on);
561
                                scaleObject(cb);
562
#ifdef __ANDROID__
563
                                QFont font = cb->font();
564
 
565
                                if (font.pixelSize() > 0)
566
                                {
567
                                    cb->setPalette(qt_fusionPalette());
568
                                    QColor txt = qt_fusionPalette().text().color();
569
                                    QColor back = qt_fusionPalette().button().color();
570
                                    QColor base = qt_fusionPalette().base().color();
571
                                    QString ss;
572
 
573
                                    ss = QString("font-size:%1px;color:%2;editable:{background-color:%3};drop-down:{color:%4;background:%5}")
574
                                            .arg(font.pixelSize())
575
                                            .arg(txt.name())
576
                                            .arg(back.name())
577
                                            .arg(txt.name())
578
                                            .arg(base.name());
579
 
580
                                    MSG_PROTOCOL("ComboBox style sheet: " << ss.toStdString());
581
                                    cb->setStyleSheet(ss);
582
                                }
583
#endif
584
                            }
585
                            else if (n.startsWith("horizontalSlider") || n.startsWith("verticalSlider"))
586
                                scaleObject(dynamic_cast<QSlider *>(on));
587
                            else if (n.startsWith("label"))
588
                            {
589
                                QLabel *lb = dynamic_cast<QLabel *>(on);
590
                                scaleObject(lb);
591
#ifdef __ANDROID__
592
                                lb->setPalette(qt_fusionPalette());
593
#endif
594
                            }
595
                        }
596
                    }
597
 
598
//                    if (namet.startsWith("tab"))
599
//                        scaleObject(dynamic_cast<QWidget *>(objt));
600
                }
601
            }
602
        }
603
        else if (name.startsWith("buttonBox"))
604
            scaleObject(dynamic_cast<QDialogButtonBox *>(obj));
605
    }
606
}
607
 
608
string TQtSettings::getSelectedFtpFile()
609
{
610
    DECL_TRACER("TQtSettings::getSelectedFtpFile()");
611
 
612
    if ((size_t)mIndex < mFileList.size())
613
        return mFileList[mIndex].fname;
614
 
615
    return string();
616
}
617
 
618
size_t TQtSettings::getSelectedFtpFileSize()
619
{
620
    DECL_TRACER("TQtSettings::getSelectedFtpFileSize()");
621
 
622
    if ((size_t)mIndex < mFileList.size())
623
        return mFileList[mIndex].size;
624
 
625
    return 0;
626
}
627
 
628
void TQtSettings::on_lineEdit_logFile_textChanged(const QString &arg1)
629
{
630
    DECL_TRACER("TQtSettings::on_lineEdit_logFile_textChanged(const QString &arg1)");
631
 
632
    if (arg1.compare(TConfig::getLogFile().c_str()) == 0)
633
        return;
634
 
635
    mSetChanged = true;
636
    TConfig::saveLogFile(arg1.toStdString());
637
}
638
 
639
void TQtSettings::on_lineEdit_Controller_textChanged(const QString &arg1)
640
{
641
    DECL_TRACER("TQtSettings::on_lineEdit_Controller_textChanged(const QString &arg1)");
642
 
643
    if (arg1.compare(TConfig::getController().c_str()) == 0)
644
        return;
645
 
646
    mSetChanged = true;
647
    TConfig::saveController(arg1.toStdString());
648
}
649
 
650
void TQtSettings::on_spinBox_Port_valueChanged(int arg1)
651
{
652
    DECL_TRACER("TQtSettings::on_spinBox_Port_valueChanged(int arg1)");
653
 
654
    if (arg1 == TConfig::getPort())
655
        return;
656
 
657
    mSetChanged = true;
658
    TConfig::savePort(arg1);
659
}
660
 
661
void TQtSettings::on_spinBox_Channel_valueChanged(int arg1)
662
{
663
    DECL_TRACER("TQtSettings::on_spinBox_Channel_valueChanged(int arg1)");
664
 
665
    if (arg1 == TConfig::getChannel())
666
        return;
667
 
668
    mSetChanged = true;
669
    TConfig::saveChannel(arg1);
670
}
671
 
672
void TQtSettings::on_lineEdit_PType_textChanged(const QString &arg1)
673
{
674
    DECL_TRACER("TQtSettings::on_lineEdit_PType_textChanged(const QString &arg1)");
675
 
676
    if (arg1.compare(TConfig::getPanelType().c_str()) == 0)
677
        return;
678
 
679
    mSetChanged = true;
680
    TConfig::savePanelType(arg1.toStdString());
681
}
682
 
683
void TQtSettings::on_checkBox_Format_toggled(bool checked)
684
{
685
    DECL_TRACER("TQtSettings::on_checkBox_Format_toggled(bool checked)");
686
 
687
    if (TConfig::isLongFormat() == checked)
688
        return;
689
 
690
    mSetChanged = true;
691
    TConfig::saveFormat(checked);
692
}
693
 
694
void TQtSettings::on_checkBox_Scale_toggled(bool checked)
695
{
696
    DECL_TRACER("TQtSettings::on_checkBox_Scale_toggled(bool checked)");
697
 
698
    if (TConfig::getScale() == checked)
699
        return;
700
 
701
    mSetChanged = true;
702
    TConfig::saveScale(checked);
703
}
704
 
705
void TQtSettings::on_checkBox_Banner_toggled(bool checked)
706
{
707
    DECL_TRACER("TQtSettings::on_checkBox_Banner_toggled(bool checked)");
708
 
709
    if (TConfig::showBanner() == checked)
710
        return;
711
 
712
    mSetChanged = true;
713
    TConfig::saveBanner(!checked);
714
}
715
 
716
void TQtSettings::on_checkBox_ToolbarSuppress_toggled(bool checked)
717
{
718
    DECL_TRACER("TQtSettings::on_checkBox_ToolbarSuppress_toggled(bool checked)");
719
 
720
    if (TConfig::getToolbarSuppress() == checked)
721
        return;
722
 
723
    mSetChanged = true;
724
    TConfig::saveToolbarSuppress(checked);
725
    ui->checkBox_Toolbar->setDisabled(checked);
726
}
727
 
728
void TQtSettings::on_checkBox_Toolbar_toggled(bool checked)
729
{
730
    DECL_TRACER("TQtSettings::on_checkBox_Toolbar_toggled(bool checked)");
731
 
732
    if (TConfig::getToolbarForce() == checked)
733
        return;
734
 
735
    mSetChanged = true;
736
    TConfig::saveToolbarForce(checked);
737
}
738
 
739
void TQtSettings::on_checkBox_Rotation_toggled(bool checked)
740
{
741
    DECL_TRACER("TQtSettings::on_checkBox_Rotation_toggled(bool checked)");
742
 
743
    if (TConfig::getRotationFixed() == checked)
744
        return;
745
 
746
    mSetChanged = true;
747
    TConfig::setRotationFixed(checked);
748
}
749
 
750
void TQtSettings::on_checkBox_Profiling_toggled(bool checked)
751
{
752
    DECL_TRACER("TQtSettings::on_checkBox_Profiling_toggled(bool checked)");
753
 
754
    if (TConfig::getProfiling() == checked)
755
        return;
756
 
757
    mSetChanged = true;
758
    TConfig::saveProfiling(checked);
759
}
760
 
761
void TQtSettings::on_checkBox_LogInfo_toggled(bool checked)
762
{
763
    DECL_TRACER("TQtSettings::on_checkBox_LogInfo_toggled(bool checked)");
764
 
765
    if (mInitRun)
766
        return;
767
 
768
    if (checked && !(mLogLevel & HLOG_INFO))
769
    {
770
        mLogLevel |= HLOG_INFO;
771
        mSetChanged = true;
772
    }
773
    else if (!checked && (mLogLevel & HLOG_INFO))
774
    {
775
        mSetChanged = true;
776
        mLogLevel &= RLOG_INFO;
777
    }
778
 
779
    mInitRun = true;
780
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
781
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
782
 
783
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
784
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
785
 
786
    mInitRun = false;
787
    TConfig::saveLogLevel(mLogLevel);
788
}
789
 
790
void TQtSettings::on_checkBox_LogWarning_toggled(bool checked)
791
{
792
    DECL_TRACER("TQtSettings::on_checkBox_LogWarning_toggled(bool checked)");
793
 
794
    if (mInitRun)
795
        return;
796
 
797
    if (checked && !(mLogLevel & HLOG_WARNING))
798
    {
799
        mLogLevel |= HLOG_WARNING;
800
        mSetChanged = true;
801
    }
802
    else if (!checked && (mLogLevel & HLOG_WARNING))
803
    {
804
        mLogLevel &= RLOG_WARNING;
805
        mSetChanged = true;
806
    }
807
 
808
    mInitRun = true;
809
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
810
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
811
 
812
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
813
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
814
 
815
    mInitRun = false;
816
    TConfig::saveLogLevel(mLogLevel);
817
}
818
 
819
void TQtSettings::on_checkBox_LogError_toggled(bool checked)
820
{
821
    DECL_TRACER("TQtSettings::on_checkBox_LogError_toggled(bool checked)");
822
 
823
    if (mInitRun)
824
        return;
825
 
826
    if (checked && !(mLogLevel & HLOG_ERROR))
827
    {
828
        mSetChanged = true;
829
        mLogLevel |= HLOG_ERROR;
830
    }
831
    else if (!checked && (mLogLevel & HLOG_ERROR))
832
    {
833
        mLogLevel &= RLOG_ERROR;
834
        mSetChanged = true;
835
    }
836
 
837
    mInitRun = true;
838
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
839
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
840
 
841
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
842
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
843
 
844
    mInitRun = false;
845
    TConfig::saveLogLevel(mLogLevel);
846
}
847
 
848
void TQtSettings::on_checkBox_LogTrace_toggled(bool checked)
849
{
850
    DECL_TRACER("TQtSettings::on_checkBox_LogTrace_toggled(bool checked)");
851
 
852
    if (mInitRun)
853
        return;
854
 
855
    if (checked && !(mLogLevel & HLOG_TRACE))
856
    {
857
        mLogLevel |= HLOG_TRACE;
858
        mSetChanged = true;
859
    }
860
    else if (!checked && (mLogLevel & HLOG_TRACE))
861
    {
862
        mLogLevel &= RLOG_TRACE;
863
        mSetChanged = true;
864
    }
865
 
866
    mInitRun = true;
867
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
868
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
869
 
870
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
871
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
872
 
873
    mInitRun = false;
874
    TConfig::saveLogLevel(mLogLevel);
875
}
876
 
877
void TQtSettings::on_checkBox_LogDebug_toggled(bool checked)
878
{
879
    DECL_TRACER("TQtSettings::on_checkBox_LogDebug_toggled(bool checked)");
880
 
881
    if (mInitRun)
882
        return;
883
 
884
    if (checked && !(mLogLevel & HLOG_DEBUG))
885
    {
886
        mLogLevel |= HLOG_DEBUG;
887
        mSetChanged = true;
888
    }
889
    else if (!checked && (mLogLevel & HLOG_DEBUG))
890
    {
891
        mLogLevel &= RLOG_DEBUG;
892
        mSetChanged = true;
893
    }
894
 
895
    mInitRun = true;
896
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
897
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
898
 
899
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
900
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
901
 
902
    mInitRun = false;
903
    TConfig::saveLogLevel(mLogLevel);
904
}
905
 
906
void TQtSettings::on_checkBox_LogProtocol_toggled(bool checked)
907
{
908
    DECL_TRACER("TQtSettings::on_checkBox_LogProtocol_toggled(bool checked)");
909
 
910
    if (mInitRun)
911
        return;
912
 
913
    if (checked && (mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
914
    {
915
        mLogLevel = HLOG_PROTOCOL;
916
        mInitRun = true;
917
        ui->checkBox_LogInfo->setCheckState(Qt::CheckState::Checked);
918
        ui->checkBox_LogWarning->setCheckState(Qt::CheckState::Checked);
919
        ui->checkBox_LogError->setCheckState(Qt::CheckState::Checked);
920
        ui->checkBox_LogTrace->setCheckState(Qt::CheckState::Unchecked);
921
        ui->checkBox_LogDebug->setCheckState(Qt::CheckState::Unchecked);
922
        TConfig::saveLogLevel(mLogLevel);
923
        mInitRun = false;
924
        mSetChanged = true;
925
    }
926
}
927
 
928
void TQtSettings::on_checkBox_LogAll_toggled(bool checked)
929
{
930
    DECL_TRACER("TQtSettings::on_checkBox_LogAll_toggled(bool checked)");
931
 
932
    if (mInitRun)
933
        return;
934
 
935
    if (checked && (mLogLevel & HLOG_ALL) != HLOG_ALL)
936
    {
937
        mLogLevel = HLOG_ALL;
938
        mInitRun = true;
939
        ui->checkBox_LogInfo->setCheckState(Qt::CheckState::Checked);
940
        ui->checkBox_LogWarning->setCheckState(Qt::CheckState::Checked);
941
        ui->checkBox_LogError->setCheckState(Qt::CheckState::Checked);
942
        ui->checkBox_LogTrace->setCheckState(Qt::CheckState::Checked);
943
        ui->checkBox_LogDebug->setCheckState(Qt::CheckState::Checked);
944
        TConfig::saveLogLevel(mLogLevel);
945
        mInitRun = false;
946
        mSetChanged = true;
947
    }
948
}
949
 
950
int TQtSettings::scale(int value)
951
{
952
    DECL_TRACER("TQtSettings::scale(int value)");
953
 
954
    if (value <= 0 || mScaleFactor == 1.0 || mScaleFactor < 0.0)
955
        return value;
956
 
957
    return (int)((double)value * mScaleFactor);
958
}
959
 
960
void TQtSettings::on_kiconbutton_reset_clicked()
961
{
962
    DECL_TRACER("TQtSettings::on_kiconbutton_reset_clicked()");
963
 
964
    char *HOME = getenv("HOME");
965
    QString logFile = TConfig::getLogFile().c_str();
966
 
967
    if (HOME)
968
    {
969
        logFile = HOME;
970
        logFile += "/tpanel/tpanel.log";
971
    }
972
 
973
    ui->lineEdit_logFile->setText(logFile);
974
}
975
 
976
void TQtSettings::on_lineEdit_FTPuser_textChanged(const QString& arg1)
977
{
978
    DECL_TRACER("TQtSettings::on_lineEdit_FTPuser_textChanged(const QString& arg1)");
979
 
980
    if (arg1.compare(TConfig::getFtpUser().c_str()) == 0)
981
        return;
982
 
983
    mSetChanged = true;
984
    TConfig::saveFtpUser(arg1.toStdString());
985
}
986
 
987
void TQtSettings::on_lineEdit_FTPpassword_textChanged(const QString& arg1)
988
{
989
    DECL_TRACER("TQtSettings::on_lineEdit_FTPpassword_textChanged(const QString& arg1)");
990
 
991
    if (arg1.compare(TConfig::getFtpPassword().c_str()) == 0)
992
        return;
993
 
994
    mSetChanged = true;
995
    TConfig::saveFtpPassword(arg1.toStdString());
996
}
997
 
998
void TQtSettings::on_comboBox_FTPsurface_currentTextChanged(const QString& arg1)
999
{
1000
    DECL_TRACER("TQtSettings::on_comboBox_FTPsurface_currentIndexChanged(const QString& arg1)");
1001
MSG_DEBUG("Comparing surface: " << arg1.toStdString() << " with " << TConfig::getFtpSurface());
1002
    if (arg1.compare(TConfig::getFtpSurface().c_str()) == 0)
1003
        return;
1004
 
1005
    mSetChanged = true;
1006
    TConfig::saveFtpSurface(arg1.toStdString());
1007
    MSG_DEBUG("Surface was set to " << arg1.toStdString());
1008
 
1009
    vector<TTPInit::FILELIST_t>::iterator iter;
1010
    int idx = 0;
1011
 
1012
    for (iter = mFileList.begin(); iter != mFileList.end(); ++iter)
1013
    {
1014
        if (iter->fname.compare(arg1.toStdString()) == 0)
1015
        {
1016
            mIndex = idx;
1017
            break;
1018
        }
1019
 
1020
        idx++;
1021
    }
1022
}
1023
 
1024
void TQtSettings::on_toolButton_Download_clicked()
1025
{
1026
    DECL_TRACER("TQtSettings::on_toolButton_Download_clicked()");
1027
 
1028
    QMessageBox box(this);
1029
    QString text = ui->comboBox_FTPsurface->currentText();
1030
 
1031
    box.setText("Do you realy want to download and install the surface <b>" + text + "</b>?");
1032
    box.addButton(QMessageBox::Yes);
1033
    box.addButton(QMessageBox::No);
1034
    int ret = box.exec();
1035
 
1036
    if (ret == QMessageBox::Yes)
1037
    {
1038
        mDownloadForce = true;
1039
        QString qss = QString("background-color: rgba(250, 0, 0, 0.9)");
1040
        ui->toolButton_Download->setStyleSheet(qss);
1041
    }
1042
    else
1043
    {
1044
        mDownloadForce = false;
1045
        QString qss = QString("background-color: rgba(209, 209, 209, 0.9)");
1046
        ui->toolButton_Download->setStyleSheet(qss);
1047
    }
1048
 
1049
    MSG_DEBUG("mDownloadForce=" << (mDownloadForce ? "YES" : "NO"));
1050
}
1051
 
1052
void TQtSettings::on_checkBox_FTPpassive_toggled(bool checked)
1053
{
1054
    DECL_TRACER("TQtSettings::on_checkBox_FTPpassive_toggled(bool checked)");
1055
 
1056
    if (TConfig::getFtpPassive() == checked)
1057
        return;
1058
 
1059
    mSetChanged = true;
1060
    TConfig::saveFtpPassive(checked);
1061
}
1062
 
1063
void TQtSettings::on_lineEdit_SIPproxy_textChanged(const QString& arg1)
1064
{
1065
    DECL_TRACER("TQtSettings::on_lineEdit_SIPproxy_textChanged(const QString& arg1)");
1066
 
1067
    if (arg1.compare(TConfig::getSIPproxy().c_str()) == 0)
1068
        return;
1069
 
1070
    mSetChanged = true;
1071
    TConfig::setSIPproxy(arg1.toStdString());
1072
}
1073
 
1074
void TQtSettings::on_spinBox_SIPport_valueChanged(int arg1)
1075
{
1076
    DECL_TRACER("TQtSettings::on_spinBox_SIPport_valueChanged(int arg1)");
1077
 
1078
    if (TConfig::getSIPport() == arg1)
1079
        return;
1080
 
1081
    mSetChanged = true;
1082
    TConfig::setSIPport(arg1);
1083
}
1084
 
1085
void TQtSettings::on_spinBox_SIPportTLS_valueChanged(int arg1)
1086
{
1087
    DECL_TRACER("TQtSettings::on_spinBoxTLS_SIPport_valueChanged(int arg1)");
1088
 
1089
    if (TConfig::getSIPportTLS() == arg1)
1090
        return;
1091
 
1092
    mSetChanged = true;
1093
    TConfig::setSIPportTLS(arg1);
1094
}
1095
 
1096
void TQtSettings::on_lineEdit_SIPstun_textChanged(const QString& arg1)
1097
{
1098
    DECL_TRACER("TQtSettings::on_lineEdit_SIPstun_textChanged(const QString& arg1)");
1099
 
1100
    if (arg1.compare(TConfig::getSIPstun().c_str()) == 0)
1101
        return;
1102
 
1103
    mSetChanged = true;
1104
    TConfig::setSIPstun(arg1.toStdString());
1105
}
1106
 
1107
void TQtSettings::on_lineEdit_SIPdomain_textChanged(const QString& arg1)
1108
{
1109
    DECL_TRACER("TQtSettings::on_lineEdit_SIPdomain_textChanged(const QString& arg1)");
1110
 
1111
    if (arg1.compare(TConfig::getSIPdomain().c_str()) == 0)
1112
        return;
1113
 
1114
    mSetChanged = true;
1115
    TConfig::setSIPdomain(arg1.toStdString());
1116
}
1117
 
1118
void TQtSettings::on_lineEdit_SIPuser_textChanged(const QString& arg1)
1119
{
1120
    DECL_TRACER("TQtSettings::on_lineEdit_SIPuser_textChanged(const QString& arg1)");
1121
 
1122
    if (arg1.compare(TConfig::getSIPuser().c_str()) == 0)
1123
        return;
1124
 
1125
    mSetChanged = true;
1126
    TConfig::setSIPuser(arg1.toStdString());
1127
}
1128
 
1129
void TQtSettings::on_lineEdit_SIPpassword_textChanged(const QString& arg1)
1130
{
1131
    DECL_TRACER("TQtSettings::on_lineEdit_SIPpassword_textChanged(const QString& arg1)");
1132
 
1133
    if (arg1.compare(TConfig::getSIPpassword().c_str()) == 0)
1134
        return;
1135
 
1136
    mSetChanged = true;
1137
    TConfig::setSIPpassword(arg1.toStdString());
1138
}
1139
 
1140
void TQtSettings::on_checkBox_SIPnetworkIPv4_toggled(bool checked)
1141
{
1142
    DECL_TRACER("TQtSettings::on_checkBox_SIPnetworkIPv4_toggled(bool checked)");
1143
 
1144
    if (TConfig::getSIPnetworkIPv4() == checked)
1145
        return;
1146
 
1147
    mSetChanged = true;
1148
    TConfig::setSIPnetworkIPv4(checked);
1149
}
1150
 
1151
void TQtSettings::on_checkBox_SIPnetworkIPv6_toggled(bool checked)
1152
{
1153
    DECL_TRACER("TQtSettings::on_checkBox_SIPnetworkIPv6_toggled(bool checked)");
1154
 
1155
    if (TConfig::getSIPnetworkIPv6() == checked)
1156
        return;
1157
 
1158
    mSetChanged = true;
1159
    TConfig::setSIPnetworkIPv6(checked);
1160
}
1161
 
1162
void TQtSettings::on_comboBox_SIPfirewall_currentIndexChanged(int index)
1163
{
1164
    DECL_TRACER("TQtSettings::on_comboBox_SIPfirewall_currentIndexChanged(const QString& arg1)");
1165
 
1166
    TConfig::SIP_FIREWALL_t fw;
1167
 
1168
    switch(index)
1169
    {
1170
        case 0: fw = TConfig::SIP_NO_FIREWALL; break;
1171
        case 1: fw = TConfig::SIP_STUN; break;
1172
        case 2: fw = TConfig::SIP_ICE; break;
1173
        case 3: fw = TConfig::SIP_UPNP; break;
1174
 
1175
        default:
1176
            fw = TConfig::SIP_NO_FIREWALL;
1177
    }
1178
 
1179
    if (TConfig::getSIPfirewall() == fw)
1180
        return;
1181
 
1182
    mSetChanged = true;
1183
    TConfig::setSIPfirewall(fw);
1184
}
1185
 
1186
void TQtSettings::on_checkBox_SIPenabled_toggled(bool checked)
1187
{
1188
    DECL_TRACER("TQtSettings::on_checkBox_SIPenabled_toggled(bool checked)");
1189
 
1190
    if (TConfig::getSIPstatus() == checked)
1191
        return;
1192
 
1193
    mSetChanged = true;
1194
    TConfig::setSIPstatus(checked);
1195
}
1196
 
1197
void TQtSettings::on_checkBox_SIPiphone_toggled(bool checked)
1198
{
1199
    DECL_TRACER("TQtSettings::on_checkBox_SIPiphone_toggled(bool checked)");
1200
 
1201
    if (TConfig::getSIPiphone() == checked)
1202
        return;
1203
 
1204
    mSetChanged = true;
1205
    TConfig::setSIPiphone(checked);
1206
}
1207
 
1208
void TQtSettings::on_comboBox_SystemSound_currentTextChanged(const QString& arg1)
1209
{
1210
    DECL_TRACER("TQtSettings::on_comboBox_SystemSound_currentIndexChanged(const QString& arg1)");
1211
 
1212
    if (arg1.compare(TConfig::getSystemSound().c_str()) == 0)
1213
        return;
1214
 
1215
    mSetChanged = true;
1216
    TConfig::saveSystemSoundFile(arg1.toStdString() + ".wav");
1217
}
1218
 
1219
void TQtSettings::on_toolButton_SystemSound_clicked()
1220
{
1221
    DECL_TRACER("TQtSettings::on_toolButton_SystemSound_clicked()");
1222
 
1223
    QString selected = ui->comboBox_SystemSound->currentText();
1224
    string file = TConfig::getProjectPath() + "/__system/graphics/sounds/" + selected.toStdString() + ".wav";
1225
 
1226
    if (gPageManager)
1227
        gPageManager->getCallPlaySound()(file);
1228
}
1229
 
1230
void TQtSettings::on_comboBox_SingleBeep_currentTextChanged(const QString& arg1)
1231
{
1232
    DECL_TRACER("TQtSettings::on_comboBox_SingleBeep_currentIndexChanged(const QString& arg1)");
1233
 
1234
    if (arg1.compare(TConfig::getSingleBeepSound().c_str()) == 0)
1235
        return;
1236
 
1237
    string file = arg1.toStdString();
1238
    size_t pos = file.find_last_of(" ");
1239
 
1240
    if (pos != string::npos)
1241
    {
1242
        int num = atoi(file.substr(pos).c_str());
1243
        file = "singleBeep";
1244
 
1245
        if (num > 0)
1246
        {
1247
            if (num < 10)
1248
                file += "0" + std::to_string(num);
1249
            else
1250
                file += std::to_string(num);
1251
        }
1252
 
1253
        file += ".wav";
1254
    }
1255
 
1256
    mSetChanged = true;
1257
    TConfig::saveSingleBeepFile(file);
1258
}
1259
 
1260
void TQtSettings::on_toolButton_SingleBeep_clicked()
1261
{
1262
    DECL_TRACER("TQtSettings::on_toolButton_SingleBeep_clicked()");
1263
 
1264
    QString selected = ui->comboBox_SingleBeep->currentText();
1265
    string file = selected.toStdString();
1266
    size_t pos = file.find_last_of(" ");
1267
 
1268
    if (pos != string::npos)
1269
    {
1270
        int num = atoi(file.substr(pos).c_str());
1271
        file = TConfig::getProjectPath() + "/__system/graphics/sounds/singleBeep";
1272
 
1273
        if (num > 0)
1274
        {
1275
            if (num < 10)
1276
                file += "0" + std::to_string(num);
1277
            else
1278
                file += std::to_string(num);
1279
        }
1280
 
1281
        file += ".wav";
1282
    }
1283
 
1284
//    playFile(file);
1285
 
1286
    if (gPageManager)
1287
        gPageManager->getCallPlaySound()(file);
1288
}
1289
 
1290
void TQtSettings::on_comboBox_DoubleBeep_currentTextChanged(const QString& arg1)
1291
{
1292
    DECL_TRACER("TQtSettings::on_comboBox_DoubleBeep_currentIndexChanged(const QString& arg1)");
1293
 
1294
    if (arg1.compare(TConfig::getDoubleBeepSound().c_str()) == 0)
1295
        return;
1296
 
1297
    string file = arg1.toStdString();
1298
    size_t pos = file.find_last_of(" ");
1299
 
1300
    if (pos != string::npos)
1301
    {
1302
        int num = atoi(file.substr(pos).c_str());
1303
        file = "doubleBeep";
1304
 
1305
        if (num > 0)
1306
        {
1307
            if (num < 10)
1308
                file += "0" + std::to_string(num);
1309
            else
1310
                file += std::to_string(num);
1311
        }
1312
 
1313
        file += ".wav";
1314
    }
1315
 
1316
    mSetChanged = true;
1317
    TConfig::saveDoubleBeepFile(file);
1318
}
1319
 
1320
void TQtSettings::on_toolButton_DoubleBeep_clicked()
1321
{
1322
    DECL_TRACER("TQtSettings::on_toolButton_DoubleBeep_clicked()");
1323
 
1324
    QString selected = ui->comboBox_DoubleBeep->currentText();
1325
    string file = selected.toStdString();
1326
    size_t pos = file.find_last_of(" ");
1327
 
1328
    if (pos != string::npos)
1329
    {
1330
        int num = atoi(file.substr(pos).c_str());
1331
        file = TConfig::getProjectPath() + "/__system/graphics/sounds/doubleBeep";
1332
 
1333
        if (num > 0)
1334
        {
1335
            if (num < 10)
1336
                file += "0" + std::to_string(num);
1337
            else
1338
                file += std::to_string(num);
1339
        }
1340
 
1341
        file += ".wav";
1342
    }
1343
 
1344
 
1345
//    playFile(file);
1346
 
1347
    if (gPageManager)
1348
        gPageManager->getCallPlaySound()(file);
1349
}
1350
 
1351
void TQtSettings::on_checkBox_SystemSound_toggled(bool checked)
1352
{
1353
    DECL_TRACER("TQtSettings::on_checkBox_SystemSound_toggled(bool checked)");
1354
 
1355
    if (TConfig::getSystemSoundState() == checked)
1356
        return;
1357
 
1358
    mSetChanged = true;
1359
    TConfig::saveSystemSoundState(checked);
1360
}
1361
 
1362
void TQtSettings::on_toolButton_TestSound_clicked()
1363
{
1364
    DECL_TRACER("TQtSettings::on_toolButton_TestSound_clicked()");
1365
 
1366
    if (gPageManager)
1367
        gPageManager->getCallPlaySound()(TConfig::getProjectPath() + "/__system/graphics/sounds/audioTest.wav");
1368
}
1369
 
1370
void TQtSettings::on_horizontalSlider_Volume_valueChanged(int value)
1371
{
1372
    DECL_TRACER("TQtSettings::on_horizontalSlider_Volume_valueChanged(int value)");
1373
 
1374
    if (TConfig::getSystemVolume() == value)
1375
        return;
1376
 
1377
    TConfig::saveSystemVolume(value);
1378
 
1379
    if (gPageManager && gPageManager->getCallSetVolume())
1380
        gPageManager->getCallSetVolume()(value);
1381
}
1382
 
1383
void TQtSettings::on_horizontalSlider_Gain_valueChanged(int value)
1384
{
1385
    DECL_TRACER("TQtSettings::on_horizontalSlider_Gain_valueChanged(int value)");
1386
 
1387
    if (TConfig::getSystemGain() == value)
1388
        return;
1389
 
1390
    TConfig::saveSystemGain(value);
1391
}
1392
 
1393
void TQtSettings::on_lineEdit_Password1_textChanged(const QString& arg)
1394
{
1395
    DECL_TRACER("TQtSettings::on_lineEdit_Password1_textChanged(const QString& arg)");
1396
 
1397
    if (arg.compare(TConfig::getPassword1().c_str()) == 0)
1398
        return;
1399
 
1400
    mSetChanged = true;
1401
    TConfig::savePassword1(arg.toStdString());
1402
}
1403
 
1404
void TQtSettings::on_lineEdit_Password2_textChanged(const QString& arg)
1405
{
1406
    DECL_TRACER("TQtSettings::on_lineEdit_Password2_textChanged(const QString& arg)");
1407
 
1408
    if (arg.compare(TConfig::getPassword2().c_str()) == 0)
1409
        return;
1410
 
1411
    mSetChanged = true;
1412
    TConfig::savePassword2(arg.toStdString());
1413
}
1414
 
1415
void TQtSettings::on_lineEdit_Password3_textChanged(const QString& arg)
1416
{
1417
    DECL_TRACER("TQtSettings::on_lineEdit_Password3_textChanged(const QString& arg)");
1418
 
1419
    if (arg.compare(TConfig::getPassword3().c_str()) == 0)
1420
        return;
1421
 
1422
    mSetChanged = true;
1423
    TConfig::savePassword3(arg.toStdString());
1424
}
1425
 
1426
void TQtSettings::on_lineEdit_Password4_textChanged(const QString& arg)
1427
{
1428
    DECL_TRACER("TQtSettings::on_lineEdit_Password4_textChanged(const QString& arg)");
1429
 
1430
    if (arg.compare(TConfig::getPassword4().c_str()) == 0)
1431
        return;
1432
 
1433
    mSetChanged = true;
1434
    TConfig::savePassword4(arg.toStdString());
1435
}
1436
 
1437
void TQtSettings::on_pushButton_ViewPW1_clicked()
1438
{
1439
    DECL_TRACER("TQtSettings::on_pushButton_ViewPW1_clicked()");
1440
 
1441
    if (ui->lineEdit_Password1->echoMode() == QLineEdit::Password)
1442
        ui->lineEdit_Password1->setEchoMode(QLineEdit::Normal);
1443
    else
1444
        ui->lineEdit_Password1->setEchoMode(QLineEdit::Password);
1445
}
1446
 
1447
void TQtSettings::on_pushButton_ViewPW2_clicked()
1448
{
1449
    DECL_TRACER("TQtSettings::on_pushButton_ViewPW2_clicked()");
1450
 
1451
    if (ui->lineEdit_Password2->echoMode() == QLineEdit::Password)
1452
        ui->lineEdit_Password2->setEchoMode(QLineEdit::Normal);
1453
    else
1454
        ui->lineEdit_Password2->setEchoMode(QLineEdit::Password);
1455
}
1456
 
1457
void TQtSettings::on_pushButton_ViewPW3_clicked()
1458
{
1459
    DECL_TRACER("TQtSettings::on_pushButton_ViewPW3_clicked()");
1460
 
1461
    if (ui->lineEdit_Password3->echoMode() == QLineEdit::Password)
1462
        ui->lineEdit_Password3->setEchoMode(QLineEdit::Normal);
1463
    else
1464
        ui->lineEdit_Password3->setEchoMode(QLineEdit::Password);
1465
}
1466
 
1467
void TQtSettings::on_pushButton_ViewPW4_clicked()
1468
{
1469
    DECL_TRACER("TQtSettings::on_pushButton_ViewPW4_clicked()");
1470
 
1471
    if (ui->lineEdit_Password4->echoMode() == QLineEdit::Password)
1472
        ui->lineEdit_Password4->setEchoMode(QLineEdit::Normal);
1473
    else
1474
        ui->lineEdit_Password4->setEchoMode(QLineEdit::Password);
1475
}