FreeCAD

Форк
0
/
DlgCustomizeImp.cpp 
141 строка · 4.9 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2004 Werner Mayer <wmayer[at]users.sourceforge.net>     *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
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.      *
10
 *                                                                         *
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.                  *
15
 *                                                                         *
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                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24

25
#ifndef _PreComp_
26
# include <QEvent>
27
# include <QGridLayout>
28
# include <QPushButton>
29
# include <QSizePolicy>
30
#endif
31

32
#include "DlgCustomizeImp.h"
33
#include "MainWindow.h"
34
#include "WidgetFactory.h"
35

36

37
using namespace Gui::Dialog;
38

39
QList<QByteArray> DlgCustomizeImp::_pages;
40

41
/* TRANSLATOR Gui::Dialog::DlgCustomizeImp */
42

43
/**
44
 *  Constructs a DlgCustomizeImp which is a child of 'parent', with the
45
 *  name 'name' and widget flags set to 'f'
46
 *
47
 *  The dialog will by default be modeless, unless you set 'modal' to
48
 *  true to construct a modal dialog.
49
 */
50
DlgCustomizeImp::DlgCustomizeImp(QWidget* parent, Qt::WindowFlags fl)
51
  : QDialog(parent, fl)
52
{
53
    setModal(false);
54
    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
55
    resize( 690, 365 );
56

57
    setWindowTitle(tr("Customize"));
58
    setSizeGripEnabled( true );
59

60
    customLayout = new QGridLayout( this );
61
    customLayout->setSpacing( 6 );
62
    customLayout->setContentsMargins( 11, 11, 11, 11 );
63

64
    layout = new QHBoxLayout;
65
    layout->setSpacing( 6 );
66
    layout->setContentsMargins( 0, 0, 0, 0 );
67

68
    buttonHelp = new QPushButton( this );
69
    buttonHelp->setText(tr("&Help"));
70
    layout->addWidget( buttonHelp );
71

72
    auto spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
73
    layout->addItem(spacer);
74

75
    buttonClose = new QPushButton( this );
76
    buttonClose->setText(tr("&Close"));
77
    layout->addWidget(buttonClose);
78

79
    customLayout->addLayout( layout, 1, 0 );
80

81
    tabWidget = new QTabWidget( this );
82
    tabWidget->setObjectName(QString::fromLatin1("Gui__Dialog__TabWidget"));//so we can find it in DlgMacroExecuteImp
83

84
    // make sure that pages are ready to create
85
    GetWidgetFactorySupplier();
86
    for (const QByteArray& it : _pages)
87
    {
88
        addPage(WidgetFactory().createWidget(it.constData()));
89
    }
90

91
    customLayout->addWidget(tabWidget, 0, 0);
92

93

94
    // tab order
95
    setTabOrder(tabWidget, buttonClose);
96
    setTabOrder(buttonClose, buttonHelp);
97

98
    // connections
99
    //
100
    connect(buttonHelp,  &QPushButton::clicked, getMainWindow(), &MainWindow::whatsThis);
101
    connect(buttonClose, &QPushButton::clicked, this, &QDialog::close);
102
}
103

104
/**
105
 *  Destroys the object and frees any allocated resources
106
 */
107
DlgCustomizeImp::~DlgCustomizeImp() = default;
108

109
/**
110
 * Adds a customize page with its class name \a className.
111
 * To create this page it must be registered in the WidgetFactory.
112
 * @see WidgetFactory
113
 * @see CustomPageProducer
114
 */
115
void DlgCustomizeImp::addPage(const char* className)
116
{
117
    _pages.push_back(className);
118
}
119

120
/** Inserts a new tab page with its caption */
121
void DlgCustomizeImp::addPage (QWidget* w)
122
{
123
    tabWidget->addTab(w, w->windowTitle());
124
}
125

126
void DlgCustomizeImp::changeEvent(QEvent *e)
127
{
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());
136
        }
137
    }
138
    QDialog::changeEvent(e);
139
}
140

141
#include "moc_DlgCustomizeImp.cpp"
142

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.