Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

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