Merge global settings and accounts into a pagedialog

Also split external tools into it's own page
This commit is contained in:
Jan Dalheimer
2014-07-16 00:13:40 +02:00
committed by Petr Mrázek
parent c91adfb3d1
commit e178284172
15 changed files with 637 additions and 478 deletions

View File

@ -17,6 +17,7 @@
#include "BasePage.h"
#include <memory>
#include <functional>
class BasePageProvider
{
@ -25,4 +26,44 @@ public:
virtual QString dialogTitle() = 0;
};
class GenericPageProvider : public BasePageProvider
{
typedef std::function<BasePage *()> PageCreator;
public:
explicit GenericPageProvider(const QString &dialogTitle)
: m_dialogTitle(dialogTitle)
{
}
QList<BasePage *> getPages() override
{
QList<BasePage *> pages;
for (PageCreator creator : m_creators)
{
pages.append(creator());
}
return pages;
}
QString dialogTitle() override { return m_dialogTitle; }
void setDialogTitle(const QString &title)
{
m_dialogTitle = title;
}
void addPageCreator(PageCreator page)
{
m_creators.append(page);
}
template<typename PageClass>
void addPage()
{
addPageCreator([](){return new PageClass();});
}
private:
QList<PageCreator> m_creators;
QString m_dialogTitle;
};
typedef std::shared_ptr<BasePageProvider> BasePageProviderPtr;