Fix #127037,解决音乐音量控件位置显示和窗口显示问题

This commit is contained in:
yushuoqi 2022-07-18 11:19:51 +08:00
parent 712662b1c7
commit 5dc9e83123
4 changed files with 26 additions and 35 deletions

View File

@ -667,7 +667,7 @@ void Widget::initAllComponent()
this->resize(960,640);
this->setLayout(mainHBoxLayout);
historyListTable = new TableHistory(this);
historyListTable = new TableHistory((QWidget *)parent());
if (Global::isWayland) {
kdk::UkuiStyleHelper::self()->removeHeader(this);

View File

@ -34,18 +34,14 @@ void PlaySongArea::initWidget()
playBtn = new QPushButton(this);
playBtn->setFixedSize(36,36);
playBtn->setCursor(Qt::PointingHandCursor);
// playBtn->setToolTip("播放");
// playBtn->setToolTip(tr("play"));
nextBtn = new QPushButton;
nextBtn->setFixedSize(18,18);
nextBtn->setCursor(Qt::PointingHandCursor);
// nextBtn->setToolTip("下一首");
nextBtn->setToolTip(tr("Next"));
volumeBtn = new QPushButton(this);
volumeBtn->setFixedSize(36, 36);
volumeBtn->setCursor(Qt::PointingHandCursor);
volumeBtn->setToolTip(tr("Volume")); //音量
int volume = playController::getInstance().getVolume();
if(volume == 0)
@ -77,7 +73,7 @@ void PlaySongArea::initWidget()
volumeBtn->setFlat(true);
}
m_volSliderWid = new SliderWidget(this);
m_volSliderWid = new SliderWidget((QWidget *)parent());
if (! WidgetStyle::isWayland) {
MotifWmHints hint;
@ -86,6 +82,7 @@ void PlaySongArea::initWidget()
hint.decorations = MWM_DECOR_BORDER;
XAtomHelper::getInstance()->setWindowMotifHint(m_volSliderWid->winId(), hint);
}
moveVolSliderWid();
m_volSliderWid->hide();
m_playBackModeWid = new PlayBackModeWidget(this);
@ -103,9 +100,6 @@ void PlaySongArea::initWidget()
hSlider->setDisabled(true);
favBtn = new QPushButton;
favBtn->setFixedSize(36, 36);
// favBtn->setCheckable(true); //按钮是否是可点击状态,默认不点击
// favBtn->setChecked(false);
favBtn->setCursor(Qt::PointingHandCursor);
favBtn->setFocusPolicy(Qt::NoFocus);
favBtn->setToolTip(tr("Favourite"));
favBtn->setProperty("isWindowButton", 0x1);
@ -115,7 +109,6 @@ void PlaySongArea::initWidget()
//播放模式
playModeBtn = new QToolButton;
playModeBtn->setFixedSize(36, 36);
playModeBtn->setCursor(Qt::PointingHandCursor);
playModeBtn->setPopupMode(QToolButton::InstantPopup);
playModeBtn->setProperty("isWindowButton", 0x1);
playModeBtn->setProperty("useIconHighlightEffect", 0x2);
@ -165,9 +158,7 @@ void PlaySongArea::initWidget()
//历史播放列表
listBtn = new QPushButton;
listBtn->setFixedSize(36, 36);
listBtn->setCheckable(true); //按钮是否是可点击状态,默认不点击
// listBtn->setChecked(false); //只可检查按钮是否是点击状态,保存点击的状态
listBtn->setCursor(Qt::PointingHandCursor);
// listBtn->setCheckable(true); //按钮是否是可点击状态,默认不点击,
listBtn->setIcon(QIcon::fromTheme("ukui-play-list-symbolic"));
listBtn->setProperty("isWindowButton", 0x1);
listBtn->setProperty("useIconHighlightEffect", 0x2);
@ -372,9 +363,9 @@ void PlaySongArea::slotVolSliderWidget()
}
else
{
moveVolSliderWid();
m_volSliderWid->show();
m_volSliderWid->raise();
moveVolSliderWid();
}
}
@ -679,16 +670,16 @@ void PlaySongArea::setPosition(int position)
void PlaySongArea::resizeEvent(QResizeEvent *event)
{
moveVolSliderWid();
movePlayModeWid();
moveVolSliderWid();
playingLabel->setFixedWidth(this->width()/3.6);
QWidget::resizeEvent(event);
}
void PlaySongArea::moveVolSliderWid()
{
// QPoint volumePos = volumeBtn->mapToGlobal(volumeBtn->rect().center());
QPoint volumePos = QPoint(40, 40);
QPoint volumePos = volumeBtn->mapToGlobal(volumeBtn->rect().center());
// QPoint volumePos = QPoint(40, 40);
qDebug() << "volumePos: " << volumePos;
m_volSliderWid->adjustSize();
@ -701,16 +692,7 @@ void PlaySongArea::moveVolSliderWid()
m_volSliderWid->changeVolumePos(newPosX, newPosY, volumSize.width(), volumSize.height());
if (WidgetStyle::isWayland) {
qDebug() << "isWayland env";
m_volSliderWid->show();
// m_volSliderWid->raise();
// kdk::WindowManager::setGeometry(m_volSliderWid->windowHandle(), QRect(volumePos.x(), volumePos.y(), volumSize.width(), volumSize.height()));
kdk::WindowManager::setGeometry(m_volSliderWid->windowHandle(), QRect(500, 500, volumSize.width(), volumSize.height()));
} else {
qDebug() << "x11 env";
m_volSliderWid->move(volumePos);
}
m_volSliderWid->move(volumePos);
}
void PlaySongArea::movePlayModeWid()
@ -877,7 +859,7 @@ void PlaySongArea::slotFavExixtsDark()
}
void PlaySongArea::slotHistoryBtnChecked(bool checked)
{
listBtn->setChecked(checked);
// listBtn->setChecked(checked);
}
void PlaySongArea::slotFavIsExixts(QString filePaths)
{

View File

@ -1,14 +1,15 @@
#include "sliderwidget.h"
#include "UI/base/widgetstyle.h"
#include "UIControl/player/player.h"
#include "UI/base/widgetstyle.h"
//#include "UI/player/xatom-helper.h"
SliderWidget::SliderWidget(QWidget *parent) : QDialog(parent)
{
installEventFilter(this);
setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
// setAttribute(Qt::WA_StyledBackground,true);
setAttribute(Qt::WA_TranslucentBackground, true);
setAttribute(Qt::WA_StyledBackground,true);
// setAttribute(Qt::WA_TranslucentBackground, true);
// this->setAttribute(Qt::WA_DeleteOnClose);
// this->setAutoFillBackground(true);
// this->setBackgroundRole(QPalette::Base);
@ -55,6 +56,11 @@ bool SliderWidget::eventFilter(QObject *obj, QEvent *event) //鼠标滑块点
bool SliderWidget::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
Q_UNUSED(result);
if (WidgetStyle::isWayland) {
return nativeEvent(eventType, message, result);
}
if(eventType != "xcb_generic_event_t")
{
return false;

View File

@ -1,10 +1,16 @@
#include "tablehistory.h"
#include "UI/mainwidget.h"
#include "UI/base/widgetstyle.h"
#define PT_15 15
TableHistory::TableHistory(QWidget *parent) : QDialog(parent)
{
if (WidgetStyle::isWayland) {
// wayland 下move位置设置不生效需要添加如下代码
setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
}
initSetModel();
initStyle();
initConnect();
@ -226,13 +232,10 @@ void TableHistory::initConnect()
}
void TableHistory::showHistroryPlayList()
{
if(this->isVisible())
{
if(this->isVisible()) {
this->hide();
signalHistoryBtnChecked(false);
}
else
{
} else {
Widget::mutual->movePlayHistoryWid();
this->show();
signalHistoryBtnChecked(true);