ui: bookmarks
can now bookmark tokens
This commit is contained in:
@@ -8,6 +8,12 @@ add_files(
|
||||
|
||||
qt/element/QtAutocompletionList.cpp
|
||||
qt/element/QtAutocompletionList.h
|
||||
qt/element/QtBookmark.cpp
|
||||
qt/element/QtBookmark.h
|
||||
qt/element/QtBookmarkBar.cpp
|
||||
qt/element/QtBookmarkBar.h
|
||||
qt/element/QtBookmarkCategory.cpp
|
||||
qt/element/QtBookmarkCategory.h
|
||||
qt/element/QtCodeArea.cpp
|
||||
qt/element/QtCodeArea.h
|
||||
qt/element/QtCodeFile.cpp
|
||||
@@ -101,6 +107,8 @@ add_files(
|
||||
qt/view/graphElements/QtGraphNodeText.cpp
|
||||
qt/view/graphElements/QtGraphNodeText.h
|
||||
|
||||
qt/view/QtBookmarkView.cpp
|
||||
qt/view/QtBookmarkView.h
|
||||
qt/view/QtCodeView.cpp
|
||||
qt/view/QtCodeView.h
|
||||
qt/view/QtCompositeView.cpp
|
||||
@@ -165,6 +173,10 @@ add_files(
|
||||
qt/window/QtAbout.h
|
||||
qt/window/QtAboutLicense.cpp
|
||||
qt/window/QtAboutLicense.h
|
||||
qt/window/QtBookmarkBrowser.cpp
|
||||
qt/window/QtBookmarkBrowser.h
|
||||
qt/window/QtBookmarkCreator.cpp
|
||||
qt/window/QtBookmarkCreator.h
|
||||
qt/window/QtIndexingDialog.cpp
|
||||
qt/window/QtIndexingDialog.h
|
||||
qt/window/QtKeyboardShortcuts.cpp
|
||||
|
||||
@@ -0,0 +1,263 @@
|
||||
#include "QtBookmark.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "qt/window/QtBookmarkCreator.h"
|
||||
|
||||
#include "data/bookmark/EdgeBookmark.h"
|
||||
|
||||
#include "utility/messaging/type/MessageActivateBookmark.h"
|
||||
#include "utility/messaging/type/MessageDisplayBookmarkEditor.h"
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
QtBookmark::QtBookmark()
|
||||
: m_treeWidgetItem(NULL)
|
||||
{
|
||||
setObjectName("bookmark");
|
||||
|
||||
m_layout = new QVBoxLayout();
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(m_layout);
|
||||
|
||||
QHBoxLayout* buttonsLayout = new QHBoxLayout();
|
||||
buttonsLayout->setSpacing(0);
|
||||
buttonsLayout->setContentsMargins(0, 0, 0, 0);
|
||||
buttonsLayout->setAlignment(Qt::AlignTop);
|
||||
|
||||
m_toggleCommentButton = new QPushButton();
|
||||
m_toggleCommentButton->setObjectName("comment_button");
|
||||
m_toggleCommentButton->setToolTip("Show Comment");
|
||||
m_toggleCommentButton->setText("");
|
||||
m_toggleCommentButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
buttonsLayout->addWidget(m_toggleCommentButton);
|
||||
|
||||
m_dateLabel = new QLabel();
|
||||
m_dateLabel->setObjectName("date_label");
|
||||
m_dateLabel->setText("n/a");
|
||||
buttonsLayout->addWidget(m_dateLabel);
|
||||
|
||||
m_activateButton = new QPushButton();
|
||||
m_activateButton->setObjectName("activate_button");
|
||||
m_activateButton->setToolTip("Activate bookmark");
|
||||
m_activateButton->setText("Bookmark");
|
||||
m_activateButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
buttonsLayout->addWidget(m_activateButton);
|
||||
|
||||
m_editButton = new QPushButton();
|
||||
m_editButton->setObjectName("edit_button");
|
||||
m_editButton->setToolTip("Edit bookmark");
|
||||
m_editButton->setText("Edit");
|
||||
m_editButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
buttonsLayout->addWidget(m_editButton);
|
||||
|
||||
m_deleteButton = new QPushButton();
|
||||
m_deleteButton->setObjectName("delete_button");
|
||||
m_deleteButton->setToolTip("Delete bookmark");
|
||||
m_deleteButton->setText("Delete");
|
||||
m_deleteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
buttonsLayout->addWidget(m_deleteButton);
|
||||
|
||||
m_layout->addLayout(buttonsLayout);
|
||||
|
||||
m_comment = new QLabel();
|
||||
m_comment->setText("no comment");
|
||||
m_comment->hide();
|
||||
m_comment->setWordWrap(true);
|
||||
m_layout->addWidget(m_comment);
|
||||
|
||||
|
||||
connect(m_activateButton, SIGNAL(clicked()), this, SLOT(activateClicked()));
|
||||
connect(m_editButton, SIGNAL(clicked()), this, SLOT(editClicked()));
|
||||
connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteClicked()));
|
||||
connect(m_toggleCommentButton, SIGNAL(clicked()), this, SLOT(commentToggled()));
|
||||
|
||||
refreshStyle();
|
||||
}
|
||||
|
||||
QtBookmark::~QtBookmark()
|
||||
{
|
||||
}
|
||||
|
||||
void QtBookmark::setName(const std::string& name)
|
||||
{
|
||||
m_activateButton->setText(name.c_str());
|
||||
}
|
||||
|
||||
std::string QtBookmark::getName() const
|
||||
{
|
||||
return m_bookmark->getDisplayName();
|
||||
}
|
||||
|
||||
void QtBookmark::setBookmark(const std::shared_ptr<Bookmark> bookmark)
|
||||
{
|
||||
m_bookmark = bookmark;
|
||||
|
||||
m_activateButton->setText(bookmark->getDisplayName().c_str());
|
||||
|
||||
bool isValid = m_bookmark->isValid();
|
||||
|
||||
if (m_bookmark->isValid() == false)
|
||||
{
|
||||
m_activateButton->setEnabled(false);
|
||||
m_editButton->setEnabled(false);
|
||||
}
|
||||
|
||||
if (m_bookmark->getComment().length() > 0)
|
||||
{
|
||||
m_comment->setText(m_bookmark->getComment().c_str());
|
||||
m_activateButton->setToolTip(bookmark->getComment().c_str());
|
||||
}
|
||||
m_dateLabel->setText(getDateString().c_str());
|
||||
|
||||
getDateString();
|
||||
}
|
||||
|
||||
Id QtBookmark::getBookmarkId() const
|
||||
{
|
||||
return m_bookmark->getId();
|
||||
}
|
||||
|
||||
QTreeWidgetItem* QtBookmark::getTreeWidgetItem() const
|
||||
{
|
||||
return m_treeWidgetItem;
|
||||
}
|
||||
|
||||
void QtBookmark::setTreeWidgetItem(QTreeWidgetItem* treeWidgetItem)
|
||||
{
|
||||
m_treeWidgetItem = treeWidgetItem;
|
||||
}
|
||||
|
||||
void QtBookmark::refreshStyle()
|
||||
{
|
||||
if (m_editButton != NULL)
|
||||
{
|
||||
m_editButton->setText("");
|
||||
m_editButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_edit_icon.png").c_str()));
|
||||
}
|
||||
|
||||
if (m_deleteButton != NULL)
|
||||
{
|
||||
m_deleteButton->setText("");
|
||||
m_deleteButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_delete_icon.png").c_str()));
|
||||
}
|
||||
|
||||
if (m_toggleCommentButton != NULL)
|
||||
{
|
||||
m_toggleCommentButton->setText("");
|
||||
m_toggleCommentButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_right.png",
|
||||
"bookmark/button"
|
||||
));
|
||||
m_toggleCommentButton->setIconSize(QSize(10, 10));
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmark::activateClicked()
|
||||
{
|
||||
MessageActivateBookmark(m_bookmark).dispatch();
|
||||
}
|
||||
|
||||
void QtBookmark::editClicked()
|
||||
{
|
||||
MessageDisplayBookmarkEditor(m_bookmark).dispatch();
|
||||
}
|
||||
|
||||
void QtBookmark::deleteClicked()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Delete Bookmark");
|
||||
msgBox.setInformativeText("Do you really want to delete this bookmark?");
|
||||
QAbstractButton* yesButton = msgBox.addButton("Delete", QMessageBox::ButtonRole::YesRole);
|
||||
QAbstractButton* noButton = msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole);
|
||||
msgBox.setIcon(QMessageBox::Icon::Question);
|
||||
int ret = msgBox.exec();
|
||||
|
||||
if (ret == 0) // QMessageBox::Yes)
|
||||
{
|
||||
MessageDeleteBookmark(m_bookmark->getId(), (dynamic_cast<EdgeBookmark*>(m_bookmark.get()) != NULL)).dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmark::commentToggled()
|
||||
{
|
||||
// std::string text = m_toggleCommentButton->text().toStdString();
|
||||
|
||||
if (m_comment->isVisible() == false)
|
||||
{
|
||||
m_toggleCommentButton->setText("");
|
||||
m_toggleCommentButton->setText("");
|
||||
m_toggleCommentButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_down.png",
|
||||
"bookmark/button"
|
||||
));
|
||||
m_toggleCommentButton->setIconSize(QSize(10, 10));
|
||||
m_comment->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_toggleCommentButton->setText("");
|
||||
m_toggleCommentButton->setText("");
|
||||
m_toggleCommentButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_right.png",
|
||||
"bookmark/button"
|
||||
));
|
||||
m_toggleCommentButton->setIconSize(QSize(10, 10));
|
||||
m_comment->hide();
|
||||
}
|
||||
|
||||
// forces the parent tree view to rescale
|
||||
if (m_treeWidgetItem)
|
||||
{
|
||||
m_treeWidgetItem->setExpanded(false);
|
||||
m_treeWidgetItem->setExpanded(true);
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmark::handleMessage(MessageEditBookmark* message)
|
||||
{
|
||||
if (m_bookmark->getId() == message->bookmarkId)
|
||||
{
|
||||
m_bookmark->setDisplayName(message->displayName);
|
||||
m_bookmark->setComment(message->comment);
|
||||
|
||||
m_activateButton->setText(message->displayName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
std::string QtBookmark::getDateString() const
|
||||
{
|
||||
std::string result = "n/a";
|
||||
|
||||
TimePoint creationDate = m_bookmark->getTimeStamp();
|
||||
|
||||
float delta = TimePoint::now() - creationDate;
|
||||
|
||||
if (delta < 3600.0f) // less than an hour ago
|
||||
{
|
||||
result = std::to_string(int(delta / 60.0f)) + " minutes ago";
|
||||
}
|
||||
else if (delta < (3600.0f * 6.0f)) // less than 6 hours ago
|
||||
{
|
||||
result = std::to_string(int(delta / 3600.0f)) + " hours ago";
|
||||
}
|
||||
else if (creationDate.isSameDay(TimePoint::now())) // today
|
||||
{
|
||||
result = "today";
|
||||
}
|
||||
else if(creationDate.deltaDays(TimePoint::now()) == 1) // yesterday
|
||||
{
|
||||
result = "yesterday";
|
||||
}
|
||||
else // whenever
|
||||
{
|
||||
result = creationDate.getDDMMYYYYString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
#ifndef QT_BOOKMARK_H
|
||||
#define QT_BOOKMARK_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageDeleteBookmark.h"
|
||||
#include "utility/messaging/type/MessageEditBookmark.h"
|
||||
|
||||
#include "data/bookmark/Bookmark.h"
|
||||
|
||||
#include <QTreeWidget>
|
||||
|
||||
class QtBookmark
|
||||
: public QFrame
|
||||
, public MessageListener<MessageEditBookmark>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtBookmark();
|
||||
virtual ~QtBookmark();
|
||||
|
||||
void setName(const std::string& name);
|
||||
std::string getName() const;
|
||||
|
||||
void setBookmark(const std::shared_ptr<Bookmark> bookmark);
|
||||
|
||||
Id getBookmarkId() const;
|
||||
|
||||
QTreeWidgetItem* getTreeWidgetItem() const;
|
||||
void setTreeWidgetItem(QTreeWidgetItem* treeWidgetItem);
|
||||
|
||||
void refreshStyle();
|
||||
|
||||
private slots:
|
||||
void activateClicked();
|
||||
void editClicked();
|
||||
void deleteClicked();
|
||||
void commentToggled();
|
||||
|
||||
private:
|
||||
void handleMessage(MessageEditBookmark* message);
|
||||
|
||||
std::string getDateString() const;
|
||||
|
||||
QVBoxLayout* m_layout;
|
||||
|
||||
QPushButton* m_activateButton;
|
||||
QPushButton* m_editButton;
|
||||
QPushButton* m_deleteButton;
|
||||
QPushButton* m_toggleCommentButton;
|
||||
|
||||
QLabel* m_comment;
|
||||
QLabel* m_dateLabel;
|
||||
|
||||
std::shared_ptr<Bookmark> m_bookmark;
|
||||
|
||||
QTreeWidgetItem* m_treeWidgetItem; // pointer to the bookmark category item in the treeView, allows to refresh tree view when a node changes in size (e.g. toggle comment)
|
||||
// not a nice solution to the problem, but couldn't find anything better yet (sizeHintChanged signal can't be emitted here...)
|
||||
};
|
||||
|
||||
#endif // QT_BOOKMARK_H
|
||||
@@ -0,0 +1,261 @@
|
||||
#include "QtBookmarkBar.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "data/bookmark/EdgeBookmark.h"
|
||||
|
||||
#include "utility/messaging/type/MessageDeleteBookmarkForActiveTokens.h"
|
||||
#include "utility/messaging/type/MessageDisplayBookmarks.h"
|
||||
#include "utility/messaging/type/MessageDisplayBookmarkCreator.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
#include "qt/window/QtBookmarkCreator.h"
|
||||
|
||||
#include "qt/window/QtMainWindow.h"
|
||||
|
||||
#include "qt/element/QtBookmark.h"
|
||||
|
||||
QtBookmarkBar::QtBookmarkBar()
|
||||
: m_displayBookmarksFunctor(std::bind(&QtBookmarkBar::doDisplayBookmarks, this, std::placeholders::_1))
|
||||
, m_displayBookmarkCreatorFunctor(std::bind(&QtBookmarkBar::doDisplayBookmarkCreator, this, std::placeholders::_1, std::placeholders::_2))
|
||||
, m_displayBookmarkEditorFunctor(std::bind(&QtBookmarkBar::doDisplayBookmarkEditor, this, std::placeholders::_1, std::placeholders::_2))
|
||||
, m_setCreateButtonStateFunctor(std::bind(&QtBookmarkBar::doSetCreateButtonState, this, std::placeholders::_1))
|
||||
, m_enableDisplayButtonFunctor(std::bind(&QtBookmarkBar::doEnableDisplayButton, this, std::placeholders::_1))
|
||||
, m_bookmarkBrowser(NULL)
|
||||
, m_createButtonState(BookmarkView::CreateButtonState::CANNOT_CREATE)
|
||||
{
|
||||
setObjectName("bookmark_bar");
|
||||
|
||||
QBoxLayout* layout = new QHBoxLayout();
|
||||
layout->setSpacing(0);
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(layout);
|
||||
|
||||
m_createBookmarkButton = new QPushButton(this);
|
||||
m_createBookmarkButton->setObjectName("bookmark_button");
|
||||
m_createBookmarkButton->setToolTip("create a bookmark for the active symbol");
|
||||
m_createBookmarkButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
layout->addWidget(m_createBookmarkButton);
|
||||
|
||||
m_createBookmarkButton->setEnabled(false);
|
||||
|
||||
connect(m_createBookmarkButton, SIGNAL(clicked()), this, SLOT(createBookmarkClicked()));
|
||||
|
||||
m_showBookmarksButton = new QPushButton(this);
|
||||
m_showBookmarksButton->setObjectName("show_bookmark_button");
|
||||
m_showBookmarksButton->setToolTip("Show bookmarks");
|
||||
m_showBookmarksButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
layout->addWidget(m_showBookmarksButton);
|
||||
|
||||
m_showBookmarksButton->setEnabled(false);
|
||||
|
||||
connect(m_showBookmarksButton, SIGNAL(clicked()), this, SLOT(showBookmarksClicked()));
|
||||
|
||||
refreshStyle();
|
||||
}
|
||||
|
||||
QtBookmarkBar::~QtBookmarkBar()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QtBookmarkBar::refreshStyle()
|
||||
{
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css").c_str());
|
||||
|
||||
float height = std::max(ApplicationSettings::getInstance()->getFontSize() + 16, 30);
|
||||
|
||||
m_createBookmarkButton->setFixedHeight(height);
|
||||
m_showBookmarksButton->setFixedHeight(height);
|
||||
|
||||
std::string createImage = ResourcePaths::getGuiPath() + "bookmark_view/images/edit_bookmark_icon.png";
|
||||
std::string listImage = ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_list_icon.png";
|
||||
|
||||
m_createBookmarkButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap(createImage.c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
));
|
||||
|
||||
m_showBookmarksButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap(listImage.c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
));
|
||||
}
|
||||
|
||||
void QtBookmarkBar::displayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks)
|
||||
{
|
||||
m_displayBookmarksFunctor(bookmarks);
|
||||
}
|
||||
|
||||
void QtBookmarkBar::displayBookmarkCreator(const std::vector<std::string>& names, const std::vector<BookmarkCategory>& categories)
|
||||
{
|
||||
m_displayBookmarkCreatorFunctor(names, categories);
|
||||
}
|
||||
|
||||
void QtBookmarkBar::displayBookmarkEditor(std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories)
|
||||
{
|
||||
m_displayBookmarkEditorFunctor(bookmark, categories);
|
||||
}
|
||||
|
||||
void QtBookmarkBar::setCreateButtonState(const BookmarkView::CreateButtonState& state)
|
||||
{
|
||||
m_setCreateButtonStateFunctor(state);
|
||||
}
|
||||
|
||||
void QtBookmarkBar::enableDisplayButton(bool enable)
|
||||
{
|
||||
m_enableDisplayButtonFunctor(enable);
|
||||
}
|
||||
|
||||
bool QtBookmarkBar::bookmarkBrowserIsVisible() const
|
||||
{
|
||||
if (m_bookmarkBrowser != NULL)
|
||||
{
|
||||
return m_bookmarkBrowser->isVisible();
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkBar::createBookmarkClicked()
|
||||
{
|
||||
if (m_createButtonState == BookmarkView::CreateButtonState::CAN_CREATE)
|
||||
{
|
||||
MessageDisplayBookmarkCreator().dispatch();
|
||||
}
|
||||
else if (m_createButtonState == BookmarkView::CreateButtonState::ALREADY_CREATED)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Edit Bookmark");
|
||||
msgBox.setInformativeText("Do you want to update or delete the Bookmark for the active Token?");
|
||||
QAbstractButton* editButton = msgBox.addButton("Edit", QMessageBox::ButtonRole::YesRole);
|
||||
QAbstractButton* deleteButton = msgBox.addButton("Delete", QMessageBox::ButtonRole::DestructiveRole);
|
||||
QAbstractButton* cancelButton = msgBox.addButton("Cancel", QMessageBox::ButtonRole::NoRole);
|
||||
msgBox.setIcon(QMessageBox::Icon::Question);
|
||||
int ret = msgBox.exec();
|
||||
|
||||
if (ret == 0) // QMessageBox::Yes)
|
||||
{
|
||||
MessageDisplayBookmarkCreator().dispatch();
|
||||
}
|
||||
else if (ret == 1)
|
||||
{
|
||||
MessageDeleteBookmarkForActiveTokens().dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkBar::showBookmarksClicked()
|
||||
{
|
||||
MessageDisplayBookmarks(MessageDisplayBookmarks::BookmarkFilter::ALL, MessageDisplayBookmarks::BookmarkOrder::NONE).dispatch();
|
||||
}
|
||||
|
||||
void QtBookmarkBar::handleMessage(MessageEnteredLicense* message)
|
||||
{
|
||||
m_onQtThread(
|
||||
[=]()
|
||||
{
|
||||
// actually only want to enable this when a project is loaded
|
||||
// maybe factor in licence later...
|
||||
// m_createBookmarkButton->setEnabled(true);
|
||||
// m_showBookmarksButton->setEnabled(true);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void QtBookmarkBar::doDisplayBookmarkCreator(const std::vector<std::string>& names, const std::vector<BookmarkCategory>& categories)
|
||||
{
|
||||
QtBookmarkCreator* bookmarkCreator = new QtBookmarkCreator();
|
||||
bookmarkCreator->setupBookmarkCreator();
|
||||
|
||||
std::string displayName = "";
|
||||
|
||||
for (unsigned int i = 0; i < names.size(); i++)
|
||||
{
|
||||
displayName += names[i];
|
||||
|
||||
if (i < names.size() - 1)
|
||||
{
|
||||
displayName += "; ";
|
||||
}
|
||||
}
|
||||
|
||||
bookmarkCreator->setDisplayName(displayName);
|
||||
bookmarkCreator->setBookmarkCategories(categories);
|
||||
bookmarkCreator->show();
|
||||
}
|
||||
|
||||
void QtBookmarkBar::doDisplayBookmarkEditor(std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories)
|
||||
{
|
||||
QtBookmarkCreator* bookmarkCreator = new QtBookmarkCreator(NULL, true, bookmark->getId());
|
||||
bookmarkCreator->setupBookmarkCreator();
|
||||
bookmarkCreator->setDisplayName(bookmark->getDisplayName());
|
||||
bookmarkCreator->setComment(bookmark->getComment());
|
||||
bookmarkCreator->setBookmarkCategories(categories);
|
||||
bookmarkCreator->setCurrentBookmarkCategory(bookmark->getCategory());
|
||||
bookmarkCreator->setIsEdge((dynamic_cast<EdgeBookmark*>(bookmark.get()) != NULL));
|
||||
|
||||
bookmarkCreator->show();
|
||||
}
|
||||
|
||||
void QtBookmarkBar::doDisplayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks)
|
||||
{
|
||||
if (m_bookmarkBrowser == NULL)
|
||||
{
|
||||
m_bookmarkBrowser = new QtBookmarkBrowser();
|
||||
m_bookmarkBrowser->setupBookmarkBrowser();
|
||||
}
|
||||
|
||||
m_bookmarkBrowser->setBookmarks(bookmarks);
|
||||
m_bookmarkBrowser->show();
|
||||
}
|
||||
|
||||
void QtBookmarkBar::doSetCreateButtonState(const BookmarkView::CreateButtonState& state)
|
||||
{
|
||||
m_createButtonState = state;
|
||||
|
||||
std::string createImage = ResourcePaths::getGuiPath() + "bookmark_view/images/edit_bookmark_icon.png";
|
||||
|
||||
m_createBookmarkButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap(createImage.c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
));
|
||||
|
||||
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);
|
||||
|
||||
std::string createImage = ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_active.png";
|
||||
|
||||
m_createBookmarkButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap(createImage.c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_createBookmarkButton->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkBar::doEnableDisplayButton(bool enable)
|
||||
{
|
||||
m_showBookmarksButton->setEnabled(enable);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
#ifndef QT_BOOKMARK_BAR_H
|
||||
#define QT_BOOKMARK_BAR_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <qtextedit.h>
|
||||
|
||||
#include "data/bookmark/Bookmark.h"
|
||||
|
||||
#include "component/view/BookmarkView.h"
|
||||
#include "qt/window/QtBookmarkBrowser.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
#include "utility/messaging/type/MessageEnteredLicense.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
|
||||
#include "data/bookmark/Bookmark.h"
|
||||
|
||||
class QPushButton;
|
||||
|
||||
class QtBookmarkBar
|
||||
: public QFrame
|
||||
, public MessageListener<MessageEnteredLicense>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtBookmarkBar();
|
||||
virtual ~QtBookmarkBar();
|
||||
|
||||
void refreshStyle();
|
||||
|
||||
virtual void displayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
virtual void displayBookmarkCreator(const std::vector<std::string>& names, const std::vector<BookmarkCategory>& categories);
|
||||
virtual void displayBookmarkEditor(std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories);
|
||||
|
||||
void setCreateButtonState(const BookmarkView::CreateButtonState& state);
|
||||
void enableDisplayButton(bool enable);
|
||||
|
||||
bool bookmarkBrowserIsVisible() const;
|
||||
|
||||
private slots:
|
||||
void createBookmarkClicked();
|
||||
void showBookmarksClicked();
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageEnteredLicense* message);
|
||||
|
||||
void doDisplayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
void doDisplayBookmarkCreator(const std::vector<std::string>& names, const std::vector<BookmarkCategory>& categories);
|
||||
void doDisplayBookmarkEditor(std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories);
|
||||
void doSetCreateButtonState(const BookmarkView::CreateButtonState& state);
|
||||
void doEnableDisplayButton(bool enable);
|
||||
|
||||
QtThreadedLambdaFunctor m_onQtThread;
|
||||
|
||||
QPushButton* m_createBookmarkButton;
|
||||
QPushButton* m_showBookmarksButton;
|
||||
|
||||
QtThreadedFunctor<std::vector<std::shared_ptr<Bookmark>>> m_displayBookmarksFunctor;
|
||||
QtThreadedFunctor<std::vector<std::string>, std::vector<BookmarkCategory>> m_displayBookmarkCreatorFunctor;
|
||||
QtThreadedFunctor<std::shared_ptr<Bookmark>, std::vector<BookmarkCategory>> m_displayBookmarkEditorFunctor;
|
||||
QtThreadedFunctor<BookmarkView::CreateButtonState> m_setCreateButtonStateFunctor;
|
||||
QtThreadedFunctor<bool> m_enableDisplayButtonFunctor;
|
||||
|
||||
QtBookmarkBrowser* m_bookmarkBrowser;
|
||||
|
||||
BookmarkView::CreateButtonState m_createButtonState;
|
||||
};
|
||||
|
||||
#endif // QT_BOOKMARK_BAR_H
|
||||
@@ -0,0 +1,145 @@
|
||||
#include "QtBookmarkCategory.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "utility/messaging/type/MessageDeleteBookmarkCategoryWithBookmarks.h"
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
QtBookmarkCategory::QtBookmarkCategory()
|
||||
: m_name(NULL)
|
||||
, m_layout(NULL)
|
||||
, m_deleteButton(NULL)
|
||||
, m_id(-1)
|
||||
, m_treeItem(NULL)
|
||||
{
|
||||
setObjectName("bookmark_category");
|
||||
|
||||
m_layout = new QHBoxLayout();
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(m_layout);
|
||||
|
||||
m_expandButton = new QPushButton();
|
||||
m_expandButton->setObjectName("category_expand_button");
|
||||
m_expandButton->setToolTip("Show/Hide bookmarks in this category");
|
||||
m_expandButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_down.png",
|
||||
"bookmark/button"
|
||||
));
|
||||
m_expandButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
m_layout->addWidget(m_expandButton);
|
||||
|
||||
connect(m_expandButton, SIGNAL(clicked()), this, SLOT(expandClicked()));
|
||||
|
||||
m_name = new QLabel();
|
||||
m_name->setObjectName("category_name");
|
||||
m_name->setText("");
|
||||
m_layout->addWidget(m_name);
|
||||
|
||||
m_deleteButton = new QPushButton();
|
||||
m_deleteButton->setObjectName("category_delete_button");
|
||||
m_deleteButton->setToolTip("Delete this Bookmark Category and the containing Bookmarks");
|
||||
// m_deleteButton->setText("Delete");
|
||||
m_deleteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
m_deleteButton->setIcon(QPixmap((ResourcePaths::getGuiPath() + "bookmark_view/images/bookmark_delete_icon.png").c_str()));
|
||||
m_layout->addWidget(m_deleteButton);
|
||||
|
||||
connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteClicked()));
|
||||
}
|
||||
|
||||
QtBookmarkCategory::~QtBookmarkCategory()
|
||||
{
|
||||
}
|
||||
|
||||
void QtBookmarkCategory::setName(const std::string& name)
|
||||
{
|
||||
if (m_name != NULL)
|
||||
{
|
||||
m_name->setText(name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
std::string QtBookmarkCategory::getName() const
|
||||
{
|
||||
std::string result = "";
|
||||
|
||||
if (m_name != NULL)
|
||||
{
|
||||
result = m_name->text().toStdString();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void QtBookmarkCategory::setId(const Id id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
Id QtBookmarkCategory::getId() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void QtBookmarkCategory::setTreeWidgetItem(QTreeWidgetItem* treeItem)
|
||||
{
|
||||
m_treeItem = treeItem;
|
||||
}
|
||||
|
||||
void QtBookmarkCategory::updateArrow()
|
||||
{
|
||||
if (m_treeItem != NULL)
|
||||
{
|
||||
if (m_treeItem->isExpanded())
|
||||
{
|
||||
m_expandButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_down.png",
|
||||
"bookmark/button"
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_expandButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "bookmark_view/images/arrow_right.png",
|
||||
"bookmark/button"
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkCategory::expandClicked()
|
||||
{
|
||||
if (m_treeItem != NULL)
|
||||
{
|
||||
if (m_treeItem->isExpanded())
|
||||
{
|
||||
m_treeItem->setExpanded(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_treeItem->setExpanded(true);
|
||||
}
|
||||
|
||||
updateArrow();
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkCategory::deleteClicked()
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Delete Category");
|
||||
msgBox.setInformativeText("Do you really want to delete this category AND all containing bookmarks?");
|
||||
QAbstractButton* yesButton = msgBox.addButton("Delete", QMessageBox::ButtonRole::YesRole);
|
||||
QAbstractButton* noButton = msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole);
|
||||
msgBox.setIcon(QMessageBox::Icon::Question);
|
||||
int ret = msgBox.exec();
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
MessageDeleteBookmarkCategoryWithBookmarks(m_id).dispatch();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef QT_BOOKMARK_CATEGORY_H
|
||||
#define QT_BOOKMARK_CATEGORY_H
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include "utility/types.h"
|
||||
|
||||
class QtBookmarkCategory
|
||||
: public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtBookmarkCategory();
|
||||
~QtBookmarkCategory();
|
||||
|
||||
void setName(const std::string& name);
|
||||
std::string getName() const;
|
||||
|
||||
void setId(const Id id);
|
||||
Id getId() const;
|
||||
|
||||
void setTreeWidgetItem(QTreeWidgetItem* treeItem);
|
||||
|
||||
void updateArrow();
|
||||
|
||||
private slots:
|
||||
void expandClicked();
|
||||
void deleteClicked();
|
||||
|
||||
private:
|
||||
QHBoxLayout* m_layout;
|
||||
QLabel* m_name;
|
||||
|
||||
QPushButton* m_expandButton;
|
||||
QPushButton* m_deleteButton;
|
||||
|
||||
QTreeWidgetItem* m_treeItem; // store a pointer to the 'parent' tree item to enable the custom expand button
|
||||
|
||||
Id m_id;
|
||||
};
|
||||
|
||||
#endif // QT_BOOKMARK_CATEGORY_H
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
QtStatusBar::QtStatusBar()
|
||||
: m_text(this)
|
||||
, m_ideStatusText(this)
|
||||
{
|
||||
addWidget(new QWidget()); // add some space
|
||||
|
||||
@@ -42,6 +43,9 @@ QtStatusBar::QtStatusBar()
|
||||
addPermanentWidget(&m_errorButton);
|
||||
|
||||
connect(&m_errorButton, SIGNAL(clicked()), this, SLOT(showErrors()));
|
||||
|
||||
m_ideStatusText.setText("No IDE connected");
|
||||
addWidget(&m_ideStatusText);
|
||||
}
|
||||
|
||||
QtStatusBar::~QtStatusBar()
|
||||
@@ -86,6 +90,11 @@ void QtStatusBar::setErrorCount(ErrorCountInfo errorCount)
|
||||
}
|
||||
}
|
||||
|
||||
void QtStatusBar::setIdeStatus(const std::string& text)
|
||||
{
|
||||
m_ideStatusText.setText(text.c_str());
|
||||
}
|
||||
|
||||
void QtStatusBar::showStatus()
|
||||
{
|
||||
MessageShowStatus().dispatch();
|
||||
|
||||
@@ -21,6 +21,8 @@ public:
|
||||
void setText(const std::string& text, bool isError, bool showLoader);
|
||||
void setErrorCount(ErrorCountInfo errorCount);
|
||||
|
||||
void setIdeStatus(const std::string& text);
|
||||
|
||||
private slots:
|
||||
void showStatus();
|
||||
void showErrors();
|
||||
@@ -29,6 +31,8 @@ private:
|
||||
QPushButton m_text;
|
||||
QLabel m_loader;
|
||||
QPushButton m_errorButton;
|
||||
|
||||
QLabel m_ideStatusText;
|
||||
};
|
||||
|
||||
#endif // QT_STATUS_BAR_H
|
||||
|
||||
@@ -23,6 +23,8 @@ void QtIDECommunicationController::startListening()
|
||||
m_tcpWrapper.startListening();
|
||||
}
|
||||
);
|
||||
|
||||
sendInitialPing();
|
||||
}
|
||||
|
||||
void QtIDECommunicationController::stopListening()
|
||||
|
||||
@@ -86,21 +86,49 @@ namespace utility
|
||||
|
||||
if (key == "setting")
|
||||
{
|
||||
if (val == "font_size")
|
||||
if (val.find("font_size") != std::string::npos)
|
||||
{
|
||||
val = std::to_string(ApplicationSettings::getInstance()->getFontSize());
|
||||
}
|
||||
else if (val == "font_size+2")
|
||||
{
|
||||
val = std::to_string(ApplicationSettings::getInstance()->getFontSize() + 2);
|
||||
}
|
||||
else if (val == "font_size+5")
|
||||
{
|
||||
val = std::to_string(ApplicationSettings::getInstance()->getFontSize() + 5);
|
||||
}
|
||||
else if (val == "font_size-2")
|
||||
{
|
||||
val = std::to_string(ApplicationSettings::getInstance()->getFontSize() - 2);
|
||||
// check for modifier
|
||||
if (val.find("+") != std::string::npos)
|
||||
{
|
||||
int pos = val.find("+");
|
||||
std::string sub = val.substr(pos + 1);
|
||||
|
||||
int mod = std::stoi(sub);
|
||||
|
||||
val = std::to_string(ApplicationSettings::getInstance()->getFontSize() + mod);
|
||||
}
|
||||
else if (val.find("-") != std::string::npos)
|
||||
{
|
||||
int pos = val.find("-");
|
||||
std::string sub = val.substr(pos + 1);
|
||||
|
||||
int mod = std::stoi(sub);
|
||||
|
||||
val = std::to_string(ApplicationSettings::getInstance()->getFontSize() - mod);
|
||||
}
|
||||
else if (val.find("*") != std::string::npos)
|
||||
{
|
||||
int pos = val.find("*");
|
||||
std::string sub = val.substr(pos + 1);
|
||||
|
||||
int mod = std::stoi(sub);
|
||||
|
||||
val = std::to_string(ApplicationSettings::getInstance()->getFontSize() * mod);
|
||||
}
|
||||
else if (val.find("/") != std::string::npos)
|
||||
{
|
||||
int pos = val.find("/");
|
||||
std::string sub = val.substr(pos + 1);
|
||||
|
||||
int mod = std::stoi(sub);
|
||||
|
||||
val = std::to_string(ApplicationSettings::getInstance()->getFontSize() / mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
val = std::to_string(ApplicationSettings::getInstance()->getFontSize());
|
||||
}
|
||||
}
|
||||
else if (val == "font_name")
|
||||
{
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
#include "qt/view/QtBookmarkView.h"
|
||||
|
||||
#include "qt/window/QtBookmarkBrowser.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "component/controller/RefreshController.h"
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QtBookmarkView::QtBookmarkView(ViewLayout* viewLayout)
|
||||
: BookmarkView(viewLayout)
|
||||
, m_refreshViewFunctor(std::bind(&QtBookmarkView::doRefreshView, this))
|
||||
{
|
||||
m_widget = new QtBookmarkBar();
|
||||
setStyleSheet();
|
||||
}
|
||||
|
||||
QtBookmarkView::~QtBookmarkView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QtBookmarkView::createWidgetWrapper()
|
||||
{
|
||||
setWidgetWrapper(std::make_shared<QtViewWidgetWrapper>(m_widget));
|
||||
}
|
||||
|
||||
void QtBookmarkView::initView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QtBookmarkView::refreshView()
|
||||
{
|
||||
m_refreshViewFunctor();
|
||||
}
|
||||
|
||||
void QtBookmarkView::setCreateButtonState(const CreateButtonState& state)
|
||||
{
|
||||
m_widget->setCreateButtonState(state);
|
||||
}
|
||||
|
||||
void QtBookmarkView::enableDisplayBookmarks(bool enable)
|
||||
{
|
||||
m_widget->enableDisplayButton(enable);
|
||||
}
|
||||
|
||||
bool QtBookmarkView::bookmarkBrowserIsVisible() const
|
||||
{
|
||||
return m_widget->bookmarkBrowserIsVisible();
|
||||
}
|
||||
|
||||
void QtBookmarkView::doRefreshView()
|
||||
{
|
||||
setStyleSheet();
|
||||
m_widget->refreshStyle();
|
||||
}
|
||||
|
||||
void QtBookmarkView::setStyleSheet()
|
||||
{
|
||||
m_widget->setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css").c_str());
|
||||
}
|
||||
|
||||
void QtBookmarkView::displayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks)
|
||||
{
|
||||
m_widget->displayBookmarks(bookmarks);
|
||||
}
|
||||
|
||||
void QtBookmarkView::displayBookmarkCreator(const std::vector<std::string>& names, const std::vector<BookmarkCategory>& categories)
|
||||
{
|
||||
m_widget->displayBookmarkCreator(names, categories);
|
||||
}
|
||||
|
||||
void QtBookmarkView::displayBookmarkEditor(std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories)
|
||||
{
|
||||
m_widget->displayBookmarkEditor(bookmark, categories);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef QT_BOOKMARK_VIEW_H
|
||||
#define QT_BOOKMARK_VIEW_H
|
||||
|
||||
#include "component/view/BookmarkView.h"
|
||||
|
||||
#include "qt/element/QtBookmarkBar.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
|
||||
class QtBookmarkView
|
||||
: public BookmarkView
|
||||
{
|
||||
public:
|
||||
QtBookmarkView(ViewLayout* viewLayout);
|
||||
virtual ~QtBookmarkView();
|
||||
|
||||
// View implementation
|
||||
virtual void createWidgetWrapper();
|
||||
virtual void initView();
|
||||
virtual void refreshView();
|
||||
|
||||
virtual void setCreateButtonState(const CreateButtonState& state);
|
||||
virtual void enableDisplayBookmarks(bool enable);
|
||||
|
||||
virtual bool bookmarkBrowserIsVisible() const;
|
||||
|
||||
private:
|
||||
void doRefreshView();
|
||||
|
||||
void setStyleSheet();
|
||||
|
||||
virtual void displayBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
virtual void displayBookmarkCreator(const std::vector<std::string>& names, const std::vector<BookmarkCategory>& categories);
|
||||
virtual void displayBookmarkEditor(std::shared_ptr<Bookmark> bookmark, const std::vector<BookmarkCategory>& categories);
|
||||
|
||||
QtThreadedFunctor<> m_refreshViewFunctor;
|
||||
|
||||
QtBookmarkBar* m_widget;
|
||||
};
|
||||
|
||||
#endif // QT_BOOKMARK_VIEW_H
|
||||
@@ -45,6 +45,11 @@ void QtStatusBarView::setErrorCount(ErrorCountInfo errorCount)
|
||||
m_setErrorCountFunctor(errorCount);
|
||||
}
|
||||
|
||||
void QtStatusBarView::showIdeStatus(const std::string& message)
|
||||
{
|
||||
m_widget->setIdeStatus(message);
|
||||
}
|
||||
|
||||
void QtStatusBarView::doShowMessage(const std::string& message, bool isError, bool showLoader)
|
||||
{
|
||||
m_widget->setText(message, isError, showLoader);
|
||||
|
||||
@@ -25,6 +25,8 @@ public:
|
||||
virtual void showMessage(const std::string& message, bool isError, bool showLoader);
|
||||
virtual void setErrorCount(ErrorCountInfo errorCount);
|
||||
|
||||
virtual void showIdeStatus(const std::string& message);
|
||||
|
||||
private:
|
||||
void doShowMessage(const std::string& message, bool isError, bool showLoader);
|
||||
void doSetErrorCount(ErrorCountInfo errorCount);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "qt/view/QtViewFactory.h"
|
||||
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "qt/view/QtBookmarkView.h"
|
||||
#include "qt/view/QtCodeView.h"
|
||||
#include "qt/view/QtCompositeView.h"
|
||||
#include "qt/view/QtDialogView.h"
|
||||
@@ -46,6 +47,11 @@ std::shared_ptr<TabbedView> QtViewFactory::createTabbedView(ViewLayout* viewLayo
|
||||
return ptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<BookmarkView> QtViewFactory::createBookmarkView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::createInitAndAddToLayout<QtBookmarkView>(viewLayout);
|
||||
}
|
||||
|
||||
std::shared_ptr<CodeView> QtViewFactory::createCodeView(ViewLayout* viewLayout) const
|
||||
{
|
||||
return View::createInitAndAddToLayout<QtCodeView>(viewLayout);
|
||||
|
||||
@@ -14,6 +14,7 @@ public:
|
||||
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<BookmarkView> createBookmarkView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<CodeView> createCodeView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<ErrorView> createErrorView(ViewLayout* viewLayout) const;
|
||||
virtual std::shared_ptr<GraphView> createGraphView(ViewLayout* viewLayout) const;
|
||||
|
||||
@@ -0,0 +1,283 @@
|
||||
#include "QtBookmarkBrowser.h"
|
||||
|
||||
#include "qt/element/QtBookmark.h"
|
||||
#include "qt/element/QtBookmarkCategory.h"
|
||||
#include <QHeaderView>
|
||||
|
||||
#include "data/bookmark/Bookmark.h"
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
QtBookmarkBrowser::QtBookmarkBrowser(QWidget* parent)
|
||||
: QtWindow(parent)
|
||||
, m_headerBackground(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
QtBookmarkBrowser::~QtBookmarkBrowser()
|
||||
{
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::setupBookmarkBrowser()
|
||||
{
|
||||
m_layout = new QHBoxLayout();
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setAlignment(Qt::AlignTop);
|
||||
setLayout(m_layout);
|
||||
|
||||
m_headerBackground = new QWidget(m_window);
|
||||
m_headerBackground->setObjectName("header_background");
|
||||
m_headerBackground->setGeometry(0, 0, 0, 0);
|
||||
m_headerBackground->show();
|
||||
m_headerBackground->lower();
|
||||
|
||||
m_headerLayout = new QVBoxLayout(this);
|
||||
m_headerLayout->setObjectName("header");
|
||||
m_headerLayout->setSpacing(0);
|
||||
m_headerLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_headerLayout->setAlignment(Qt::AlignTop);
|
||||
m_layout->addLayout(m_headerLayout);
|
||||
|
||||
m_bodyLayout = new QVBoxLayout(this);
|
||||
m_bodyLayout->setObjectName("body");
|
||||
m_bodyLayout->setSpacing(0);
|
||||
m_bodyLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_bodyLayout->setAlignment(Qt::AlignLeft);
|
||||
m_layout->addLayout(m_bodyLayout);
|
||||
|
||||
m_title = new QLabel(this);
|
||||
m_title->setObjectName("title");
|
||||
m_title->setText("Bookmarks");
|
||||
m_headerLayout->addWidget(m_title);
|
||||
|
||||
m_filterLabel = new QLabel(this);
|
||||
m_filterLabel->setObjectName("filter_label");
|
||||
m_filterLabel->setText("Show:");
|
||||
m_headerLayout->addWidget(m_filterLabel);
|
||||
|
||||
m_filterComboBox = new QComboBox(this);
|
||||
m_filterComboBox->addItem("All");
|
||||
m_filterComboBox->addItem("Nodes");
|
||||
m_filterComboBox->addItem("Edges");
|
||||
m_filterComboBox->setObjectName("filter_box");
|
||||
m_headerLayout->addWidget(m_filterComboBox);
|
||||
|
||||
connect(m_filterComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(filterBoxChanged(const QString&)));
|
||||
|
||||
m_orderLabel = new QLabel(this);
|
||||
m_orderLabel->setObjectName("order_label");
|
||||
m_orderLabel->setText("Sort by:");
|
||||
m_headerLayout->addWidget(m_orderLabel);
|
||||
|
||||
m_orderNames.push_back("Date des.");
|
||||
m_orderNames.push_back("Date asc.");
|
||||
m_orderNames.push_back("Name des.");
|
||||
m_orderNames.push_back("Name asc.");
|
||||
m_currentOrderIndex = 0;
|
||||
|
||||
m_orderComboBox = new QComboBox(this);
|
||||
// m_orderComboBox->setToolTip("Select Bookmark Order");
|
||||
m_orderComboBox->addItem(m_orderNames[0].c_str());
|
||||
m_orderComboBox->addItem(m_orderNames[1].c_str());
|
||||
m_orderComboBox->addItem(m_orderNames[2].c_str());
|
||||
m_orderComboBox->addItem(m_orderNames[3].c_str());
|
||||
m_orderComboBox->setObjectName("order_box");
|
||||
m_headerLayout->addWidget(m_orderComboBox);
|
||||
|
||||
connect(m_orderComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(orderBoxChanged(const QString&)));
|
||||
|
||||
|
||||
m_headerLayout->addWidget(m_orderComboBox);
|
||||
|
||||
m_bookmarkTree = new QTreeWidget();
|
||||
m_bookmarkTree->setObjectName("bookmark_tree");
|
||||
m_bookmarkTree->setSelectionMode(QAbstractItemView::SelectionMode::NoSelection);
|
||||
m_bookmarkTree->header()->close();
|
||||
m_bookmarkTree->setAlternatingRowColors(true);
|
||||
m_bookmarkTree->setIndentation(0);
|
||||
m_bookmarkTree->setHeaderLabel("Bookmarks");
|
||||
|
||||
connect(m_bookmarkTree, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(itemExpanded(QTreeWidgetItem*)));
|
||||
connect(m_bookmarkTree, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(itemCollapsed(QTreeWidgetItem*)));
|
||||
|
||||
// m_bookmarkTree->icon
|
||||
|
||||
m_bodyLayout->addWidget(m_bookmarkTree);
|
||||
|
||||
m_closeButton = new QPushButton(this);
|
||||
m_closeButton->setObjectName("close_button");
|
||||
m_closeButton->setToolTip("Close Window");
|
||||
m_closeButton->setText("Close");
|
||||
m_closeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||
m_bodyLayout->addWidget(m_closeButton);
|
||||
m_bodyLayout->setAlignment(m_closeButton, Qt::AlignRight);
|
||||
|
||||
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(closeButtonClicked()));
|
||||
|
||||
setFixedSize(QSize(790, 600));
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css").c_str());
|
||||
|
||||
m_headerBackground->setGeometry(0, 0, 247, size().height()-20);
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::setBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks)
|
||||
{
|
||||
m_bookmarkTree->clear();
|
||||
// m_bookmarkTree->adjustSize();
|
||||
|
||||
for (unsigned int i = 0; i < bookmarks.size(); i++)
|
||||
{
|
||||
QtBookmark* bookmark = new QtBookmark();
|
||||
bookmark->setName(bookmarks[i]->getDisplayName());
|
||||
bookmark->setBookmark(bookmarks[i]);
|
||||
|
||||
QTreeWidgetItem* top = findOrCreateTreeCategory(bookmarks[i]->getCategory().getName(), bookmarks[i]->getCategory().getId());
|
||||
QTreeWidgetItem* treeWidgetItem = new QTreeWidgetItem(top);
|
||||
// treeWidgetItem->setText(0, bookmarks[i]->getDisplayName().c_str());
|
||||
treeWidgetItem->setSizeHint(0, bookmark->minimumSizeHint());
|
||||
m_bookmarkTree->setItemWidget(treeWidgetItem, 0, bookmark);
|
||||
top->addChild(treeWidgetItem);
|
||||
|
||||
bookmark->setTreeWidgetItem(top);
|
||||
|
||||
top->setExpanded(true);
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::closeButtonClicked()
|
||||
{
|
||||
try
|
||||
{
|
||||
close();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::string message = e.what();
|
||||
|
||||
LOG_ERROR(message);
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::filterBoxChanged(const QString& text)
|
||||
{
|
||||
MessageDisplayBookmarks(getSelectedFilter(), getSelectedOrder()).dispatch();
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::orderBoxChanged(const QString& text)
|
||||
{
|
||||
MessageDisplayBookmarks(getSelectedFilter(), getSelectedOrder()).dispatch();
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::itemExpanded(QTreeWidgetItem* item)
|
||||
{
|
||||
QWidget* widget = m_bookmarkTree->itemWidget(item, 0);
|
||||
|
||||
QtBookmarkCategory* category = dynamic_cast<QtBookmarkCategory*>(widget);
|
||||
|
||||
if (category != NULL)
|
||||
{
|
||||
category->updateArrow();
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::itemCollapsed(QTreeWidgetItem* item)
|
||||
{
|
||||
QWidget* widget = m_bookmarkTree->itemWidget(item, 0);
|
||||
|
||||
QtBookmarkCategory* category = dynamic_cast<QtBookmarkCategory*>(widget);
|
||||
|
||||
if (category != NULL)
|
||||
{
|
||||
category->updateArrow();
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::handleMessage(MessageDeleteBookmark* message)
|
||||
{
|
||||
MessageDisplayBookmarks(getSelectedFilter(), getSelectedOrder()).dispatch();
|
||||
}
|
||||
|
||||
void QtBookmarkBrowser::handleMessage(MessageEditBookmark* message)
|
||||
{
|
||||
MessageDisplayBookmarks(getSelectedFilter(), getSelectedOrder()).dispatch();
|
||||
}
|
||||
|
||||
MessageDisplayBookmarks::BookmarkFilter QtBookmarkBrowser::getSelectedFilter()
|
||||
{
|
||||
std::string text = m_filterComboBox->currentText().toStdString();
|
||||
|
||||
if (text == "Nodes")
|
||||
{
|
||||
return MessageDisplayBookmarks::BookmarkFilter::NODES;
|
||||
}
|
||||
else if (text == "Edges")
|
||||
{
|
||||
return MessageDisplayBookmarks::BookmarkFilter::EDGES;
|
||||
}
|
||||
|
||||
return MessageDisplayBookmarks::BookmarkFilter::ALL;
|
||||
}
|
||||
|
||||
MessageDisplayBookmarks::BookmarkOrder QtBookmarkBrowser::getSelectedOrder()
|
||||
{
|
||||
std::string orderString = m_orderComboBox->currentText().toStdString(); // m_orderButton->text().toStdString();
|
||||
|
||||
if (orderString == m_orderNames[0])
|
||||
{
|
||||
return MessageDisplayBookmarks::BookmarkOrder::DATE_DESCENDING;
|
||||
}
|
||||
else if (orderString == m_orderNames[1])
|
||||
{
|
||||
return MessageDisplayBookmarks::BookmarkOrder::DATE_ASCENDING;
|
||||
}
|
||||
else if (orderString == m_orderNames[2])
|
||||
{
|
||||
return MessageDisplayBookmarks::BookmarkOrder::NAME_DESCENDING;
|
||||
}
|
||||
else if (orderString == m_orderNames[3])
|
||||
{
|
||||
return MessageDisplayBookmarks::BookmarkOrder::NAME_ASCENDING;
|
||||
}
|
||||
else
|
||||
{
|
||||
return MessageDisplayBookmarks::BookmarkOrder::NONE;
|
||||
}
|
||||
}
|
||||
|
||||
QTreeWidgetItem* QtBookmarkBrowser::findOrCreateTreeCategory(const std::string& name, const Id id)
|
||||
{
|
||||
for (int i = 0; i < m_bookmarkTree->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem* item = m_bookmarkTree->topLevelItem(i);
|
||||
|
||||
if (item->whatsThis(0).toStdString() == name)
|
||||
{
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
QtBookmarkCategory* category = new QtBookmarkCategory();
|
||||
if (name.length() > 0)
|
||||
{
|
||||
category->setName(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
category->setName("No Category");
|
||||
}
|
||||
category->setId(id);
|
||||
|
||||
QTreeWidgetItem* newItem = new QTreeWidgetItem(m_bookmarkTree);
|
||||
newItem->setChildIndicatorPolicy(QTreeWidgetItem::ShowIndicator);
|
||||
newItem->setSizeHint(0, category->minimumSizeHint());
|
||||
newItem->setWhatsThis(0, name.c_str());
|
||||
category->setTreeWidgetItem(newItem);
|
||||
|
||||
m_bookmarkTree->setItemWidget(newItem, 0, category);
|
||||
|
||||
m_bookmarkTree->addTopLevelItem(newItem);
|
||||
|
||||
return newItem;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
#ifndef QT_BOOKMARK_BROWSER_H
|
||||
#define QT_BOOKMARK_BROWSER_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
|
||||
#include <QListWidget>
|
||||
#include <QTreeWidget>
|
||||
|
||||
#include "qt/window/QtWindow.h"
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageDeleteBookmark.h"
|
||||
#include "utility/messaging/type/MessageDisplayBookmarks.h"
|
||||
#include "utility/messaging/type/MessageEditBookmark.h"
|
||||
|
||||
class Bookmark;
|
||||
class QtBookmark;
|
||||
|
||||
class QtBookmarkBrowser
|
||||
: public QtWindow
|
||||
, public MessageListener<MessageDeleteBookmark>
|
||||
, public MessageListener<MessageEditBookmark>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtBookmarkBrowser(QWidget* parent = nullptr);
|
||||
~QtBookmarkBrowser();
|
||||
|
||||
void setupBookmarkBrowser();
|
||||
void setBookmarks(const std::vector<std::shared_ptr<Bookmark>>& bookmarks);
|
||||
|
||||
private slots:
|
||||
void closeButtonClicked();
|
||||
void filterBoxChanged(const QString& text);
|
||||
void orderBoxChanged(const QString& text);
|
||||
void itemExpanded(QTreeWidgetItem* item);
|
||||
void itemCollapsed(QTreeWidgetItem* item);
|
||||
|
||||
private:
|
||||
virtual void handleMessage(MessageDeleteBookmark* message);
|
||||
virtual void handleMessage(MessageEditBookmark* message);
|
||||
|
||||
MessageDisplayBookmarks::BookmarkFilter getSelectedFilter();
|
||||
MessageDisplayBookmarks::BookmarkOrder getSelectedOrder();
|
||||
|
||||
QTreeWidgetItem* findOrCreateTreeCategory(const std::string& name, const Id id);
|
||||
|
||||
QHBoxLayout* m_layout;
|
||||
QVBoxLayout* m_headerLayout;
|
||||
QVBoxLayout* m_bodyLayout;
|
||||
|
||||
QTreeWidget* m_bookmarkTree;
|
||||
QPushButton* m_closeButton;
|
||||
|
||||
QLabel* m_title;
|
||||
QLabel* m_filterLabel;
|
||||
QLabel* m_orderLabel;
|
||||
QComboBox* m_filterComboBox;
|
||||
QComboBox* m_orderComboBox;
|
||||
std::vector<std::string> m_orderNames;
|
||||
int m_currentOrderIndex;
|
||||
|
||||
QWidget* m_headerBackground;
|
||||
};
|
||||
|
||||
#endif // QT_BOOKMARK_BROWSER_H
|
||||
@@ -0,0 +1,233 @@
|
||||
#include "QtBookmarkCreator.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "data/bookmark/BookmarkCategory.h"
|
||||
|
||||
#include "utility/messaging/type/MessageCreateBookmark.h"
|
||||
#include "utility/messaging/type/MessageCreateBookmarkCategory.h"
|
||||
#include "utility/messaging/type/MessageEditBookmark.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QString QtBookmarkCreator::m_namePlaceholder = "Name";
|
||||
QString QtBookmarkCreator::m_commentPlaceholder = "Comment";
|
||||
QString QtBookmarkCreator::m_categoryPlaceholder = "Category";
|
||||
|
||||
QtBookmarkCreator::QtBookmarkCreator(QWidget* parent, bool edit, Id id)
|
||||
: QtWindow(parent)
|
||||
, m_edit(edit)
|
||||
, m_bookmarkId(id)
|
||||
, m_categoryCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
QtBookmarkCreator::~QtBookmarkCreator()
|
||||
{
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::setupBookmarkCreator()
|
||||
{
|
||||
m_displayName = new QLineEdit(this);
|
||||
m_displayName->setObjectName("display_name_edit");
|
||||
m_commentBox = new QTextEdit(this);
|
||||
m_commentBox->setObjectName("comment_box");
|
||||
m_categoryBox = new QComboBox(this);
|
||||
m_categoryBox->setObjectName("category_box");
|
||||
|
||||
m_title = new QLabel();
|
||||
if (m_edit == true)
|
||||
{
|
||||
m_title->setText("Edit Bookmark");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_title->setText("Create Bookmark");
|
||||
}
|
||||
m_title->setObjectName("creator_title_label");
|
||||
m_nameLabel = new QLabel();
|
||||
m_nameLabel->setText("Bookmark:");
|
||||
m_nameLabel->setObjectName("creator_name_label");
|
||||
m_commentLabel = new QLabel();
|
||||
m_commentLabel->setText("Comment:");
|
||||
m_commentLabel->setObjectName("creator_comment_label");
|
||||
m_categoryLabel = new QLabel();
|
||||
m_categoryLabel->setText("Choose or Create Bookmark:");
|
||||
m_categoryLabel->setObjectName("category_label");
|
||||
|
||||
m_categoryBox->addItem("");
|
||||
m_categoryBox->setEditable(true);
|
||||
m_categoryBox->setInsertPolicy(QComboBox::InsertPolicy::InsertAtTop);
|
||||
|
||||
m_categoryCount = m_categoryBox->count();
|
||||
|
||||
m_cancelButton = new QPushButton(this);
|
||||
m_cancelButton->setObjectName("creator_cancel_button");
|
||||
m_cancelButton->setText("Cancel");
|
||||
m_createButton = new QPushButton(this);
|
||||
m_createButton->setObjectName("creator_create_button");
|
||||
if (m_edit)
|
||||
{
|
||||
m_createButton->setText("Save");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_createButton->setText("Create");
|
||||
}
|
||||
|
||||
m_commentBox->setPlaceholderText(m_commentPlaceholder);
|
||||
m_displayName->setPlaceholderText(m_namePlaceholder);
|
||||
m_categoryBox->lineEdit()->setPlaceholderText(m_categoryPlaceholder);
|
||||
|
||||
m_createButton->setEnabled(false);
|
||||
|
||||
connect(m_displayName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&)));
|
||||
connect(m_commentBox, SIGNAL(textChanged()), this, SLOT(onCommentChanged()));
|
||||
connect(m_categoryBox, SIGNAL(currentTextChanged(const QString&)), this, SLOT(onCategoryChanged(const QString&)));
|
||||
connect(m_categoryBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxIndexChanged(int)));
|
||||
connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(cancel()));
|
||||
connect(m_createButton, SIGNAL(clicked()), this, SLOT(create()));
|
||||
|
||||
m_layout = new QVBoxLayout(this);
|
||||
m_layout->addWidget(m_title);
|
||||
m_layout->addWidget(m_nameLabel);
|
||||
m_layout->addWidget(m_displayName);
|
||||
m_layout->addWidget(m_commentLabel);
|
||||
m_layout->addWidget(m_commentBox);
|
||||
m_layout->addWidget(m_categoryLabel);
|
||||
m_layout->addWidget(m_categoryBox);
|
||||
|
||||
QHBoxLayout* buttonLayout = new QHBoxLayout(this);
|
||||
|
||||
buttonLayout->addWidget(m_cancelButton);
|
||||
buttonLayout->setAlignment(m_cancelButton, Qt::AlignLeft);
|
||||
buttonLayout->addWidget(m_createButton);
|
||||
buttonLayout->setAlignment(m_createButton, Qt::AlignRight);
|
||||
|
||||
m_layout->addLayout(buttonLayout);
|
||||
|
||||
m_headerBackground = new QWidget(m_window);
|
||||
m_headerBackground->setObjectName("creator_header_background");
|
||||
m_headerBackground->setGeometry(0, 0, 0, 0);
|
||||
m_headerBackground->show();
|
||||
m_headerBackground->lower();
|
||||
|
||||
setFixedSize(QSize(500, 580));
|
||||
refreshStyle();
|
||||
|
||||
m_headerBackground->setGeometry(0, 0, size().width() - 10, 70);
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::refreshStyle()
|
||||
{
|
||||
setStyleSheet(utility::getStyleSheet(ResourcePaths::getGuiPath() + "bookmark_view/bookmark_view.css").c_str());
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::setDisplayName(const std::string& name)
|
||||
{
|
||||
m_displayName->setText(name.c_str());
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::setComment(const std::string& comment)
|
||||
{
|
||||
m_commentBox->setText(comment.c_str());
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::setBookmarkCategories(const std::vector<BookmarkCategory>& categories)
|
||||
{
|
||||
for (unsigned int i = 0; i < categories.size(); i++)
|
||||
{
|
||||
m_categoryBox->addItem(categories[i].getName().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::setCurrentBookmarkCategory(const BookmarkCategory& category)
|
||||
{
|
||||
int index = m_categoryBox->findText(category.getName().c_str());
|
||||
|
||||
if (index > -1)
|
||||
{
|
||||
m_categoryBox->setCurrentIndex(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_categoryBox->addItem(category.getName().c_str());
|
||||
m_categoryBox->setCurrentIndex(1);
|
||||
}
|
||||
}
|
||||
|
||||
bool QtBookmarkCreator::getIsEdge() const
|
||||
{
|
||||
return m_isEdge;
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::setIsEdge(const bool isEdge)
|
||||
{
|
||||
m_isEdge = isEdge;
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::onNameChanged(const QString& text)
|
||||
{
|
||||
if (text.length() > 0)
|
||||
{
|
||||
m_createButton->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_createButton->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::onCommentChanged()
|
||||
{
|
||||
/*if (m_commentBox->toPlainText().size() <= 0)
|
||||
{
|
||||
m_commentBox->
|
||||
}*/
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::onCategoryChanged(const QString& text)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::onComboBoxIndexChanged(int index)
|
||||
{
|
||||
if (m_categoryBox->count() > m_categoryCount)
|
||||
{
|
||||
std::string categoryName = m_categoryBox->currentText().toStdString();
|
||||
|
||||
MessageCreateBookmarkCategory(categoryName).dispatch();
|
||||
|
||||
m_categoryCount = m_categoryBox->count();
|
||||
}
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::cancel()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void QtBookmarkCreator::create()
|
||||
{
|
||||
QString qComment = m_commentBox->toPlainText();
|
||||
QString qDisplayName = m_displayName->text();
|
||||
QString qCategory = m_categoryBox->currentText();
|
||||
|
||||
if (m_edit)
|
||||
{
|
||||
MessageEditBookmark(m_bookmarkId, qComment.toStdString(), qDisplayName.toStdString(), qCategory.toStdString(), m_isEdge).dispatch();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageCreateBookmark(qComment.toStdString(), qDisplayName.toStdString(), qCategory.toStdString()).dispatch();
|
||||
}
|
||||
|
||||
MessageStatus("Creating Bookmark for active Token").dispatch();
|
||||
|
||||
close();
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#ifndef QT_BOOKMARK_CREATOR_H
|
||||
#define QT_BOOKMARK_CREATOR_H
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
#include <QWidget>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "qt/window/QtWindow.h"
|
||||
|
||||
#include "utility/types.h"
|
||||
|
||||
class BookmarkCategory;
|
||||
|
||||
class QtBookmarkCreator
|
||||
: public QtWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtBookmarkCreator(QWidget* parent = nullptr, bool edit = false, Id id = -1);
|
||||
~QtBookmarkCreator();
|
||||
|
||||
void setupBookmarkCreator();
|
||||
|
||||
void refreshStyle();
|
||||
|
||||
void setDisplayName(const std::string& name);
|
||||
void setComment(const std::string& comment);
|
||||
|
||||
void setBookmarkCategories(const std::vector<BookmarkCategory>& categories);
|
||||
void setCurrentBookmarkCategory(const BookmarkCategory& category);
|
||||
|
||||
bool getIsEdge() const;
|
||||
void setIsEdge(const bool isEdge);
|
||||
|
||||
private slots:
|
||||
void onNameChanged(const QString& text);
|
||||
void onCommentChanged();
|
||||
void onCategoryChanged(const QString& text);
|
||||
void onComboBoxIndexChanged(int index);
|
||||
|
||||
void cancel();
|
||||
void create();
|
||||
|
||||
private:
|
||||
bool m_edit;
|
||||
Id m_bookmarkId; // important for editing
|
||||
|
||||
QLabel* m_title;
|
||||
QLabel* m_nameLabel;
|
||||
QLabel* m_commentLabel;
|
||||
QLabel* m_categoryLabel;
|
||||
|
||||
QLineEdit* m_displayName;
|
||||
QTextEdit* m_commentBox;
|
||||
QComboBox* m_categoryBox;
|
||||
|
||||
QPushButton* m_cancelButton;
|
||||
QPushButton* m_createButton;
|
||||
|
||||
QVBoxLayout* m_layout;
|
||||
|
||||
int m_categoryCount;
|
||||
|
||||
static QString m_namePlaceholder;
|
||||
static QString m_commentPlaceholder;
|
||||
static QString m_categoryPlaceholder;
|
||||
|
||||
bool m_isEdge;
|
||||
|
||||
QWidget* m_headerBackground;
|
||||
};
|
||||
|
||||
#endif // QT_BOOKMARK_CREATOR_H
|
||||
@@ -53,9 +53,18 @@ void QtRecentProjectButton::handleButtonClick()
|
||||
{
|
||||
std::string text = "Couldn't find " + m_projectFilePath.str()
|
||||
+ " in your filesystem. Delete it from this recent Proejct list?";
|
||||
int ret = QMessageBox::question(this, "Missing Project File", text.c_str(), QMessageBox::Yes | QMessageBox::No);
|
||||
// int ret = QMessageBox::question(this, "Missing Project File", text.c_str(), QMessageBox::Yes | QMessageBox::No);
|
||||
|
||||
if (ret == QMessageBox::Yes)
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Missing Project File");
|
||||
msgBox.setInformativeText(text.c_str());
|
||||
QAbstractButton* yesButton = msgBox.addButton("Delete", QMessageBox::ButtonRole::YesRole);
|
||||
QAbstractButton* noButton = msgBox.addButton("Keep", QMessageBox::ButtonRole::NoRole);
|
||||
msgBox.setIcon(QMessageBox::Icon::Question);
|
||||
int ret = msgBox.exec();
|
||||
|
||||
if (ret == 0) // QMessageBox::Yes)
|
||||
{
|
||||
std::vector<FilePath> recentProjects = ApplicationSettings::getInstance()->getRecentProjects();
|
||||
const int maxRecentProjectsCount = ApplicationSettings::getInstance()->getMaxRecentProjectsCount();
|
||||
|
||||
Reference in New Issue
Block a user