summaryrefslogtreecommitdiff
path: root/libs/svgviewer/mainwindow.cpp
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-03-27 18:14:16 +0100
committerClifford Wolf <clifford@clifford.at>2013-03-27 18:14:16 +0100
commit35a02ee81e360a0f8c7643a38b72305c33da08c6 (patch)
tree74cd0fcba0ab3a06290f986bac1482707b789b76 /libs/svgviewer/mainwindow.cpp
parent9c401b58a241827c187c9e586aa22b600bd2ef0a (diff)
Now using SVG and yosys-svgviewer per default in show command
Diffstat (limited to 'libs/svgviewer/mainwindow.cpp')
-rw-r--r--libs/svgviewer/mainwindow.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/libs/svgviewer/mainwindow.cpp b/libs/svgviewer/mainwindow.cpp
index 7d4d303e..31dd63e5 100644
--- a/libs/svgviewer/mainwindow.cpp
+++ b/libs/svgviewer/mainwindow.cpp
@@ -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