summaryrefslogtreecommitdiffstats
path: root/src/modules/dcc/dialogs.cpp
blob: 6f2426d7847e0356f0f0327e6ac6a39b8fb1f420 (plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
//
//   File : dialogs.cpp
//   Creation date : Tue Sep 19 09 2000 15:23:12 by Szymon Stefanek
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
//
//   This program is FREE software. You can redistribute it and/or
//   modify it under the terms of the GNU General Public License
//   as published by the Free Software Foundation; either version 2
//   of the License, or (at your opinion) any later version.
//
//   This program is distributed in the HOPE that it will be USEFUL,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//   See the GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program. If not, write to the Free Software Foundation,
//   Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
#include "dialogs.h"

#include "kvi_locale.h"
#include "kvi_iconmanager.h"
#include "kvi_app.h"

#include <tqlayout.h>
#include <tqpushbutton.h>
#include <tqlabel.h>
#include <tqstringlist.h>
#include <tqevent.h>
#include <tqdesktopwidget.h>

KviDccBox::KviDccBox(KviDccBroker * br,KviDccDescriptor * dcc)
{
	m_pDescriptor = dcc;
	m_pBroker = br;
}

KviDccBox::~KviDccBox()
{
	if(m_pDescriptor)delete m_pDescriptor;
	m_pDescriptor = 0;
	m_pBroker->unregisterDccBox(this);
}

void KviDccBox::forgetDescriptor()
{
	m_pDescriptor = 0;
}

KviDccAcceptBox::KviDccAcceptBox(KviDccBroker * br,KviDccDescriptor * dcc,const TQString &text,const TQString &capt)
: TQWidget(0,"dcc_accept_box") , KviDccBox(br,dcc)
{
	TQVBoxLayout * vb = new TQVBoxLayout(this,4,4);
	TQLabel * l = new TQLabel(text,this);
	vb->addWidget(l);
	TQHBoxLayout *hb = new TQHBoxLayout(4);
	vb->addLayout(hb,TQt::AlignCenter);
	TQPushButton * btn = new TQPushButton(__tr2qs_ctx("&Accept","dcc"),this);
	btn->setDefault(true);
	//btn->setFocus();
	hb->addWidget(btn);
	connect(btn,TQT_SIGNAL(clicked()),this,TQT_SLOT(acceptClicked()));
	btn = new TQPushButton(__tr2qs_ctx("&Reject","dcc"),this);
	connect(btn,TQT_SIGNAL(clicked()),this,TQT_SLOT(rejectClicked()));
	hb->addWidget(btn);

	setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DCCMSG)));
	setCaption(capt);

	l->setActiveWindow();
	l->setFocus();
}

KviDccAcceptBox::~KviDccAcceptBox()
{
}

void KviDccAcceptBox::acceptClicked()
{
	hide();
	emit accepted(this,m_pDescriptor);
	g_pApp->collectGarbage(TQT_TQOBJECT(this));
}

void KviDccAcceptBox::rejectClicked()
{
	hide();
	emit rejected(this,m_pDescriptor);
	g_pApp->collectGarbage(TQT_TQOBJECT(this));
}

void KviDccAcceptBox::closeEvent(TQCloseEvent *e)
{
	hide();
	e->ignore();
	emit rejected(this,m_pDescriptor);
	g_pApp->collectGarbage(TQT_TQOBJECT(this));
}

void KviDccAcceptBox::showEvent(TQShowEvent *e)
{
	move((g_pApp->desktop()->width() - width()) >> 1,
		(g_pApp->desktop()->height() - height()) >> 1);
	TQWidget::showEvent(e);
}




KviDccRenameBox::KviDccRenameBox(KviDccBroker * br,KviDccDescriptor * dcc,const TQString &text,bool bDisableResume)
: TQWidget(0,"dcc_rename_box") , KviDccBox(br,dcc)
{
	TQVBoxLayout * vb = new TQVBoxLayout(this,4,4);
	TQLabel * l = new TQLabel(text,this);
	vb->addWidget(l);

	TQHBoxLayout *hb = new TQHBoxLayout(4);
	vb->addLayout(hb,TQt::AlignCenter);	

	TQPushButton * btn = new TQPushButton(__tr2qs_ctx("&Rename","dcc"),this);
	hb->addWidget(btn);
	connect(btn,TQT_SIGNAL(clicked()),this,TQT_SLOT(renameClicked()));

	btn = new TQPushButton(__tr2qs_ctx("Over&write","dcc"),this);
	hb->addWidget(btn);
	connect(btn,TQT_SIGNAL(clicked()),this,TQT_SLOT(overwriteClicked()));

	btn = new TQPushButton(__tr2qs_ctx("Re&sume","dcc"),this);
	hb->addWidget(btn);
	connect(btn,TQT_SIGNAL(clicked()),this,TQT_SLOT(resumeClicked()));
	if(bDisableResume)btn->setEnabled(false);

	btn = new TQPushButton(__tr2qs_ctx("Cancel","dcc"),this);
	hb->addWidget(btn);
	connect(btn,TQT_SIGNAL(clicked()),this,TQT_SLOT(cancelClicked()));
	btn->setDefault(true);
	//btn->setFocus();

	setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DCCMSG)));
	setCaption(__tr2qs_ctx("File Already Exists - KVIrc","dcc"));
}

KviDccRenameBox::~KviDccRenameBox()
{
}

void KviDccRenameBox::closeEvent(TQCloseEvent *e)
{
	hide();
	e->ignore();
	if(m_pDescriptor)
	{
		emit cancelSelected(this,m_pDescriptor);
		g_pApp->collectGarbage(TQT_TQOBJECT(this));
	}
}

void KviDccRenameBox::showEvent(TQShowEvent *e)
{
	move((g_pApp->desktop()->width() - width()) >> 1,
		(g_pApp->desktop()->height() - height()) >> 1);
	TQWidget::showEvent(e);
}

void KviDccRenameBox::renameClicked()
{
	hide();
	emit renameSelected(this,m_pDescriptor);
	g_pApp->collectGarbage(TQT_TQOBJECT(this));
}

void KviDccRenameBox::overwriteClicked()
{
	hide();
	emit overwriteSelected(this,m_pDescriptor);
	g_pApp->collectGarbage(TQT_TQOBJECT(this));
}

void KviDccRenameBox::resumeClicked()
{
	hide();
	m_pDescriptor->bResume = true;
	emit overwriteSelected(this,m_pDescriptor);
	g_pApp->collectGarbage(TQT_TQOBJECT(this));
}

void KviDccRenameBox::cancelClicked()
{
	hide();
	emit cancelSelected(this,m_pDescriptor);
	g_pApp->collectGarbage(TQT_TQOBJECT(this));
}




#include "m_dialogs.moc"