diff --git a/argumentparser.cpp b/argumentparser.cpp index c59abc7..7871327 100644 --- a/argumentparser.cpp +++ b/argumentparser.cpp @@ -109,12 +109,6 @@ bool ArgumentParser::parseCmdLineArgs(bool &successful) successful = false; return false; } - if (!fileInfo.isWritable()) - { - std::cout << tr("File: ").toStdString() << - m_filePath.toStdString() << - tr(" is not writeable.").toStdString() << std::endl; - } } return true; } diff --git a/mainwindow.cpp b/mainwindow.cpp index 35854c9..5cb115c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -225,6 +225,11 @@ void MainWindow::openFile(const QString &fileName) m_fileName = fileName; } + + QFileInfo fileInfo(fileName); + if (!fileInfo.isWritable()) + statusBarMsg(tr("Read-only file!")); + if (!m_graphicsView->readContentFromXmlFile(m_fileName)) { m_fileName = currFilename; @@ -232,17 +237,35 @@ void MainWindow::openFile(const QString &fileName) } - m_ui->actionSave->setEnabled(true); m_ui->actionSaveAs->setEnabled(true); m_ui->actionClose->setEnabled(true); m_ui->actionExport->setEnabled(true); + contentChanged(false); - setTitle(m_fileName); + + if (!fileInfo.isWritable()) + { + m_ui->actionSave->setEnabled(false); + setTitle(QString("readonly ").append(m_fileName)); + } + else + { + m_ui->actionSave->setEnabled(true); + setTitle(m_fileName); + } + showMainToolbar(); } void MainWindow::saveFile() { + QFileInfo fileInfo(m_fileName); + if (!fileInfo.isWritable()) + { + statusBarMsg(tr("Read-only file!")); + return; + } + m_graphicsView->writeContentToXmlFile(m_fileName); contentChanged(false); }