1 /**
2  * UGENE - Integrated Bioinformatics Tools.
3  * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru>
4  * http://ugene.net
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program 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 General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  */
21 
22 #include "GroupOptionsWidget.h"
23 
24 #include <QHBoxLayout>
25 #include <QLabel>
26 #include <QPushButton>
27 #include <QSpacerItem>
28 
29 #include <U2Gui/HelpButton.h>
30 
31 namespace U2 {
32 
GroupOptionsWidget(const QString & _groupId,const QString & _title,const QString & documentationPage,QWidget * _widget,QWidget * mainWidget)33 GroupOptionsWidget::GroupOptionsWidget(const QString &_groupId, const QString &_title, const QString &documentationPage, QWidget *_widget, QWidget *mainWidget)
34     : groupId(_groupId),
35       widget(_widget),
36       mainWidget(mainWidget),
37       title(_title) {
38 #ifdef Q_OS_DARWIN
39     setStyleSheet("font-size: 11.25pt;");
40 #else
41     setStyleSheet("font-size: 8.25pt;");
42 #endif
43 
44     titleWidget = new QLabel(title);
45     titleWidget->setObjectName("titleWidget");
46     titleWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
47     titleWidget->setMinimumWidth(MIN_WIDGET_WIDTH);
48 
49     titleWidget->setStyleSheet(
50         "background: palette(midlight);"
51         "border-style: solid;"
52         "border-width: 1px;"
53         "border-color: palette(mid);"
54         "padding: 2px;"
55         "margin: 5px;");
56 
57     widget->setContentsMargins(10, 5, 5, 5);
58 
59     // Layout and "parent" the widgets
60     mainLayout = new QVBoxLayout();
61     mainLayout->setContentsMargins(0, 0, 0, 15);
62     mainLayout->setSpacing(0);
63     mainLayout->addWidget(titleWidget);
64     mainLayout->addWidget(widget);
65 
66     QPushButton *helpButton = new QPushButton(tr("Help"), this);
67     helpButton->setMaximumWidth(60);
68     new HelpButton(this, helpButton, documentationPage);
69     QSpacerItem *spacer = new QSpacerItem(MIN_WIDGET_WIDTH, 0, QSizePolicy::Maximum, QSizePolicy::Expanding);
70     mainLayout->addSpacerItem(spacer);
71 
72     QHBoxLayout *helpLayout = new QHBoxLayout();
73     helpLayout->addWidget(helpButton, 0, Qt::AlignRight);
74     helpLayout->setContentsMargins(0, 0, 10, 0);
75 
76     mainLayout->addLayout(helpLayout);
77     mainLayout->setAlignment(helpLayout, Qt::AlignBottom);
78 
79     setLayout(mainLayout);
80 
81     setFocusProxy(widget);
82 }
83 
84 }  // namespace U2
85