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
59 andreas 265
    mInitRun = false;
266
    mSetChanged = false;
2 andreas 267
}
268
 
269
TQtSettings::~TQtSettings()
270
{
3 andreas 271
	DECL_TRACER("TQtSettings::~TQtSettings()");
2 andreas 272
	delete ui;
273
}
43 andreas 274
 
120 andreas 275
#ifdef __ANDROID__
276
QPalette TQtSettings::qt_fusionPalette()
277
{
278
    QColor backGround(239, 239, 239);
279
    QColor light = backGround.lighter(150);
280
    QColor mid(backGround.darker(130));
281
    QColor midLight = mid.lighter(110);
282
    QColor base = Qt::white;
283
    QColor disabledBase(backGround);
284
    QColor dark = backGround.darker(150);
285
    QColor darkDisabled = QColor(209, 209, 209).darker(110);
286
    QColor text = Qt::black;
126 andreas 287
    QColor hightlightedText = Qt::darkGray;
120 andreas 288
    QColor disabledText = QColor(190, 190, 190);
289
    QColor button = backGround;
290
    QColor shadow = dark.darker(135);
291
    QColor disabledShadow = shadow.lighter(150);
292
 
293
    QPalette fusionPalette(Qt::black,backGround,light,dark,mid,text,base);
294
    fusionPalette.setBrush(QPalette::Midlight, midLight);
295
    fusionPalette.setBrush(QPalette::Button, button);
296
    fusionPalette.setBrush(QPalette::Shadow, shadow);
297
    fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText);
298
 
299
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText);
300
    fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText);
301
    fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText);
302
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase);
303
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
304
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
305
 
306
    fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198));
307
    fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(48, 140, 198));
308
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 145, 145));
309
    return fusionPalette;
310
}
311
#endif
312
 
22 andreas 313
void TQtSettings::on_kiconbutton_logFile_clicked()
314
{
41 andreas 315
    DECL_TRACER("TQtSettings::on_kiconbutton_logFile_clicked()");
316
 
22 andreas 317
    std::string pt = TConfig::getLogFile();
318
    size_t pos = pt.find_last_of("/");
319
 
320
    if (pos != std::string::npos)
321
        pt = pt.substr(0, pos);
322
    else
23 andreas 323
    {
324
        char hv0[4096];
325
        getcwd(hv0, sizeof(hv0));
326
        pt = hv0;
327
    }
22 andreas 328
 
329
    QString actPath(pt.c_str());
43 andreas 330
    QFileDialog fdialog(this, tr("Logfile"), actPath, tr("TPanel.log (*.log)"));
23 andreas 331
    fdialog.setAcceptMode(QFileDialog::AcceptSave);
332
    fdialog.setDefaultSuffix("log");
333
    fdialog.setOption(QFileDialog::DontConfirmOverwrite);
334
    QString fname;
335
 
336
    if (fdialog.exec())
337
    {
338
        QDir dir = fdialog.directory();
339
        QStringList list = fdialog.selectedFiles();
340
 
341
        if (list.size() > 0)
342
            fname = dir.absoluteFilePath(list.at(0));
343
        else
344
            return;
345
    }
346
    else
347
        return;
348
 
182 andreas 349
#ifdef Q_OS_ANDROID
43 andreas 350
    QString fileName = fname;
351
 
352
    if (fileName.contains("content://"))
353
    {
264 andreas 354
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
43 andreas 355
        QAndroidJniObject uri = QAndroidJniObject::callStaticObjectMethod(
356
              "android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;",
357
              QAndroidJniObject::fromString(fileName).object<jstring>());
358
 
359
        fileName =
360
              QAndroidJniObject::callStaticObjectMethod(
361
                  "org/qtproject/theosys/UriToPath", "getFileName",
362
                  "(Landroid/net/Uri;Landroid/content/Context;)Ljava/lang/String;",
363
                  uri.object(), QtAndroid::androidContext().object()).toString();
182 andreas 364
#else
365
        QJniObject uri = QJniObject::callStaticObjectMethod(
366
              "android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;",
367
              QJniObject::fromString(fileName).object<jstring>());
43 andreas 368
 
182 andreas 369
        fileName =
370
              QJniObject::callStaticObjectMethod(
371
                  "org/qtproject/theosys/UriToPath", "getFileName",
372
                  "(Landroid/net/Uri;Landroid/content/Context;)Ljava/lang/String;",
373
                  uri.object(), QNativeInterface::QAndroidApplication::context()).toString();
374
#endif
43 andreas 375
        if (fileName.length() > 0)
376
            fname = fileName;
377
    }
378
    else
379
    {
380
        MSG_WARNING("Not an Uri? (" << fname.toStdString() << ")");
381
    }
382
#endif
23 andreas 383
    ui->lineEdit_logFile->setText(fname);
384
 
385
    if (TConfig::getLogFile().compare(fname.toStdString()) != 0)
386
    {
387
        mSetChanged = true;
388
        TConfig::saveLogFile(fname.toStdString());
389
    }
22 andreas 390
}
43 andreas 391
 
