Window::Window( QWidget *parent) : QObject(parent) { m_view = new QWebView(); m_page = new WebPage(m_view); m_view->setPage(m_page); m_window = new CustomWindow(m_view); connect(m_page, SIGNAL(javaScriptWindowObjectCleared()),this,SLOT(onInitialized())); connect(m_window,SIGNAL(myCloseEvent()),SIGNAL(_onClose())); }
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; //} }
void NewFromTemplate::_createFromTemplate() { _main_widget.createTemplate(); _onClose(); }
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())); } }
Ui::VideoPanelHeader::VideoPanelHeader(QWidget* _parent, int _items) : MoveablePanel(_parent) , itemsToShow_(_items) , callName_(nullptr) , callTime_(nullptr) , btnMin_(nullptr) , btnClose_(nullptr) , lowWidget_(nullptr) , secureCallEnabled_(false) { #ifdef __linux__ setStyleSheet(Utils::LoadStyle(":/qss/video_panel_linux")); #else setStyleSheet(Utils::LoadStyle(":/qss/video_panel")); #endif setProperty("VideoPanelHeader", true); setContentsMargins(0, 0, 0, 0); QHBoxLayout* layout = Utils::emptyHLayout(); lowWidget_ = new QFrame(this); { // low widget. it makes background panel coloured lowWidget_->setContentsMargins(DEFAULT_BORDER, 0, 0, 0); #ifdef __APPLE__ lowWidget_->setProperty("VideoPanelHeaderMac", true); #else lowWidget_->setProperty("VideoPanelHeader", true); #endif lowWidget_->setLayout(layout); QVBoxLayout* vLayoutParent = Utils::emptyVLayout(); vLayoutParent->setAlignment(Qt::AlignVCenter); vLayoutParent->addWidget(lowWidget_); setLayout(vLayoutParent); 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::Preferred, QSizePolicy::Expanding); return w; }; auto addLayout = [] (QWidget* _w, Qt::Alignment _align) { assert(_w); if (_w) { QHBoxLayout* layout = Utils::emptyHLayout(); layout->setAlignment(_align); _w->setLayout(layout); } }; QWidget* leftWidg = addWidget(lowWidget_); QWidget* centerWidg = addWidget(lowWidget_); QWidget* rightWidg = addWidget(lowWidget_); layout->addWidget(leftWidg, 1); layout->addWidget(centerWidg); layout->addWidget(rightWidg, 1); 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 (itemsToShow_ & kVPH_ShowName) { callName_ = new NameWidget(leftWidg, Utils::scale_value(18)); callName_->setFont(font); callName_->layout()->setAlignment(Qt::AlignVCenter | Qt::AlignLeft); callName_->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding)); callName_->setNameProperty("VideoPanelHeaderText", true); leftWidg->layout()->addWidget(callName_); } if (itemsToShow_ & kVPH_ShowTime) { callTime_ = new voipTools::BoundBox<PushButton_t>(centerWidg); callTime_->setPostfixColor(CommonStyle::getColor(CommonStyle::Color::TEXT_PRIMARY)); 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_); } 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; }; if (itemsToShow_ & kVPH_ShowMin) { btnMin_ = addButton(CommonStyle::getMinimizeButtonStyle(), SLOT(_onMinimize())); } if (itemsToShow_ & kVPH_ShowClose) { btnClose_ = addButton(CommonStyle::getCloseButtonStyle(), SLOT(_onClose())); } }