Ui::VideoPanelHeader::VideoPanelHeader(QWidget* parent, int items) : MoveablePanel(parent) , _callName(NULL) , _lowWidget(NULL) , _callTime(NULL) , _btnMin(NULL) , _secureCallEnabled(false) , _btnMax(NULL) , _btnClose(NULL) , _callNameSpacer(NULL) , _callTimeSpacer(NULL) , _items_to_show(items) { setProperty("VideoPanelHeader", true); setContentsMargins(0, 0, 0, 0); QHBoxLayout* layout = new QHBoxLayout(); _lowWidget = new QWidget(this); { // low widget. it makes background panel coloured _lowWidget->setContentsMargins(DEFAULT_BORDER, 0, 0, 0); _lowWidget->setProperty("VideoPanelHeader", true); _lowWidget->setLayout(layout); QVBoxLayout* vLayoutParent = new QVBoxLayout(); vLayoutParent->setContentsMargins(0, 0, 0, 0); vLayoutParent->setSpacing(0); vLayoutParent->setAlignment(Qt::AlignVCenter); vLayoutParent->addWidget(_lowWidget); setLayout(vLayoutParent); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); layout->setAlignment(Qt::AlignVCenter); //layout->addSpacing(DEFAULT_BORDER); } auto __addWidget = [] (QWidget* parent) { QWidget* w = new QWidget(parent); w->setContentsMargins(0, 0, 0, 0); w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); if (parent) { parent->layout()->addWidget(w); } return w; }; auto __addLayout = [] (QWidget* w, Qt::Alignment align) { assert(w); if (w) { QHBoxLayout* layout = new QHBoxLayout(); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); layout->setAlignment(align); w->setLayout(layout); } }; QWidget* leftWidg = __addWidget(_lowWidget); QWidget* centerWidg = __addWidget(_lowWidget); QWidget* rightWidg = __addWidget(_lowWidget); __addLayout(leftWidg, Qt::AlignLeft | Qt::AlignVCenter); __addLayout(centerWidg, Qt::AlignCenter); __addLayout(rightWidg, Qt::AlignRight | Qt::AlignVCenter); QFont font = QApplication::font(); font.setStyleStrategy(QFont::PreferAntialias); if (_items_to_show & kVPH_ShowName) { _callName = new NameWidget(leftWidg, Utils::scale_value(15)); _callName->setFont(font); _callName->layout()->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); _callName->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); _callName->setNameProperty("VideoPanelHeaderText", true); leftWidg->layout()->addWidget(_callName); //leftWidg->layout()->addSpacing(DEFAULT_BORDER << 1); } if (_items_to_show & kVPH_ShowTime) { _callTime = new voipTools::BoundBox<PushButton_t>(centerWidg); _callTime->setPostfixColor(QColor(255, 255, 255, 255)); _callTime->setFont(font); _callTime->setEnabled(false); _callTime->setAlignment(Qt::AlignCenter); _callTime->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); _callTime->setFixedWidth(SECURE_BTN_TEXT_W); _callTime->setIconSize(SECURE_BTN_ICON_W, SECURE_BTN_ICON_H); QObject::connect(_callTime, SIGNAL(clicked()), this, SLOT(_onSecureCallClicked()), Qt::QueuedConnection); Utils::ApplyStyle(_callTime, secureCallButton); centerWidg->layout()->addWidget(_callTime); //layout->addSpacing(DEFAULT_BORDER * 3); } QWidget* parentWidget = rightWidg; auto __addButton = [this, parentWidget] (const QString& propertyName, const char* slot)->QPushButton* { QPushButton* btn = new voipTools::BoundBox<QPushButton>(parentWidget); Utils::ApplyStyle(btn, propertyName); btn->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); btn->setCursor(QCursor(Qt::PointingHandCursor)); btn->setFlat(true); parentWidget->layout()->addWidget(btn); connect(btn, SIGNAL(clicked()), this, slot, Qt::QueuedConnection); return btn; }; bool spacerBetweenBtnsAndTimeAdded = false; if (_items_to_show & kVPH_ShowMin) { //if (!spacerBetweenBtnsAndTimeAdded) { // _callTimeSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding); // layout->addSpacerItem(_callTimeSpacer); // spacerBetweenBtnsAndTimeAdded = true; //} _btnMin = __addButton(minButtonStyle, SLOT(_onMinimize())); } if (_items_to_show & kVPH_ShowMax) { //if (!spacerBetweenBtnsAndTimeAdded) { // _callTimeSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding); // layout->addSpacerItem(_callTimeSpacer); // spacerBetweenBtnsAndTimeAdded = true; //} _btnMax = __addButton(maxButtonStyle, SLOT(_onMaximize())); } if (_items_to_show & kVPH_ShowClose) { //if (!spacerBetweenBtnsAndTimeAdded) { // _callTimeSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding); // layout->addSpacerItem(_callTimeSpacer); // spacerBetweenBtnsAndTimeAdded = true; //} _btnClose = __addButton(closeButtonStyle, SLOT(_onClose())); } //if (!spacerBetweenBtnsAndTimeAdded) { // _callTimeSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding); // layout->addSpacerItem(_callTimeSpacer); // spacerBetweenBtnsAndTimeAdded = true; //} }
Ui::VideoPanelHeader::VideoPanelHeader(QWidget* parent, int items) : MoveablePanel(parent) , _callName(NULL) , _lowWidget(NULL) , _callTime(NULL) , _btnMin(NULL) , _btnMax(NULL) , _btnClose(NULL) , _callNameSpacer(NULL) , _callTimeSpacer(NULL) , _items_to_show(items) { setProperty("VideoPanelHeader", true); setContentsMargins(0, 0, 0, 0); setAttribute(Qt::WA_ShowWithoutActivating); QHBoxLayout* layout = new QHBoxLayout(); _lowWidget = new QWidget(this); { // low widget. it makes background panel coloured _lowWidget->setContentsMargins(0, 0, 0, 0); _lowWidget->setProperty("VideoPanelHeader", true); _lowWidget->setLayout(layout); QVBoxLayout* vLayoutParent = new QVBoxLayout(); vLayoutParent->setContentsMargins(0, 0, 0, 0); vLayoutParent->setSpacing(0); vLayoutParent->setAlignment(Qt::AlignVCenter); vLayoutParent->addWidget(_lowWidget); setLayout(vLayoutParent); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); layout->setAlignment(Qt::AlignVCenter); layout->addSpacing(DEFAULT_BORDER); } QFont font = QApplication::font(); font.setStyleStrategy(QFont::PreferAntialias); if (_items_to_show & kVPH_ShowName) { _callName = new NameWidget(_lowWidget, Utils::scale_value(15)); _callName->setFont(font); _callName->layout()->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); _callName->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); _callName->setNameProperty("VideoPanelHeaderText", true); layout->addWidget(_callName); layout->addSpacing(DEFAULT_BORDER << 1); } if (_items_to_show & kVPH_ShowTime) { _callTime = new QLabel(_lowWidget); _callTime->setFont(font); _callTime->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); _callTime->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding)); _callTime->setProperty("VideoPanelHeaderText", true); layout->addWidget(_callTime); layout->addSpacing(DEFAULT_BORDER * 3); } QWidget* parentWidget = _lowWidget; auto __addButton = [this, parentWidget, layout] (const char* propertyName, const char* slot)->QPushButton* { QPushButton* btn = new QPushButton(parentWidget); btn->setProperty(propertyName, true); btn->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); btn->setCursor(QCursor(Qt::PointingHandCursor)); btn->setFlat(true); layout->addWidget(btn); connect(btn, SIGNAL(clicked()), this, slot, Qt::QueuedConnection); return btn; }; bool spacerBetweenBtnsAndTimeAdded = false; if (_items_to_show & kVPH_ShowMin) { if (!spacerBetweenBtnsAndTimeAdded) { _callTimeSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding); layout->addSpacerItem(_callTimeSpacer); spacerBetweenBtnsAndTimeAdded = true; } _btnMin = __addButton("VideoPanelHeaderMin", SLOT(_onMinimize())); } if (_items_to_show & kVPH_ShowMax) { if (!spacerBetweenBtnsAndTimeAdded) { _callTimeSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding); layout->addSpacerItem(_callTimeSpacer); spacerBetweenBtnsAndTimeAdded = true; } _btnMax = __addButton("VideoPanelHeaderMax", SLOT(_onMaximize())); } if (_items_to_show & kVPH_ShowClose) { if (!spacerBetweenBtnsAndTimeAdded) { _callTimeSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding); layout->addSpacerItem(_callTimeSpacer); spacerBetweenBtnsAndTimeAdded = true; } _btnClose = __addButton("VideoPanelHeaderClose", SLOT(_onClose())); } }