Add reload from disk
This is typically mapped to the F5 key, so the "secret force refresh" key has been temporarily moved to F6.
This commit is contained in:
19
document.cpp
19
document.cpp
@@ -94,6 +94,25 @@ bool TeletextDocument::isEmpty() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TeletextDocument::clear()
|
||||||
|
{
|
||||||
|
LevelOnePage *blankSubPage = new LevelOnePage;
|
||||||
|
|
||||||
|
m_subPages.insert(m_subPages.begin(), blankSubPage);
|
||||||
|
|
||||||
|
emit aboutToChangeSubPage();
|
||||||
|
m_currentSubPageIndex = 0;
|
||||||
|
m_clutModel->setSubPage(m_subPages[0]);
|
||||||
|
emit subPageSelected();
|
||||||
|
cancelSelection();
|
||||||
|
m_undoStack->clear();
|
||||||
|
|
||||||
|
for (int i=m_subPages.size()-1; i>0; i--) {
|
||||||
|
delete(m_subPages[i]);
|
||||||
|
m_subPages.erase(m_subPages.begin()+i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void TeletextDocument::setPageFunction(PageFunctionEnum newPageFunction)
|
void TeletextDocument::setPageFunction(PageFunctionEnum newPageFunction)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
~TeletextDocument();
|
~TeletextDocument();
|
||||||
|
|
||||||
bool isEmpty() const;
|
bool isEmpty() const;
|
||||||
|
void clear();
|
||||||
|
|
||||||
PageFunctionEnum pageFunction() const { return m_pageFunction; }
|
PageFunctionEnum pageFunction() const { return m_pageFunction; }
|
||||||
// void setPageFunction(PageFunctionEnum);
|
// void setPageFunction(PageFunctionEnum);
|
||||||
|
|||||||
@@ -386,7 +386,7 @@ void TeletextWidget::keyPressEvent(QKeyEvent *event)
|
|||||||
case Qt::Key_PageDown:
|
case Qt::Key_PageDown:
|
||||||
m_teletextDocument->selectSubPagePrevious();
|
m_teletextDocument->selectSubPagePrevious();
|
||||||
break;
|
break;
|
||||||
case Qt::Key_F5:
|
case Qt::Key_F6:
|
||||||
m_pageDecode.decodePage();
|
m_pageDecode.decodePage();
|
||||||
m_pageRender.renderPage(true);
|
m_pageRender.renderPage(true);
|
||||||
update();
|
update();
|
||||||
|
|||||||
@@ -149,6 +149,34 @@ bool MainWindow::saveAs()
|
|||||||
return saveFile(fileName);
|
return saveFile(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::reload()
|
||||||
|
{
|
||||||
|
if (m_isUntitled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!m_textWidget->document()->undoStack()->isClean()) {
|
||||||
|
const QMessageBox::StandardButton ret = QMessageBox::warning(this, QApplication::applicationDisplayName(), tr("The document \"%1\" has been modified.\nDo you want to discard your changes?").arg(QFileInfo(m_curFile).fileName()), QMessageBox::Discard | QMessageBox::Cancel);
|
||||||
|
|
||||||
|
if (ret != QMessageBox::Discard)
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
const QMessageBox::StandardButton ret = QMessageBox::warning(this, QApplication::applicationDisplayName(), tr("Do you want to reload the document \"%1\" from disk?").arg(QFileInfo(m_curFile).fileName()), QMessageBox::Yes | QMessageBox::No);
|
||||||
|
|
||||||
|
if (ret != QMessageBox::Yes)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int subPageIndex = m_textWidget->document()->currentSubPageIndex();
|
||||||
|
|
||||||
|
m_textWidget->document()->clear();
|
||||||
|
loadFile(m_curFile);
|
||||||
|
|
||||||
|
if (subPageIndex >= m_textWidget->document()->numberOfSubPages())
|
||||||
|
subPageIndex = m_textWidget->document()->numberOfSubPages()-1;
|
||||||
|
|
||||||
|
m_textWidget->document()->selectSubPageIndex(subPageIndex, true);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::exportPNG()
|
void MainWindow::exportPNG()
|
||||||
{
|
{
|
||||||
QString exportFileName = QFileDialog::getSaveFileName(this, tr("Export PNG"), QString(), "PNG image (*.png)");
|
QString exportFileName = QFileDialog::getSaveFileName(this, tr("Export PNG"), QString(), "PNG image (*.png)");
|
||||||
@@ -328,6 +356,11 @@ void MainWindow::createActions()
|
|||||||
saveAsAct->setShortcuts(QKeySequence::SaveAs);
|
saveAsAct->setShortcuts(QKeySequence::SaveAs);
|
||||||
saveAsAct->setStatusTip(tr("Save the document under a new name"));
|
saveAsAct->setStatusTip(tr("Save the document under a new name"));
|
||||||
|
|
||||||
|
const QIcon reloadIcon = QIcon::fromTheme("document-revert");
|
||||||
|
QAction *reloadAct = fileMenu->addAction(reloadIcon, tr("Reload"), this, &MainWindow::reload);
|
||||||
|
reloadAct->setShortcuts(QKeySequence::Refresh);
|
||||||
|
reloadAct->setStatusTip(tr("Reload the document from disk"));
|
||||||
|
|
||||||
fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
|
|
||||||
QMenu *recentMenu = fileMenu->addMenu(tr("Recent"));
|
QMenu *recentMenu = fileMenu->addMenu(tr("Recent"));
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ private slots:
|
|||||||
void open();
|
void open();
|
||||||
bool save();
|
bool save();
|
||||||
bool saveAs();
|
bool saveAs();
|
||||||
|
void reload();
|
||||||
void exportT42();
|
void exportT42();
|
||||||
void exportZXNet();
|
void exportZXNet();
|
||||||
void exportEditTF();
|
void exportEditTF();
|
||||||
|
|||||||
Reference in New Issue
Block a user