Skip to content

Commit

Permalink
Use a list in accounts UI
Browse files Browse the repository at this point in the history
Preparation for multiple cloud services: change the UI to show a list of
accounts, even though there's only Crowdin for now.
  • Loading branch information
vslavik committed Jul 6, 2023
1 parent dc97aed commit bea8099
Show file tree
Hide file tree
Showing 16 changed files with 195 additions and 84 deletions.
4 changes: 2 additions & 2 deletions Poedit.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="src\accounts_ui.cpp" />
<ClCompile Include="src\attentionbar.cpp" />
<ClCompile Include="src\catalog.cpp" />
<ClCompile Include="src\catalog_json.cpp" />
Expand All @@ -117,6 +116,7 @@
<ClCompile Include="src\cat_sorting.cpp" />
<ClCompile Include="src\cat_update.cpp" />
<ClCompile Include="src\chooselang.cpp" />
<ClCompile Include="src\cloud_accounts_ui.cpp" />
<ClCompile Include="src\colorscheme.cpp" />
<ClCompile Include="src\commentdlg.cpp" />
<ClCompile Include="src\concurrency.cpp" />
Expand Down Expand Up @@ -172,7 +172,6 @@
<ClCompile Include="src\wx\main_toolbar.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\accounts_ui.h" />
<ClInclude Include="src\attentionbar.h" />
<ClInclude Include="src\catalog.h" />
<ClInclude Include="src\catalog_json.h" />
Expand All @@ -181,6 +180,7 @@
<ClInclude Include="src\cat_sorting.h" />
<ClInclude Include="src\cat_update.h" />
<ClInclude Include="src\chooselang.h" />
<ClInclude Include="src\cloud_accounts_ui.h" />
<ClInclude Include="src\cloud_sync.h" />
<ClInclude Include="src\colorscheme.h" />
<ClInclude Include="src\commentdlg.h" />
Expand Down
12 changes: 6 additions & 6 deletions Poedit.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\accounts_ui.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\attentionbar.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand All @@ -30,6 +27,9 @@
<ClCompile Include="src\catalog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\cloud_accounts_ui.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\commentdlg.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -200,9 +200,6 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\accounts_ui.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\attentionbar.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -359,6 +356,9 @@
<ClInclude Include="src\pretranslate.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\cloud_accounts_ui.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\cloud_sync.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
24 changes: 18 additions & 6 deletions Poedit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,15 @@
B29B282119D2E87600D27DC8 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = B29B281F19D2E87600D27DC8 /* [email protected] */; };
B2A012B321BEE4C5008051FD /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = B2E7F16F1E04534A005FA992 /* [email protected] */; };
B2A3637C1E4B9DC800E96253 /* pretranslate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2A3637A1E4B9DC800E96253 /* pretranslate.cpp */; };
B2B5A3652A4B31870045FC33 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = B2B5A3622A4B31870045FC33 /* [email protected] */; };
B2B5A3662A4B31870045FC33 /* AccountCrowdin.png in Resources */ = {isa = PBXBuildFile; fileRef = B2B5A3632A4B31870045FC33 /* AccountCrowdin.png */; };
B2B5A3672A4B31870045FC33 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = B2B5A3642A4B31870045FC33 /* [email protected] */; };
B2B6065525F100F3006186A9 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2B6065425F100F3006186A9 /* WebKit.framework */; };
B2B7D472170DD93E00ED0AFE /* GettextTools.bundle in Copy Gettext bundle */ = {isa = PBXBuildFile; fileRef = B248B2DE170D765100EBA58E /* GettextTools.bundle */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
B2B7E81A1AD94194007FC4EB /* libwx_osx_base_static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B2B7E8191AD94194007FC4EB /* libwx_osx_base_static.a */; };
B2BC828B20A1F0DC007652D6 /* catalog_po.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2BC828920A1F0DC007652D6 /* catalog_po.cpp */; };
B2BC828C20A34AB6007652D6 /* catalog_po.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2BC828920A1F0DC007652D6 /* catalog_po.cpp */; };
B2BCE2E72A44B112005CA5A7 /* accounts_ui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2BCE2E52A44B112005CA5A7 /* accounts_ui.cpp */; };
B2BCE2E72A44B112005CA5A7 /* cloud_accounts_ui.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B2BCE2E52A44B112005CA5A7 /* cloud_accounts_ui.cpp */; };
B2BF84BE170847220030AA22 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B2BF84BD170847220030AA22 /* libz.dylib */; };
B2BF84C1170847E60030AA22 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2BF84C0170847E60030AA22 /* IOKit.framework */; };
B2BF84C4170849D00030AA22 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2BF84BB170846940030AA22 /* Carbon.framework */; };
Expand Down Expand Up @@ -515,14 +518,17 @@
B2AEFE131A3210CB003BEFAF /* ro */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ro; path = ro.lproj/InfoPlist.strings; sourceTree = "<group>"; };
B2AEFE141A3210CB003BEFAF /* ro */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ro; path = ro.lproj/MoveApplication.strings; sourceTree = "<group>"; };
B2B133431CF7522B009BBA1A /* json.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = json.h; sourceTree = "<group>"; };
B2B5A3622A4B31870045FC33 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
B2B5A3632A4B31870045FC33 /* AccountCrowdin.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = AccountCrowdin.png; sourceTree = "<group>"; };
B2B5A3642A4B31870045FC33 /* [email protected] */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "[email protected]"; sourceTree = "<group>"; };
B2B6065425F100F3006186A9 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
B2B7E8191AD94194007FC4EB /* libwx_osx_base_static.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libwx_osx_base_static.a; sourceTree = BUILT_PRODUCTS_DIR; };
B2B814851E82F7B70050DCBF /* ga */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ga; path = ga.lproj/InfoPlist.strings; sourceTree = "<group>"; };
B2B814861E82F7B80050DCBF /* ga */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ga; path = ga.lproj/MoveApplication.strings; sourceTree = "<group>"; };
B2BC828920A1F0DC007652D6 /* catalog_po.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = catalog_po.cpp; sourceTree = "<group>"; };
B2BC828A20A1F0DC007652D6 /* catalog_po.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catalog_po.h; sourceTree = "<group>"; };
B2BCE2E52A44B112005CA5A7 /* accounts_ui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = accounts_ui.cpp; sourceTree = "<group>"; };
B2BCE2E62A44B112005CA5A7 /* accounts_ui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = accounts_ui.h; sourceTree = "<group>"; };
B2BCE2E52A44B112005CA5A7 /* cloud_accounts_ui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cloud_accounts_ui.cpp; sourceTree = "<group>"; };
B2BCE2E62A44B112005CA5A7 /* cloud_accounts_ui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cloud_accounts_ui.h; sourceTree = "<group>"; };
B2BF84BB170846940030AA22 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
B2BF84BD170847220030AA22 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
B2BF84C0170847E60030AA22 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -743,14 +749,14 @@
isa = PBXGroup;
children = (
B25504A51A2201CC00EE2CEE /* Native */,
B2BCE2E52A44B112005CA5A7 /* accounts_ui.cpp */,
B2BCE2E62A44B112005CA5A7 /* accounts_ui.h */,
B28F1CB116F629D30018AF7E /* attentionbar.cpp */,
B28F1CB216F629D30018AF7E /* attentionbar.h */,
B28F1CD616F629D30018AF7E /* cat_update.cpp */,
B28F1CD716F629D30018AF7E /* cat_update.h */,
B28F1CB316F629D30018AF7E /* cat_sorting.cpp */,
B28F1CB416F629D30018AF7E /* cat_sorting.h */,
B2BCE2E52A44B112005CA5A7 /* cloud_accounts_ui.cpp */,
B2BCE2E62A44B112005CA5A7 /* cloud_accounts_ui.h */,
B28F1CB616F629D30018AF7E /* chooselang.cpp */,
B28F1CAD16F629D30018AF7E /* chooselang.h */,
B28602421DDB279400FCA617 /* colorscheme.cpp */,
Expand Down Expand Up @@ -1034,6 +1040,9 @@
B2B1EB0619E45FE7009A59B7 /* Toolbar */,
B2166F4019AE4024000A6AA0 /* Preferences */,
B24ACD8316F6263900399242 /* Poedit.iconset */,
B2B5A3632A4B31870045FC33 /* AccountCrowdin.png */,
B2B5A3642A4B31870045FC33 /* [email protected] */,
B2B5A3622A4B31870045FC33 /* [email protected] */,
B26E2C8D25A245BD008D6DF1 /* CloseButtonHoverTemplate.png */,
B26E2C8A25A245BC008D6DF1 /* [email protected] */,
B26E2C8C25A245BC008D6DF1 /* CloseButtonTemplate.png */,
Expand Down Expand Up @@ -1269,6 +1278,7 @@
B26E2C8E25A245BD008D6DF1 /* [email protected] in Resources */,
B290F9E32166543800741842 /* [email protected] in Resources */,
B292667421664C9500DC536C /* ItemCommentTemplate.png in Resources */,
B2B5A3662A4B31870045FC33 /* AccountCrowdin.png in Resources */,
B290F9E42166543800741842 /* DownvoteTemplate.png in Resources */,
B29AE89017103992008D1F8A /* comment.xrc in Resources */,
B26E2C8F25A245BD008D6DF1 /* [email protected] in Resources */,
Expand All @@ -1279,6 +1289,7 @@
B2CE2FEB1A94EBDE0020A620 /* CrowdinLogoTemplate.png in Resources */,
B2CE2FF21A94F19D0020A620 /* Prefs-Accounts.png in Resources */,
B2E3EE4E256D658500FCE1BF /* Prefs-Advanced.png in Resources */,
B2B5A3672A4B31870045FC33 /* [email protected] in Resources */,
B29B282119D2E87600D27DC8 /* [email protected] in Resources */,
B2D52B861DE88A3D00E27B35 /* SuggestionPerfectMatch.png in Resources */,
B29AE89217103992008D1F8A /* manager.xrc in Resources */,
Expand All @@ -1295,6 +1306,7 @@
B24D196A1E84503B00C6DD8D /* [email protected] in Resources */,
B26897B4197A830200B42764 /* MoveApplication.strings in Resources */,
B292667521664C9500DC536C /* [email protected] in Resources */,
B2B5A3652A4B31870045FC33 /* [email protected] in Resources */,
B22A5C82184E4B870034BEFD /* [email protected] in Resources */,
B2166F4B19AE4045000A6AA0 /* Prefs-General.png in Resources */,
B209005E19CAD64400D6382E /* SuggestionTMTemplate.png in Resources */,
Expand Down Expand Up @@ -1511,7 +1523,7 @@
B28F1D0016F629D30018AF7E /* export_html.cpp in Sources */,
B230E2281A73F81400FB1E57 /* hidpi.cpp in Sources */,
B280E84D1A92776D009F4A98 /* http_client_macos.mm in Sources */,
B2BCE2E72A44B112005CA5A7 /* accounts_ui.cpp in Sources */,
B2BCE2E72A44B112005CA5A7 /* cloud_accounts_ui.cpp in Sources */,
B22C5F0A17DDC67400ECAFD1 /* language.cpp in Sources */,
B2E2184C199A76B100EA2784 /* syntaxhighlighter.cpp in Sources */,
B26E2C8625A24541008D6DF1 /* menus.cpp in Sources */,
Expand Down
Binary file added artwork/AccountCrowdin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added artwork/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added artwork/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions artwork/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dist_uiicons_DATA = \
linux/poedit-update.png \
linux/poedit-validate.png \
linux/sidebar.png \
AccountCrowdin.png \
CrowdinLogoTemplate.png \
DownvoteTemplate.png \
ExtractorsGNUgettext.png \
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ WX_BACKPORT_SRC = wx_backports/wx_gtk_activityindicator.cpp \
if HAVE_CPPREST
CROWDIN_SUPPORT_SRC = \
http_client.h http_client.cpp http_client_casablanca.cpp \
accounts_ui.h accounts_ui.cpp \
cloud_accounts_ui.h cloud_accounts_ui.cpp \
crowdin_client.h crowdin_client.cpp \
crowdin_gui.h crowdin_gui.cpp \
keychain/keytar_posix.cc keychain/keytar.h \
Expand Down
51 changes: 0 additions & 51 deletions src/accounts_ui.cpp

