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 "DashboardTabPage.h"
23
24 #include "DashboardWidget.h"
25
26 namespace U2 {
27
DashboardTabPage(const QString & tabObjectName)28 DashboardTabPage::DashboardTabPage(const QString &tabObjectName) {
29 setObjectName(tabObjectName);
30 setStyleSheet("QWidget#tabPageStyleRoot {"
31 " background: url(':U2Designer/images/background.png') repeat scroll 0 0 transparent; "
32 " padding: 10px;"
33 "}");
34
35 auto mainWidget = new QWidget();
36
37 auto layout = new QHBoxLayout();
38 layout->setMargin(0);
39 layout->setSpacing(0);
40 mainWidget->setLayout(layout);
41
42 auto styleRootWidget = new QWidget();
43 styleRootWidget->setObjectName("tabPageStyleRoot");
44 layout->addWidget(styleRootWidget);
45
46 auto styleRootWidgetLayout = new QHBoxLayout();
47 styleRootWidgetLayout->setMargin(0);
48 styleRootWidgetLayout->setSpacing(0);
49 styleRootWidget->setLayout(styleRootWidgetLayout);
50
51 styleRootWidgetLayout->addStretch(1);
52 auto centerWidget = new QWidget();
53 centerWidget->setMinimumWidth(1150);
54 styleRootWidgetLayout->addWidget(centerWidget);
55 styleRootWidgetLayout->addStretch(1);
56
57 auto centerWidgetLayout = new QHBoxLayout();
58 centerWidgetLayout->setSpacing(0);
59 centerWidgetLayout->setContentsMargins(0, 0, 0, 0);
60 centerWidget->setLayout(centerWidgetLayout);
61
62 int widgetSpacing = 20;
63 leftColumnLayout = new QVBoxLayout();
64 leftColumnLayout->setSpacing(widgetSpacing);
65 leftColumnLayout->setContentsMargins(widgetSpacing, widgetSpacing, widgetSpacing / 2, widgetSpacing);
66 leftColumnLayout->addStretch(1000);
67 centerWidgetLayout->addLayout(leftColumnLayout);
68
69 rightColumnLayout = new QVBoxLayout();
70 rightColumnLayout->setSpacing(widgetSpacing);
71 rightColumnLayout->setContentsMargins(widgetSpacing / 2, widgetSpacing, widgetSpacing, widgetSpacing);
72 rightColumnLayout->addStretch(1000);
73 centerWidgetLayout->addLayout(rightColumnLayout);
74
75 setWidget(mainWidget);
76 setWidgetResizable(true); // make the widget to fill whole available space
77 }
78
addDashboardWidget(const QString & title,QWidget * contentWidget)79 DashboardWidget *DashboardTabPage::addDashboardWidget(const QString &title, QWidget *contentWidget) {
80 auto layout = leftColumnLayout->count() <= rightColumnLayout->count() ? leftColumnLayout : rightColumnLayout;
81 auto dashboardWidget = new DashboardWidget(title, contentWidget);
82 layout->insertWidget(layout->count() - 1, dashboardWidget); // the last is stretch.
83 return dashboardWidget;
84 }
85
86 } // namespace U2
87