1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
#include "targetsettingswidget.h"
#include "ui_targetsettingswidget.h"
static int WIDTH = 900;
using namespace ProjectExplorer::Internal;
TargetSettingsWidget::TargetSettingsWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::TargetSettingsWidget),
m_targetSelector(new TargetSelector(this))
{
ui->setupUi(this);
ui->separator->setStyleSheet(QLatin1String("* { "
"background-image: url(:/projectexplorer/images/targetseparatorbackground.png);"
"}"));
m_targetSelector->raise();
connect(m_targetSelector, SIGNAL(removeButtonClicked()),
this, SIGNAL(removeButtonClicked()));
connect(m_targetSelector, SIGNAL(currentChanged(int,int)),
this, SIGNAL(currentChanged(int,int)));
m_shadow = new QWidget(this);
// Create shadow below targetselector
m_targetSelector->raise();
QPalette shadowPal = palette();
QLinearGradient grad(0, 0, 0, 2);
grad.setColorAt(0, QColor(0, 0, 0, 60));
grad.setColorAt(1, Qt::transparent);
shadowPal.setBrush(QPalette::All, QPalette::Window, grad);
m_shadow->setPalette(shadowPal);
m_shadow->setAutoFillBackground(true);
updateTargetSelector();
}
TargetSettingsWidget::~TargetSettingsWidget()
{
delete ui;
}
void TargetSettingsWidget::addTarget(const QString &name)
{
m_targetSelector->addTarget(name);
updateTargetSelector();
}
void TargetSettingsWidget::insertTarget(int index, const QString &name)
{
m_targetSelector->insertTarget(index, name);
updateTargetSelector();
}
void TargetSettingsWidget::removeTarget(int index)
{
m_targetSelector->removeTarget(index);
updateTargetSelector();
}
void TargetSettingsWidget::setCurrentIndex(int index)
{
m_targetSelector->setCurrentIndex(index);
}
void TargetSettingsWidget::setCurrentSubIndex(int index)
{
m_targetSelector->setCurrentSubIndex(index);
}
void TargetSettingsWidget::setAddButtonEnabled(bool enabled)
{
m_targetSelector->setAddButtonEnabled(enabled);
}
void TargetSettingsWidget::setAddButtonMenu(QMenu *menu)
{
m_targetSelector->setAddButtonMenu(menu);
}
void TargetSettingsWidget::setRemoveButtonEnabled(bool enabled)
{
m_targetSelector->setRemoveButtonEnabled(enabled);
}
QString TargetSettingsWidget::targetNameAt(int index) const
{
return m_targetSelector->targetAt(index).name;
}
void TargetSettingsWidget::setCentralWidget(QWidget *widget)
{
ui->scrollArea->setWidget(widget);
}
int TargetSettingsWidget::targetCount() const
{
return m_targetSelector->targetCount();
}
int TargetSettingsWidget::currentIndex() const
{
return m_targetSelector->currentIndex();
}
int TargetSettingsWidget::currentSubIndex() const
{
return m_targetSelector->currentSubIndex();
}
bool TargetSettingsWidget::isAddButtonEnabled() const
{
return m_targetSelector->isAddButtonEnabled();
}
bool TargetSettingsWidget::isRemoveButtonEnabled() const
{
return m_targetSelector->isRemoveButtonEnabled();
}
void TargetSettingsWidget::resizeEvent(QResizeEvent *e)
{
QWidget::resizeEvent(e);
m_shadow->setGeometry(0, m_targetSelector->height() + 3, width(), 2);
}
void TargetSettingsWidget::updateTargetSelector()
{
m_targetSelector->setGeometry((WIDTH-m_targetSelector->minimumSizeHint().width())/2, 13,
m_targetSelector->minimumSizeHint().width(),
m_targetSelector->minimumSizeHint().height());
}
void TargetSettingsWidget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
|