Author: ashaposhnikov
Date: Thu Jul 20 22:57:48 2017
New Revision: 75384
URL:
http://svn.reactos.org/svn/reactos?rev=75384&view=rev
Log:
[RAPPS] Improvements & multiple selections
- Improved translations view - storing LCIDs now
- Added checkboxes on list view and Select All button (although they do nothing just yet)
- Made download dialogs nonmodal (yay, download and install multiple apps at once!)
- Minor code improvements
Modified:
branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/en-US.rc
branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp
branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h
branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.rc
branches/GSoC_2017/rapps/reactos/base/applications/rapps/resource.h
branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/available.cpp [iso-8859-1]
Thu Jul 20 22:57:48 2017
@@ -84,23 +84,30 @@
// Parse parameter string
ATL::CStringW m_szLocale;
+ int iLCID;
for (INT i = 0; szBuffer[i] != UNICODE_NULL; ++i)
{
- if (szBuffer[i] != cDelimiter)
+ if (szBuffer[i] != cDelimiter && szBuffer[i] != L'\n')
{
m_szLocale += szBuffer[i];
}
else
{
- Languages.Add(m_szLocale);
- m_szLocale.Empty();
+ if (StrToIntExW(m_szLocale.GetString(), STIF_DEFAULT, &iLCID))
+ {
+ Languages.Add(static_cast<LCID>(iLCID));
+ m_szLocale.Empty();
+ }
}
}
// For the text after delimiter
if (!m_szLocale.IsEmpty())
{
- Languages.Add(m_szLocale);
+ if (StrToIntExW(m_szLocale.GetString(), STIF_DEFAULT, &iLCID))
+ {
+ Languages.Add(static_cast<LCID>(iLCID));
+ }
}
m_HasLanguageInfo = TRUE;
@@ -120,12 +127,7 @@
}
}
-BOOL CAvailableApplicationInfo::HasLanguageInfo() const
-{
- return m_HasLanguageInfo;
-}
-
-BOOL CAvailableApplicationInfo::HasNativeLanguage() const
+BOOL CAvailableApplicationInfo::FindInLanguages(LCID what) const
{
if (!m_HasLanguageInfo)
{
@@ -136,7 +138,7 @@
const INT nLanguagesSize = Languages.GetSize();
for (INT i = 0; i < nLanguagesSize; ++i)
{
- if (Languages[i] == CConfigParser::GetLocale())
+ if (Languages[i] == what)
{
return TRUE;
}
@@ -145,39 +147,19 @@
return FALSE;
}
+BOOL CAvailableApplicationInfo::HasLanguageInfo() const
+{
+ return m_HasLanguageInfo;
+}
+
+BOOL CAvailableApplicationInfo::HasNativeLanguage() const
+{
+ return FindInLanguages(GetUserDefaultLCID());
+}
+
BOOL CAvailableApplicationInfo::HasEnglishLanguage() const
{
- static ATL::CStringW szEnglishLocaleID;
- const INT cchLocaleSize = m_Parser.GetLocaleSize();
- if (!m_HasLanguageInfo)
- {
- return FALSE;
- }
-
- //Get English locale code
- if (szEnglishLocaleID.IsEmpty())
- {
- INT result = GetLocaleInfoW(MAKELCID(LANG_ENGLISH, SORT_DEFAULT),
LOCALE_ILANGUAGE,
- szEnglishLocaleID.GetBuffer(cchLocaleSize),
cchLocaleSize);
- szEnglishLocaleID.ReleaseBuffer();
- if (result != ERROR_SUCCESS)
- {
- return FALSE;
- }
-
- }
-
- //Find locale code in the list
- const INT nLanguagesSize = Languages.GetSize();
- for (INT i = 0; i < nLanguagesSize; ++i)
- {
- if (Languages[i] == szEnglishLocaleID)
- {
- return TRUE;
- }
- }
-
- return FALSE;
+ return FindInLanguages(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
SORT_DEFAULT));
}
BOOL CAvailableApplicationInfo::IsInstalled() const
@@ -397,7 +379,7 @@
// CAvailableApps
// CConfigParser
-ATL::CStringW CConfigParser::m_szLocale;
+ATL::CStringW CConfigParser::m_szLocaleID;
ATL::CStringW CConfigParser::m_szCachedINISectionLocale;
ATL::CStringW CConfigParser::m_szCachedINISectionLocaleNeutral;
@@ -410,7 +392,7 @@
ATL::CStringW CConfigParser::GetINIFullPath(const ATL::CStringW& FileName)
{
ATL::CStringW szDir;
- static ATL::CStringW szBuffer;
+ ATL::CStringW szBuffer;
GetStorageDirectory(szDir);
szBuffer.Format(L"%ls\\rapps\\%ls", szDir, FileName);
@@ -420,24 +402,25 @@
VOID CConfigParser::CacheINILocaleLazy()
{
- if (m_szLocale.IsEmpty())
+ if (m_szLocaleID.IsEmpty())
{
// TODO: Set default locale if call fails
// find out what is the current system lang code (e.g. "0a") and append
it to SectionLocale
- GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE,
- m_szLocale.GetBuffer(m_cchLocaleSize), m_cchLocaleSize);
- m_szLocale.ReleaseBuffer();
- m_szCachedINISectionLocale = L"Section." + m_szLocale;
+ GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_ILANGUAGE,
+ m_szLocaleID.GetBuffer(m_cchLocaleSize), m_cchLocaleSize);
+
+ m_szLocaleID.ReleaseBuffer();
+ m_szCachedINISectionLocale = L"Section." + m_szLocaleID;
// turn "Section.0c0a" into "Section.0a", keeping just the
neutral lang part
- m_szCachedINISectionLocaleNeutral = m_szCachedINISectionLocale +
m_szLocale.Right(2);
+ m_szCachedINISectionLocaleNeutral = m_szCachedINISectionLocale +
m_szLocaleID.Right(2);
}
}
const ATL::CStringW& CConfigParser::GetLocale()
{
CacheINILocaleLazy();
- return m_szLocale;
+ return m_szLocaleID;
}
INT CConfigParser::GetLocaleSize()
@@ -486,8 +469,6 @@
UINT CConfigParser::GetInt(const ATL::CStringW& KeyName)
{
ATL::CStringW Buffer;
- UNICODE_STRING BufferW;
- ULONG Result;
// grab the text version of our entry
if (!GetString(KeyName, Buffer))
@@ -497,9 +478,8 @@
return FALSE;
// convert it to an actual integer
- RtlInitUnicodeString(&BufferW, Buffer.GetString());
- RtlUnicodeStringToInteger(&BufferW, 0, &Result);
-
- return (UINT) Result;
-}
-// CConfigParser
+ int result = StrToIntW(Buffer.GetString());
+
+ return (UINT) (result <= 0) ? 0 : result;
+}
+// CConfigParser
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/gui.cpp [iso-8859-1] Thu Jul
20 22:57:48 2017
@@ -179,6 +179,7 @@
WCHAR szInstallBtn[MAX_STR_LEN];
WCHAR szUninstallBtn[MAX_STR_LEN];
WCHAR szModifyBtn[MAX_STR_LEN];
+ WCHAR szSelectAll[MAX_STR_LEN];
VOID AddImageToImageList(HIMAGELIST hImageList, UINT ImageIndex)
{
@@ -217,6 +218,7 @@
AddImageToImageList(hImageList, IDI_INSTALL);
AddImageToImageList(hImageList, IDI_UNINSTALL);
AddImageToImageList(hImageList, IDI_MODIFY);
+ AddImageToImageList(hImageList, IDI_CHECK_ALL);
AddImageToImageList(hImageList, IDI_REFRESH);
AddImageToImageList(hImageList, IDI_UPDATE_DB);
AddImageToImageList(hImageList, IDI_SETTINGS);
@@ -272,17 +274,19 @@
{ 0, ID_INSTALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0,
(INT_PTR) szInstallBtn },
{ 1, ID_UNINSTALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0,
(INT_PTR) szUninstallBtn },
{ 2, ID_MODIFY, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0,
(INT_PTR) szModifyBtn },
- { 5, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
- { 3, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0
},
- { 4, ID_RESETDB, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, {0}, 0, 0},
- { 5, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
- { 5, ID_SETTINGS, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0
},
- { 6, ID_EXIT, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 }
+ { 3, ID_CHECK_ALL, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE,{0}, 0,
(INT_PTR) szSelectAll},
+ {-1, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
+ { 4, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0
},
+ { 5, ID_RESETDB, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0
},
+ {-1, 0, TBSTATE_ENABLED, BTNS_SEP, { 0 }, 0, 0 },
+ { 6, ID_SETTINGS, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0
},
+ { 7, ID_EXIT, TBSTATE_ENABLED, BTNS_BUTTON | BTNS_AUTOSIZE, { 0 }, 0, 0 },
};
LoadStringW(hInst, IDS_INSTALL, szInstallBtn, _countof(szInstallBtn));
LoadStringW(hInst, IDS_UNINSTALL, szUninstallBtn, _countof(szUninstallBtn));
LoadStringW(hInst, IDS_MODIFY, szModifyBtn, _countof(szModifyBtn));
+ LoadStringW(hInst, IDS_SELECT_ALL, szSelectAll, _countof(szSelectAll));
m_hWnd = CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL,
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS
| TBSTYLE_LIST,
@@ -324,6 +328,7 @@
int iSubItem;
};
+ BOOL HasAllChecked;
public:
BOOL bAscending;
@@ -443,11 +448,20 @@
HWND hwnd = CListView::Create(hwndParent, r, NULL, style, WS_EX_CLIENTEDGE,
menu);
if (hwnd)
- SetExtendedListViewStyle(LVS_EX_FULLROWSELECT);
+ {
+ SetExtendedListViewStyle(LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT );
+ }
return hwnd;
}
+ VOID CheckAll()
+ {
+ if (HasAllChecked)
+ {
+
+ }
+ }
};
class CSideTreeView :
@@ -558,8 +572,8 @@
SearchEnabled(FALSE)
{
}
+
private:
-
VOID InitApplicationsList(VOID)
{
ATL::CStringW szText;
@@ -574,7 +588,8 @@
szText.LoadStringW(hInst, IDS_APP_DESCRIPTION);
m_ListView->AddColumn(3, szText, 250, LVCFMT_LEFT);
- //UpdateApplicationsList(ENUM_ALL_COMPONENTS);
+ // Unnesesary since the list updates on every TreeView selection
+ // UpdateApplicationsList(ENUM_ALL_COMPONENTS);
}
HTREEITEM AddCategory(HTREEITEM hRootItem, UINT TextIndex, UINT IconIndex)
@@ -1012,7 +1027,7 @@
if (data->hwndFrom == m_ListView->m_hWnd && ((LPNMLISTVIEW)
lParam)->iItem != -1)
{
/* this won't do anything if the program is already installed */
- SendMessage(hwnd, WM_COMMAND, ID_INSTALL, 0);
+ SendMessageW(hwnd, WM_COMMAND, ID_INSTALL, 0);
}
}
break;
@@ -1068,7 +1083,7 @@
if (wParam == SEARCH_TIMER_ID)
{
::KillTimer(hwnd, SEARCH_TIMER_ID);
- if(SearchEnabled)
+ if (SearchEnabled)
UpdateApplicationsList(-1);
}
break;
@@ -1247,6 +1262,9 @@
case ID_ABOUT:
ShowAboutDialog();
+ break;
+
+ case ID_CHECK_ALL:
break;
}
}
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/en-US.rc
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/en-US.rc [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/lang/en-US.rc [iso-8859-1]
Thu Jul 20 22:57:48 2017
@@ -91,7 +91,7 @@
END
IDD_DOWNLOAD_DIALOG DIALOGEX 0, 0, 220, 72
-STYLE DS_SHELLFONT | DS_CENTER | WS_BORDER | WS_CAPTION | WS_POPUP | WS_SYSMENU |
WS_VISIBLE
+STYLE DS_SHELLFONT | DS_CENTER | WS_POPUPWINDOW | WS_CAPTION | WS_VISIBLE
CAPTION "Downloading..."
FONT 8, "MS Shell Dlg"
BEGIN
@@ -207,6 +207,8 @@
IDS_INTEG_CHECK_FAIL "The package did not pass the integrity check, it may have
been corrupted or tampered with during downloading. Running the software is not
recommended."
IDS_INTERRUPTED_DOWNLOAD "The download was interrupted. Check connection to
Internet."
IDS_UNABLE_TO_WRITE "Unable to write to disk. Disk may be at capacity."
+ IDS_SELECT_ALL "Select/Desellect All"
+ IDS_INSTALL_SELECTED "Install Selected"
END
STRINGTABLE
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/loaddlg.cpp [iso-8859-1] Thu
Jul 20 22:57:48 2017
@@ -602,7 +602,7 @@
return FALSE;
case WM_CLOSE:
- EndDialog(Dlg, 0);
+ DestroyWindow(Dlg);
return TRUE;
default:
@@ -622,7 +622,7 @@
WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_INSTALL,
AppInfo->szName.GetString());
- DialogBoxW(hInst,
+ CreateDialogW(hInst,
MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG),
hMainWnd,
DownloadDlgProc);
@@ -638,7 +638,7 @@
AppInfo = &IntInfo;
- DialogBoxW(hInst,
+ CreateDialogW(hInst,
MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG),
hMainWnd,
DownloadDlgProc);
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.h [iso-8859-1] Thu Jul
20 22:57:48 2017
@@ -101,7 +101,7 @@
ATL::CStringW szUrlSite;
ATL::CStringW szUrlDownload;
ATL::CStringW szCDPath;
- ATL::CSimpleArray<ATL::CStringW> Languages;
+ ATL::CSimpleArray<LCID> Languages;
/* caching mechanism related entries */
ATL::CStringW sFileName;
@@ -146,7 +146,7 @@
class CConfigParser
{
// Loacale names cache
- static ATL::CStringW m_szLocale;
+ static ATL::CStringW m_szLocaleID;
const static INT m_cchLocaleSize = 5;
static ATL::CStringW m_szCachedINISectionLocale;
static ATL::CStringW m_szCachedINISectionLocaleNeutral;
@@ -200,6 +200,7 @@
VOID RetrieveInstalledVersion();
VOID RetrieveLanguages();
VOID RetrieveLicenseType();
+ inline BOOL FindInLanguages(LCID what) const;
};
class CAvailableApps
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.rc
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.rc [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/rapps.rc [iso-8859-1] Thu Jul
20 22:57:48 2017
@@ -22,6 +22,7 @@
IDI_APPUPD ICON "res/appupd.ico"
IDI_CATEGORY ICON "res/cat.ico"
IDI_UPDATE_DB ICON "res/updatedb.ico"
+IDI_CHECK_ALL ICON "res/checksheet.ico"
/* Categories */
IDI_CAT_AUDIO ICON "res/cats/audio.ico"
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/resource.h
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/resource.h [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/resource.h [iso-8859-1] Thu
Jul 20 22:57:48 2017
@@ -12,6 +12,7 @@
#define IDI_APPUPD 18
#define IDI_CATEGORY 19
#define IDI_UPDATE_DB 20
+#define IDI_CHECK_ALL 21
/* Icons for categories */
#define IDI_CAT_AUDIO 50
@@ -76,6 +77,7 @@
#define ID_REFRESH 559
#define ID_REGREMOVE 560
#define ID_RESETDB 561
+#define ID_CHECK_ALL 562
/* Strings */
#define IDS_APPTITLE 100
@@ -103,6 +105,8 @@
#define IDS_INTEG_CHECK_FAIL 123
#define IDS_INTERRUPTED_DOWNLOAD 124
#define IDS_UNABLE_TO_WRITE 125
+#define IDS_SELECT_ALL 126
+#define IDS_INSTALL_SELECTED 127
/* Tooltips */
#define IDS_TOOLTIP_INSTALL 200
Modified: branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2017/rapps/reactos/base/ap…
==============================================================================
--- branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp [iso-8859-1]
(original)
+++ branches/GSoC_2017/rapps/reactos/base/applications/rapps/winmain.cpp [iso-8859-1] Thu
Jul 20 22:57:48 2017
@@ -188,15 +188,15 @@
GetAvailableApps()->UpdateAppsDB();
/* Load the menu hotkeys */
- KeyBrd = LoadAccelerators(NULL, MAKEINTRESOURCE(HOTKEYS));
+ KeyBrd = LoadAcceleratorsW(NULL, MAKEINTRESOURCE(HOTKEYS));
/* Message Loop */
while (GetMessage(&Msg, NULL, 0, 0))
{
- if (!TranslateAccelerator(hMainWnd, KeyBrd, &Msg))
+ if (!TranslateAcceleratorW(hMainWnd, KeyBrd, &Msg))
{
TranslateMessage(&Msg);
- DispatchMessage(&Msg);
+ DispatchMessageW(&Msg);
}
}