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