class browser color ok
This commit is contained in:
parent
dc807f527c
commit
3a6097c40f
|
@ -715,7 +715,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
|
||||||
kind = StatementKind::skVariable;
|
kind = StatementKind::skVariable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreground = mCompletionPopup->colors().value(kind,
|
foreground = mCompletionPopup->colors()->value(kind,
|
||||||
highlighter()->identifierAttribute()->foreground());
|
highlighter()->identifierAttribute()->foreground());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3020,59 +3020,6 @@ void Editor::applyColorScheme(const QString& schemeName)
|
||||||
this->mBreakpointForegroundColor = item->foreground();
|
this->mBreakpointForegroundColor = item->foreground();
|
||||||
this->mBreakpointBackgroundColor = item->background();
|
this->mBreakpointBackgroundColor = item->background();
|
||||||
}
|
}
|
||||||
//color for code completion popup
|
|
||||||
if (mCompletionPopup) {
|
|
||||||
item = pColorManager->getItem(schemeName, SYNS_AttrFunction);
|
|
||||||
if (item) {
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skFunction,item->foreground());
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skConstructor,item->foreground());
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skDestructor,item->foreground());
|
|
||||||
}
|
|
||||||
item = pColorManager->getItem(schemeName, SYNS_AttrClass);
|
|
||||||
if (item) {
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skClass,item->foreground());
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skTypedef,item->foreground());
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skAlias,item->foreground());
|
|
||||||
}
|
|
||||||
item = pColorManager->getItem(schemeName, SYNS_AttrIdentifier);
|
|
||||||
if (item) {
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skEnumType,item->foreground());
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skEnumClassType,item->foreground());
|
|
||||||
}
|
|
||||||
item = pColorManager->getItem(schemeName, SYNS_AttrVariable);
|
|
||||||
if (item) {
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skVariable,item->foreground());
|
|
||||||
}
|
|
||||||
item = pColorManager->getItem(schemeName, SYNS_AttrLocalVariable);
|
|
||||||
if (item) {
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skLocalVariable,item->foreground());
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skParameter,item->foreground());
|
|
||||||
}
|
|
||||||
item = pColorManager->getItem(schemeName, SYNS_AttrGlobalVariable);
|
|
||||||
if (item) {
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skGlobalVariable,item->foreground());
|
|
||||||
}
|
|
||||||
item = pColorManager->getItem(schemeName, SYNS_AttrGlobalVariable);
|
|
||||||
if (item) {
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skGlobalVariable,item->foreground());
|
|
||||||
}
|
|
||||||
item = pColorManager->getItem(schemeName, SYNS_AttrPreprocessor);
|
|
||||||
if (item) {
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skPreprocessor,item->foreground());
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skEnum,item->foreground());
|
|
||||||
mHeaderCompletionPopup->setSuggestionColor(item->foreground());
|
|
||||||
}
|
|
||||||
item = pColorManager->getItem(schemeName, SYNS_AttrReservedWord);
|
|
||||||
if (item) {
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skKeyword,item->foreground());
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skUserCodeIn,item->foreground());
|
|
||||||
}
|
|
||||||
item = pColorManager->getItem(schemeName, SYNS_AttrString);
|
|
||||||
if (item) {
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skNamespace,item->foreground());
|
|
||||||
mCompletionPopup->colors().insert(StatementKind::skNamespaceAlias,item->foreground());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this->invalidate();
|
this->invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,10 +147,13 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
connect(&mFileSystemWatcher,&QFileSystemWatcher::fileChanged,
|
connect(&mFileSystemWatcher,&QFileSystemWatcher::fileChanged,
|
||||||
this, &MainWindow::onFileChanged);
|
this, &MainWindow::onFileChanged);
|
||||||
|
|
||||||
|
mStatementColors = std::make_shared<QHash<StatementKind, QColor> >();
|
||||||
mCompletionPopup = std::make_shared<CodeCompletionPopup>();
|
mCompletionPopup = std::make_shared<CodeCompletionPopup>();
|
||||||
|
mCompletionPopup->setColors(mStatementColors);
|
||||||
mHeaderCompletionPopup = std::make_shared<HeaderCompletionPopup>();
|
mHeaderCompletionPopup = std::make_shared<HeaderCompletionPopup>();
|
||||||
mFunctionTip = std::make_shared<FunctionTooltipWidget>();
|
mFunctionTip = std::make_shared<FunctionTooltipWidget>();
|
||||||
|
|
||||||
|
mClassBrowserModel.setColors(mStatementColors);
|
||||||
updateAppTitle();
|
updateAppTitle();
|
||||||
|
|
||||||
connect(&mAutoSaveTimer, &QTimer::timeout,
|
connect(&mAutoSaveTimer, &QTimer::timeout,
|
||||||
|
@ -164,6 +167,8 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
this, &MainWindow::updateProjectActions);
|
this, &MainWindow::updateProjectActions);
|
||||||
|
|
||||||
buildContextMenus();
|
buildContextMenus();
|
||||||
|
|
||||||
|
updateEditorColorSchemes();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
@ -322,6 +327,59 @@ void MainWindow::updateCompileActions()
|
||||||
void MainWindow::updateEditorColorSchemes()
|
void MainWindow::updateEditorColorSchemes()
|
||||||
{
|
{
|
||||||
mEditorList->applyColorSchemes(pSettings->editor().colorScheme());
|
mEditorList->applyColorSchemes(pSettings->editor().colorScheme());
|
||||||
|
QString schemeName = pSettings->editor().colorScheme();
|
||||||
|
//color for code completion popup
|
||||||
|
PColorSchemeItem item;
|
||||||
|
item = pColorManager->getItem(schemeName, SYNS_AttrFunction);
|
||||||
|
if (item) {
|
||||||
|
mStatementColors->insert(StatementKind::skFunction,item->foreground());
|
||||||
|
mStatementColors->insert(StatementKind::skConstructor,item->foreground());
|
||||||
|
mStatementColors->insert(StatementKind::skDestructor,item->foreground());
|
||||||
|
}
|
||||||
|
item = pColorManager->getItem(schemeName, SYNS_AttrClass);
|
||||||
|
if (item) {
|
||||||
|
mStatementColors->insert(StatementKind::skClass,item->foreground());
|
||||||
|
mStatementColors->insert(StatementKind::skTypedef,item->foreground());
|
||||||
|
mStatementColors->insert(StatementKind::skAlias,item->foreground());
|
||||||
|
}
|
||||||
|
item = pColorManager->getItem(schemeName, SYNS_AttrIdentifier);
|
||||||
|
if (item) {
|
||||||
|
mStatementColors->insert(StatementKind::skEnumType,item->foreground());
|
||||||
|
mStatementColors->insert(StatementKind::skEnumClassType,item->foreground());
|
||||||
|
}
|
||||||
|
item = pColorManager->getItem(schemeName, SYNS_AttrVariable);
|
||||||
|
if (item) {
|
||||||
|
mStatementColors->insert(StatementKind::skVariable,item->foreground());
|
||||||
|
}
|
||||||
|
item = pColorManager->getItem(schemeName, SYNS_AttrLocalVariable);
|
||||||
|
if (item) {
|
||||||
|
mStatementColors->insert(StatementKind::skLocalVariable,item->foreground());
|
||||||
|
mStatementColors->insert(StatementKind::skParameter,item->foreground());
|
||||||
|
}
|
||||||
|
item = pColorManager->getItem(schemeName, SYNS_AttrGlobalVariable);
|
||||||
|
if (item) {
|
||||||
|
mStatementColors->insert(StatementKind::skGlobalVariable,item->foreground());
|
||||||
|
}
|
||||||
|
item = pColorManager->getItem(schemeName, SYNS_AttrGlobalVariable);
|
||||||
|
if (item) {
|
||||||
|
mStatementColors->insert(StatementKind::skGlobalVariable,item->foreground());
|
||||||
|
}
|
||||||
|
item = pColorManager->getItem(schemeName, SYNS_AttrPreprocessor);
|
||||||
|
if (item) {
|
||||||
|
mStatementColors->insert(StatementKind::skPreprocessor,item->foreground());
|
||||||
|
mStatementColors->insert(StatementKind::skEnum,item->foreground());
|
||||||
|
mHeaderCompletionPopup->setSuggestionColor(item->foreground());
|
||||||
|
}
|
||||||
|
item = pColorManager->getItem(schemeName, SYNS_AttrReservedWord);
|
||||||
|
if (item) {
|
||||||
|
mStatementColors->insert(StatementKind::skKeyword,item->foreground());
|
||||||
|
mStatementColors->insert(StatementKind::skUserCodeIn,item->foreground());
|
||||||
|
}
|
||||||
|
item = pColorManager->getItem(schemeName, SYNS_AttrString);
|
||||||
|
if (item) {
|
||||||
|
mStatementColors->insert(StatementKind::skNamespace,item->foreground());
|
||||||
|
mStatementColors->insert(StatementKind::skNamespaceAlias,item->foreground());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::applySettings()
|
void MainWindow::applySettings()
|
||||||
|
@ -3370,3 +3428,8 @@ void MainWindow::on_actionProject_Open_In_Terminal_triggered()
|
||||||
openShell(mProject->directory(),"cmd.exe");
|
openShell(mProject->directory(),"cmd.exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::shared_ptr<QHash<StatementKind, QColor> > &MainWindow::statementColors() const
|
||||||
|
{
|
||||||
|
return mStatementColors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,8 @@ public:
|
||||||
|
|
||||||
std::shared_ptr<Project> project();
|
std::shared_ptr<Project> project();
|
||||||
|
|
||||||
|
const std::shared_ptr<QHash<StatementKind, QColor> > &statementColors() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onCompileLog(const QString& msg);
|
void onCompileLog(const QString& msg);
|
||||||
void onCompileIssue(PCompileIssue issue);
|
void onCompileIssue(PCompileIssue issue);
|
||||||
|
@ -369,6 +371,7 @@ private:
|
||||||
PSearchResultTreeModel mSearchResultTreeModel;
|
PSearchResultTreeModel mSearchResultTreeModel;
|
||||||
PSearchResultTreeViewDelegate mSearchViewDelegate;
|
PSearchResultTreeViewDelegate mSearchViewDelegate;
|
||||||
ClassBrowserModel mClassBrowserModel;
|
ClassBrowserModel mClassBrowserModel;
|
||||||
|
std::shared_ptr<QHash<StatementKind, QColor>> mStatementColors;
|
||||||
|
|
||||||
bool mCheckSyntaxInBack;
|
bool mCheckSyntaxInBack;
|
||||||
bool mOpenClosingBottomPanel;
|
bool mOpenClosingBottomPanel;
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
<enum>QTabWidget::West</enum>
|
<enum>QTabWidget::West</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="usesScrollButtons">
|
<property name="usesScrollButtons">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -183,7 +183,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="classBrowser">
|
<widget class="QTreeView" name="classBrowser">
|
||||||
<property name="rootIsDecorated">
|
<property name="rootIsDecorated">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="headerVisible">
|
<attribute name="headerVisible">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
|
|
@ -42,6 +42,7 @@ enum class SkipType {
|
||||||
skNone // It's a keyword but don't process here
|
skNone // It's a keyword but don't process here
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
enum StatementKind {
|
enum StatementKind {
|
||||||
skUnknown,
|
skUnknown,
|
||||||
skPreprocessor,
|
skPreprocessor,
|
||||||
|
@ -180,7 +181,7 @@ struct FileIncludes {
|
||||||
QSet<QString> dependedFiles; // the files depends on me
|
QSet<QString> dependedFiles; // the files depends on me
|
||||||
};
|
};
|
||||||
using PFileIncludes = std::shared_ptr<FileIncludes>;
|
using PFileIncludes = std::shared_ptr<FileIncludes>;
|
||||||
|
using ColorCallback = std::function<QColor (PStatement)>;
|
||||||
|
|
||||||
extern QStringList CppDirectives;
|
extern QStringList CppDirectives;
|
||||||
extern QStringList JavadocTags;
|
extern QStringList JavadocTags;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#include "classbrowser.h"
|
#include "classbrowser.h"
|
||||||
#include "../utils.h"
|
#include "../utils.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QColor>
|
||||||
|
#include <QPalette>
|
||||||
|
#include "../mainwindow.h"
|
||||||
|
|
||||||
ClassBrowserModel::ClassBrowserModel(QObject *parent):QAbstractItemModel(parent)
|
ClassBrowserModel::ClassBrowserModel(QObject *parent):QAbstractItemModel(parent)
|
||||||
{
|
{
|
||||||
|
@ -97,11 +100,9 @@ void ClassBrowserModel::fetchMore(const QModelIndex &parent)
|
||||||
|
|
||||||
bool ClassBrowserModel::canFetchMore(const QModelIndex &parent) const
|
bool ClassBrowserModel::canFetchMore(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!parent.isValid()) { // top level
|
if (!parent.isValid()) { // top level
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassBrowserNode *parentNode = static_cast<ClassBrowserNode *>(parent.internalPointer());
|
ClassBrowserNode *parentNode = static_cast<ClassBrowserNode *>(parent.internalPointer());
|
||||||
if (!parentNode->childrenFetched) {
|
if (!parentNode->childrenFetched) {
|
||||||
if (parentNode->statement && !parentNode->statement->children.isEmpty())
|
if (parentNode->statement && !parentNode->statement->children.isEmpty())
|
||||||
|
@ -124,6 +125,17 @@ QVariant ClassBrowserModel::data(const QModelIndex &index, int role) const
|
||||||
if (node->statement) {
|
if (node->statement) {
|
||||||
return node->statement->command;
|
return node->statement->command;
|
||||||
}
|
}
|
||||||
|
} else if (role == Qt::ForegroundRole) {
|
||||||
|
if (node->statement) {
|
||||||
|
PStatement statement = (node->statement);
|
||||||
|
StatementKind kind;
|
||||||
|
if (mParser) {
|
||||||
|
kind = mParser->getKindOfStatement(statement);
|
||||||
|
} else {
|
||||||
|
kind = statement->kind;
|
||||||
|
}
|
||||||
|
return mColors->value(kind,pMainWindow->palette().color(QPalette::Text));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -324,6 +336,16 @@ PStatement ClassBrowserModel::createDummy(PStatement statement)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::shared_ptr<QHash<StatementKind, QColor> > &ClassBrowserModel::colors() const
|
||||||
|
{
|
||||||
|
return mColors;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClassBrowserModel::setColors(const std::shared_ptr<QHash<StatementKind, QColor> > &newColors)
|
||||||
|
{
|
||||||
|
mColors = newColors;
|
||||||
|
}
|
||||||
|
|
||||||
const QString &ClassBrowserModel::currentFile() const
|
const QString &ClassBrowserModel::currentFile() const
|
||||||
{
|
{
|
||||||
return mCurrentFile;
|
return mCurrentFile;
|
||||||
|
@ -348,5 +370,3 @@ void ClassBrowserModel::endUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,10 @@ public:
|
||||||
void beginUpdate();
|
void beginUpdate();
|
||||||
void endUpdate();
|
void endUpdate();
|
||||||
|
|
||||||
|
|
||||||
|
const std::shared_ptr<QHash<StatementKind, QColor> > &colors() const;
|
||||||
|
void setColors(const std::shared_ptr<QHash<StatementKind, QColor> > &newColors);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void fillStatements();
|
void fillStatements();
|
||||||
private:
|
private:
|
||||||
|
@ -54,10 +58,7 @@ private:
|
||||||
QRecursiveMutex mMutex;
|
QRecursiveMutex mMutex;
|
||||||
QString mCurrentFile;
|
QString mCurrentFile;
|
||||||
bool mShowInheritedMembers;
|
bool mShowInheritedMembers;
|
||||||
|
std::shared_ptr<QHash<StatementKind, QColor>> mColors;
|
||||||
|
|
||||||
// QAbstractItemModel interface
|
|
||||||
public:
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CLASSBROWSER_H
|
#endif // CLASSBROWSER_H
|
||||||
|
|
|
@ -21,6 +21,5 @@ private:
|
||||||
KeyPressedCallback mKeypressedCallback;
|
KeyPressedCallback mKeypressedCallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
using ColorCallback = std::function<QColor (PStatement)>;
|
|
||||||
|
|
||||||
#endif // CODECOMPLETIONLISTVIEW_H
|
#endif // CODECOMPLETIONLISTVIEW_H
|
||||||
|
|
|
@ -19,7 +19,7 @@ CodeCompletionPopup::CodeCompletionPopup(QWidget *parent) :
|
||||||
} else {
|
} else {
|
||||||
kind = statement->kind;
|
kind = statement->kind;
|
||||||
}
|
}
|
||||||
return mColors.value(kind,palette().color(QPalette::Text));
|
return mColors->value(kind,palette().color(QPalette::Text));
|
||||||
});
|
});
|
||||||
mListView->setModel(mModel);
|
mListView->setModel(mModel);
|
||||||
setLayout(new QVBoxLayout());
|
setLayout(new QVBoxLayout());
|
||||||
|
@ -709,6 +709,11 @@ bool CodeCompletionPopup::isIncluded(const QString &fileName)
|
||||||
return mIncludedFiles.contains(fileName);
|
return mIncludedFiles.contains(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CodeCompletionPopup::setColors(const std::shared_ptr<QHash<StatementKind, QColor> > &newColors)
|
||||||
|
{
|
||||||
|
mColors = newColors;
|
||||||
|
}
|
||||||
|
|
||||||
const QString &CodeCompletionPopup::phrase() const
|
const QString &CodeCompletionPopup::phrase() const
|
||||||
{
|
{
|
||||||
return mPhrase;
|
return mPhrase;
|
||||||
|
@ -729,7 +734,7 @@ void CodeCompletionPopup::setCurrentStatement(const PStatement &newCurrentStatem
|
||||||
mCurrentStatement = newCurrentStatement;
|
mCurrentStatement = newCurrentStatement;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<StatementKind, QColor> &CodeCompletionPopup::colors()
|
const std::shared_ptr<QHash<StatementKind, QColor> >& CodeCompletionPopup::colors() const
|
||||||
{
|
{
|
||||||
return mColors;
|
return mColors;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,8 @@ public:
|
||||||
|
|
||||||
const PStatement ¤tStatement() const;
|
const PStatement ¤tStatement() const;
|
||||||
void setCurrentStatement(const PStatement &newCurrentStatement);
|
void setCurrentStatement(const PStatement &newCurrentStatement);
|
||||||
QHash<StatementKind, QColor>& colors();
|
const std::shared_ptr<QHash<StatementKind, QColor> >& colors() const;
|
||||||
|
void setColors(const std::shared_ptr<QHash<StatementKind, QColor> > &newColors);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addChildren(PStatement scopeStatement, const QString& fileName,
|
void addChildren(PStatement scopeStatement, const QString& fileName,
|
||||||
|
@ -86,7 +87,7 @@ private:
|
||||||
QString mPhrase;
|
QString mPhrase;
|
||||||
QHash<QString,int> mSymbolUsage;
|
QHash<QString,int> mSymbolUsage;
|
||||||
QRecursiveMutex mMutex;
|
QRecursiveMutex mMutex;
|
||||||
QHash<StatementKind, QColor> mColors;
|
std::shared_ptr<QHash<StatementKind, QColor>> mColors;
|
||||||
|
|
||||||
PCppParser mParser;
|
PCppParser mParser;
|
||||||
PStatement mCurrentStatement;
|
PStatement mCurrentStatement;
|
||||||
|
|
Loading…
Reference in New Issue