ui: Added tabs UI to top of main window (issue #215)
* Added tab bar to top of main window with UI/shortcuts similar to web browsers * ComponentManager offers components for 2 use-cases: application and tab * Application components: log view (status/errors), bookmarks, screen search, status bar, tabs, tooltips, dialogs and all tab views disabled * Tab components: graph, code, history and search * When a project is loaded there is always at least one tab, otherwise there is none * Each tab replaces the application views of the same name in the main layout when activated * Each tab has it's own TaskScheduler, to process tasks independent from other tabs * The application has a global TaskScheduler for application wide tasks * The singloton class TaskManager is responsible for managing the TaskSchedulers * MessageListeners and Messages hold an optional schedulerId, both must be set to only send to a specific TaskScheduler * Bookmark buttons where split off into a separate view per tab, bookmark managemement is done in the application * History menu processing is done by the QtMainWindow now * Screen search is an application component, the responders are always changed to the active tab * Plugin messages are opened in a new tab * Symbols can be opened in a new tab via middle click/context menu in graph, code, history dropdown * Full text index creation is mutexed now in PersistenStorage to make it fully thread-safe * All tabs are closed when switching projects * Tab contents are only animated when visible fortune cookie message = Catch your lucky star!
This commit is contained in:
@@ -1,87 +1,147 @@
|
||||
#include "ComponentManager.h"
|
||||
|
||||
#include "logging.h"
|
||||
|
||||
#include "Controller.h"
|
||||
#include "ScreenSearchController.h"
|
||||
#include "CompositeView.h"
|
||||
#include "Controller.h"
|
||||
#include "DialogView.h"
|
||||
#include "logging.h"
|
||||
#include "ScreenSearchController.h"
|
||||
#include "TabbedView.h"
|
||||
#include "ViewFactory.h"
|
||||
#include "BookmarkButtonsView.h"
|
||||
#include "BookmarkView.h"
|
||||
#include "CodeView.h"
|
||||
#include "GraphView.h"
|
||||
#include "RefreshView.h"
|
||||
#include "SearchView.h"
|
||||
#include "UndoRedoView.h"
|
||||
|
||||
std::shared_ptr<ComponentManager> ComponentManager::create(ViewFactory* viewFactory, StorageAccess* storageAccess)
|
||||
{
|
||||
std::shared_ptr<ComponentManager> ptr(new ComponentManager());
|
||||
|
||||
ptr->m_componentFactory = ComponentFactory::create(viewFactory, storageAccess);
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
ComponentManager::~ComponentManager()
|
||||
ComponentManager::ComponentManager(const ViewFactory* viewFactory, StorageAccess* storageAccess)
|
||||
: m_componentFactory(viewFactory, storageAccess)
|
||||
{
|
||||
}
|
||||
|
||||
void ComponentManager::setup(ViewLayout* viewLayout)
|
||||
void ComponentManager::clear()
|
||||
{
|
||||
m_dialogViews.clear();
|
||||
m_components.clear();
|
||||
m_singleViews.clear();
|
||||
}
|
||||
|
||||
void ComponentManager::setupMain(ViewLayout* viewLayout, Id appId)
|
||||
{
|
||||
std::shared_ptr<CompositeView> compositeView =
|
||||
m_componentFactory->getViewFactory()->createCompositeView(viewLayout, CompositeView::DIRECTION_HORIZONTAL, "Search");
|
||||
m_compositeViews.push_back(compositeView);
|
||||
m_componentFactory.getViewFactory()->createCompositeView(viewLayout, CompositeView::DIRECTION_HORIZONTAL, "Search");
|
||||
m_singleViews.push_back(compositeView);
|
||||
|
||||
std::shared_ptr<Component> undoRedoComponent = m_componentFactory->createUndoRedoComponent(compositeView.get());
|
||||
m_components.push_back(undoRedoComponent);
|
||||
std::shared_ptr<UndoRedoView> undoRedoView = m_componentFactory.getViewFactory()->createUndoRedoView(compositeView.get());
|
||||
std::shared_ptr<RefreshView> refreshView = m_componentFactory.getViewFactory()->createRefreshView(compositeView.get());
|
||||
std::shared_ptr<SearchView> searchView = m_componentFactory.getViewFactory()->createSearchView(compositeView.get());
|
||||
|
||||
std::shared_ptr<Component> refreshComponent = m_componentFactory->createRefreshComponent(compositeView.get());
|
||||
m_components.push_back(refreshComponent);
|
||||
std::shared_ptr<BookmarkButtonsView> bookmarkView =
|
||||
m_componentFactory.getViewFactory()->createBookmarkButtonsView(compositeView.get());
|
||||
bookmarkView->setTabId(appId);
|
||||
|
||||
std::shared_ptr<Component> searchComponent = m_componentFactory->createSearchComponent(compositeView.get());
|
||||
m_components.push_back(searchComponent);
|
||||
std::shared_ptr<GraphView> graphView = m_componentFactory.getViewFactory()->createGraphView(viewLayout);
|
||||
std::shared_ptr<CodeView> codeView = m_componentFactory.getViewFactory()->createCodeView(viewLayout);
|
||||
|
||||
std::shared_ptr<Component> bookmarkComponent = m_componentFactory->createBookmarkComponent(compositeView.get());
|
||||
m_components.push_back(bookmarkComponent);
|
||||
for (std::shared_ptr<View> view :
|
||||
std::vector<std::shared_ptr<View>>({ undoRedoView, searchView, bookmarkView, graphView, codeView }))
|
||||
{
|
||||
view->setEnabled(false);
|
||||
}
|
||||
|
||||
std::shared_ptr<Component> graphComponent = m_componentFactory->createGraphComponent(viewLayout);
|
||||
m_components.push_back(graphComponent);
|
||||
m_singleViews.push_back(undoRedoView);
|
||||
m_singleViews.push_back(refreshView);
|
||||
m_singleViews.push_back(searchView);
|
||||
m_singleViews.push_back(bookmarkView);
|
||||
m_singleViews.push_back(graphView);
|
||||
m_singleViews.push_back(codeView);
|
||||
|
||||
std::shared_ptr<Component> codeComponent = m_componentFactory->createCodeComponent(viewLayout);
|
||||
m_components.push_back(codeComponent);
|
||||
std::shared_ptr<Component> screenSearchComponent = m_componentFactory.createScreenSearchComponent(viewLayout);
|
||||
ScreenSearchController* screenSearchController = screenSearchComponent->getController<ScreenSearchController>();
|
||||
screenSearchController->addResponder(graphView.get());
|
||||
screenSearchController->addResponder(codeView.get());
|
||||
m_components.push_back(screenSearchComponent);
|
||||
|
||||
std::shared_ptr<Component> statusBarComponent = m_componentFactory->createStatusBarComponent(viewLayout);
|
||||
std::shared_ptr<Component> tabsComponent = m_componentFactory.createTabsComponent(viewLayout, screenSearchController);
|
||||
m_components.push_back(tabsComponent);
|
||||
|
||||
std::shared_ptr<Component> statusBarComponent = m_componentFactory.createStatusBarComponent(viewLayout);
|
||||
m_components.push_back(statusBarComponent);
|
||||
|
||||
std::shared_ptr<Component> activationComponent = m_componentFactory->createActivationComponent();
|
||||
m_components.push_back(activationComponent);
|
||||
|
||||
std::shared_ptr<Component> tooltipComponent = m_componentFactory->createTooltipComponent(viewLayout);
|
||||
std::shared_ptr<Component> tooltipComponent = m_componentFactory.createTooltipComponent(viewLayout);
|
||||
m_components.push_back(tooltipComponent);
|
||||
|
||||
std::shared_ptr<Component> screenSearchComponent = m_componentFactory->createScreenSearchComponent(viewLayout);
|
||||
ScreenSearchController* screenSearchController = screenSearchComponent->getController<ScreenSearchController>();
|
||||
screenSearchController->addResponder(dynamic_cast<ScreenSearchResponder*>(graphComponent->getViewPtr()));
|
||||
screenSearchController->addResponder(dynamic_cast<ScreenSearchResponder*>(codeComponent->getViewPtr()));
|
||||
m_components.push_back(screenSearchComponent);
|
||||
|
||||
for (DialogView::UseCase useCase :
|
||||
{ DialogView::UseCase::GENERAL, DialogView::UseCase::INDEXING, DialogView::UseCase::PROJECT_SETUP })
|
||||
{
|
||||
m_dialogViews.emplace(
|
||||
useCase,
|
||||
m_componentFactory->getViewFactory()->createDialogView(viewLayout, useCase, m_componentFactory->getStorageAccess())
|
||||
m_componentFactory.getViewFactory()->createDialogView(viewLayout, useCase, m_componentFactory.getStorageAccess())
|
||||
);
|
||||
}
|
||||
|
||||
m_dialogViews[DialogView::UseCase::INDEXING]->setDialogsHideable(true);
|
||||
|
||||
std::shared_ptr<TabbedView> tabbedView =
|
||||
m_componentFactory->getViewFactory()->createTabbedView(viewLayout, "Status");
|
||||
m_tabbedViews.push_back(tabbedView);
|
||||
m_componentFactory.getViewFactory()->createTabbedView(viewLayout, "Status");
|
||||
m_singleViews.push_back(tabbedView);
|
||||
|
||||
std::shared_ptr<Component> statusComponent = m_componentFactory->createStatusComponent(tabbedView.get());
|
||||
std::shared_ptr<Component> statusComponent = m_componentFactory.createStatusComponent(tabbedView.get());
|
||||
m_components.push_back(statusComponent);
|
||||
|
||||
std::shared_ptr<Component> errorComponent = m_componentFactory->createErrorComponent(tabbedView.get());
|
||||
std::shared_ptr<Component> errorComponent = m_componentFactory.createErrorComponent(tabbedView.get());
|
||||
m_components.push_back(errorComponent);
|
||||
|
||||
std::shared_ptr<Component> bookmarkComponent = m_componentFactory.createBookmarkComponent(compositeView.get());
|
||||
m_components.push_back(bookmarkComponent);
|
||||
|
||||
std::shared_ptr<Component> activationComponent = m_componentFactory.createActivationComponent();
|
||||
m_components.push_back(activationComponent);
|
||||
}
|
||||
|
||||
void ComponentManager::setupTab(ViewLayout* viewLayout, Id tabId, ScreenSearchSender* screenSearchSender)
|
||||
{
|
||||
std::shared_ptr<CompositeView> compositeView =
|
||||
m_componentFactory.getViewFactory()->createCompositeView(viewLayout, CompositeView::DIRECTION_HORIZONTAL, "Search");
|
||||
m_singleViews.push_back(compositeView);
|
||||
|
||||
std::shared_ptr<Component> undoRedoComponent = m_componentFactory.createUndoRedoComponent(compositeView.get());
|
||||
undoRedoComponent->setTabId(tabId);
|
||||
m_components.push_back(undoRedoComponent);
|
||||
|
||||
std::shared_ptr<Component> refreshComponent = m_componentFactory.createRefreshComponent(compositeView.get());
|
||||
refreshComponent->setTabId(tabId);
|
||||
m_components.push_back(refreshComponent);
|
||||
|
||||
std::shared_ptr<Component> searchComponent = m_componentFactory.createSearchComponent(compositeView.get());
|
||||
searchComponent->setTabId(tabId);
|
||||
m_components.push_back(searchComponent);
|
||||
|
||||
std::shared_ptr<BookmarkButtonsView> bookmarkView =
|
||||
m_componentFactory.getViewFactory()->createBookmarkButtonsView(compositeView.get());
|
||||
bookmarkView->setTabId(tabId);
|
||||
m_singleViews.push_back(bookmarkView);
|
||||
|
||||
std::shared_ptr<Component> graphComponent = m_componentFactory.createGraphComponent(viewLayout);
|
||||
graphComponent->setTabId(tabId);
|
||||
m_components.push_back(graphComponent);
|
||||
|
||||
std::shared_ptr<Component> codeComponent = m_componentFactory.createCodeComponent(viewLayout);
|
||||
codeComponent->setTabId(tabId);
|
||||
m_components.push_back(codeComponent);
|
||||
|
||||
screenSearchSender->addResponder(graphComponent->getView<GraphView>());
|
||||
screenSearchSender->addResponder(codeComponent->getView<CodeView>());
|
||||
}
|
||||
|
||||
void ComponentManager::teardownTab(ScreenSearchSender* screenSearchSender)
|
||||
{
|
||||
for (const std::shared_ptr<Component>& component : m_components)
|
||||
{
|
||||
screenSearchSender->removeResponder(component->getView<GraphView>());
|
||||
screenSearchSender->removeResponder(component->getView<CodeView>());
|
||||
}
|
||||
}
|
||||
|
||||
void ComponentManager::clearComponents()
|
||||
@@ -109,12 +169,7 @@ void ComponentManager::refreshViews()
|
||||
}
|
||||
}
|
||||
|
||||
for (const std::shared_ptr<CompositeView>& view : m_compositeViews)
|
||||
{
|
||||
view->refreshView();
|
||||
}
|
||||
|
||||
for (const std::shared_ptr<TabbedView>& view : m_tabbedViews)
|
||||
for (const std::shared_ptr<View>& view : m_singleViews)
|
||||
{
|
||||
view->refreshView();
|
||||
}
|
||||
@@ -131,7 +186,3 @@ std::shared_ptr<DialogView> ComponentManager::getDialogView(DialogView::UseCase
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
ComponentManager::ComponentManager()
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user