39 #include "ui_quickcontrolview.h"
50 #include <QApplication>
58 using namespace DISPLIB;
66 Qt::WindowFlags flags,
71 , m_pUi(new Ui::QuickControlViewWidget)
73 m_sSettingsPath = sSettingsPath;
75 m_pUi->m_pTabWidget->setTabBarAutoHide(
true);
76 m_pUi->m_pTabWidget->setMovable(
true);
77 m_pUi->m_pTabWidget->setTabPosition(QTabWidget::West);
78 this->setWindowTitle(
"Quick Control");
80 if(!(windowFlags() & Qt::CustomizeWindowHint)) {
81 m_pUi->m_pushButton_close->hide();
85 connect(m_pUi->m_horizontalSlider_opacity, &QSlider::valueChanged,
89 connect(m_pUi->m_pushButton_close,
static_cast<void (QPushButton::*)(
bool)
>(&QPushButton::clicked),
90 this, &QuickControlView::hide);
110 while(m_pUi->m_pTabWidget->count() != 0) {
111 QWidget* pTabWidget = m_pUi->m_pTabWidget->widget(m_pUi->m_pTabWidget->count()-1);
112 m_pUi->m_pTabWidget->removeTab(m_pUi->m_pTabWidget->count()-1);
119 QVBoxLayout* QuickControlView::findTabWidgetLayout(
const QString& sTabName)
121 QVBoxLayout* pTabWidgetLayout = Q_NULLPTR;
123 if(QWidget* pTabWidget = m_pUi->m_pTabWidget->findChild<QWidget *>(sTabName +
"TabWidget")) {
125 pTabWidgetLayout = qobject_cast<QVBoxLayout *>(pTabWidget->layout());
128 pTabWidget =
new QWidget();
129 pTabWidget->setObjectName(sTabName +
"TabWidget");
130 pTabWidgetLayout =
new QVBoxLayout();
131 pTabWidgetLayout->setContentsMargins(4,2,4,4);
132 pTabWidget->setLayout(pTabWidgetLayout);
133 m_pUi->m_pTabWidget->insertTab(0,pTabWidget, sTabName);
136 return pTabWidgetLayout;
142 const QString& sTabName,
145 for(
int i = 0; i < lWidgets.size(); ++i) {
146 QString sObjectName = lWidgets.at(i)->objectName();
148 if(sObjectName.contains(
"widget_", Qt::CaseInsensitive)) {
149 this->
addWidget(lWidgets.at(i), sTabName, bAddToEnd);
152 if(sObjectName.contains(
"group_", Qt::CaseInsensitive)) {
153 if(sObjectName.contains(
"group_tab_", Qt::CaseInsensitive)) {
154 sObjectName.remove(
"group_tab_");
155 QStringList sList = sObjectName.split(
"_");
157 if(sList.size() >= 2) {
163 sObjectName.remove(
"group_");
164 this->
addGroupBox(lWidgets.at(i), sObjectName, sTabName, bAddToEnd);
173 const QString& sTabName,
176 if(QVBoxLayout* pTabWidgetLayout = findTabWidgetLayout(sTabName)) {
177 int iPos = bAddToEnd ? -1 : 0;
178 pTabWidgetLayout->insertWidget(iPos,
187 const QString& sGroupBoxName,
188 const QString& sTabName,
191 if(QVBoxLayout* pTabWidgetLayout = findTabWidgetLayout(sTabName)) {
192 int iPos = bAddToEnd ? -1 : 0;
193 QGroupBox* pGroupBox =
new QGroupBox(sGroupBoxName);
194 pGroupBox->setObjectName(sGroupBoxName);
196 QVBoxLayout *pVBox =
new QVBoxLayout;
198 pVBox->setContentsMargins(0,0,0,0);
199 pVBox->addWidget(pWidget);
200 pGroupBox->setLayout(pVBox);
202 pTabWidgetLayout->insertWidget(iPos,
211 const QString& sGroupBoxName,
212 const QString& sTabNameGroupBox,
213 const QString& sTabName,
216 if(QVBoxLayout* pTabWidgetLayout = findTabWidgetLayout(sTabName)) {
217 QGroupBox* pGroupBox = pTabWidgetLayout->parentWidget()->findChild<QGroupBox *>(sGroupBoxName);
220 int iPos = bAddToEnd ? -1 : 0;
221 pGroupBox =
new QGroupBox(sGroupBoxName);
222 pGroupBox->setObjectName(sGroupBoxName);
224 pTabWidgetLayout->insertWidget(iPos,
228 QVBoxLayout *pVBox =
new QVBoxLayout;
229 QTabWidget* pTabWidget =
new QTabWidget;
230 pTabWidget->setTabBarAutoHide(
false);
231 pTabWidget->setMovable(
true);
232 pTabWidget->setObjectName(sGroupBoxName +
"TabWidget");
234 pTabWidget->addTab(pWidget, sTabNameGroupBox);
235 pVBox->setContentsMargins(4,2,4,4);
236 pVBox->addWidget(pTabWidget);
237 pGroupBox->setLayout(pVBox);
239 QTabWidget* pTabWidget = pGroupBox->findChild<QTabWidget *>(sGroupBoxName +
"TabWidget");
242 pTabWidget->addTab(pWidget, sTabNameGroupBox);
252 m_pUi->m_horizontalSlider_opacity->setValue(opactiy);
261 return m_pUi->m_horizontalSlider_opacity->value();
268 m_pUi->m_pushButton_close->setVisible(bVisibility);
269 m_pUi->m_horizontalSlider_opacity->setVisible(bVisibility);
270 m_pUi->m_label_opacity->setVisible(bVisibility);
277 if(m_sSettingsPath.isEmpty()) {
281 QSettings settings(
"MNECPP");
283 settings.setValue(m_sSettingsPath + QString(
"/QuickControlView/ViewOpacity"),
getOpacityValue());
284 settings.setValue(m_sSettingsPath + QString(
"/QuickControlView/ViewPos"), this->pos());
291 if(m_sSettingsPath.isEmpty()) {
295 QSettings settings(
"MNECPP");
297 setOpacityValue(settings.value(m_sSettingsPath + QString(
"/QuickControlView/ViewOpacity"), 100).toInt());
299 QPoint pos = settings.value(m_sSettingsPath + QString(
"/QuickControlView/ViewPos"), QPoint(100,100)).toPoint();
301 QRect screenRect = QApplication::primaryScreen()->geometry();
302 if(!screenRect.contains(pos) && QGuiApplication::screens().size() == 1) {
303 move(QPoint(100,100));
314 this->setWindowOpacity(1);
316 this->setWindowOpacity(1/(100.0/value));