Subversion Repositories tpanel

Rev

Rev 120 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 120 Rev 122
Line 14... Line 14...
14
 * You should have received a copy of the GNU General Public License
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,
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
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
17
 */
18
#include <QFileDialog>
18
#include <QFileDialog>
-
 
19
#include <QComboBox>
-
 
20
#include <QMessageBox>
19
 
21
 
20
#include <unistd.h>
22
#include <unistd.h>
21
 
23
 
22
#include "tqtsettings.h"
24
#include "tqtsettings.h"
23
#include "terror.h"
25
#include "terror.h"
Line 29... Line 31...
29
#include <QtQml/QQmlFile>
31
#include <QtQml/QQmlFile>
30
#include <android/log.h>
32
#include <android/log.h>
31
#endif
33
#endif
32
 
34
 
33
#include "tconfig.h"
35
#include "tconfig.h"
-
 
36
#include "ttpinit.h"
34
 
37
 
35
#define RLOG_INFO           0x00fe
38
#define RLOG_INFO           0x00fe
36
#define RLOG_WARNING        0x00fd
39
#define RLOG_WARNING        0x00fd
37
#define RLOG_ERROR          0x00fb
40
#define RLOG_ERROR          0x00fb
38
#define RLOG_TRACE          0x00f7
41
#define RLOG_TRACE          0x00f7
39
#define RLOG_DEBUG          0x00ef
42
#define RLOG_DEBUG          0x00ef
40
#define RLOG_PROTOCOL       0x00f8
43
#define RLOG_PROTOCOL       0x00f8
41
#define RLOG_ALL            0x00e0
44
#define RLOG_ALL            0x00e0
42
 
45
 
-
 
46
using std::string;
-
 
47
using std::vector;
-
 
48
 
43
TQtSettings::TQtSettings(QWidget *parent)
49
TQtSettings::TQtSettings(QWidget *parent)
44
	: QDialog(parent),
50
	: QDialog(parent),
45
	  ui(new Ui::TQtSettings)
51
	  ui(new Ui::TQtSettings)
46
{
52
{
47
	DECL_TRACER("TQtSettings::TQtSettings(QWidget *parent)");
53
	DECL_TRACER("TQtSettings::TQtSettings(QWidget *parent)");
Line 54... Line 60...
54
    ui->lineEdit_PType->setText(TConfig::getPanelType().c_str());
60
    ui->lineEdit_PType->setText(TConfig::getPanelType().c_str());
55
    ui->spinBox_Port->setValue(TConfig::getPort());
61
    ui->spinBox_Port->setValue(TConfig::getPort());
56
    ui->spinBox_Channel->setValue(TConfig::getChannel());
62
    ui->spinBox_Channel->setValue(TConfig::getChannel());
57
    ui->lineEdit_FTPuser->setText(TConfig::getFtpUser().c_str());
63
    ui->lineEdit_FTPuser->setText(TConfig::getFtpUser().c_str());
58
    ui->lineEdit_FTPpassword->setText(TConfig::getFtpPassword().c_str());
64
    ui->lineEdit_FTPpassword->setText(TConfig::getFtpPassword().c_str());
-
 
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)
59
    ui->lineEdit_FTPsurface->setText(TConfig::getFtpSurface().c_str());
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
 
60
    ui->checkBox_FTPpassive->setCheckState((TConfig::getFtpPassive() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
95
    ui->checkBox_FTPpassive->setCheckState((TConfig::getFtpPassive() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked));
61
 
96
 
62
    mLogLevel = TConfig::getLogLevelBits();
97
    mLogLevel = TConfig::getLogLevelBits();
63
    ui->checkBox_LogInfo->setCheckState((mLogLevel & HLOG_INFO) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
98
    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);
99
    ui->checkBox_LogWarning->setCheckState((mLogLevel & HLOG_WARNING) ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
Line 288... Line 323...
288
                            }
323
                            }
289
                            else if (n.startsWith("lineEdit"))
324
                            else if (n.startsWith("lineEdit"))
290
                                scaleObject(dynamic_cast<QLineEdit *>(on));
325
                                scaleObject(dynamic_cast<QLineEdit *>(on));
291
                            else if (n.startsWith("spinBox"))
326
                            else if (n.startsWith("spinBox"))
292
                                scaleObject(dynamic_cast<QSpinBox *>(on));
327
                                scaleObject(dynamic_cast<QSpinBox *>(on));
-
 
328
                            else if (n.startsWith("comboBox"))
-
 
329
                                scaleObject(dynamic_cast<QComboBox *>(on));
293
                            else if (n.startsWith("label"))
330
                            else if (n.startsWith("label"))
294
                            {
331
                            {
295
                                scaleObject(dynamic_cast<QLabel *>(on));
332
                                scaleObject(dynamic_cast<QLabel *>(on));
296
#ifdef __ANDROID__
333
#ifdef __ANDROID__
297
                                QLabel *lb = dynamic_cast<QLabel *>(on);
334
                                QLabel *lb = dynamic_cast<QLabel *>(on);
Line 656... Line 693...
656
 
693
 
657
    mSetChanged = true;
694
    mSetChanged = true;
658
    TConfig::saveFtpPassword(arg1.toStdString());
695
    TConfig::saveFtpPassword(arg1.toStdString());
659
}
696
}
660
 
697
 
661
void TQtSettings::on_lineEdit_FTPsurface_textChanged(const QString& arg1)
698
void TQtSettings::on_comboBox_FTPsurface_currentIndexChanged(const QString& arg1)
662
{
699
{
663
    DECL_TRACER("TQtSettings::on_lineEdit_FTPsurface_textChanged(const QString& arg1)");
700
    DECL_TRACER("TQtSettings::on_comboBox_FTPsurface_currentIndexChanged(const QString& arg1)");
664
 
701
 
665
    if (arg1.compare(TConfig::getFtpSurface().c_str()) == 0)
702
    if (arg1.compare(TConfig::getFtpSurface().c_str()) == 0)
666
        return;
703
        return;
667
 
704
 
668
    mSetChanged = true;
705
    mSetChanged = true;
669
    TConfig::saveFtpSurface(arg1.toStdString());
706
    TConfig::saveFtpSurface(arg1.toStdString());
-
 
707
    MSG_DEBUG("Surface was set to " << arg1.toStdString());
-
 
708
}
-
 
709
 
-
 
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"));
670
}
736
}
671
 
737
 
672
void TQtSettings::on_checkBox_FTPpassive_toggled(bool checked)
738
void TQtSettings::on_checkBox_FTPpassive_toggled(bool checked)
673
{
739
{
674
    DECL_TRACER("TQtSettings::on_checkBox_FTPpassive_toggled(bool checked)");
740
    DECL_TRACER("TQtSettings::on_checkBox_FTPpassive_toggled(bool checked)");