Skip to content

Commit

Permalink
#5537: Add a Reload Decls button to all DeclarationSelectors
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 23, 2022
1 parent 0c13973 commit 2746e3c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
26 changes: 23 additions & 3 deletions libs/wxutil/decl/DeclarationSelectorDialog.cpp
Expand Up @@ -4,6 +4,8 @@
#include <wx/button.h>
#include <wx/sizer.h>

#include "i18n.h"
#include "ideclmanager.h"
#include "iregistry.h"

namespace wxutil
Expand All @@ -24,12 +26,25 @@ DeclarationSelectorDialog::DeclarationSelectorDialog(decl::Type declType,
_mainSizer = new wxBoxSizer(wxVERTICAL);
GetSizer()->Add(_mainSizer, 1, wxEXPAND | wxALL, 12);

// Button row
// Bottom row
auto grid = new wxFlexGridSizer(1, 2, 0, 12);
grid->AddGrowableCol(0);

// Left half
_bottomRowSizer = new wxBoxSizer(wxHORIZONTAL);
grid->Add(_bottomRowSizer, 1, wxALIGN_LEFT);

// Right half contains the buttons
_buttonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL);
_bottomRowSizer->Add(_buttonSizer, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 12);

_mainSizer->Add(_bottomRowSizer, 0, wxEXPAND, 12);
// Add a Reload Decls button
_reloadDeclsButton = new wxButton(this, wxID_ANY, _("Reload Decls"));
_reloadDeclsButton->Bind(wxEVT_BUTTON, &DeclarationSelectorDialog::onReloadDecls, this);
_buttonSizer->Prepend(_reloadDeclsButton, 0, wxLEFT | wxALIGN_CENTER_VERTICAL | wxRIGHT, 12);

grid->Add(_buttonSizer, 0, wxALIGN_RIGHT);

_mainSizer->Add(grid, 0, wxEXPAND, 12);

// Save the state of this dialog on close
RegisterPersistableObject(this);
Expand Down Expand Up @@ -114,6 +129,11 @@ void DeclarationSelectorDialog::onDeclItemActivated(wxDataViewEvent&)
}
}

void DeclarationSelectorDialog::onReloadDecls(wxCommandEvent& ev)
{
GlobalDeclarationManager().reloadDeclarations();
}

void DeclarationSelectorDialog::loadFromPath(const std::string& registryKey)
{
if (!_restoreSelectionFromRegistry) return;
Expand Down
3 changes: 3 additions & 0 deletions libs/wxutil/decl/DeclarationSelectorDialog.h
Expand Up @@ -7,6 +7,7 @@
#include "../dialog/DialogBase.h"

class wxSizer;
class wxButton;
class wxStdDialogButtonSizer;

namespace wxutil
Expand Down Expand Up @@ -34,6 +35,7 @@ class DeclarationSelectorDialog :
wxSizer* _mainSizer;
wxSizer* _bottomRowSizer;
wxStdDialogButtonSizer* _buttonSizer;
wxButton* _reloadDeclsButton;

bool _restoreSelectionFromRegistry;

Expand Down Expand Up @@ -66,6 +68,7 @@ class DeclarationSelectorDialog :
void HandleTreeViewSelectionChanged();
void onDeclSelectionChanged(wxDataViewEvent& ev);
void onDeclItemActivated(wxDataViewEvent& ev);
void onReloadDecls(wxCommandEvent& ev);
};

}

0 comments on commit 2746e3c

Please sign in to comment.