|
21 | 21 | #include "ProgressDialog.h" |
22 | 22 | #include "unzip.h" |
23 | 23 | #include "CheckedList/CheckedList.h" |
24 | | -#include "common/Utility.h" |
25 | 24 | #include "common/ProgressData.h" |
| 25 | +#include "common/Utility.h" |
| 26 | +#include "common/WindowsDefs.h" |
26 | 27 | #include "common/string_utils.h" |
27 | 28 | #include "common/winapi.h" |
28 | | -#include "common/WindowsDefs.h" |
29 | 29 | #include "network/GithubFileListProvider.h" |
30 | 30 | #include "network/UrlHelpers.h" |
| 31 | +#include "npp/EditorInterface.h" |
31 | 32 | #include "plugin/Constants.h" |
32 | 33 | #include "plugin/Plugin.h" |
33 | | -#include "plugin/resource.h" |
34 | 34 | #include "plugin/Settings.h" |
| 35 | +#include "plugin/resource.h" |
35 | 36 | #include "spellers/HunspellInterface.h" |
36 | 37 | #include "spellers/SpellerContainer.h" |
37 | 38 |
|
| 39 | +#include <Wininet.h> |
38 | 40 | #include <fcntl.h> |
| 41 | +#include <filesystem> |
39 | 42 | #include <io.h> |
40 | 43 | #include <variant> |
41 | | -#include <Wininet.h> |
| 44 | + |
| 45 | +namespace fs = std::filesystem; |
42 | 46 |
|
43 | 47 | void DownloadDictionariesDialog::do_dialog() { |
44 | 48 | if (!isCreated()) { |
@@ -76,8 +80,8 @@ DownloadDictionariesDialog::~DownloadDictionariesDialog() { |
76 | 80 | DestroyIcon(m_refresh_icon); |
77 | 81 | } |
78 | 82 |
|
79 | | -DownloadDictionariesDialog::DownloadDictionariesDialog(HINSTANCE h_inst, HWND parent, const Settings &settings, const SpellerContainer &speller_container) |
80 | | - : m_settings(settings), m_github_provider(std::make_unique<GitHubFileListProvider>(parent, settings)), m_speller_container(speller_container) { |
| 83 | +DownloadDictionariesDialog::DownloadDictionariesDialog(HINSTANCE h_inst, HWND parent, const Settings &settings, const SpellerContainer &speller_container, const EditorInterface &editor) |
| 84 | + : m_settings(settings), m_github_provider(std::make_unique<GitHubFileListProvider>(parent, settings)), m_speller_container(speller_container), m_editor(editor) { |
81 | 85 | m_github_provider->file_list_received.connect([this](const std::vector<FileDescription> &list) { on_new_file_list(list); }); |
82 | 86 | m_github_provider->error_happened.connect([this](const std::string &description) { |
83 | 87 | auto wstr = to_wstring(description); |
@@ -135,8 +139,13 @@ bool DownloadDictionariesDialog::prepare_downloading() { |
135 | 139 | p->get_progress_data()->set(0, L""); |
136 | 140 | get_progress_dlg()->update(); |
137 | 141 | p->set_top_message(L""); |
| 142 | + std::wstring dictionary_path; |
| 143 | + if (m_settings.data.download_install_dictionaries_for_all_users) |
| 144 | + dictionary_path = fs::weakly_canonical(fs::path(m_editor.get_editor_directory()) / m_settings.data.hunspell_system_path).wstring(); |
| 145 | + else |
| 146 | + dictionary_path = m_settings.data.hunspell_user_path; |
138 | 147 | if (!check_for_directory_existence( |
139 | | - m_settings.data.download_install_dictionaries_for_all_users ? m_settings.data.hunspell_system_path : m_settings.data.hunspell_user_path, |
| 148 | + dictionary_path, |
140 | 149 | false, |
141 | 150 | _hParent)) // If path doesn't exist we're gonna try to create it |
142 | 151 | // else it's finish |
|
0 commit comments