From f52dffefb1a8efa4d6a4c4dad3edbc3384e82c72 Mon Sep 17 00:00:00 2001 From: Brian Ferguson Date: Mon, 12 Nov 2012 13:02:01 -0700 Subject: [PATCH] Added SkinPath, ConfigEditor, and TrayIcon to Manage/Settings dialog Also added Help button to Manage dialog --- Language/Resource.rc | 35 +++++++++----- Library/DialogManage.cpp | 100 ++++++++++++++++++++++++++++++++++++++- Library/DialogManage.h | 1 - Library/Rainmeter.cpp | 24 ++++++++++ Library/Rainmeter.h | 2 + Library/TrayWindow.cpp | 19 ++++++++ Library/TrayWindow.h | 1 + Library/resource.h | 6 +++ 8 files changed, 173 insertions(+), 15 deletions(-) diff --git a/Language/Resource.rc b/Language/Resource.rc index dc8d41fd..7f5cd79d 100644 --- a/Language/Resource.rc +++ b/Language/Resource.rc @@ -1,4 +1,5 @@ #include +#include #include "../Library/resource.h" #include "../Version.h" @@ -203,6 +204,7 @@ FONT 8, "MS Shell Dlg 2", 0, 0, 0x0 PUSHBUTTON STR_REFRESHALL, IDC_MANAGE_REFRESHALL_BUTTON, 5, 303, NUM_BUTTONWIDTH, 14 PUSHBUTTON STR_EDITSETTINGS, IDC_MANAGE_EDITSETTINGS_BUTTON, NUM_BUTTONWIDTH + 9, 303, NUM_BUTTONWIDTH, 14 PUSHBUTTON STR_OPENLOG, IDC_MANAGE_OPENLOG_BUTTON, NUM_BUTTONWIDTH + NUM_BUTTONWIDTH + 13, 303, NUM_BUTTONWIDTH, 14 + PUSHBUTTON STR_HELP, IDC_MANAGE_HELP_BUTTON, 444 - 50 - 5, 303, 50, 14 PUSHBUTTON STR_CLOSE, IDCLOSE, 444, 303, 50, 14 } @@ -232,12 +234,12 @@ FONT 8, "MS Shell Dlg 2", 0, 0, 0x0 CONTROL "", IDC_STATIC, STATIC, SS_ETCHEDHORZ | WS_CHILD | WS_VISIBLE, 165, 156, 304, 1 LTEXT STR_COORDINATESSC, IDC_STATIC, 165, 169, NUM_LABELWIDTH, 9 - EDITTEXT IDC_MANAGESKINS_X_TEXT, 165 + NUM_LABELWIDTH, 166, 38, 14, WS_BORDER | WS_TABSTOP | WS_DISABLED + EDITTEXT IDC_MANAGESKINS_X_TEXT, 165 + NUM_LABELWIDTH, 166, 38, 14, ES_NUMBER | WS_BORDER | WS_TABSTOP | WS_DISABLED EDITTEXT IDC_MANAGESKINS_Y_TEXT, 165 + NUM_LABELWIDTH + 42, 166, 38, 14, ES_NUMBER | WS_BORDER | WS_TABSTOP | WS_DISABLED LTEXT STR_POSITIONSC, IDC_STATIC, 165, 190, NUM_LABELWIDTH, 9 COMBOBOX IDC_MANAGESKINS_ZPOSITION_COMBOBOX, 165 + NUM_LABELWIDTH, 187, 80, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | WS_DISABLED LTEXT STR_LOADORDERSC, IDC_STATIC, 165, 208, NUM_LABELWIDTH, 9 - EDITTEXT IDC_MANAGESKINS_LOADORDER_TEXT, 165 + NUM_LABELWIDTH, 205, 80, 14, WS_BORDER | WS_TABSTOP | WS_DISABLED + EDITTEXT IDC_MANAGESKINS_LOADORDER_TEXT, 165 + NUM_LABELWIDTH, 205, 80, 14, ES_NUMBER | WS_BORDER | WS_TABSTOP | WS_DISABLED LTEXT STR_TRANSPARENCYSC, IDC_STATIC, 165, 229, NUM_LABELWIDTH, 9 COMBOBOX IDC_MANAGESKINS_TRANSPARENCY_COMBOBOX, 165 + NUM_LABELWIDTH, 226, 80, 14, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | WS_DISABLED LTEXT STR_ONHOVERSC, IDC_STATIC, 165, 247, NUM_LABELWIDTH, 9 @@ -278,19 +280,26 @@ IDD_MANAGESETTINGS_DIALOG DIALOGEX 15, 30, 470, 260 STYLE DS_CONTROL | WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS FONT 8, "MS Shell Dlg 2", 0, 0, 0x0 { - GROUPBOX STR_GENERAL, IDC_STATIC, 0, 0, 468, 86 - LTEXT STR_LANGUAGESC, IDC_STATIC, 6, 16, 87, 44 - COMBOBOX IDC_MANAGESETTINGS_LANGUAGE_COMBOBOX, 87, 13, 140, 14, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP + GROUPBOX STR_GENERAL, IDC_STATIC, 0, 0, 468, 132 + LTEXT STR_LANGUAGESC, IDC_STATIC, 6, 16, 87, 14 + COMBOBOX IDC_MANAGESETTINGS_LANGUAGE_COMBOBOX, 87, 13, 222, 14, CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP //AUTOCHECKBOX "Run automatically at startup", IDC_MANAGESETTINGS_AUTOSTART_CHECKBOX, 6, 16, 140, 9, WS_DISABLED - AUTOCHECKBOX STR_CHECKFORUPDATES, IDC_MANAGESETTINGS_CHECKUPDATES_CHECKBOX, 6, 34, 200, 9 - AUTOCHECKBOX STR_DISABLEDRAGGING, IDC_MANAGESETTINGS_LOCKSKINS_CHECKBOX, 6, 47, 200, 9 - PUSHBUTTON STR_RESETSTATISTICS, IDC_MANAGESETTINGS_RESETSTATISTICS_BUTTON, 6, 64, NUM_BUTTONWIDTH + 20, 14 + LTEXT "Skin Path:", IDC_STATIC, 6, 35, 87, 14 + EDITTEXT IDC_MANAGESETTINGS_SKINPATH_TEXT, 87, 32, 222, 14, ES_AUTOHSCROLL | WS_DISABLED | WS_BORDER | WS_TABSTOP + PUSHBUTTON "...", IDC_MANAGESETTINGS_SKINPATH_BUTTON, 317, 32, 25, 14, WS_TABSTOP + LTEXT "ConfigEditor:", IDC_STATIC, 6, 54, 87, 14 + EDITTEXT IDC_MANAGESETTINGS_CONFIGEDITOR_TEXT, 87, 51, 222, 14, ES_AUTOHSCROLL | WS_DISABLED | WS_BORDER | WS_TABSTOP + PUSHBUTTON "...", IDC_MANAGESETTINGS_CONFIGEDITOR_BUTTON, 317, 51, 25, 14, WS_TABSTOP + AUTOCHECKBOX STR_CHECKFORUPDATES, IDC_MANAGESETTINGS_CHECKUPDATES_CHECKBOX, 6, 73, 150, 9 + AUTOCHECKBOX STR_DISABLEDRAGGING, IDC_MANAGESETTINGS_LOCKSKINS_CHECKBOX, 6, 86, 150, 9 + AUTOCHECKBOX "Show tray icon", IDC_MANAGESETTINGS_TRAYICON_CHECKBOX, 6, 99, 150, 9 + PUSHBUTTON STR_RESETSTATISTICS, IDC_MANAGESETTINGS_RESETSTATISTICS_BUTTON, 6, 112, NUM_BUTTONWIDTH + 20, 14, WS_TABSTOP - GROUPBOX STR_LOGGING, IDC_STATIC, 0, 91, 468, 68 - AUTOCHECKBOX STR_DEBUGMODE, IDC_MANAGESETTINGS_VERBOSELOGGING_CHECKBOX, 6, 107, 200, 9 - AUTOCHECKBOX STR_LOGTOFILE, IDC_MANAGESETTINGS_LOGTOFILE_CHECKBOX, 6, 120, 200, 9 - PUSHBUTTON STR_SHOWLOGFILE, IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON, 6, 137, NUM_BUTTONWIDTH + 20, 14 - PUSHBUTTON STR_DELETELOGFILE, IDC_MANAGESETTINGS_DELETELOGFILE_BUTTON, NUM_BUTTONWIDTH + 30, 137, NUM_BUTTONWIDTH + 20, 14 + GROUPBOX STR_LOGGING, IDC_STATIC, 0, 135, 468, 66 + AUTOCHECKBOX STR_DEBUGMODE, IDC_MANAGESETTINGS_VERBOSELOGGING_CHECKBOX, 6, 152, 200, 9 + AUTOCHECKBOX STR_LOGTOFILE, IDC_MANAGESETTINGS_LOGTOFILE_CHECKBOX, 6, 166, 200, 9 + PUSHBUTTON STR_SHOWLOGFILE, IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON, 6, 180, NUM_BUTTONWIDTH + 20, 14 + PUSHBUTTON STR_DELETELOGFILE, IDC_MANAGESETTINGS_DELETELOGFILE_BUTTON, NUM_BUTTONWIDTH + 30, 180, NUM_BUTTONWIDTH + 20, 14 } ///////////////////////////////////////////////////////////////////////////// diff --git a/Library/DialogManage.cpp b/Library/DialogManage.cpp index beb18430..54dff7ba 100644 --- a/Library/DialogManage.cpp +++ b/Library/DialogManage.cpp @@ -26,6 +26,7 @@ #include "DialogManage.h" #include "DialogAbout.h" #include "../Version.h" +#include #define WM_DELAYED_CLOSE WM_APP + 0 @@ -267,6 +268,28 @@ INT_PTR CDialogManage::OnCommand(WPARAM wParam, LPARAM lParam) PostMessage(m_Window, WM_DELAYED_CLOSE, 0, 0); break; + case IDC_MANAGE_HELP_BUTTON: + { + std::wstring url = L"http://docs.rainmeter.net/"; + + HWND hwnd = c_Dialog->GetActiveTabWindow(); + if (hwnd == m_TabSkins.GetWindow()) + { + url.append(L"manual/user-interface/manage#SkinsTab"); + } + else if (hwnd == m_TabLayouts.GetWindow()) + { + url.append(L"/manual/user-interface/manage#LayoutsTab"); + } + else if (hwnd == m_TabSettings.GetWindow()) + { + url.append(L"/manual/user-interface/manage#SettingsTab"); + } + + ShellExecute(m_Window, L"open", url.c_str(), NULL, NULL, SW_SHOWNORMAL); + } + break; + default: return FALSE; } @@ -1649,6 +1672,12 @@ void CDialogManage::CTabSettings::Initialize() BOOL isLogFile = (_waccess(Rainmeter->GetLogFile().c_str(), 0) != -1); EnableWindow(GetDlgItem(m_Window, IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON), isLogFile); EnableWindow(GetDlgItem(m_Window, IDC_MANAGESETTINGS_DELETELOGFILE_BUTTON), isLogFile); + + Edit_SetText(GetDlgItem(m_Window, IDC_MANAGESETTINGS_SKINPATH_TEXT), Rainmeter->GetSkinPath().c_str()); + Edit_SetText(GetDlgItem(m_Window, IDC_MANAGESETTINGS_CONFIGEDITOR_TEXT), Rainmeter->GetSkinEditor().c_str()); + + bool iconEnabled = Rainmeter->GetTrayWindow()->IsTrayIconEnabled(); + Button_SetCheck(GetDlgItem(m_Window, IDC_MANAGESETTINGS_TRAYICON_CHECKBOX), iconEnabled); } /* @@ -1762,9 +1791,78 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam) Rainmeter->SetDebug(!Rainmeter->GetDebug()); break; + case IDC_MANAGESETTINGS_SKINPATH_TEXT: + if (HIWORD(wParam) == EN_CHANGE) + { + WCHAR buffer[MAX_LINE_LENGTH]; + std::wstring skinPath = (GetWindowText((HWND)lParam, buffer, MAX_LINE_LENGTH) > 0) ? buffer : Rainmeter->GetSkinPath(); + Rainmeter->SetSkinPath(skinPath); + } + break; + + case IDC_MANAGESETTINGS_SKINPATH_BUTTON: + { + WCHAR buffer[MAX_PATH]; + WCHAR* temp; + BROWSEINFO bi = {0}; + bi.hwndOwner = c_Dialog->GetWindow(); + bi.lpszTitle = L"Select a new Skins folder:\r\n\r\nNote: Changes take place next time you load Rainmeter."; + bi.ulFlags = BIF_USENEWUI | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; + + PIDLIST_ABSOLUTE pidl = SHBrowseForFolder(&bi); + if (pidl && SHGetPathFromIDList(pidl, buffer)) + { + temp = wcscat(buffer, L"\\"); + Edit_SetText(GetDlgItem(m_Window, IDC_MANAGESETTINGS_SKINPATH_TEXT), temp); + CoTaskMemFree(pidl); + } + } + break; + + case IDC_MANAGESETTINGS_CONFIGEDITOR_TEXT: + if (HIWORD(wParam) == EN_CHANGE) + { + WCHAR buffer[MAX_LINE_LENGTH]; + std::wstring editor = (GetWindowText((HWND)lParam, buffer, MAX_LINE_LENGTH) > 0) ? buffer : L""; + Rainmeter->SetSkinEditor(editor); + } + break; + + case IDC_MANAGESETTINGS_CONFIGEDITOR_BUTTON: + { + WCHAR buffer[MAX_PATH]; + buffer[0] = L'\0'; + + std::wstring editor = Rainmeter->GetSkinEditor(); + editor = editor.substr(0, editor.find_last_of(L"/\\")).c_str(); + + OPENFILENAME ofn = { sizeof(OPENFILENAME) }; + ofn.Flags = OFN_FILEMUSTEXIST; + ofn.lpstrFilter = L"Executable File (.exe)\0*.exe"; + ofn.lpstrTitle = L"Select executable file"; + ofn.lpstrDefExt = L"exe"; + ofn.lpstrInitialDir = editor.c_str(); + ofn.nFilterIndex = 0; + ofn.lpstrFile = buffer; + ofn.nMaxFile = _countof(buffer); + ofn.hwndOwner = c_Dialog->GetWindow(); + + if (!GetOpenFileName(&ofn)) + { + break; + } + + Edit_SetText(GetDlgItem(m_Window, IDC_MANAGESETTINGS_CONFIGEDITOR_TEXT), buffer); + } + break; + + case IDC_MANAGESETTINGS_TRAYICON_CHECKBOX: + Rainmeter->GetTrayWindow()->SetTrayIcon(!Rainmeter->GetTrayWindow()->IsTrayIconEnabled()); + break; + default: return 1; } return 0; -} +} \ No newline at end of file diff --git a/Library/DialogManage.h b/Library/DialogManage.h index 1749982f..089b05e6 100644 --- a/Library/DialogManage.h +++ b/Library/DialogManage.h @@ -85,7 +85,6 @@ private: virtual void Initialize(); static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - INT_PTR OnNotify(WPARAM wParam, LPARAM lParam); INT_PTR OnCommand(WPARAM wParam, LPARAM lParam); }; diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index e8c0b44e..38ea1e1c 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -1498,6 +1498,30 @@ void CRainmeter::ToggleSkin(int folderIndex, int fileIndex) } } +void CRainmeter::SetSkinPath(std::wstring skinPath) +{ + WritePrivateProfileString(L"Rainmeter", L"SkinPath", skinPath.c_str(), m_IniFile.c_str()); +} + +void CRainmeter::SetSkinEditor(std::wstring editor) +{ + LPCWSTR tmp = editor.empty() ? NULL : editor.c_str(); + if (!tmp) + { + // Get the program path associated with .ini files + WCHAR buffer[MAX_PATH]; + DWORD cchOut = MAX_PATH; + HRESULT hr = AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L".ini", L"open", buffer, &cchOut); + m_SkinEditor = (SUCCEEDED(hr) && cchOut > 0) ? buffer : L"Notepad"; + } + else + { + m_SkinEditor = editor; + } + + WritePrivateProfileString(L"Rainmeter", L"ConfigEditor", tmp, m_IniFile.c_str()); +} + void CRainmeter::WriteActive(const std::wstring& folderPath, int fileIndex) { WCHAR buffer[32]; diff --git a/Library/Rainmeter.h b/Library/Rainmeter.h index 65b2e9ca..cb649df0 100644 --- a/Library/Rainmeter.h +++ b/Library/Rainmeter.h @@ -138,6 +138,7 @@ public: const std::wstring& GetLogFile() { return m_LogFile; } const std::wstring& GetSettingsPath() { return m_SettingsPath; } const std::wstring& GetSkinPath() { return m_SkinPath; } + void SetSkinPath(std::wstring skinPath); std::wstring GetLayoutPath() { return m_SettingsPath + L"Layouts\\"; } std::wstring GetPluginPath() { return m_Path + L"Plugins\\"; } std::wstring GetUserPluginPath() { return m_SettingsPath + L"Plugins\\"; } @@ -153,6 +154,7 @@ public: const std::wstring& GetDrive() { return m_Drive; } const std::wstring& GetSkinEditor() { return m_SkinEditor; } + void SetSkinEditor(std::wstring editor); const std::wstring& GetStatsDate() { return m_StatsDate; } HWND GetWindow() { return m_Window; } diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index 4070f88b..0c23b265 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -333,6 +333,25 @@ void CTrayWindow::ShowUpdateNotification(const WCHAR* newVersion) ShowNotification(TRAY_NOTIFICATION_UPDATE, GetString(ID_STR_UPDATEAVAILABLE), text.c_str()); } +void CTrayWindow::SetTrayIcon(bool state) +{ + std::wstring iniFile = Rainmeter->GetIniFile(); + + if (state) + { + // Delete the key from Rainmeter.ini + WritePrivateProfileString(L"Rainmeter", L"TrayIcon", NULL, iniFile.c_str()); + } + else + { + WritePrivateProfileString(L"Rainmeter", L"TrayIcon", L"0", iniFile.c_str()); + } + + CConfigParser parser; + parser.Initialize(iniFile, NULL, NULL); + ReadOptions(parser); +} + void CTrayWindow::ReadOptions(CConfigParser& parser) { // Clear old Settings diff --git a/Library/TrayWindow.h b/Library/TrayWindow.h index 801a417b..febbfc05 100644 --- a/Library/TrayWindow.h +++ b/Library/TrayWindow.h @@ -47,6 +47,7 @@ public: void ReadOptions(CConfigParser& parser); HWND GetWindow() { return m_Window; } bool IsTrayIconEnabled() { return m_IconEnabled; } + void SetTrayIcon(bool state); void ShowWelcomeNotification(); void ShowUpdateNotification(const WCHAR* newVersion); diff --git a/Library/resource.h b/Library/resource.h index 8300f52c..6b2fc9d8 100644 --- a/Library/resource.h +++ b/Library/resource.h @@ -44,6 +44,7 @@ #define IDC_MANAGE_REFRESHALL_BUTTON 1001 #define IDC_MANAGE_EDITSETTINGS_BUTTON 1002 #define IDC_MANAGE_OPENLOG_BUTTON 1003 +#define IDC_MANAGE_HELP_BUTTON 1004 #define IDC_MANAGESKINS_ACTIVESKINS_BUTTON 1000 #define IDC_MANAGESKINS_SKINS_TREEVIEW 1001 @@ -90,6 +91,11 @@ #define IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON 1005 #define IDC_MANAGESETTINGS_DELETELOGFILE_BUTTON 1006 #define IDC_MANAGESETTINGS_LANGUAGE_COMBOBOX 1007 +#define IDC_MANAGESETTINGS_SKINPATH_TEXT 1008 +#define IDC_MANAGESETTINGS_SKINPATH_BUTTON 1009 +#define IDC_MANAGESETTINGS_CONFIGEDITOR_TEXT 1010 +#define IDC_MANAGESETTINGS_CONFIGEDITOR_BUTTON 1011 +#define IDC_MANAGESETTINGS_TRAYICON_CHECKBOX 1012 #define ID_STR_ISRTL 2000 #define ID_STR_UPDATEAVAILABLE 2001