Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
DlgSettingsSSH.cpp
1#include "DlgSettingsSSH.h"
2#include "ui_DlgSettingsSSH.h"
3#include "RabbitCommonDir.h"
4#include <QStandardPaths>
5
6CDlgSettingsSSH::CDlgSettingsSSH(CParameterSSH *pPara, QWidget *parent) :
7 QDialog(parent),
8 ui(new Ui::CDlgSettingsSSH),
9 m_pPara(pPara)
10{
11 ui->setupUi(this);
12
13 Q_ASSERT(m_pPara);
14 ui->leName->setText(m_pPara->GetName());
15 ui->leHost->setText(m_pPara->GetHost());
16 ui->spPort->setValue(m_pPara->GetPort());
17 ui->cbSavePassword->setChecked(m_pPara->GetSavePassword());
18 ui->leUser->setText(m_pPara->GetUser());
19 ui->lePassword->setText(m_pPara->GetPassword());
20
21 ui->leCapFile->setText(m_pPara->captrueFile);
22
23 m_pFrmParaAppearance =
25 if(m_pFrmParaAppearance)
26 ui->tabWidget->addTab(m_pFrmParaAppearance,
27 m_pFrmParaAppearance->windowTitle());
28 m_pFrmParaBehavior = new CFrmParameterTerminalBehavior(m_pPara, this);
29 if(m_pFrmParaBehavior)
30 ui->tabWidget->addTab(m_pFrmParaBehavior, m_pFrmParaBehavior->windowTitle());
31}
32
33CDlgSettingsSSH::~CDlgSettingsSSH()
34{
35 delete ui;
36}
37
38void CDlgSettingsSSH::on_pbOK_clicked()
39{
40 m_pPara->SetName(ui->leName->text());
41 m_pPara->SetHost(ui->leHost->text());
42 m_pPara->SetPort(ui->spPort->value());
43 m_pPara->SetSavePassword(ui->cbSavePassword->isChecked());
44 m_pPara->SetUser(ui->leUser->text());
45 m_pPara->SetPassword(ui->lePassword->text());
46
47 m_pPara->captrueFile = ui->leCapFile->text();
48
49 if(m_pFrmParaAppearance)
50 m_pFrmParaAppearance->AcceptSettings();
51 if(m_pFrmParaBehavior)
52 m_pFrmParaBehavior->AcceptSettings();
53
54 accept();
55}
56
57void CDlgSettingsSSH::on_pbCancel_clicked()
58{
59 reject();
60}
61
62void CDlgSettingsSSH::on_pbCapFileBrowser_clicked()
63{
64 ui->leCapFile->setText(
65 RabbitCommon::CDir::Instance()->GetSaveFileName(this,
66 tr("Capture file"),
67 QStandardPaths::writableLocation(QStandardPaths::TempLocation)
68 + QDir::separator() + "capfile.dat"));
69}
70
71void CDlgSettingsSSH::on_leHost_editingFinished()
72{
73 auto s = ui->leHost->text().split(":");
74 if(s.size() == 2)
75 {
76 ui->spPort->setValue(s[1].toUInt());
77 ui->leHost->setText(s[0]);
78 }
79}