/
download_options.cpp
109 lines (92 loc) · 3.39 KB
/
download_options.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include "download_options.h"
#include "int_validator.h"
#include "pixmap/open.xpm"
#include "pixmap/open_d.xpm"
#include <qpushbutton.h>
#include <qtoolbutton.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qfiledialog.h>
#include <qiconset.h>
#include <qvalidator.h>
// -------------------------------------------------------
// -------- WGDownloadOptionsDlg
// -------------------------------------------------------
WGDownloadOptionsDlg::WGDownloadOptionsDlg( QWidget* parent, const char* name, bool modal, WFlags fl ): WGDownloadOptionsDlgBase( parent, name, modal, fl )
{
QIconSet image_open( QPixmap((const char**)image_open_data) );
image_open.setPixmap( QPixmap((const char**)image_open_d_data), QIconSet::Automatic, QIconSet::Disabled );
DirectoryB->setIconSet( image_open );
LogDirectoryB->setIconSet( image_open );
RetriesNumberLE->setValidator( new WGIntValidator( RetriesNumberLE ) );
RetriesWaitLE->setValidator( new WGIntValidator( RetriesWaitLE ) );
connect( OkB , SIGNAL(clicked()) , this, SLOT(slot_ok()) );
connect( CancelB , SIGNAL(clicked()) , this, SLOT(slot_cancel()) );
connect( DirectoryB , SIGNAL(clicked()) , this, SLOT(slot_directory()) );
connect( RestartCB , SIGNAL(clicked()) , this, SLOT(slot_restart()) );
connect( PasswordCB , SIGNAL(clicked()) , this, SLOT(slot_password()) );
connect( LogCB , SIGNAL(clicked()) , this, SLOT(slot_log()) );
connect( LogDirectoryB , SIGNAL(clicked()) , this, SLOT(slot_log_directory()) );
connect( URLLE , SIGNAL(returnPressed()), this, SLOT(slot_ok()) );
connect( PasswordUsrLE , SIGNAL(returnPressed()), this, SLOT(slot_ok()) );
connect( PasswordPassLE , SIGNAL(returnPressed()), this, SLOT(slot_ok()) );
connect( RetriesNumberLE, SIGNAL(returnPressed()), this, SLOT(slot_ok()) );
connect( RetriesWaitLE , SIGNAL(returnPressed()), this, SLOT(slot_ok()) );
updateControls();
URLLE->setFocus();
}
WGDownloadOptionsDlg::~WGDownloadOptionsDlg()
{
}
void WGDownloadOptionsDlg::slot_ok()
{
accept();
}
void WGDownloadOptionsDlg::slot_cancel()
{
reject();
}
void WGDownloadOptionsDlg::slot_directory()
{
QString s = QFileDialog::getExistingDirectory( DirectoryLE->text(), this );
if ( !s.isEmpty() ) DirectoryLE->setText( s );
}
void WGDownloadOptionsDlg::slot_restart()
{
bool flag = !RestartCB->isChecked();
DontUseSuffixCB->setEnabled( flag );
OlderCB->setEnabled( flag );
}
void WGDownloadOptionsDlg::slot_password()
{
bool flag = PasswordCB->isChecked();
bool f = PasswordUsrLE->hasFocus() || PasswordPassLE->hasFocus();
PasswordUsrL->setEnabled( flag );
PasswordUsrLE->setEnabled( flag );
PasswordPassL->setEnabled( flag );
PasswordPassLE->setEnabled( flag );
if ( flag ) {
PasswordUsrLE->setFocus();
} else {
if ( f ) PasswordCB->setFocus();
}
}
void WGDownloadOptionsDlg::slot_log()
{
bool flag = LogCB->isChecked();
LogDirectoryL->setEnabled( flag );
LogDirectoryLE->setEnabled( flag );
LogDirectoryB->setEnabled( flag );
}
void WGDownloadOptionsDlg::slot_log_directory()
{
QString s = QFileDialog::getExistingDirectory( LogDirectoryLE->text(), this );
if ( !s.isEmpty() ) LogDirectoryLE->setText( s );
}
void WGDownloadOptionsDlg::updateControls()
{
slot_restart();
slot_password();
slot_log();
}