Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
pdf viewer window now can be restored to maximized window from embedded state
  • Loading branch information
octaeder committed Jan 1, 2024
1 parent 682964e commit 8d97bc6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/pdfviewer/PDFDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2857,21 +2857,21 @@ PDFDocument::PDFDocument(PDFDocumentConfig *const pdfConfig, bool embedded)
int &h = globalConfig->windowHeight;
QRect screen = UtilsUi::getAvailableGeometryAt(QPoint(x, y));
// add some tolerance, as fullscreen seems to have negative coordinate (KDE, Win7 ...)
screen.adjust(-8, -8, +8, +8);
// screen.adjust(-8, -8, +8, +8);
if (!screen.contains(x, y)) {
// top left is not on screen
x = screen.x() + screen.width() * 2 / 3;
y = screen.y() + 10;
if (x + w > screen.right()) w = screen.width() / 3 - 26;
if (y + h > screen.height()) h = screen.height() - 100;
}
resize(w, h); //important to first resize then move then maximize
move(x, y);
if (globalConfig->windowMaximized)
showMaximized();
else
setWindowState(Qt::WindowNoState);

resize(w, h); //important to first resize then move
move(x, y);
if (!globalConfig->windowState.isEmpty()) restoreState(globalConfig->windowState);
toolBar->setVisible(globalConfig->toolbarVisible);
statusbar->setVisible(true);
Expand Down Expand Up @@ -4298,10 +4298,12 @@ PDFDocument *PDFDocument::findDocument(const QString &fileName)

void PDFDocument::saveGeometryToConfig()
{
globalConfig->windowLeft = x();
globalConfig->windowTop = y();
globalConfig->windowWidth = width();
globalConfig->windowHeight = height();
if (!isMaximized() && !isFullScreen()) {
globalConfig->windowLeft = x();
globalConfig->windowTop = y();
globalConfig->windowWidth = width();
globalConfig->windowHeight = height();
}
globalConfig->windowMaximized = isMaximized();
globalConfig->windowState = saveState();
globalConfig->toolbarVisible = toolBar->isVisible();
Expand Down

0 comments on commit 8d97bc6

Please sign in to comment.