reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 34ade9bce83e7332d8fc02a0b3ea3d96d12ba529
parent 7342ee2757c4ef85336452603300c4ec7fed8658
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Tue,  2 Feb 2016 20:28:04 -0500

implement "Enable this repository" button of the about dialog

Diffstat:
Msrc/about.cpp | 19++++++++++++-------
Msrc/about.hpp | 9+++++----
Msrc/manager.cpp | 18+++++++++++++-----
Msrc/resource.rc | 2+-
4 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/src/about.cpp b/src/about.cpp @@ -21,6 +21,7 @@ #include "index.hpp" #include "listview.hpp" #include "menu.hpp" +#include "remote.hpp" #include "resource.hpp" #include "richedit.hpp" #include "tabbar.hpp" @@ -29,8 +30,9 @@ using namespace std; -About::About(const RemoteIndex *index) - : Dialog(IDD_ABOUT_DIALOG), m_index(index), m_currentCat(-255) +About::About(const Remote *remote, const RemoteIndex *index) + : Dialog(IDD_ABOUT_DIALOG), m_remote(remote), m_index(index), + m_currentCat(-255) { RichEdit::Init(); } @@ -64,9 +66,6 @@ void About::onInit() {AUTO_STR("Installed Files"), {}}, }); - m_website = getControl(IDC_WEBSITE); - m_donate = getControl(IDC_DONATE); - populate(); #ifdef LVSCW_AUTOSIZE_USEHEADER @@ -84,6 +83,9 @@ void About::onCommand(const int id) case IDC_DONATE: selectLink(id, m_donationLinks); break; + case IDC_ENABLE: + close(EnableResult); + break; case IDOK: case IDCANCEL: close(); @@ -105,11 +107,14 @@ void About::populate() m_websiteLinks = m_index->links(RemoteIndex::WebsiteLink); if(m_websiteLinks.empty()) - hide(m_website); + hide(getControl(IDC_WEBSITE)); m_donationLinks = m_index->links(RemoteIndex::DonationLink); if(m_donationLinks.empty()) - hide(m_donate); + hide(getControl(IDC_DONATE)); + + if(m_remote->isEnabled()) + hide(getControl(IDC_ENABLE)); if(!m_about->setRichText(m_index->aboutText())) { // if description is invalid or empty, don't display it diff --git a/src/about.hpp b/src/about.hpp @@ -22,15 +22,17 @@ #include <vector> -struct Link; class ListView; +class Remote; class RemoteIndex; class RichEdit; class TabBar; +struct Link; class About : public Dialog { public: - About(const RemoteIndex *); + enum { EnableResult = 100 }; + About(const Remote *, const RemoteIndex *); protected: void onInit() override; @@ -42,6 +44,7 @@ private: void selectLink(const int control, const std::vector<const Link *> &); void openLink(const Link *); + const Remote *m_remote; const RemoteIndex *m_index; int m_currentCat; @@ -49,8 +52,6 @@ private: RichEdit *m_about; ListView *m_cats; ListView *m_packages; - HWND m_website; - HWND m_donate; std::vector<const Link *> m_websiteLinks; std::vector<const Link *> m_donationLinks; diff --git a/src/manager.cpp b/src/manager.cpp @@ -192,12 +192,15 @@ void Manager::uninstall() void Manager::about() { - const Remote &remote = currentRemote(); + Remote remote = currentRemote(); if(remote.isNull()) return; - RemoteIndex *index = nullptr; + // show the enable state changes as if they were already applied + remote.setEnabled(isRemoteEnabled(remote)); + + const RemoteIndex *index; try { index = RemoteIndex::load(remote.name()); @@ -212,7 +215,7 @@ void Manager::about() AUTO_STR("Synchronize your packages and try again.\n") AUTO_STR("If the problem persist, contact the repository maintainer.\n\n") - AUTO_STR("[error description: %s]"), + AUTO_STR("[Error description: %s]"), make_autostring(remote.name()).c_str(), desc.c_str() ); @@ -220,9 +223,14 @@ void Manager::about() return; } - unique_ptr<RemoteIndex> ptr(index); + unique_ptr<const RemoteIndex> ptr(index); - Dialog::Show<About>(instance(), handle(), index); + const int result = Dialog::Show<About>(instance(), handle(), &remote, index); + switch(result) { + case About::EnableResult: + setRemoteEnabled(true); + break; + } } bool Manager::confirm() const diff --git a/src/resource.rc b/src/resource.rc @@ -56,6 +56,6 @@ BEGIN LVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP, 110, 20, 340, 220 PUSHBUTTON "&Website", IDC_WEBSITE, 5, 250, 45, 14 PUSHBUTTON "&Donate...", IDC_DONATE, 54, 250, 45, 14 - PUSHBUTTON "&Enable this repository!", IDC_ENABLE, 305, 250, 100, 14 + PUSHBUTTON "&Enable this repository!", IDC_ENABLE, 285, 250, 120, 14 DEFPUSHBUTTON "&Close", IDOK, 409, 250, 45, 14 END