From b39f8c6ab6b8d83b190571ba2065615494b34c47 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 5 Jan 2021 23:57:32 +0300 Subject: =?UTF-8?q?fixes=20#2658=20(=D0=92=D1=8B=D0=BD=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=B8=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D1=83?= =?UTF-8?q?=20=D1=86=D0=B2=D0=B5=D1=82=D0=B0=20=D0=BF=D0=BE=D0=BF=D0=B0?= =?UTF-8?q?=D0=BF=D0=BE=D0=B2=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B0=20=D0=B1=D0=B0=D0=B7=D1=8B=20=D0=B2=20=D0=BE=D1=82?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BD=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B8)=20+=20=D1=86=D0=B2=D0=B5?= =?UTF-8?q?=D1=82=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B0=20+=20=D1=87?= =?UTF-8?q?=D0=B8=D1=81=D1=82=D0=BA=D0=B0=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/DbEditorPP/src/deletemodule.cpp | 2 +- plugins/DbEditorPP/src/main.cpp | 11 +++- plugins/DbEditorPP/src/main_window.cpp | 12 ++-- plugins/DbEditorPP/src/moduletree.cpp | 2 +- plugins/DbEditorPP/src/options.cpp | 103 ++++++++++++++++---------------- plugins/DbEditorPP/src/resource.h | 6 +- plugins/DbEditorPP/src/settinglist.cpp | 2 +- plugins/DbEditorPP/src/stdafx.h | 66 ++++++++++---------- plugins/DbEditorPP/src/version.h | 2 +- plugins/DbEditorPP/src/watchedvars.cpp | 25 ++++---- 10 files changed, 120 insertions(+), 111 deletions(-) (limited to 'plugins/DbEditorPP/src') diff --git a/plugins/DbEditorPP/src/deletemodule.cpp b/plugins/DbEditorPP/src/deletemodule.cpp index fadb491816..7c0eea7c2f 100644 --- a/plugins/DbEditorPP/src/deletemodule.cpp +++ b/plugins/DbEditorPP/src/deletemodule.cpp @@ -8,7 +8,7 @@ int deleteModule(MCONTACT hContact, const char *module, int confirm) if (!module || IsModuleEmpty(hContact, module)) return 0; - if (confirm && g_plugin.getByte("WarnOnDelete", 1)) { + if (confirm && g_plugin.bWarnOnDelete) { wchar_t text[MSG_SIZE]; mir_snwprintf(text, TranslateT("Are you sure you want to delete module \"%s\"?"), _A2T(module).get()); if (dlg(text, MB_YESNO | MB_ICONEXCLAMATION) == IDNO) diff --git a/plugins/DbEditorPP/src/main.cpp b/plugins/DbEditorPP/src/main.cpp index 564ed97d0f..d954cf1b89 100644 --- a/plugins/DbEditorPP/src/main.cpp +++ b/plugins/DbEditorPP/src/main.cpp @@ -33,8 +33,15 @@ PLUGININFOEX pluginInfoEx = }; CMPlugin::CMPlugin() : - PLUGIN(MODULENAME, pluginInfoEx) -{} + PLUGIN(MODULENAME, pluginInfoEx), + iPopupDelay(MODULENAME, "PopupDelay", 4), + iPopupBkColor(MODULENAME, "PopupColour", RGB(255, 0, 0)), + iPopupTxtColor(MODULENAME, "PopupTextColour", RGB(0, 0, 0)), + bWarnOnDelete(MODULENAME, "WarnOnDelete", true), + bRestoreOnOpen(MODULENAME, "RestoreOnOpen", true), + bExpandSettingsOnOpen(MODULENAME, "ExpandSettingsOnOpen", false) +{ +} ///////////////////////////////////////////////////////////////////////////////////////// // we implement service mode interface diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp index 1f81ee24a8..680851e7ac 100644 --- a/plugins/DbEditorPP/src/main_window.cpp +++ b/plugins/DbEditorPP/src/main_window.cpp @@ -247,7 +247,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) CheckMenuItem(GetSubMenu(hMenu, 5), MENU_WORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_WORD) ? MF_CHECKED : MF_UNCHECKED)); CheckMenuItem(GetSubMenu(hMenu, 5), MENU_DWORD_HEX, MF_BYCOMMAND | ((g_Hex & HEX_DWORD) ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (g_plugin.getByte("RestoreOnOpen", 1) ? MF_CHECKED : MF_UNCHECKED)); + CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (g_plugin.bRestoreOnOpen ? MF_CHECKED : MF_UNCHECKED)); g_Order = g_plugin.getByte("SortMode", 1); CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SORT_ORDER, MF_BYCOMMAND | (g_Order ? MF_CHECKED : MF_UNCHECKED)); @@ -255,7 +255,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) int restore; if (hRestore) restore = 3; - else if (g_plugin.getByte("RestoreOnOpen", 1)) + else if (g_plugin.bRestoreOnOpen) restore = 2; else restore = 0; @@ -304,7 +304,7 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; case WM_DESTROY: // free our shit! - if (g_plugin.getByte("RestoreOnOpen", 1)) { + if (g_plugin.bRestoreOnOpen) { HTREEITEM item; if (item = TreeView_GetSelection(hwnd2Tree)) { @@ -491,9 +491,9 @@ INT_PTR CALLBACK MainDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break; case MENU_SAVE_POSITION: { - BOOL save = !g_plugin.getByte("RestoreOnOpen", 1); - CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (save ? MF_CHECKED : MF_UNCHECKED)); - g_plugin.setByte("RestoreOnOpen", (byte)save); + bool bSave = !g_plugin.bRestoreOnOpen; + CheckMenuItem(GetSubMenu(GetMenu(hwnd), 5), MENU_SAVE_POSITION, MF_BYCOMMAND | (bSave ? MF_CHECKED : MF_UNCHECKED)); + g_plugin.bRestoreOnOpen = bSave; } break; case MENU_INLINE_EDIT: diff --git a/plugins/DbEditorPP/src/moduletree.cpp b/plugins/DbEditorPP/src/moduletree.cpp index f5048a6567..1bfc5ff05e 100644 --- a/plugins/DbEditorPP/src/moduletree.cpp +++ b/plugins/DbEditorPP/src/moduletree.cpp @@ -403,7 +403,7 @@ void __cdecl PopulateModuleTreeThreadFunc(LPVOID param) insertItem(hContact, module->name, contact); } - if (g_plugin.getByte("ExpandSettingsOnOpen", 0)) + if (g_plugin.bExpandSettingsOnOpen) TreeView_Expand(hwnd2Tree, contact, TVE_EXPAND); if (Select && hSelectedContact == NULL) { diff --git a/plugins/DbEditorPP/src/options.cpp b/plugins/DbEditorPP/src/options.cpp index 870f1d2ea0..ad2892ff9e 100644 --- a/plugins/DbEditorPP/src/options.cpp +++ b/plugins/DbEditorPP/src/options.cpp @@ -1,67 +1,66 @@ #include "stdafx.h" -static INT_PTR CALLBACK DlgProcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +class COptionsDlg : public CDlgBase { - static bool bInitDone = true; - switch (msg) { - case WM_INITDIALOG: - bInitDone = false; - CheckDlgButton(hwnd, IDC_EXPANDSETTINGS, g_plugin.getByte("ExpandSettingsOnOpen", 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwnd, IDC_RESTORESETTINGS, g_plugin.getByte("RestoreOnOpen", 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwnd, IDC_WARNONDEL, g_plugin.getByte("WarnOnDelete", 1) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwnd, IDC_POPUPS, g_bUsePopups ? BST_CHECKED : BST_UNCHECKED); - SetDlgItemInt(hwnd, IDC_POPUPTIMEOUT, g_plugin.getWord("PopupDelay", 4), 0); - SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_SETCOLOUR, 0, (LPARAM)g_plugin.getDword("PopupColour", RGB(255, 0, 0))); - TranslateDialogDefault(hwnd); - bInitDone = true; - return TRUE; + CCtrlCheck chkExpand, chkRestore, chkWarnDelete; - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_RESTORESETTINGS: - case IDC_EXPANDSETTINGS: - case IDC_POPUPS: - case IDC_WARNONDEL: - case IDC_COLOUR: - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; +public: + COptionsDlg() : + CDlgBase(g_plugin, IDD_OPTIONS), + chkExpand(this, IDC_EXPANDSETTINGS), + chkRestore(this, IDC_RESTORESETTINGS), + chkWarnDelete(this, IDC_WARNONDEL) + { + CreateLink(chkExpand, g_plugin.bExpandSettingsOnOpen); + CreateLink(chkRestore, g_plugin.bRestoreOnOpen); + CreateLink(chkWarnDelete, g_plugin.bWarnOnDelete); + } +}; - case IDC_POPUPTIMEOUT: - if (bInitDone && (HIWORD(wParam) == EN_CHANGE)) - SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0); - break; - } - break; +class CPopupOptionsDlg : public CDlgBase +{ + CCtrlEdit edtTimeout; + CCtrlCheck chkUsePopups; + CCtrlColor clrBack, clrText; - case WM_NOTIFY: - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_APPLY: - g_plugin.setByte("ExpandSettingsOnOpen", (BYTE)IsDlgButtonChecked(hwnd, IDC_EXPANDSETTINGS)); - g_plugin.setByte("RestoreOnOpen", (BYTE)IsDlgButtonChecked(hwnd, IDC_RESTORESETTINGS)); - g_plugin.setByte("WarnOnDelete", (BYTE)IsDlgButtonChecked(hwnd, IDC_WARNONDEL)); - g_bUsePopups = IsDlgButtonChecked(hwnd, IDC_POPUPS) != 0; - g_plugin.setByte("UsePopUps", (BYTE)g_bUsePopups); - g_plugin.setWord("PopupDelay", (WORD)GetDlgItemInt(hwnd, IDC_POPUPTIMEOUT, nullptr, 0)); - g_plugin.setDword("PopupColour", (DWORD)SendDlgItemMessage(hwnd, IDC_COLOUR, CPM_GETCOLOUR, 0, 0)); - return TRUE; - } - break; - } - break; +public: + CPopupOptionsDlg() : + CDlgBase(g_plugin, IDD_POPUP_OPTS), + clrBack(this, IDC_COLOUR), + clrText(this, IDC_TXT_COLOUR), + edtTimeout(this, IDC_POPUPTIMEOUT), + chkUsePopups(this, IDC_POPUPS) + { + CreateLink(clrBack, g_plugin.iPopupBkColor); + CreateLink(clrText, g_plugin.iPopupTxtColor); + CreateLink(edtTimeout, g_plugin.iPopupDelay); } - return FALSE; -} + + bool OnInitDialog() override + { + chkUsePopups.SetState(g_bUsePopups); + return true; + } + + bool OnApply() override + { + g_plugin.setByte("UsePopUps", g_bUsePopups = chkUsePopups.GetState()); + return true; + } +}; INT OptInit(WPARAM wParam, LPARAM) { OPTIONSDIALOGPAGE odp = {}; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS); - odp.szGroup.a = LPGEN("Database"); - odp.szTitle.a = modFullname; - odp.pfnDlgProc = DlgProcOpts; odp.flags = ODPF_BOLDGROUPS; + odp.szTitle.a = modFullname; + + odp.szGroup.a = LPGEN("Database"); + odp.pDialog = new COptionsDlg(); + g_plugin.addOptions(wParam, &odp); + + odp.szGroup.a = LPGEN("Popups"); + odp.pDialog = new CPopupOptionsDlg(); g_plugin.addOptions(wParam, &odp); return 0; } diff --git a/plugins/DbEditorPP/src/resource.h b/plugins/DbEditorPP/src/resource.h index f8e379b8c5..cd785d9e54 100644 --- a/plugins/DbEditorPP/src/resource.h +++ b/plugins/DbEditorPP/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by E:\Miranda\NG\plugins\DbeditorPP\res\resource.rc +// Used by w:\miranda-ng\plugins\DbEditorPP\res\resource.rc // #define ICO_REGEDIT 1 #define ICO_UNICODE 2 @@ -28,6 +28,7 @@ #define IDD_CHANGE_ARRAYSIZE 120 #define IDD_FIND 121 #define IDD_OPTIONS 122 +#define IDD_POPUP_OPTS 123 #define ICO_CLOSED 124 #define ICO_OPENED 125 #define ICO_SETTINGS 128 @@ -76,6 +77,7 @@ #define IDC_POPUPTIMEOUT 1049 #define IDC_COLOUR 1050 #define IDC_RESTORESETTINGS 1051 +#define IDC_TXT_COLOUR 1051 #define IDC_BLOB 1052 #define IDC_FOUND 1056 #define IDC_SBAR 1057 @@ -145,7 +147,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 131 +#define _APS_NEXT_RESOURCE_VALUE 132 #define _APS_NEXT_COMMAND_VALUE 40065 #define _APS_NEXT_CONTROL_VALUE 1059 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/plugins/DbEditorPP/src/settinglist.cpp b/plugins/DbEditorPP/src/settinglist.cpp index e60e15f2d5..96264fd906 100644 --- a/plugins/DbEditorPP/src/settinglist.cpp +++ b/plugins/DbEditorPP/src/settinglist.cpp @@ -124,7 +124,7 @@ void DeleteSettingsFromList(MCONTACT hContact, const char *module, const char *s if (!count) return; - if (g_plugin.getByte("WarnOnDelete", 1)) { + if (g_plugin.bWarnOnDelete) { wchar_t text[MSG_SIZE]; mir_snwprintf(text, TranslateT("Are you sure you want to delete setting(s): %d?"), count); if (dlg(text, MB_YESNO | MB_ICONEXCLAMATION) == IDNO) diff --git a/plugins/DbEditorPP/src/stdafx.h b/plugins/DbEditorPP/src/stdafx.h index 56f5fc0c08..048e49168f 100644 --- a/plugins/DbEditorPP/src/stdafx.h +++ b/plugins/DbEditorPP/src/stdafx.h @@ -17,37 +17,41 @@ #include #include -#include #include -#include -#include #include #include -#include +#include +#include +#include +#include +#include #include -#include -#include #include -#include #include -#include -#include -#include +#include +#include +#include +#include +#include #include "m_toptoolbar.h" #include "resource.h" #include "version.h" - //======================================================= // Definitions //======================================================= + #define MODULENAME "DBEditorpp" #define modFullname "Database Editor++" struct CMPlugin : public PLUGIN { + CMOption bExpandSettingsOnOpen, bRestoreOnOpen, bWarnOnDelete; + CMOption iPopupDelay; + CMOption iPopupBkColor, iPopupTxtColor; + CMPlugin(); int Load() override; @@ -63,7 +67,6 @@ struct CMPlugin : public PLUGIN #define WM_FINDITEM (WM_USER + 1) // onyl for the main window, wparam is ItemIfno* lparam is 0 - /*********************** ModuleTreeInfoStruct this gets dumped as the lparam for each module tree item @@ -76,14 +79,14 @@ struct CMPlugin : public PLUGIN #define STUB 4 #define EMPTY 8 - -struct ModuleTreeInfoStruct { +struct ModuleTreeInfoStruct +{ int type; // from above types MCONTACT hContact; }; - -struct SettingListInfo { +struct SettingListInfo +{ MCONTACT hContact; int selectedItem; // item that is currently selected char module[FLD_SIZE]; @@ -93,35 +96,37 @@ struct SettingListInfo { int subitem; }; - -struct DBsetting { +struct DBsetting +{ MCONTACT hContact; char *module; char *setting; DBVARIANT dbv; }; - -typedef struct { +struct ModuleAndContact +{ char module[FLD_SIZE]; MCONTACT hContact; -} ModuleAndContact; +}; // find window #define FW_MODULE 0 #define FW_SETTINGNAME 1 #define FW_SETTINGVALUE 2 -typedef struct { +struct ItemInfo +{ int type; // above types MCONTACT hContact; char module[FLD_SIZE]; char setting[FLD_SIZE]; -} ItemInfo; +}; // watchwindow -struct WatchListArrayStruct { - struct DBsetting *item; // gotta malloc this +struct WatchListArrayStruct +{ + DBsetting *item; // gotta malloc this int count; int size; }; @@ -139,21 +144,23 @@ struct ModuleSettingLL ModSetLinkLinkItem *last; }; -struct ColumnsSettings { +struct ColumnsSettings +{ wchar_t *name; int index; char *dbname; int defsize; }; -struct ColumnsSortParams { +struct ColumnsSortParams +{ HWND hList; int column; int last; }; - -enum ICONS { +enum ICONS +{ IMAGE_EMPTY, IMAGE_BINARY, IMAGE_BYTE, @@ -170,7 +177,6 @@ enum ICONS { IMAGE_OFFLINE }; - //======================================================= // Variables //======================================================= diff --git a/plugins/DbEditorPP/src/version.h b/plugins/DbEditorPP/src/version.h index 837746b063..94ec411e83 100644 --- a/plugins/DbEditorPP/src/version.h +++ b/plugins/DbEditorPP/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 4 #define __MINOR_VERSION 0 #define __RELEASE_NUM 1 -#define __BUILD_NUM 3 +#define __BUILD_NUM 4 #include diff --git a/plugins/DbEditorPP/src/watchedvars.cpp b/plugins/DbEditorPP/src/watchedvars.cpp index cc4e945452..47270f09c6 100644 --- a/plugins/DbEditorPP/src/watchedvars.cpp +++ b/plugins/DbEditorPP/src/watchedvars.cpp @@ -342,25 +342,20 @@ void openWatchedVarWindow() void popupWatchedVar(MCONTACT hContact, const char *module, const char *setting) { - COLORREF colorBack = g_plugin.getDword("PopupColour", RGB(255, 0, 0)); - COLORREF colorText = g_plugin.getDword("PopupTextColour", RGB(0, 0, 0)); - int timeout = g_plugin.getByte("PopupDelay", 3); - - wchar_t name[NAME_SIZE], text[MAX_SECONDLINE], value[MAX_SECONDLINE]; - GetContactName(hContact, nullptr, name, _countof(name)); - - // 2nd line + int timeout = g_plugin.iPopupDelay; + + wchar_t value[MAX_SECONDLINE]; int type = GetValue(hContact, module, setting, value, _countof(value)); - mir_snwprintf(text, TranslateT("Database Setting Changed: \nModule: \"%s\", Setting: \"%s\"\nNew Value (%s): \"%s\""), - _A2T(module).get(), _A2T(setting).get(), DBVType(type), value); POPUPDATAW ppd; - ppd.lchContact = (MCONTACT)hContact; + GetContactName(hContact, nullptr, ppd.lpwzContactName, _countof(ppd.lpwzContactName)); + mir_snwprintf(ppd.lpwzText, TranslateT("Database Setting Changed: \nModule: \"%s\", Setting: \"%s\"\nNew Value (%s): \"%s\""), + _A2T(module).get(), _A2T(setting).get(), DBVType(type), value); + + ppd.lchContact = hContact; ppd.lchIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(ICO_REGEDIT)); - mir_wstrncpy(ppd.lpwzContactName, name, _countof(ppd.lpwzContactName)); - mir_wstrncpy(ppd.lpwzText, text, _countof(ppd.lpwzText)); - ppd.colorBack = colorBack; - ppd.colorText = colorText; + ppd.colorBack = g_plugin.iPopupBkColor; + ppd.colorText = g_plugin.iPopupTxtColor; ppd.iSeconds = timeout ? timeout : -1; PUAddPopupW(&ppd); } -- cgit v1.2.3