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
 
56
    ui->spinBox_Port->setValue(TConfig::getPort());
57
    ui->spinBox_Channel->setValue(TConfig::getChannel());
59 andreas 58
 
59
    mLogLevel = TConfig::getLogLevelBits();
60
    ui->checkBox_LogInfo->setCheckState((mLogLevel & HLOG_INFO) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
61
    ui->checkBox_LogWarning->setCheckState((mLogLevel & HLOG_WARNING) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
62
    ui->checkBox_LogError->setCheckState((mLogLevel & HLOG_ERROR) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
63
    ui->checkBox_LogTrace->setCheckState((mLogLevel & HLOG_TRACE) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
64
    ui->checkBox_LogDebug->setCheckState((mLogLevel & HLOG_DEBUG) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
65
    ui->checkBox_LogProtocol->setCheckState(((mLogLevel & HLOG_PROTOCOL) == HLOG_PROTOCOL) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
66
    ui->checkBox_LogAll->setCheckState(((mLogLevel & HLOG_ALL) == HLOG_ALL) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
67
 
23 andreas 68
    ui->checkBox_Format->setCheckState((TConfig::isLongFormat() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
24 andreas 69
    ui->checkBox_Scale->setCheckState((TConfig::getScale() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
59 andreas 70
    mInitRun = false;
71
    mSetChanged = false;
2 andreas 72
}
73
 
74
TQtSettings::~TQtSettings()
75
{
3 andreas 76
	DECL_TRACER("TQtSettings::~TQtSettings()");
2 andreas 77
	delete ui;
78
}
43 andreas 79
 
22 andreas 80
void TQtSettings::on_kiconbutton_logFile_clicked()
81
{
41 andreas 82
    DECL_TRACER("TQtSettings::on_kiconbutton_logFile_clicked()");
83
 
22 andreas 84
    std::string pt = TConfig::getLogFile();
85
    size_t pos = pt.find_last_of("/");
86
 
87
    if (pos != std::string::npos)
88
        pt = pt.substr(0, pos);
89
    else
23 andreas 90
    {
91
        char hv0[4096];
92
        getcwd(hv0, sizeof(hv0));
93
        pt = hv0;
94
    }
22 andreas 95
 
96
    QString actPath(pt.c_str());
43 andreas 97
    QFileDialog fdialog(this, tr("Logfile"), actPath, tr("TPanel.log (*.log)"));
23 andreas 98
    fdialog.setAcceptMode(QFileDialog::AcceptSave);
99
    fdialog.setDefaultSuffix("log");
100
    fdialog.setOption(QFileDialog::DontConfirmOverwrite);
101
    QString fname;
102
 
103
    if (fdialog.exec())
104
    {
105
        QDir dir = fdialog.directory();
106
        QStringList list = fdialog.selectedFiles();
107
 
108
        if (list.size() > 0)
109
            fname = dir.absoluteFilePath(list.at(0));
110
        else
111
            return;
112
    }
113
    else
114
        return;
115
 
43 andreas 116
#ifdef __ANDROID__
117
//    QString fileName = QQmlFile::urlToLocalFileOrQrc(fname);
118
    QString fileName = fname;
119
 
120
    if (fileName.contains("content://"))
121
    {
122
        QAndroidJniObject uri = QAndroidJniObject::callStaticObjectMethod(
123
              "android/net/Uri", "parse", "(Ljava/lang/String;)Landroid/net/Uri;",
124
              QAndroidJniObject::fromString(fileName).object<jstring>());
125
 
126
        fileName =
127
              QAndroidJniObject::callStaticObjectMethod(
128
                  "org/qtproject/theosys/UriToPath", "getFileName",
129
                  "(Landroid/net/Uri;Landroid/content/Context;)Ljava/lang/String;",
130
                  uri.object(), QtAndroid::androidContext().object()).toString();
131
 
132
        if (fileName.length() > 0)
133
            fname = fileName;
134
    }
135
    else
136
    {
137
        MSG_WARNING("Not an Uri? (" << fname.toStdString() << ")");
138
    }
139
#endif
23 andreas 140
    ui->lineEdit_logFile->setText(fname);
141
 
142
    if (TConfig::getLogFile().compare(fname.toStdString()) != 0)
143
    {
144
        mSetChanged = true;
145
        TConfig::saveLogFile(fname.toStdString());
146
    }
22 andreas 147
}
43 andreas 148
 
40 andreas 149
void TQtSettings::doResize()
150
{
41 andreas 151
    DECL_TRACER("TQtSettings::doResize()");
152
 
40 andreas 153
    // The main dialog window
154
    QSize size = this->size();
41 andreas 155
    QRect rect = this->geometry();
40 andreas 156
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
157
    this->resize(size);
41 andreas 158
    this->move(scale(rect.left()), scale(rect.top()));
159
    QWidget *parent = this->parentWidget();
160
 
161
    if (parent)
162
    {
163
        rect = parent->geometry();
164
        this->move(rect.center() - this->rect().center());
165
    }
166
 
59 andreas 167
    // Layout
168
    size = ui->scrollArea->size();
169
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
170
    ui->scrollArea->resize(size);
171
    rect = ui->scrollArea->geometry();
172
    ui->scrollArea->move(scale(rect.left()), scale(rect.top()));
173
 
174
    size = ui->scrollAreaWidgetContents->size();
175
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
176
    ui->scrollAreaWidgetContents->resize(size);
177
    rect = ui->scrollAreaWidgetContents->geometry();
178
    ui->scrollAreaWidgetContents->move(scale(rect.left()), scale(rect.top()));
179
 
40 andreas 180
    // labels
41 andreas 181
    QFont font = ui->label_Channel->font();
182
    font.setPointSizeF(12.0);
40 andreas 183
    size = ui->label_Channel->size();
184
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
185
    ui->label_Channel->resize(size);
41 andreas 186
    rect = ui->label_Channel->geometry();
187
    ui->label_Channel->move(scale(rect.left()), scale(rect.top()));
188
    ui->label_Channel->setFont(font);
189
 
40 andreas 190
    ui->label_Controller->resize(size);
41 andreas 191
    rect = ui->label_Controller->geometry();
192
    ui->label_Controller->move(scale(rect.left()), scale(rect.top()));
193
    ui->label_Controller->setFont(font);
194
 
40 andreas 195
    ui->label_PType->resize(size);
41 andreas 196
    rect = ui->label_PType->geometry();
197
    ui->label_PType->move(scale(rect.left()), scale(rect.top()));
198
    ui->label_PType->setFont(font);
199
 
40 andreas 200
    ui->label_PType_2->resize(size);
41 andreas 201
    rect = ui->label_PType_2->geometry();
202
    ui->label_PType_2->move(scale(rect.left()), scale(rect.top()));
203
    ui->label_PType_2->setFont(font);
204
 
40 andreas 205
    ui->label_Port->resize(size);
41 andreas 206
    rect = ui->label_Port->geometry();
207
    ui->label_Port->move(scale(rect.left()), scale(rect.top()));
208
    ui->label_Port->setFont(font);
209
 
40 andreas 210
    ui->label_logLevel->resize(size);
41 andreas 211
    rect = ui->label_logLevel->geometry();
212
    ui->label_logLevel->move(scale(rect.left()), scale(rect.top()));
213
    ui->label_logLevel->setFont(font);
214
 
43 andreas 215
    ui->label_logFile->resize(size);
216
    rect = ui->label_logFile->geometry();
217
    ui->label_logFile->move(scale(rect.left()), scale(rect.top()));
218
    ui->label_logFile->setFont(font);
41 andreas 219
 
59 andreas 220
    ui->label_logFormats->resize(size);
221
    rect = ui->label_logFormats->geometry();
222
    ui->label_logFormats->move(scale(rect.left()), scale(rect.top()));
223
    ui->label_logFormats->setFont(font);
224
 
40 andreas 225
    // Inputs
226
    size = ui->lineEdit_Controller->size();
41 andreas 227
    rect = ui->lineEdit_Controller->geometry();
40 andreas 228
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
229
    ui->lineEdit_Controller->resize(size);
41 andreas 230
    rect = ui->lineEdit_Controller->geometry();
231
    ui->lineEdit_Controller->move(scale(rect.left()), scale(rect.top()));
232
    ui->lineEdit_Controller->setFont(font);
40 andreas 233
 
234
    size = ui->lineEdit_PType->size();
235
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
236
    ui->lineEdit_PType->resize(size);
41 andreas 237
    rect = ui->lineEdit_PType->geometry();
238
    ui->lineEdit_PType->move(scale(rect.left()), scale(rect.top()));
239
    ui->lineEdit_PType->setFont(font);
40 andreas 240
 
43 andreas 241
    size = ui->lineEdit_logFile->size();
40 andreas 242
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
43 andreas 243
    ui->lineEdit_logFile->resize(size);
244
    rect = ui->lineEdit_logFile->geometry();
245
    ui->lineEdit_logFile->move(scale(rect.left()), scale(rect.top()));
246
    ui->lineEdit_logFile->setFont(font);
40 andreas 247
 
43 andreas 248
    size = ui->kiconbutton_reset->size();
41 andreas 249
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
43 andreas 250
    ui->kiconbutton_reset->resize(size);
251
    rect = ui->kiconbutton_reset->geometry();
252
    ui->kiconbutton_reset->move(scale(rect.left()), scale(rect.top()));
253
    size = ui->kiconbutton_reset->iconSize();
41 andreas 254
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
43 andreas 255
    ui->kiconbutton_reset->setIconSize(size);
41 andreas 256
 
43 andreas 257
    size = ui->kiconbutton_logFile->size();
258
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
259
    ui->kiconbutton_logFile->resize(size);
260
    rect = ui->kiconbutton_logFile->geometry();
261
    ui->kiconbutton_logFile->move(scale(rect.left()), scale(rect.top()));
262
    size = ui->kiconbutton_logFile->iconSize();
263
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
264
    ui->kiconbutton_logFile->setIconSize(size);
265
 
40 andreas 266
    size = ui->spinBox_Channel->size();
267
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
268
    ui->spinBox_Channel->resize(size);
41 andreas 269
    rect = ui->spinBox_Channel->geometry();
270
    ui->spinBox_Channel->move(scale(rect.left()), scale(rect.top()));
271
    ui->spinBox_Channel->setFont(font);
40 andreas 272
 
273
    size = ui->spinBox_Port->size();
274
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
275
    ui->spinBox_Port->resize(size);
41 andreas 276
    rect = ui->spinBox_Port->geometry();
277
    ui->spinBox_Port->move(scale(rect.left()), scale(rect.top()));
278
    ui->spinBox_Port->setFont(font);
40 andreas 279
 
59 andreas 280
 
281
    size = ui->checkBox_LogInfo->size();
40 andreas 282
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
59 andreas 283
    ui->checkBox_LogInfo->resize(size);
284
    rect = ui->checkBox_LogInfo->geometry();
285
    ui->checkBox_LogInfo->move(scale(rect.left()), scale(rect.top()));
286
    ui->checkBox_LogInfo->setFont(font);
40 andreas 287
 
59 andreas 288
    size = ui->checkBox_LogWarning->size();
289
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
290
    ui->checkBox_LogWarning->resize(size);
291
    rect = ui->checkBox_LogWarning->geometry();
292
    ui->checkBox_LogWarning->move(scale(rect.left()), scale(rect.top()));
293
    ui->checkBox_LogWarning->setFont(font);
294
 
295
    size = ui->checkBox_LogError->size();
296
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
297
    ui->checkBox_LogError->resize(size);
298
    rect = ui->checkBox_LogError->geometry();
299
    ui->checkBox_LogError->move(scale(rect.left()), scale(rect.top()));
300
    ui->checkBox_LogError->setFont(font);
301
 
302
    size = ui->checkBox_LogTrace->size();
303
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
304
    ui->checkBox_LogTrace->resize(size);
305
    rect = ui->checkBox_LogTrace->geometry();
306
    ui->checkBox_LogTrace->move(scale(rect.left()), scale(rect.top()));
307
    ui->checkBox_LogTrace->setFont(font);
308
 
309
    size = ui->checkBox_LogDebug->size();
310
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
311
    ui->checkBox_LogDebug->resize(size);
312
    rect = ui->checkBox_LogDebug->geometry();
313
    ui->checkBox_LogDebug->move(scale(rect.left()), scale(rect.top()));
314
    ui->checkBox_LogDebug->setFont(font);
315
 
316
    size = ui->checkBox_LogProtocol->size();
317
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
318
    ui->checkBox_LogProtocol->resize(size);
319
    rect = ui->checkBox_LogProtocol->geometry();
320
    ui->checkBox_LogProtocol->move(scale(rect.left()), scale(rect.top()));
321
    ui->checkBox_LogProtocol->setFont(font);
322
 
323
    size = ui->checkBox_LogAll->size();
324
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
325
    ui->checkBox_LogAll->resize(size);
326
    rect = ui->checkBox_LogAll->geometry();
327
    ui->checkBox_LogAll->move(scale(rect.left()), scale(rect.top()));
328
    ui->checkBox_LogAll->setFont(font);
329
 
40 andreas 330
    size = ui->checkBox_Format->size();
331
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
332
    ui->checkBox_Format->resize(size);
41 andreas 333
    rect = ui->checkBox_Format->geometry();
334
    ui->checkBox_Format->move(scale(rect.left()), scale(rect.top()));
335
    ui->checkBox_Format->setFont(font);
40 andreas 336
 
337
    size = ui->checkBox_Profiling->size();
338
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
339
    ui->checkBox_Profiling->resize(size);
41 andreas 340
    rect = ui->checkBox_Profiling->geometry();
341
    ui->checkBox_Profiling->move(scale(rect.left()), scale(rect.top()));
342
    ui->checkBox_Profiling->setFont(font);
40 andreas 343
 
344
    size = ui->checkBox_Scale->size();
345
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
346
    ui->checkBox_Scale->resize(size);
41 andreas 347
    rect = ui->checkBox_Scale->geometry();
348
    ui->checkBox_Scale->move(scale(rect.left()), scale(rect.top()));
349
    ui->checkBox_Scale->setFont(font);
350
 
351
    size = ui->buttonBox->size();
352
    size.scale(scale(size.width()), scale(size.height()), Qt::KeepAspectRatio);
353
    ui->buttonBox->resize(size);
354
    rect = ui->buttonBox->geometry();
355
    ui->buttonBox->move(scale(rect.left()), scale(rect.top()));
356
    ui->buttonBox->setFont(font);
40 andreas 357
}
41 andreas 358
 
23 andreas 359
void TQtSettings::on_lineEdit_logFile_textChanged(const QString &arg1)
360
{
41 andreas 361
    DECL_TRACER("TQtSettings::on_lineEdit_logFile_textChanged(const QString &arg1)");
362
 
23 andreas 363
    if (arg1.compare(TConfig::getLogFile().c_str()) == 0)
364
        return;
365
 
366
    mSetChanged = true;
367
    TConfig::saveLogFile(arg1.toStdString());
368
}
43 andreas 369
 
23 andreas 370
void TQtSettings::on_lineEdit_Controller_textChanged(const QString &arg1)
371
{
41 andreas 372
    DECL_TRACER("TQtSettings::on_lineEdit_Controller_textChanged(const QString &arg1)");
373
 
23 andreas 374
    if (arg1.compare(TConfig::getController().c_str()) == 0)
375
        return;
376
 
377
    mSetChanged = true;
378
    TConfig::saveController(arg1.toStdString());
379
}
380
 
381
void TQtSettings::on_spinBox_Port_valueChanged(int arg1)
382
{
41 andreas 383
    DECL_TRACER("TQtSettings::on_spinBox_Port_valueChanged(int arg1)");
384
 
23 andreas 385
    if (arg1 == TConfig::getPort())
386
        return;
387
 
388
    mSetChanged = true;
389
    TConfig::savePort(arg1);
390
}
391
 
392
void TQtSettings::on_spinBox_Channel_valueChanged(int arg1)
393
{
41 andreas 394
    DECL_TRACER("TQtSettings::on_spinBox_Channel_valueChanged(int arg1)");
395
 
23 andreas 396
    if (arg1 == TConfig::getChannel())
397
        return;
398
 
399
    mSetChanged = true;
400
    TConfig::saveChannel(arg1);
401
}
402
 
403
void TQtSettings::on_lineEdit_PType_textChanged(const QString &arg1)
404
{
41 andreas 405
    DECL_TRACER("TQtSettings::on_lineEdit_PType_textChanged(const QString &arg1)");
406
 
23 andreas 407
    if (arg1.compare(TConfig::getPanelType().c_str()) == 0)
408
        return;
409
 
410
    mSetChanged = true;
411
    TConfig::savePanelType(arg1.toStdString());
412
}
413
 
414
void TQtSettings::on_checkBox_Format_toggled(bool checked)
415
{
41 andreas 416
    DECL_TRACER("TQtSettings::on_checkBox_Format_toggled(bool checked)");
417
 
23 andreas 418
    if (TConfig::isLongFormat() == checked)
419
        return;
420
 
421
    mSetChanged = true;
422
    TConfig::saveFormat(checked);
423
}
24 andreas 424
 
425
void TQtSettings::on_checkBox_Scale_toggled(bool checked)
426
{
41 andreas 427
    DECL_TRACER("TQtSettings::on_checkBox_Scale_toggled(bool checked)");
428
 
24 andreas 429
    if (TConfig::getScale() == checked)
430
        return;
431
 
432
    mSetChanged = true;
433
    TConfig::saveScale(checked);
434
}
35 andreas 435
 
436
void TQtSettings::on_checkBox_Profiling_toggled(bool checked)
437
{
41 andreas 438
    DECL_TRACER("TQtSettings::on_checkBox_Profiling_toggled(bool checked)");
439
 
35 andreas 440
    if (TConfig::getProfiling() == checked)
441
        return;
442
 
443
    mSetChanged = true;
444
    TConfig::saveProfiling(checked);
445
}
40 andreas 446
 
59 andreas 447
void TQtSettings::on_checkBox_LogInfo_toggled(bool checked)
448
{
449
    DECL_TRACER("TQtSettings::on_checkBox_LogInfo_toggled(bool checked)");
450
 
451
    if (mInitRun)
452
        return;
453
 
454
    if (checked && !(mLogLevel & HLOG_INFO))
455
    {
456
        mLogLevel |= HLOG_INFO;
457
        mSetChanged = true;
458
    }
459
    else if (!checked && (mLogLevel & HLOG_INFO))
460
    {
461
        mSetChanged = true;
462
        mLogLevel &= RLOG_INFO;
463
    }
464
 
465
    mInitRun = true;
466
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
467
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
468
 
469
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
470
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
471
 
472
    mInitRun = false;
473
    TConfig::saveLogLevel(mLogLevel);
474
}
475
 
476
void TQtSettings::on_checkBox_LogWarning_toggled(bool checked)
477
{
478
    DECL_TRACER("TQtSettings::on_checkBox_LogWarning_toggled(bool checked)");
479
 
480
    if (mInitRun)
481
        return;
482
 
483
    if (checked && !(mLogLevel & HLOG_WARNING))
484
    {
485
        mLogLevel |= HLOG_WARNING;
486
        mSetChanged = true;
487
    }
488
    else if (!checked && (mLogLevel & HLOG_WARNING))
489
    {
490
        mLogLevel &= RLOG_WARNING;
491
        mSetChanged = true;
492
    }
493
 
494
    mInitRun = true;
495
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
496
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
497
 
498
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
499
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
500
 
501
    mInitRun = false;
502
    TConfig::saveLogLevel(mLogLevel);
503
}
504
 
505
void TQtSettings::on_checkBox_LogError_toggled(bool checked)
506
{
507
    DECL_TRACER("TQtSettings::on_checkBox_LogError_toggled(bool checked)");
508
 
509
    if (mInitRun)
510
        return;
511
 
512
    if (checked && !(mLogLevel & HLOG_ERROR))
513
    {
514
        mSetChanged = true;
515
        mLogLevel |= HLOG_ERROR;
516
    }
517
    else if (!checked && (mLogLevel & HLOG_ERROR))
518
    {
519
        mLogLevel &= RLOG_ERROR;
520
        mSetChanged = true;
521
    }
522
 
523
    mInitRun = true;
524
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
525
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
526
 
527
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
528
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
529
 
530
    mInitRun = false;
531
    TConfig::saveLogLevel(mLogLevel);
532
}
533
 
534
void TQtSettings::on_checkBox_LogTrace_toggled(bool checked)
535
{
536
    DECL_TRACER("TQtSettings::on_checkBox_LogTrace_toggled(bool checked)");
537
 
538
    if (mInitRun)
539
        return;
540
 
541
    if (checked && !(mLogLevel & HLOG_TRACE))
542
    {
543
        mLogLevel |= HLOG_TRACE;
544
        mSetChanged = true;
545
    }
546
    else if (!checked && (mLogLevel & HLOG_TRACE))
547
    {
548
        mLogLevel &= RLOG_TRACE;
549
        mSetChanged = true;
550
    }
551
 
552
    mInitRun = true;
553
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
554
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
555
 
556
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
557
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
558
 
559
    mInitRun = false;
560
    TConfig::saveLogLevel(mLogLevel);
561
}
562
 
563
void TQtSettings::on_checkBox_LogDebug_toggled(bool checked)
564
{
565
    DECL_TRACER("TQtSettings::on_checkBox_LogDebug_toggled(bool checked)");
566
 
567
    if (mInitRun)
568
        return;
569
 
570
    if (checked && !(mLogLevel & HLOG_DEBUG))
571
    {
572
        mLogLevel |= HLOG_DEBUG;
573
        mSetChanged = true;
574
    }
575
    else if (!checked && (mLogLevel & HLOG_DEBUG))
576
    {
577
        mLogLevel &= RLOG_DEBUG;
578
        mSetChanged = true;
579
    }
580
 
581
    mInitRun = true;
582
    if ((mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
583
        ui->checkBox_LogProtocol->setCheckState(Qt::CheckState::Unchecked);
584
 
585
    if ((mLogLevel & HLOG_ALL) != HLOG_ALL)
586
        ui->checkBox_LogAll->setCheckState(Qt::CheckState::Unchecked);
587
 
588
    mInitRun = false;
589
    TConfig::saveLogLevel(mLogLevel);
590
}
591
 
592
void TQtSettings::on_checkBox_LogProtocol_toggled(bool checked)
593
{
594
    DECL_TRACER("TQtSettings::on_checkBox_LogProtocol_toggled(bool checked)");
595
 
596
    if (mInitRun)
597
        return;
598
 
599
    if (checked && (mLogLevel & HLOG_PROTOCOL) != HLOG_PROTOCOL)
600
    {
601
        mLogLevel = HLOG_PROTOCOL;
602
        mInitRun = true;
603
        ui->checkBox_LogInfo->setCheckState(Qt::CheckState::Checked);
604
        ui->checkBox_LogWarning->setCheckState(Qt::CheckState::Checked);
605
        ui->checkBox_LogError->setCheckState(Qt::CheckState::Checked);
606
        ui->checkBox_LogTrace->setCheckState(Qt::CheckState::Unchecked);
607
        ui->checkBox_LogDebug->setCheckState(Qt::CheckState::Unchecked);
608
        TConfig::saveLogLevel(mLogLevel);
609
        mInitRun = false;
610
        mSetChanged = true;
611
    }
612
}
613
 
614
void TQtSettings::on_checkBox_LogAll_toggled(bool checked)
615
{
616
    DECL_TRACER("TQtSettings::on_checkBox_LogAll_toggled(bool checked)");
617
 
618
    if (mInitRun)
619
        return;
620
 
621
    if (checked && (mLogLevel & HLOG_ALL) != HLOG_ALL)
622
    {
623
        mLogLevel = HLOG_ALL;
624
        mInitRun = true;
625
        ui->checkBox_LogInfo->setCheckState(Qt::CheckState::Checked);
626
        ui->checkBox_LogWarning->setCheckState(Qt::CheckState::Checked);
627
        ui->checkBox_LogError->setCheckState(Qt::CheckState::Checked);
628
        ui->checkBox_LogTrace->setCheckState(Qt::CheckState::Checked);
629
        ui->checkBox_LogDebug->setCheckState(Qt::CheckState::Checked);
630
        TConfig::saveLogLevel(mLogLevel);
631
        mInitRun = false;
632
        mSetChanged = true;
633
    }
634
}
635
 
40 andreas 636
int TQtSettings::scale(int value)
637
{
638
    if (value <= 0 || mScaleFactor == 1.0)
639
        return value;
640
 
641
    return (int)((double)value * mScaleFactor);
642
}
43 andreas 643
 
644
void TQtSettings::on_kiconbutton_reset_clicked()
645
{
646
    char *HOME = getenv("HOME");
647
    QString logFile = TConfig::getLogFile().c_str();
648
 
649
    if (HOME)
650
    {
651
        logFile = HOME;
652
        logFile += "/tpanel/tpanel.log";
653
    }
654
 
655
    ui->lineEdit_logFile->setText(logFile);
656
}