mirror of https://gitee.com/openkylin/peony.git
[FIX][文件管理器]三屏-投屏模式切换成镜像模式,在切换成扩展屏模式时,第二扩展屏的文件重叠显示在一个扩展屏上[LINK]123283
This commit is contained in:
parent
c0b646c9c8
commit
911d9e9abc
|
@ -1536,7 +1536,7 @@ void DesktopIconView::rowsAboutToBeRemoved(const QModelIndex &parent, int start,
|
|||
QPoint itemPos(-1, -1);
|
||||
setRestoreInfo(uri, itemPos);
|
||||
}
|
||||
|
||||
qDebug() << "[DesktopIconView::rowsAboutToBeRemove] need relayout:" << m_model->m_items_need_relayout;
|
||||
relayoutExsitingItems(m_model->m_items_need_relayout);
|
||||
QListView::rowsAboutToBeRemoved(parent, start, end);
|
||||
// QTimer::singleShot(1, this, [=](){
|
||||
|
@ -2654,10 +2654,11 @@ void DesktopIconView::saveExtendItemInfo()
|
|||
QStringList topLeft;
|
||||
topLeft<<QString::number(indexRect.top());
|
||||
topLeft<<QString::number(indexRect.left());
|
||||
topLeft<<QString::number(m_id);
|
||||
QString uri = index.data(Qt::UserRole).toString();
|
||||
auto metaInfo = FileMetaInfo::fromUri(uri);
|
||||
if (metaInfo) {
|
||||
qDebug() << "DesktopIconView::saveExtendItemInfo:"<<str<<" "<<topLeft;
|
||||
qDebug() << "[DesktopIconView::saveExtendItemInfo] uri:"<<str<<" topLeft:"<<topLeft;
|
||||
metaInfo->setMetaInfoStringList(RESTORE_EXTEND_ITEM_POS_ATTRIBUTE, topLeft);
|
||||
metaInfo->setMetaInfoInt("peony-qt-desktop-id", 0);
|
||||
QStringList tmp;
|
||||
|
@ -2692,15 +2693,21 @@ void DesktopIconView::resetExtendItemInfo()
|
|||
auto metaInfo = FileMetaInfo::fromUri(uri);
|
||||
auto str = index.data(Qt::UserRole).toString();
|
||||
if (metaInfo) {
|
||||
auto list = metaInfo->getMetaInfoStringList(RESTORE_EXTEND_ITEM_POS_ATTRIBUTE);
|
||||
if (list.count() == 2) {
|
||||
qDebug() << "DesktopIconView::resetExtendItemInfo:"<<str<<" :"<<list<<"id:"<<m_id;
|
||||
QStringList list = metaInfo->getMetaInfoStringList(RESTORE_EXTEND_ITEM_POS_ATTRIBUTE);
|
||||
if (list.count() == 3) {
|
||||
QString id = list.takeLast();
|
||||
qDebug() << "[DesktopIconView::resetExtendItemInfo] uri:"<<str<<" peony-qt-desktop-restore-extend-item-position:"<<list<<" id:"<<m_id;
|
||||
if (id.toInt() != m_id) {
|
||||
continue;
|
||||
}
|
||||
metaInfo->setMetaInfoStringList(ITEM_POS_ATTRIBUTE, list);
|
||||
metaInfo->setMetaInfoInt("peony-qt-desktop-id", m_id);
|
||||
QStringList tmp;
|
||||
tmp<<"";
|
||||
metaInfo->setMetaInfoStringList(RESTORE_EXTEND_ITEM_POS_ATTRIBUTE, tmp);
|
||||
m_model->m_items_need_relayout.removeOne(uri);
|
||||
qDebug() << "[DesktopIconView::resetExtendItemInfo] need relayout:"<<m_model->m_items_need_relayout;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,10 +10,9 @@
|
|||
#include <QPlatformSurfaceEvent>
|
||||
#include "plasma-shell-manager.h"
|
||||
|
||||
static int desktop_window_id = 0;
|
||||
static QTimeLine *gTimeLine = nullptr;
|
||||
|
||||
DesktopBackgroundWindow::DesktopBackgroundWindow(QScreen *screen, QWidget *parent) : QMainWindow(parent)
|
||||
DesktopBackgroundWindow::DesktopBackgroundWindow(QScreen *screen, int desktopWindowId, QWidget *parent) : QMainWindow(parent)
|
||||
{
|
||||
connect(this, &DesktopBackgroundWindow::destroyed, this, &DesktopBackgroundWindow::invaidScreen);
|
||||
|
||||
|
@ -31,9 +30,8 @@ DesktopBackgroundWindow::DesktopBackgroundWindow(QScreen *screen, QWidget *paren
|
|||
|
||||
m_screen = screen;
|
||||
m_desktopIconView = new Peony::DesktopIconView(this);
|
||||
m_desktopIconView->setId(desktop_window_id);
|
||||
m_id = desktop_window_id;
|
||||
desktop_window_id++;
|
||||
m_desktopIconView->setId(desktopWindowId);
|
||||
m_id = desktopWindowId;
|
||||
move(screen->geometry().topLeft());
|
||||
setFixedSize(screen->geometry().size());
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
|
@ -98,7 +96,7 @@ DesktopBackgroundWindow::DesktopBackgroundWindow(QScreen *screen, QWidget *paren
|
|||
|
||||
DesktopBackgroundWindow::~DesktopBackgroundWindow()
|
||||
{
|
||||
--desktop_window_id;
|
||||
|
||||
}
|
||||
|
||||
void DesktopBackgroundWindow::paintEvent(QPaintEvent *event)
|
||||
|
|
|
@ -15,7 +15,7 @@ class DesktopBackgroundWindow : public QMainWindow
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DesktopBackgroundWindow(QScreen *screen, QWidget *parent = nullptr);
|
||||
explicit DesktopBackgroundWindow(QScreen *screen, int desktopWindowId, QWidget *parent = nullptr);
|
||||
~DesktopBackgroundWindow() override;
|
||||
|
||||
int id() const;
|
||||
|
|
|
@ -79,6 +79,7 @@ static bool has_daemon = false;
|
|||
static bool has_background = false;
|
||||
static QRect max_size = QRect(0, 0, 0, 0);
|
||||
static Peony::DesktopItemModel *desktop_model = nullptr;
|
||||
static int desktop_window_id = 0;
|
||||
|
||||
/*!
|
||||
* \brief virtualDesktopWindow
|
||||
|
@ -440,10 +441,14 @@ void PeonyDesktopApplication::relocateIconView()
|
|||
}
|
||||
|
||||
for (auto window : m_bg_windows) {
|
||||
qDebug() << "screen name :" << window->screen()->name() << " id:" << window->id() ;
|
||||
Q_EMIT window->getIconView()->updateView();
|
||||
window->setCentralWidget(window->getIconView());
|
||||
if (window->screen() != qApp->primaryScreen()) {
|
||||
KWindowSystem::raiseWindow(window->winId());
|
||||
}
|
||||
}
|
||||
KWindowSystem::raiseWindow(primaryWindow->winId());
|
||||
|
||||
}
|
||||
|
||||
|
@ -645,15 +650,18 @@ void PeonyDesktopApplication::updateVirtualDesktopGeometryByWindows()
|
|||
|
||||
void PeonyDesktopApplication::addBgWindow(QScreen *screen)
|
||||
{
|
||||
auto window = new DesktopBackgroundWindow(screen);
|
||||
int desktopWindowId = getDesktopWindowId();
|
||||
auto window = new DesktopBackgroundWindow(screen, desktopWindowId );
|
||||
|
||||
if (screen == qApp->primaryScreen()) {
|
||||
window->getIconView()->refresh();
|
||||
}
|
||||
m_bg_windows.append(window);
|
||||
|
||||
m_bg_windows.append(window);
|
||||
desktop_window_id = m_bg_windows.count();
|
||||
// recheck primary screen info. new screen might become
|
||||
// primary screen.
|
||||
|
||||
qDebug()<<"[PeonyDesktopApplication::addBgWindow] screen name:"<<window->screen()->name()<<" IP:"<<window->screen();
|
||||
window->show();
|
||||
connect(screen, &QScreen::destroyed, this, [=](){
|
||||
if (!isPrimaryScreen(screen)) {
|
||||
|
@ -686,6 +694,7 @@ void PeonyDesktopApplication::addBgWindow(QScreen *screen)
|
|||
for (auto bgWindow : m_bg_windows) {
|
||||
if (!isPrimaryScreen(bgWindow->screen())) {
|
||||
bgWindow->getIconView()->saveExtendItemInfo();
|
||||
// Q_EMIT bgWindow->getIconView()->updateView();
|
||||
}
|
||||
}
|
||||
getIconView(qApp->primaryScreen())->updateView();
|
||||
|
@ -693,7 +702,6 @@ void PeonyDesktopApplication::addBgWindow(QScreen *screen)
|
|||
for (auto bgWindow : m_bg_windows) {
|
||||
if (!isPrimaryScreen(bgWindow->screen())) {
|
||||
bgWindow->getIconView()->resetExtendItemInfo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -710,15 +718,6 @@ void PeonyDesktopApplication::addBgWindow(QScreen *screen)
|
|||
}
|
||||
|
||||
relocateIconView();
|
||||
|
||||
if (1 == mode){
|
||||
for (auto bgWindow : m_bg_windows) {
|
||||
if (isPrimaryScreen(bgWindow->screen())) {
|
||||
bgWindow->setCentralWidget(bgWindow->getIconView());
|
||||
KWindowSystem::raiseWindow(bgWindow->winId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PeonyDesktopApplication::setupDesktop()
|
||||
|
@ -727,7 +726,7 @@ void PeonyDesktopApplication::setupDesktop()
|
|||
for (auto screen : qApp->screens()) {
|
||||
addBgWindow(screen);
|
||||
}
|
||||
relocateIconView();
|
||||
//relocateIconView();
|
||||
connect(qApp, &QApplication::screenAdded, this, &PeonyDesktopApplication::addBgWindow);
|
||||
connect(this, &PeonyDesktopApplication::primaryScreenChanged, this, &PeonyDesktopApplication::relocateIconView);
|
||||
}
|
||||
|
@ -740,6 +739,24 @@ void PeonyDesktopApplication::setupBgAndDesktop()
|
|||
has_background = true;
|
||||
}
|
||||
|
||||
int PeonyDesktopApplication::getDesktopWindowId()
|
||||
{
|
||||
int desktopWindowId = 0;
|
||||
for (; desktopWindowId <= desktop_window_id; desktopWindowId++) {
|
||||
bool find = false;
|
||||
for (auto bgWindow : m_bg_windows) {
|
||||
if (bgWindow->id() == desktopWindowId) {
|
||||
find = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!find) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return desktopWindowId;
|
||||
}
|
||||
|
||||
void guessContentTypeCallback(GObject* object, GAsyncResult *res,gpointer data)
|
||||
{
|
||||
char **guessType;
|
||||
|
|
|
@ -87,6 +87,7 @@ private:
|
|||
void setupDesktop();
|
||||
void setupBgAndDesktop();
|
||||
void clearIcons(const QStringList &args);
|
||||
int getDesktopWindowId();
|
||||
|
||||
bool m_first_parse = true;
|
||||
|
||||
|
|
Loading…
Reference in New Issue