@@ -166,6 +166,11 @@ void Application::updateHistory(const std::vector<SearchMatch>& history)
|
||||
m_mainView->updateHistoryMenu(history);
|
||||
}
|
||||
|
||||
void Application::updateBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks)
|
||||
{
|
||||
m_mainView->updateBookmarksMenu(bookmarks);
|
||||
}
|
||||
|
||||
void Application::createAndLoadProject(const FilePath& projectSettingsFilePath)
|
||||
{
|
||||
MessageStatus("Loading Project: " + projectSettingsFilePath.str(), false, true).dispatch();
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageSwitchColorScheme.h"
|
||||
|
||||
class Bookmark;
|
||||
class DialogView;
|
||||
class IDECommunicationController;
|
||||
class MainView;
|
||||
@@ -54,6 +55,7 @@ public:
|
||||
bool isInTrial() const;
|
||||
|
||||
void updateHistory(const std::vector<SearchMatch>& history);
|
||||
void updateBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Application> s_instance;
|
||||
|
||||
@@ -361,6 +361,8 @@ void BookmarkController::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
m_bookmarkCache.clear();
|
||||
getView<BookmarkView>()->enableDisplayBookmarks(true);
|
||||
|
||||
getView<BookmarkView>()->update();
|
||||
}
|
||||
|
||||
void BookmarkController::handleMessage(MessageShowErrors* message)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "component/view/BookmarkView.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "component/controller/BookmarkController.h"
|
||||
|
||||
BookmarkView::BookmarkView(ViewLayout* viewLayout)
|
||||
@@ -24,6 +25,19 @@ void BookmarkView::update()
|
||||
{
|
||||
displayBookmarks(getController()->getBookmarks(m_filter, m_order));
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Bookmark>> bookmarks = getController()->getBookmarks(
|
||||
MessageDisplayBookmarks::BookmarkFilter::ALL,
|
||||
MessageDisplayBookmarks::BookmarkOrder::DATE_DESCENDING
|
||||
);
|
||||
|
||||
const size_t maxBookmarkMenuCount = 20;
|
||||
if (bookmarks.size() > maxBookmarkMenuCount)
|
||||
{
|
||||
bookmarks.resize(maxBookmarkMenuCount);
|
||||
}
|
||||
|
||||
Application::getInstance()->updateBookmarks(bookmarks);
|
||||
}
|
||||
|
||||
BookmarkController* BookmarkView::getController()
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "component/view/ViewLayout.h"
|
||||
|
||||
struct SearchMatch;
|
||||
class Bookmark;
|
||||
|
||||
class MainView
|
||||
: public ViewLayout
|
||||
@@ -24,6 +25,7 @@ public:
|
||||
|
||||
virtual void updateRecentProjectMenu() = 0;
|
||||
virtual void updateHistoryMenu(const std::vector<SearchMatch>& history) = 0;
|
||||
virtual void updateBookmarksMenu(const std::vector<std::shared_ptr<Bookmark>>& bookmarks) = 0;
|
||||
};
|
||||
|
||||
#endif // MAIN_VIEW_H
|
||||
|
||||
@@ -128,6 +128,16 @@ void QtMainView::updateHistoryMenu(const std::vector<SearchMatch>& history)
|
||||
);
|
||||
}
|
||||
|
||||
void QtMainView::updateBookmarksMenu(const std::vector<std::shared_ptr<Bookmark>>& bookmarks)
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
m_window->updateBookmarksMenu(bookmarks);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtMainView::handleMessage(MessageForceEnterLicense* message)
|
||||
{
|
||||
bool expired = message->licenseExpired;
|
||||
|
||||
@@ -48,8 +48,10 @@ public:
|
||||
virtual void hideStartScreen();
|
||||
virtual void setTitle(const std::string& title);
|
||||
virtual void activateWindow();
|
||||
|
||||
virtual void updateRecentProjectMenu();
|
||||
virtual void updateHistoryMenu(const std::vector<SearchMatch>& history);
|
||||
virtual void updateBookmarksMenu(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
|
||||
private:
|
||||
void handleMessage(MessageForceEnterLicense* message);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "component/view/CompositeView.h"
|
||||
#include "component/view/TabbedView.h"
|
||||
#include "component/view/View.h"
|
||||
#include "data/bookmark/Bookmark.h"
|
||||
#include "LicenseChecker.h"
|
||||
#include "qt/utility/QtContextMenu.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
@@ -30,6 +31,7 @@
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageActivateBookmark.h"
|
||||
#include "utility/messaging/type/MessageCodeReference.h"
|
||||
#include "utility/messaging/type/MessageDisplayBookmarkCreator.h"
|
||||
#include "utility/messaging/type/MessageDisplayBookmarks.h"
|
||||
@@ -98,6 +100,7 @@ bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event)
|
||||
|
||||
QtMainWindow::QtMainWindow()
|
||||
: m_historyMenu(nullptr)
|
||||
, m_bookmarksMenu(nullptr)
|
||||
, m_showDockWidgetTitleBars(true)
|
||||
, m_windowStack(this)
|
||||
{
|
||||
@@ -269,6 +272,12 @@ void QtMainWindow::updateHistoryMenu(const std::vector<SearchMatch>& history)
|
||||
setupHistoryMenu();
|
||||
}
|
||||
|
||||
void QtMainWindow::updateBookmarksMenu(const std::vector<std::shared_ptr<Bookmark>>& bookmarks)
|
||||
{
|
||||
m_bookmarks = bookmarks;
|
||||
setupBookmarksMenu();
|
||||
}
|
||||
|
||||
void QtMainWindow::setContentEnabled(bool enabled)
|
||||
{
|
||||
foreach (QAction *action, menuBar()->actions())
|
||||
@@ -673,6 +682,16 @@ void QtMainWindow::openHistoryAction()
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::activateBookmarkAction()
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>(sender());
|
||||
if (action)
|
||||
{
|
||||
std::shared_ptr<Bookmark> bookmark = m_bookmarks[action->data().toInt()];
|
||||
MessageActivateBookmark(bookmark).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::setupProjectMenu()
|
||||
{
|
||||
QMenu *menu = new QMenu(tr("&Project"), this);
|
||||
@@ -805,11 +824,37 @@ void QtMainWindow::setupHistoryMenu()
|
||||
|
||||
void QtMainWindow::setupBookmarksMenu()
|
||||
{
|
||||
QMenu *menu = new QMenu(tr("&Bookmarks"), this);
|
||||
menuBar()->addMenu(menu);
|
||||
if (!m_bookmarksMenu)
|
||||
{
|
||||
m_bookmarksMenu = new QMenu(tr("&Bookmarks"), this);
|
||||
menuBar()->addMenu(m_bookmarksMenu);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bookmarksMenu->clear();
|
||||
}
|
||||
|
||||
menu->addAction(tr("Bookmark Active Symbol..."), this, SLOT(showBookmarkCreator()), QKeySequence(Qt::CTRL + Qt::Key_D));
|
||||
menu->addAction(tr("Bookmark Manager"), this, SLOT(showBookmarkBrowser()), QKeySequence(Qt::CTRL + Qt::Key_B));
|
||||
m_bookmarksMenu->addAction(tr("Bookmark Active Symbol..."), this, SLOT(showBookmarkCreator()), QKeySequence(Qt::CTRL + Qt::Key_D));
|
||||
m_bookmarksMenu->addAction(tr("Bookmark Manager"), this, SLOT(showBookmarkBrowser()), QKeySequence(Qt::CTRL + Qt::Key_B));
|
||||
|
||||
m_bookmarksMenu->addSeparator();
|
||||
|
||||
QAction* title = new QAction(tr("Recent Bookmarks"));
|
||||
title->setEnabled(false);
|
||||
m_bookmarksMenu->addAction(title);
|
||||
|
||||
for (size_t i = 0; i < m_bookmarks.size(); i++)
|
||||
{
|
||||
Bookmark* bookmark = m_bookmarks[i].get();
|
||||
std::string name = utility::elide(bookmark->getName(), utility::ELIDE_RIGHT, 50);
|
||||
|
||||
QAction* action = new QAction();
|
||||
action->setText(name.c_str());
|
||||
action->setData(QVariant(int(i)));
|
||||
|
||||
connect(action, SIGNAL(triggered()), this, SLOT(activateBookmarkAction()));
|
||||
m_bookmarksMenu->addAction(action);
|
||||
}
|
||||
}
|
||||
|
||||
void QtMainWindow::setupHelpMenu()
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "data/search/SearchMatch.h"
|
||||
#include "qt/window/QtWindowStack.h"
|
||||
|
||||
class Bookmark;
|
||||
class QDockWidget;
|
||||
class View;
|
||||
|
||||
@@ -70,6 +71,7 @@ public:
|
||||
void forceEnterLicense(bool expired);
|
||||
|
||||
void updateHistoryMenu(const std::vector<SearchMatch>& history);
|
||||
void updateBookmarksMenu(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
|
||||
void setContentEnabled(bool enabled);
|
||||
|
||||
@@ -133,6 +135,7 @@ private slots:
|
||||
void showBookmarkBrowser();
|
||||
|
||||
void openHistoryAction();
|
||||
void activateBookmarkAction();
|
||||
|
||||
private:
|
||||
struct DockWidget
|
||||
@@ -166,6 +169,9 @@ private:
|
||||
QMenu* m_historyMenu;
|
||||
std::vector<SearchMatch> m_history;
|
||||
|
||||
QMenu* m_bookmarksMenu;
|
||||
std::vector<std::shared_ptr<Bookmark>> m_bookmarks;
|
||||
|
||||
QAction** m_recentProjectAction;
|
||||
QAction* m_showTitleBarsAction;
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
QtProjectWizzardContentPathsClassJava(std::shared_ptr<SourceGroupSettings> settings, QtProjectWizzardWindow* window);
|
||||
|
||||
// QtProjectWizzardContent implementation
|
||||
virtual void populate(QGridLayout* layout, int& row);
|
||||
virtual void populate(QGridLayout* layout, int& row) override;
|
||||
virtual void load() override;
|
||||
virtual void save() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user