Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 andreas 1
/*
21 andreas 2
 * Copyright (C) 2020, 2021 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>
19
 
23 andreas 20
#include <unistd.h>
21
 
2 andreas 22
#include "tqtsettings.h"
23
#include "terror.h"
24
#include "ui_tqtsettings.h"
25
 
23 andreas 26
#ifdef __ANDROID__
43 andreas 27
#include <QtAndroidExtras/QAndroidJniObject>
28
#include <QtAndroid>
23 andreas 29
#include <QtQml/QQmlFile>
30
#include <android/log.h>
31
#endif
32
 
22 andreas 33
#include "tconfig.h"
34
 
59 andreas 35
#define RLOG_INFO           0x00fe
36
#define RLOG_WARNING        0x00fd
37
#define RLOG_ERROR          0x00fb
38
#define RLOG_TRACE          0x00f7
39
#define RLOG_DEBUG          0x00ef
40
#define RLOG_PROTOCOL       0x00f8
41
#define RLOG_ALL            0x00e0
42
 
2 andreas 43
TQtSettings::TQtSettings(QWidget *parent)
44
	: QDialog(parent),
45
	  ui(new Ui::TQtSettings)
46
{
3 andreas 47
	DECL_TRACER("TQtSettings::TQtSettings(QWidget *parent)");
22 andreas 48
 
59 andreas 49
    mInitRun = true;
2 andreas 50
	ui->setupUi(this);
22 andreas 51
 
43 andreas 52
    ui->lineEdit_logFile->setText(TConfig::getLogFile().c_str());
22 andreas 53
    ui->lineEdit_Controller->setText(TConfig::getController().c_str());
54
    ui->lineEdit_PType->setText(TConfig::getPanelType().c_str());
55
    ui->spinBox_Port->setValue(TConfig::getPort());
56
    ui->spinBox_Channel->setValue(TConfig::getChannel());
118 andreas 57
    ui->lineEdit_FTPuser->setText(TConfig::getFtpUser().c_str());
58
    ui->lineEdit_FTPpassword->setText(TConfig::getFtpPassword().c_str());
59
    ui->lineEdit_FTPsurface->setText(TConfig::getFtpSurface().c_str());
60
    ui->checkBox_FTPpassive->setCheckState((TConfig::getFtpPassive() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
59 andreas 61
 
62
    mLogLevel = TConfig::getLogLevelBits();
63
    ui->checkBox_LogInfo->setCheckState((mLogLevel & HLOG_INFO) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
64
    ui->checkBox_LogWarning->setCheckState((mLogLevel & HLOG_WARNING) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
65
    ui->checkBox_LogError->setCheckState((mLogLevel & HLOG_ERROR) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
66
    ui->checkBox_LogTrace->setCheckState((mLogLevel & HLOG_TRACE) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
67
    ui->checkBox_LogDebug->setCheckState((mLogLevel & HLOG_DEBUG) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
68
    ui->checkBox_LogProtocol->setCheckState(((mLogLevel & HLOG_PROTOCOL) == HLOG_PROTOCOL) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
69
    ui->checkBox_LogAll->setCheckState(((mLogLevel & HLOG_ALL) == HLOG_ALL) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
70
 
23 andreas 71
    ui->checkBox_Format->setCheckState((TConfig::isLongFormat() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
24 andreas 72
    ui->checkBox_Scale->setCheckState((TConfig::getScale() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
120 andreas 73
#ifndef __ANDROID__
74
    ui->checkBox_Scale->setDisabled(true);
75
#endif
118 andreas 76
    ui->checkBox_Banner->setCheckState((TConfig::showBanner() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
120 andreas 77
#ifdef __ANDROID__
78
    ui->checkBox_Banner->setDisabled(true);
79
#endif
80
    ui->checkBox_Toolbar->setCheckState((TConfig::getToolbarForce() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
118 andreas 81
 
82
    ui->lineEdit_SIPproxy->setText(TConfig::getSIPproxy().c_str());
83
    ui->spinBox_SIPport->setValue(TConfig::getSIPport());
84
    ui->lineEdit_SIPstun->setText(TConfig::getSIPstun().c_str());
85
    ui->lineEdit_SIPdomain->setText(TConfig::getSIPdomain().c_str());
86
    ui->lineEdit_SIPuser->setText(TConfig::getSIPuser().c_str());
87
    ui->lineEdit_SIPpassword->setText(TConfig::getSIPpassword().c_str());
88
    ui->checkBox_SIPenabled->setCheckState((TConfig::getSIPstatus() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
120 andreas 89
#ifdef __ANDROID__
90
    ui->tabWidget->setPalette(qt_fusionPalette());
91
    ui->tabCtrl->setPalette(qt_fusionPalette());
92
    ui->tabLog->setPalette(qt_fusionPalette());
93
    ui->tabSIP->setPalette(qt_fusionPalette());
94
    ui->tabView->setPalette(qt_fusionPalette());
95
#endif
59 andreas 96
    mInitRun = false;
97
    mSetChanged = false;
2 andreas 98
}
99
 
100
TQtSettings::~TQtSettings()
101
{
3 andreas 102
	DECL_TRACER("TQtSettings::~TQtSettings()");
2 andreas 103
	delete ui;
104
}
43 andreas 105
 
120 andreas 106
#ifdef __ANDROID__
107
QPalette TQtSettings::qt_fusionPalette()
108
{
109
    QColor backGround(239, 239, 239);
110
    QColor light = backGround.lighter(150);
111
    QColor mid(backGround.darker(130));
112
    QColor midLight = mid.lighter(110);
113
    QColor base = Qt::white;
114
    QColor disabledBase(backGround);
115
    QColor dark = backGround.darker(150);
116
    QColor darkDisabled = QColor(209, 209, 209).darker(110);
117
    QColor text = Qt::black;
118
    QColor hightlightedText = Qt::white;
119
    QColor disabledText = QColor(190, 190, 190);
120
    QColor button = backGround;
121
    QColor shadow = dark.darker(135);
122
    QColor disabledShadow = shadow.lighter(150);
123
 
124
    QPalette fusionPalette(Qt::black,backGround,light,dark,mid,text,base);
125
    fusionPalette.setBrush(QPalette::Midlight, midLight);
126
    fusionPalette.setBrush(QPalette::Button, button);
127
    fusionPalette.setBrush(QPalette::Shadow, shadow);
128
    fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText);
129
 
130
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText);
131
    fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText);
132
    fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText);
133
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase);
134
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
135
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
136
 
137
    fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198));
138
    fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(48, 140, 198));
139
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 145, 145));
140
    return fusionPalette;
141
}
142
#endif
143
 
22 andreas 144
void TQtSettings::on_kiconbutton_logFile_clicked()
145
{
41 andreas 146
    DECL_TRACER("TQtSettings::on_kiconbutton_logFile_clicked()");
147
 
22 andreas 148
    std::string pt = TConfig::getLogFile();
149
    size_t pos = pt.find_last_of("/");
150
 
151
    if (pos != std::string::npos)
152
        pt = pt.substr(0, pos);
153
    else
23 andreas 154
    {
155
        char hv0[4096];
156
        getcwd(hv0, sizeof(hv0));
157
        pt = hv0;
158
    }
22 andreas 159
 
160
    QString actPath(pt.c_str());
43 andreas 161
    QFileDialog fdialog(this, tr("Logfile"), actPath, tr("TPanel.log (*.log)"));
23 andreas 162
    fdialog.setAcceptMode(QFileDialog::AcceptSave);
163
    fdialog.setDefaultSuffix("log");
164
    fdialog.setOption(QFileDialog::DontConfirmOverwrite);
165
    QString fname;
166
 
167
    if (fdialog.exec())
168
    {
169
        QDir dir = fdialog.directory();
170
        QStringList list = fdialog.selectedFiles();
171
 
172
        if (list.size() > 0)
173
            fname = dir.absoluteFilePath(list.at(0));
174
        else
175
            return;
176
    }
177
    else
178
        return;
179
 
43 andreas 180
#ifdef __ANDROID__
181
    QString fileName = fname;
182
 
183
    if (fileName.contains("content://"))
184
    {
185
        QAndroidJniObject uri = QAndroidJniObject::callStaticObjectMethod(
186
              "android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;",
187
              QAndroidJniObject::fromString(fileName).object<jstring>());
188
 
189
        fileName =
190
              QAndroidJniObject::callStaticObjectMethod(
191
                  "org/qtproject/theosys/UriToPath", "getFileName",
192
                  "(Landroid/net/Uri;Landroid/content/Context;)Ljava/lang/String;",
193
                  uri.object(), QtAndroid::androidContext().object()).toString();
194
 
195
        if (fileName.length() > 0)
196
            fname = fileName;
197
    }
198
    else
199
    {
200
        MSG_WARNING("Not an Uri? (" << fname.toStdString() << ")");
201
    }
202
#endif
23 andreas 203
    ui->lineEdit_logFile->setText(fname);
204
 
205
    if (TConfig::getLogFile().compare(fname.toStdString()) != 0)
206
    {
207
        mSetChanged = true;
208
        TConfig::saveLogFile(fname.toStdString());
209
    }
22 andreas 210
}
43 andreas 211
 
120 andreas 212
template<typename T>
213
void TQtSettings::scaleObject(T *obj)
214
{
215
    DECL_TRACER("TQtSettings::scaleObject(T *obj)");
216
 
217
    QSize size = obj->size();
218
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
219
    obj->resize(size);
220
    QRect rect = obj->geometry();
221
    obj->move(scale(rect.left()), scale(rect.top()));
222
}
223
 
40 andreas 224
void TQtSettings::doResize()
225
{
41 andreas 226
    DECL_TRACER("TQtSettings::doResize()");
227
 
40 andreas 228
    // The main dialog window
229
    QSize size = this->size();
41 andreas 230
    QRect rect = this->geometry();
40 andreas 231
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
232
    this->resize(size);
41 andreas 233
    this->move(scale(rect.left()), scale(rect.top()));
234
    QWidget *parent = this->parentWidget();
235
 
236
    if (parent)
237
    {
238
        rect = parent->geometry();
239
        this->move(rect.center() - this->rect().center());
240
    }
241
 
59 andreas 242
    // Layout
118 andreas 243
    // Iterate through childs and resize them
244
    QObjectList childs = children();
245
    QList<QObject *>::Iterator iter;
59 andreas 246
 
118 andreas 247
    for (iter = childs.begin(); iter != childs.end(); ++iter)
248
    {
249
        QString name = iter.i->t()->objectName();
250
        QObject *obj = iter.i->t();
59 andreas 251
 
120 andreas 252
        if (name.startsWith("tabWidget"))
118 andreas 253
        {
120 andreas 254
            scaleObject(dynamic_cast<QTabWidget *>(obj));
255
 
256
            QObjectList childsTab = obj->children();
257
            QList<QObject *>::Iterator iterTab;
258
 
259
            for (iterTab = childsTab.begin(); iterTab != childsTab.end(); ++iterTab)
260
            {
261
                QString namet = iterTab.i->t()->objectName();
262
                QObject *objt = iterTab.i->t();
263
 
264
                if (namet.startsWith("qt_tabwidget_stackedwidget"))
265
                {
266
                    QObjectList childsStack = objt->children();
267
                    QList<QObject *>::Iterator iterStack;
268
 
269
                    for (iterStack = childsStack.begin(); iterStack != childsStack.end(); ++iterStack)
270
                    {
271
                        QObjectList tabStack = iterStack.i->t()->children();
272
                        QList<QObject *>::Iterator tabIter;
273
 
274
                        for (tabIter = tabStack.begin(); tabIter != tabStack.end(); ++tabIter)
275
                        {
276
                            QString n = tabIter.i->t()->objectName();
277
                            QObject *on = tabIter.i->t();
278
 
279
                            if (n.startsWith("kiconbutton"))
280
                                scaleObject(dynamic_cast<QToolButton *>(on));
281
                            else if (n.startsWith("checkBox"))
282
                            {
283
                                scaleObject(dynamic_cast<QCheckBox *>(on));
284
#ifdef __ANDROID__
285
                                QCheckBox *cb = dynamic_cast<QCheckBox *>(on);
286
                                cb->setPalette(qt_fusionPalette());
287
#endif
288
                            }
289
                            else if (n.startsWith("lineEdit"))
290
                                scaleObject(dynamic_cast<QLineEdit *>(on));
291
                            else if (n.startsWith("spinBox"))
292
                                scaleObject(dynamic_cast<QSpinBox *>(on));
293
                            else if (n.startsWith("label"))
294
                            {
295
                                scaleObject(dynamic_cast<QLabel *>(on));
296
#ifdef __ANDROID__
297
                                QLabel *lb = dynamic_cast<QLabel *>(on);
298
                                lb->setPalette(qt_fusionPalette());
299
#endif
300
                            }
301
                        }
302
                    }
303
 
304
//                    if (namet.startsWith("tab"))
305
//                        scaleObject(dynamic_cast<QWidget *>(objt));
306
                }
307
            }
118 andreas 308
        }
120 andreas 309
        else if (name.startsWith("buttonBox"))
310
            scaleObject(dynamic_cast<QDialogButtonBox *>(obj));
118 andreas 311
    }
40 andreas 312
}
41 andreas 313
 
23 andreas 314
void TQtSettings::on_lineEdit_logFile_textChanged(const QString &arg1)
315
{
41 andreas 316
    DECL_TRACER("TQtSettings::on_lineEdit_logFile_textChanged(const QString &arg1)");
317
 
23 andreas 318
    if (arg1.compare(TConfig::getLogFile().c_str()) == 0)
319
        return;
320
 
321
    mSetChanged = true;
322
    TConfig::saveLogFile(arg1.toStdString());
323
}
43 andreas 324
 
23 andreas 325
void TQtSettings::on_lineEdit_Controller_textChanged(const QString &arg1)
326
{
41 andreas 327
    DECL_TRACER("TQtSettings::on_lineEdit_Controller_textChanged(const QString &arg1)");
328
 
23 andreas 329
    if (arg1.compare(TConfig::getController().c_str()) == 0)
330
        return;
331
 
332
    mSetChanged = true;
333
    TConfig::saveController(arg1.toStdString());
334
}
335
 
336
void TQtSettings::on_spinBox_Port_valueChanged(int arg1)
337
{
41 andreas 338
    DECL_TRACER("TQtSettings::on_spinBox_Port_valueChanged(int arg1)");
339
 
23 andreas 340
    if (arg1 == TConfig::getPort())
341
        return;
342
 
343
    mSetChanged = true;
344
    TConfig::savePort(arg1);
345
}
346
 
347
void TQtSettings::on_spinBox_Channel_valueChanged(int arg1)
348
{
41 andreas 349
    DECL_TRACER("TQtSettings::on_spinBox_Channel_valueChanged(int arg1)");
350
 
23 andreas 351
    if (arg1 == TConfig::getChannel())
352
        return;
353
 
354
    mSetChanged = true;
355
    TConfig::saveChannel(arg1);
356
}
357
 
358
void TQtSettings::on_lineEdit_PType_textChanged(const QString &arg1)
359
{
41 andreas 360
    DECL_TRACER("TQtSettings::on_lineEdit_PType_textChanged(const QString &arg1)");
361
 
23 andreas 362
    if (arg1.compare(TConfig::getPanelType().c_str()) == 0)
363
        return;
364
 
365
    mSetChanged = true;
366
    TConfig::savePanelType(arg1.toStdString());
367
}
368
 
369
void TQtSettings::on_checkBox_Format_toggled(bool checked)
370
{
41 andreas 371
    DECL_TRACER("TQtSettings::on_checkBox_Format_toggled(bool checked)");
372
 
23 andreas 373
    if (TConfig::isLongFormat() == checked)
374
        return;
375
 
376
    mSetChanged = true;
377
    TConfig::saveFormat(checked);
378
}
24 andreas 379
 
380
void TQtSettings::on_checkBox_Scale_toggled(bool checked)
381
{
41 andreas 382
    DECL_TRACER("TQtSettings::on_checkBox_Scale_toggled(bool checked)");
383
 
24 andreas 384
    if (TConfig::getScale() == checked)
385
        return;
386
 
387
    mSetChanged = true;
388
    TConfig::saveScale(checked);
389
}
35 andreas 390
 
118 andreas 391
void TQtSettings::on_checkBox_Banner_toggled(bool checked)
392
{
393
    DECL_TRACER("TQtSettings::on_checkBox_Banner_toggled(bool checked)");
394
 
395
    if (TConfig::showBanner() == checked)
396
        return;
397
 
398
    mSetChanged = true;
399
    TConfig::saveBanner(!checked);
400
}
401
 
120 andreas 402
void TQtSettings::on_checkBox_Toolbar_toggled(bool checked)
403
{
404
    DECL_TRACER("TQtSettings::on_checkBox_Toolbar_toggled(bool checked)");
405
 
406
    if (TConfig::getToolbarForce() == checked)
407
        return;
408
 
409
    mSetChanged = true;
410
    TConfig::saveToolbarForce(checked);
411
}
412
 
35 andreas 413
void TQtSettings::on_checkBox_Profiling_toggled(bool checked)
414
{
41 andreas 415
    DECL_TRACER("TQtSettings::on_checkBox_Profiling_toggled(bool checked)");
416
 
35 andreas 417
    if (TConfig::getProfiling() == checked)
418
        return;
419
 
420
    mSetChanged = true;
421
    TConfig::saveProfiling(checked);
422
}
40 andreas 423
 
59 andreas 424
void TQtSettings::on_checkBox_LogInfo_toggled(bool checked)
425
{
426
    DECL_TRACER("TQtSettings::on_checkBox_LogInfo_toggled(bool checked)");
427
 
428
    if (mInitRun)
429
        return;
430
 
431
    if (checked && !(mLogLevel & HLOG_INFO))
432
    {
433
        mLogLevel |= HLOG_INFO;
434
        mSetChanged = true;
435
    }
436
    else if (!checked && (mLogLevel & HLOG_INFO))
437
    {
438
        mSetChanged = true;
439
        mLogLevel &= RLOG_INFO;
440
    }
441
 
442
    mInitRun = true;
443
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
444
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
445
 
446
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
447
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
448
 
449
    mInitRun = false;
450
    TConfig::saveLogLevel(mLogLevel);
451
}
452
 
453
void TQtSettings::on_checkBox_LogWarning_toggled(bool checked)
454
{
455
    DECL_TRACER("TQtSettings::on_checkBox_LogWarning_toggled(bool checked)");
456
 
457
    if (mInitRun)
458
        return;
459
 
460
    if (checked && !(mLogLevel & HLOG_WARNING))
461
    {
462
        mLogLevel |= HLOG_WARNING;
463
        mSetChanged = true;
464
    }
465
    else if (!checked && (mLogLevel & HLOG_WARNING))
466
    {
467
        mLogLevel &= RLOG_WARNING;
468
        mSetChanged = true;
469
    }
470
 
471
    mInitRun = true;
472
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
473
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
474
 
475
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
476
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
477
 
478
    mInitRun = false;
479
    TConfig::saveLogLevel(mLogLevel);
480
}
481
 
482
void TQtSettings::on_checkBox_LogError_toggled(bool checked)
483
{
484
    DECL_TRACER("TQtSettings::on_checkBox_LogError_toggled(bool checked)");
485
 
486
    if (mInitRun)
487
        return;
488
 
489
    if (checked && !(mLogLevel & HLOG_ERROR))
490
    {
491
        mSetChanged = true;
492
        mLogLevel |= HLOG_ERROR;
493
    }
494
    else if (!checked && (mLogLevel & HLOG_ERROR))
495
    {
496
        mLogLevel &= RLOG_ERROR;
497
        mSetChanged = true;
498
    }
499
 
500
    mInitRun = true;
501
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
502
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
503
 
504
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
505
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
506
 
507
    mInitRun = false;
508
    TConfig::saveLogLevel(mLogLevel);
509
}
510
 
511
void TQtSettings::on_checkBox_LogTrace_toggled(bool checked)
512
{
513
    DECL_TRACER("TQtSettings::on_checkBox_LogTrace_toggled(bool checked)");
514
 
515
    if (mInitRun)
516
        return;
517
 
518
    if (checked && !(mLogLevel & HLOG_TRACE))
519
    {
520
        mLogLevel |= HLOG_TRACE;
521
        mSetChanged = true;
522
    }
523
    else if (!checked && (mLogLevel & HLOG_TRACE))
524
    {
525
        mLogLevel &= RLOG_TRACE;
526
        mSetChanged = true;
527
    }
528
 
529
    mInitRun = true;
530
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
531
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
532
 
533
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
534
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
535
 
536
    mInitRun = false;
537
    TConfig::saveLogLevel(mLogLevel);
538
}
539
 
540
void TQtSettings::on_checkBox_LogDebug_toggled(bool checked)
541
{
542
    DECL_TRACER("TQtSettings::on_checkBox_LogDebug_toggled(bool checked)");
543
 
544
    if (mInitRun)
545
        return;
546
 
547
    if (checked && !(mLogLevel & HLOG_DEBUG))
548
    {
549
        mLogLevel |= HLOG_DEBUG;
550
        mSetChanged = true;
551
    }
552
    else if (!checked && (mLogLevel & HLOG_DEBUG))
553
    {
554
        mLogLevel &= RLOG_DEBUG;
555
        mSetChanged = true;
556
    }
557
 
558
    mInitRun = true;
559
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
560
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
561
 
562
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
563
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
564
 
565
    mInitRun = false;
566
    TConfig::saveLogLevel(mLogLevel);
567
}
568
 
569
void TQtSettings::on_checkBox_LogProtocol_toggled(bool checked)
570
{
571
    DECL_TRACER("TQtSettings::on_checkBox_LogProtocol_toggled(bool checked)");
572
 
573
    if (mInitRun)
574
        return;
575
 
576
    if (checked && (mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
577
    {
578
        mLogLevel = HLOG_PROTOCOL;
579
        mInitRun = true;
580
        ui->checkBox_LogInfo->setCheckState(Qt::CheckState::Checked);
581
        ui->checkBox_LogWarning->setCheckState(Qt::CheckState::Checked);
582
        ui->checkBox_LogError->setCheckState(Qt::CheckState::Checked);
583
        ui->checkBox_LogTrace->setCheckState(Qt::CheckState::Unchecked);
584
        ui->checkBox_LogDebug->setCheckState(Qt::CheckState::Unchecked);
585
        TConfig::saveLogLevel(mLogLevel);
586
        mInitRun = false;
587
        mSetChanged = true;
588
    }
589
}
590
 
591
void TQtSettings::on_checkBox_LogAll_toggled(bool checked)
592
{
593
    DECL_TRACER("TQtSettings::on_checkBox_LogAll_toggled(bool checked)");
594
 
595
    if (mInitRun)
596
        return;
597
 
598
    if (checked && (mLogLevel & HLOG_ALL) != HLOG_ALL)
599
    {
600
        mLogLevel = HLOG_ALL;
601
        mInitRun = true;
602
        ui->checkBox_LogInfo->setCheckState(Qt::CheckState::Checked);
603
        ui->checkBox_LogWarning->setCheckState(Qt::CheckState::Checked);
604
        ui->checkBox_LogError->setCheckState(Qt::CheckState::Checked);
605
        ui->checkBox_LogTrace->setCheckState(Qt::CheckState::Checked);
606
        ui->checkBox_LogDebug->setCheckState(Qt::CheckState::Checked);
607
        TConfig::saveLogLevel(mLogLevel);
608
        mInitRun = false;
609
        mSetChanged = true;
610
    }
611
}
612
 
40 andreas 613
int TQtSettings::scale(int value)
614
{
118 andreas 615
    DECL_TRACER("TQtSettings::scale(int value)");
616
 
40 andreas 617
    if (value <= 0 || mScaleFactor == 1.0)
618
        return value;
619
 
620
    return (int)((double)value * mScaleFactor);
621
}
43 andreas 622
 
623
void TQtSettings::on_kiconbutton_reset_clicked()
624
{
118 andreas 625
    DECL_TRACER("TQtSettings::on_kiconbutton_reset_clicked()");
626
 
43 andreas 627
    char *HOME = getenv("HOME");
628
    QString logFile = TConfig::getLogFile().c_str();
629
 
630
    if (HOME)
631
    {
632
        logFile = HOME;
633
        logFile += "/tpanel/tpanel.log";
634
    }
635
 
636
    ui->lineEdit_logFile->setText(logFile);
637
}
118 andreas 638
 
639
void TQtSettings::on_lineEdit_FTPuser_textChanged(const QString& arg1)
640
{
641
    DECL_TRACER("TQtSettings::on_lineEdit_FTPuser_textChanged(const QString& arg1)");
642
 
643
    if (arg1.compare(TConfig::getFtpUser().c_str()) == 0)
644
        return;
645
 
646
    mSetChanged = true;
647
    TConfig::saveFtpUser(arg1.toStdString());
648
}
649
 
650
void TQtSettings::on_lineEdit_FTPpassword_textChanged(const QString& arg1)
651
{
652
    DECL_TRACER("TQtSettings::on_lineEdit_FTPpassword_textChanged(const QString& arg1)");
653
 
654
    if (arg1.compare(TConfig::getFtpPassword().c_str()) == 0)
655
        return;
656
 
657
    mSetChanged = true;
658
    TConfig::saveFtpPassword(arg1.toStdString());
659
}
660
 
661
void TQtSettings::on_lineEdit_FTPsurface_textChanged(const QString& arg1)
662
{
663
    DECL_TRACER("TQtSettings::on_lineEdit_FTPsurface_textChanged(const QString& arg1)");
664
 
665
    if (arg1.compare(TConfig::getFtpSurface().c_str()) == 0)
666
        return;
667
 
668
    mSetChanged = true;
669
    TConfig::saveFtpSurface(arg1.toStdString());
670
}
671
 
672
void TQtSettings::on_checkBox_FTPpassive_toggled(bool checked)
673
{
674
    DECL_TRACER("TQtSettings::on_checkBox_FTPpassive_toggled(bool checked)");
675
 
676
    if (TConfig::getFtpPassive() == checked)
677
        return;
678
 
679
    mSetChanged = true;
680
    TConfig::saveFtpPassive(checked);
681
}
682
 
683
void TQtSettings::on_lineEdit_SIPproxy_textChanged(const QString& arg1)
684
{
685
    DECL_TRACER("TQtSettings::on_lineEdit_SIPproxy_textChanged(const QString& arg1)");
686
 
687
    if (arg1.compare(TConfig::getSIPproxy().c_str()) == 0)
688
        return;
689
 
690
    mSetChanged = true;
691
    TConfig::setSIPproxy(arg1.toStdString());
692
}
693
 
694
void TQtSettings::on_spinBox_SIPport_valueChanged(int arg1)
695
{
696
    DECL_TRACER("TQtSettings::on_spinBox_SIPport_valueChanged(int arg1)");
697
 
698
    if (TConfig::getSIPport() == arg1)
699
        return;
700
 
701
    mSetChanged = true;
702
    TConfig::setSIPport(arg1);
703
}
704
 
705
void TQtSettings::on_lineEdit_SIPstun_textChanged(const QString& arg1)
706
{
707
    DECL_TRACER("TQtSettings::on_lineEdit_SIPstun_textChanged(const QString& arg1)");
708
 
709
    if (arg1.compare(TConfig::getSIPstun().c_str()) == 0)
710
        return;
711
 
712
    mSetChanged = true;
713
    TConfig::setSIPstun(arg1.toStdString());
714
}
715
 
716
void TQtSettings::on_lineEdit_SIPdomain_textChanged(const QString& arg1)
717
{
718
    DECL_TRACER("TQtSettings::on_lineEdit_SIPdomain_textChanged(const QString& arg1)");
719
 
720
    if (arg1.compare(TConfig::getSIPdomain().c_str()) == 0)
721
        return;
722
 
723
    mSetChanged = true;
724
    TConfig::setSIPdomain(arg1.toStdString());
725
}
726
 
727
void TQtSettings::on_lineEdit_SIPuser_textChanged(const QString& arg1)
728
{
729
    DECL_TRACER("TQtSettings::on_lineEdit_SIPuser_textChanged(const QString& arg1)");
730
 
731
    if (arg1.compare(TConfig::getSIPuser().c_str()) == 0)
732
        return;
733
 
734
    mSetChanged = true;
735
    TConfig::setSIPuser(arg1.toStdString());
736
}
737
 
738
void TQtSettings::on_lineEdit_SIPpassword_textChanged(const QString& arg1)
739
{
740
    DECL_TRACER("TQtSettings::on_lineEdit_SIPpassword_textChanged(const QString& arg1)");
741
 
742
    if (arg1.compare(TConfig::getSIPpassword().c_str()) == 0)
743
        return;
744
 
745
    mSetChanged = true;
746
    TConfig::setSIPpassword(arg1.toStdString());
747
}
748
 
749
void TQtSettings::on_checkBox_SIPenabled_toggled(bool checked)
750
{
751
    DECL_TRACER("TQtSettings::on_checkBox_SIPenabled_toggled(bool checked)");
752
 
753
    if (TConfig::getSIPstatus() == checked)
754
        return;
755
 
756
    mSetChanged = true;
757
    TConfig::setSIPstatus(checked);
758
}