From d387ed11456e40f36f359cb3aa9f74a54b8f369b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 9 Mar 2022 16:01:24 +0300 Subject: popup control moved from main menu to Options - Popups - Enabled items --- plugins/Db_autobackups/src/backup.cpp | 4 ++-- plugins/Db_autobackups/src/main.cpp | 39 +++++++++-------------------------- plugins/Db_autobackups/src/stdafx.h | 12 +++++------ 3 files changed, 18 insertions(+), 37 deletions(-) (limited to 'plugins/Db_autobackups/src') diff --git a/plugins/Db_autobackups/src/backup.cpp b/plugins/Db_autobackups/src/backup.cpp index 21d3f0d826..0dab268428 100644 --- a/plugins/Db_autobackups/src/backup.cpp +++ b/plugins/Db_autobackups/src/backup.cpp @@ -232,7 +232,7 @@ static int Backup(wchar_t *backup_filename) bZip = true; } - if (!g_plugin.disable_popups) + if (g_plugin.bPopups) ShowPopup(dbname, TranslateT("Backup in progress"), nullptr); HWND progress_dialog = nullptr; @@ -276,7 +276,7 @@ static int Backup(wchar_t *backup_filename) wchar_t *pd = wcsrchr(dest_file, '\\'); - if (!g_plugin.disable_popups) { + if (g_plugin.bPopups) { CMStringW puText; if (pd && mir_wstrlen(dest_file) > 50) { diff --git a/plugins/Db_autobackups/src/main.cpp b/plugins/Db_autobackups/src/main.cpp index 1b898f31c2..b629e5c657 100644 --- a/plugins/Db_autobackups/src/main.cpp +++ b/plugins/Db_autobackups/src/main.cpp @@ -2,7 +2,6 @@ CMPlugin g_plugin; -HGENMENU g_hPopupMenu; HANDLE hFolder; char g_szMirVer[100]; @@ -35,22 +34,13 @@ CMPlugin::CMPlugin() : num_backups(MODULENAME, "NumBackups", 3), file_mask(MODULENAME, "FileMask", L"%miranda_profilename%_%currtime%_%compname%"), disable_progress(MODULENAME, "NoProgress", 0), - disable_popups(MODULENAME, "NoPopups", 0), + bPopups(MODULENAME, "Popups", 1), use_zip(MODULENAME, "UseZip", 0), backup_profile(MODULENAME, "BackupProfile", 0), use_cloudfile(MODULENAME, "UseCloudFile", 0), cloudfile_service(MODULENAME, "CloudFileService", nullptr) { -} - -///////////////////////////////////////////////////////////////////////////////////////// - -static void UpdateMenuIcons() -{ - if (g_plugin.disable_popups) - Menu_ModifyItem(g_hPopupMenu, LPGENW("Enable &AutoBackups notification"), Skin_GetIconHandle(SKINICON_OTHER_NOPOPUP)); - else - Menu_ModifyItem(g_hPopupMenu, LPGENW("Disable &AutoBackups notification"), Skin_GetIconHandle(SKINICON_OTHER_POPUP)); + folder[0] = 0; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -91,13 +81,6 @@ static int FoldersGetBackupPath(WPARAM, LPARAM) return 0; } -static INT_PTR OnTogglePopups(WPARAM, LPARAM) -{ - g_plugin.disable_popups = !g_plugin.disable_popups; - UpdateMenuIcons(); - return 0; -} - static int PluginLoaded(WPARAM, LPARAM) { g_plugin.bCloudFilePresent = ServiceExists(MS_CLOUDFILE_UPLOAD); @@ -126,15 +109,6 @@ static int ModulesLoad(WPARAM, LPARAM) mi.position = 500100001; Menu_AddMainMenuItem(&mi); - // Popup menu item - SET_UID(mi, 0xe9250a75, 0x30da, 0x42f2, 0x85, 0x27, 0x54, 0x24, 0x62, 0x59, 0x9e, 0xae); - mi.position = 0; - mi.root = g_plugin.addRootMenu(MO_MAIN, LPGENW("Popups"), 0); - mi.pszService = "DbAutoBackup/EnableDisableMenuCommand"; - g_hPopupMenu = Menu_AddMainMenuItem(&mi); - UpdateMenuIcons(); - CreateServiceFunction(mi.pszService, &OnTogglePopups); - if (hFolder = FoldersRegisterCustomPathW(LPGEN("Database backups"), LPGEN("Backup folder"), DIR SUB_DIR)) { HookEvent(ME_FOLDERS_PATH_CHANGED, FoldersGetBackupPath); FoldersGetBackupPath(0, 0); @@ -171,6 +145,11 @@ static int OkToExit(WPARAM, LPARAM) int CMPlugin::Load() { + if (getBool("NoPopups")) { + bPopups = false; + delSetting("NoPopups"); + } + Miranda_GetVersionText(g_szMirVer, sizeof(g_szMirVer)); HookEvent(ME_SYSTEM_OKTOEXIT, OkToExit); @@ -178,7 +157,9 @@ int CMPlugin::Load() HookEvent(ME_SYSTEM_MODULELOAD, PluginLoaded); HookEvent(ME_SYSTEM_MODULEUNLOAD, PluginLoaded); - g_plugin.registerIcon(LPGEN("Database") "/" LPGEN("Database backups"), iconList); + addPopupOption(LPGEN("AutoBackups notifications"), bPopups); + + registerIcon(LPGEN("Database") "/" LPGEN("Database backups"), iconList); CreateServiceFunction(MS_AB_BACKUP, ABService); CreateServiceFunction(MS_AB_SAVEAS, DBSaveAs); diff --git a/plugins/Db_autobackups/src/stdafx.h b/plugins/Db_autobackups/src/stdafx.h index 9c84fc678c..f569f099bd 100644 --- a/plugins/Db_autobackups/src/stdafx.h +++ b/plugins/Db_autobackups/src/stdafx.h @@ -38,20 +38,20 @@ struct CMPlugin : public PLUGIN CMPlugin(); bool bCloudFilePresent = false; - HANDLE hevBackup; + HANDLE hevBackup = nullptr; wchar_t folder[MAX_PATH]; CMOption backup_types; - CMOption period; + CMOption period; CMOption period_type; - CMOption file_mask; - CMOption num_backups; + CMOption file_mask; + CMOption num_backups; CMOption disable_progress; - CMOption disable_popups; + CMOption bPopups; CMOption use_zip; CMOption backup_profile; CMOption use_cloudfile; - CMOption cloudfile_service; + CMOption cloudfile_service; int Load() override; }; -- cgit v1.2.3