feat: DockPopupWindow改用DBlurEffectWidget实现

DockPopupWindow改为使用DBlurEffectWidget来实现新的设计,以及摆脱原来DArrowRectangle出现的侧边任务栏PopupWindow圆角显示不对称的问题.

Log: DockPopupWindow改用DBlurEffectWidget实现

Signed-off-by: Yutao Meng <mengyutao@uniontech.com>
This commit is contained in:
Yutao Meng 2023-04-07 14:43:09 +08:00 committed by deepin-bot[bot]
parent 6242e642bc
commit ec5c447264
13 changed files with 107 additions and 181 deletions

View File

@ -32,12 +32,6 @@ AppDragWidget::AppDragWidget(QWidget *parent)
, m_item(nullptr)
, m_dockScreen(nullptr)
{
m_popupWindow->setShadowBlurRadius(20);
m_popupWindow->setRadius(18);
m_popupWindow->setShadowYOffset(2);
m_popupWindow->setShadowXOffset(0);
m_popupWindow->setArrowWidth(18);
m_popupWindow->setArrowHeight(10);
m_popupWindow->setRadius(18);
m_scene->addItem(m_object.get());

View File

@ -31,19 +31,14 @@ DockItem::DockItem(QWidget *parent)
, m_popupAdjustDelayTimer(new QTimer(this))
{
if (PopupWindow.isNull()) {
DockPopupWindow *arrowRectangle = new DockPopupWindow(nullptr);
arrowRectangle->setShadowBlurRadius(20);
arrowRectangle->setRadius(18);
arrowRectangle->setShadowYOffset(2);
arrowRectangle->setShadowXOffset(0);
arrowRectangle->setArrowWidth(18);
arrowRectangle->setArrowHeight(10);
arrowRectangle->setObjectName("apppopup");
DockPopupWindow *blurRectangle = new DockPopupWindow(nullptr);
blurRectangle->setRadius(18);
blurRectangle->setObjectName("apppopup");
if (Utils::IS_WAYLAND_DISPLAY) {
Qt::WindowFlags flags = arrowRectangle->windowFlags() | Qt::FramelessWindowHint;
arrowRectangle->setWindowFlags(flags);
Qt::WindowFlags flags = blurRectangle->windowFlags() | Qt::FramelessWindowHint;
blurRectangle->setWindowFlags(flags);
}
PopupWindow = arrowRectangle;
PopupWindow = blurRectangle;
connect(qApp, &QApplication::aboutToQuit, PopupWindow, &DockPopupWindow::deleteLater);
}
@ -271,9 +266,9 @@ void DockItem::showHoverTips()
void DockItem::showPopupWindow(QWidget *const content, const bool model)
{
if(itemType() == App){
if (itemType() == App) {
PopupWindow->setRadius(18);
}else {
} else {
PopupWindow->setRadius(6);
}
@ -288,13 +283,8 @@ void DockItem::showPopupWindow(QWidget *const content, const bool model)
if (lastContent)
lastContent->setVisible(false);
switch (DockPosition) {
case Top: popup->setArrowDirection(DockPopupWindow::ArrowTop); break;
case Bottom: popup->setArrowDirection(DockPopupWindow::ArrowBottom); break;
case Left: popup->setArrowDirection(DockPopupWindow::ArrowLeft); break;
case Right: popup->setArrowDirection(DockPopupWindow::ArrowRight); break;
}
popup->resize(content->sizeHint());
popup->setPosition(DockPosition);
popup->setContent(content);
const QPoint p = popupMarkPoint();
@ -359,16 +349,16 @@ const QPoint DockItem::popupMarkPoint()
const QRect r = rect();
switch (DockPosition) {
case Top:
p += QPoint(r.width() / 2, r.height());
p += QPoint(r.width() / 2, r.height() + POPUP_PADDING);
break;
case Bottom:
p += QPoint(r.width() / 2, 0);
p += QPoint(r.width() / 2, -POPUP_PADDING);
break;
case Left:
p += QPoint(r.width(), r.height() / 2);
p += QPoint(r.width() + POPUP_PADDING, r.height() / 2);
break;
case Right:
p += QPoint(0, r.height() / 2);
p += QPoint(-POPUP_PADDING, r.height() / 2);
break;
}
return p;

View File

@ -19,18 +19,17 @@
DWIDGET_USE_NAMESPACE
DockPopupWindow::DockPopupWindow(QWidget *parent)
: DArrowRectangle(ArrowBottom, parent)
: DBlurEffectWidget(parent)
, m_model(false)
, m_eventMonitor(new XEventMonitor(xEventMonitorService, xEventMonitorPath, QDBusConnection::sessionBus(), this))
, m_enableMouseRelease(true)
, m_extendWidget(nullptr)
, m_lastWidget(nullptr)
{
setMargin(0);
setContentsMargins(0, 0, 0, 0);
m_wmHelper = DWindowManagerHelper::instance();
compositeChanged();
setWindowFlags(Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint | Qt::WindowDoesNotAcceptFocus);
setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
if (Utils::IS_WAYLAND_DISPLAY) {
setAttribute(Qt::WA_NativeWindow);
windowHandle()->setProperty("_d_dwayland_window-type", "override");
@ -38,7 +37,6 @@ DockPopupWindow::DockPopupWindow(QWidget *parent)
setAttribute(Qt::WA_InputMethodEnabled, false);
}
connect(m_wmHelper, &DWindowManagerHelper::hasCompositeChanged, this, &DockPopupWindow::compositeChanged);
connect(m_eventMonitor, &XEventMonitor::ButtonPress, this, &DockPopupWindow::onButtonPress);
if (Utils::IS_WAYLAND_DISPLAY)
@ -54,11 +52,15 @@ bool DockPopupWindow::model() const
return isVisible() && m_model;
}
QWidget *DockPopupWindow::getContent()
{
return m_lastWidget;
}
void DockPopupWindow::setContent(QWidget *content)
{
QWidget *lastWidget = getContent();
if (lastWidget)
lastWidget->removeEventFilter(this);
if (m_lastWidget)
m_lastWidget->removeEventFilter(this);
content->installEventFilter(this);
QAccessibleEvent event(this, QAccessible::NameChanged);
@ -67,7 +69,10 @@ void DockPopupWindow::setContent(QWidget *content)
if (!content->objectName().trimmed().isEmpty())
setAccessibleName(content->objectName() + "-popup");
DArrowRectangle::setContent(content);
m_lastWidget = content;
content->setParent(this);
content->show();
resize(content->sizeHint());
}
void DockPopupWindow::setExtendWidget(QWidget *widget)
@ -76,7 +81,12 @@ void DockPopupWindow::setExtendWidget(QWidget *widget)
connect(widget, &QWidget::destroyed, this, [ this ] { m_extendWidget = nullptr; }, Qt::UniqueConnection);
}
QWidget *DockPopupWindow::extengWidget() const
void DockPopupWindow::setPosition(Dock::Position position)
{
m_position = position;
}
QWidget *DockPopupWindow::extendWidget() const
{
return m_extendWidget;
}
@ -84,8 +94,6 @@ QWidget *DockPopupWindow::extengWidget() const
void DockPopupWindow::show(const QPoint &pos, const bool model)
{
m_model = model;
m_lastPoint = pos;
show(pos.x(), pos.y());
if (!m_eventKey.isEmpty()) {
@ -102,10 +110,26 @@ void DockPopupWindow::show(const QPoint &pos, const bool model)
void DockPopupWindow::show(const int x, const int y)
{
QPoint displayPoint;
m_lastPoint = QPoint(x, y);
switch (m_position) {
case Dock::Position::Left:
displayPoint = m_lastPoint + QPoint(0, -m_lastWidget->height() / 2);
break;
case Dock::Position::Right:
displayPoint = m_lastPoint + QPoint(-m_lastWidget->width(), -m_lastWidget->height() / 2);
break;
case Dock::Position::Top:
displayPoint = m_lastPoint + QPoint(-m_lastWidget->width() / 2, 0);
break;
case Dock::Position::Bottom:
displayPoint = m_lastPoint + QPoint(-m_lastWidget->width() / 2, -m_lastWidget->height());
break;
}
blockButtonRelease();
DArrowRectangle::show(x, y);
move(displayPoint);
resize(m_lastWidget->size());
DBlurEffectWidget::show();
}
void DockPopupWindow::blockButtonRelease()
@ -124,12 +148,12 @@ void DockPopupWindow::hide()
m_eventKey.clear();
}
DArrowRectangle::hide();
DBlurEffectWidget::hide();
}
void DockPopupWindow::showEvent(QShowEvent *e)
{
DArrowRectangle::showEvent(e);
DBlurEffectWidget::showEvent(e);
if (Utils::IS_WAYLAND_DISPLAY) {
Utils::updateCursor(this);
}
@ -140,12 +164,12 @@ void DockPopupWindow::showEvent(QShowEvent *e)
void DockPopupWindow::hideEvent(QHideEvent *event)
{
m_extendWidget = nullptr;
Dtk::Widget::DArrowRectangle::hideEvent(event);
Dtk::Widget::DBlurEffectWidget::hideEvent(event);
}
void DockPopupWindow::enterEvent(QEvent *e)
{
DArrowRectangle::enterEvent(e);
DBlurEffectWidget::enterEvent(e);
if (Utils::IS_WAYLAND_DISPLAY) {
Utils::updateCursor(this);
}
@ -181,14 +205,6 @@ bool DockPopupWindow::eventFilter(QObject *o, QEvent *e)
return false;
}
void DockPopupWindow::compositeChanged()
{
if (m_wmHelper->hasComposite())
setBorderColor(QColor(255, 255, 255, 255 * 0.05));
else
setBorderColor(QColor("#2C3238"));
}
void DockPopupWindow::ensureRaised()
{
if (isVisible())

View File

@ -7,17 +7,22 @@
#define DOCKPOPUPWINDOW_H
#include "org_deepin_dde_xeventmonitor1.h"
#include "constants.h"
#include <darrowrectangle.h>
#include <DBlurEffectWidget>
#include <dregionmonitor.h>
#include <DWindowManagerHelper>
#include <QVBoxLayout>
#include <QPainter>
#include <QMouseEvent>
DWIDGET_USE_NAMESPACE
DGUI_USE_NAMESPACE
using XEventMonitor = org::deepin::dde::XEventMonitor1;
class DockPopupWindow : public Dtk::Widget::DArrowRectangle
class DockPopupWindow : public Dtk::Widget::DBlurEffectWidget
{
Q_OBJECT
@ -27,9 +32,11 @@ public:
bool model() const;
QWidget *getContent();
void setContent(QWidget *content);
void setExtendWidget(QWidget *widget);
QWidget *extengWidget() const;
void setPosition(Dock::Position position);
QWidget *extendWidget() const;
public slots:
void show(const QPoint &pos, const bool model = false);
@ -52,19 +59,20 @@ protected:
void blockButtonRelease();
private slots:
void compositeChanged();
void ensureRaised();
void onButtonPress(int type, int x, int y, const QString &key);
private:
bool m_model;
QPoint m_lastPoint;
Dock::Position m_position;
XEventMonitor *m_eventMonitor;
QString m_eventKey;
DWindowManagerHelper *m_wmHelper;
bool m_enableMouseRelease;
QWidget *m_extendWidget;
QPointer<QWidget> m_lastWidget;
};
class PopupSwitchWidget : public QWidget

View File

@ -18,6 +18,7 @@
#include <QFont>
#include <QMenu>
#include <QPainterPath>
#include <QMouseEvent>
DWIDGET_USE_NAMESPACE
DGUI_USE_NAMESPACE
@ -84,32 +85,19 @@ void DateTimeDisplayer::setOneRow(bool oneRow)
void DateTimeDisplayer::updatePolicy()
{
switch (m_position) {
case Dock::Position::Top: {
switch(m_position) {
case Dock::Position::Top:
case Dock::Position::Bottom:
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
m_tipPopupWindow->setArrowDirection(DArrowRectangle::ArrowDirection::ArrowTop);
m_tipPopupWindow->setContent(m_tipsWidget);
break;
}
case Dock::Position::Bottom: {
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
m_tipPopupWindow->setArrowDirection(DArrowRectangle::ArrowDirection::ArrowBottom);
m_tipPopupWindow->setContent(m_tipsWidget);
break;
}
case Dock::Position::Left: {
case Dock::Position::Left:
case Dock::Position::Right:
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_tipPopupWindow->setArrowDirection(DArrowRectangle::ArrowDirection::ArrowLeft);
m_tipPopupWindow->setContent(m_tipsWidget);
break;
}
case Dock::Position::Right: {
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_tipPopupWindow->setArrowDirection(DArrowRectangle::ArrowDirection::ArrowRight);
m_tipPopupWindow->setContent(m_tipsWidget);
break;
}
}
m_tipPopupWindow->setPosition(m_position);
m_tipPopupWindow->setContent(m_tipsWidget);
}
QSize DateTimeDisplayer::suitableSize() const
@ -296,15 +284,15 @@ void DateTimeDisplayer::paintEvent(QPaintEvent *e)
QPoint DateTimeDisplayer::tipsPoint() const
{
QPoint pointInTopWidget = parentWidget()->mapTo(topLevelWidget(), pos());
QPoint pointInTopWidget = parentWidget()->mapTo(window(), pos());
switch (m_position) {
case Dock::Position::Left: {
pointInTopWidget.setX(topLevelWidget()->x() + topLevelWidget()->width());
pointInTopWidget.setX(window()->x() + window()->width());
pointInTopWidget.setY(pointInTopWidget.y() + height() / 2);
break;
}
case Dock::Position::Top: {
pointInTopWidget.setY(y() + topLevelWidget()->y() + topLevelWidget()->height());
pointInTopWidget.setY(y() + window()->y() + window()->height());
pointInTopWidget.setX(pointInTopWidget.x() + width() / 2);
break;
}
@ -314,12 +302,12 @@ QPoint DateTimeDisplayer::tipsPoint() const
break;
}
case Dock::Position::Bottom: {
pointInTopWidget.setY(0);
pointInTopWidget.setY(-POPUP_PADDING);
pointInTopWidget.setX(pointInTopWidget.x() + width() / 2);
break;
}
}
return topLevelWidget()->mapToGlobal(pointInTopWidget);
return window()->mapToGlobal(pointInTopWidget);
}
QFont DateTimeDisplayer::timeFont() const

View File

@ -20,6 +20,7 @@
#include <QBoxLayout>
#include <QLabel>
#include <QPainter>
#define FRONTSPACING 18
#define SPLITERSIZE 2

View File

@ -124,20 +124,7 @@ void QuickPluginWindow::setPositon(Position position)
} else {
m_mainLayout->setDirection(QBoxLayout::BottomToTop);
}
switch(m_position) {
case Dock::Position::Top:
getPopWindow()->setArrowDirection(DArrowRectangle::ArrowDirection::ArrowTop);
break;
case Dock::Position::Right:
getPopWindow()->setArrowDirection(DArrowRectangle::ArrowDirection::ArrowRight);
break;
case Dock::Position::Bottom:
getPopWindow()->setArrowDirection(DArrowRectangle::ArrowDirection::ArrowBottom);
break;
case Dock::Position::Left:
getPopWindow()->setArrowDirection(DArrowRectangle::ArrowDirection::ArrowLeft);
break;
}
getPopWindow()->setPosition(m_position);
}
void QuickPluginWindow::dragPlugin(PluginsItemInterface *item)
@ -368,7 +355,7 @@ void QuickPluginWindow::onRequestUpdate()
DockPopupWindow *popupWindow = getPopWindow();
if (popupWindow->isVisible()) {
// 该插件被移除的情况下,判断弹出窗口是否在当前的插件中打开的,如果是,则隐藏该窗口
if (popupWindow->extengWidget() == dockItem)
if (popupWindow->extendWidget() == dockItem)
popupWindow->hide();
}
// 如果该插件不在任务栏上,则先删除
@ -413,24 +400,24 @@ QPoint QuickPluginWindow::popupPoint(QWidget *widget) const
case Dock::Position::Bottom: {
// 在下方的时候Y坐标设置在顶层窗口的y值保证下方对齐
pointCurrent.setX(pointCurrent.x() + itemWidget->width() / 2);
pointCurrent.setY(topLevelWidget()->y());
pointCurrent.setY(topLevelWidget()->y() - POPUP_PADDING);
break;
}
case Dock::Position::Top: {
// 在上面的时候Y坐标设置为任务栏的下方保证上方对齐
pointCurrent.setX(pointCurrent.x() + itemWidget->width() / 2);
pointCurrent.setY(topLevelWidget()->y() + topLevelWidget()->height());
pointCurrent.setY(topLevelWidget()->y() + topLevelWidget()->height() + POPUP_PADDING);
break;
}
case Dock::Position::Left: {
// 在左边的时候X坐标设置在顶层窗口的最右侧保证左对齐
pointCurrent.setX(topLevelWidget()->x() + topLevelWidget()->width());
pointCurrent.setX(topLevelWidget()->x() + topLevelWidget()->width() + POPUP_PADDING);
pointCurrent.setY(pointCurrent.y() + itemWidget->height() / 2);
break;
}
case Dock::Position::Right: {
// 在右边的时候X坐标设置在顶层窗口的最左侧保证右对齐
pointCurrent.setX(topLevelWidget()->x());
pointCurrent.setX(topLevelWidget()->x() - POPUP_PADDING);
pointCurrent.setY(pointCurrent.y() + itemWidget->height() / 2);
}
}
@ -579,23 +566,6 @@ QList<QuickDockItem *> QuickPluginWindow::quickDockItems()
return dockItems;
}
// 根据位置获取箭头的方向
static DArrowRectangle::ArrowDirection getDirection(const Dock::Position &position)
{
switch (position) {
case Dock::Position::Top:
return DArrowRectangle::ArrowDirection::ArrowTop;
case Dock::Position::Left:
return DArrowRectangle::ArrowDirection::ArrowLeft;
case Dock::Position::Right:
return DArrowRectangle::ArrowDirection::ArrowRight;
default:
return DArrowRectangle::ArrowDirection::ArrowBottom;
}
return DArrowRectangle::ArrowDirection::ArrowBottom;
}
DockPopupWindow *QuickPluginWindow::getPopWindow() const
{
static DockPopupWindow *popWindow = nullptr;
@ -603,13 +573,8 @@ DockPopupWindow *QuickPluginWindow::getPopWindow() const
return popWindow;
popWindow = new DockPopupWindow;
popWindow->setShadowBlurRadius(20);
popWindow->setRadius(18);
popWindow->setShadowYOffset(2);
popWindow->setShadowXOffset(0);
popWindow->setArrowWidth(18);
popWindow->setArrowHeight(10);
popWindow->setArrowDirection(getDirection(m_position));
popWindow->setPosition(m_position);
popWindow->setWindowFlags(Qt::FramelessWindowHint | Qt::Tool);
PopupSwitchWidget *content = new PopupSwitchWidget(popWindow);
popWindow->setContent(content);
@ -902,21 +867,7 @@ void QuickDockItem::enterEvent(QEvent *event)
if (tipWidget->parentWidget() != m_popupWindow)
m_tipParent = tipWidget->parentWidget();
switch (m_position) {
case Top:
m_popupWindow->setArrowDirection(DockPopupWindow::ArrowTop);
break;
case Bottom:
m_popupWindow->setArrowDirection(DockPopupWindow::ArrowBottom);
break;
case Left:
m_popupWindow->setArrowDirection(DockPopupWindow::ArrowLeft);
break;
case Right:
m_popupWindow->setArrowDirection(DockPopupWindow::ArrowRight);
break;
}
m_popupWindow->setPosition(m_position);
m_popupWindow->resize(tipWidget->sizeHint());
m_popupWindow->setContent(tipWidget);
@ -1013,12 +964,7 @@ void QuickDockItem::initUi()
void QuickDockItem::initAttribute()
{
m_popupWindow->setShadowBlurRadius(20);
m_popupWindow->setRadius(6);
m_popupWindow->setShadowYOffset(2);
m_popupWindow->setShadowXOffset(0);
m_popupWindow->setArrowWidth(18);
m_popupWindow->setArrowHeight(10);
m_popupWindow->setObjectName("quickitempopup");
if (Utils::IS_WAYLAND_DISPLAY) {
Qt::WindowFlags flags = m_popupWindow->windowFlags() | Qt::FramelessWindowHint;
@ -1103,16 +1049,16 @@ QPoint QuickDockItem::popupMarkPoint() const
const QRect r = rect();
switch (m_position) {
case Top:
p += QPoint(r.width() / 2, r.height());
p += QPoint(r.width() / 2, r.height() + POPUP_PADDING);
break;
case Bottom:
p += QPoint(r.width() / 2, 0);
p += QPoint(r.width() / 2, -POPUP_PADDING);
break;
case Left:
p += QPoint(r.width(), r.height() / 2);
p += QPoint(r.width() + POPUP_PADDING, r.height() / 2);
break;
case Right:
p += QPoint(0, r.height() / 2);
p += QPoint(-POPUP_PADDING, r.height() / 2);
break;
}
return p;

View File

@ -15,6 +15,7 @@
#include <QDir>
#include <QMetaObject>
#include <QGuiApplication>
#include <QPainter>
#define MAXICONSIZE 48
#define MINICONSIZE 24

View File

@ -25,6 +25,7 @@
#include <QKeyEvent>
#include <QApplication>
#include <QPainterPath>
#include <QPainter>
#include <xcb/xcb_icccm.h>
#include <X11/Xlib.h>

View File

@ -17,6 +17,7 @@
#include <QDBusPendingCall>
#include <QtConcurrent>
#include <QFuture>
#include <QMouseEvent>
#include <xcb/xproto.h>
@ -54,12 +55,7 @@ SNITrayItemWidget::SNITrayItemWidget(const QString &sniServicePath, QWidget *par
if (PopupWindow.isNull()) {
DockPopupWindow *arrowRectangle = new DockPopupWindow(nullptr);
arrowRectangle->setShadowBlurRadius(20);
arrowRectangle->setRadius(6);
arrowRectangle->setShadowYOffset(2);
arrowRectangle->setShadowXOffset(0);
arrowRectangle->setArrowWidth(18);
arrowRectangle->setArrowHeight(10);
arrowRectangle->setObjectName("snitraypopup");
PopupWindow = arrowRectangle;
if (Utils::IS_WAYLAND_DISPLAY)
@ -757,12 +753,7 @@ void SNITrayItemWidget::showPopupWindow(QWidget *const content, const bool model
if (lastContent)
lastContent->setVisible(false);
switch (DockPosition) {
case Dock::Position::Top: popup->setArrowDirection(DockPopupWindow::ArrowTop); break;
case Dock::Position::Bottom: popup->setArrowDirection(DockPopupWindow::ArrowBottom); break;
case Dock::Position::Left: popup->setArrowDirection(DockPopupWindow::ArrowLeft); break;
case Dock::Position::Right: popup->setArrowDirection(DockPopupWindow::ArrowRight); break;
}
popup->setPosition(DockPosition);
popup->resize(content->sizeHint());
popup->setContent(content);

View File

@ -50,12 +50,7 @@ SystemPluginItem::SystemPluginItem(PluginsItemInterface *const pluginInter, cons
if (PopupWindow.isNull()) {
DockPopupWindow *arrowRectangle = new DockPopupWindow(nullptr);
arrowRectangle->setShadowBlurRadius(20);
arrowRectangle->setRadius(6);
arrowRectangle->setShadowYOffset(2);
arrowRectangle->setShadowXOffset(0);
arrowRectangle->setArrowWidth(18);
arrowRectangle->setArrowHeight(10);
arrowRectangle->setObjectName("systemtraypopup");
if (Utils::IS_WAYLAND_DISPLAY) {
Qt::WindowFlags flags = arrowRectangle->windowFlags() | Qt::FramelessWindowHint;
@ -428,12 +423,7 @@ void SystemPluginItem::showPopupWindow(QWidget *const content, const bool model)
if (lastContent)
lastContent->setVisible(false);
switch (DockPosition) {
case Dock::Position::Top: popup->setArrowDirection(DockPopupWindow::ArrowTop); break;
case Dock::Position::Bottom: popup->setArrowDirection(DockPopupWindow::ArrowBottom); break;
case Dock::Position::Left: popup->setArrowDirection(DockPopupWindow::ArrowLeft); break;
case Dock::Position::Right: popup->setArrowDirection(DockPopupWindow::ArrowRight); break;
}
popup->setPosition(DockPosition);
popup->resize(content->sizeHint());
popup->setContent(content);

View File

@ -89,6 +89,7 @@ enum class AniAction {
};
#define IS_TOUCH_STATE "isTouchState"
#define POPUP_PADDING 10
}

View File

@ -82,7 +82,7 @@ bool SoundDevicesWidget::eventFilter(QObject *watcher, QEvent *event)
void SoundDevicesWidget::initUi()
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins(10, 0, 10, 0);
layout->setSpacing(6);
m_sliderParent->setFixedHeight(SLIDERHEIGHT);
@ -103,7 +103,7 @@ void SoundDevicesWidget::initUi()
sliderLayout->addWidget(m_sliderContainer);
QHBoxLayout *topLayout = new QHBoxLayout(this);
topLayout->setContentsMargins(10, 0, 10, 0);
topLayout->setContentsMargins(0, 0, 0, 0);
topLayout->setSpacing(0);
topLayout->addWidget(m_sliderParent);
@ -238,20 +238,19 @@ void SoundDevicesWidget::startRemovePort(const QString &portId, const uint &card
void SoundDevicesWidget::addPort(const SoundDevicePort *port)
{
DStandardItem *portItem = new DStandardItem;
QString deviceName = port->name() + "(" + port->cardName() + ")";
QString deviceName = port->name();
portItem->setIcon(QIcon(soundIconFile()));
portItem->setText(deviceName);
portItem->setTextColorRole(QPalette::BrightText);
portItem->setData(QVariant::fromValue<const SoundDevicePort *>(port), DeviceObjRole);
portItem->setData(AUDIOPORT, ItemTypeRole);
portItem->setToolTip(port->cardName());
connect(port, &SoundDevicePort::nameChanged, this, [ = ](const QString &str) {
QString devName = str + "(" + port->cardName() + ")";
portItem->setText(devName);
portItem->setText(str);
});
connect(port, &SoundDevicePort::cardNameChanged, this, [ = ](const QString &str) {
QString devName = port->name() + "(" + str + ")";
portItem->setText(devName);
portItem->setToolTip(str);
});
connect(port, &SoundDevicePort::isActiveChanged, this, [ = ](bool isActive) {
portItem->setCheckState(isActive ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);