// Discard changes and proceed with "New" or "Open" void TextEditor::newOrOpenConfirmed(QString op) { if(op=="new") { currentFile = tr(UNTITLED); currentContent = ""; emit editorCleared(currentFolder,currentFile); } else if(op=="open") { bool saveRequested = false; emit browseRequested(currentFolder, saveRequested); } }
TextEditor::TextEditor(QObject *qml, RecentFiles *recentfiles, QObject *parent) : QObject(parent) { currentFolder = "file:///home/user"; newFolder = currentFolder; //currentFolder = QDesktopServices::storageLocation(QDesktopServices::HomeLocation); //qDebug() << currentFolder; currentFile = tr(UNTITLED); currentContent = ""; recentFiles = recentfiles; // connect QML signals to TextEditor slots connect(qml, SIGNAL(menuOpenClicked(QString)), this, SLOT(menuOpenClicked(QString))); connect(qml, SIGNAL(toolSaveClicked(QString)), this, SLOT(toolSaveClicked(QString))); connect(qml, SIGNAL(toolRecentClicked()), this, SLOT(toolRecentClicked())); connect(qml, SIGNAL(menuSaveAsClicked()), this, SLOT(menuSaveAsClicked())); connect(qml, SIGNAL(saveAsRequested(QString,QString)), this, SLOT(saveAsRequested(QString,QString))); connect(qml, SIGNAL(newFolderChanged(QString)), this, SLOT(newFolderChanged(QString))); connect(qml, SIGNAL(fileOpenRequested(QString)), this, SLOT(fileOpenRequested(QString))); connect(qml, SIGNAL(saveAsConfirmed(QString)), this, SLOT(saveAsConfirmed(QString))); connect(qml, SIGNAL(newOrOpenConfirmed(QString)), this, SLOT(newOrOpenConfirmed(QString))); connect(qml, SIGNAL(openRecentConfirmed()), this, SLOT(openRecentConfirmed())); connect(qml, SIGNAL(menuQuitClicked(QString)), this, SLOT(menuQuitClicked(QString))); connect(qml, SIGNAL(saveBeforeClosed(QString)), this, SLOT(saveBeforeClosed(QString))); connect(qml, SIGNAL(menuNewClicked(QString)), this, SLOT(menuNewClicked(QString))); connect(qml, SIGNAL(recentFileClicked(QString,QString,QString)), this, SLOT(recentFileClicked(QString,QString,QString))); // connect TextEditor signals to QML signals connect(this, SIGNAL(browseRequested(QString,bool)), qml, SLOT(browseRequested(QString,bool))); connect(this, SIGNAL(recentRequested()), qml, SLOT(recentRequested())); connect(this, SIGNAL(openCompleted(QString,QString,QString)), qml, SLOT(openCompleted(QString,QString,QString))); connect(this, SIGNAL(openFailed(QString,QString)), qml, SLOT(openFailed(QString,QString))); connect(this, SIGNAL(saveCompleted()), qml, SLOT(saveCompleted())); connect(this, SIGNAL(saveFailed(QString,QString)), qml, SLOT(saveFailed(QString,QString))); connect(this, SIGNAL(saveAsCompleted(QString,QString)), qml, SLOT(saveAsCompleted(QString,QString))); connect(this, SIGNAL(saveAsToBeConfirmed(QString)), qml, SLOT(saveAsToBeConfirmed(QString))); connect(this, SIGNAL(newOrOpenToBeConfirmed(QString,QString)), qml, SLOT(newOrOpenToBeConfirmed(QString,QString))); connect(this, SIGNAL(openRecentToBeConfirmed(QString)), qml, SLOT(openRecentToBeConfirmed(QString))); connect(this, SIGNAL(appCloseToBeConfirmed(QString)), qml, SLOT(appCloseToBeConfirmed(QString))); connect(this, SIGNAL(appToBeClosed()), qml, SLOT(appToBeClosed())); connect(this, SIGNAL(editorCleared(QString,QString)), qml, SLOT(editorCleared(QString,QString))); }
void EditWidget::clearEditor() { ui.medEditor->clear(); emit editorCleared(); }