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:
@@ -67,6 +67,8 @@ add_files(
|
||||
qt/element/QtStringListBoxItem.h
|
||||
qt/element/QtStatusBar.cpp
|
||||
qt/element/QtStatusBar.h
|
||||
qt/element/QtTabBar.cpp
|
||||
qt/element/QtTabBar.h
|
||||
qt/element/QtTable.cpp
|
||||
qt/element/QtTable.h
|
||||
qt/element/QtTextEdit.cpp
|
||||
@@ -150,6 +152,8 @@ add_files(
|
||||
qt/view/graphElements/QtGraphNodeText.cpp
|
||||
qt/view/graphElements/QtGraphNodeText.h
|
||||
|
||||
qt/view/QtBookmarkButtonsView.cpp
|
||||
qt/view/QtBookmarkButtonsView.h
|
||||
qt/view/QtBookmarkView.cpp
|
||||
qt/view/QtBookmarkView.h
|
||||
qt/view/QtCodeView.cpp
|
||||
@@ -180,6 +184,8 @@ add_files(
|
||||
qt/view/QtTabbedView.h
|
||||
qt/view/QtTooltipView.cpp
|
||||
qt/view/QtTooltipView.h
|
||||
qt/view/QtTabsView.cpp
|
||||
qt/view/QtTabsView.h
|
||||
qt/view/QtUndoRedoView.cpp
|
||||
qt/view/QtUndoRedoView.h
|
||||
qt/view/QtViewFactory.cpp
|
||||
|
||||
@@ -620,6 +620,7 @@ void QtCodeArea::mousePressEvent(QMouseEvent* event)
|
||||
void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
const int panningThreshold = 5;
|
||||
|
||||
if (event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_isSelecting = false;
|
||||
@@ -636,9 +637,7 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
||||
}
|
||||
else
|
||||
{
|
||||
QTextCursor cursor = this->cursorForPosition(event->pos());
|
||||
std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(cursor.position());
|
||||
|
||||
std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(event->pos());
|
||||
if (annotations.size())
|
||||
{
|
||||
if (m_navigator->hasErrors())
|
||||
@@ -657,6 +656,10 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QtCodeField::mouseReleaseEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeArea::mouseMoveEvent(QMouseEvent* event)
|
||||
@@ -681,8 +684,7 @@ void QtCodeArea::mouseMoveEvent(QMouseEvent* event)
|
||||
scrollbar->setValue(scrollbar->value() - utility::roundToInt(deltaPosRatio * scrollbar->pageStep()));
|
||||
}
|
||||
|
||||
QTextCursor cursor = this->cursorForPosition(event->pos());
|
||||
std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(cursor.position());
|
||||
std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(event->pos());
|
||||
|
||||
bool same = annotations.size() == m_hoveredAnnotations.size();
|
||||
if (same)
|
||||
@@ -730,9 +732,12 @@ void QtCodeArea::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
m_eventPosition = event->pos();
|
||||
|
||||
checkOpenInTabActionEnabled(event->pos());
|
||||
m_setIDECursorPositionAction->setEnabled(!getSourceLocationFile()->getFilePath().empty());
|
||||
|
||||
QtContextMenu menu(event, this);
|
||||
menu.addAction(m_openInTabAction);
|
||||
menu.addUndoActions();
|
||||
menu.addSeparator();
|
||||
menu.addFileActions(getSourceLocationFile()->getFilePath());
|
||||
menu.addSeparator();
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
#include "QtCodeField.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QPainter>
|
||||
#include <QTextBlock>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "SourceLocation.h"
|
||||
#include "SourceLocationFile.h"
|
||||
#include "QtContextMenu.h"
|
||||
#include "QtHighlighter.h"
|
||||
#include "ApplicationSettings.h"
|
||||
#include "ColorScheme.h"
|
||||
#include "MessageActivateLocalSymbols.h"
|
||||
#include "MessageActivateSourceLocations.h"
|
||||
#include "MessageActivateTokenIds.h"
|
||||
#include "MessageTabOpenWith.h"
|
||||
#include "MessageTooltipShow.h"
|
||||
#include "TextCodec.h"
|
||||
#include "tracing.h"
|
||||
@@ -99,6 +102,12 @@ QtCodeField::QtCodeField(
|
||||
font.setPixelSize(appSettings->getFontSize());
|
||||
setFont(font);
|
||||
setTabStopWidth(appSettings->getCodeTabWidth() * fontMetrics().width('9'));
|
||||
|
||||
m_openInTabAction = new QAction("Open in New Tab", this);
|
||||
m_openInTabAction->setStatusTip("Opens the node in a new tab");
|
||||
m_openInTabAction->setToolTip("Opens the node in a new tab");
|
||||
m_openInTabAction->setEnabled(false);
|
||||
connect(m_openInTabAction, &QAction::triggered, this, &QtCodeField::openInTab);
|
||||
}
|
||||
|
||||
QtCodeField::~QtCodeField()
|
||||
@@ -251,8 +260,7 @@ void QtCodeField::leaveEvent(QEvent* event)
|
||||
|
||||
void QtCodeField::mouseMoveEvent(QMouseEvent* event)
|
||||
{
|
||||
QTextCursor cursor = this->cursorForPosition(event->pos());
|
||||
std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(cursor.position());
|
||||
std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(event->pos());
|
||||
|
||||
bool same = annotations.size() == m_hoveredAnnotations.size();
|
||||
if (same)
|
||||
@@ -275,6 +283,13 @@ void QtCodeField::mouseMoveEvent(QMouseEvent* event)
|
||||
|
||||
void QtCodeField::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::MiddleButton)
|
||||
{
|
||||
checkOpenInTabActionEnabled(event->pos());
|
||||
openInTab();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
@@ -282,9 +297,7 @@ void QtCodeField::mouseReleaseEvent(QMouseEvent* event)
|
||||
|
||||
viewport()->setCursor(Qt::ArrowCursor);
|
||||
|
||||
QTextCursor cursor = this->cursorForPosition(event->pos());
|
||||
std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(cursor.position());
|
||||
|
||||
std::vector<const Annotation*> annotations = getInteractiveAnnotationsForPosition(event->pos());
|
||||
if (!annotations.size())
|
||||
{
|
||||
return;
|
||||
@@ -293,6 +306,16 @@ void QtCodeField::mouseReleaseEvent(QMouseEvent* event)
|
||||
activateAnnotations(annotations);
|
||||
}
|
||||
|
||||
void QtCodeField::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
checkOpenInTabActionEnabled(event->pos());
|
||||
|
||||
QtContextMenu menu(event, nullptr);
|
||||
menu.addAction(m_openInTabAction);
|
||||
menu.addUndoActions();
|
||||
menu.show();
|
||||
}
|
||||
|
||||
void QtCodeField::focusTokenIds(const std::vector<Id>& focusedTokenIds)
|
||||
{
|
||||
annotateText(std::set<Id>(), std::set<Id>(), std::set<Id>(focusedTokenIds.begin(), focusedTokenIds.end()));
|
||||
@@ -639,10 +662,13 @@ void QtCodeField::setTextColorForAnnotation(const Annotation& annotation, QColor
|
||||
m_highlighter->applyFormat(annotation.start, annotation.end, format);
|
||||
}
|
||||
|
||||
std::vector<const QtCodeField::Annotation*> QtCodeField::getInteractiveAnnotationsForPosition(int pos) const
|
||||
std::vector<const QtCodeField::Annotation*> QtCodeField::getInteractiveAnnotationsForPosition(QPoint position) const
|
||||
{
|
||||
std::vector<const QtCodeField::Annotation*> annotations;
|
||||
|
||||
QTextCursor cursor = this->cursorForPosition(position);
|
||||
int pos = cursor.position();
|
||||
|
||||
for (const Annotation& annotation : m_annotations)
|
||||
{
|
||||
const LocationType& type = annotation.locationType;
|
||||
@@ -656,6 +682,38 @@ std::vector<const QtCodeField::Annotation*> QtCodeField::getInteractiveAnnotatio
|
||||
return annotations;
|
||||
}
|
||||
|
||||
void QtCodeField::checkOpenInTabActionEnabled(QPoint position)
|
||||
{
|
||||
std::vector<Id> locationIds;
|
||||
for (const Annotation* annotation : getInteractiveAnnotationsForPosition(position))
|
||||
{
|
||||
const LocationType& type = annotation->locationType;
|
||||
if (type == LOCATION_TOKEN || type == LOCATION_QUALIFIER)
|
||||
{
|
||||
locationIds.emplace_back(annotation->locationId);
|
||||
}
|
||||
}
|
||||
|
||||
if (locationIds.size())
|
||||
{
|
||||
m_openInTabLocationId = locationIds[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
m_openInTabLocationId = 0;
|
||||
}
|
||||
|
||||
m_openInTabAction->setEnabled(m_openInTabLocationId);
|
||||
}
|
||||
|
||||
void QtCodeField::openInTab()
|
||||
{
|
||||
if (m_openInTabLocationId)
|
||||
{
|
||||
MessageTabOpenWith(0, m_openInTabLocationId).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeField::createLineLengthCache()
|
||||
{
|
||||
m_endTextEditPosition = -1;
|
||||
|
||||
@@ -51,6 +51,8 @@ protected:
|
||||
virtual void mouseMoveEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
||||
virtual void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
|
||||
|
||||
virtual void focusTokenIds(const std::vector<Id>& tokenIds);
|
||||
virtual void defocusTokenIds(const std::vector<Id>& tokenIds);
|
||||
|
||||
@@ -99,12 +101,20 @@ protected:
|
||||
const AnnotationColor& getAnnotationColorForAnnotation(const Annotation& annotation);
|
||||
void setTextColorForAnnotation(const Annotation& annotation, QColor color) const;
|
||||
|
||||
std::vector<const Annotation*> getInteractiveAnnotationsForPosition(int pos) const;
|
||||
std::vector<const Annotation*> getInteractiveAnnotationsForPosition(QPoint position) const;
|
||||
std::vector<Id> getInteractiveTokenIdsForPosition(QPoint position) const;
|
||||
|
||||
void checkOpenInTabActionEnabled(QPoint position);
|
||||
|
||||
std::vector<Annotation> m_annotations;
|
||||
std::vector<const Annotation*> m_hoveredAnnotations;
|
||||
std::vector<int> m_linesToRehighlight;
|
||||
|
||||
QAction* m_openInTabAction;
|
||||
|
||||
private slots:
|
||||
void openInTab();
|
||||
|
||||
private:
|
||||
static std::vector<AnnotationColor> s_annotationColors;
|
||||
|
||||
@@ -123,6 +133,8 @@ private:
|
||||
std::vector<std::vector<std::pair<int, int>>> m_multibyteCharacterLocations;
|
||||
|
||||
int m_endTextEditPosition;
|
||||
|
||||
Id m_openInTabLocationId;
|
||||
};
|
||||
|
||||
#endif // QT_CODE_FIELD_H
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
#include "QtCodeFileTitleButton.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "FileSystem.h"
|
||||
#include "MessageActivateFile.h"
|
||||
#include "MessageProjectEdit.h"
|
||||
#include "MessageTabOpenWith.h"
|
||||
#include "ResourcePaths.h"
|
||||
#include "utilityString.h"
|
||||
|
||||
@@ -25,6 +28,12 @@ QtCodeFileTitleButton::QtCodeFileTitleButton(QWidget* parent)
|
||||
setIconSize(QSize(16, 16));
|
||||
|
||||
connect(this, &QtCodeFileTitleButton::clicked, this, &QtCodeFileTitleButton::clickedTitle);
|
||||
|
||||
m_openInTabAction = new QAction("Open in New Tab", this);
|
||||
m_openInTabAction->setStatusTip("Opens the file in a new tab");
|
||||
m_openInTabAction->setToolTip("Opens the file in a new tab");
|
||||
m_openInTabAction->setEnabled(false);
|
||||
connect(m_openInTabAction, &QAction::triggered, this, &QtCodeFileTitleButton::openInTab);
|
||||
}
|
||||
|
||||
QtCodeFileTitleButton::~QtCodeFileTitleButton()
|
||||
@@ -147,6 +156,17 @@ void QtCodeFileTitleButton::updateFromOther(const QtCodeFileTitleButton* other)
|
||||
updateTexts();
|
||||
}
|
||||
|
||||
void QtCodeFileTitleButton::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::MiddleButton)
|
||||
{
|
||||
openInTab();
|
||||
return;
|
||||
}
|
||||
|
||||
QtSelfRefreshIconButton::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void QtCodeFileTitleButton::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
FilePath path = m_filePath;
|
||||
@@ -161,7 +181,11 @@ void QtCodeFileTitleButton::contextMenuEvent(QContextMenuEvent* event)
|
||||
path = currentProject->getProjectSettingsFilePath();
|
||||
}
|
||||
|
||||
m_openInTabAction->setEnabled(!m_filePath.empty());
|
||||
|
||||
QtContextMenu menu(event, this);
|
||||
menu.addAction(m_openInTabAction);
|
||||
menu.addUndoActions();
|
||||
menu.addSeparator();
|
||||
menu.addFileActions(path);
|
||||
menu.show();
|
||||
@@ -186,6 +210,14 @@ void QtCodeFileTitleButton::clickedTitle()
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeFileTitleButton::openInTab()
|
||||
{
|
||||
if (!m_filePath.empty())
|
||||
{
|
||||
MessageTabOpenWith(m_filePath).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void QtCodeFileTitleButton::updateIcon()
|
||||
{
|
||||
if (m_filePath.empty())
|
||||
|
||||
@@ -31,12 +31,14 @@ public:
|
||||
void updateFromOther(const QtCodeFileTitleButton* other);
|
||||
|
||||
protected:
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
|
||||
virtual void refresh();
|
||||
|
||||
private slots:
|
||||
void clickedTitle();
|
||||
void openInTab();
|
||||
|
||||
private:
|
||||
void updateIcon();
|
||||
@@ -46,6 +48,8 @@ private:
|
||||
TimeStamp m_modificationTime;
|
||||
bool m_isComplete;
|
||||
bool m_isIndexed;
|
||||
|
||||
QAction* m_openInTabAction;
|
||||
};
|
||||
|
||||
#endif // QT_CODE_FILE_TITLE_BUTTON_H
|
||||
|
||||
@@ -64,7 +64,7 @@ void QtCodeNavigateable::ensureWidgetVisibleAnimated(
|
||||
QScrollBar* scrollBar = area->verticalScrollBar();
|
||||
if (scrollBar && value)
|
||||
{
|
||||
if (animated && ApplicationSettings::getInstance()->getUseAnimations())
|
||||
if (animated && ApplicationSettings::getInstance()->getUseAnimations() && area->isVisible())
|
||||
{
|
||||
QPropertyAnimation* anim = new QPropertyAnimation(scrollBar, "value");
|
||||
anim->setDuration(300);
|
||||
@@ -136,7 +136,7 @@ void QtCodeNavigateable::ensurePercentVisibleAnimated(double percentA, double pe
|
||||
int diff = value - scrollBar->value();
|
||||
if (diff > 5 || diff < -5)
|
||||
{
|
||||
if (animated && ApplicationSettings::getInstance()->getUseAnimations())
|
||||
if (animated && ApplicationSettings::getInstance()->getUseAnimations() && area->isVisible())
|
||||
{
|
||||
QPropertyAnimation* anim = new QPropertyAnimation(scrollBar, "value");
|
||||
anim->setDuration(300);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "MessageShowError.h"
|
||||
#include "MessageScrollCode.h"
|
||||
#include "ResourcePaths.h"
|
||||
#include "TabId.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include "SourceLocation.h"
|
||||
@@ -26,6 +27,7 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_mode(MODE_NONE)
|
||||
, m_oldMode(MODE_NONE)
|
||||
, m_schedulerId(TabId::ignore())
|
||||
, m_activeTokenId(0)
|
||||
, m_value(0)
|
||||
, m_refIndex(0)
|
||||
@@ -338,6 +340,16 @@ void QtCodeNavigator::setMode(Mode mode)
|
||||
}
|
||||
}
|
||||
|
||||
Id QtCodeNavigator::getSchedulerId() const
|
||||
{
|
||||
return m_schedulerId;
|
||||
}
|
||||
|
||||
void QtCodeNavigator::setSchedulerId(Id schedulerId)
|
||||
{
|
||||
m_schedulerId = schedulerId;
|
||||
}
|
||||
|
||||
const std::set<Id>& QtCodeNavigator::getCurrentActiveTokenIds() const
|
||||
{
|
||||
return m_currentActiveTokenIds;
|
||||
@@ -708,6 +720,11 @@ void QtCodeNavigator::deactivateScreenMatch(size_t matchIndex)
|
||||
m_activeScreenMatchId = 0;
|
||||
}
|
||||
|
||||
bool QtCodeNavigator::hasScreenMatches() const
|
||||
{
|
||||
return !m_screenMatches.empty();
|
||||
}
|
||||
|
||||
void QtCodeNavigator::clearScreenMatches()
|
||||
{
|
||||
if (m_activeScreenMatchId)
|
||||
@@ -847,7 +864,7 @@ void QtCodeNavigator::requestScroll(
|
||||
void QtCodeNavigator::handleScrollRequest()
|
||||
{
|
||||
const ScrollRequest& req = m_scrollRequest;
|
||||
if (req.filePath.empty())
|
||||
if (req.filePath.empty() || !isVisible())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -871,6 +888,11 @@ void QtCodeNavigator::scrolled(int value)
|
||||
MessageScrollCode(value, m_mode == MODE_LIST).dispatch();
|
||||
}
|
||||
|
||||
void QtCodeNavigator::showEvent(QShowEvent* event)
|
||||
{
|
||||
emit scrollRequest();
|
||||
}
|
||||
|
||||
void QtCodeNavigator::setValue()
|
||||
{
|
||||
QAbstractScrollArea* area = m_current->getScrollArea();
|
||||
|
||||
@@ -56,6 +56,9 @@ public:
|
||||
|
||||
void setMode(Mode mode);
|
||||
|
||||
Id getSchedulerId() const override;
|
||||
void setSchedulerId(Id schedulerId);
|
||||
|
||||
const std::set<Id>& getCurrentActiveTokenIds() const;
|
||||
void setCurrentActiveTokenIds(const std::vector<Id>& currentActiveTokenIds);
|
||||
|
||||
@@ -101,6 +104,7 @@ public:
|
||||
size_t findScreenMatches(const std::wstring& query);
|
||||
void activateScreenMatch(size_t matchIndex);
|
||||
void deactivateScreenMatch(size_t matchIndex);
|
||||
bool hasScreenMatches() const;
|
||||
void clearScreenMatches();
|
||||
|
||||
void scrollToValue(int value, bool inListMode);
|
||||
@@ -118,6 +122,9 @@ signals:
|
||||
public slots:
|
||||
void scrolled(int value);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void handleScrollRequest();
|
||||
void setValue();
|
||||
@@ -172,11 +179,11 @@ private:
|
||||
QtCodeNavigateable::ScrollTarget target;
|
||||
};
|
||||
|
||||
void handleMessage(MessageCodeReference* message);
|
||||
void handleMessage(MessageIndexingFinished* message);
|
||||
void handleMessage(MessageShowReference* message);
|
||||
void handleMessage(MessageSwitchColorScheme* message);
|
||||
void handleMessage(MessageWindowFocus* message);
|
||||
void handleMessage(MessageCodeReference* message) override;
|
||||
void handleMessage(MessageIndexingFinished* message) override;
|
||||
void handleMessage(MessageShowReference* message) override;
|
||||
void handleMessage(MessageSwitchColorScheme* message) override;
|
||||
void handleMessage(MessageWindowFocus* message) override;
|
||||
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
|
||||
@@ -187,6 +194,8 @@ private:
|
||||
Mode m_mode;
|
||||
Mode m_oldMode;
|
||||
|
||||
Id m_schedulerId;
|
||||
|
||||
std::set<Id> m_currentActiveTokenIds;
|
||||
std::set<Id> m_currentActiveLocationIds;
|
||||
std::set<Id> m_currentActiveLocalLocationIds;
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMouseEvent>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "MessageHistoryToPosition.h"
|
||||
#include "MessageTabOpenWith.h"
|
||||
#include "ResourcePaths.h"
|
||||
#include "utilityString.h"
|
||||
|
||||
@@ -12,11 +14,11 @@
|
||||
#include "utilityQt.h"
|
||||
|
||||
#include "GraphViewStyle.h"
|
||||
#include "SearchMatch.h"
|
||||
#include "ColorScheme.h"
|
||||
|
||||
QtHistoryItem::QtHistoryItem(const SearchMatch& match, size_t index, bool isCurrent)
|
||||
: index(index)
|
||||
, m_match(match)
|
||||
{
|
||||
QBoxLayout* layout = new QHBoxLayout();
|
||||
layout->setSpacing(0);
|
||||
@@ -74,6 +76,11 @@ QSize QtHistoryItem::getSizeHint() const
|
||||
return QSize(m_name->fontMetrics().width(m_name->text()) + 40, m_name->fontMetrics().height() + 8);
|
||||
}
|
||||
|
||||
const SearchMatch& QtHistoryItem::getMatch() const
|
||||
{
|
||||
return m_match;
|
||||
}
|
||||
|
||||
void QtHistoryItem::enterEvent(QEvent *event)
|
||||
{
|
||||
QWidget::enterEvent(event);
|
||||
@@ -111,13 +118,36 @@ void QtHistoryItem::leaveEvent(QEvent *event)
|
||||
}
|
||||
|
||||
|
||||
|
||||
QtHistoryListWidget::QtHistoryListWidget(QWidget* parent)
|
||||
: QListWidget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void QtHistoryListWidget::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
if (event->button() == Qt::MiddleButton)
|
||||
{
|
||||
QtHistoryItem* item = dynamic_cast<QtHistoryItem*>(itemWidget(itemAt(event->pos())));
|
||||
if (item)
|
||||
{
|
||||
MessageTabOpenWith(item->getMatch()).dispatch();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
QListWidget::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
QtHistoryList::QtHistoryList(const std::vector<SearchMatch>& history, size_t currentIndex)
|
||||
: m_currentIndex(currentIndex)
|
||||
{
|
||||
setWindowFlags(Qt::Popup);
|
||||
setObjectName("history");
|
||||
|
||||
m_list = new QListWidget(this);
|
||||
m_list = new QtHistoryListWidget(this);
|
||||
m_list->setObjectName("history_list");
|
||||
m_list->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
m_list->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
@@ -141,8 +171,8 @@ void QtHistoryList::showPopup(QPoint pos)
|
||||
QSize size(50, 2);
|
||||
for (int i = 0; i < m_list->count(); i++)
|
||||
{
|
||||
QtHistoryItem* it = dynamic_cast<QtHistoryItem*>(m_list->itemWidget(m_list->item(i)));
|
||||
QSize itemSize = it->getSizeHint();
|
||||
QtHistoryItem* item = dynamic_cast<QtHistoryItem*>(m_list->itemWidget(m_list->item(i)));
|
||||
QSize itemSize = item->getSizeHint();
|
||||
if (itemSize.width() > size.width())
|
||||
{
|
||||
size.setWidth(itemSize.width());
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
|
||||
#include <QListWidget>
|
||||
|
||||
#include "SearchMatch.h"
|
||||
|
||||
class QLabel;
|
||||
struct SearchMatch;
|
||||
|
||||
class QtHistoryItem
|
||||
: public QWidget
|
||||
@@ -16,6 +17,8 @@ public:
|
||||
|
||||
QSize getSizeHint() const;
|
||||
|
||||
const SearchMatch& getMatch() const;
|
||||
|
||||
size_t index;
|
||||
|
||||
protected:
|
||||
@@ -29,6 +32,19 @@ private:
|
||||
QWidget* m_indicator;
|
||||
std::string m_indicatorColor;
|
||||
std::string m_indicatorHoverColor;
|
||||
|
||||
const SearchMatch m_match;
|
||||
};
|
||||
|
||||
|
||||
class QtHistoryListWidget
|
||||
: public QListWidget
|
||||
{
|
||||
public:
|
||||
QtHistoryListWidget(QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
};
|
||||
|
||||
|
||||
@@ -52,7 +68,7 @@ private slots:
|
||||
void onItemClicked(QListWidgetItem *item);
|
||||
|
||||
private:
|
||||
QListWidget* m_list;
|
||||
QtHistoryListWidget* m_list;
|
||||
size_t m_currentIndex;
|
||||
};
|
||||
|
||||
|
||||
@@ -141,10 +141,15 @@ void QtScreenSearchBox::setMatchIndex(size_t matchIndex)
|
||||
|
||||
void QtScreenSearchBox::addResponder(const std::string& name)
|
||||
{
|
||||
if (m_checkBoxes.find(name) != m_checkBoxes.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QCheckBox* box = new QCheckBox(name.c_str());
|
||||
box->setObjectName("filter_checkbox");
|
||||
box->setChecked(true);
|
||||
m_checkBoxes.push_back(box);
|
||||
m_checkBoxes.emplace(name, box);
|
||||
m_checkboxLayout->addWidget(box);
|
||||
|
||||
connect(box, &QCheckBox::stateChanged, this, &QtScreenSearchBox::findMatches);
|
||||
@@ -173,11 +178,11 @@ void QtScreenSearchBox::findMatches()
|
||||
[this](ScreenSearchController* controller)
|
||||
{
|
||||
std::set<std::string> responderNames;
|
||||
for (QCheckBox* box : m_checkBoxes)
|
||||
for (auto p : m_checkBoxes)
|
||||
{
|
||||
if (box->isChecked())
|
||||
if (p.second->isChecked())
|
||||
{
|
||||
responderNames.insert(box->text().toStdString());
|
||||
responderNames.insert(p.first);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ private:
|
||||
QtSelfRefreshIconButton* m_closeButton;
|
||||
|
||||
QHBoxLayout* m_checkboxLayout;
|
||||
std::vector<QCheckBox*> m_checkBoxes;
|
||||
std::map<std::string, QCheckBox*> m_checkBoxes;
|
||||
|
||||
size_t m_matchCount = 0;
|
||||
size_t m_matchIndex = 0;
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "QtTabBar.h"
|
||||
|
||||
QtTabBar::QtTabBar(QWidget* parent)
|
||||
: QTabBar(parent)
|
||||
{
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
|
||||
QSize QtTabBar::minimumSizeHint() const
|
||||
{
|
||||
return QSize(0, QTabBar::minimumSizeHint().height());
|
||||
}
|
||||
|
||||
QSize QtTabBar::tabSizeHint(int index) const
|
||||
{
|
||||
return QSize(300, QTabBar::tabSizeHint(index).height());
|
||||
}
|
||||
|
||||
QSize QtTabBar::minimumTabSizeHint(int index) const
|
||||
{
|
||||
return QSize(45, QTabBar::minimumTabSizeHint(index).height());
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef QT_TAB_BAR_H
|
||||
#define QT_TAB_BAR_H
|
||||
|
||||
#include <QTabBar>
|
||||
|
||||
class QtTabBar
|
||||
: public QTabBar
|
||||
{
|
||||
public:
|
||||
QtTabBar(QWidget* parent = nullptr);
|
||||
|
||||
protected:
|
||||
QSize minimumSizeHint() const override;
|
||||
|
||||
QSize tabSizeHint(int index) const override;
|
||||
QSize minimumTabSizeHint(int index) const override;
|
||||
};
|
||||
|
||||
#endif // QT_TAB_BAR_H
|
||||
@@ -22,10 +22,11 @@
|
||||
#include "utilityQt.h"
|
||||
#include "ApplicationSettings.h"
|
||||
#include "MessageActivateLegend.h"
|
||||
#include "MessageBookmarkCreate.h"
|
||||
#include "MessageCodeShowDefinition.h"
|
||||
#include "MessageDisplayBookmarkCreator.h"
|
||||
#include "MessageGraphNodeExpand.h"
|
||||
#include "MessageGraphNodeHide.h"
|
||||
#include "MessageTabOpenWith.h"
|
||||
#include "ResourcePaths.h"
|
||||
#include "utilityApp.h"
|
||||
|
||||
@@ -55,10 +56,10 @@ QtGraphicsView::QtGraphicsView(QWidget* parent)
|
||||
m_zoomLabelTimer = std::make_shared<QTimer>(this);
|
||||
connect(m_zoomLabelTimer.get(), &QTimer::timeout, this, &QtGraphicsView::hideZoomLabel);
|
||||
|
||||
m_exportGraphAction = new QAction("Save as Image", this);
|
||||
m_exportGraphAction->setStatusTip("Save this graph as image file");
|
||||
m_exportGraphAction->setToolTip("Save this graph as image file");
|
||||
connect(m_exportGraphAction, &QAction::triggered, this, &QtGraphicsView::exportGraph);
|
||||
m_openInTabAction = new QAction("Open in New Tab", this);
|
||||
m_openInTabAction->setStatusTip("Open this node in a new tab");
|
||||
m_openInTabAction->setToolTip("Open this node in a new tab");
|
||||
connect(m_openInTabAction, &QAction::triggered, this, &QtGraphicsView::openInTab);
|
||||
|
||||
m_copyNodeNameAction = new QAction("Copy Name", this);
|
||||
m_copyNodeNameAction->setStatusTip("Copies the name of this node to the clipboard");
|
||||
@@ -98,6 +99,11 @@ QtGraphicsView::QtGraphicsView(QWidget* parent)
|
||||
m_bookmarkNodeAction->setToolTip("Create a bookmark for this node");
|
||||
connect(m_bookmarkNodeAction, &QAction::triggered, this, &QtGraphicsView::bookmarkNode);
|
||||
|
||||
m_exportGraphAction = new QAction("Save as Image", this);
|
||||
m_exportGraphAction->setStatusTip("Save this graph as image file");
|
||||
m_exportGraphAction->setToolTip("Save this graph as image file");
|
||||
connect(m_exportGraphAction, &QAction::triggered, this, &QtGraphicsView::exportGraph);
|
||||
|
||||
m_zoomState = new QPushButton(this);
|
||||
m_zoomState->setObjectName("zoom_state");
|
||||
m_zoomState->hide();
|
||||
@@ -175,7 +181,7 @@ void QtGraphicsView::ensureVisibleAnimated(const QRectF& rect, int xmargin, int
|
||||
|
||||
ensureVisible(rect, xmargin, ymargin);
|
||||
|
||||
if (ApplicationSettings::getInstance()->getUseAnimations())
|
||||
if (ApplicationSettings::getInstance()->getUseAnimations() && isVisible())
|
||||
{
|
||||
int xval2 = horizontalScrollBar()->value();
|
||||
int yval2 = verticalScrollBar()->value();
|
||||
@@ -345,6 +351,7 @@ void QtGraphicsView::wheelEvent(QWheelEvent* event)
|
||||
|
||||
void QtGraphicsView::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
m_openInTabNodeId = 0;
|
||||
m_clipboardNodeName = L"";
|
||||
m_collapseNodeId = 0;
|
||||
m_expandNodeId = 0;
|
||||
@@ -369,6 +376,7 @@ void QtGraphicsView::contextMenuEvent(QContextMenuEvent* event)
|
||||
if (dataNode)
|
||||
{
|
||||
m_clipboardNodeName = dataNode->getName();
|
||||
m_openInTabNodeId = dataNode->getTokenId();
|
||||
m_bookmarkNodeId = dataNode->getTokenId();
|
||||
clipboardFilePath = dataNode->getFilePath();
|
||||
}
|
||||
@@ -408,6 +416,7 @@ void QtGraphicsView::contextMenuEvent(QContextMenuEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
m_openInTabAction->setEnabled(m_openInTabNodeId);
|
||||
m_collapseAction->setEnabled(m_collapseNodeId);
|
||||
m_expandAction->setEnabled(m_expandNodeId);
|
||||
m_showDefinitionAction->setEnabled(m_hideNodeId);
|
||||
@@ -419,8 +428,8 @@ void QtGraphicsView::contextMenuEvent(QContextMenuEvent* event)
|
||||
|
||||
QtContextMenu menu(event, this);
|
||||
|
||||
menu.addSeparator();
|
||||
menu.addAction(m_exportGraphAction);
|
||||
menu.addAction(m_openInTabAction);
|
||||
menu.addUndoActions();
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
@@ -438,6 +447,9 @@ void QtGraphicsView::contextMenuEvent(QContextMenuEvent* event)
|
||||
menu.addAction(m_hideEdgeAction);
|
||||
menu.addAction(m_bookmarkNodeAction);
|
||||
|
||||
menu.addSeparator();
|
||||
menu.addAction(m_exportGraphAction);
|
||||
|
||||
menu.addSeparator();
|
||||
menu.addAction(m_copyNodeNameAction);
|
||||
menu.addFileActions(clipboardFilePath);
|
||||
@@ -507,6 +519,11 @@ void QtGraphicsView::stopTimer()
|
||||
m_timer->stop();
|
||||
}
|
||||
|
||||
void QtGraphicsView::openInTab()
|
||||
{
|
||||
MessageTabOpenWith(m_openInTabNodeId).dispatch();
|
||||
}
|
||||
|
||||
void QtGraphicsView::exportGraph()
|
||||
{
|
||||
const QString exportNotice = "Exported from Sourcetrail";
|
||||
@@ -616,7 +633,7 @@ void QtGraphicsView::hideEdge()
|
||||
|
||||
void QtGraphicsView::bookmarkNode()
|
||||
{
|
||||
MessageDisplayBookmarkCreator(m_bookmarkNodeId).dispatch();
|
||||
MessageBookmarkCreate(m_bookmarkNodeId).dispatch();
|
||||
}
|
||||
|
||||
void QtGraphicsView::zoomInPressed()
|
||||
|
||||
@@ -55,6 +55,8 @@ private slots:
|
||||
void updateTimer();
|
||||
void stopTimer();
|
||||
|
||||
void openInTab();
|
||||
|
||||
void exportGraph();
|
||||
void copyNodeName();
|
||||
|
||||
@@ -91,6 +93,7 @@ private:
|
||||
bool m_shift;
|
||||
|
||||
std::wstring m_clipboardNodeName;
|
||||
Id m_openInTabNodeId;
|
||||
Id m_hideNodeId;
|
||||
Id m_hideEdgeId;
|
||||
Id m_bookmarkNodeId;
|
||||
@@ -101,7 +104,8 @@ private:
|
||||
std::shared_ptr<QTimer> m_timerStopper;
|
||||
std::shared_ptr<QTimer> m_zoomLabelTimer;
|
||||
|
||||
QAction* m_exportGraphAction;
|
||||
QAction* m_openInTabAction;
|
||||
|
||||
QAction* m_copyNodeNameAction;
|
||||
QAction* m_collapseAction;
|
||||
QAction* m_expandAction;
|
||||
@@ -110,6 +114,8 @@ private:
|
||||
QAction* m_hideEdgeAction;
|
||||
QAction* m_bookmarkNodeAction;
|
||||
|
||||
QAction* m_exportGraphAction;
|
||||
|
||||
QPushButton* m_zoomState;
|
||||
QtSelfRefreshIconButton* m_zoomInButton;
|
||||
QtSelfRefreshIconButton* m_zoomOutButton;
|
||||
|
||||
@@ -25,8 +25,6 @@ QtContextMenu::QtContextMenu(QContextMenuEvent* event, QWidget* origin)
|
||||
, m_point(event->globalPos())
|
||||
{
|
||||
getInstance();
|
||||
|
||||
addUndoActions();
|
||||
}
|
||||
|
||||
void QtContextMenu::addAction(QAction* action)
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
#include "QtBookmarkButtonsView.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QHBoxLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "MessageBookmarkBrowse.h"
|
||||
#include "MessageBookmarkCreate.h"
|
||||
#include "MessageBookmarkDelete.h"
|
||||
#include "MessageBookmarkEdit.h"
|
||||
#include "QtSearchBarButton.h"
|
||||
#include "QtViewWidgetWrapper.h"
|
||||
#include "ResourcePaths.h"
|
||||
#include "utilityQt.h"
|
||||
|
||||
QtBookmarkButtonsView::QtBookmarkButtonsView(ViewLayout* viewLayout)
|
||||
: BookmarkButtonsView(viewLayout)
|
||||
, m_createButtonState(MessageBookmarkButtonState::CANNOT_CREATE)
|
||||
{
|
||||
m_widget = new QFrame();
|
||||
}
|
||||
|
||||
void QtBookmarkButtonsView::createWidgetWrapper()
|
||||
{
|
||||
setWidgetWrapper(std::make_shared<QtViewWidgetWrapper>(m_widget));
|
||||
}
|
||||
|
||||
void QtBookmarkButtonsView::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, &QtBookmarkButtonsView::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");
|
||||
layout->addWidget(m_showBookmarksButton);
|
||||
|
||||
connect(m_showBookmarksButton, &QPushButton::clicked, this, &QtBookmarkButtonsView::showBookmarksClicked);
|
||||
}
|
||||
|
||||
void QtBookmarkButtonsView::refreshView()
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_widget->setStyleSheet(utility::getStyleSheet(
|
||||
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/bookmark_view.css")
|
||||
).c_str());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtBookmarkButtonsView::setCreateButtonState(const MessageBookmarkButtonState::ButtonState& state)
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_createButtonState = state;
|
||||
|
||||
m_createBookmarkButton->setIconPath(
|
||||
ResourcePaths::getGuiPath().concatenate(L"bookmark_view/images/edit_bookmark_icon.png"));
|
||||
|
||||
if (state == MessageBookmarkButtonState::CAN_CREATE)
|
||||
{
|
||||
m_createBookmarkButton->setEnabled(true);
|
||||
}
|
||||
else if (state == MessageBookmarkButtonState::CANNOT_CREATE)
|
||||
{
|
||||
m_createBookmarkButton->setEnabled(false);
|
||||
}
|
||||
else if (state == MessageBookmarkButtonState::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 QtBookmarkButtonsView::createBookmarkClicked()
|
||||
{
|
||||
if (m_createButtonState == MessageBookmarkButtonState::CAN_CREATE)
|
||||
{
|
||||
MessageBookmarkCreate().dispatch();
|
||||
}
|
||||
else if (m_createButtonState == MessageBookmarkButtonState::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
|
||||
{
|
||||
MessageBookmarkEdit().dispatch();
|
||||
}
|
||||
else if (ret == 1)
|
||||
{
|
||||
MessageBookmarkDelete().dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkButtonsView::showBookmarksClicked()
|
||||
{
|
||||
MessageBookmarkBrowse().dispatch();
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef QT_BOOKMARK_BUTTONS_VIEW_H
|
||||
#define QT_BOOKMARK_BUTTONS_VIEW_H
|
||||
|
||||
#include "BookmarkButtonsView.h"
|
||||
|
||||
#include "QtThreadedFunctor.h"
|
||||
|
||||
class QFrame;
|
||||
class QtSearchBarButton;
|
||||
|
||||
class QtBookmarkButtonsView
|
||||
: public QObject
|
||||
, public BookmarkButtonsView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtBookmarkButtonsView(ViewLayout* viewLayout);
|
||||
virtual ~QtBookmarkButtonsView() = default;
|
||||
|
||||
// View implementation
|
||||
void createWidgetWrapper() override;
|
||||
void initView() override;
|
||||
void refreshView() override;
|
||||
|
||||
// BookmarkView implementation
|
||||
void setCreateButtonState(const MessageBookmarkButtonState::ButtonState& state) override;
|
||||
|
||||
private slots:
|
||||
void createBookmarkClicked();
|
||||
void showBookmarksClicked();
|
||||
|
||||
private:
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
|
||||
QFrame* m_widget;
|
||||
|
||||
QtSearchBarButton* m_createBookmarkButton;
|
||||
QtSearchBarButton* m_showBookmarksButton;
|
||||
|
||||
MessageBookmarkButtonState::ButtonState m_createButtonState;
|
||||
};
|
||||
|
||||
#endif // QT_BOOKMARK_BUTTONS_VIEW_H
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -2,24 +2,19 @@
|
||||
#define QT_BOOKMARK_VIEW_H
|
||||
|
||||
#include "BookmarkController.h"
|
||||
#include "ControllerProxy.h"
|
||||
#include "BookmarkView.h"
|
||||
|
||||
#include "ControllerProxy.h"
|
||||
#include "QtThreadedFunctor.h"
|
||||
|
||||
class QFrame;
|
||||
class QtBookmarkBrowser;
|
||||
class QtSearchBarButton;
|
||||
|
||||
class QtBookmarkView
|
||||
: public QObject
|
||||
, public BookmarkView
|
||||
: public BookmarkView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtBookmarkView(ViewLayout* viewLayout);
|
||||
virtual ~QtBookmarkView();
|
||||
virtual ~QtBookmarkView() = default;
|
||||
|
||||
// View implementation
|
||||
virtual void createWidgetWrapper();
|
||||
@@ -27,34 +22,19 @@ public:
|
||||
virtual void refreshView();
|
||||
|
||||
// BookmarkView implementation
|
||||
virtual void setCreateButtonState(const CreateButtonState& state);
|
||||
|
||||
virtual void displayBookmarkCreator(
|
||||
const std::vector<std::wstring>& names, const std::vector<BookmarkCategory>& categories, Id nodeId);
|
||||
virtual void displayBookmarkEditor(
|
||||
std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories);
|
||||
|
||||
virtual void displayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
virtual void enableDisplayBookmarks(bool enable);
|
||||
|
||||
virtual bool bookmarkBrowserIsVisible() const;
|
||||
|
||||
private slots:
|
||||
void createBookmarkClicked();
|
||||
void showBookmarksClicked();
|
||||
|
||||
private:
|
||||
ControllerProxy<BookmarkController> m_controllerProxy;
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
|
||||
QFrame* m_widget;
|
||||
|
||||
QtSearchBarButton* m_createBookmarkButton;
|
||||
QtSearchBarButton* m_showBookmarksButton;
|
||||
|
||||
QtBookmarkBrowser* m_bookmarkBrowser;
|
||||
|
||||
BookmarkView::CreateButtonState m_createButtonState;
|
||||
};
|
||||
|
||||
#endif // QT_BOOKMARK_VIEW_H
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "QtCodeView.h"
|
||||
|
||||
#include "CodeController.h"
|
||||
#include "ResourcePaths.h"
|
||||
#include "tracing.h"
|
||||
|
||||
@@ -31,6 +32,11 @@ void QtCodeView::initView()
|
||||
|
||||
void QtCodeView::refreshView()
|
||||
{
|
||||
if (getController())
|
||||
{
|
||||
m_widget->setSchedulerId(getController()->getTabId());
|
||||
}
|
||||
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
TRACE("refresh");
|
||||
@@ -82,6 +88,11 @@ void QtCodeView::deactivateMatch(size_t matchIndex)
|
||||
|
||||
void QtCodeView::clearMatches()
|
||||
{
|
||||
if (!m_widget->hasScreenMatches())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_onQtThread(
|
||||
[this]()
|
||||
{
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "QtWindow.h"
|
||||
#include "MessageIndexingStatus.h"
|
||||
#include "MessageStatus.h"
|
||||
#include "TabId.h"
|
||||
#include "TaskLambda.h"
|
||||
#include "utility.h"
|
||||
#include "Project.h"
|
||||
@@ -168,7 +169,7 @@ void QtDialogView::startIndexingDialog(
|
||||
);
|
||||
timer->start(200);
|
||||
|
||||
Task::dispatch(std::make_shared<TaskLambda>(
|
||||
Task::dispatch(TabId::app(), std::make_shared<TaskLambda>(
|
||||
[=]()
|
||||
{
|
||||
RefreshInfo info = project->getRefreshInfo(refreshMode);
|
||||
@@ -194,7 +195,7 @@ void QtDialogView::startIndexingDialog(
|
||||
[=](RefreshMode refreshMode)
|
||||
{
|
||||
RefreshInfo info = m_refreshInfos.find(refreshMode)->second;
|
||||
Task::dispatch(std::make_shared<TaskLambda>(
|
||||
Task::dispatch(TabId::app(), std::make_shared<TaskLambda>(
|
||||
[=]()
|
||||
{
|
||||
onStartIndexing(info);
|
||||
@@ -208,7 +209,7 @@ void QtDialogView::startIndexingDialog(
|
||||
connect(window, &QtWindow::canceled,
|
||||
[=]()
|
||||
{
|
||||
Task::dispatch(std::make_shared<TaskLambda>(
|
||||
Task::dispatch(TabId::app(), std::make_shared<TaskLambda>(
|
||||
[=]()
|
||||
{
|
||||
onCancelIndexing();
|
||||
|
||||
@@ -13,14 +13,15 @@
|
||||
#include <QStandardItem>
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
#include "ColorScheme.h"
|
||||
#include "MessageProjectEdit.h"
|
||||
#include "QtHelpButton.h"
|
||||
#include "QtIconButton.h"
|
||||
#include "QtTable.h"
|
||||
#include "utilityQt.h"
|
||||
#include "QtViewWidgetWrapper.h"
|
||||
#include "ColorScheme.h"
|
||||
#include "MessageProjectEdit.h"
|
||||
#include "ResourcePaths.h"
|
||||
#include "TabId.h"
|
||||
#include "utilityQt.h"
|
||||
|
||||
QIcon QtErrorView::s_errorIcon;
|
||||
|
||||
@@ -54,8 +55,7 @@ QWidget* SelectableDelegate::createEditor(
|
||||
|
||||
QtErrorView::QtErrorView(ViewLayout* viewLayout)
|
||||
: ErrorView(viewLayout)
|
||||
, m_controllerProxy(this)
|
||||
, m_ignoreRowSelection(false)
|
||||
, m_controllerProxy(this, TabId::app())
|
||||
{
|
||||
s_errorIcon = QIcon(QString::fromStdWString(ResourcePaths::getGuiPath().concatenate(L"indexing_dialog/error.png").wstr()));
|
||||
}
|
||||
@@ -78,8 +78,8 @@ void QtErrorView::initView()
|
||||
layout->setSpacing(0);
|
||||
widget->setLayout(layout);
|
||||
|
||||
m_table = new QtTable(this);
|
||||
m_model = new QStandardItemModel(this);
|
||||
m_table = new QtTable(widget);
|
||||
m_model = new QStandardItemModel(widget);
|
||||
m_table->setSortingEnabled(true);
|
||||
m_table->setModel(m_model);
|
||||
m_table->setItemDelegate(new SelectableDelegate(m_table));
|
||||
@@ -97,10 +97,10 @@ void QtErrorView::initView()
|
||||
headers << "ID" << "Type" << "Message" << "File" << "Line" << "Indexed" << "Translation Unit";
|
||||
m_model->setHorizontalHeaderLabels(headers);
|
||||
|
||||
connect(m_table->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||
[=](const QModelIndex& index, const QModelIndex& previousIndex)
|
||||
connect(m_table, &QTableView::clicked,
|
||||
[=](const QModelIndex& index)
|
||||
{
|
||||
if (index.isValid() && !m_ignoreRowSelection)
|
||||
if (index.isValid())
|
||||
{
|
||||
if (m_model->item(index.row(), Column::FILE) == nullptr)
|
||||
{
|
||||
@@ -267,9 +267,7 @@ void QtErrorView::setErrorId(Id errorId)
|
||||
|
||||
if (items.size() == 1)
|
||||
{
|
||||
m_ignoreRowSelection = true;
|
||||
m_table->selectRow(items.at(0)->row());
|
||||
m_ignoreRowSelection = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ private slots:
|
||||
void errorFilterChanged(int i = 0);
|
||||
|
||||
private:
|
||||
enum Column
|
||||
enum Column
|
||||
{
|
||||
ID = 0,
|
||||
TYPE = 1,
|
||||
@@ -88,8 +88,6 @@ private:
|
||||
|
||||
QStandardItemModel* m_model;
|
||||
QtTable* m_table;
|
||||
|
||||
bool m_ignoreRowSelection;
|
||||
};
|
||||
|
||||
#endif // QT_ERROR_VIEW_H
|
||||
|
||||
@@ -287,6 +287,11 @@ void QtGraphView::deactivateMatch(size_t matchIndex)
|
||||
|
||||
void QtGraphView::clearMatches()
|
||||
{
|
||||
if (m_matchedNodes.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_onQtThread(
|
||||
[this]()
|
||||
{
|
||||
@@ -384,7 +389,7 @@ void QtGraphView::rebuildGraph(
|
||||
m_scrollToTop = params.scrollToTop;
|
||||
m_isIndexedList = params.isIndexedList;
|
||||
|
||||
if (params.animatedTransition && ApplicationSettings::getInstance()->getUseAnimations())
|
||||
if (params.animatedTransition && ApplicationSettings::getInstance()->getUseAnimations() && view->isVisible())
|
||||
{
|
||||
createTransition();
|
||||
}
|
||||
@@ -755,7 +760,7 @@ void QtGraphView::groupingUpdated(QPushButton* button)
|
||||
|
||||
void QtGraphView::performScroll(QScrollBar* scrollBar, int value) const
|
||||
{
|
||||
if (ApplicationSettings::getInstance()->getUseAnimations())
|
||||
if (ApplicationSettings::getInstance()->getUseAnimations() && getView()->isVisible())
|
||||
{
|
||||
QPropertyAnimation* anim = new QPropertyAnimation(scrollBar, "value");
|
||||
anim->setDuration(300);
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include "QtViewWidgetWrapper.h"
|
||||
#include "QtMainWindow.h"
|
||||
|
||||
QtMainView::QtMainView()
|
||||
QtMainView::QtMainView(const ViewFactory* viewFactory, StorageAccess* storageAccess)
|
||||
: MainView(viewFactory, storageAccess)
|
||||
{
|
||||
m_window = std::make_shared<QtMainWindow>();
|
||||
m_window->show();
|
||||
@@ -11,6 +12,8 @@ QtMainView::QtMainView()
|
||||
|
||||
QtMainView::~QtMainView()
|
||||
{
|
||||
// clear components to avoid double deletion of views when destroying m_window
|
||||
m_componentManager.clear();
|
||||
}
|
||||
|
||||
QtMainWindow* QtMainView::getMainWindow() const
|
||||
@@ -24,6 +27,11 @@ void QtMainView::addView(View* view)
|
||||
m_window->addView(view);
|
||||
}
|
||||
|
||||
void QtMainView::overrideView(View* view)
|
||||
{
|
||||
m_window->overrideView(view);
|
||||
}
|
||||
|
||||
void QtMainView::removeView(View* view)
|
||||
{
|
||||
std::vector<View*>::iterator it = std::find(m_views.begin(), m_views.end(), view);
|
||||
@@ -72,6 +80,14 @@ View* QtMainView::findFloatingView(const std::string& name) const
|
||||
return m_window->findFloatingView(name);
|
||||
}
|
||||
|
||||
void QtMainView::showOriginalViews()
|
||||
{
|
||||
for (View* view : m_views)
|
||||
{
|
||||
m_window->overrideView(view);
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainView::loadLayout()
|
||||
{
|
||||
m_window->loadLayout();
|
||||
@@ -157,12 +173,22 @@ void QtMainView::updateRecentProjectMenu()
|
||||
);
|
||||
}
|
||||
|
||||
void QtMainView::updateHistoryMenu(const std::vector<std::shared_ptr<MessageBase>>& historyMenuItems)
|
||||
void QtMainView::updateHistoryMenu(std::shared_ptr<MessageBase> message)
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_window->updateHistoryMenu(historyMenuItems);
|
||||
m_window->updateHistoryMenu(message);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtMainView::clearHistoryMenu()
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_window->clearHistoryMenu();
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -177,6 +203,11 @@ void QtMainView::updateBookmarksMenu(const std::vector<std::shared_ptr<Bookmark>
|
||||
);
|
||||
}
|
||||
|
||||
void QtMainView::clearBookmarksMenu()
|
||||
{
|
||||
updateBookmarksMenu({});
|
||||
}
|
||||
|
||||
void QtMainView::handleMessage(MessageForceEnterLicense* message)
|
||||
{
|
||||
LicenseChecker::LicenseState state = message->state;
|
||||
|
||||
@@ -24,45 +24,52 @@ class QtMainView
|
||||
, public MessageListener<MessageProjectNew>
|
||||
{
|
||||
public:
|
||||
QtMainView();
|
||||
QtMainView(const ViewFactory* viewFactory, StorageAccess* storageAccess);
|
||||
virtual ~QtMainView();
|
||||
|
||||
QtMainWindow* getMainWindow() const;
|
||||
|
||||
// ViewLayout implementation
|
||||
virtual void addView(View* view);
|
||||
virtual void removeView(View* view);
|
||||
void addView(View* view) override;
|
||||
void overrideView(View* view) override;
|
||||
void removeView(View* view) override;
|
||||
|
||||
virtual void showView(View* view);
|
||||
virtual void hideView(View* view);
|
||||
void showView(View* view) override;
|
||||
void hideView(View* view) override;
|
||||
|
||||
virtual void setViewEnabled(View* view, bool enabled);
|
||||
void setViewEnabled(View* view, bool enabled) override;
|
||||
|
||||
virtual View* findFloatingView(const std::string& name) const;
|
||||
View* findFloatingView(const std::string& name) const override;
|
||||
|
||||
virtual QStatusBar* getStatusBar();
|
||||
virtual void setStatusBar(QStatusBar* statusBar);
|
||||
void showOriginalViews() override;
|
||||
|
||||
QStatusBar* getStatusBar();
|
||||
void setStatusBar(QStatusBar* statusBar);
|
||||
|
||||
// MainView implementation
|
||||
virtual void loadLayout();
|
||||
virtual void saveLayout();
|
||||
void loadLayout() override;
|
||||
void saveLayout() override;
|
||||
|
||||
virtual void loadWindow(bool showStartWindow);
|
||||
void loadWindow(bool showStartWindow) override;
|
||||
|
||||
virtual void refreshView();
|
||||
void refreshView() override;
|
||||
|
||||
virtual void hideStartScreen();
|
||||
virtual void setTitle(const std::wstring& title);
|
||||
virtual void activateWindow();
|
||||
void hideStartScreen() override;
|
||||
void setTitle(const std::wstring& title) override;
|
||||
void activateWindow() override;
|
||||
|
||||
virtual void updateRecentProjectMenu();
|
||||
virtual void updateHistoryMenu(const std::vector<std::shared_ptr<MessageBase>>& historyMenuItems);
|
||||
virtual void updateBookmarksMenu(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
void updateRecentProjectMenu() override;
|
||||
|
||||
void updateHistoryMenu(std::shared_ptr<MessageBase> message) override;
|
||||
void clearHistoryMenu() override;
|
||||
|
||||
void updateBookmarksMenu(const std::vector<std::shared_ptr<Bookmark>>& bookmarks) override;
|
||||
void clearBookmarksMenu() override;
|
||||
|
||||
private:
|
||||
void handleMessage(MessageForceEnterLicense* message);
|
||||
void handleMessage(MessageProjectEdit* message);
|
||||
void handleMessage(MessageProjectNew* message);
|
||||
void handleMessage(MessageForceEnterLicense* message) override;
|
||||
void handleMessage(MessageProjectEdit* message) override;
|
||||
void handleMessage(MessageProjectNew* message) override;
|
||||
|
||||
std::shared_ptr<QtMainWindow> m_window;
|
||||
std::vector<View*> m_views;
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
#include <QToolBar>
|
||||
|
||||
#include "QtScreenSearchBox.h"
|
||||
#include "utilityQt.h"
|
||||
#include "QtMainView.h"
|
||||
#include "QtViewWidgetWrapper.h"
|
||||
#include "QtMainWindow.h"
|
||||
#include "ResourcePaths.h"
|
||||
#include "TabId.h"
|
||||
#include "utilityQt.h"
|
||||
|
||||
QtScreenSearchView::QtScreenSearchView(ViewLayout* viewLayout)
|
||||
: ScreenSearchView(viewLayout)
|
||||
, m_controllerProxy(this)
|
||||
, m_controllerProxy(this, TabId::app())
|
||||
{
|
||||
m_widget = new QtScreenSearchBox(&m_controllerProxy);
|
||||
|
||||
|
||||
@@ -7,12 +7,10 @@
|
||||
QtStatusBarView::QtStatusBarView(ViewLayout* viewLayout)
|
||||
: StatusBarView(viewLayout)
|
||||
{
|
||||
m_widget = std::make_shared<QtStatusBar>();
|
||||
m_widget = new QtStatusBar();
|
||||
m_widget->show();
|
||||
|
||||
QtMainView* mw = static_cast<QtMainView*>(viewLayout);
|
||||
QStatusBar* sb = static_cast<QStatusBar*>(m_widget.get());
|
||||
mw->setStatusBar(sb);
|
||||
dynamic_cast<QtMainView*>(viewLayout)->setStatusBar(m_widget);
|
||||
}
|
||||
|
||||
void QtStatusBarView::createWidgetWrapper()
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
private:
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
|
||||
std::shared_ptr<QtStatusBar> m_widget;
|
||||
QtStatusBar* m_widget;
|
||||
};
|
||||
|
||||
#endif // !QT_STATUS_BAR_VIEW_H
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
#include "QtTabsView.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QStyle>
|
||||
#include <QVariant>
|
||||
|
||||
#include "Application.h"
|
||||
#include "ColorScheme.h"
|
||||
#include "GraphViewStyle.h"
|
||||
#include "QtIconButton.h"
|
||||
#include "QtTabBar.h"
|
||||
#include "QtViewWidgetWrapper.h"
|
||||
#include "ResourcePaths.h"
|
||||
#include "TabId.h"
|
||||
#include "TabsController.h"
|
||||
#include "utilityQt.h"
|
||||
|
||||
QtTabsView::QtTabsView(ViewLayout* viewLayout)
|
||||
: TabsView(viewLayout)
|
||||
, m_widget(nullptr)
|
||||
, m_insertedTabCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
void QtTabsView::createWidgetWrapper()
|
||||
{
|
||||
m_widget = new QWidget();
|
||||
setWidgetWrapper(std::make_shared<QtViewWidgetWrapper>(m_widget));
|
||||
}
|
||||
|
||||
void QtTabsView::initView()
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout(m_widget);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
|
||||
QWidget* front = new QWidget();
|
||||
front->setMinimumWidth(5);
|
||||
front->setObjectName("side_area");
|
||||
layout->addWidget(front);
|
||||
|
||||
m_tabBar = new QtTabBar();
|
||||
m_tabBar->setDrawBase(false);
|
||||
m_tabBar->setMinimumWidth(0);
|
||||
m_tabBar->setMovable(true);
|
||||
m_tabBar->setElideMode(Qt::ElideMiddle);
|
||||
layout->addWidget(m_tabBar);
|
||||
|
||||
connect(m_tabBar, &QTabBar::currentChanged, this, &QtTabsView::changedTab);
|
||||
|
||||
QPushButton* addButton = new QtSelfRefreshIconButton(
|
||||
"", ResourcePaths::getGuiPath().concatenate(L"tabs_view/images/add.png"), "tab/bar/button");
|
||||
addButton->setObjectName("add_button");
|
||||
addButton->setIconSize(QSize(14, 14));
|
||||
|
||||
QWidget* back = new QWidget();
|
||||
back->setObjectName("side_area");
|
||||
QHBoxLayout* backLayout = new QHBoxLayout(back);
|
||||
backLayout->setContentsMargins(3, 0, 5, 0);
|
||||
backLayout->setSpacing(0);
|
||||
backLayout->addWidget(addButton);
|
||||
backLayout->addStretch();
|
||||
layout->addWidget(back);
|
||||
|
||||
connect(addButton, &QPushButton::clicked, this, &QtTabsView::addTab);
|
||||
}
|
||||
|
||||
void QtTabsView::refreshView()
|
||||
{
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
setStyleSheet();
|
||||
});
|
||||
}
|
||||
|
||||
void QtTabsView::clear()
|
||||
{
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
getController<TabsController>()->onClearTabs();
|
||||
|
||||
m_tabBar->blockSignals(true);
|
||||
|
||||
int c = m_tabBar->count();
|
||||
for (int i = c - 1; i >= 0; i--)
|
||||
{
|
||||
removeTab(i);
|
||||
}
|
||||
|
||||
m_tabBar->blockSignals(false);
|
||||
});
|
||||
}
|
||||
|
||||
void QtTabsView::openTab(bool showTab, SearchMatch match)
|
||||
{
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
insertTab(showTab, match);
|
||||
});
|
||||
}
|
||||
|
||||
void QtTabsView::closeTab()
|
||||
{
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
removeTab(m_tabBar->currentIndex());
|
||||
});
|
||||
}
|
||||
|
||||
void QtTabsView::destroyTab(Id tabId)
|
||||
{
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
getController<TabsController>()->destroyTab(tabId);
|
||||
});
|
||||
}
|
||||
|
||||
void QtTabsView::selectTab(bool next)
|
||||
{
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
int idx = m_tabBar->currentIndex();
|
||||
if (idx != -1)
|
||||
{
|
||||
idx += next ? 1 : -1;
|
||||
m_tabBar->setCurrentIndex((idx + m_tabBar->count()) % m_tabBar->count());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void QtTabsView::updateTab(Id tabId, std::vector<SearchMatch> matches)
|
||||
{
|
||||
m_onQtThread([=]()
|
||||
{
|
||||
for (int i = 0; i < m_tabBar->count(); i++)
|
||||
{
|
||||
if (m_tabBar->tabData(i).toInt() == int(tabId))
|
||||
{
|
||||
setTabState(i, matches);
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void QtTabsView::addTab()
|
||||
{
|
||||
if (Application::getInstance()->isProjectLoaded())
|
||||
{
|
||||
insertTab(true, SearchMatch());
|
||||
}
|
||||
}
|
||||
|
||||
void QtTabsView::insertTab(bool showTab, SearchMatch match)
|
||||
{
|
||||
int tabId = TabId::nextTab();
|
||||
|
||||
m_tabBar->blockSignals(true);
|
||||
|
||||
m_insertedTabCount++;
|
||||
int idx = match.isValid() ? m_tabBar->currentIndex() + m_insertedTabCount : m_tabBar->count() + 1;
|
||||
idx = m_tabBar->insertTab(idx, " Empty Tab ");
|
||||
m_tabBar->setTabData(idx, QVariant(tabId));
|
||||
|
||||
QPushButton* typeCircle = new QPushButton();
|
||||
typeCircle->setObjectName("type_circle");
|
||||
m_tabBar->setTabButton(idx, QTabBar::LeftSide, typeCircle);
|
||||
|
||||
connect(typeCircle, &QPushButton::clicked,
|
||||
[tabId, this]()
|
||||
{
|
||||
for (int i = 0; i < m_tabBar->count(); i++)
|
||||
{
|
||||
if (m_tabBar->tabData(i).toInt() == tabId)
|
||||
{
|
||||
m_tabBar->setCurrentIndex(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
QPushButton* closeButton = new QtSelfRefreshIconButton(
|
||||
"", ResourcePaths::getGuiPath().concatenate(L"tabs_view/images/close.png"), "tab/bar/button");
|
||||
closeButton->setObjectName("close_button");
|
||||
closeButton->setIconSize(QSize(10, 10));
|
||||
m_tabBar->setTabButton(idx, QTabBar::RightSide, closeButton);
|
||||
|
||||
connect(closeButton, &QPushButton::clicked,
|
||||
[tabId, this]()
|
||||
{
|
||||
for (int i = 0; i < m_tabBar->count(); i++)
|
||||
{
|
||||
if (m_tabBar->tabData(i).toInt() == tabId)
|
||||
{
|
||||
removeTab(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
m_tabBar->blockSignals(false);
|
||||
|
||||
getController<TabsController>()->addTab(tabId, match);
|
||||
|
||||
if (m_tabBar->count() == 1)
|
||||
{
|
||||
changedTab(m_tabBar->currentIndex());
|
||||
}
|
||||
else if (showTab)
|
||||
{
|
||||
m_tabBar->setCurrentIndex(idx);
|
||||
}
|
||||
|
||||
setTabState(idx, { });
|
||||
}
|
||||
|
||||
void QtTabsView::changedTab(int index)
|
||||
{
|
||||
m_insertedTabCount = 0;
|
||||
|
||||
getController<TabsController>()->showTab(m_tabBar->tabData(index).toInt());
|
||||
|
||||
for (int i = 0; i < m_tabBar->count(); i++)
|
||||
{
|
||||
QWidget* circle = m_tabBar->tabButton(i, QTabBar::LeftSide);
|
||||
bool selected = (i == index);
|
||||
if (circle->property("selected").toBool() != selected)
|
||||
{
|
||||
circle->setProperty("selected", selected);
|
||||
circle->style()->unpolish(circle);
|
||||
circle->style()->polish(circle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtTabsView::removeTab(int index)
|
||||
{
|
||||
m_insertedTabCount = 0;
|
||||
|
||||
getController<TabsController>()->removeTab(m_tabBar->tabData(index).toInt());
|
||||
m_tabBar->removeTab(index);
|
||||
}
|
||||
|
||||
void QtTabsView::setTabState(int idx, const std::vector<SearchMatch>& matches)
|
||||
{
|
||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||
std::wstring name;
|
||||
std::string color;
|
||||
std::string activeColor;
|
||||
|
||||
if (matches.size())
|
||||
{
|
||||
const SearchMatch& match = matches[0];
|
||||
name = match.getFullName();
|
||||
|
||||
if (match.searchType == SearchMatch::SEARCH_TOKEN)
|
||||
{
|
||||
color = GraphViewStyle::getNodeColor(match.nodeType.getUnderscoredTypeString(), false).fill;
|
||||
activeColor = GraphViewStyle::getNodeColor(match.nodeType.getUnderscoredTypeString(), true).fill;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = scheme->getSearchTypeColor(utility::encodeToUtf8(match.getSearchTypeName()), "fill");
|
||||
activeColor = scheme->getSearchTypeColor(utility::encodeToUtf8(match.getSearchTypeName()), "fill", "hover");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
name = L"Empty Tab";
|
||||
color = scheme->getColor("tab/bar/button/background/press");
|
||||
activeColor = color;
|
||||
}
|
||||
|
||||
m_tabBar->setTabText(idx, ' ' + QString::fromStdWString(name) + ' ');
|
||||
m_tabBar->tabButton(idx, QTabBar::LeftSide)->setStyleSheet(
|
||||
"#type_circle { background-color: " + QString::fromStdString(color) + "; } "
|
||||
"#type_circle[selected=true] { background-color: " + QString::fromStdString(activeColor) + "; } "
|
||||
);
|
||||
}
|
||||
|
||||
void QtTabsView::setStyleSheet()
|
||||
{
|
||||
const std::string css = utility::getStyleSheet(ResourcePaths::getGuiPath().concatenate(L"tabs_view/tabs_view.css"));
|
||||
m_widget->setStyleSheet(css.c_str());
|
||||
|
||||
utility::setWidgetBackgroundColor(m_widget, ColorScheme::getInstance()->getColor("tab/bar/background"));
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef QT_TABS_VIEW_H
|
||||
#define QT_TABS_VIEW_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "TabsController.h"
|
||||
#include "TabsView.h"
|
||||
#include "QtThreadedFunctor.h"
|
||||
|
||||
class QtTabBar;
|
||||
|
||||
class QtTabsView
|
||||
: public QObject
|
||||
, public TabsView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtTabsView(ViewLayout* viewLayout);
|
||||
virtual ~QtTabsView() = default;
|
||||
|
||||
// View implementation
|
||||
void createWidgetWrapper() override;
|
||||
void initView() override;
|
||||
void refreshView() override;
|
||||
|
||||
// TabsView implementation
|
||||
void clear() override;
|
||||
void openTab(bool showTab, SearchMatch match) override;
|
||||
void closeTab() override;
|
||||
void destroyTab(Id tabId) override;
|
||||
void selectTab(bool next) override;
|
||||
void updateTab(Id tabId, std::vector<SearchMatch> matches) override;
|
||||
|
||||
private slots:
|
||||
void addTab();
|
||||
void insertTab(bool showTab, SearchMatch match);
|
||||
void changedTab(int index);
|
||||
void removeTab(int index);
|
||||
|
||||
private:
|
||||
void setTabState(int idx, const std::vector<SearchMatch>& matches);
|
||||
|
||||
void setStyleSheet();
|
||||
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
|
||||
QWidget* m_widget;
|
||||
QtTabBar* m_tabBar;
|
||||
|
||||
size_t m_insertedTabCount;
|
||||
};
|
||||
|
||||
#endif // QT_TABS_VIEW_H
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "QtViewFactory.h"
|
||||
|
||||
#include "GraphViewStyle.h"
|
||||
#include "QtBookmarkButtonsView.h"
|
||||
#include "QtBookmarkView.h"
|
||||
#include "QtCodeView.h"
|
||||
#include "QtCompositeView.h"
|
||||
@@ -15,6 +16,7 @@
|
||||
#include "QtStatusBarView.h"
|
||||
#include "QtStatusView.h"
|
||||
#include "QtTabbedView.h"
|
||||
#include "QtTabsView.h"
|
||||
#include "QtTooltipView.h"
|
||||
#include "QtUndoRedoView.h"
|
||||
|
||||
@@ -22,9 +24,9 @@ QtViewFactory::QtViewFactory()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<MainView> QtViewFactory::createMainView() const
|
||||
std::shared_ptr<MainView> QtViewFactory::createMainView(StorageAccess* storageAccess) const
|
||||
{
|
||||
return std::make_shared<QtMainView>();
|
||||
return std::make_shared<QtMainView>(this, storageAccess);
|
||||
}
|
||||
|
||||
std::shared_ptr<CompositeView> QtViewFactory::createCompositeView(
|
||||
@@ -44,9 +46,14 @@ std::shared_ptr<TabbedView> QtViewFactory::createTabbedView(ViewLayout* viewLayo
|
||||
return ptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<BookmarkButtonsView> QtViewFactory::createBookmarkButtonsView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::createInitAndAddToLayout<QtBookmarkButtonsView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<BookmarkView> QtViewFactory::createBookmarkView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::createInitAndAddToLayout<QtBookmarkView>(viewLayout);
|
||||
return View::createAndInit<QtBookmarkView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<CodeView> QtViewFactory::createCodeView(ViewLayout* viewLayout) const
|
||||
@@ -66,7 +73,6 @@ std::shared_ptr<StatusView> QtViewFactory::createStatusView(ViewLayout* viewLayo
|
||||
|
||||
std::shared_ptr<GraphView> QtViewFactory::createGraphView(ViewLayout* viewLayout) const
|
||||
{
|
||||
GraphViewStyle::setImpl(std::make_shared<QtGraphViewStyleImpl>());
|
||||
return View::createInitAndAddToLayout<QtGraphView>(viewLayout);
|
||||
}
|
||||
|
||||
@@ -90,6 +96,11 @@ std::shared_ptr<StatusBarView> QtViewFactory::createStatusBarView(ViewLayout* vi
|
||||
return View::createAndInit<QtStatusBarView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<TabsView> QtViewFactory::createTabsView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::createInitAndAddToLayout<QtTabsView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<TooltipView> QtViewFactory::createTooltipView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::createAndInit<QtTooltipView>(viewLayout);
|
||||
@@ -105,3 +116,8 @@ std::shared_ptr<DialogView> QtViewFactory::createDialogView(
|
||||
{
|
||||
return std::make_shared<QtDialogView>(dynamic_cast<QtMainView*>(viewLayout)->getMainWindow(), useCase, storageAccess);
|
||||
}
|
||||
|
||||
std::shared_ptr<GraphViewStyleImpl> QtViewFactory::createGraphStyleImpl() const
|
||||
{
|
||||
return std::make_shared<QtGraphViewStyleImpl>();
|
||||
}
|
||||
|
||||
@@ -10,11 +10,12 @@ public:
|
||||
QtViewFactory();
|
||||
virtual ~QtViewFactory() = default;
|
||||
|
||||
virtual std::shared_ptr<MainView> createMainView() const;
|
||||
virtual std::shared_ptr<MainView> createMainView(StorageAccess* storageAccess) const;
|
||||
virtual std::shared_ptr<CompositeView> createCompositeView(
|
||||
ViewLayout* viewLayout, CompositeView::CompositeDirection direction, const std::string& name) const;
|
||||
virtual std::shared_ptr<TabbedView> createTabbedView(ViewLayout* viewLayout, const std::string& name) const;
|
||||
|
||||
virtual std::shared_ptr<BookmarkButtonsView> createBookmarkButtonsView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<BookmarkView> createBookmarkView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<CodeView> createCodeView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<ErrorView> createErrorView(ViewLayout* viewLayout) const;
|
||||
@@ -24,11 +25,14 @@ public:
|
||||
virtual std::shared_ptr<SearchView> createSearchView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<StatusBarView> createStatusBarView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<StatusView> createStatusView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<TabsView> createTabsView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<TooltipView> createTooltipView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<UndoRedoView> createUndoRedoView(ViewLayout* viewLayout) const;
|
||||
|
||||
virtual std::shared_ptr<DialogView> createDialogView(
|
||||
ViewLayout* viewLayout, DialogView::UseCase useCase, StorageAccess* storageAccess) const;
|
||||
|
||||
virtual std::shared_ptr<GraphViewStyleImpl> createGraphStyleImpl() const;
|
||||
};
|
||||
|
||||
#endif // QT_VIEW_FACTORY_H
|
||||
|
||||
@@ -29,6 +29,8 @@ QtViewWidgetWrapper::QtViewWidgetWrapper(QWidget* widget)
|
||||
|
||||
QtViewWidgetWrapper::~QtViewWidgetWrapper()
|
||||
{
|
||||
m_widget->hide();
|
||||
m_widget->deleteLater();
|
||||
}
|
||||
|
||||
QWidget* QtViewWidgetWrapper::getWidget()
|
||||
|
||||
@@ -382,6 +382,10 @@ void QtGraphNode::onClick()
|
||||
{
|
||||
}
|
||||
|
||||
void QtGraphNode::onMiddleClick()
|
||||
{
|
||||
}
|
||||
|
||||
void QtGraphNode::onHide()
|
||||
{
|
||||
Id tokenId = getTokenId();
|
||||
@@ -431,11 +435,6 @@ void QtGraphNode::mousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
event->ignore();
|
||||
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::shared_ptr<QtGraphNodeComponent> component : m_components)
|
||||
{
|
||||
component->nodeMousePressEvent(event);
|
||||
@@ -474,11 +473,6 @@ void QtGraphNode::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
event->ignore();
|
||||
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (std::shared_ptr<QtGraphNodeComponent> component : m_components)
|
||||
{
|
||||
component->nodeMouseReleaseEvent(event);
|
||||
|
||||
@@ -95,6 +95,7 @@ public:
|
||||
virtual void addSubNode(QtGraphNode* node);
|
||||
|
||||
virtual void onClick();
|
||||
virtual void onMiddleClick();
|
||||
|
||||
void onHide();
|
||||
void onCollapseExpand();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "MessageDeactivateEdge.h"
|
||||
#include "MessageFocusIn.h"
|
||||
#include "MessageFocusOut.h"
|
||||
#include "MessageTabOpenWith.h"
|
||||
#include "MessageTooltipShow.h"
|
||||
#include "ResourcePaths.h"
|
||||
|
||||
@@ -61,6 +62,11 @@ void QtGraphNodeData::onClick()
|
||||
MessageActivateNodes(m_data->getId()).dispatch();
|
||||
}
|
||||
|
||||
void QtGraphNodeData::onMiddleClick()
|
||||
{
|
||||
MessageTabOpenWith(m_data->getId()).dispatch();
|
||||
}
|
||||
|
||||
void QtGraphNodeData::updateStyle()
|
||||
{
|
||||
GraphViewStyle::NodeStyle style = GraphViewStyle::getStyleForNodeType(
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
virtual Id getTokenId() const;
|
||||
|
||||
virtual void onClick();
|
||||
virtual void onMiddleClick();
|
||||
virtual void updateStyle();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -17,8 +17,15 @@ QtGraphNodeComponentClickable::~QtGraphNodeComponentClickable()
|
||||
|
||||
void QtGraphNodeComponentClickable::nodeMousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton && event->button() != Qt::MiddleButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_mousePos = Vec2i(event->scenePos().x(), event->scenePos().y());
|
||||
m_mouseMoved = false;
|
||||
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void QtGraphNodeComponentClickable::nodeMouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
||||
@@ -33,23 +40,35 @@ void QtGraphNodeComponentClickable::nodeMouseMoveEvent(QGraphicsSceneMouseEvent*
|
||||
|
||||
void QtGraphNodeComponentClickable::nodeMouseReleaseEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton && event->button() != Qt::MiddleButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_mouseMoved)
|
||||
{
|
||||
if (event->modifiers() & Qt::AltModifier)
|
||||
if (event->modifiers() & Qt::AltModifier && event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_graphNode->onHide();
|
||||
}
|
||||
else if (event->modifiers() & Qt::ShiftModifier)
|
||||
else if (event->modifiers() & Qt::ShiftModifier && event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_graphNode->onCollapseExpand();
|
||||
}
|
||||
else if (event->modifiers() & Qt::ControlModifier)
|
||||
else if (event->modifiers() & Qt::ControlModifier && event->button() == Qt::LeftButton)
|
||||
{
|
||||
m_graphNode->onShowDefinition();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_graphNode->onClick();
|
||||
if (event->button() == Qt::MiddleButton)
|
||||
{
|
||||
m_graphNode->onMiddleClick();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_graphNode->onClick();
|
||||
}
|
||||
}
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@ QtGraphNodeComponentMoveable::~QtGraphNodeComponentMoveable()
|
||||
|
||||
void QtGraphNodeComponentMoveable::nodeMousePressEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_oldPos = m_graphNode->getPosition();
|
||||
m_mouseOffset.x = event->scenePos().x() - m_oldPos.x;
|
||||
m_mouseOffset.y = event->scenePos().y() - m_oldPos.y;
|
||||
@@ -25,12 +30,22 @@ void QtGraphNodeComponentMoveable::nodeMousePressEvent(QGraphicsSceneMouseEvent*
|
||||
|
||||
void QtGraphNodeComponentMoveable::nodeMouseMoveEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_graphNode->setPosition(Vec2i(event->scenePos().x() - m_mouseOffset.x, event->scenePos().y() - m_mouseOffset.y));
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void QtGraphNodeComponentMoveable::nodeMouseReleaseEvent(QGraphicsSceneMouseEvent* event)
|
||||
{
|
||||
if (event->button() != Qt::LeftButton)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->isAccepted())
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <QMenuBar>
|
||||
#include <QSettings>
|
||||
#include <QTimer>
|
||||
#include <QToolBar>
|
||||
|
||||
#include "Application.h"
|
||||
#include "CompositeView.h"
|
||||
@@ -33,10 +34,10 @@
|
||||
#include "MessageHistoryUndo.h"
|
||||
#include "MessageActivateAll.h"
|
||||
#include "MessageActivateBase.h"
|
||||
#include "MessageActivateBookmark.h"
|
||||
#include "MessageBookmarkActivate.h"
|
||||
#include "MessageBookmarkBrowse.h"
|
||||
#include "MessageBookmarkCreate.h"
|
||||
#include "MessageCodeReference.h"
|
||||
#include "MessageDisplayBookmarkCreator.h"
|
||||
#include "MessageDisplayBookmarks.h"
|
||||
#include "MessageEnteredLicense.h"
|
||||
#include "MessageFind.h"
|
||||
#include "MessageIndexingShowDialog.h"
|
||||
@@ -45,6 +46,9 @@
|
||||
#include "MessageRefresh.h"
|
||||
#include "MessageRefreshUI.h"
|
||||
#include "MessageResetZoom.h"
|
||||
#include "MessageTabClose.h"
|
||||
#include "MessageTabOpen.h"
|
||||
#include "MessageTabSelect.h"
|
||||
#include "MessageWindowClosed.h"
|
||||
#include "MessageZoom.h"
|
||||
#include "ResourcePaths.h"
|
||||
@@ -150,12 +154,30 @@ QtMainWindow::~QtMainWindow()
|
||||
|
||||
void QtMainWindow::addView(View* view)
|
||||
{
|
||||
QDockWidget* dock = new QDockWidget(tr(view->getName().c_str()), this);
|
||||
dock->setWidget(QtViewWidgetWrapper::getWidgetOfView(view));
|
||||
dock->setObjectName(QString::fromStdString("Dock" + view->getName()));
|
||||
const QString name = QString::fromStdString(view->getName());
|
||||
if (name == "Tabs")
|
||||
{
|
||||
QToolBar* toolBar = new QToolBar();
|
||||
toolBar->setObjectName("Tool" + name);
|
||||
toolBar->setMovable(false);
|
||||
toolBar->setFloatable(false);
|
||||
toolBar->setStyleSheet("* { margin: 0; }");
|
||||
toolBar->addWidget(QtViewWidgetWrapper::getWidgetOfView(view));
|
||||
addToolBar(toolBar);
|
||||
return;
|
||||
}
|
||||
|
||||
QDockWidget* dock = new QDockWidget(name, this);
|
||||
dock->setObjectName("Dock" + name);
|
||||
|
||||
dock->setWidget(new QWidget());
|
||||
QVBoxLayout* layout = new QVBoxLayout(dock->widget());
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(QtViewWidgetWrapper::getWidgetOfView(view));
|
||||
|
||||
// Disable un-intended vertical growth of search widget
|
||||
if (view->getName() == "Search")
|
||||
if (name == "Search")
|
||||
{
|
||||
dock->setSizePolicy(dock->sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
|
||||
}
|
||||
@@ -171,7 +193,7 @@ void QtMainWindow::addView(View* view)
|
||||
QtViewToggle* toggle = new QtViewToggle(view, this);
|
||||
connect(dock, &QDockWidget::visibilityChanged, toggle, &QtViewToggle::toggledByUI);
|
||||
|
||||
QAction* action = new QAction(tr((view->getName() + " Window").c_str()), this);
|
||||
QAction* action = new QAction(name + " Window", this);
|
||||
action->setCheckable(true);
|
||||
connect(action, &QAction::triggered, toggle, &QtViewToggle::toggledByAction);
|
||||
m_viewMenu->insertAction(m_viewSeparator, action);
|
||||
@@ -185,6 +207,44 @@ void QtMainWindow::addView(View* view)
|
||||
m_dockWidgets.push_back(dockWidget);
|
||||
}
|
||||
|
||||
void QtMainWindow::overrideView(View* view)
|
||||
{
|
||||
const QString name = QString::fromStdString(view->getName());
|
||||
if (name == "Tabs")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QDockWidget* dock = nullptr;
|
||||
for (const DockWidget& dockWidget : m_dockWidgets)
|
||||
{
|
||||
if (dockWidget.widget->windowTitle() == name)
|
||||
{
|
||||
dock = dockWidget.widget;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dock)
|
||||
{
|
||||
LOG_ERROR_STREAM(<< "Couldn't find view to override: " << name.toStdString());
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget* oldWidget = dock->widget()->layout()->itemAt(0)->widget();
|
||||
QWidget* newWidget = QtViewWidgetWrapper::getWidgetOfView(view);
|
||||
|
||||
if (oldWidget == newWidget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
oldWidget = dock->widget()->layout()->takeAt(0)->widget();
|
||||
oldWidget->hide();
|
||||
dock->widget()->layout()->addWidget(newWidget);
|
||||
newWidget->show();
|
||||
}
|
||||
|
||||
void QtMainWindow::removeView(View* view)
|
||||
{
|
||||
for (size_t i = 0; i < m_dockWidgets.size(); i++)
|
||||
@@ -347,9 +407,41 @@ void QtMainWindow::forceEnterLicense(LicenseChecker::LicenseState state)
|
||||
connect(window, &QtWindow::canceled, dynamic_cast<QApplication*>(QCoreApplication::instance()), &QApplication::quit);
|
||||
}
|
||||
|
||||
void QtMainWindow::updateHistoryMenu(const std::vector<std::shared_ptr<MessageBase>>& historyMenuItems)
|
||||
void QtMainWindow::updateHistoryMenu(std::shared_ptr<MessageBase> message)
|
||||
{
|
||||
m_history = historyMenuItems;
|
||||
const size_t historyMenuSize = 20;
|
||||
|
||||
if (message && dynamic_cast<MessageActivateBase*>(message.get()))
|
||||
{
|
||||
std::vector<SearchMatch> matches = dynamic_cast<MessageActivateBase*>(message.get())->getSearchMatches();
|
||||
if (matches.size() && !matches[0].text.empty())
|
||||
{
|
||||
std::vector<std::shared_ptr<MessageBase>> history = { message };
|
||||
std::set<SearchMatch> uniqueMatches = { matches[0] };
|
||||
|
||||
for (std::shared_ptr<MessageBase> m : m_history)
|
||||
{
|
||||
if (uniqueMatches.insert(dynamic_cast<MessageActivateBase*>(m.get())->getSearchMatches()[0]).second)
|
||||
{
|
||||
history.push_back(m);
|
||||
|
||||
if (history.size() >= historyMenuSize)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_history = history;
|
||||
}
|
||||
}
|
||||
|
||||
setupHistoryMenu();
|
||||
}
|
||||
|
||||
void QtMainWindow::clearHistoryMenu()
|
||||
{
|
||||
m_history.clear();
|
||||
setupHistoryMenu();
|
||||
}
|
||||
|
||||
@@ -426,6 +518,7 @@ void QtMainWindow::keyPressEvent(QKeyEvent* event)
|
||||
void QtMainWindow::contextMenuEvent(QContextMenuEvent* event)
|
||||
{
|
||||
QtContextMenu menu(event, this);
|
||||
menu.addUndoActions();
|
||||
menu.show();
|
||||
}
|
||||
|
||||
@@ -549,6 +642,26 @@ void QtMainWindow::showLogFolder()
|
||||
QDesktopServices::openUrl(QUrl(QString::fromStdWString(L"file:///" + UserPaths::getLogPath().makeCanonical().wstr()), QUrl::TolerantMode));
|
||||
}
|
||||
|
||||
void QtMainWindow::openTab()
|
||||
{
|
||||
MessageTabOpen().dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::closeTab()
|
||||
{
|
||||
MessageTabClose().dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::nextTab()
|
||||
{
|
||||
MessageTabSelect(true).dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::previousTab()
|
||||
{
|
||||
MessageTabSelect(false).dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::showStartScreen()
|
||||
{
|
||||
if (dynamic_cast<QtStartScreen*>(m_windowStack.getTopWindow()))
|
||||
@@ -757,12 +870,12 @@ void QtMainWindow::toggleShowDockWidgetTitleBars()
|
||||
|
||||
void QtMainWindow::showBookmarkCreator()
|
||||
{
|
||||
MessageDisplayBookmarkCreator().dispatch();
|
||||
MessageBookmarkCreate().dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::showBookmarkBrowser()
|
||||
{
|
||||
MessageDisplayBookmarks().dispatch();
|
||||
MessageBookmarkBrowse().dispatch();
|
||||
}
|
||||
|
||||
void QtMainWindow::openHistoryAction()
|
||||
@@ -771,6 +884,7 @@ void QtMainWindow::openHistoryAction()
|
||||
if (action)
|
||||
{
|
||||
std::shared_ptr<MessageBase> m = m_history[action->data().toInt()];
|
||||
m->setSchedulerId(TabId::currentTab());
|
||||
m->setIsReplayed(false);
|
||||
m->dispatch();
|
||||
}
|
||||
@@ -782,7 +896,7 @@ void QtMainWindow::activateBookmarkAction()
|
||||
if (action)
|
||||
{
|
||||
std::shared_ptr<Bookmark> bookmark = m_bookmarks[action->data().toInt()];
|
||||
MessageActivateBookmark(bookmark).dispatch();
|
||||
MessageBookmarkActivate(bookmark).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -845,9 +959,9 @@ void QtMainWindow::setupEditMenu()
|
||||
&QtMainWindow::codeReferencePrevious, QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_G));
|
||||
|
||||
menu->addAction(tr("Next Local Reference"), this,
|
||||
&QtMainWindow::codeLocalReferenceNext, QKeySequence(Qt::CTRL + Qt::Key_T));
|
||||
&QtMainWindow::codeLocalReferenceNext, QKeySequence(Qt::CTRL + Qt::Key_E));
|
||||
menu->addAction(tr("Previous Local Reference"), this,
|
||||
&QtMainWindow::codeLocalReferencePrevious, QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_T));
|
||||
&QtMainWindow::codeLocalReferencePrevious, QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_E));
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
@@ -863,6 +977,22 @@ void QtMainWindow::setupViewMenu()
|
||||
QMenu *menu = new QMenu(tr("&View"), this);
|
||||
menuBar()->addMenu(menu);
|
||||
|
||||
menu->addAction(tr("New Tab"), this, &QtMainWindow::openTab, QKeySequence::AddTab);
|
||||
menu->addAction(tr("Close Tab"), this, &QtMainWindow::closeTab, QKeySequence::Close);
|
||||
|
||||
if (utility::getOsType() == OS_MAC)
|
||||
{
|
||||
menu->addAction(tr("Select Next Tab"), this, &QtMainWindow::nextTab, QKeySequence(Qt::META + Qt::Key_Tab));
|
||||
menu->addAction(tr("Select Previous Tab"), this, &QtMainWindow::previousTab, QKeySequence(Qt::SHIFT + Qt::META + Qt::Key_Tab));
|
||||
}
|
||||
else
|
||||
{
|
||||
menu->addAction(tr("Select Next Tab"), this, &QtMainWindow::nextTab, QKeySequence(Qt::CTRL + Qt::Key_Tab));
|
||||
menu->addAction(tr("Select Previous Tab"), this, &QtMainWindow::previousTab, QKeySequence(Qt::SHIFT + Qt::CTRL + Qt::Key_Tab));
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
menu->addAction(tr("Show Start Window"), this, &QtMainWindow::showStartScreen);
|
||||
|
||||
m_showTitleBarsAction = new QAction("Show Title Bars", this);
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
~QtMainWindow();
|
||||
|
||||
void addView(View* view);
|
||||
void overrideView(View* view);
|
||||
void removeView(View* view);
|
||||
|
||||
void showView(View* view);
|
||||
@@ -75,7 +76,9 @@ public:
|
||||
|
||||
void forceEnterLicense(LicenseChecker::LicenseState state);
|
||||
|
||||
void updateHistoryMenu(const std::vector<std::shared_ptr<MessageBase>>& historyMenuItems);
|
||||
void updateHistoryMenu(std::shared_ptr<MessageBase> message);
|
||||
void clearHistoryMenu();
|
||||
|
||||
void updateBookmarksMenu(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
|
||||
void setContentEnabled(bool enabled);
|
||||
@@ -111,6 +114,11 @@ public slots:
|
||||
void showDataFolder();
|
||||
void showLogFolder();
|
||||
|
||||
void openTab();
|
||||
void closeTab();
|
||||
void nextTab();
|
||||
void previousTab();
|
||||
|
||||
void showStartScreen();
|
||||
void hideStartScreen();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user