This file was deleted.

99 changes: 99 additions & 0 deletions src/cloud_accounts_ui.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* This file is part of Poedit (https://poedit.net)
*
* Copyright (C) 2023 Vaclav Slavik
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/

#include "cloud_accounts_ui.h"

#ifdef HAVE_HTTP_CLIENT

#include "customcontrols.h"
#include "crowdin_client.h"
#include "crowdin_gui.h"
#include "utility.h"

#include <wx/simplebook.h>
#include <wx/sizer.h>


AccountsPanel::AccountsPanel(wxWindow *parent) : wxPanel(parent, wxID_ANY)
{
wxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
SetSizer(sizer);

m_list = new IconAndSubtitleListCtrl(this, _("Account"), MSW_OR_OTHER(wxBORDER_SIMPLE, wxBORDER_SUNKEN));
sizer->Add(m_list, wxSizerFlags().Expand().Border(wxRIGHT, PX(10)));

m_panelsBook = new wxSimplebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | MSW_OR_OTHER(wxBORDER_SIMPLE, wxBORDER_SUNKEN));
ColorScheme::SetupWindowColors(m_panelsBook, [=]
{
if (ColorScheme::GetWindowMode(m_panelsBook) == ColorScheme::Light)
m_panelsBook->SetBackgroundColour(*wxWHITE);
else
m_panelsBook->SetBackgroundColour(wxNullColour);
});

sizer->Add(m_panelsBook, wxSizerFlags(1).Expand());

AddAccount("Crowdin", "AccountCrowdin", new CrowdinLoginPanel(m_panelsBook));

m_list->SetMinSize(wxSize(PX(180), -1));
m_panelsBook->SetMinSize(wxSize(PX(320), -1));

m_list->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &AccountsPanel::OnSelectAccount, this);
}


void AccountsPanel::InitializeAfterShown()
{
for (auto& p: m_panels)
p->EnsureInitialized();
}


void AccountsPanel::AddAccount(const wxString& name, const wxString& iconId, AccountDetailPanel *panel)
{
auto pos = (unsigned)m_panels.size();
m_panels.push_back(panel);
m_panelsBook->AddPage(panel, "");

m_list->AppendFormattedItem(wxArtProvider::GetBitmap(iconId), name, " ... ");

panel->OnContentChanged = [=]{
wxString desc = panel->IsSignedIn() ? panel->GetLoginName() : _("(not signed in)");
m_list->UpdateFormattedItem(pos, name, desc);
};
}


void AccountsPanel::OnSelectAccount(wxDataViewEvent& event)
{
auto index = m_list->ItemToRow(event.GetItem());
if (index == wxNOT_FOUND || index >= (int)m_panels.size())
return;

m_panelsBook->SetSelection(index);
}


#endif // #ifdef HAVE_HTTP_CLIENT
Loading

0 comments on commit bea8099

Please sign in to comment.