Merge branch '0330-dev' into 'main'
Fix:Fit ukui-kwin for setting widget. See merge request kylin-desktop/ukui-search!2
This commit is contained in:
commit
af643ec4ad
|
@ -244,7 +244,8 @@ int main(int argc, char *argv[])
|
|||
MainWindow *w = new MainWindow;
|
||||
QStringList arguments = QCoreApplication::arguments();
|
||||
// centerToScreen(w);
|
||||
w->moveToPanel();
|
||||
// w->moveToPanel();
|
||||
centerToScreen(w);
|
||||
|
||||
//使用窗管的无边框策略
|
||||
// w->setProperty("useStyleWindowManager", false); //禁用拖动
|
||||
|
@ -257,7 +258,8 @@ int main(int argc, char *argv[])
|
|||
app.setActivationWindow(w);
|
||||
|
||||
if (QString::compare(QString("-s"), QString(QLatin1String(argv[1]))) == 0) {
|
||||
w->moveToPanel();
|
||||
// w->moveToPanel();
|
||||
centerToScreen(w);
|
||||
XAtomHelper::getInstance()->setWindowMotifHint(w->winId(), w->m_hints);
|
||||
w->show();
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
this->setWindowTitle(tr("ukui-search"));
|
||||
initUi();
|
||||
|
||||
setProperty("useStyleWindowManager", false);
|
||||
// setProperty("useStyleWindowManager", false); //禁止拖动
|
||||
m_hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS;
|
||||
m_hints.functions = MWM_FUNC_ALL;
|
||||
m_hints.decorations = MWM_DECOR_BORDER;
|
||||
|
@ -136,7 +136,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
{
|
||||
if (!this->isVisible()) {
|
||||
clearSearchResult();
|
||||
this->moveToPanel();
|
||||
// this->moveToPanel();
|
||||
centerToScreen(this);
|
||||
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
||||
this->show();
|
||||
this->m_searchLayout->focusIn(); //打开主界面时输入框夺焦,可直接输入
|
||||
|
@ -202,10 +203,14 @@ void MainWindow::initUi()
|
|||
m_menuBtn->setFlat(true);
|
||||
connect(m_menuBtn, &QPushButton::clicked, this, [ = ]() {
|
||||
if (m_settingsWidget) { //当此窗口已存在时,仅需置顶
|
||||
if (!m_settingsWidget->isVisible()) {
|
||||
centerToScreen(m_settingsWidget);
|
||||
}
|
||||
m_settingsWidget->showWidget();
|
||||
return;
|
||||
}
|
||||
m_settingsWidget = new SettingsWidget();
|
||||
centerToScreen(m_settingsWidget);
|
||||
m_settingsWidget->show();
|
||||
connect(m_settingsWidget, &SettingsWidget::settingWidgetClosed, this, [ = ]() {
|
||||
QTimer::singleShot(100, this, [ = ] {
|
||||
|
@ -273,7 +278,8 @@ void MainWindow::bootOptionsFilter(QString opt)
|
|||
{
|
||||
if (opt == "-s" || opt == "--show") {
|
||||
clearSearchResult();
|
||||
this->moveToPanel();
|
||||
// this->moveToPanel();
|
||||
centerToScreen(this);
|
||||
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
||||
this->show();
|
||||
this->m_searchLayout->focusIn();
|
||||
|
@ -391,6 +397,32 @@ void MainWindow::moveToPanel()
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief MainWindow::centerToScreen 使窗口显示在屏幕中间
|
||||
* @param widget
|
||||
*/
|
||||
void MainWindow::centerToScreen(QWidget* widget) {
|
||||
if (!widget)
|
||||
return;
|
||||
QDesktopWidget* m = QApplication::desktop();
|
||||
QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
|
||||
int desk_x = desk_rect.width();
|
||||
int desk_y = desk_rect.height();
|
||||
int x = widget->width();
|
||||
int y = widget->height();
|
||||
QDBusInterface primaryScreenInterface("org.ukui.SettingsDaemon",
|
||||
"/org/ukui/SettingsDaemon/wayland",
|
||||
"org.ukui.SettingsDaemon.wayland",
|
||||
QDBusConnection::sessionBus());
|
||||
if (QDBusReply<int>(primaryScreenInterface.call("x")).isValid()) {
|
||||
QDBusReply<int> width = primaryScreenInterface.call("width");
|
||||
QDBusReply<int> height = primaryScreenInterface.call("height");
|
||||
desk_x = width;
|
||||
desk_y = height;
|
||||
}
|
||||
widget->move(desk_x / 2 - x / 2 + desk_rect.left(), desk_y / 2 - y / 2 + desk_rect.top());
|
||||
}
|
||||
|
||||
//使用GSetting获取当前窗口应该使用的透明度
|
||||
double MainWindow::getTransparentData()
|
||||
{
|
||||
|
|
|
@ -65,6 +65,7 @@ public:
|
|||
*/
|
||||
void searchContent(QString searchcontent);
|
||||
void moveToPanel();
|
||||
void centerToScreen(QWidget* widget);
|
||||
MotifWmHints m_hints;
|
||||
|
||||
private:
|
||||
|
|
|
@ -30,12 +30,18 @@
|
|||
#include "file-utils.h"
|
||||
|
||||
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
|
||||
SettingsWidget::SettingsWidget(QWidget *parent) : QDialog(parent)
|
||||
SettingsWidget::SettingsWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
this->setWindowIcon(QIcon::fromTheme("kylin-search"));
|
||||
this->setWindowTitle(tr("ukui-search-settings"));
|
||||
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
|
||||
this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
// this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
|
||||
// this->setAttribute(Qt::WA_TranslucentBackground);
|
||||
|
||||
m_hints.flags = MWM_HINTS_FUNCTIONS|MWM_HINTS_DECORATIONS;
|
||||
m_hints.functions = MWM_FUNC_ALL;
|
||||
m_hints.decorations = MWM_DECOR_BORDER;
|
||||
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
||||
|
||||
initUi();
|
||||
refreshIndexState();
|
||||
setupBlackList(GlobalSettings::getInstance()->getBlockDirs());
|
||||
|
@ -369,6 +375,7 @@ void SettingsWidget::showWidget()
|
|||
flags &= ~Qt::WindowStaysOnTopHint;
|
||||
this->setWindowFlags(flags);
|
||||
m_timer->start();
|
||||
XAtomHelper::getInstance()->setWindowMotifHint(winId(), m_hints);
|
||||
this->show();
|
||||
}
|
||||
|
||||
|
@ -432,40 +439,39 @@ void SettingsWidget::paintEvent(QPaintEvent *event) {
|
|||
QPainter p(this);
|
||||
p.setRenderHint(QPainter::Antialiasing);
|
||||
QPainterPath rectPath;
|
||||
rectPath.addRoundedRect(this->rect().adjusted(10, 10, -10, -10), 6, 6);
|
||||
rectPath.addRoundedRect(this->rect(), 6, 6);
|
||||
|
||||
// 画一个黑底
|
||||
QPixmap pixmap(this->rect().size());
|
||||
pixmap.fill(Qt::transparent);
|
||||
QPainter pixmapPainter(&pixmap);
|
||||
pixmapPainter.setRenderHint(QPainter::Antialiasing);
|
||||
pixmapPainter.setPen(Qt::transparent);
|
||||
pixmapPainter.setBrush(Qt::black);
|
||||
pixmapPainter.setOpacity(0.65);
|
||||
pixmapPainter.drawPath(rectPath);
|
||||
pixmapPainter.end();
|
||||
// // 画一个黑底
|
||||
// QPixmap pixmap(this->rect().size());
|
||||
// pixmap.fill(Qt::transparent);
|
||||
// QPainter pixmapPainter(&pixmap);
|
||||
// pixmapPainter.setRenderHint(QPainter::Antialiasing);
|
||||
// pixmapPainter.setPen(Qt::transparent);
|
||||
// pixmapPainter.setBrush(Qt::black);
|
||||
// pixmapPainter.setOpacity(0.65);
|
||||
// pixmapPainter.drawPath(rectPath);
|
||||
// pixmapPainter.end();
|
||||
|
||||
// 模糊这个黑底
|
||||
QImage img = pixmap.toImage();
|
||||
qt_blurImage(img, 10, false, false);
|
||||
// // 模糊这个黑底
|
||||
// QImage img = pixmap.toImage();
|
||||
// qt_blurImage(img, 10, false, false);
|
||||
|
||||
// 挖掉中心
|
||||
pixmap = QPixmap::fromImage(img);
|
||||
QPainter pixmapPainter2(&pixmap);
|
||||
pixmapPainter2.setRenderHint(QPainter::Antialiasing);
|
||||
pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear);
|
||||
pixmapPainter2.setPen(Qt::transparent);
|
||||
pixmapPainter2.setBrush(Qt::transparent);
|
||||
pixmapPainter2.drawPath(rectPath);
|
||||
// // 挖掉中心
|
||||
// pixmap = QPixmap::fromImage(img);
|
||||
// QPainter pixmapPainter2(&pixmap);
|
||||
// pixmapPainter2.setRenderHint(QPainter::Antialiasing);
|
||||
// pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear);
|
||||
// pixmapPainter2.setPen(Qt::transparent);
|
||||
// pixmapPainter2.setBrush(Qt::transparent);
|
||||
// pixmapPainter2.drawPath(rectPath);
|
||||
|
||||
// 绘制阴影
|
||||
p.drawPixmap(this->rect(), pixmap, pixmap.rect());
|
||||
// // 绘制阴影
|
||||
// p.drawPixmap(this->rect(), pixmap, pixmap.rect());
|
||||
|
||||
// 绘制一个背景
|
||||
p.save();
|
||||
p.fillPath(rectPath,palette().color(QPalette::Base));
|
||||
p.restore();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,8 +33,9 @@
|
|||
#include <QScrollArea>
|
||||
#include <QTimer>
|
||||
#include <libsearch.h>
|
||||
#include "xatom-helper.h"
|
||||
|
||||
class SettingsWidget : public QDialog
|
||||
class SettingsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -54,6 +55,9 @@ private:
|
|||
void resize();
|
||||
void showWarningDialog(const int&);
|
||||
void resetWebEngine();
|
||||
|
||||
MotifWmHints m_hints;
|
||||
|
||||
//标题栏
|
||||
QVBoxLayout * m_mainLyt = nullptr;
|
||||
QFrame * m_contentFrame = nullptr;
|
||||
|
|
Loading…
Reference in New Issue