120 andreas 392
template<typename T>
393
void TQtSettings::scaleObject(T *obj)
394
{
395
    DECL_TRACER("TQtSettings::scaleObject(T *obj)");
396
 
397
    QSize size = obj->size();
178 andreas 398
    QFont font = obj->font();
120 andreas 399
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
400
    obj->resize(size);
401
    QRect rect = obj->geometry();
402
    obj->move(scale(rect.left()), scale(rect.top()));
155 andreas 403
 
156 andreas 404
    double fontSize = -1.0;
405
    int pixelSize = -1;
155 andreas 406
 
156 andreas 407
    if (font.pointSizeF() > 0.0 && mRatioFont != 1.0)
408
        fontSize = font.pointSizeF() * mRatioFont;
409
    else if (font.pointSize() > 0 && mRatioFont != 1.0)
410
        fontSize = font.pointSize() * mRatioFont;
178 andreas 411
    else if (font.pixelSize() > 0 && mRatioFont != 1.0)
412
        pixelSize = (int)((double)font.pixelSize() * mRatioFont);
413
    else if (font.pixelSize() >= 8)
414
        return;
156 andreas 415
 
416
    if (fontSize >= 6.0)
155 andreas 417
        font.setPointSizeF(fontSize);
156 andreas 418
    else if (pixelSize >= 8)
419
        font.setPixelSize(pixelSize);
420
    else
178 andreas 421
        font.setPointSizeF(11.0);
156 andreas 422
 
423
    obj->setFont(font);
120 andreas 424
}
425
 
40 andreas 426
void TQtSettings::doResize()
427
{
41 andreas 428
    DECL_TRACER("TQtSettings::doResize()");
429
 
40 andreas 430
    // The main dialog window
431
    QSize size = this->size();
41 andreas 432
    QRect rect = this->geometry();
155 andreas 433
    QRect rectGui = QGuiApplication::primaryScreen()->geometry();
156 andreas 434
    qreal height = 0.0;
435
    qreal width = 0.0;
155 andreas 436
 
156 andreas 437
    if (gPageManager->getSettings()->isPortrait())
438
    {
439
        height = qMax(rectGui.width(), rectGui.height());
440
        width = qMin(rectGui.width(), rectGui.height());
155 andreas 441
 
156 andreas 442
        if (rectGui.width() > rectGui.height())
443
            mScaleFactor = qMin(height / rect.height(), width / rect.width());
444
    }
445
    else
446
    {
447
        height = qMin(rectGui.width(), rectGui.height());
448
        width = qMax(rectGui.width(), rectGui.height());
449
 
450
        if (rectGui.width() < rectGui.height())
451
            mScaleFactor = qMax(height / rect.height(), width / rect.width());
452
    }
453
 
40 andreas 454
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
455
    this->resize(size);
155 andreas 456
 
41 andreas 457
    QWidget *parent = this->parentWidget();
458
 
155 andreas 459
    if (rect.width() > rectGui.width() || rect.height() > rectGui.height())
460
        this->move(0, 0);
461
    else if (parent && rect.width() < rectGui.width() && rect.height() < rectGui.height())
41 andreas 462
    {
463
        rect = parent->geometry();
464
        this->move(rect.center() - this->rect().center());
465
    }
155 andreas 466
    else
467
        this->move(scale(rect.left()), scale(rect.top()));
41 andreas 468
 
155 andreas 469
    // Font size calculation
217 andreas 470
    double refWidth = gPageManager->getSettings()->getWidth();
155 andreas 471
    double refHeight = gPageManager->getSettings()->getHeight();
472
    double dpi = QGuiApplication::primaryScreen()->logicalDotsPerInch();
178 andreas 473
    double amxDpi = dpi / ((width > height) ? width : height) * ((refWidth > refHeight) ? refWidth : refHeight);
474
    mRatioFont = qMin(height * amxDpi / (dpi * refHeight), width * amxDpi / (dpi * refWidth));
475
//    MSG_PROTOCOL("qMin(" << height << " * " << amxDpi << " / " << "(" << dpi << " * " << refHeight << "), " << width << " * " << amxDpi << " / " << "(" << dpi << " * " << refWidth << "))");
476
//    MSG_PROTOCOL("Original DPI: " << dpi << ", initial AMX DPI: " << amxDpi << ", font scale factor: " << mRatioFont);
59 andreas 477
    // Layout
118 andreas 478
    // Iterate through childs and resize them
479
    QObjectList childs = children();
480
    QList<QObject *>::Iterator iter;
59 andreas 481
 
118 andreas 482
    for (iter = childs.begin(); iter != childs.end(); ++iter)
483
    {
181 andreas 484
        QObject *obj = *iter;
485
        QString name = obj->objectName();
59 andreas 486
 
120 andreas 487
        if (name.startsWith("tabWidget"))
118 andreas 488
        {
156 andreas 489
            QTabWidget *tw = dynamic_cast<QTabWidget *>(obj);
490
            scaleObject(tw);
157 andreas 491
#ifdef __ANDROID__
156 andreas 492
            QColor txt = qt_fusionPalette().Text;
493
            tw->setStyleSheet(QString("color: %1").arg(txt.name()));
157 andreas 494
#endif
120 andreas 495
            QObjectList childsTab = obj->children();
496
            QList<QObject *>::Iterator iterTab;
497
 
498
            for (iterTab = childsTab.begin(); iterTab != childsTab.end(); ++iterTab)
499
            {
181 andreas 500
                QObject *objt = *iterTab;
501
                QString namet = objt->objectName();
120 andreas 502
 
503
                if (namet.startsWith("qt_tabwidget_stackedwidget"))
504
                {
505
                    QObjectList childsStack = objt->children();
506
                    QList<QObject *>::Iterator iterStack;
507
 
508
                    for (iterStack = childsStack.begin(); iterStack != childsStack.end(); ++iterStack)
509
                    {
181 andreas 510
                        QObject *objStack = *iterStack;
511
                        QObjectList tabStack = objStack->children();
120 andreas 512
                        QList<QObject *>::Iterator tabIter;
513
 
514
                        for (tabIter = tabStack.begin(); tabIter != tabStack.end(); ++tabIter)
515
                        {
181 andreas 516
                            QObject *on = *tabIter;
517
                            QString n = on->objectName();
120 andreas 518
 
126 andreas 519
                            if (n.startsWith("kiconbutton") || n.startsWith("toolButton"))
120 andreas 520
                                scaleObject(dynamic_cast<QToolButton *>(on));
521
                            else if (n.startsWith("checkBox"))
522
                            {
178 andreas 523
                                QCheckBox *cb = dynamic_cast<QCheckBox *>(on);
524
                                scaleObject(cb);
120 andreas 525
#ifdef __ANDROID__
526
                                cb->setPalette(qt_fusionPalette());
184 andreas 527
                                QSize size = cb->size();
528
                                QString ss = QString("spacing:%1;indicator:{width:%2px;height:%3px;}").arg(scale(5)).arg(size.height()).arg(size.height());
529
                                MSG_PROTOCOL("CheckBox style sheet: " << ss.toStdString());
530
                                cb->setStyleSheet(ss);
120 andreas 531
#endif
532
                            }
533
                            else if (n.startsWith("lineEdit"))
178 andreas 534
                            {
535
                                QLineEdit *le = dynamic_cast<QLineEdit *>(on);
536
                                scaleObject(le);
537
                            }
120 andreas 538
                            else if (n.startsWith("spinBox"))
156 andreas 539
                            {
540
                                QSpinBox *sb = dynamic_cast<QSpinBox *>(on);
178 andreas 541
                                scaleObject(sb);
156 andreas 542
                                QFont font = sb->font();
543
 
544
                                if (font.pixelSize() > 0)
178 andreas 545
                                    sb->setStyleSheet(QString("font-size: %1px").arg(font.pixelSize()));
156 andreas 546
                            }
122 andreas 547
                            else if (n.startsWith("comboBox"))
156 andreas 548
                            {
549
                                QComboBox *cb = dynamic_cast<QComboBox *>(on);
178 andreas 550
                                scaleObject(cb);
323 andreas 551
#ifdef __ANDROID__
156 andreas 552
                                QFont font = cb->font();
323 andreas 553
 
156 andreas 554
                                if (font.pixelSize() > 0)
555
                                {
178 andreas 556
                                    cb->setPalette(qt_fusionPalette());
557
                                    QColor txt = qt_fusionPalette().text().color();
558
                                    QColor back = qt_fusionPalette().button().color();
559
                                    QColor base = qt_fusionPalette().base().color();
560
                                    QString ss;
561
 
562
                                    ss = QString("font-size:%1px;color:%2;editable:{background-color:%3};drop-down:{color:%4;background:%5}")
563
                                            .arg(font.pixelSize())
564
                                            .arg(txt.name())
565
                                            .arg(back.name())
566
                                            .arg(txt.name())
567
                                            .arg(base.name());
568
 
569
                                    MSG_PROTOCOL("ComboBox style sheet: " << ss.toStdString());
570
                                    cb->setStyleSheet(ss);
156 andreas 571
                                }
157 andreas 572
#endif
156 andreas 573
                            }
141 andreas 574
                            else if (n.startsWith("horizontalSlider") || n.startsWith("verticalSlider"))
575
                                scaleObject(dynamic_cast<QSlider *>(on));
120 andreas 576
                            else if (n.startsWith("label"))
577
                            {
178 andreas 578
                                QLabel *lb = dynamic_cast<QLabel *>(on);
579
                                scaleObject(lb);
120 andreas 580
#ifdef __ANDROID__
581
                                lb->setPalette(qt_fusionPalette());
582
#endif
583
                            }
584
                        }
585
                    }
586
 
587
//                    if (namet.startsWith("tab"))
588
//                        scaleObject(dynamic_cast<QWidget *>(objt));
589
                }
590
            }
118 andreas 591
        }
120 andreas 592
        else if (name.startsWith("buttonBox"))
593
            scaleObject(dynamic_cast<QDialogButtonBox *>(obj));
118 andreas 594
    }
40 andreas 595
}
41 andreas 596
 
