1
//=============================================================================
3
// File : container.cpp
4
// Creation date : Wed Nov 21 17:09:49 2001 GMT by Szymon Stefanek
6
// This file is part of the KVirc irc client distribution
7
// Copyright (C) 2001-2008 Szymon Stefanek (pragma at kvirc dot net)
9
// This program is FREE software. You can redistribute it and/or
10
// modify it under the terms of the GNU General Public License
11
// as published by the Free Software Foundation; either version 2
12
// of the License, or (at your opinion) any later version.
14
// This program is distributed in the HOPE that it will be USEFUL,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
// See the GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program. If not, write to the Free Software Foundation,
21
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
//=============================================================================
25
#include "container.h"
26
#include "instances.h"
28
#include "kvi_locale.h"
29
#include "kvi_iconmanager.h"
31
#include "kvi_tal_tooltip.h"
34
#include <QPushButton>
35
#include <QDesktopWidget>
37
#include <QGridLayout>
38
#include <QCloseEvent>
42
extern KviOptionsInstanceManager * g_pOptionsInstanceManager;
44
KviOptionsWidgetContainer::KviOptionsWidgetContainer(QWidget * par,bool bModal)
47
m_pLayout = new QGridLayout(this);
49
setObjectName("container");
54
KviOptionsWidgetContainer::~KviOptionsWidgetContainer()
56
if(m_pOptionsWidget)delete m_pOptionsWidget;
59
void KviOptionsWidgetContainer::setLeftCornerWidget(QWidget * pWidget)
63
m_pLayout->addWidget(pWidget,1,0);
67
void KviOptionsWidgetContainer::setup(KviOptionsWidget * w)
69
m_pLayout->addWidget(w,0,0,1,3);
70
//g->addMultiCellWidget(w,0,0,0,2);
72
QPushButton * b = new QPushButton(__tr2qs_ctx("&OK","options"),this);
73
KviTalToolTip::add(b,__tr2qs_ctx("Close this dialog, accepting all changes.","options"));
74
//b->setMinimumWidth(m_pCancel->sizeHint().width());
75
m_pLayout->addWidget(b,1,1);
77
connect(b,SIGNAL(clicked()),this,SLOT(okClicked()));
78
b->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT)));
80
m_pCancel = new QPushButton(__tr2qs_ctx("Cancel","options"),this);
81
KviTalToolTip::add(m_pCancel,__tr2qs_ctx("Close this dialog, discarding all changes.","options"));
82
m_pLayout->addWidget(m_pCancel,1,2);
83
connect(m_pCancel,SIGNAL(clicked()),this,SLOT(cancelClicked()));
84
m_pCancel->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD)));
87
m_pLayout->setRowStretch(0,1);
88
m_pLayout->setColumnStretch(0,1);
90
KviOptionsWidgetInstanceEntry * e = g_pOptionsInstanceManager->findInstanceEntry(w->metaObject()->className());
93
setWindowIcon(QIcon(*(g_pIconManager->getSmallIcon(e->iIcon))));
94
setWindowTitle(e->szName);
100
void KviOptionsWidgetContainer::closeEvent(QCloseEvent *e)
106
void KviOptionsWidgetContainer::showEvent(QShowEvent *e)
110
QRect rect = g_pApp->desktop()->screenGeometry(g_pApp->desktop()->primaryScreen());
111
move((rect.width() - width())/2,(rect.height() - height())/2);
113
QWidget::showEvent(e);
114
m_pCancel->setFocus();
117
void KviOptionsWidgetContainer::reject()
122
void KviOptionsWidgetContainer::okClicked()
124
if(m_pOptionsWidget)m_pOptionsWidget->commit();
125
g_pApp->saveOptions();
129
void KviOptionsWidgetContainer::cancelClicked()
134
#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
135
#include "m_container.moc"
136
#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES