mirror of https://gitee.com/openkylin/peony.git
[FIX] 【整机生态-SP1-2303-update必测清单】【特殊机型】【龙梦A2207】【双屏】4k屏设置1280x720 4k屏幕显示异常 [LINK]176679
This commit is contained in:
parent
05ba6746a7
commit
0e59fa4f18
|
@ -242,39 +242,7 @@ DesktopIconView::DesktopIconView(QWidget *parent) : QListView(parent)
|
|||
|
||||
// check if there are items overlapped.
|
||||
QTimer::singleShot(150, this, [=](){
|
||||
if (!m_initialized) {
|
||||
qInfo()<<"desktop icon view model inited";
|
||||
m_initialized = true;
|
||||
|
||||
if (!QGSettings::isSchemaInstalled(PANEL_SETTINGS))
|
||||
return;
|
||||
//panel
|
||||
QGSettings *panelSetting = new QGSettings(PANEL_SETTINGS, QByteArray(), this);
|
||||
int position = panelSetting->get("panelposition").toInt();
|
||||
int margins = panelSetting->get("panelsize").toInt();
|
||||
switch (position) {
|
||||
case 1: {
|
||||
setViewportMargins(0, margins, 0, 0);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
setViewportMargins(margins, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
setViewportMargins(0, 0, margins, 0);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
setViewportMargins(0, 0, 0, margins);
|
||||
break;
|
||||
}
|
||||
}
|
||||
getAllRestoreInfo();
|
||||
modifyGridSize();
|
||||
resolutionChange();
|
||||
setAllRestoreInfo();
|
||||
}
|
||||
initViewport();
|
||||
checkItemsOver();
|
||||
|
||||
// check icon is out of screen
|
||||
|
@ -1568,8 +1536,8 @@ void DesktopIconView::rowsAboutToBeRemoved(const QModelIndex &parent, int start,
|
|||
auto uri = model()->index(row, 0).data(Qt::UserRole).toString();
|
||||
m_item_rect_hash.remove(uri);
|
||||
m_resolution_item_rect.remove(uri);
|
||||
QPoint itemPos(-1, -1);
|
||||
setRestoreInfo(uri, itemPos);
|
||||
// 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);
|
||||
|
@ -2501,6 +2469,7 @@ void DesktopIconView::setRestoreInfo(QString &uri, QPoint &itemPos)
|
|||
// restoreInfo<<pixelRatio;
|
||||
restoreInfo<<QString::number(itemPos.x());
|
||||
restoreInfo<<QString::number(itemPos.y());
|
||||
restoreInfo<<QString::number(m_id);
|
||||
metaInfo->setMetaInfoStringList(RESTORE_ITEM_POS_ATTRIBUTE, restoreInfo);
|
||||
}
|
||||
}
|
||||
|
@ -2515,6 +2484,7 @@ void DesktopIconView::setAllRestoreInfo()
|
|||
QStringList restoreInfo;
|
||||
restoreInfo<<QString::number(rect.topLeft().x());
|
||||
restoreInfo<<QString::number(rect.topLeft().y());
|
||||
restoreInfo<<QString::number(m_id);
|
||||
metaInfo->setMetaInfoStringList(RESTORE_ITEM_POS_ATTRIBUTE, restoreInfo);
|
||||
}
|
||||
}
|
||||
|
@ -2527,10 +2497,11 @@ void DesktopIconView::getAllRestoreInfo()
|
|||
auto metaInfo = FileMetaInfo::fromUri(uri);
|
||||
if (metaInfo) {
|
||||
QStringList restoreInfo = metaInfo->getMetaInfoStringList(RESTORE_ITEM_POS_ATTRIBUTE);
|
||||
if (restoreInfo.count() == 2) {
|
||||
if (restoreInfo.count() == 3) {
|
||||
int top = restoreInfo.at(0).toInt();
|
||||
int left = restoreInfo.at(1).toInt();
|
||||
if (top >= 0 && left >= 0) {
|
||||
int id = restoreInfo.at(2).toInt();
|
||||
if (id == m_id && top >= 0 && left >= 0) {
|
||||
QPoint topLeft(top, left);
|
||||
updateItemPosByUri(uri, topLeft);
|
||||
setFileMetaInfoPos(uri, topLeft);
|
||||
|
@ -2960,42 +2931,42 @@ void DesktopIconView::modifyGridSize()
|
|||
}
|
||||
}
|
||||
|
||||
//QSize DesktopIconView::getSizeFromConfig()
|
||||
//{
|
||||
// QSize sizeFromConfig;
|
||||
// QString configPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/peony-qt.txt";
|
||||
// if (QFile::exists(configPath)) {
|
||||
// QFile file(configPath);
|
||||
// if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
// QTextStream in(&file);
|
||||
// QString configFileContent = in.readAll();
|
||||
// file.close();
|
||||
void DesktopIconView::initViewport()
|
||||
{
|
||||
if (!m_initialized) {
|
||||
qInfo()<<"desktop icon view model inited";
|
||||
m_initialized = true;
|
||||
|
||||
// QStringList sizeValues = configFileContent.split("x");
|
||||
// if (sizeValues.size() == 2) {
|
||||
// int width = sizeValues[0].toInt();
|
||||
// int height = sizeValues[1].toInt();
|
||||
// sizeFromConfig = QSize(width, height);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return sizeFromConfig;
|
||||
//}
|
||||
|
||||
//void DesktopIconView::writeSizeToConfig(const QSize &gridSize)
|
||||
//{
|
||||
// if (gridSize.isValid()) {
|
||||
// QString configFileContent;
|
||||
// QString configPath = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/peony-qt.txt";
|
||||
// QFile file(configPath);
|
||||
// if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
// QTextStream out(&file);
|
||||
// configFileContent = QString::number(gridSize.width()) + "x" + QString::number(gridSize.height());
|
||||
// out << configFileContent;
|
||||
// file.close();
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
if (!QGSettings::isSchemaInstalled(PANEL_SETTINGS))
|
||||
return;
|
||||
//panel
|
||||
QGSettings *panelSetting = new QGSettings(PANEL_SETTINGS, QByteArray(), this);
|
||||
int position = panelSetting->get("panelposition").toInt();
|
||||
int margins = panelSetting->get("panelsize").toInt();
|
||||
switch (position) {
|
||||
case 1: {
|
||||
setViewportMargins(0, margins, 0, 0);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
setViewportMargins(margins, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
setViewportMargins(0, 0, margins, 0);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
setViewportMargins(0, 0, 0, margins);
|
||||
break;
|
||||
}
|
||||
}
|
||||
getAllRestoreInfo();
|
||||
modifyGridSize();
|
||||
resolutionChange();
|
||||
setAllRestoreInfo();
|
||||
}
|
||||
}
|
||||
|
||||
static bool iconSizeLessThan (const QPair<QRect, QString>& p1, const QPair<QRect, QString>& p2)
|
||||
{
|
||||
|
|
|
@ -124,6 +124,7 @@ public:
|
|||
// only used in model refresh.
|
||||
void clearCache();
|
||||
void modifyGridSize();
|
||||
void initViewport();
|
||||
|
||||
private:
|
||||
QRect getScreenArea(QScreen* screen);
|
||||
|
@ -259,8 +260,6 @@ protected:
|
|||
void relayoutExsitingItems(const QStringList &uris);
|
||||
void checkItemsOver();
|
||||
bool dragToOtherScreen(QDropEvent *e);
|
||||
// QSize getSizeFromConfig();
|
||||
// void writeSizeToConfig(const QSize &gridSize);
|
||||
|
||||
private:
|
||||
ZoomLevel m_zoom_level = Invalid;
|
||||
|
|
|
@ -751,16 +751,26 @@ void PeonyDesktopApplication::addBgWindow(QScreen *screen)
|
|||
int desktopWindowId = getDesktopWindowId();
|
||||
auto window = new DesktopBackgroundWindow(screen, desktopWindowId );
|
||||
|
||||
if (screen == qApp->primaryScreen()) {
|
||||
window->getIconView()->refresh();
|
||||
}
|
||||
|
||||
m_bg_windows.append(window);
|
||||
desktop_window_id = m_bg_windows.count();
|
||||
|
||||
// recheck primary screen info. new screen might become
|
||||
// primary screen.
|
||||
qInfo()<<"[PeonyDesktopApplication::addBgWindow] screen name:"<<window->screen()->name()<<" IP:"<<window->screen() << "count:" << m_bg_windows.count();
|
||||
window->show();
|
||||
//task#74174 恢复扩展屏
|
||||
m_mode = checkScreenMode(screen->geometry());
|
||||
if (2 == m_mode) {
|
||||
multiscreenMode();
|
||||
}
|
||||
//在设置模式后初始化viewprt,否则会导致主屏是扩展屏,插入扩展屏后,model没有数据
|
||||
if (screen == qApp->primaryScreen()) {
|
||||
window->getIconView()->refresh();
|
||||
} else {
|
||||
QTimer::singleShot(150, window, [=](){
|
||||
window->getIconView()->initViewport();
|
||||
});
|
||||
}
|
||||
connect(screen, &QScreen::destroyed, this, [=](){
|
||||
if (m_mode == 2) {
|
||||
if (m_bg_windows.count() > 2) {
|
||||
|
@ -806,11 +816,6 @@ void PeonyDesktopApplication::addBgWindow(QScreen *screen)
|
|||
m_mode = mode;
|
||||
window->setWindowGeometry(geometry);
|
||||
});
|
||||
//task#74174 恢复扩展屏
|
||||
m_mode = checkScreenMode(screen->geometry());
|
||||
if (2 == m_mode) {
|
||||
multiscreenMode();
|
||||
}
|
||||
|
||||
relocateIconView();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue