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
|
//
// File : container.cpp
// Creation date : Wed Nov 21 17:09:49 2001 GMT by Szymon Stefanek
//
// This file is part of the KVirc irc client distribution
// Copyright (C) 2001 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 "container.h"
#include "instances.h"
#include "kvi_locale.h"
#include "kvi_iconmanager.h"
#include "kvi_app.h"
#include <tqlayout.h>
#include <tqpushbutton.h>
#include "kvi_tal_tooltip.h"
#include <tqevent.h>
#ifdef COMPILE_USE_QT4
#include <tqdesktopwidget.h>
#endif
extern KviOptionsInstanceManager * g_pOptionsInstanceManager;
KviOptionsWidgetContainer::KviOptionsWidgetContainer(TQWidget * par,bool bModal)
: TQDialog(par,"container","options")
{
m_pOptionsWidget = 0;
setModal(bModal);
}
KviOptionsWidgetContainer::~KviOptionsWidgetContainer()
{
if(m_pOptionsWidget)delete m_pOptionsWidget;
}
void KviOptionsWidgetContainer::setup(KviOptionsWidget * w)
{
TQGridLayout * g = new TQGridLayout(this,2,3,4,8);
g->addMultiCellWidget(w,0,0,0,2);
TQPushButton * b = new TQPushButton(__tr2qs_ctx("&OK","options"),this);
KviTalToolTip::add(b,__tr2qs_ctx("Close this dialog, accepting all changes.","options"));
//b->setMinimumWidth(m_pCancel->tqsizeHint().width());
g->addWidget(b,1,1);
b->setDefault(true);
connect(b,TQT_SIGNAL(clicked()),this,TQT_SLOT(okClicked()));
b->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT)));
m_pCancel = new TQPushButton(__tr2qs_ctx("Cancel","options"),this);
KviTalToolTip::add(m_pCancel,__tr2qs_ctx("Close this dialog, discarding all changes.","options"));
g->addWidget(m_pCancel,1,2);
connect(m_pCancel,TQT_SIGNAL(clicked()),this,TQT_SLOT(cancelClicked()));
m_pCancel->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD)));
g->setRowStretch(0,1);
g->setColStretch(0,1);
KviOptionsWidgetInstanceEntry * e = g_pOptionsInstanceManager->findInstanceEntry(w->className());
if(e)
{
//KviStr caption(KviStr::Format,"%s - KVIrc",e->szName);
setIcon(*(g_pIconManager->getSmallIcon(e->iIcon)));
setCaption(e->szName);
}
m_pOptionsWidget = w;
}
void KviOptionsWidgetContainer::closeEvent(TQCloseEvent *e)
{
e->ignore();
cancelClicked();
}
void KviOptionsWidgetContainer::showEvent(TQShowEvent *e)
{
if(tqparent() == 0)
{
move((g_pApp->desktop()->width() - width()) / 2,
(g_pApp->desktop()->height() - height()) / 2);
}
TQWidget::showEvent(e);
m_pCancel->setFocus();
}
void KviOptionsWidgetContainer::reject()
{
cancelClicked();
}
void KviOptionsWidgetContainer::okClicked()
{
if(m_pOptionsWidget)m_pOptionsWidget->commit();
g_pApp->saveOptions();
delete this;
}
void KviOptionsWidgetContainer::cancelClicked()
{
deleteLater();
}
#include "m_container.moc"
|