3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-22 16:45:32 +00:00

Now using SVG and yosys-svgviewer per default in show command

This commit is contained in:
Clifford Wolf 2013-03-27 18:14:16 +01:00
parent 9c401b58a2
commit 35a02ee81e
4 changed files with 67 additions and 16 deletions

View file

@ -41,12 +41,15 @@
#include "mainwindow.h"
#include <QtGui>
#include <QFileSystemWatcher>
#include "svgview.h"
MainWindow::MainWindow()
: QMainWindow()
, m_view(new SvgView)
, m_watcher(NULL)
, m_filehandle(NULL)
{
QMenu *fileMenu = new QMenu(tr("&File"), this);
QAction *openAction = fileMenu->addAction(tr("&Open..."));
@ -118,6 +121,15 @@ void MainWindow::openFile(const QString &path)
else
fileName = path;
if (m_watcher) {
delete m_watcher;
m_watcher = NULL;
}
if (m_filehandle) {
fclose(m_filehandle);
m_filehandle = NULL;
}
if (!fileName.isEmpty()) {
QFile file(fileName);
if (!file.exists()) {
@ -129,6 +141,13 @@ void MainWindow::openFile(const QString &path)
return;
}
m_watcher = new QFileSystemWatcher(this);
m_watcher->addPath(fileName);
connect(m_watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(reloadFile()));
// just keep the file open so this process is found using 'fuser'
m_filehandle = fopen(fileName.toAscii(), "r");
m_view->openFile(file);
if (!fileName.startsWith(":/")) {
@ -139,10 +158,15 @@ void MainWindow::openFile(const QString &path)
m_outlineAction->setEnabled(true);
m_backgroundAction->setEnabled(true);
resize(m_view->sizeHint() + QSize(80, 80 + menuBar()->height()));
// resize(m_view->sizeHint() + QSize(80, 80 + menuBar()->height()));
}
}
void MainWindow::reloadFile()
{
openFile(m_currentPath);
}
void MainWindow::setRenderer(QAction *action)
{
#ifndef QT_NO_OPENGL

View file

@ -43,6 +43,7 @@
#include <QMainWindow>
#include <QString>
#include <stdio.h>
class SvgView;
@ -51,6 +52,7 @@ class QAction;
class QGraphicsView;
class QGraphicsScene;
class QGraphicsRectItem;
class QFileSystemWatcher;
QT_END_NAMESPACE
class MainWindow : public QMainWindow
@ -63,6 +65,7 @@ public:
public slots:
void openFile(const QString &path = QString());
void setRenderer(QAction *action);
void reloadFile();
private:
QAction *m_nativeAction;
@ -75,6 +78,8 @@ private:
SvgView *m_view;
QString m_currentPath;
QFileSystemWatcher *m_watcher;
FILE *m_filehandle;
};
#endif