179 andreas 597
string TQtSettings::getSelectedFtpFile()
598
{
599
    DECL_TRACER("TQtSettings::getSelectedFtpFile()");
600
 
601
    if ((size_t)mIndex < mFileList.size())
602
        return mFileList[mIndex].fname;
603
 
604
    return string();
605
}
606
 
607
size_t TQtSettings::getSelectedFtpFileSize()
608
{
609
    DECL_TRACER("TQtSettings::getSelectedFtpFileSize()");
610
 
611
    if ((size_t)mIndex < mFileList.size())
612
        return mFileList[mIndex].size;
613
 
614
    return 0;
615
}
616
 
23 andreas 617
void TQtSettings::on_lineEdit_logFile_textChanged(const QString &arg1)
618
{
41 andreas 619
    DECL_TRACER("TQtSettings::on_lineEdit_logFile_textChanged(const QString &arg1)");
620
 
23 andreas 621
    if (arg1.compare(TConfig::getLogFile().c_str()) == 0)
622
        return;
623
 
624
    mSetChanged = true;
625
    TConfig::saveLogFile(arg1.toStdString());
626
}
43 andreas 627
 
23 andreas 628
void TQtSettings::on_lineEdit_Controller_textChanged(const QString &arg1)
629
{
41 andreas 630
    DECL_TRACER("TQtSettings::on_lineEdit_Controller_textChanged(const QString &arg1)");
631
 
23 andreas 632
    if (arg1.compare(TConfig::getController().c_str()) == 0)
633
        return;
634
 
635
    mSetChanged = true;
636
    TConfig::saveController(arg1.toStdString());
637
}
638
 
639
void TQtSettings::on_spinBox_Port_valueChanged(int arg1)
640
{
41 andreas 641
    DECL_TRACER("TQtSettings::on_spinBox_Port_valueChanged(int arg1)");
642
 
23 andreas 643
    if (arg1 == TConfig::getPort())
644
        return;
645
 
646
    mSetChanged = true;
647
    TConfig::savePort(arg1);
648
}
649
 
650
void TQtSettings::on_spinBox_Channel_valueChanged(int arg1)
651
{
41 andreas 652
    DECL_TRACER("TQtSettings::on_spinBox_Channel_valueChanged(int arg1)");
653
 
23 andreas 654
    if (arg1 == TConfig::getChannel())
655
        return;
656
 
657
    mSetChanged = true;
658
    TConfig::saveChannel(arg1);
659
}
660
 
661
void TQtSettings::on_lineEdit_PType_textChanged(const QString &arg1)
662
{
41 andreas 663
    DECL_TRACER("TQtSettings::on_lineEdit_PType_textChanged(const QString &arg1)");
664
 
23 andreas 665
    if (arg1.compare(TConfig::getPanelType().c_str()) == 0)
666
        return;
667
 
668
    mSetChanged = true;
669
    TConfig::savePanelType(arg1.toStdString());
670
}
671
 
672
void TQtSettings::on_checkBox_Format_toggled(bool checked)
673
{
41 andreas 674
    DECL_TRACER("TQtSettings::on_checkBox_Format_toggled(bool checked)");
675
 
23 andreas 676
    if (TConfig::isLongFormat() == checked)
677
        return;
678
 
679
    mSetChanged = true;
680
    TConfig::saveFormat(checked);
681
}
24 andreas 682
 
683
void TQtSettings::on_checkBox_Scale_toggled(bool checked)
684
{
41 andreas 685
    DECL_TRACER("TQtSettings::on_checkBox_Scale_toggled(bool checked)");
686
 
24 andreas 687
    if (TConfig::getScale() == checked)
688
        return;
689
 
690
    mSetChanged = true;
691
    TConfig::saveScale(checked);
692
}
35 andreas 693
 
118 andreas 694
void TQtSettings::on_checkBox_Banner_toggled(bool checked)
695
{
696
    DECL_TRACER("TQtSettings::on_checkBox_Banner_toggled(bool checked)");
697
 
698
    if (TConfig::showBanner() == checked)
699
        return;
700
 
701
    mSetChanged = true;
702
    TConfig::saveBanner(!checked);
703
}
704
 
151 andreas 705
void TQtSettings::on_checkBox_ToolbarSuppress_toggled(bool checked)
706
{
707
    DECL_TRACER("TQtSettings::on_checkBox_ToolbarSuppress_toggled(bool checked)");
708
 
709
    if (TConfig::getToolbarSuppress() == checked)
710
        return;
711
 
712
    mSetChanged = true;
713
    TConfig::saveToolbarSuppress(checked);
714
    ui->checkBox_Toolbar->setDisabled(checked);
715
}
716
 
120 andreas 717
void TQtSettings::on_checkBox_Toolbar_toggled(bool checked)
718
{
719
    DECL_TRACER("TQtSettings::on_checkBox_Toolbar_toggled(bool checked)");
720
 
721
    if (TConfig::getToolbarForce() == checked)
722
        return;
723
 
724
    mSetChanged = true;
725
    TConfig::saveToolbarForce(checked);
726
}
727
 
134 andreas 728
void TQtSettings::on_checkBox_Rotation_toggled(bool checked)
729
{
730
    DECL_TRACER("TQtSettings::on_checkBox_Rotation_toggled(bool checked)");
731
 
732
    if (TConfig::getRotationFixed() == checked)
733
        return;
734
 
735
    mSetChanged = true;
736
    TConfig::setRotationFixed(checked);
737
}
738
 
35 andreas 739
void TQtSettings::on_checkBox_Profiling_toggled(bool checked)
740
{
41 andreas 741
    DECL_TRACER("TQtSettings::on_checkBox_Profiling_toggled(bool checked)");
742
 
35 andreas 743
    if (TConfig::getProfiling() == checked)
744
        return;
745
 
746
    mSetChanged = true;
747
    TConfig::saveProfiling(checked);
748
}
40 andreas 749
 
59 andreas 750
void TQtSettings::on_checkBox_LogInfo_toggled(bool checked)
751
{
752
    DECL_TRACER("TQtSettings::on_checkBox_LogInfo_toggled(bool checked)");
753
 
754
    if (mInitRun)
755
        return;
756
 
757
    if (checked && !(mLogLevel & HLOG_INFO))
758
    {
759
        mLogLevel |= HLOG_INFO;
760
        mSetChanged = true;
761
    }
762
    else if (!checked && (mLogLevel & HLOG_INFO))
763
    {
764
        mSetChanged = true;
765
        mLogLevel &= RLOG_INFO;
766
    }
767
 
768
    mInitRun = true;
769
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
770
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
771
 
772
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
773
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
774
 
775
    mInitRun = false;
776
    TConfig::saveLogLevel(mLogLevel);
777
}
778
 
779
void TQtSettings::on_checkBox_LogWarning_toggled(bool checked)
780
{
781
    DECL_TRACER("TQtSettings::on_checkBox_LogWarning_toggled(bool checked)");
782
 
783
    if (mInitRun)
784
        return;
785
 
786
    if (checked && !(mLogLevel & HLOG_WARNING))
787
    {
788
        mLogLevel |= HLOG_WARNING;
789
        mSetChanged = true;
790
    }
791
    else if (!checked && (mLogLevel & HLOG_WARNING))
792
    {
793
        mLogLevel &= RLOG_WARNING;
794
        mSetChanged = true;
795
    }
796
 
797
    mInitRun = true;
798
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
799
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
800
 
801
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
802
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
803
 
804
    mInitRun = false;
805
    TConfig::saveLogLevel(mLogLevel);
806
}
807
 
