DlgCustomizeImp.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #include "PreCompiled.h"
00025 
00026 #include "DlgCustomizeImp.h"
00027 #include "MainWindow.h"
00028 #include "WidgetFactory.h"
00029 
00030 using namespace Gui::Dialog;
00031 
00032 QList<QByteArray> DlgCustomizeImp::_pages;
00033 
00034 /* TRANSLATOR Gui::Dialog::DlgCustomizeImp */
00035 
00043 DlgCustomizeImp::DlgCustomizeImp(QWidget* parent, Qt::WFlags fl)
00044   : QDialog(parent, fl)
00045 {
00046     setModal(false);
00047     resize( 434, 365 ); 
00048 
00049     setWindowTitle(tr("Customize"));
00050     setSizeGripEnabled( true );
00051 
00052     customLayout = new QGridLayout( this ); 
00053     customLayout->setSpacing( 6 );
00054     customLayout->setMargin( 11 );
00055 
00056     layout = new QHBoxLayout; 
00057     layout->setSpacing( 6 );
00058     layout->setMargin( 0 );
00059 
00060     buttonHelp = new QPushButton( this );
00061     buttonHelp->setText(tr("&Help"));
00062     layout->addWidget( buttonHelp );
00063 
00064     QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
00065     layout->addItem(spacer);
00066 
00067     buttonClose = new QPushButton( this );
00068     buttonClose->setText(tr("&Close"));
00069     layout->addWidget(buttonClose);
00070 
00071     customLayout->addLayout( layout, 1, 0 );
00072 
00073     tabWidget = new QTabWidget( this );
00074 
00075     // make sure that pages are ready to create
00076     GetWidgetFactorySupplier();
00077     for (QList<QByteArray>::Iterator it = _pages.begin(); it!=_pages.end(); ++it)
00078     {
00079         addPage(WidgetFactory().createWidget((*it).constData()));
00080     }
00081 
00082     customLayout->addWidget(tabWidget, 0, 0);
00083 
00084 
00085     // tab order
00086     setTabOrder(tabWidget, buttonClose);
00087     setTabOrder(buttonClose, buttonHelp);
00088 
00089     // connections
00090     //
00091     connect(buttonHelp,  SIGNAL (clicked()), getMainWindow(), SLOT (whatsThis()));
00092     connect(buttonClose, SIGNAL (clicked()), this, SLOT (close()));
00093 }
00094 
00098 DlgCustomizeImp::~DlgCustomizeImp()
00099 {
00100     // no need to delete child widgets, Qt does it all for us
00101 }
00102 
00109 void DlgCustomizeImp::addPage(const char* className)
00110 {
00111     _pages.push_back(className);
00112 }
00113 
00115 void DlgCustomizeImp::addPage (QWidget* w)
00116 {
00117     tabWidget->addTab(w, w->windowTitle());
00118 }
00119 
00120 void DlgCustomizeImp::changeEvent(QEvent *e)
00121 {
00122     if (e->type() == QEvent::LanguageChange) {
00123         setWindowTitle(tr("Customize"));
00124         buttonHelp->setText(tr("&Help"));
00125         buttonClose->setText(tr("&Close"));
00126         int count = tabWidget->count();
00127         for (int i=0; i<count; i++) {
00128             QWidget* w = tabWidget->widget(i);
00129             tabWidget->setTabText(i, w->windowTitle());
00130         }
00131     }
00132     QDialog::changeEvent(e);
00133 }
00134 
00135 #include "moc_DlgCustomizeImp.cpp"

Generated on Wed Nov 23 19:00:05 2011 for FreeCAD by  doxygen 1.6.1