void MainWindow::updateWindowTitle() { Document* doc = Application::I()->CurrentDocument(); if (doc == 0) { setWindowTitle(VER_PRODUCTNAME_STR); setWindowModified(false); } else { QString title; title = doc->GetFilename().isEmpty() ? "<unsaved>" : doc->GetFilename(); title.append("[*] - ").append(VER_PRODUCTNAME_STR); setWindowModified(doc->HasUnsavedData()); setWindowTitle(title); } }
void MainWindow::sl_Application_CurrentDocumentChanged(Document* oldDoc) { if (oldDoc) { QObject::disconnect(oldDoc, 0, this, 0); } Document* doc = Application::I()->CurrentDocument(); engine->SetTargetDocument(doc); if (searchResultsWidget) { searchResultsWidget->ClearResults(); searchResultsWidget->hide(); } navigationPanel->SetTargetDocument(doc); bookmarksMenu->SetDocument(doc); if (doc) { QObject::connect(doc, SIGNAL(sg_Changed()), this, SLOT(sl_CurrentDocument_Changed())); QObject::connect(doc, SIGNAL(sg_ItemUnregistered(Note*)), this, SLOT(sl_Application_NoteDeleted(Note*))); QObject::connect(doc, SIGNAL(sg_SavingAborted()), this, SLOT(sl_Document_SavingAborted())); QObject::connect(doc, SIGNAL(sg_SavingFailed(QString)), this, SLOT(sl_Document_SavingFailed(QString))); QObject::connect(doc, SIGNAL(sg_SavingFinished()), this, SLOT(sl_Document_SavingFinished())); QObject::connect(doc, SIGNAL(sg_SavingProgress(int)), this, SLOT(sl_Document_SavingFinished())); QObject::connect(doc, SIGNAL(sg_SavingStarted()), this, SLOT(sl_Document_SavingStarted())); Application::I()->Settings.SetLastDocumentName(doc->GetFilename()); } sl_EditMenuContentChanged(); // Actions bool enable = (doc != 0); saveDocumentAction->setEnabled(enable); saveDocumentAsAction->setEnabled(enable); closeDocumentAction->setEnabled(enable); documentPropertiesAction->setEnabled(enable); globalSearchAction->setEnabled(enable); sl_Clipboard_DataChanged(); updateWindowTitle(); }
void MainWindow::sl_SaveDocumentAction_Triggered(bool* actionCancelled) { Document* doc = Application::I()->CurrentDocument(); if (!doc) { WARNING("No current document set"); return; } QString filename = QString(); if (doc->GetFilename().isEmpty()) { filename = QFileDialog::getSaveFileName(this, "Select a name", QString(), "qNotesManager save file (*.nms)"); if (filename.isNull() || filename.isEmpty()) { if (actionCancelled) { *actionCancelled = true; } return; } newRecentFile(filename); } doc->Save(filename); }