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_CloseDocumentAction_Triggered(bool* actionCancelled, bool* actionDelayed, bool suppressSaving) {
    Document* oldDoc = Application::I()->CurrentDocument();
    if (oldDoc == 0) {
        WARNING("No current document set");
        return;
    }

    if (oldDoc->HasUnsavedData() && (suppressSaving == false)) {
        CustomMessageBox msg(this, "Current document has been changed. Save it?", "Save document?",
                             QMessageBox::Question, QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
        QMessageBox::StandardButton result = msg.show();

        if (result == QMessageBox::Cancel) {
            if (actionCancelled) {
                *actionCancelled = true;
            }
            return;
        }
        if (result == QMessageBox::Yes) {
            bool saveCancelled = false;
            sl_SaveDocumentAction_Triggered(&saveCancelled);
            if (saveCancelled) {
                if (actionCancelled) {
                    *actionCancelled = saveCancelled;
                }
                return;
            }

            closeDocumentAfterSave = true;
            if (actionDelayed) {
                *actionDelayed = true;
            }
            return;
        }
    }

    documentUpdateCheckTimer.stop();
    Application::I()->SetCurrentDocument(0);
    notesTabWidget->Clear();
    delete oldDoc;
}