ui: new style for CodeView
@@ -1,62 +1,105 @@
|
|||||||
#code_file #title_label {
|
#code_file_list {
|
||||||
background-color: rgb(220,220,220);
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
#code_file {
|
||||||
|
background-color: white;
|
||||||
|
border: 2px solid #E0E0E0;
|
||||||
|
border-radius: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#code_file #title_widget {
|
||||||
|
background-color: #E0E0E0;
|
||||||
|
border-top-left-radius: 10px;
|
||||||
border-top-right-radius: 10px;
|
border-top-right-radius: 10px;
|
||||||
font-family: "Source Code Pro";
|
margin-bottom: 5px;
|
||||||
|
min-height: 28px;
|
||||||
|
padding-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#code_file #title_label {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
border-radius: 3px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
padding: 4px 12px;
|
padding: 2px 4px;
|
||||||
|
margin: 2px 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#code_file #title_label:hover {
|
#code_file #title_label:hover {
|
||||||
background: #D2D2D2;
|
background-color: #D0D0D0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#code_file #title_label:disabled {
|
#code_file #title_label:disabled {
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
#code_file #code_snippet #title_label {
|
#code_file #code_snippet{
|
||||||
background-color: rgb(220,220,220);
|
border-top: 2px solid #E0E0E0;
|
||||||
|
padding-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#code_file #code_snippet[isFirst=true] {
|
||||||
|
border: none;
|
||||||
|
padding-top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#code_file #code_snippet #scope_name, #code_file #code_snippet #dots {
|
||||||
|
background: none;
|
||||||
|
color: gray;
|
||||||
|
border: none;
|
||||||
font-family: "Source Code Pro";
|
font-family: "Source Code Pro";
|
||||||
border-top-right-radius: 10px;
|
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
text-align: left;
|
}
|
||||||
padding: 4px 12px;
|
|
||||||
|
#code_file #code_snippet #dots {
|
||||||
|
padding-right: 13px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
#code_file #code_snippet #scope_name {
|
||||||
|
padding-left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#code_area {
|
#code_area {
|
||||||
|
background-color: transparent;
|
||||||
font-family: "Source Code Pro";
|
font-family: "Source Code Pro";
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin-bottom: 2px;
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#code_area #line_number_area {
|
#code_area #line_number_area {
|
||||||
background-color: white;
|
|
||||||
font-family: "Source Code Pro";
|
font-family: "Source Code Pro";
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#code_file #maximize_button {
|
#code_file #maximize_button, #code_file #snippet_button, #code_file #minimize_button {
|
||||||
background-color: lightgray;
|
margin: 3px;
|
||||||
border-image: none;
|
|
||||||
border-radius: 8px;
|
|
||||||
margin: 1px;
|
|
||||||
max-height: 16px;
|
max-height: 16px;
|
||||||
max-width: 16px;
|
max-width: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#code_file #maximize_button {
|
||||||
|
border-image: url(data/gui/code_view/images/maximize_inactive.png);
|
||||||
|
}
|
||||||
|
|
||||||
#code_file #maximize_button:enabled {
|
#code_file #maximize_button:enabled {
|
||||||
border-image: url(data/gui/code_view/images/button_maximize.png);
|
border-image: url(data/gui/code_view/images/maximize_active.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
#code_area #maximize_button {
|
#code_file #snippet_button {
|
||||||
background-color: none;
|
border-image: url(data/gui/code_view/images/snippet_inactive.png);
|
||||||
border-image: none;
|
|
||||||
margin: 5px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#code_area #maximize_button:enabled {
|
#code_file #snippet_button:enabled {
|
||||||
border-image: url(data/gui/code_view/images/button_maximize.png);
|
border-image: url(data/gui/code_view/images/snippet_active.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
#code_file #minimize_button {
|
||||||
|
border-image: url(data/gui/code_view/images/minimize_inactive.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
#code_file #minimize_button:enabled {
|
||||||
|
border-image: url(data/gui/code_view/images/minimize_active.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
QToolTip {
|
QToolTip {
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 30 KiB |
@@ -49,7 +49,6 @@ QtCodeArea::QtCodeArea(
|
|||||||
)
|
)
|
||||||
: QPlainTextEdit(parent)
|
: QPlainTextEdit(parent)
|
||||||
, m_fileWidget(file)
|
, m_fileWidget(file)
|
||||||
, m_maximizeButton(nullptr)
|
|
||||||
, m_startLineNumber(startLineNumber)
|
, m_startLineNumber(startLineNumber)
|
||||||
, m_hoveredAnnotation(nullptr)
|
, m_hoveredAnnotation(nullptr)
|
||||||
, m_digits(0)
|
, m_digits(0)
|
||||||
@@ -91,27 +90,10 @@ QtCodeArea::~QtCodeArea()
|
|||||||
QSize QtCodeArea::sizeHint() const
|
QSize QtCodeArea::sizeHint() const
|
||||||
{
|
{
|
||||||
int width = 480;
|
int width = 480;
|
||||||
int height = (document()->size().height() + 0.7f) * fontMetrics().lineSpacing();
|
int height = (document()->size().height() + 0.7f) * fontMetrics().lineSpacing() - 3;
|
||||||
return QSize(width, height);
|
return QSize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeArea::addMaximizeButton()
|
|
||||||
{
|
|
||||||
QHBoxLayout* layout = new QHBoxLayout();
|
|
||||||
layout->setMargin(0);
|
|
||||||
layout->setSpacing(0);
|
|
||||||
layout->setAlignment(Qt::AlignTop);
|
|
||||||
setLayout(layout);
|
|
||||||
|
|
||||||
m_maximizeButton = new QPushButton(this);
|
|
||||||
m_maximizeButton->setObjectName("maximize_button");
|
|
||||||
m_maximizeButton->setEnabled(false);
|
|
||||||
layout->addWidget(m_maximizeButton);
|
|
||||||
layout->setAlignment(m_maximizeButton, Qt::AlignRight);
|
|
||||||
|
|
||||||
connect(m_maximizeButton, SIGNAL(clicked()), this, SLOT(clickedMaximizeButton()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent *event)
|
void QtCodeArea::lineNumberAreaPaintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
QPainter painter(m_lineNumberArea);
|
QPainter painter(m_lineNumberArea);
|
||||||
@@ -185,7 +167,7 @@ void QtCodeArea::showEvent(QShowEvent* event)
|
|||||||
void QtCodeArea::paintEvent(QPaintEvent* event)
|
void QtCodeArea::paintEvent(QPaintEvent* event)
|
||||||
{
|
{
|
||||||
QPainter painter(viewport());
|
QPainter painter(viewport());
|
||||||
painter.fillRect(rect(), Qt::white);
|
// painter.fillRect(rect(), Qt::white);
|
||||||
|
|
||||||
QTextBlock block = firstVisibleBlock();
|
QTextBlock block = firstVisibleBlock();
|
||||||
int top = blockBoundingGeometry(block).translated(contentOffset()).top();
|
int top = blockBoundingGeometry(block).translated(contentOffset()).top();
|
||||||
@@ -216,19 +198,10 @@ void QtCodeArea::paintEvent(QPaintEvent* event)
|
|||||||
|
|
||||||
void QtCodeArea::enterEvent(QEvent* event)
|
void QtCodeArea::enterEvent(QEvent* event)
|
||||||
{
|
{
|
||||||
if (m_maximizeButton)
|
|
||||||
{
|
|
||||||
m_maximizeButton->setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeArea::leaveEvent(QEvent* event)
|
void QtCodeArea::leaveEvent(QEvent* event)
|
||||||
{
|
{
|
||||||
if (m_maximizeButton)
|
|
||||||
{
|
|
||||||
m_maximizeButton->setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
setHoveredAnnotation(nullptr);
|
setHoveredAnnotation(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +212,7 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
QTextCursor cursor = this->cursorForPosition(event->pos());
|
QTextCursor cursor = this->cursorForPosition(event->pos());
|
||||||
const Annotation* annotation = findAnnotationForPosition(cursor.position());
|
const Annotation* annotation = findAnnotationForPosition(cursor.position());
|
||||||
|
|
||||||
if (annotation)
|
if (annotation && !annotation->isScope)
|
||||||
{
|
{
|
||||||
MessageActivateTokenLocation(annotation->locationId).dispatch();
|
MessageActivateTokenLocation(annotation->locationId).dispatch();
|
||||||
}
|
}
|
||||||
@@ -248,9 +221,9 @@ void QtCodeArea::mouseReleaseEvent(QMouseEvent* event)
|
|||||||
|
|
||||||
void QtCodeArea::mouseDoubleClickEvent(QMouseEvent* event)
|
void QtCodeArea::mouseDoubleClickEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
if (event->button() == Qt::LeftButton && m_maximizeButton)
|
if (event->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
clickedMaximizeButton();
|
MessageShowFile(m_fileWidget->getFilePath().absoluteStr(), m_startLineNumber, m_startLineNumber + blockCount() - 1).dispatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,11 +276,6 @@ void QtCodeArea::updateLineNumberArea(const QRect &rect, int dy)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeArea::clickedMaximizeButton()
|
|
||||||
{
|
|
||||||
MessageShowFile(m_fileWidget->getFilePath().absoluteStr(), m_startLineNumber, m_startLineNumber + blockCount() - 1).dispatch();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtCodeArea::clearSelection()
|
void QtCodeArea::clearSelection()
|
||||||
{
|
{
|
||||||
QTextCursor cursor = textCursor();
|
QTextCursor cursor = textCursor();
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
#include "utility/types.h"
|
#include "utility/types.h"
|
||||||
|
|
||||||
class QPaintEvent;
|
class QPaintEvent;
|
||||||
class QPushButton;
|
|
||||||
class QResizeEvent;
|
class QResizeEvent;
|
||||||
class QSize;
|
class QSize;
|
||||||
class QtCodeFile;
|
class QtCodeFile;
|
||||||
@@ -19,12 +18,14 @@ class QWidget;
|
|||||||
class TokenLocation;
|
class TokenLocation;
|
||||||
class TokenLocationFile;
|
class TokenLocationFile;
|
||||||
|
|
||||||
class QtCodeArea: public QPlainTextEdit
|
class QtCodeArea
|
||||||
|
: public QPlainTextEdit
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class LineNumberArea: public QWidget
|
class LineNumberArea
|
||||||
|
: public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LineNumberArea(QtCodeArea *codeArea);
|
LineNumberArea(QtCodeArea *codeArea);
|
||||||
@@ -50,8 +51,6 @@ public:
|
|||||||
|
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
|
|
||||||
void addMaximizeButton();
|
|
||||||
|
|
||||||
void lineNumberAreaPaintEvent(QPaintEvent *event);
|
void lineNumberAreaPaintEvent(QPaintEvent *event);
|
||||||
int lineNumberDigits() const;
|
int lineNumberDigits() const;
|
||||||
int lineNumberAreaWidth() const;
|
int lineNumberAreaWidth() const;
|
||||||
@@ -72,7 +71,6 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
void updateLineNumberAreaWidth(int newBlockCount);
|
void updateLineNumberAreaWidth(int newBlockCount);
|
||||||
void updateLineNumberArea(const QRect &, int);
|
void updateLineNumberArea(const QRect &, int);
|
||||||
void clickedMaximizeButton();
|
|
||||||
void clearSelection();
|
void clearSelection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -113,8 +111,6 @@ private:
|
|||||||
QWidget* m_lineNumberArea;
|
QWidget* m_lineNumberArea;
|
||||||
QtHighlighter* m_highlighter;
|
QtHighlighter* m_highlighter;
|
||||||
|
|
||||||
QPushButton* m_maximizeButton;
|
|
||||||
|
|
||||||
const uint m_startLineNumber;
|
const uint m_startLineNumber;
|
||||||
|
|
||||||
std::vector<Annotation> m_annotations;
|
std::vector<Annotation> m_annotations;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include "qt/element/QtCodeSnippet.h"
|
#include "qt/element/QtCodeSnippet.h"
|
||||||
|
|
||||||
QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeFileList* parent)
|
QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeFileList* parent)
|
||||||
: QWidget(parent)
|
: QFrame(parent)
|
||||||
, m_parent(parent)
|
, m_parent(parent)
|
||||||
, m_filePath(filePath)
|
, m_filePath(filePath)
|
||||||
{
|
{
|
||||||
@@ -23,11 +23,15 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeFileList* parent)
|
|||||||
layout->setAlignment(Qt::AlignTop);
|
layout->setAlignment(Qt::AlignTop);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
|
QFrame* titleWidget = new QFrame(this);
|
||||||
|
titleWidget->setObjectName("title_widget");
|
||||||
|
layout->addWidget(titleWidget);
|
||||||
|
|
||||||
QHBoxLayout* titleLayout = new QHBoxLayout();
|
QHBoxLayout* titleLayout = new QHBoxLayout();
|
||||||
titleLayout->setMargin(0);
|
titleLayout->setMargin(0);
|
||||||
titleLayout->setSpacing(0);
|
titleLayout->setSpacing(0);
|
||||||
titleLayout->setAlignment(Qt::AlignLeft);
|
titleLayout->setAlignment(Qt::AlignLeft);
|
||||||
layout->addLayout(titleLayout);
|
titleWidget->setLayout(titleLayout);
|
||||||
|
|
||||||
m_title = new QPushButton(filePath.fileName().c_str(), this);
|
m_title = new QPushButton(filePath.fileName().c_str(), this);
|
||||||
m_title->setObjectName("title_label");
|
m_title->setObjectName("title_label");
|
||||||
@@ -41,17 +45,20 @@ QtCodeFile::QtCodeFile(const FilePath& filePath, QtCodeFileList* parent)
|
|||||||
titleLayout->addStretch(3);
|
titleLayout->addStretch(3);
|
||||||
|
|
||||||
m_minimizeButton = new QPushButton(this);
|
m_minimizeButton = new QPushButton(this);
|
||||||
m_minimizeButton->setObjectName("maximize_button");
|
m_minimizeButton->setObjectName("minimize_button");
|
||||||
|
m_minimizeButton->setToolTip("minimize file");
|
||||||
m_minimizeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
m_minimizeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||||
titleLayout->addWidget(m_minimizeButton);
|
titleLayout->addWidget(m_minimizeButton);
|
||||||
|
|
||||||
m_snippetButton = new QPushButton(this);
|
m_snippetButton = new QPushButton(this);
|
||||||
m_snippetButton->setObjectName("maximize_button");
|
m_snippetButton->setObjectName("snippet_button");
|
||||||
|
m_snippetButton->setToolTip("show snippets in file");
|
||||||
m_snippetButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
m_snippetButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||||
titleLayout->addWidget(m_snippetButton);
|
titleLayout->addWidget(m_snippetButton);
|
||||||
|
|
||||||
m_maximizeButton = new QPushButton(this);
|
m_maximizeButton = new QPushButton(this);
|
||||||
m_maximizeButton->setObjectName("maximize_button");
|
m_maximizeButton->setObjectName("maximize_button");
|
||||||
|
m_maximizeButton->setToolTip("maximize file");
|
||||||
m_maximizeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
m_maximizeButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||||
titleLayout->addWidget(m_maximizeButton);
|
titleLayout->addWidget(m_maximizeButton);
|
||||||
|
|
||||||
@@ -109,6 +116,7 @@ void QtCodeFile::addCodeSnippet(
|
|||||||
|
|
||||||
if (locationFile->isWholeCopy)
|
if (locationFile->isWholeCopy)
|
||||||
{
|
{
|
||||||
|
snippet->setProperty("isFirst", true);
|
||||||
m_fileSnippet = snippet;
|
m_fileSnippet = snippet;
|
||||||
clickedMaximizeButton();
|
clickedMaximizeButton();
|
||||||
return;
|
return;
|
||||||
@@ -116,9 +124,9 @@ void QtCodeFile::addCodeSnippet(
|
|||||||
|
|
||||||
m_snippets.push_back(snippet);
|
m_snippets.push_back(snippet);
|
||||||
|
|
||||||
if (m_parent->getShowMaximizeButton())
|
if (m_snippets.size() == 1)
|
||||||
{
|
{
|
||||||
snippet->addMaximizeButton();
|
snippet->setProperty("isFirst", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxDigits = 1;
|
int maxDigits = 1;
|
||||||
@@ -146,8 +154,6 @@ void QtCodeFile::updateContent()
|
|||||||
{
|
{
|
||||||
m_fileSnippet->updateContent();
|
m_fileSnippet->updateContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_title->setEnabled(m_parent->getShowMaximizeButton());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeFile::clickedTitle()
|
void QtCodeFile::clickedTitle()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QFrame>
|
||||||
|
|
||||||
#include "utility/file/FilePath.h"
|
#include "utility/file/FilePath.h"
|
||||||
#include "utility/types.h"
|
#include "utility/types.h"
|
||||||
@@ -16,7 +16,7 @@ class QtCodeSnippet;
|
|||||||
class TokenLocationFile;
|
class TokenLocationFile;
|
||||||
|
|
||||||
class QtCodeFile
|
class QtCodeFile
|
||||||
: public QWidget
|
: public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|||||||
@@ -3,27 +3,26 @@
|
|||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include "utility/file/FileSystem.h"
|
||||||
|
|
||||||
#include "data/location/TokenLocationFile.h"
|
#include "data/location/TokenLocationFile.h"
|
||||||
#include "qt/element/QtCodeFile.h"
|
#include "qt/element/QtCodeFile.h"
|
||||||
#include "utility/file/FileSystem.h"
|
|
||||||
|
|
||||||
QtCodeFileList::QtCodeFileList(QWidget* parent)
|
QtCodeFileList::QtCodeFileList(QWidget* parent)
|
||||||
: QScrollArea(parent)
|
: QScrollArea(parent)
|
||||||
, m_focusedTokenId(0)
|
, m_focusedTokenId(0)
|
||||||
, m_showMaximizeButton(true)
|
|
||||||
{
|
{
|
||||||
m_frame = std::make_shared<QFrame>(this);
|
m_frame = std::make_shared<QFrame>(this);
|
||||||
|
m_frame->setObjectName("code_file_list");
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout(m_frame.get());
|
QVBoxLayout* layout = new QVBoxLayout(m_frame.get());
|
||||||
layout->setSpacing(10);
|
layout->setSpacing(8);
|
||||||
layout->setContentsMargins(15, 15, 15, 15);
|
layout->setContentsMargins(8, 8, 8, 8);
|
||||||
layout->setAlignment(Qt::AlignTop);
|
layout->setAlignment(Qt::AlignTop);
|
||||||
m_frame->setLayout(layout);
|
m_frame->setLayout(layout);
|
||||||
|
|
||||||
setWidgetResizable(true);
|
setWidgetResizable(true);
|
||||||
setWidget(m_frame.get());
|
setWidget(m_frame.get());
|
||||||
|
|
||||||
setObjectName("code_file_list");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QtCodeFileList::~QtCodeFileList()
|
QtCodeFileList::~QtCodeFileList()
|
||||||
@@ -98,17 +97,6 @@ void QtCodeFileList::setErrorMessages(const std::vector<std::string>& errorMessa
|
|||||||
updateFiles();
|
updateFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtCodeFileList::getShowMaximizeButton() const
|
|
||||||
{
|
|
||||||
return m_showMaximizeButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtCodeFileList::setShowMaximizeButton(bool show)
|
|
||||||
{
|
|
||||||
m_showMaximizeButton = show;
|
|
||||||
updateFiles();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtCodeFileList::updateFiles()
|
void QtCodeFileList::updateFiles()
|
||||||
{
|
{
|
||||||
for (std::shared_ptr<QtCodeFile> file: m_files)
|
for (std::shared_ptr<QtCodeFile> file: m_files)
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
class QtCodeFile;
|
class QtCodeFile;
|
||||||
class TokenLocationFile;
|
class TokenLocationFile;
|
||||||
|
|
||||||
class QtCodeFileList: public QScrollArea
|
class QtCodeFileList
|
||||||
|
: public QScrollArea
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -39,9 +40,6 @@ public:
|
|||||||
const std::vector<std::string>& getErrorMessages() const;
|
const std::vector<std::string>& getErrorMessages() const;
|
||||||
void setErrorMessages(const std::vector<std::string>& errorMessages);
|
void setErrorMessages(const std::vector<std::string>& errorMessages);
|
||||||
|
|
||||||
bool getShowMaximizeButton() const;
|
|
||||||
void setShowMaximizeButton(bool show);
|
|
||||||
|
|
||||||
void focusToken(Id tokenId);
|
void focusToken(Id tokenId);
|
||||||
void defocusToken();
|
void defocusToken();
|
||||||
|
|
||||||
@@ -54,7 +52,6 @@ private:
|
|||||||
Id m_focusedTokenId;
|
Id m_focusedTokenId;
|
||||||
std::vector<Id> m_activeTokenIds;
|
std::vector<Id> m_activeTokenIds;
|
||||||
std::vector<std::string> m_errorMessages;
|
std::vector<std::string> m_errorMessages;
|
||||||
bool m_showMaximizeButton;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QT_CODE_FILE_LIST
|
#endif // QT_CODE_FILE_LIST
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include "qt/element/QtCodeSnippet.h"
|
#include "qt/element/QtCodeSnippet.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QBoxLayout>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
#include "qt/element/QtCodeFile.h"
|
#include "qt/element/QtCodeFile.h"
|
||||||
@@ -12,7 +12,9 @@ QtCodeSnippet::QtCodeSnippet(
|
|||||||
std::shared_ptr<TokenLocationFile> locationFile,
|
std::shared_ptr<TokenLocationFile> locationFile,
|
||||||
QtCodeFile* file
|
QtCodeFile* file
|
||||||
)
|
)
|
||||||
: QWidget(file)
|
: QFrame(file)
|
||||||
|
, m_dots(nullptr)
|
||||||
|
, m_title(nullptr)
|
||||||
, m_codeArea(std::make_shared<QtCodeArea>(startLineNumber, code, locationFile, file, this))
|
, m_codeArea(std::make_shared<QtCodeArea>(startLineNumber, code, locationFile, file, this))
|
||||||
{
|
{
|
||||||
setObjectName("code_snippet");
|
setObjectName("code_snippet");
|
||||||
@@ -23,25 +25,35 @@ QtCodeSnippet::QtCodeSnippet(
|
|||||||
layout->setAlignment(Qt::AlignTop);
|
layout->setAlignment(Qt::AlignTop);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
m_title = new QPushButton(title.c_str(), this);
|
if (title.size())
|
||||||
m_title->setObjectName("title_label");
|
{
|
||||||
m_title->minimumSizeHint(); // force font loading
|
QHBoxLayout* titleLayout = new QHBoxLayout();
|
||||||
m_title->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
titleLayout->setMargin(0);
|
||||||
m_title->setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
|
titleLayout->setSpacing(0);
|
||||||
layout->addWidget(m_title);
|
titleLayout->setAlignment(Qt::AlignLeft);
|
||||||
|
layout->addLayout(titleLayout);
|
||||||
|
|
||||||
|
m_dots = new QPushButton(this);
|
||||||
|
m_dots->setObjectName("dots");
|
||||||
|
m_dots->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||||
|
titleLayout->addWidget(m_dots);
|
||||||
|
|
||||||
|
m_title = new QPushButton(title.c_str(), this);
|
||||||
|
m_title->setObjectName("scope_name");
|
||||||
|
m_title->minimumSizeHint(); // force font loading
|
||||||
|
m_title->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
|
||||||
|
m_title->setSizePolicy(sizePolicy().horizontalPolicy(), QSizePolicy::Fixed);
|
||||||
|
titleLayout->addWidget(m_title);
|
||||||
|
}
|
||||||
|
|
||||||
layout->addWidget(m_codeArea.get());
|
layout->addWidget(m_codeArea.get());
|
||||||
|
updateDots();
|
||||||
}
|
}
|
||||||
|
|
||||||
QtCodeSnippet::~QtCodeSnippet()
|
QtCodeSnippet::~QtCodeSnippet()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeSnippet::addMaximizeButton()
|
|
||||||
{
|
|
||||||
m_codeArea->addMaximizeButton();
|
|
||||||
}
|
|
||||||
|
|
||||||
int QtCodeSnippet::lineNumberDigits() const
|
int QtCodeSnippet::lineNumberDigits() const
|
||||||
{
|
{
|
||||||
return m_codeArea->lineNumberDigits();
|
return m_codeArea->lineNumberDigits();
|
||||||
@@ -50,9 +62,22 @@ int QtCodeSnippet::lineNumberDigits() const
|
|||||||
void QtCodeSnippet::updateLineNumberAreaWidthForDigits(int digits)
|
void QtCodeSnippet::updateLineNumberAreaWidthForDigits(int digits)
|
||||||
{
|
{
|
||||||
m_codeArea->updateLineNumberAreaWidthForDigits(digits);
|
m_codeArea->updateLineNumberAreaWidthForDigits(digits);
|
||||||
|
updateDots();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtCodeSnippet::updateContent()
|
void QtCodeSnippet::updateContent()
|
||||||
{
|
{
|
||||||
m_codeArea->updateContent();
|
m_codeArea->updateContent();
|
||||||
|
updateDots();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QtCodeSnippet::updateDots()
|
||||||
|
{
|
||||||
|
if (!m_dots)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_dots->setText(QString::fromStdString(std::string(lineNumberDigits(), '.')));
|
||||||
|
m_dots->setMinimumWidth(m_codeArea->lineNumberAreaWidth());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,18 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QFrame>
|
||||||
|
|
||||||
#include "utility/types.h"
|
#include "utility/types.h"
|
||||||
|
|
||||||
#include "qt/element/QtCodeArea.h"
|
#include "qt/element/QtCodeArea.h"
|
||||||
|
|
||||||
|
class QPushButton;
|
||||||
class QtCodeFile;
|
class QtCodeFile;
|
||||||
class QWidget;
|
|
||||||
class TokenLocationFile;
|
class TokenLocationFile;
|
||||||
|
|
||||||
class QtCodeSnippet: public QWidget
|
class QtCodeSnippet
|
||||||
|
: public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -25,14 +29,15 @@ public:
|
|||||||
);
|
);
|
||||||
virtual ~QtCodeSnippet();
|
virtual ~QtCodeSnippet();
|
||||||
|
|
||||||
void addMaximizeButton();
|
|
||||||
|
|
||||||
int lineNumberDigits() const;
|
int lineNumberDigits() const;
|
||||||
|
|
||||||
void updateLineNumberAreaWidthForDigits(int digits);
|
void updateLineNumberAreaWidthForDigits(int digits);
|
||||||
void updateContent();
|
void updateContent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateDots();
|
||||||
|
|
||||||
|
QPushButton* m_dots;
|
||||||
QPushButton* m_title;
|
QPushButton* m_title;
|
||||||
std::shared_ptr<QtCodeArea> m_codeArea;
|
std::shared_ptr<QtCodeArea> m_codeArea;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#include "qt/view/QtCodeView.h"
|
#include "qt/view/QtCodeView.h"
|
||||||
|
|
||||||
|
#include "utility/file/FileSystem.h"
|
||||||
|
#include "utility/text/TextAccess.h"
|
||||||
|
|
||||||
#include "qt/element/QtCodeFileList.h"
|
#include "qt/element/QtCodeFileList.h"
|
||||||
#include "qt/view/QtViewWidgetWrapper.h"
|
#include "qt/view/QtViewWidgetWrapper.h"
|
||||||
#include "utility/file/FileSystem.h"
|
|
||||||
#include "utility/text/TextAccess.h"
|
|
||||||
|
|
||||||
QtCodeView::QtCodeView(ViewLayout* viewLayout)
|
QtCodeView::QtCodeView(ViewLayout* viewLayout)
|
||||||
: CodeView(viewLayout)
|
: CodeView(viewLayout)
|
||||||
@@ -66,7 +67,6 @@ void QtCodeView::doShowCodeSnippets(const std::vector<CodeSnippetParams>& snippe
|
|||||||
|
|
||||||
m_widget->setActiveTokenIds(m_activeTokenIds);
|
m_widget->setActiveTokenIds(m_activeTokenIds);
|
||||||
m_widget->setErrorMessages(m_errorMessages);
|
m_widget->setErrorMessages(m_errorMessages);
|
||||||
m_widget->setShowMaximizeButton(m_errorMessages.size() == 0);
|
|
||||||
|
|
||||||
for (const CodeSnippetParams& params : snippets)
|
for (const CodeSnippetParams& params : snippets)
|
||||||
{
|
{
|
||||||
@@ -79,18 +79,6 @@ void QtCodeView::doShowCodeFile(const CodeSnippetParams& params)
|
|||||||
m_widget->addCodeSnippet(1, params.title, params.code, params.locationFile);
|
m_widget->addCodeSnippet(1, params.title, params.code, params.locationFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<QtCodeFileList> QtCodeView::createQtCodeFileList() const
|
|
||||||
{
|
|
||||||
std::shared_ptr<QtCodeFileList> ptr = std::make_shared<QtCodeFileList>();
|
|
||||||
setStyleSheet(ptr.get());
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtCodeView::setStyleSheet(QWidget* widget) const
|
|
||||||
{
|
|
||||||
widget->setStyleSheet(TextAccess::createFromFile("data/gui/code_view/code_view.css")->getText().c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
void QtCodeView::focusToken(const Id tokenId)
|
void QtCodeView::focusToken(const Id tokenId)
|
||||||
{
|
{
|
||||||
m_focusTokenFunctor(tokenId);
|
m_focusTokenFunctor(tokenId);
|
||||||
@@ -110,3 +98,8 @@ void QtCodeView::doDefocusToken()
|
|||||||
{
|
{
|
||||||
m_widget->defocusToken();
|
m_widget->defocusToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtCodeView::setStyleSheet(QWidget* widget) const
|
||||||
|
{
|
||||||
|
widget->setStyleSheet(TextAccess::createFromFile("data/gui/code_view/code_view.css")->getText().c_str());
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,15 +4,17 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "utility/types.h"
|
||||||
|
|
||||||
#include "component/view/CodeView.h"
|
#include "component/view/CodeView.h"
|
||||||
#include "qt/utility/QtThreadedFunctor.h"
|
#include "qt/utility/QtThreadedFunctor.h"
|
||||||
#include "utility/types.h"
|
|
||||||
|
|
||||||
class QFrame;
|
class QFrame;
|
||||||
class QtCodeFileList;
|
class QtCodeFileList;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
class QtCodeView: public CodeView
|
class QtCodeView
|
||||||
|
: public CodeView
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QtCodeView(ViewLayout* viewLayout);
|
QtCodeView(ViewLayout* viewLayout);
|
||||||
@@ -35,13 +37,13 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void doRefreshView();
|
void doRefreshView();
|
||||||
|
|
||||||
void doShowCodeSnippets(const std::vector<CodeSnippetParams>& snippets);
|
void doShowCodeSnippets(const std::vector<CodeSnippetParams>& snippets);
|
||||||
void doShowCodeFile(const CodeSnippetParams& params);
|
void doShowCodeFile(const CodeSnippetParams& params);
|
||||||
|
|
||||||
void doFocusToken(const Id tokenId);
|
void doFocusToken(const Id tokenId);
|
||||||
void doDefocusToken();
|
void doDefocusToken();
|
||||||
|
|
||||||
std::shared_ptr<QtCodeFileList> createQtCodeFileList() const;
|
|
||||||
|
|
||||||
void setStyleSheet(QWidget* widget) const;
|
void setStyleSheet(QWidget* widget) const;
|
||||||
|
|
||||||
QtThreadedFunctor<> m_refreshViewFunctor;
|
QtThreadedFunctor<> m_refreshViewFunctor;
|
||||||
|
|||||||