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,109 +1,28 @@
|
||||
#include "QtBookmarkView.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "QtSearchBarButton.h"
|
||||
#include "utilityQt.h"
|
||||
#include "QtMainView.h"
|
||||
#include "QtViewWidgetWrapper.h"
|
||||
#include "QtBookmarkBrowser.h"
|
||||
#include "QtBookmarkCreator.h"
|
||||
#include "QtMainView.h"
|
||||
#include "QtMainWindow.h"
|
||||
#include "ResourcePaths.h"
|
||||
#include "TabId.h"
|
||||
|
||||
QtBookmarkView::QtBookmarkView(ViewLayout* viewLayout)
|
||||
: BookmarkView(viewLayout)
|
||||
, m_controllerProxy(this)
|
||||
, m_controllerProxy(this, TabId::app())
|
||||
, m_bookmarkBrowser(nullptr)
|
||||
, m_createButtonState(BookmarkView::CreateButtonState::CANNOT_CREATE)
|
||||
{
|
||||
m_widget = new QFrame();
|
||||
}
|
||||
|
||||
QtBookmarkView::~QtBookmarkView()
|
||||
{
|
||||
}
|
||||
|
||||
void QtBookmarkView::createWidgetWrapper()
|
||||
{
|
||||
setWidgetWrapper(std::make_shared<QtViewWidgetWrapper>(m_widget));
|
||||
}
|
||||
|
||||
void QtBookmarkView::initView()
|
||||
{
|
||||
m_widget->setObjectName("bookmark_bar");
|
||||
|
||||
QBoxLayout* layout = new QHBoxLayout();
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
m_widget->setLayout(layout);
|
||||
|
||||
m_createBookmarkButton = new QtSearchBarButton(
|
||||
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/edit_bookmark_icon.png"));
|
||||
m_createBookmarkButton->setObjectName("bookmark_button");
|
||||
m_createBookmarkButton->setToolTip("create a bookmark for the active symbol");
|
||||
m_createBookmarkButton->setEnabled(false);
|
||||
layout->addWidget(m_createBookmarkButton);
|
||||
|
||||
connect(m_createBookmarkButton, &QPushButton::clicked, this, &QtBookmarkView::createBookmarkClicked);
|
||||
|
||||
m_showBookmarksButton = new QtSearchBarButton(
|
||||
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/bookmark_list_icon.png"));
|
||||
m_showBookmarksButton->setObjectName("show_bookmark_button");
|
||||
m_showBookmarksButton->setToolTip("Show bookmarks");
|
||||
m_showBookmarksButton->setEnabled(false);
|
||||
layout->addWidget(m_showBookmarksButton);
|
||||
|
||||
connect(m_showBookmarksButton, &QPushButton::clicked, this, &QtBookmarkView::showBookmarksClicked);
|
||||
}
|
||||
|
||||
void QtBookmarkView::refreshView()
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_widget->setStyleSheet(utility::getStyleSheet(
|
||||
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/bookmark_view.css")
|
||||
).c_str());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtBookmarkView::setCreateButtonState(const CreateButtonState& state)
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_createButtonState = state;
|
||||
|
||||
m_createBookmarkButton->setIconPath(
|
||||
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/edit_bookmark_icon.png"));
|
||||
|
||||
if (state == BookmarkView::CreateButtonState::CAN_CREATE)
|
||||
{
|
||||
m_createBookmarkButton->setEnabled(true);
|
||||
}
|
||||
else if (state == BookmarkView::CreateButtonState::CANNOT_CREATE)
|
||||
{
|
||||
m_createBookmarkButton->setEnabled(false);
|
||||
}
|
||||
else if (state == BookmarkView::CreateButtonState::ALREADY_CREATED)
|
||||
{
|
||||
m_createBookmarkButton->setEnabled(true);
|
||||
|
||||
m_createBookmarkButton->setIconPath(
|
||||
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/bookmark_active.png"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_createBookmarkButton->setEnabled(false);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtBookmarkView::displayBookmarkCreator(
|
||||
@@ -185,16 +104,6 @@ void QtBookmarkView::displayBookmarks(const std::vector<std::shared_ptr<Bookmark
|
||||
);
|
||||
}
|
||||
|
||||
void QtBookmarkView::enableDisplayBookmarks(bool enable)
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_showBookmarksButton->setEnabled(enable);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
bool QtBookmarkView::bookmarkBrowserIsVisible() const
|
||||
{
|
||||
if (m_bookmarkBrowser != nullptr)
|
||||
@@ -206,37 +115,3 @@ bool QtBookmarkView::bookmarkBrowserIsVisible() const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkView::createBookmarkClicked()
|
||||
{
|
||||
if (m_createButtonState == BookmarkView::CreateButtonState::CAN_CREATE)
|
||||
{
|
||||
m_controllerProxy.executeAsTaskWithArgs(&BookmarkController::showBookmarkCreator, 0);
|
||||
}
|
||||
else if (m_createButtonState == BookmarkView::CreateButtonState::ALREADY_CREATED)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Edit Bookmark");
|
||||
msgBox.setInformativeText("Do you want to edit or delete the bookmark for this symbol?");
|
||||
msgBox.addButton("Edit", QMessageBox::ButtonRole::YesRole);
|
||||
msgBox.addButton("Delete", QMessageBox::ButtonRole::NoRole);
|
||||
QPushButton* cancelButton = msgBox.addButton("Cancel", QMessageBox::ButtonRole::RejectRole);
|
||||
msgBox.setDefaultButton(cancelButton);
|
||||
msgBox.setIcon(QMessageBox::Icon::Question);
|
||||
int ret = msgBox.exec();
|
||||
|
||||
if (ret == 0) // QMessageBox::Yes
|
||||
{
|
||||
m_controllerProxy.executeAsTaskWithArgs(&BookmarkController::showBookmarkCreator, 0);
|
||||
}
|
||||
else if (ret == 1)
|
||||
{
|
||||
m_controllerProxy.executeAsTask(&BookmarkController::deleteBookmarkForActiveTokens);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkView::showBookmarksClicked()
|
||||
{
|
||||
m_controllerProxy.executeAsTask(&BookmarkController::displayBookmarks);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user