808
void TQtSettings::on_checkBox_LogError_toggled(bool checked)
809
{
810
    DECL_TRACER("TQtSettings::on_checkBox_LogError_toggled(bool checked)");
811
 
812
    if (mInitRun)
813
        return;
814
 
815
    if (checked && !(mLogLevel & HLOG_ERROR))
816
    {
817
        mSetChanged = true;
818
        mLogLevel |= HLOG_ERROR;
819
    }
820
    else if (!checked && (mLogLevel & HLOG_ERROR))
821
    {
822
        mLogLevel &= RLOG_ERROR;
823
        mSetChanged = true;
824
    }
825
 
826
    mInitRun = true;
827
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
828
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
829
 
830
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
831
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
832
 
833
    mInitRun = false;
834
    TConfig::saveLogLevel(mLogLevel);
835
}
836
 
837
void TQtSettings::on_checkBox_LogTrace_toggled(bool checked)
838
{
839
    DECL_TRACER("TQtSettings::on_checkBox_LogTrace_toggled(bool checked)");
840
 
841
    if (mInitRun)
842
        return;
843
 
844
    if (checked && !(mLogLevel & HLOG_TRACE))
845
    {
846
        mLogLevel |= HLOG_TRACE;
847
        mSetChanged = true;
848
    }
849
    else if (!checked && (mLogLevel & HLOG_TRACE))
850
    {
851
        mLogLevel &= RLOG_TRACE;
852
        mSetChanged = true;
853
    }
854
 
855
    mInitRun = true;
856
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
857
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
858
 
859
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
860
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
861
 
862
    mInitRun = false;
863
    TConfig::saveLogLevel(mLogLevel);
864
}
865
 
866
void TQtSettings::on_checkBox_LogDebug_toggled(bool checked)
867
{
868
    DECL_TRACER("TQtSettings::on_checkBox_LogDebug_toggled(bool checked)");
869
 
870
    if (mInitRun)
871
        return;
872
 
873
    if (checked && !(mLogLevel & HLOG_DEBUG))
874
    {
875
        mLogLevel |= HLOG_DEBUG;
876
        mSetChanged = true;
877
    }
878
    else if (!checked && (mLogLevel & HLOG_DEBUG))
879
    {
880
        mLogLevel &= RLOG_DEBUG;
881
        mSetChanged = true;
882
    }
883
 
884
    mInitRun = true;
885
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
886
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
887
 
888
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
889
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
890
 
891
    mInitRun = false;
892
    TConfig::saveLogLevel(mLogLevel);
893
}
894
 
