mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 13:29:12 +00:00 
			
		
		
		
	Keep viewport transform stable on reload in yosys-svgviewer
This commit is contained in:
		
							parent
							
								
									92cf7ae2f7
								
							
						
					
					
						commit
						98fcb5daa3
					
				
					 2 changed files with 8 additions and 4 deletions
				
			
		| 
						 | 
					@ -112,7 +112,7 @@ MainWindow::MainWindow()
 | 
				
			||||||
    setWindowTitle(tr("SVG Viewer"));
 | 
					    setWindowTitle(tr("SVG Viewer"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MainWindow::openFile(const QString &path)
 | 
					void MainWindow::openFile(const QString &path, bool reload)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    QString fileName;
 | 
					    QString fileName;
 | 
				
			||||||
    if (path.isNull())
 | 
					    if (path.isNull())
 | 
				
			||||||
| 
						 | 
					@ -148,6 +148,7 @@ void MainWindow::openFile(const QString &path)
 | 
				
			||||||
	// just keep the file open so this process is found using 'fuser'
 | 
						// just keep the file open so this process is found using 'fuser'
 | 
				
			||||||
	m_filehandle = fopen(fileName.toAscii(), "r");
 | 
						m_filehandle = fopen(fileName.toAscii(), "r");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						QTransform oldTransform = m_view->transform();
 | 
				
			||||||
        m_view->openFile(file);
 | 
					        m_view->openFile(file);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (!fileName.startsWith(":/")) {
 | 
					        if (!fileName.startsWith(":/")) {
 | 
				
			||||||
| 
						 | 
					@ -158,13 +159,16 @@ void MainWindow::openFile(const QString &path)
 | 
				
			||||||
        m_outlineAction->setEnabled(true);
 | 
					        m_outlineAction->setEnabled(true);
 | 
				
			||||||
        m_backgroundAction->setEnabled(true);
 | 
					        m_backgroundAction->setEnabled(true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // resize(m_view->sizeHint() + QSize(80, 80 + menuBar()->height()));
 | 
						if (reload)
 | 
				
			||||||
 | 
							m_view->setTransform(oldTransform);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							resize(m_view->sizeHint() + QSize(80, 80 + menuBar()->height()));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MainWindow::reloadFile()
 | 
					void MainWindow::reloadFile()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	openFile(m_currentPath);
 | 
						openFile(m_currentPath, true);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void MainWindow::setRenderer(QAction *action)
 | 
					void MainWindow::setRenderer(QAction *action)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -63,7 +63,7 @@ public:
 | 
				
			||||||
    MainWindow();
 | 
					    MainWindow();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public slots:
 | 
					public slots:
 | 
				
			||||||
    void openFile(const QString &path = QString());
 | 
					    void openFile(const QString &path = QString(), bool reload = false);
 | 
				
			||||||
    void setRenderer(QAction *action);
 | 
					    void setRenderer(QAction *action);
 | 
				
			||||||
    void reloadFile();
 | 
					    void reloadFile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue