ui: Styled code navigation
* Defined final icons and colors for code navigation buttons * Added disabled color for all buttons in search and code navigation UI
This commit is contained in:
@@ -22,7 +22,7 @@ QtCodeFileSingle::QtCodeFileSingle(QtCodeNavigator* navigator, QWidget* parent)
|
||||
, m_area(nullptr)
|
||||
, m_contentRequested(false)
|
||||
{
|
||||
setObjectName("code_container_single");
|
||||
setObjectName("code_container");
|
||||
|
||||
setLayout(new QVBoxLayout(this));
|
||||
layout()->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
@@ -33,7 +33,7 @@ void QtCodeFileTitleButton::setFilePath(const FilePath& filePath)
|
||||
setText(filePath.fileName().c_str());
|
||||
setToolTip(filePath.str().c_str());
|
||||
|
||||
std::string text = ResourcePaths::getGuiPath() + "graph_view/images/file.png";
|
||||
std::string text = ResourcePaths::getGuiPath() + "code_view/images/file.png";
|
||||
|
||||
setIcon(utility::colorizePixmap(
|
||||
QPixmap(text.c_str()),
|
||||
|
||||
@@ -7,18 +7,21 @@
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "data/location/TokenLocation.h"
|
||||
#include "data/location/TokenLocationCollection.h"
|
||||
#include "data/location/TokenLocationFile.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageCodeViewExpandedInitialFiles.h"
|
||||
#include "utility/messaging/type/MessageScrollCode.h"
|
||||
#include "utility/messaging/type/MessageShowReference.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "data/location/TokenLocation.h"
|
||||
#include "data/location/TokenLocationCollection.h"
|
||||
#include "data/location/TokenLocationFile.h"
|
||||
#include "qt/element/QtCodeFile.h"
|
||||
#include "qt/element/QtCodeSnippet.h"
|
||||
#include "qt/utility/QtDeviceScaledPixmap.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
|
||||
QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
@@ -39,11 +42,11 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
|
||||
QHBoxLayout* navLayout = new QHBoxLayout();
|
||||
navLayout->setSpacing(2);
|
||||
navLayout->setContentsMargins(7, 7, 7, 7);
|
||||
navLayout->setContentsMargins(7, 7, 7, 6);
|
||||
|
||||
|
||||
m_prevButton = new QPushButton("<");
|
||||
m_nextButton = new QPushButton(">");
|
||||
m_prevButton = new QPushButton();
|
||||
m_nextButton = new QPushButton();
|
||||
|
||||
m_prevButton->setObjectName("reference_button_previous");
|
||||
m_nextButton->setObjectName("reference_button_next");
|
||||
@@ -65,12 +68,15 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
navLayout->addStretch();
|
||||
|
||||
|
||||
m_listButton = new QPushButton("list");
|
||||
m_fileButton = new QPushButton("file");
|
||||
m_listButton = new QPushButton();
|
||||
m_fileButton = new QPushButton();
|
||||
|
||||
m_listButton->setObjectName("mode_button_list");
|
||||
m_fileButton->setObjectName("mode_button_single");
|
||||
|
||||
m_listButton->setToolTip("snippet list mode");
|
||||
m_fileButton->setToolTip("single file mode");
|
||||
|
||||
m_listButton->setCheckable(true);
|
||||
m_fileButton->setCheckable(true);
|
||||
|
||||
@@ -83,6 +89,30 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
|
||||
navigation->setLayout(navLayout);
|
||||
layout->addWidget(navigation);
|
||||
|
||||
refreshStyle();
|
||||
|
||||
QHBoxLayout* separatorLayout = new QHBoxLayout();
|
||||
|
||||
QWidget* widget = new QWidget();
|
||||
widget->setObjectName("separator_gap");
|
||||
widget->setFixedWidth(7);
|
||||
separatorLayout->addWidget(widget);
|
||||
|
||||
m_separatorLine = new QFrame();
|
||||
m_separatorLine->setFrameShape(QFrame::HLine);
|
||||
m_separatorLine->setFrameShadow(QFrame::Plain);
|
||||
m_separatorLine->setObjectName("separator_line");
|
||||
m_separatorLine->setFixedHeight(1);
|
||||
m_separatorLine->hide();
|
||||
separatorLayout->addWidget(m_separatorLine);
|
||||
|
||||
QWidget* widget2 = new QWidget();
|
||||
widget2->setObjectName("separator_gap");
|
||||
widget2->setFixedWidth(7);
|
||||
separatorLayout->addWidget(widget2);
|
||||
|
||||
layout->addLayout(separatorLayout);
|
||||
}
|
||||
|
||||
m_list = new QtCodeFileList(this);
|
||||
@@ -435,6 +465,41 @@ void QtCodeNavigator::showContents()
|
||||
m_current->showContents();
|
||||
}
|
||||
|
||||
void QtCodeNavigator::refreshStyle()
|
||||
{
|
||||
float height = std::max(ApplicationSettings::getInstance()->getFontSize() + 10, 24);
|
||||
|
||||
m_prevButton->setFixedHeight(height);
|
||||
m_nextButton->setFixedHeight(height);
|
||||
m_listButton->setFixedHeight(height);
|
||||
m_fileButton->setFixedHeight(height);
|
||||
|
||||
m_prevButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "code_view/images/arrow_left.png",
|
||||
"code/navigation/button"
|
||||
));
|
||||
|
||||
m_nextButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "code_view/images/arrow_right.png",
|
||||
"code/navigation/button"
|
||||
));
|
||||
|
||||
m_listButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "code_view/images/list.png",
|
||||
"code/navigation/button"
|
||||
));
|
||||
|
||||
m_fileButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "code_view/images/file.png",
|
||||
"code/navigation/button"
|
||||
));
|
||||
|
||||
m_prevButton->setIconSize(QSize(12, 12));
|
||||
m_nextButton->setIconSize(QSize(12, 12));
|
||||
m_listButton->setIconSize(QSize(14, 14));
|
||||
m_fileButton->setIconSize(QSize(14, 14));
|
||||
}
|
||||
|
||||
void QtCodeNavigator::scrollToValue(int value, bool inListMode)
|
||||
{
|
||||
if ((m_mode == MODE_LIST) == inListMode)
|
||||
@@ -623,11 +688,13 @@ void QtCodeNavigator::setMode(Mode mode)
|
||||
case MODE_SINGLE:
|
||||
m_list->hide();
|
||||
m_single->show();
|
||||
m_separatorLine->hide();
|
||||
m_current = m_single;
|
||||
break;
|
||||
case MODE_LIST:
|
||||
m_single->hide();
|
||||
m_list->show();
|
||||
m_separatorLine->show();
|
||||
m_current = m_list;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -75,6 +75,8 @@ public:
|
||||
void updateFiles();
|
||||
void showContents();
|
||||
|
||||
void refreshStyle();
|
||||
|
||||
void scrollToValue(int value, bool inListMode);
|
||||
void scrollToLine(const FilePath& filePath, unsigned int line);
|
||||
void scrollToDefinition();
|
||||
@@ -170,6 +172,7 @@ private:
|
||||
QLabel* m_refLabel;
|
||||
QPushButton* m_prevButton;
|
||||
QPushButton* m_nextButton;
|
||||
QFrame* m_separatorLine;
|
||||
|
||||
std::vector<Reference> m_references;
|
||||
size_t m_refIndex;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QtRefreshBar::QtRefreshBar()
|
||||
{
|
||||
@@ -49,10 +48,9 @@ void QtRefreshBar::refreshStyle()
|
||||
|
||||
m_refreshButton->setFixedHeight(height);
|
||||
|
||||
std::string map = ResourcePaths::getGuiPath() + "refresh_view/images/refresh.png";
|
||||
m_refreshButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap(map.c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
m_refreshButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "refresh_view/images/refresh.png",
|
||||
"search/button"
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "qt/element/QtSmartSearchBox.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QtSearchBar::QtSearchBar()
|
||||
{
|
||||
@@ -102,16 +101,14 @@ void QtSearchBar::refreshStyle()
|
||||
m_searchButton->setFixedHeight(m_searchBox->height() + 5);
|
||||
m_homeButton->setFixedHeight(m_searchBox->height() + 5);
|
||||
|
||||
std::string map = ResourcePaths::getGuiPath() + "search_view/images/search.png";
|
||||
m_searchButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap(map.c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
m_searchButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "search_view/images/search.png",
|
||||
"search/button"
|
||||
));
|
||||
|
||||
map = ResourcePaths::getGuiPath() + "search_view/images/home.png";
|
||||
m_homeButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap(map.c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
m_homeButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "search_view/images/home.png",
|
||||
"search/button"
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QtUndoRedo::QtUndoRedo()
|
||||
{
|
||||
@@ -72,13 +71,13 @@ void QtUndoRedo::refreshStyle()
|
||||
m_undoButton->setFixedHeight(height);
|
||||
m_redoButton->setFixedHeight(height);
|
||||
|
||||
m_undoButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap((ResourcePaths::getGuiPath() + "undoredo_view/images/arrow_left.png").c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
m_undoButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "undoredo_view/images/arrow_left.png",
|
||||
"search/button"
|
||||
));
|
||||
|
||||
m_redoButton->setIcon(utility::colorizePixmap(
|
||||
QPixmap((ResourcePaths::getGuiPath() + "undoredo_view/images/arrow_right.png").c_str()),
|
||||
ColorScheme::getInstance()->getColor("search/button/icon").c_str()
|
||||
m_redoButton->setIcon(utility::createButtonIcon(
|
||||
ResourcePaths::getGuiPath() + "undoredo_view/images/arrow_right.png",
|
||||
"search/button"
|
||||
));
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFontDatabase>
|
||||
#include <QIcon>
|
||||
#include <QPainter>
|
||||
#include <QWidget>
|
||||
|
||||
@@ -157,6 +158,19 @@ namespace utility
|
||||
return QPixmap::fromImage(image);
|
||||
}
|
||||
|
||||
QIcon createButtonIcon(const std::string& iconPath, const std::string& colorId)
|
||||
{
|
||||
QPixmap pixmap(iconPath.c_str());
|
||||
|
||||
QIcon icon(utility::colorizePixmap(pixmap, ColorScheme::getInstance()->getColor(colorId + "/icon").c_str()));
|
||||
icon.addPixmap(
|
||||
utility::colorizePixmap(pixmap, ColorScheme::getInstance()->getColor(colorId + "/icon_disabled").c_str()),
|
||||
QIcon::Disabled
|
||||
);
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
void copyNewFilesFromDirectory(QString src, QString dst)
|
||||
{
|
||||
QDir dir(src);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <string>
|
||||
|
||||
class QColor;
|
||||
class QIcon;
|
||||
class QPixmap;
|
||||
class QString;
|
||||
class QWidget;
|
||||
@@ -16,6 +17,7 @@ namespace utility
|
||||
std::string getStyleSheet(const std::string& path);
|
||||
|
||||
QPixmap colorizePixmap(const QPixmap& pixmap, QColor color);
|
||||
QIcon createButtonIcon(const std::string& iconPath, const std::string& colorId);
|
||||
|
||||
void copyNewFilesFromDirectory(QString src, QString dst);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ void QtCodeView::refreshView()
|
||||
{
|
||||
setStyleSheet();
|
||||
|
||||
m_widget->refreshStyle();
|
||||
|
||||
QtCodeArea::clearAnnotationColors();
|
||||
QtHighlighter::clearHighlightingRules();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user