895
void TQtSettings::on_checkBox_LogProtocol_toggled(bool checked)
896
{
897
    DECL_TRACER("TQtSettings::on_checkBox_LogProtocol_toggled(bool checked)");
898
 
899
    if (mInitRun)
900
        return;
901
 
902
    if (checked && (mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
903
    {
904
        mLogLevel = HLOG_PROTOCOL;
905
        mInitRun = true;
906
        ui->checkBox_LogInfo->setCheckState(Qt::CheckState::Checked);
907
        ui->checkBox_LogWarning->setCheckState(Qt::CheckState::Checked);
908
        ui->checkBox_LogError->setCheckState(Qt::CheckState::Checked);
909
        ui->checkBox_LogTrace->setCheckState(Qt::CheckState::Unchecked);
910
        ui->checkBox_LogDebug->setCheckState(Qt::CheckState::Unchecked);
911
        TConfig::saveLogLevel(mLogLevel);
912
        mInitRun = false;
913
        mSetChanged = true;
914
    }
915
}
916
 
917
void TQtSettings::on_checkBox_LogAll_toggled(bool checked)
918
{
919
    DECL_TRACER("TQtSettings::on_checkBox_LogAll_toggled(bool checked)");
920
 
921
    if (mInitRun)
922
        return;
923
 
924
    if (checked && (mLogLevel & HLOG_ALL) != HLOG_ALL)
925
    {
926
        mLogLevel = HLOG_ALL;
927
        mInitRun = true;
928
        ui->checkBox_LogInfo->setCheckState(Qt::CheckState::Checked);
929
        ui->checkBox_LogWarning->setCheckState(Qt::CheckState::Checked);
930
        ui->checkBox_LogError->setCheckState(Qt::CheckState::Checked);
931
        ui->checkBox_LogTrace->setCheckState(Qt::CheckState::Checked);
932
        ui->checkBox_LogDebug->setCheckState(Qt::CheckState::Checked);
933
        TConfig::saveLogLevel(mLogLevel);
934
        mInitRun = false;
935
        mSetChanged = true;
936
    }
937
}
938
 
40 andreas 939
int TQtSettings::scale(int value)
940
{
118 andreas 941
    DECL_TRACER("TQtSettings::scale(int value)");
942
 
155 andreas 943
    if (value <= 0 || mScaleFactor == 1.0 || mScaleFactor < 0.0)
40 andreas 944
        return value;
945
 
946
    return (int)((double)value * mScaleFactor);
947
}
43 andreas 948
 
949
void TQtSettings::on_kiconbutton_reset_clicked()
950
{
118 andreas 951
    DECL_TRACER("TQtSettings::on_kiconbutton_reset_clicked()");
952
 
43 andreas 953
    char *HOME = getenv("HOME");
954
    QString logFile = TConfig::getLogFile().c_str();
955
 
956
    if (HOME)
957
    {
958
        logFile = HOME;
959
        logFile += "/tpanel/tpanel.log";
960
    }
961
 
962
    ui->lineEdit_logFile->setText(logFile);
963
}
118 andreas 964
 
965
void TQtSettings::on_lineEdit_FTPuser_textChanged(const QString& arg1)
966
{
967
    DECL_TRACER("TQtSettings::on_lineEdit_FTPuser_textChanged(const QString& arg1)");
968
 
969
    if (arg1.compare(TConfig::getFtpUser().c_str()) == 0)
970
        return;
971
 
972
    mSetChanged = true;
973
    TConfig::saveFtpUser(arg1.toStdString());
974
}
975
 
976
void TQtSettings::on_lineEdit_FTPpassword_textChanged(const QString& arg1)
977
{
978
    DECL_TRACER("TQtSettings::on_lineEdit_FTPpassword_textChanged(const QString& arg1)");
979
 
980
    if (arg1.compare(TConfig::getFtpPassword().c_str()) == 0)
981
        return;
982
 
983
    mSetChanged = true;
984
    TConfig::saveFtpPassword(arg1.toStdString());
985
}
986
 
258 andreas 987
void TQtSettings::on_comboBox_FTPsurface_currentTextChanged(const QString& arg1)
118 andreas 988
{
122 andreas 989
    DECL_TRACER("TQtSettings::on_comboBox_FTPsurface_currentIndexChanged(const QString& arg1)");
258 andreas 990
MSG_DEBUG("Comparing surface: " << arg1.toStdString() << " with " << TConfig::getFtpSurface());
118 andreas 991
    if (arg1.compare(TConfig::getFtpSurface().c_str()) == 0)
992
        return;
993
 
994
    mSetChanged = true;
995
    TConfig::saveFtpSurface(arg1.toStdString());
122 andreas 996
    MSG_DEBUG("Surface was set to " << arg1.toStdString());
179 andreas 997
 
998
    vector<TTPInit::FILELIST_t>::iterator iter;
999
    int idx = 0;
1000
 
1001
    for (iter = mFileList.begin(); iter != mFileList.end(); ++iter)
1002
    {
1003
        if (iter->fname.compare(arg1.toStdString()) == 0)
1004
        {
1005
            mIndex = idx;
1006
            break;
1007
        }
1008
 
1009
        idx++;
1010
    }
118 andreas 1011
}
1012
 
122 andreas 1013
void TQtSettings::on_toolButton_Download_clicked()
1014
{
1015
    DECL_TRACER("TQtSettings::on_toolButton_Download_clicked()");
1016
 
1017
    QMessageBox box(this);
1018
    QString text = ui->comboBox_FTPsurface->currentText();
1019
 
1020
    box.setText("Do you realy want to download and install the surface <b>" + text + "</b>?");
1021
    box.addButton(QMessageBox::Yes);
1022
    box.addButton(QMessageBox::No);
1023
    int ret = box.exec();
1024
 
1025
    if (ret == QMessageBox::Yes)
1026
    {
1027
        mDownloadForce = true;
1028
        QString qss = QString("background-color: rgba(250, 0, 0, 0.9)");
1029
        ui->toolButton_Download->setStyleSheet(qss);
1030
    }
1031
    else
1032
    {
1033
        mDownloadForce = false;
1034
        QString qss = QString("background-color: rgba(209, 209, 209, 0.9)");
1035
        ui->toolButton_Download->setStyleSheet(qss);
1036
    }
1037
 
1038
    MSG_DEBUG("mDownloadForce=" << (mDownloadForce ? "YES" : "NO"));
1039
}
1040
 
118 andreas 1041
void TQtSettings::on_checkBox_FTPpassive_toggled(bool checked)
1042
{
1043
    DECL_TRACER("TQtSettings::on_checkBox_FTPpassive_toggled(bool checked)");
1044
 
1045
    if (TConfig::getFtpPassive() == checked)
1046
        return;
1047
 
1048
    mSetChanged = true;
1049
    TConfig::saveFtpPassive(checked);
1050
}
1051
 
1052
void TQtSettings::on_lineEdit_SIPproxy_textChanged(const QString& arg1)
1053
{
1054
    DECL_TRACER("TQtSettings::on_lineEdit_SIPproxy_textChanged(const QString& arg1)");
1055
 
1056
    if (arg1.compare(TConfig::getSIPproxy().c_str()) == 0)
1057
        return;
1058
 
1059
    mSetChanged = true;
1060
    TConfig::setSIPproxy(arg1.toStdString());
1061
}
1062
 
1063
void TQtSettings::on_spinBox_SIPport_valueChanged(int arg1)
1064
{
1065
    DECL_TRACER("TQtSettings::on_spinBox_SIPport_valueChanged(int arg1)");
1066
 
1067
    if (TConfig::getSIPport() == arg1)
1068
        return;
1069
 
1070
    mSetChanged = true;
1071
    TConfig::setSIPport(arg1);
1072
}
1073
 
127 andreas 1074
void TQtSettings::on_spinBox_SIPportTLS_valueChanged(int arg1)
1075
{
1076
    DECL_TRACER("TQtSettings::on_spinBoxTLS_SIPport_valueChanged(int arg1)");
1077
 
1078
    if (TConfig::getSIPportTLS() == arg1)
1079
        return;
1080
 
1081
    mSetChanged = true;
1082
    TConfig::setSIPportTLS(arg1);
1083
}
1084
 
118 andreas 1085
void TQtSettings::on_lineEdit_SIPstun_textChanged(const QString& arg1)
1086
{
1087
    DECL_TRACER("TQtSettings::on_lineEdit_SIPstun_textChanged(const QString& arg1)");
1088
 
1089
    if (arg1.compare(TConfig::getSIPstun().c_str()) == 0)
1090
        return;
1091
 
1092
    mSetChanged = true;
1093
    TConfig::setSIPstun(arg1.toStdString());
1094
}
1095
 
1096
void TQtSettings::on_lineEdit_SIPdomain_textChanged(const QString& arg1)
1097
{
1098
    DECL_TRACER("TQtSettings::on_lineEdit_SIPdomain_textChanged(const QString& arg1)");
1099
 
1100
    if (arg1.compare(TConfig::getSIPdomain().c_str()) == 0)
1101
        return;
1102
 
1103
    mSetChanged = true;
1104
    TConfig::setSIPdomain(arg1.toStdString());
1105
}
1106
 
1107
void TQtSettings::on_lineEdit_SIPuser_textChanged(const QString& arg1)
1108
{
1109
    DECL_TRACER("TQtSettings::on_lineEdit_SIPuser_textChanged(const QString& arg1)");
1110
 
1111
    if (arg1.compare(TConfig::getSIPuser().c_str()) == 0)
1112
        return;
1113
 
1114
    mSetChanged = true;
1115
    TConfig::setSIPuser(arg1.toStdString());
1116
}
1117
 
1118
void TQtSettings::on_lineEdit_SIPpassword_textChanged(const QString& arg1)
1119
{
1120
    DECL_TRACER("TQtSettings::on_lineEdit_SIPpassword_textChanged(const QString& arg1)");
1121
 
1122
    if (arg1.compare(TConfig::getSIPpassword().c_str()) == 0)
1123
        return;
1124
 
1125
    mSetChanged = true;
1126
    TConfig::setSIPpassword(arg1.toStdString());
1127
}
1128
 
127 andreas 1129
void TQtSettings::on_checkBox_SIPnetworkIPv4_toggled(bool checked)
1130
{
1131
    DECL_TRACER("TQtSettings::on_checkBox_SIPnetworkIPv4_toggled(bool checked)");
1132
 
1133
    if (TConfig::getSIPnetworkIPv4() == checked)
1134
        return;
1135
 
1136
    mSetChanged = true;
1137
    TConfig::setSIPnetworkIPv4(checked);
1138
}
1139
 
1140
void TQtSettings::on_checkBox_SIPnetworkIPv6_toggled(bool checked)
1141
{
1142
    DECL_TRACER("TQtSettings::on_checkBox_SIPnetworkIPv6_toggled(bool checked)");
1143
 
1144
    if (TConfig::getSIPnetworkIPv6() == checked)
1145
        return;
1146
 
1147
    mSetChanged = true;
1148
    TConfig::setSIPnetworkIPv6(checked);
1149
}
1150
 
1151
void TQtSettings::on_comboBox_SIPfirewall_currentIndexChanged(int index)
1152
{
1153
    DECL_TRACER("TQtSettings::on_comboBox_SIPfirewall_currentIndexChanged(const QString& arg1)");
1154
 
1155
    TConfig::SIP_FIREWALL_t fw;
1156
 
1157
    switch(index)
1158
    {
1159
        case 0: fw = TConfig::SIP_NO_FIREWALL; break;
1160
        case 1: fw = TConfig::SIP_STUN; break;
1161
        case 2: fw = TConfig::SIP_ICE; break;
1162
        case 3: fw = TConfig::SIP_UPNP; break;
1163
 
1164
        default:
1165
            fw = TConfig::SIP_NO_FIREWALL;
1166
    }
1167
 
1168
    if (TConfig::getSIPfirewall() == fw)
1169
        return;
1170
 
1171
    mSetChanged = true;
1172
    TConfig::setSIPfirewall(fw);
1173
}
1174
 
118 andreas 1175
void TQtSettings::on_checkBox_SIPenabled_toggled(bool checked)
1176
{
1177
    DECL_TRACER("TQtSettings::on_checkBox_SIPenabled_toggled(bool checked)");
1178
 
1179
    if (TConfig::getSIPstatus() == checked)
1180
        return;
1181
 
1182
    mSetChanged = true;
1183
    TConfig::setSIPstatus(checked);
1184
}
139 andreas 1185
 
1186
void TQtSettings::on_checkBox_SIPiphone_toggled(bool checked)
1187
{
1188
    DECL_TRACER("TQtSettings::on_checkBox_SIPiphone_toggled(bool checked)");
1189
 
1190
    if (TConfig::getSIPiphone() == checked)
1191
        return;
1192
 
1193
    mSetChanged = true;
1194
    TConfig::setSIPiphone(checked);
1195
}
141 andreas 1196
 
258 andreas 1197
void TQtSettings::on_comboBox_SystemSound_currentTextChanged(const QString& arg1)
141 andreas 1198
{
1199
    DECL_TRACER("TQtSettings::on_comboBox_SystemSound_currentIndexChanged(const QString& arg1)");
1200
 
1201
    if (arg1.compare(TConfig::getSystemSound().c_str()) == 0)
1202
        return;
1203
 
1204
    mSetChanged = true;
1205
    TConfig::saveSystemSoundFile(arg1.toStdString() + ".wav");
1206
}
1207
 
1208
void TQtSettings::on_toolButton_SystemSound_clicked()
1209
{
1210
    DECL_TRACER("TQtSettings::on_toolButton_SystemSound_clicked()");
1211
 
1212
    QString selected = ui->comboBox_SystemSound->currentText();
1213
    string file = TConfig::getProjectPath() + "/__system/graphics/sounds/" + selected.toStdString() + ".wav";
1214
 
1215
    if (gPageManager)
1216
        gPageManager->getCallPlaySound()(file);
1217
}
1218
 
258 andreas 1219
void TQtSettings::on_comboBox_SingleBeep_currentTextChanged(const QString& arg1)
141 andreas 1220
{
1221
    DECL_TRACER("TQtSettings::on_comboBox_SingleBeep_currentIndexChanged(const QString& arg1)");
1222
 
1223
    if (arg1.compare(TConfig::getSingleBeepSound().c_str()) == 0)
1224
        return;
1225
 
1226
    string file = arg1.toStdString();
1227
    size_t pos = file.find_last_of(" ");
1228
 
1229
    if (pos != string::npos)
1230
    {
1231
        int num = atoi(file.substr(pos).c_str());
1232
        file = "singleBeep";
1233
 
1234
        if (num > 0)
1235
        {
1236
            if (num < 10)
1237
                file += "0" + std::to_string(num);
1238
            else
1239
                file += std::to_string(num);
1240
        }
1241
 
1242
        file += ".wav";
1243
    }
1244
 
1245
    mSetChanged = true;
1246
    TConfig::saveSingleBeepFile(file);
1247
}
1248
 
1249
void TQtSettings::on_toolButton_SingleBeep_clicked()
1250
{
1251
    DECL_TRACER("TQtSettings::on_toolButton_SingleBeep_clicked()");
1252
 
1253
    QString selected = ui->comboBox_SingleBeep->currentText();
1254
    string file = selected.toStdString();
1255
    size_t pos = file.find_last_of(" ");
1256
 
1257
    if (pos != string::npos)
1258
    {
1259
        int num = atoi(file.substr(pos).c_str());
1260
        file = TConfig::getProjectPath() + "/__system/graphics/sounds/singleBeep";
1261
 
1262
        if (num > 0)
1263
        {
1264
            if (num < 10)
1265
                file += "0" + std::to_string(num);
1266
            else
1267
                file += std::to_string(num);
1268
        }
1269
 
1270
        file += ".wav";
1271
    }
1272
 
1273
//    playFile(file);
1274
 
1275
    if (gPageManager)
1276
        gPageManager->getCallPlaySound()(file);
1277
}
1278
 
258 andreas 1279
void TQtSettings::on_comboBox_DoubleBeep_currentTextChanged(const QString& arg1)
141 andreas 1280
{
1281
    DECL_TRACER("TQtSettings::on_comboBox_DoubleBeep_currentIndexChanged(const QString& arg1)");
1282
 
1283
    if (arg1.compare(TConfig::getDoubleBeepSound().c_str()) == 0)
1284
        return;
1285
 
1286
    string file = arg1.toStdString();
1287
    size_t pos = file.find_last_of(" ");
1288
 
1289
    if (pos != string::npos)
1290
    {
1291
        int num = atoi(file.substr(pos).c_str());
1292
        file = "doubleBeep";
1293
 
1294
        if (num > 0)
1295
        {
1296
            if (num < 10)
1297
                file += "0" + std::to_string(num);
1298
            else
1299
                file += std::to_string(num);
1300
        }
1301
 
1302
        file += ".wav";
1303
    }
1304
 
1305
    mSetChanged = true;
1306
    TConfig::saveDoubleBeepFile(file);
1307
}
1308
 
1309
void TQtSettings::on_toolButton_DoubleBeep_clicked()
1310
{
1311
    DECL_TRACER("TQtSettings::on_toolButton_DoubleBeep_clicked()");
1312
 
1313
    QString selected = ui->comboBox_DoubleBeep->currentText();
1314
    string file = selected.toStdString();
1315
    size_t pos = file.find_last_of(" ");
1316
 
1317
    if (pos != string::npos)
1318
    {
1319
        int num = atoi(file.substr(pos).c_str());
1320
        file = TConfig::getProjectPath() + "/__system/graphics/sounds/doubleBeep";
1321
 
1322
        if (num > 0)
1323
        {
1324
            if (num < 10)
1325
                file += "0" + std::to_string(num);
1326
            else
1327
                file += std::to_string(num);
1328
        }
1329
 
1330
        file += ".wav";
1331
    }
1332
 
1333
 
1334
//    playFile(file);
1335
 
1336
    if (gPageManager)
1337
        gPageManager->getCallPlaySound()(file);
1338
}
1339
 
1340
void TQtSettings::on_checkBox_SystemSound_toggled(bool checked)
1341
{
1342
    DECL_TRACER("TQtSettings::on_checkBox_SystemSound_toggled(bool checked)");
1343
 
1344
    if (TConfig::getSystemSoundState() == checked)
1345
        return;
1346
 
1347
    mSetChanged = true;
1348
    TConfig::saveSystemSoundState(checked);
1349
}
1350
 
1351
void TQtSettings::on_toolButton_TestSound_clicked()
1352
{
1353
    DECL_TRACER("TQtSettings::on_toolButton_TestSound_clicked()");
1354
 
1355
    if (gPageManager)
1356
        gPageManager->getCallPlaySound()(TConfig::getProjectPath() + "/__system/graphics/sounds/audioTest.wav");
1357
}
1358
 
1359
void TQtSettings::on_horizontalSlider_Volume_valueChanged(int value)
1360
{
1361
    DECL_TRACER("TQtSettings::on_horizontalSlider_Volume_valueChanged(int value)");
1362
 
1363
    if (TConfig::getSystemVolume() == value)
1364
        return;
1365
 
1366
    TConfig::saveSystemVolume(value);
335 andreas 1367
 
1368
    if (gPageManager && gPageManager->getCallSetVolume())
1369
        gPageManager->getCallSetVolume()(value);
141 andreas 1370
}
1371
 
1372
void TQtSettings::on_horizontalSlider_Gain_valueChanged(int value)
1373
{
1374
    DECL_TRACER("TQtSettings::on_horizontalSlider_Gain_valueChanged(int value)");
1375
 
1376
    if (TConfig::getSystemGain() == value)
1377
        return;
1378
 
1379
    TConfig::saveSystemGain(value);
1380
}