Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

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