| 116 | } |
| 117 | |
| 118 | void ChatHistoryStore::showSaveDialog() |
| 119 | { |
| 120 | QString initialDir = historyDir(); |
| 121 | |
| 122 | QFileDialog *dialog = new QFileDialog(nullptr, tr("Save Chat History")); |
| 123 | dialog->setAcceptMode(QFileDialog::AcceptSave); |
| 124 | dialog->setFileMode(QFileDialog::AnyFile); |
| 125 | dialog->setNameFilter(tr("JSON files (*.json)")); |
| 126 | dialog->setDefaultSuffix("json"); |
| 127 | if (!initialDir.isEmpty()) { |
| 128 | dialog->setDirectory(initialDir); |
| 129 | dialog->selectFile(suggestedFileName() + ".json"); |
| 130 | } |
| 131 | |
| 132 | connect(dialog, &QFileDialog::finished, this, [this, dialog](int result) { |
| 133 | if (result == QFileDialog::Accepted) { |
| 134 | QStringList files = dialog->selectedFiles(); |
| 135 | if (!files.isEmpty()) { |
| 136 | emit saveRequested(files.first()); |
| 137 | } |
| 138 | } |
| 139 | dialog->deleteLater(); |
| 140 | }); |
| 141 | |
| 142 | dialog->open(); |
| 143 | } |
| 144 | |
| 145 | void ChatHistoryStore::showLoadDialog() |
| 146 | { |