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;
|
||||
}
|
||||
}
|
||||
foreground = mCompletionPopup->colors().value(kind,
|
||||
foreground = mCompletionPopup->colors()->value(kind,
|
||||
highlighter()->identifierAttribute()->foreground());
|
||||
return;
|
||||
}
|
||||
|
@ -3020,59 +3020,6 @@ void Editor::applyColorScheme(const QString& schemeName)
|
|||
this->mBreakpointForegroundColor = item->foreground();
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -147,10 +147,13 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
connect(&mFileSystemWatcher,&QFileSystemWatcher::fileChanged,
|
||||
this, &MainWindow::onFileChanged);
|
||||
|
||||
mStatementColors = std::make_shared<QHash<StatementKind, QColor> >();
|
||||
mCompletionPopup = std::make_shared<CodeCompletionPopup>();
|
||||
mCompletionPopup->setColors(mStatementColors);
|
||||
mHeaderCompletionPopup = std::make_shared<HeaderCompletionPopup>();
|
||||
mFunctionTip = std::make_shared<FunctionTooltipWidget>();
|
||||
|
||||
mClassBrowserModel.setColors(mStatementColors);
|
||||
updateAppTitle();
|
||||
|
||||
connect(&mAutoSaveTimer, &QTimer::timeout,
|
||||
|
@ -164,6 +167,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
this, &MainWindow::updateProjectActions);
|
||||
|
||||
buildContextMenus();
|
||||
|
||||
updateEditorColorSchemes();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -322,6 +327,59 @@ void MainWindow::updateCompileActions()
|
|||
void MainWindow::updateEditorColorSchemes()
|
||||
{
|
||||
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()
|
||||
|
@ -3370,3 +3428,8 @@ void MainWindow::on_actionProject_Open_In_Terminal_triggered()
|
|||
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();
|
||||
|
||||
const std::shared_ptr<QHash<StatementKind, QColor> > &statementColors() const;
|
||||
|
||||
public slots:
|
||||
void onCompileLog(const QString& msg);
|
||||
void onCompileIssue(PCompileIssue issue);
|
||||
|
@ -369,6 +371,7 @@ private:
|
|||
PSearchResultTreeModel mSearchResultTreeModel;
|
||||
PSearchResultTreeViewDelegate mSearchViewDelegate;
|
||||
ClassBrowserModel mClassBrowserModel;
|
||||
std::shared_ptr<QHash<StatementKind, QColor>> mStatementColors;
|
||||
|
||||
bool mCheckSyntaxInBack;
|
||||
bool mOpenClosingBottomPanel;
|
||||
|
|
|
@ -85,7 +85,7 @@
|
|||
<enum>QTabWidget::West</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="usesScrollButtons">
|
||||
<bool>true</bool>
|
||||
|
@ -183,7 +183,7 @@
|
|||
<item>
|
||||
<widget class="QTreeView" name="classBrowser">
|
||||
<property name="rootIsDecorated">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
|
|
|
@ -42,6 +42,7 @@ enum class SkipType {
|
|||
skNone // It's a keyword but don't process here
|
||||
};
|
||||
|
||||
|
||||
enum StatementKind {
|
||||
skUnknown,
|
||||
skPreprocessor,
|
||||
|
@ -180,7 +181,7 @@ struct FileIncludes {
|
|||
QSet<QString> dependedFiles; // the files depends on me
|
||||
};
|
||||
using PFileIncludes = std::shared_ptr<FileIncludes>;
|
||||
|
||||
using ColorCallback = std::function<QColor (PStatement)>;
|
||||
|
||||
extern QStringList CppDirectives;
|
||||
extern QStringList JavadocTags;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#include "classbrowser.h"
|
||||
#include "../utils.h"
|
||||
#include <QDebug>
|
||||
#include <QColor>
|
||||
#include <QPalette>
|
||||
#include "../mainwindow.h"
|
||||
|
||||
ClassBrowserModel::ClassBrowserModel(QObject *parent):QAbstractItemModel(parent)
|
||||
{
|
||||
|
@ -97,11 +100,9 @@ void ClassBrowserModel::fetchMore(const QModelIndex &parent)
|
|||
|
||||
bool ClassBrowserModel::canFetchMore(const QModelIndex &parent) const
|
||||
{
|
||||
|
||||
if (!parent.isValid()) { // top level
|
||||
return false;
|
||||
}
|
||||
|
||||
ClassBrowserNode *parentNode = static_cast<ClassBrowserNode *>(parent.internalPointer());
|
||||
if (!parentNode->childrenFetched) {
|
||||
if (parentNode->statement && !parentNode->statement->children.isEmpty())
|
||||
|
@ -124,6 +125,17 @@ QVariant ClassBrowserModel::data(const QModelIndex &index, int role) const
|
|||
if (node->statement) {
|
||||
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();
|
||||
}
|
||||
|
@ -324,6 +336,16 @@ PStatement ClassBrowserModel::createDummy(PStatement statement)
|
|||
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
|
||||
{
|
||||
return mCurrentFile;
|
||||
|
@ -348,5 +370,3 @@ void ClassBrowserModel::endUpdate()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,10 @@ public:
|
|||
void beginUpdate();
|
||||
void endUpdate();
|
||||
|
||||
|
||||
const std::shared_ptr<QHash<StatementKind, QColor> > &colors() const;
|
||||
void setColors(const std::shared_ptr<QHash<StatementKind, QColor> > &newColors);
|
||||
|
||||
public slots:
|
||||
void fillStatements();
|
||||
private:
|
||||
|
@ -54,10 +58,7 @@ private:
|
|||
QRecursiveMutex mMutex;
|
||||
QString mCurrentFile;
|
||||
bool mShowInheritedMembers;
|
||||
|
||||
|
||||
// QAbstractItemModel interface
|
||||
public:
|
||||
std::shared_ptr<QHash<StatementKind, QColor>> mColors;
|
||||
};
|
||||
|
||||
#endif // CLASSBROWSER_H
|
||||
|
|
|
@ -21,6 +21,5 @@ private:
|
|||
KeyPressedCallback mKeypressedCallback;
|
||||
};
|
||||
|
||||
using ColorCallback = std::function<QColor (PStatement)>;
|
||||
|
||||
#endif // CODECOMPLETIONLISTVIEW_H
|
||||
|
|
|
@ -19,7 +19,7 @@ CodeCompletionPopup::CodeCompletionPopup(QWidget *parent) :
|
|||
} else {
|
||||
kind = statement->kind;
|
||||
}
|
||||
return mColors.value(kind,palette().color(QPalette::Text));
|
||||
return mColors->value(kind,palette().color(QPalette::Text));
|
||||
});
|
||||
mListView->setModel(mModel);
|
||||
setLayout(new QVBoxLayout());
|
||||
|
@ -709,6 +709,11 @@ bool CodeCompletionPopup::isIncluded(const QString &fileName)
|
|||
return mIncludedFiles.contains(fileName);
|
||||
}
|
||||
|
||||
void CodeCompletionPopup::setColors(const std::shared_ptr<QHash<StatementKind, QColor> > &newColors)
|
||||
{
|
||||
mColors = newColors;
|
||||
}
|
||||
|
||||
const QString &CodeCompletionPopup::phrase() const
|
||||
{
|
||||
return mPhrase;
|
||||
|
@ -729,7 +734,7 @@ void CodeCompletionPopup::setCurrentStatement(const PStatement &newCurrentStatem
|
|||
mCurrentStatement = newCurrentStatement;
|
||||
}
|
||||
|
||||
QHash<StatementKind, QColor> &CodeCompletionPopup::colors()
|
||||
const std::shared_ptr<QHash<StatementKind, QColor> >& CodeCompletionPopup::colors() const
|
||||
{
|
||||
return mColors;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,8 @@ public:
|
|||
|
||||
const PStatement ¤tStatement() const;
|
||||
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:
|
||||
void addChildren(PStatement scopeStatement, const QString& fileName,
|
||||
|
@ -86,7 +87,7 @@ private:
|
|||
QString mPhrase;
|
||||
QHash<QString,int> mSymbolUsage;
|
||||
QRecursiveMutex mMutex;
|
||||
QHash<StatementKind, QColor> mColors;
|
||||
std::shared_ptr<QHash<StatementKind, QColor>> mColors;
|
||||
|
||||
PCppParser mParser;
|
||||
PStatement mCurrentStatement;
|
||||
|
|
Loading…
Reference in New Issue