1
/***************************************************************************
2
* Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
27
# include <QGridLayout>
28
# include <QPushButton>
29
# include <QSizePolicy>
32
#include "DlgCustomizeImp.h"
33
#include "MainWindow.h"
34
#include "WidgetFactory.h"
37
using namespace Gui::Dialog;
39
QList<QByteArray> DlgCustomizeImp::_pages;
41
/* TRANSLATOR Gui::Dialog::DlgCustomizeImp */
44
* Constructs a DlgCustomizeImp which is a child of 'parent', with the
45
* name 'name' and widget flags set to 'f'
47
* The dialog will by default be modeless, unless you set 'modal' to
48
* true to construct a modal dialog.
50
DlgCustomizeImp::DlgCustomizeImp(QWidget* parent, Qt::WindowFlags fl)
54
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
57
setWindowTitle(tr("Customize"));
58
setSizeGripEnabled( true );
60
customLayout = new QGridLayout( this );
61
customLayout->setSpacing( 6 );
62
customLayout->setContentsMargins( 11, 11, 11, 11 );
64
layout = new QHBoxLayout;
65
layout->setSpacing( 6 );
66
layout->setContentsMargins( 0, 0, 0, 0 );
68
buttonHelp = new QPushButton( this );
69
buttonHelp->setText(tr("&Help"));
70
layout->addWidget( buttonHelp );
72
auto spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
73
layout->addItem(spacer);
75
buttonClose = new QPushButton( this );
76
buttonClose->setText(tr("&Close"));
77
layout->addWidget(buttonClose);
79
customLayout->addLayout( layout, 1, 0 );
81
tabWidget = new QTabWidget( this );
82
tabWidget->setObjectName(QString::fromLatin1("Gui__Dialog__TabWidget"));//so we can find it in DlgMacroExecuteImp
84
// make sure that pages are ready to create
85
GetWidgetFactorySupplier();
86
for (const QByteArray& it : _pages)
88
addPage(WidgetFactory().createWidget(it.constData()));
91
customLayout->addWidget(tabWidget, 0, 0);
95
setTabOrder(tabWidget, buttonClose);
96
setTabOrder(buttonClose, buttonHelp);
100
connect(buttonHelp, &QPushButton::clicked, getMainWindow(), &MainWindow::whatsThis);
101
connect(buttonClose, &QPushButton::clicked, this, &QDialog::close);
105
* Destroys the object and frees any allocated resources
107
DlgCustomizeImp::~DlgCustomizeImp() = default;
110
* Adds a customize page with its class name \a className.
111
* To create this page it must be registered in the WidgetFactory.
113
* @see CustomPageProducer
115
void DlgCustomizeImp::addPage(const char* className)
117
_pages.push_back(className);
120
/** Inserts a new tab page with its caption */
121
void DlgCustomizeImp::addPage (QWidget* w)
123
tabWidget->addTab(w, w->windowTitle());
126
void DlgCustomizeImp::changeEvent(QEvent *e)
128
if (e->type() == QEvent::LanguageChange) {
129
setWindowTitle(tr("Customize"));
130
buttonHelp->setText(tr("&Help"));
131
buttonClose->setText(tr("&Close"));
132
int count = tabWidget->count();
133
for (int i=0; i<count; i++) {
134
QWidget* w = tabWidget->widget(i);
135
tabWidget->setTabText(i, w->windowTitle());
138
QDialog::changeEvent(e);
141
#include "moc_DlgCustomizeImp.cpp"