bool ApplicationEventFilter::eventFilter(QObject *watched, QEvent *event) { Q_UNUSED(watched); switch (event->type()) { default: return false; case QEvent::TabletEnterProximity: { emit tabletEntered(static_cast<QTabletEvent *>(event)); return true; } case QEvent::TabletLeaveProximity: { emit tabletLeft(static_cast<QTabletEvent *>(event)); return true; } case QEvent::FileOpen: { auto fileOpenEvent = static_cast<QFileOpenEvent *>(event); emit fileOpenRequested(fileOpenEvent->file()); return true; } } }
void TextEditor::recentFileClicked(QString fileName, QString folderName, QString content) { newFolder = folderName; newFile = fileName; // Check if the content was changed. if(content!=currentContent) { emit openRecentToBeConfirmed(currentFile); return; } // Not changed -> ok to open. fileOpenRequested(newFile); }
AppController::AppController(Application *app, QObject *parent) : QObject(parent), d(new Data) { d->app = app; d->formatSupportManager = new FormatSupportManager(this); d->blendModeTexts = new BlendModeTexts(this); d->workspaceManager = new WorkspaceManager(this); d->extensionManager = new ExtensionManager(this); d->settingsManager = new SettingsManager(this); d->cursorStack = new CursorStack(this); d->documentReferenceManager = new DocumentReferenceManager(this); _instance = this; declareMenus(); createActions(); connect(app, SIGNAL(fileOpenRequested(QString)), this, SLOT(openFile(QString))); }
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))); }
// Discard changes and proceed with "Open recent" void TextEditor::openRecentConfirmed() { fileOpenRequested(newFile); }