void DX11Widget::paintEvent(QPaintEvent */*e*/) { D_D(DX11Widget); int glowRadius = d->m_ShadowWidth; int radius = d->m_Radius; QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); QRect rect = this->rect().marginsRemoved(QMargins(glowRadius, glowRadius, glowRadius, glowRadius)); if (! d->m_Background.isNull()) { painter.drawPixmap(rect, d->m_Background); } else { QPoint topLeft(rect.x(), rect.y()); QPoint bottomRight(rect.x() + rect.width(), rect.y() + rect.height()); QPainterPath border; border.addRoundedRect(rect, radius, radius); QLinearGradient linearGradient(topLeft, QPoint(topLeft.x(), bottomRight.y())); linearGradient.setColorAt(0.0, BackgroundTopColor); linearGradient.setColorAt(0.2, BackgroundBottonColor); linearGradient.setColorAt(1.0, BackgroundBottonColor); QPen borderPen(BorderColor); painter.setBrush(QBrush(linearGradient)); painter.strokePath(border, borderPen); painter.fillPath(border, palette().background()); } }
void DX11Widget::mouseMoveEvent(QMouseEvent *event) { D_D(DX11Widget); if (true == d->leftPressed) { XUtils::MoveWindow(this); } return QWidget::mouseMoveEvent(event); }
void DOption::resizeEvent(QResizeEvent *e) { QWidget::resizeEvent(e); D_D(DOption); d->sizeChanged(e); }
void DX11Widget::setRadius(int r) { D_D(DX11Widget); if (r > d->m_Border * 2) { r = d->m_Border * 2; } d->m_Radius = r; }
void DX11Widget::resizeEvent(QResizeEvent *e) { D_D(DX11Widget); if (!d->resizable) { return; } QWidget::resizeEvent(e); }
void DX11Widget::setLayout(QLayout *l) { D_D(DX11Widget); qDeleteAll(d->contentWidget->children()); d->contentWidget->setLayout(l); d->contentWidget->adjustSize(); DX11Widget::resize(d->contentWidget->size()); }
void DX11Widget::showMaximized() { D_D(DX11Widget); d->m_ShadowWidth = 0; XUtils::ShowMaximizedWindow(this); this->show(); this->activateWindow(); this->raise(); }
void DX11Widget::setBorder(int b) { D_D(DX11Widget); if (b < 0) { b = 0; } d->m_Border = b; if (d->m_Radius > b * 2) { d->m_Radius = b * 2; } }
void DX11Widget::setShadow() { D_D(DX11Widget); d->m_Shadow = new DGraphicsGlowEffect(this); d->m_Shadow->setOffset(0, 0); d->m_Shadow->setBlurRadius(d->m_ShadowWidth); this->setGraphicsEffect(d->m_Shadow); }
void DX11Widget::mousePressEvent(QMouseEvent *event) { D_D(DX11Widget); d->leftPressed = true; if (event->button() == Qt::LeftButton && d->resizable) { XUtils::MoveResizeWindow(this, event->x(), event->y(), 4); } return QWidget::mousePressEvent(event); }
void DX11Widget::showFullScreen() { D_D(DX11Widget); d->m_ShadowWidth = 0; XUtils::ShowFullscreenWindow(this, true); this->show(); this->activateWindow(); this->raise(); }
DOption::DOption(QWidget *parent) : QFrame(parent), DObject(*new DOptionPrivate(this)) { D_THEME_INIT_WIDGET(DOption, checked) D_D(DOption); d->init(); }
void DSpinBox::setDefaultValue(int defaultValue) { D_D(DSpinBox); if (d->defaultValue == defaultValue) return; d->defaultValue = defaultValue; emit defaultValueChanged(defaultValue); }
void DDoubleSpinBox::setAlert(bool alert) { D_D(DDoubleSpinBox); if(alert == d->alert) return; d->alert = alert; emit alertChanged(alert); }
void DDoubleSpinBox::setDefaultValue(double defaultValue) { D_D(DDoubleSpinBox); if (d->defaultValue == defaultValue) return; d->defaultValue = defaultValue; emit defaultValueChanged(defaultValue); }
void DX11Widget::resize(const QSize &size) { D_D(DX11Widget); d->contentWidget->resize(size); QSize externSize = d->externSize(size); if (d->resizable) { QWidget::setMinimumSize(externSize); QWidget::resize(externSize); } else { QWidget::setMaximumSize(externSize); } }
DAction *DMenu::addMenu(DMenu *menu) { D_D(DMenu); DAction *action = new DAction(this); menu->d_func()->parent = this; action->setMenu(menu); d->menuActions << action; return action; }
DAction *DMenu::actionAt(const QString &text) { D_D(DMenu); for (DAction *action : d->menuActions) { if (action->text() == text) { return action; } } return Q_NULLPTR; }
void DX11Widget::setFixedSize(const QSize &size) { D_D(DX11Widget); d->resizable = false; d->titlebar->setMinimumWidth(size.width() + d->m_Border * 2); d->contentWidget->setFixedSize(size); QSize externSize = d->externSize(size); QWidget::resize(externSize); QWidget::setMaximumSize(externSize); setWindowFlags(windowFlags() & ~ Qt::WindowMaximizeButtonHint); XUtils::DisableResize(this); }
void DX11Widget::adjustSize() { D_D(DX11Widget); d->contentWidget->adjustSize(); QSize externSize = d->externSize(d->contentWidget->size()); if (d->resizable) { QWidget::setMinimumSize(externSize); QWidget::resize(externSize); } else { QWidget::setMaximumSize(externSize); QWidget::resize(externSize); } }
DAction *DMenu::exec(const QPoint &p, DAction *action) { D_D(DMenu); if(!d->eventLoop && popup(p, action)) { d->eventLoop = new QEventLoop(this); d->eventLoop->exec(QEventLoop::DialogExec); d->eventLoop->deleteLater(); d->eventLoop = Q_NULLPTR; return d->lastTriggerAction; } return Q_NULLPTR; }
DMenu::DMenu(QObject *parent) : QObject(parent) , DObject(* new DMenuPrivate(this)) { D_D(DMenu); d->menuManager = new MenumanagerInterface(MenuManager_service, MenuManager_path, QDBusConnection::sessionBus(), this); d->menuInterface = Q_NULLPTR; d->menuVariant["x"] = 0; d->menuVariant["y"] = 0; d->menuVariant["isDockMenu"] = false; d->menuVariant["menuJsonContent"] = ""; }
DX11Widget::DX11Widget(DObjectPrivate &dd, QWidget *parent) : QWidget(parent), DObject(dd) { D_D(DX11Widget); d->init(); QWidget::setLayout(d->rootLayout); QWidget::setAttribute(Qt::WA_TranslucentBackground, true); QWidget::setWindowFlags(Qt::Window | Qt::FramelessWindowHint); setWindowFlags(windowFlags()); // resize(size()); setShadow(); XUtils::SetWindowExtents(this, WindowGlowRadius); DX11Widget::adjustSize(); }
bool DMenu::popup(const QPoint &pos, DAction */*action*/) { D_D(DMenu); if (d->parent) { qWarning() << "Only top DMenu can be show"; return false; } if (d->menuInterface) { qWarning() << "Another menu is active"; return false; } d->menuVariant["x"] = pos.x(); d->menuVariant["y"] = pos.y(); QVariantMap content = d->toVariantMap(); QJsonDocument jsonDoc = QJsonDocument::fromVariant(content); auto menuStr = jsonDoc.toJson(); QDBusPendingReply<QDBusObjectPath> reply = d->menuManager->RegisterMenu(); reply.waitForFinished(); if (reply.isError()) { qDebug() << "Call deepin-menu dbus failed: " << reply.error(); } QString menuPath = reply.value().path(); d->menuInterface = new MenuInterface(MenuManager_service, menuPath, QDBusConnection::sessionBus(), this); d->menuInterface->ShowMenu(menuStr); connect(d->menuInterface, SIGNAL(MenuUnregistered()), this, SLOT(_q_onMenuUnregistered())); connect(d->menuInterface, SIGNAL(ItemInvoked(QString,bool)), this, SLOT(_q_onItemInvoked(QString,bool))); return true; }
void DX11Widget::setTitleIcon(const QPixmap &icon) { D_D(DX11Widget); d->titlebar->setIcon(icon); }
void DX11Widget::setTitlebarWidget(QWidget *w, bool fixCenterPos) { D_D(DX11Widget); d->titlebar->setCustomWidget(w, Qt::AlignCenter, fixCenterPos); }
void DX11Widget::showEvent(QShowEvent *e) { D_D(DX11Widget); QWidget::showEvent(e); }
void DX11Widget::setTitlebarMenu(DMenu *menu) { D_D(DX11Widget); d->titlebar->setMenu(menu); }
void DX11Widget::setBackgroundImage(const QPixmap &bk) { D_D(DX11Widget); d->m_Background = bk; }
void DX11Widget::setShadowWidth(int r) { D_D(DX11Widget); d->m_Radius = r; }