* work save: color scheme options
This commit is contained in:
parent
9390545641
commit
021873a9d6
|
@ -46,7 +46,8 @@ SOURCES += \
|
||||||
systemconsts.cpp \
|
systemconsts.cpp \
|
||||||
utils.cpp \
|
utils.cpp \
|
||||||
widgets/coloredit.cpp \
|
widgets/coloredit.cpp \
|
||||||
widgets/issuestable.cpp
|
widgets/issuestable.cpp \
|
||||||
|
widgets/qpatchedcombobox.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
HighlighterManager.h \
|
HighlighterManager.h \
|
||||||
|
@ -87,7 +88,8 @@ HEADERS += \
|
||||||
utils.h \
|
utils.h \
|
||||||
common.h \
|
common.h \
|
||||||
widgets/coloredit.h \
|
widgets/coloredit.h \
|
||||||
widgets/issuestable.h
|
widgets/issuestable.h \
|
||||||
|
widgets/qpatchedcombobox.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
mainwindow.ui \
|
mainwindow.ui \
|
||||||
|
|
Binary file not shown.
|
@ -54,7 +54,7 @@ PColorScheme ColorScheme::load(const QString &filename)
|
||||||
.arg(file.fileName()).arg(error.offset).arg(error.error);
|
.arg(file.fileName()).arg(error.offset).arg(error.error);
|
||||||
}
|
}
|
||||||
if (!doc.isObject()) {
|
if (!doc.isObject()) {
|
||||||
qDebug()<<QObject::tr("Can't parse json file '%1' is not a color schema config file!")
|
qDebug()<<QObject::tr("Can't parse json file '%1' is not a color scheme config file!")
|
||||||
.arg(file.fileName());
|
.arg(file.fileName());
|
||||||
}
|
}
|
||||||
return ColorScheme::fromJson(doc.object());
|
return ColorScheme::fromJson(doc.object());
|
||||||
|
@ -68,8 +68,10 @@ QMap<QString, PColorSchemeItem> ColorScheme::items()
|
||||||
void ColorScheme::save(const QString &filename)
|
void ColorScheme::save(const QString &filename)
|
||||||
{
|
{
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
|
QFileInfo info(filename);
|
||||||
|
info.dir().mkpath(info.dir().absolutePath());
|
||||||
if (!file.open(QFile::WriteOnly)) {
|
if (!file.open(QFile::WriteOnly)) {
|
||||||
throw new FileError(QObject::tr("Can't open file '%1' for write").arg(file.fileName()));
|
throw FileError(QObject::tr("Can't open file '%1' for write").arg(file.fileName()));
|
||||||
}
|
}
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
toJson(json);
|
toJson(json);
|
||||||
|
@ -249,11 +251,11 @@ void ColorManager::reload()
|
||||||
{
|
{
|
||||||
mSchemes.clear();
|
mSchemes.clear();
|
||||||
//bundled schemes ( the lowest priority)
|
//bundled schemes ( the lowest priority)
|
||||||
loadSchemesInDir(pSettings->dirs().data(Settings::Dirs::DataType::ColorSheme),false);
|
loadSchemesInDir(pSettings->dirs().data(Settings::Dirs::DataType::ColorSheme),true,false);
|
||||||
//config schemes ( higher priority)
|
//config schemes ( higher priority)
|
||||||
loadSchemesInDir(pSettings->dirs().config(Settings::Dirs::DataType::ColorSheme),false);
|
loadSchemesInDir(pSettings->dirs().config(Settings::Dirs::DataType::ColorSheme),false,false);
|
||||||
//customed schemes ( highest priority)
|
//customed schemes ( highest priority)
|
||||||
loadSchemesInDir(pSettings->dirs().config(Settings::Dirs::DataType::ColorSheme),true);
|
loadSchemesInDir(pSettings->dirs().config(Settings::Dirs::DataType::ColorSheme),false,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList ColorManager::getSchemes(const QString &themeType)
|
QStringList ColorManager::getSchemes(const QString &themeType)
|
||||||
|
@ -309,15 +311,16 @@ QString ColorManager::generateFilename(const QString &name, bool isCustomed)
|
||||||
return newName += EXT_COLOR_SCHEME;
|
return newName += EXT_COLOR_SCHEME;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorManager::loadSchemesInDir(const QString &dirName, bool isCustomed)
|
void ColorManager::loadSchemesInDir(const QString &dirName, bool isBundled, bool isCustomed)
|
||||||
{
|
{
|
||||||
QDir dir(dirName);
|
QDir dir(dirName);
|
||||||
dir.setFilter(QDir::Files);
|
dir.setFilter(QDir::Files);
|
||||||
QFileInfoList list = dir.entryInfoList();
|
QFileInfoList list = dir.entryInfoList();
|
||||||
QString suffix;
|
QString suffix;
|
||||||
|
QString customSuffix = EXT_PREFIX_CUSTOM;
|
||||||
|
customSuffix += EXT_COLOR_SCHEME;
|
||||||
if (isCustomed) {
|
if (isCustomed) {
|
||||||
suffix = EXT_PREFIX_CUSTOM;
|
suffix = customSuffix;
|
||||||
suffix = suffix + EXT_COLOR_SCHEME;
|
|
||||||
} else {
|
} else {
|
||||||
suffix = EXT_COLOR_SCHEME;
|
suffix = EXT_COLOR_SCHEME;
|
||||||
}
|
}
|
||||||
|
@ -325,9 +328,25 @@ void ColorManager::loadSchemesInDir(const QString &dirName, bool isCustomed)
|
||||||
QFileInfo fileInfo = list[i];
|
QFileInfo fileInfo = list[i];
|
||||||
QString name = fileInfo.fileName();
|
QString name = fileInfo.fileName();
|
||||||
if (name.toLower().endsWith(suffix)) {
|
if (name.toLower().endsWith(suffix)) {
|
||||||
|
if (!isCustomed && name.toLower().endsWith(customSuffix))
|
||||||
|
continue;
|
||||||
PColorScheme scheme = ColorScheme::load(fileInfo.absoluteFilePath());
|
PColorScheme scheme = ColorScheme::load(fileInfo.absoluteFilePath());
|
||||||
name.remove(name.length()-suffix.length(),suffix.length());
|
name.remove(name.length()-suffix.length(),suffix.length());
|
||||||
name.replace('_',' ');
|
name.replace('_',' ');
|
||||||
|
if (!isCustomed) {
|
||||||
|
scheme->setBundled(isBundled);
|
||||||
|
scheme->setCustomed(false);
|
||||||
|
} else {
|
||||||
|
scheme->setBundled(false);
|
||||||
|
if (mSchemes.contains(name)) {
|
||||||
|
PColorScheme oldScheme = mSchemes[name];
|
||||||
|
if (oldScheme) {
|
||||||
|
scheme->setBundled(oldScheme->bundled());
|
||||||
|
}
|
||||||
|
mSchemes.remove(name);
|
||||||
|
}
|
||||||
|
scheme->setCustomed(true);
|
||||||
|
}
|
||||||
mSchemes[name]=scheme;
|
mSchemes[name]=scheme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -547,10 +566,19 @@ PColorSchemeItemDefine ColorManager::getDefine(const QString &name)
|
||||||
return PColorSchemeItemDefine();
|
return PColorSchemeItemDefine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ColorManager::saveScheme(const QString &name)
|
||||||
|
{
|
||||||
|
PColorScheme scheme = get(name);
|
||||||
|
if (!scheme)
|
||||||
|
return false;
|
||||||
|
QString newFilepath = generateFullPathname(name,scheme->bundled(),scheme->customed());
|
||||||
|
scheme->save(newFilepath);
|
||||||
|
}
|
||||||
|
|
||||||
QString ColorManager::generateFullPathname(const QString &name, bool isBundled, bool isCustomed)
|
QString ColorManager::generateFullPathname(const QString &name, bool isBundled, bool isCustomed)
|
||||||
{
|
{
|
||||||
QString filename = generateFilename(name,isCustomed);
|
QString filename = generateFilename(name,isCustomed);
|
||||||
if (isBundled) {
|
if (isBundled && !isCustomed) {
|
||||||
return includeTrailingPathDelimiter(pSettings->dirs().data(Settings::Dirs::DataType::ColorSheme))+filename;
|
return includeTrailingPathDelimiter(pSettings->dirs().data(Settings::Dirs::DataType::ColorSheme))+filename;
|
||||||
} else {
|
} else {
|
||||||
return includeTrailingPathDelimiter(pSettings->dirs().config(Settings::Dirs::DataType::ColorSheme))+filename;
|
return includeTrailingPathDelimiter(pSettings->dirs().config(Settings::Dirs::DataType::ColorSheme))+filename;
|
||||||
|
|
|
@ -138,10 +138,11 @@ public:
|
||||||
void addDefine(const QString& name, const QString& displayName, const QString& group, bool hasForeground, bool hasBackground, bool hasFontStyle);
|
void addDefine(const QString& name, const QString& displayName, const QString& group, bool hasForeground, bool hasBackground, bool hasFontStyle);
|
||||||
bool removeDefine(const QString &name);
|
bool removeDefine(const QString &name);
|
||||||
PColorSchemeItemDefine getDefine(const QString& name);
|
PColorSchemeItemDefine getDefine(const QString& name);
|
||||||
|
bool saveScheme(const QString &name);
|
||||||
private:
|
private:
|
||||||
QString generateFullPathname(const QString& name, bool isBundled, bool isCustomed);
|
QString generateFullPathname(const QString& name, bool isBundled, bool isCustomed);
|
||||||
QString generateFilename(const QString& name, bool isCustomed);
|
QString generateFilename(const QString& name, bool isCustomed);
|
||||||
void loadSchemesInDir(const QString& dirName, bool isCustomed);
|
void loadSchemesInDir(const QString& dirName, bool isBundled, bool isCustomed);
|
||||||
void initItemDefines();
|
void initItemDefines();
|
||||||
private:
|
private:
|
||||||
QMap<QString,PColorSchemeItemDefine> mSchemeItemDefines;
|
QMap<QString,PColorSchemeItemDefine> mSchemeItemDefines;
|
||||||
|
|
|
@ -49,11 +49,11 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
||||||
bool inProject, bool isNew,
|
bool inProject, bool isNew,
|
||||||
QTabWidget* parentPageControl):
|
QTabWidget* parentPageControl):
|
||||||
SynEdit(parent),
|
SynEdit(parent),
|
||||||
mFilename(filename),
|
|
||||||
mEncodingOption(encoding),
|
mEncodingOption(encoding),
|
||||||
|
mFilename(filename),
|
||||||
|
mParentPageControl(parentPageControl),
|
||||||
mInProject(inProject),
|
mInProject(inProject),
|
||||||
mIsNew(isNew),
|
mIsNew(isNew)
|
||||||
mParentPageControl(parentPageControl)
|
|
||||||
{
|
{
|
||||||
if (mFilename.isEmpty()) {
|
if (mFilename.isEmpty()) {
|
||||||
newfileCount++;
|
newfileCount++;
|
||||||
|
@ -84,6 +84,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
||||||
}
|
}
|
||||||
|
|
||||||
applySettings();
|
applySettings();
|
||||||
|
applyColorScheme(pSettings->editor().colorScheme());
|
||||||
|
|
||||||
connect(this,&SynEdit::statusChanged,this,&Editor::onStatusChanged);
|
connect(this,&SynEdit::statusChanged,this,&Editor::onStatusChanged);
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,18 @@ void EditorList::applySettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorList::applyColorSchemes(const QString& name)
|
||||||
|
{
|
||||||
|
for (int i=0;i<mLeftPageWidget->count();i++) {
|
||||||
|
Editor* e = static_cast<Editor*>(mLeftPageWidget->widget(i));
|
||||||
|
e->applyColorScheme(name);
|
||||||
|
}
|
||||||
|
for (int i=0;i<mRightPageWidget->count();i++) {
|
||||||
|
Editor* e = static_cast<Editor*>(mRightPageWidget->widget(i));
|
||||||
|
e->applyColorScheme(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool EditorList::closeAll(bool force) {
|
bool EditorList::closeAll(bool force) {
|
||||||
beginUpdate();
|
beginUpdate();
|
||||||
auto end = finally([this] {
|
auto end = finally([this] {
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
void beginUpdate();
|
void beginUpdate();
|
||||||
void endUpdate();
|
void endUpdate();
|
||||||
void applySettings();
|
void applySettings();
|
||||||
|
void applyColorSchemes(const QString& name);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTabWidget* getNewEditorPageControl() const;
|
QTabWidget* getNewEditorPageControl() const;
|
||||||
|
|
|
@ -63,17 +63,18 @@ int main(int argc, char *argv[])
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
auto settings = std::unique_ptr<Settings>(pSettings);
|
auto settings = std::unique_ptr<Settings>(pSettings);
|
||||||
|
settings->environment().load();
|
||||||
settings->compilerSets().loadSets();
|
settings->compilerSets().loadSets();
|
||||||
settings->editor().load();
|
settings->editor().load();
|
||||||
settings->environment().load();
|
|
||||||
|
|
||||||
pColorManager = new ColorManager();
|
//Translation must be loaded after language setting is loaded
|
||||||
|
|
||||||
//load translations
|
|
||||||
QTranslator trans;
|
QTranslator trans;
|
||||||
trans.load("RedPandaIDE_"+pSettings->environment().language(),":/translations");
|
trans.load("RedPandaIDE_"+pSettings->environment().language(),":/translations");
|
||||||
app.installTranslator(&trans);
|
app.installTranslator(&trans);
|
||||||
|
|
||||||
|
//Color scheme settings must be loaded after translation
|
||||||
|
pColorManager = new ColorManager();
|
||||||
|
|
||||||
MainWindow mainWindow;
|
MainWindow mainWindow;
|
||||||
pMainWindow = &mainWindow;
|
pMainWindow = &mainWindow;
|
||||||
mainWindow.show();
|
mainWindow.show();
|
||||||
|
|
|
@ -157,6 +157,11 @@ void MainWindow::updateEditorActions()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateEditorColorSchemes()
|
||||||
|
{
|
||||||
|
mEditorList->applyColorSchemes(pSettings->editor().colorScheme());
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::applySettings()
|
void MainWindow::applySettings()
|
||||||
{
|
{
|
||||||
changeTheme(pSettings->environment().theme());
|
changeTheme(pSettings->environment().theme());
|
||||||
|
|
|
@ -27,6 +27,7 @@ public:
|
||||||
void updateForStatusbarModeInfo();
|
void updateForStatusbarModeInfo();
|
||||||
void updateEditorSettings();
|
void updateEditorSettings();
|
||||||
void updateEditorActions();
|
void updateEditorActions();
|
||||||
|
void updateEditorColorSchemes();
|
||||||
|
|
||||||
void applySettings();
|
void applySettings();
|
||||||
|
|
||||||
|
|
|
@ -159,31 +159,18 @@ void SynEditKeyStrokes::clear()
|
||||||
|
|
||||||
void SynEditKeyStrokes::resetDefaults()
|
void SynEditKeyStrokes::resetDefaults()
|
||||||
{
|
{
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults ";
|
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: clear ";
|
|
||||||
clear();
|
clear();
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start ";
|
|
||||||
add(SynEditorCommand::ecUp, Qt::Key_Up, Qt::NoModifier);
|
add(SynEditorCommand::ecUp, Qt::Key_Up, Qt::NoModifier);
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 0";
|
|
||||||
add(SynEditorCommand::ecSelUp, Qt::Key_Up, Qt::ShiftModifier);
|
add(SynEditorCommand::ecSelUp, Qt::Key_Up, Qt::ShiftModifier);
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 01";
|
|
||||||
add(SynEditorCommand::ecScrollUp, Qt::Key_Up, Qt::ControlModifier);
|
add(SynEditorCommand::ecScrollUp, Qt::Key_Up, Qt::ControlModifier);
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 02";
|
|
||||||
add(SynEditorCommand::ecDown, Qt::Key_Down, Qt::NoModifier);
|
add(SynEditorCommand::ecDown, Qt::Key_Down, Qt::NoModifier);
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 03";
|
|
||||||
add(SynEditorCommand::ecSelDown, Qt::Key_Down, Qt::ShiftModifier);
|
add(SynEditorCommand::ecSelDown, Qt::Key_Down, Qt::ShiftModifier);
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 04";
|
|
||||||
add(SynEditorCommand::ecScrollDown, Qt::Key_Down, Qt::ControlModifier);
|
add(SynEditorCommand::ecScrollDown, Qt::Key_Down, Qt::ControlModifier);
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 05";
|
|
||||||
add(SynEditorCommand::ecLeft, Qt::Key_Left, Qt::NoModifier);
|
add(SynEditorCommand::ecLeft, Qt::Key_Left, Qt::NoModifier);
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 06";
|
|
||||||
add(SynEditorCommand::ecSelLeft, Qt::Key_Left, Qt::ShiftModifier);
|
add(SynEditorCommand::ecSelLeft, Qt::Key_Left, Qt::ShiftModifier);
|
||||||
add(SynEditorCommand::ecWordLeft, Qt::Key_Left, Qt::ControlModifier);
|
add(SynEditorCommand::ecWordLeft, Qt::Key_Left, Qt::ControlModifier);
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 1";
|
|
||||||
add(SynEditorCommand::ecSelWordLeft, Qt::Key_Left, Qt::ShiftModifier|Qt::ControlModifier);
|
add(SynEditorCommand::ecSelWordLeft, Qt::Key_Left, Qt::ShiftModifier|Qt::ControlModifier);
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 2 ";
|
|
||||||
add(SynEditorCommand::ecRight, Qt::Key_Right, Qt::NoModifier);
|
add(SynEditorCommand::ecRight, Qt::Key_Right, Qt::NoModifier);
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 3";
|
|
||||||
|
|
||||||
add(SynEditorCommand::ecSelRight, Qt::Key_Right, Qt::ShiftModifier);
|
add(SynEditorCommand::ecSelRight, Qt::Key_Right, Qt::ShiftModifier);
|
||||||
add(SynEditorCommand::ecWordRight, Qt::Key_Right, Qt::ControlModifier);
|
add(SynEditorCommand::ecWordRight, Qt::Key_Right, Qt::ControlModifier);
|
||||||
|
@ -257,5 +244,4 @@ void SynEditKeyStrokes::resetDefaults()
|
||||||
add(SynEditorCommand::ecColumnSelect, Qt::Key_C, Qt::ControlModifier | Qt::ShiftModifier);
|
add(SynEditorCommand::ecColumnSelect, Qt::Key_C, Qt::ControlModifier | Qt::ShiftModifier);
|
||||||
add(SynEditorCommand::ecLineSelect, Qt::Key_L, Qt::ControlModifier | Qt::ShiftModifier);
|
add(SynEditorCommand::ecLineSelect, Qt::Key_L, Qt::ControlModifier | Qt::ShiftModifier);
|
||||||
add(SynEditorCommand::ecMatchBracket, Qt::Key_B, Qt::ControlModifier | Qt::ShiftModifier);
|
add(SynEditorCommand::ecMatchBracket, Qt::Key_B, Qt::ControlModifier | Qt::ShiftModifier);
|
||||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add end ";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,7 +287,6 @@ QColor SynGutter::color() const
|
||||||
void SynGutter::setColor(const QColor &value)
|
void SynGutter::setColor(const QColor &value)
|
||||||
{
|
{
|
||||||
if (mColor!=value) {
|
if (mColor!=value) {
|
||||||
qDebug()<<"mColor"<<value;
|
|
||||||
mColor = value;
|
mColor = value;
|
||||||
setChanged();
|
setChanged();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,10 @@
|
||||||
|
|
||||||
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
{
|
{
|
||||||
qDebug()<<"init SynEdit:";
|
|
||||||
mPaintLock = 0;
|
mPaintLock = 0;
|
||||||
mPainterLock = 0;
|
mPainterLock = 0;
|
||||||
mPainting = false;
|
mPainting = false;
|
||||||
mLines = std::make_shared<SynEditStringList>(this);
|
mLines = std::make_shared<SynEditStringList>(this);
|
||||||
qDebug()<<"init SynEdit: 1";
|
|
||||||
mOrigLines = mLines;
|
mOrigLines = mLines;
|
||||||
//fPlugins := TList.Create;
|
//fPlugins := TList.Create;
|
||||||
mMouseMoved = false;
|
mMouseMoved = false;
|
||||||
|
@ -35,7 +33,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
mLines->connect(mLines.get(), &SynEditStringList::deleted, this, &SynEdit::linesDeleted);
|
mLines->connect(mLines.get(), &SynEditStringList::deleted, this, &SynEdit::linesDeleted);
|
||||||
mLines->connect(mLines.get(), &SynEditStringList::inserted, this, &SynEdit::linesInserted);
|
mLines->connect(mLines.get(), &SynEditStringList::inserted, this, &SynEdit::linesInserted);
|
||||||
mLines->connect(mLines.get(), &SynEditStringList::putted, this, &SynEdit::linesPutted);
|
mLines->connect(mLines.get(), &SynEditStringList::putted, this, &SynEdit::linesPutted);
|
||||||
qDebug()<<"init SynEdit: 2";
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
mFontDummy = QFont("Consolas",12);
|
mFontDummy = QFont("Consolas",12);
|
||||||
|
@ -46,7 +43,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
#endif
|
#endif
|
||||||
mFontDummy.setStyleStrategy(QFont::PreferAntialias);
|
mFontDummy.setStyleStrategy(QFont::PreferAntialias);
|
||||||
setFont(mFontDummy);
|
setFont(mFontDummy);
|
||||||
qDebug()<<"init SynEdit:3";
|
|
||||||
|
|
||||||
mUndoList = std::make_shared<SynEditUndoList>();
|
mUndoList = std::make_shared<SynEditUndoList>();
|
||||||
mUndoList->connect(mUndoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::undoAdded);
|
mUndoList->connect(mUndoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::undoAdded);
|
||||||
|
@ -54,7 +50,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
mRedoList = std::make_shared<SynEditUndoList>();
|
mRedoList = std::make_shared<SynEditUndoList>();
|
||||||
mRedoList->connect(mRedoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::redoAdded);
|
mRedoList->connect(mRedoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::redoAdded);
|
||||||
mOrigRedoList = mRedoList;
|
mOrigRedoList = mRedoList;
|
||||||
qDebug()<<"init SynEdit: 4";
|
|
||||||
|
|
||||||
mCaretColor = QColorConstants::Red;
|
mCaretColor = QColorConstants::Red;
|
||||||
mActiveLineColor = QColorConstants::Svg::lightblue;
|
mActiveLineColor = QColorConstants::Svg::lightblue;
|
||||||
|
@ -64,7 +59,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
mBookMarkOpt.connect(&mBookMarkOpt, &SynBookMarkOpt::changed, this, &SynEdit::bookMarkOptionsChanged);
|
mBookMarkOpt.connect(&mBookMarkOpt, &SynBookMarkOpt::changed, this, &SynEdit::bookMarkOptionsChanged);
|
||||||
// fRightEdge has to be set before FontChanged is called for the first time
|
// fRightEdge has to be set before FontChanged is called for the first time
|
||||||
mRightEdge = 80;
|
mRightEdge = 80;
|
||||||
qDebug()<<"init SynEdit: 5";
|
|
||||||
|
|
||||||
mGutter.setRightOffset(21);
|
mGutter.setRightOffset(21);
|
||||||
mGutter.connect(&mGutter, &SynGutter::changed, this, &SynEdit::gutterChanged);
|
mGutter.connect(&mGutter, &SynGutter::changed, this, &SynEdit::gutterChanged);
|
||||||
|
@ -77,7 +71,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
mInserting = true;
|
mInserting = true;
|
||||||
mScrollBars = SynScrollStyle::ssBoth;
|
mScrollBars = SynScrollStyle::ssBoth;
|
||||||
mExtraLineSpacing = 0;
|
mExtraLineSpacing = 0;
|
||||||
qDebug()<<"init SynEdit: 6";
|
|
||||||
|
|
||||||
this->setFrameShape(QFrame::Panel);
|
this->setFrameShape(QFrame::Panel);
|
||||||
this->setFrameShadow(QFrame::Sunken);
|
this->setFrameShadow(QFrame::Sunken);
|
||||||
|
@ -87,18 +80,14 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
mSelectionMode = SynSelectionMode::smNormal;
|
mSelectionMode = SynSelectionMode::smNormal;
|
||||||
mActiveSelectionMode = SynSelectionMode::smNormal;
|
mActiveSelectionMode = SynSelectionMode::smNormal;
|
||||||
mReadOnly = false;
|
mReadOnly = false;
|
||||||
qDebug()<<"init SynEdit: 7";
|
|
||||||
|
|
||||||
//stop qt to auto fill background
|
//stop qt to auto fill background
|
||||||
setAutoFillBackground(false);
|
setAutoFillBackground(false);
|
||||||
//fFocusList := TList.Create;
|
//fFocusList := TList.Create;
|
||||||
//fKbdHandler := TSynEditKbdHandler.Create;
|
//fKbdHandler := TSynEditKbdHandler.Create;
|
||||||
//fMarkList.OnChange := MarkListChange;
|
//fMarkList.OnChange := MarkListChange;
|
||||||
qDebug()<<"init SynEdit: 7-1";
|
|
||||||
setDefaultKeystrokes();
|
setDefaultKeystrokes();
|
||||||
qDebug()<<"init SynEdit: 7-2";
|
|
||||||
mRightEdgeColor = QColorConstants::Svg::silver;
|
mRightEdgeColor = QColorConstants::Svg::silver;
|
||||||
qDebug()<<"init SynEdit: 8";
|
|
||||||
|
|
||||||
/* IME input */
|
/* IME input */
|
||||||
mImeCount = 0;
|
mImeCount = 0;
|
||||||
|
@ -118,7 +107,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
mOptions = eoAutoIndent | eoAddIndent
|
mOptions = eoAutoIndent | eoAddIndent
|
||||||
| eoDragDropEditing | eoEnhanceEndKey | eoTabIndent |
|
| eoDragDropEditing | eoEnhanceEndKey | eoTabIndent |
|
||||||
eoGroupUndo | eoKeepCaretX | eoSelectWordByDblClick;
|
eoGroupUndo | eoKeepCaretX | eoSelectWordByDblClick;
|
||||||
qDebug()<<"init SynEdit: 9";
|
|
||||||
|
|
||||||
mScrollTimer = new QTimer(this);
|
mScrollTimer = new QTimer(this);
|
||||||
mScrollTimer->setInterval(100);
|
mScrollTimer->setInterval(100);
|
||||||
|
@ -132,10 +120,8 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||||
mUseCodeFolding = true;
|
mUseCodeFolding = true;
|
||||||
m_blinkTimerId = 0;
|
m_blinkTimerId = 0;
|
||||||
m_blinkStatus = 0;
|
m_blinkStatus = 0;
|
||||||
qDebug()<<"init SynEdit: 10";
|
|
||||||
|
|
||||||
synFontChanged();
|
synFontChanged();
|
||||||
qDebug()<<"init SynEdit: done";
|
|
||||||
|
|
||||||
showCaret();
|
showCaret();
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ const char ValueToChar[28] = {'0', '1', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
|
||||||
Settings* pSettings;
|
Settings* pSettings;
|
||||||
|
|
||||||
Settings::Settings(const QString &filename):
|
Settings::Settings(const QString &filename):
|
||||||
|
mFilename(filename),
|
||||||
mSettings(filename,QSettings::IniFormat),
|
mSettings(filename,QSettings::IniFormat),
|
||||||
mDirs(this),
|
mDirs(this),
|
||||||
mEditor(this),
|
mEditor(this),
|
||||||
|
@ -282,14 +283,24 @@ void Settings::Editor::setCopyWithFormatAs(int copyWithFormatAs)
|
||||||
mCopyWithFormatAs = copyWithFormatAs;
|
mCopyWithFormatAs = copyWithFormatAs;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::Editor::copyHTMLColorSchema() const
|
QString Settings::Editor::colorScheme() const
|
||||||
{
|
{
|
||||||
return mCopyHTMLColorSchema;
|
return mColorScheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::Editor::setCopyHTMLColorSchema(const QString ©HTMLColorSchema)
|
void Settings::Editor::setColorScheme(const QString &colorScheme)
|
||||||
{
|
{
|
||||||
mCopyHTMLColorSchema = copyHTMLColorSchema;
|
mColorScheme = colorScheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Settings::Editor::copyHTMLColorScheme() const
|
||||||
|
{
|
||||||
|
return mCopyHTMLColorScheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::Editor::setCopyHTMLColorScheme(const QString ©HTMLColorScheme)
|
||||||
|
{
|
||||||
|
mCopyHTMLColorScheme = copyHTMLColorScheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::Editor::copyHTMLUseEditorColor() const
|
bool Settings::Editor::copyHTMLUseEditorColor() const
|
||||||
|
@ -312,14 +323,14 @@ void Settings::Editor::setCopyHTMLUseBackground(bool copyHTMLUseBackground)
|
||||||
mCopyHTMLUseBackground = copyHTMLUseBackground;
|
mCopyHTMLUseBackground = copyHTMLUseBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::Editor::copyRTFColorSchema() const
|
QString Settings::Editor::copyRTFColorScheme() const
|
||||||
{
|
{
|
||||||
return mCopyRTFColorSchema;
|
return mCopyRTFColorScheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::Editor::setCopyRTFColorSchema(const QString ©RTFColorSchema)
|
void Settings::Editor::setCopyRTFColorScheme(const QString ©RTFColorScheme)
|
||||||
{
|
{
|
||||||
mCopyRTFColorSchema = copyRTFColorSchema;
|
mCopyRTFColorScheme = copyRTFColorScheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Settings::Editor::copyRTFUseEditorColor() const
|
bool Settings::Editor::copyRTFUseEditorColor() const
|
||||||
|
@ -591,11 +602,14 @@ void Settings::Editor::doSave()
|
||||||
saveValue("copy_line_limits",mCopyLineLimits);
|
saveValue("copy_line_limits",mCopyLineLimits);
|
||||||
saveValue("copy_with_format_as",mCopyWithFormatAs);
|
saveValue("copy_with_format_as",mCopyWithFormatAs);
|
||||||
saveValue("copy_rtf_use_background",mCopyRTFUseBackground);
|
saveValue("copy_rtf_use_background",mCopyRTFUseBackground);
|
||||||
saveValue("copy_rtf_use_editor_color_schema",mCopyRTFUseEditorColor);
|
saveValue("copy_rtf_use_editor_color_scheme",mCopyRTFUseEditorColor);
|
||||||
saveValue("copy_rtf_color_schema",mCopyRTFColorSchema);
|
saveValue("copy_rtf_color_scheme",mCopyRTFColorScheme);
|
||||||
saveValue("copy_html_use_background",mCopyHTMLUseBackground);
|
saveValue("copy_html_use_background",mCopyHTMLUseBackground);
|
||||||
saveValue("copy_html_use_editor_color_schema",mCopyHTMLUseEditorColor);
|
saveValue("copy_html_use_editor_color_scheme",mCopyHTMLUseEditorColor);
|
||||||
saveValue("copy_html_color_schema", mCopyHTMLColorSchema);
|
saveValue("copy_html_color_scheme", mCopyHTMLColorScheme);
|
||||||
|
|
||||||
|
//color scheme
|
||||||
|
saveValue("color_scheme", mColorScheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::Editor::doLoad()
|
void Settings::Editor::doLoad()
|
||||||
|
@ -649,12 +663,14 @@ void Settings::Editor::doLoad()
|
||||||
mCopyLineLimits = intValue("copy_line_limits",100000);
|
mCopyLineLimits = intValue("copy_line_limits",100000);
|
||||||
mCopyWithFormatAs = intValue("copy_with_format_as",0);
|
mCopyWithFormatAs = intValue("copy_with_format_as",0);
|
||||||
mCopyRTFUseBackground = boolValue("copy_rtf_use_background",false);
|
mCopyRTFUseBackground = boolValue("copy_rtf_use_background",false);
|
||||||
mCopyRTFUseEditorColor = boolValue("copy_rtf_use_editor_color_schema",true);
|
mCopyRTFUseEditorColor = boolValue("copy_rtf_use_editor_color_scheme",true);
|
||||||
mCopyRTFColorSchema = stringValue("copy_rtf_color_schema","");
|
mCopyRTFColorScheme = stringValue("copy_rtf_color_scheme","");
|
||||||
mCopyHTMLUseBackground = boolValue("copy_html_use_background",false);
|
mCopyHTMLUseBackground = boolValue("copy_html_use_background",false);
|
||||||
mCopyHTMLUseEditorColor = boolValue("copy_html_use_editor_color_schema",true);
|
mCopyHTMLUseEditorColor = boolValue("copy_html_use_editor_color_scheme",true);
|
||||||
mCopyHTMLColorSchema = stringValue("copy_html_color_schema","");
|
mCopyHTMLColorScheme = stringValue("copy_html_color_scheme","");
|
||||||
|
|
||||||
|
//color
|
||||||
|
mColorScheme = stringValue("color_scheme", "VS Code");
|
||||||
}
|
}
|
||||||
|
|
||||||
SynEditCaretType Settings::Editor::caretForOverwrite() const
|
SynEditCaretType Settings::Editor::caretForOverwrite() const
|
||||||
|
|
|
@ -200,8 +200,8 @@ public:
|
||||||
bool copyRTFUseEditorColor() const;
|
bool copyRTFUseEditorColor() const;
|
||||||
void setCopyRTFUseEditorColor(bool copyRTFUseEditorColor);
|
void setCopyRTFUseEditorColor(bool copyRTFUseEditorColor);
|
||||||
|
|
||||||
QString copyRTFColorSchema() const;
|
QString copyRTFColorScheme() const;
|
||||||
void setCopyRTFColorSchema(const QString ©RTFColorSchema);
|
void setCopyRTFColorScheme(const QString ©RTFColorScheme);
|
||||||
|
|
||||||
bool copyHTMLUseBackground() const;
|
bool copyHTMLUseBackground() const;
|
||||||
void setCopyHTMLUseBackground(bool copyHTMLUseBackground);
|
void setCopyHTMLUseBackground(bool copyHTMLUseBackground);
|
||||||
|
@ -209,12 +209,15 @@ public:
|
||||||
bool copyHTMLUseEditorColor() const;
|
bool copyHTMLUseEditorColor() const;
|
||||||
void setCopyHTMLUseEditorColor(bool copyHTMLUseEditorColor);
|
void setCopyHTMLUseEditorColor(bool copyHTMLUseEditorColor);
|
||||||
|
|
||||||
QString copyHTMLColorSchema() const;
|
QString copyHTMLColorScheme() const;
|
||||||
void setCopyHTMLColorSchema(const QString ©HTMLColorSchema);
|
void setCopyHTMLColorScheme(const QString ©HTMLColorScheme);
|
||||||
|
|
||||||
int copyWithFormatAs() const;
|
int copyWithFormatAs() const;
|
||||||
void setCopyWithFormatAs(int copyWithFormatAs);
|
void setCopyWithFormatAs(int copyWithFormatAs);
|
||||||
|
|
||||||
|
QString colorScheme() const;
|
||||||
|
void setColorScheme(const QString &colorScheme);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QByteArray mDefaultEncoding;
|
QByteArray mDefaultEncoding;
|
||||||
//General
|
//General
|
||||||
|
@ -266,10 +269,13 @@ public:
|
||||||
int mCopyWithFormatAs;
|
int mCopyWithFormatAs;
|
||||||
bool mCopyRTFUseBackground;
|
bool mCopyRTFUseBackground;
|
||||||
bool mCopyRTFUseEditorColor;
|
bool mCopyRTFUseEditorColor;
|
||||||
QString mCopyRTFColorSchema;
|
QString mCopyRTFColorScheme;
|
||||||
bool mCopyHTMLUseBackground;
|
bool mCopyHTMLUseBackground;
|
||||||
bool mCopyHTMLUseEditorColor;
|
bool mCopyHTMLUseEditorColor;
|
||||||
QString mCopyHTMLColorSchema;
|
QString mCopyHTMLColorScheme;
|
||||||
|
|
||||||
|
//Color
|
||||||
|
QString mColorScheme;
|
||||||
|
|
||||||
// _Base interface
|
// _Base interface
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -21,7 +21,7 @@ void EditorClipboardWidget::doLoad()
|
||||||
{
|
{
|
||||||
//pSettings->editor().load();
|
//pSettings->editor().load();
|
||||||
//copy
|
//copy
|
||||||
QString mCopyHTMLColorSchema;
|
QString mCopyHTMLColorScheme;
|
||||||
|
|
||||||
ui->grpCopySizeLimit->setChecked(pSettings->editor().copySizeLimit());
|
ui->grpCopySizeLimit->setChecked(pSettings->editor().copySizeLimit());
|
||||||
ui->spinCopyCharLimits->setValue(pSettings->editor().copyCharLimits());
|
ui->spinCopyCharLimits->setValue(pSettings->editor().copyCharLimits());
|
||||||
|
@ -31,11 +31,11 @@ void EditorClipboardWidget::doLoad()
|
||||||
ui->chkCopyRTFUseBackground->setChecked(pSettings->editor().copyRTFUseBackground());
|
ui->chkCopyRTFUseBackground->setChecked(pSettings->editor().copyRTFUseBackground());
|
||||||
ui->chkCopyRTFUseEditorColor->setChecked(pSettings->editor().copyRTFUseEditorColor());
|
ui->chkCopyRTFUseEditorColor->setChecked(pSettings->editor().copyRTFUseEditorColor());
|
||||||
//todo
|
//todo
|
||||||
//ui->cbCopyRTFColorSchema
|
//ui->cbCopyRTFColorScheme
|
||||||
ui->chkCopyHTMLUseBackground->setChecked(pSettings->editor().copyHTMLUseBackground());
|
ui->chkCopyHTMLUseBackground->setChecked(pSettings->editor().copyHTMLUseBackground());
|
||||||
ui->chkCopyHTMLUseEditorColor->setChecked(pSettings->editor().copyHTMLUseEditorColor());
|
ui->chkCopyHTMLUseEditorColor->setChecked(pSettings->editor().copyHTMLUseEditorColor());
|
||||||
//todo
|
//todo
|
||||||
//ui->cbCopyHTMLColorSchema
|
//ui->cbCopyHTMLColorScheme
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>429</height>
|
<height>470</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -150,7 +150,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="chkCopyHTMLUseEditorColor">
|
<widget class="QCheckBox" name="chkCopyHTMLUseEditorColor">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Use editor's color schema</string>
|
<string>Use editor's color scheme</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -172,12 +172,12 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="label_5">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Color schema</string>
|
<string>Color scheme</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="cbCopyHTMLColorSchema"/>
|
<widget class="QComboBox" name="cbHTMLColorScheme"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_3">
|
<spacer name="horizontalSpacer_3">
|
||||||
|
@ -217,7 +217,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="chkCopyRTFUseEditorColor">
|
<widget class="QCheckBox" name="chkCopyRTFUseEditorColor">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Use editor's color schema</string>
|
<string>Use editor's color scheme</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -239,12 +239,12 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Color schema</string>
|
<string>Color scheme</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="cbCopyRTFColorSchema"/>
|
<widget class="QComboBox" name="cbRTFColorScheme"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_2">
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
#include "ui_editorcolorschemewidget.h"
|
#include "ui_editorcolorschemewidget.h"
|
||||||
#include "../settings.h"
|
#include "../settings.h"
|
||||||
#include "../colorscheme.h"
|
#include "../colorscheme.h"
|
||||||
|
#include "../mainwindow.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QString& group, QWidget *parent) :
|
EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QString& group, QWidget *parent) :
|
||||||
SettingsWidget(name,group,parent),
|
SettingsWidget(name,group,parent),
|
||||||
|
@ -9,8 +13,18 @@ EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QStr
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
mDefaultSchemeComboFont = ui->cbScheme->font();
|
||||||
|
mModifiedSchemeComboFont = mDefaultSchemeComboFont;
|
||||||
|
mModifiedSchemeComboFont.setBold(true);
|
||||||
|
int schemeCount=0;
|
||||||
for (QString schemeName: pColorManager->getSchemes()) {
|
for (QString schemeName: pColorManager->getSchemes()) {
|
||||||
|
PColorScheme scheme = pColorManager->get(schemeName);
|
||||||
|
if (!scheme)
|
||||||
|
return;
|
||||||
ui->cbScheme->addItem(schemeName);
|
ui->cbScheme->addItem(schemeName);
|
||||||
|
if (scheme->customed())
|
||||||
|
ui->cbScheme->setItemData(schemeCount,mModifiedSchemeComboFont,Qt::FontRole);
|
||||||
|
schemeCount++;
|
||||||
}
|
}
|
||||||
ui->treeItems->setModel(&mDefinesModel);
|
ui->treeItems->setModel(&mDefinesModel);
|
||||||
mDefinesModel.setHorizontalHeaderLabels(QStringList());
|
mDefinesModel.setHorizontalHeaderLabels(QStringList());
|
||||||
|
@ -18,29 +32,17 @@ EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QStr
|
||||||
addDefine(defineName, pColorManager->getDefine(defineName));
|
addDefine(defineName, pColorManager->getDefine(defineName));
|
||||||
}
|
}
|
||||||
ui->treeItems->expandAll();
|
ui->treeItems->expandAll();
|
||||||
connect(ui->treeItems->selectionModel(), &QItemSelectionModel::selectionChanged,
|
|
||||||
this, &EditorColorSchemeWidget::onItemSelectionChanged);
|
|
||||||
connect(this, &SettingsWidget::settingsChanged,this,
|
|
||||||
&EditorColorSchemeWidget::onSettingChanged);
|
|
||||||
connect(ui->cbBackground,&QCheckBox::stateChanged,
|
|
||||||
this, &EditorColorSchemeWidget::onBackgroundChanged);
|
|
||||||
connect(ui->colorBackground,&ColorEdit::colorChanged,
|
|
||||||
this, &EditorColorSchemeWidget::onBackgroundChanged);
|
|
||||||
connect(ui->cbForeground,&QCheckBox::stateChanged,
|
|
||||||
this, &EditorColorSchemeWidget::onForegroundChanged);
|
|
||||||
connect(ui->colorForeground,&ColorEdit::colorChanged,
|
|
||||||
this, &EditorColorSchemeWidget::onForegroundChanged);
|
|
||||||
connect(ui->cbBold,&QCheckBox::stateChanged,
|
|
||||||
this, &EditorColorSchemeWidget::onFontStyleChanged);
|
|
||||||
connect(ui->cbItalic,&QCheckBox::stateChanged,
|
|
||||||
this, &EditorColorSchemeWidget::onFontStyleChanged);
|
|
||||||
connect(ui->cbStrikeout,&QCheckBox::stateChanged,
|
|
||||||
this, &EditorColorSchemeWidget::onFontStyleChanged);
|
|
||||||
connect(ui->cbUnderlined,&QCheckBox::stateChanged,
|
|
||||||
this, &EditorColorSchemeWidget::onFontStyleChanged);
|
|
||||||
QModelIndex groupIndex = mDefinesModel.index(0,0);
|
QModelIndex groupIndex = mDefinesModel.index(0,0);
|
||||||
QModelIndex index = mDefinesModel.index(0,0,groupIndex);
|
QModelIndex index = mDefinesModel.index(0,0,groupIndex);
|
||||||
ui->treeItems->setCurrentIndex(index);
|
ui->treeItems->setCurrentIndex(index);
|
||||||
|
connect(ui->treeItems->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onItemSelectionChanged);
|
||||||
|
connect(ui->cbScheme, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
|
this, &EditorColorSchemeWidget::changeSchemeComboFont);
|
||||||
|
connect(ui->cbScheme, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
|
this, &EditorColorSchemeWidget::onItemSelectionChanged);
|
||||||
|
connect(this, &SettingsWidget::settingsChanged,this,
|
||||||
|
&EditorColorSchemeWidget::onSettingChanged);
|
||||||
ui->editDemo->lines()->setText(
|
ui->editDemo->lines()->setText(
|
||||||
"#include <iostream>\n"
|
"#include <iostream>\n"
|
||||||
"#include <conio.h>\n"
|
"#include <conio.h>\n"
|
||||||
|
@ -62,6 +64,7 @@ EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QStr
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
ui->editDemo->setReadOnly(true);
|
ui->editDemo->setReadOnly(true);
|
||||||
|
onItemSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorColorSchemeWidget::addDefine(const QString& name, PColorSchemeItemDefine define)
|
void EditorColorSchemeWidget::addDefine(const QString& name, PColorSchemeItemDefine define)
|
||||||
|
@ -94,6 +97,63 @@ PColorScheme EditorColorSchemeWidget::getCurrentScheme()
|
||||||
return pColorManager->get(ui->cbScheme->currentText());
|
return pColorManager->get(ui->cbScheme->currentText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorColorSchemeWidget::connectModificationSlots()
|
||||||
|
{
|
||||||
|
connect(ui->cbBackground,&QCheckBox::stateChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onBackgroundChanged);
|
||||||
|
connect(ui->colorBackground,&ColorEdit::colorChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onBackgroundChanged);
|
||||||
|
connect(ui->cbForeground,&QCheckBox::stateChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onForegroundChanged);
|
||||||
|
connect(ui->colorForeground,&ColorEdit::colorChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onForegroundChanged);
|
||||||
|
connect(ui->cbBold,&QCheckBox::stateChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onFontStyleChanged);
|
||||||
|
connect(ui->cbItalic,&QCheckBox::stateChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onFontStyleChanged);
|
||||||
|
connect(ui->cbStrikeout,&QCheckBox::stateChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onFontStyleChanged);
|
||||||
|
connect(ui->cbUnderlined,&QCheckBox::stateChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onFontStyleChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorColorSchemeWidget::disconnectModificationSlots()
|
||||||
|
{
|
||||||
|
disconnect(ui->cbBackground,&QCheckBox::stateChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onBackgroundChanged);
|
||||||
|
disconnect(ui->colorBackground,&ColorEdit::colorChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onBackgroundChanged);
|
||||||
|
disconnect(ui->cbForeground,&QCheckBox::stateChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onForegroundChanged);
|
||||||
|
disconnect(ui->colorForeground,&ColorEdit::colorChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onForegroundChanged);
|
||||||
|
disconnect(ui->cbBold,&QCheckBox::stateChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onFontStyleChanged);
|
||||||
|
disconnect(ui->cbItalic,&QCheckBox::stateChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onFontStyleChanged);
|
||||||
|
disconnect(ui->cbStrikeout,&QCheckBox::stateChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onFontStyleChanged);
|
||||||
|
disconnect(ui->cbUnderlined,&QCheckBox::stateChanged,
|
||||||
|
this, &EditorColorSchemeWidget::onFontStyleChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorColorSchemeWidget::setCurrentSchemeModified()
|
||||||
|
{
|
||||||
|
PColorScheme scheme = getCurrentScheme();
|
||||||
|
if (scheme) {
|
||||||
|
scheme->setCustomed(true);
|
||||||
|
}
|
||||||
|
if (mModifiedSchemes.contains(ui->cbScheme->currentText()))
|
||||||
|
return;
|
||||||
|
mModifiedSchemes.insert(ui->cbScheme->currentText());
|
||||||
|
ui->cbScheme->setItemData(ui->cbScheme->currentIndex(),
|
||||||
|
mModifiedSchemeComboFont,Qt::FontRole);
|
||||||
|
ui->cbScheme->setFont(mModifiedSchemeComboFont);
|
||||||
|
ui->cbScheme->view()->setFont(mDefaultSchemeComboFont);
|
||||||
|
//we must reset the editor here, because this slot is processed after the onSettingChanged
|
||||||
|
onSettingChanged();
|
||||||
|
}
|
||||||
|
|
||||||
EditorColorSchemeWidget::~EditorColorSchemeWidget()
|
EditorColorSchemeWidget::~EditorColorSchemeWidget()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
|
@ -112,6 +172,7 @@ static void setColorProp(ColorEdit* ce, QCheckBox* cb, const QColor& color) {
|
||||||
|
|
||||||
void EditorColorSchemeWidget::onItemSelectionChanged()
|
void EditorColorSchemeWidget::onItemSelectionChanged()
|
||||||
{
|
{
|
||||||
|
disconnectModificationSlots();
|
||||||
QItemSelectionModel * selectionModel = ui->treeItems->selectionModel();
|
QItemSelectionModel * selectionModel = ui->treeItems->selectionModel();
|
||||||
QString name =mDefinesModel.data(selectionModel->currentIndex(),NameRole).toString();
|
QString name =mDefinesModel.data(selectionModel->currentIndex(),NameRole).toString();
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
@ -150,8 +211,9 @@ void EditorColorSchemeWidget::onItemSelectionChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// not found
|
|
||||||
ui->widgetSchemeItem->setEnabled(found);
|
ui->widgetSchemeItem->setEnabled(found);
|
||||||
|
connectModificationSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorColorSchemeWidget::onSettingChanged()
|
void EditorColorSchemeWidget::onSettingChanged()
|
||||||
|
@ -169,10 +231,7 @@ void EditorColorSchemeWidget::onForegroundChanged()
|
||||||
} else {
|
} else {
|
||||||
item->setForeground(QColor());
|
item->setForeground(QColor());
|
||||||
}
|
}
|
||||||
PColorScheme scheme = getCurrentScheme();
|
setCurrentSchemeModified();
|
||||||
if (scheme) {
|
|
||||||
scheme->setCustomed(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorColorSchemeWidget::onBackgroundChanged()
|
void EditorColorSchemeWidget::onBackgroundChanged()
|
||||||
|
@ -185,10 +244,7 @@ void EditorColorSchemeWidget::onBackgroundChanged()
|
||||||
} else {
|
} else {
|
||||||
item->setBackground(QColor());
|
item->setBackground(QColor());
|
||||||
}
|
}
|
||||||
PColorScheme scheme = getCurrentScheme();
|
setCurrentSchemeModified();
|
||||||
if (scheme) {
|
|
||||||
scheme->setCustomed(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorColorSchemeWidget::onFontStyleChanged()
|
void EditorColorSchemeWidget::onFontStyleChanged()
|
||||||
|
@ -200,18 +256,67 @@ void EditorColorSchemeWidget::onFontStyleChanged()
|
||||||
item->setItalic(ui->cbItalic->isChecked());
|
item->setItalic(ui->cbItalic->isChecked());
|
||||||
item->setStrikeout(ui->cbStrikeout->isChecked());
|
item->setStrikeout(ui->cbStrikeout->isChecked());
|
||||||
item->setUnderlined(ui->cbUnderlined->isChecked());
|
item->setUnderlined(ui->cbUnderlined->isChecked());
|
||||||
PColorScheme scheme = getCurrentScheme();
|
setCurrentSchemeModified();
|
||||||
if (scheme) {
|
}
|
||||||
scheme->setCustomed(true);
|
|
||||||
|
void EditorColorSchemeWidget::changeSchemeComboFont()
|
||||||
|
{
|
||||||
|
QString name = ui->cbScheme->currentText();
|
||||||
|
PColorScheme scheme = pColorManager->get(name);
|
||||||
|
if (scheme && scheme->customed()) {
|
||||||
|
ui->cbScheme->setFont(mModifiedSchemeComboFont);
|
||||||
|
} else {
|
||||||
|
ui->cbScheme->setFont(mDefaultSchemeComboFont);
|
||||||
}
|
}
|
||||||
|
ui->cbScheme->view()->setFont(mDefaultSchemeComboFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorColorSchemeWidget::doLoad()
|
void EditorColorSchemeWidget::doLoad()
|
||||||
{
|
{
|
||||||
|
ui->cbScheme->setCurrentText(pSettings->editor().colorScheme());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorColorSchemeWidget::doSave()
|
void EditorColorSchemeWidget::doSave()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
for (QString name:mModifiedSchemes) {
|
||||||
|
pColorManager->saveScheme(name);
|
||||||
|
}
|
||||||
|
pSettings->editor().setColorScheme(ui->cbScheme->currentText());
|
||||||
|
pSettings->editor().save();
|
||||||
|
pMainWindow->updateEditorColorSchemes();
|
||||||
|
} catch (FileError e) {
|
||||||
|
QMessageBox::information(this,tr("Error"),e.reason());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorColorSchemeWidget::on_actionCopy_Scheme_triggered()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorColorSchemeWidget::on_btnSchemeMenu_pressed()
|
||||||
|
{
|
||||||
|
QMenu menu;
|
||||||
|
|
||||||
|
PColorScheme scheme = pColorManager->get(ui->cbScheme->currentText());
|
||||||
|
if (scheme) {
|
||||||
|
if (scheme->customed()) {
|
||||||
|
menu.addAction(ui->actionReset_Scheme);
|
||||||
|
}
|
||||||
|
if (!scheme->bundled()) {
|
||||||
|
menu.addAction(ui->actionRename_Scheme);
|
||||||
|
menu.addAction(ui->actionDelete_Scheme);
|
||||||
|
}
|
||||||
|
menu.addAction(ui->actionCopy_Scheme);
|
||||||
|
menu.addAction(ui->actionExport_Scheme);
|
||||||
|
menu.addSeparator();
|
||||||
|
}
|
||||||
|
menu.addAction(ui->actionImport_Scheme);
|
||||||
|
QPoint p;
|
||||||
|
p.setX(0);
|
||||||
|
p.setY(ui->btnSchemeMenu->height()+2);
|
||||||
|
QAction* action = menu.exec(ui->btnSchemeMenu->mapToGlobal(p));
|
||||||
|
if (action)
|
||||||
|
action->trigger();
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "settingswidget.h"
|
#include "settingswidget.h"
|
||||||
#include "../colorscheme.h"
|
#include "../colorscheme.h"
|
||||||
|
|
||||||
|
#include <QMenu>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
@ -27,21 +28,32 @@ public slots:
|
||||||
void onForegroundChanged();
|
void onForegroundChanged();
|
||||||
void onBackgroundChanged();
|
void onBackgroundChanged();
|
||||||
void onFontStyleChanged();
|
void onFontStyleChanged();
|
||||||
|
void changeSchemeComboFont();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addDefine(const QString& name, PColorSchemeItemDefine define);
|
void addDefine(const QString& name, PColorSchemeItemDefine define);
|
||||||
PColorSchemeItem getCurrentItem();
|
PColorSchemeItem getCurrentItem();
|
||||||
PColorScheme getCurrentScheme();
|
PColorScheme getCurrentScheme();
|
||||||
|
void connectModificationSlots();
|
||||||
|
void disconnectModificationSlots();
|
||||||
|
void setCurrentSchemeModified();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::EditorColorSchemeWidget *ui;
|
Ui::EditorColorSchemeWidget *ui;
|
||||||
QStandardItemModel mDefinesModel;
|
QStandardItemModel mDefinesModel;
|
||||||
|
QFont mDefaultSchemeComboFont;
|
||||||
|
QFont mModifiedSchemeComboFont;
|
||||||
|
QSet<QString> mModifiedSchemes;
|
||||||
|
QMenu mMenu;
|
||||||
|
|
||||||
// SettingsWidget interface
|
// SettingsWidget interface
|
||||||
protected:
|
protected:
|
||||||
void doLoad() override;
|
void doLoad() override;
|
||||||
void doSave() override;
|
void doSave() override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_actionCopy_Scheme_triggered();
|
||||||
|
void on_btnSchemeMenu_pressed();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EDITORCOLORSCHEMEWIDGET_H
|
#endif // EDITORCOLORSCHEMEWIDGET_H
|
||||||
|
|
|
@ -46,10 +46,10 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="cbScheme"/>
|
<widget class="QPatchedComboBox" name="cbScheme"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="toolButton">
|
<widget class="QToolButton" name="btnSchemeMenu">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>...</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -108,7 +108,16 @@
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>1</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>7</number>
|
||||||
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -124,7 +133,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="treeItems">
|
<widget class="QTreeView" name="treeItems">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
|
@ -171,6 +180,12 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="ColorEdit" name="colorForeground">
|
<widget class="ColorEdit" name="colorForeground">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -179,8 +194,27 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="ColorEdit" name="colorBackground">
|
<widget class="ColorEdit" name="colorBackground">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -189,7 +223,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1" colspan="2">
|
<item row="2" column="1">
|
||||||
<widget class="QGroupBox" name="grpFontStyles">
|
<widget class="QGroupBox" name="grpFontStyles">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Font Styles</string>
|
<string>Font Styles</string>
|
||||||
|
@ -223,35 +257,9 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -260,7 +268,7 @@
|
||||||
<widget class="Editor" name="editDemo">
|
<widget class="Editor" name="editDemo">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>2</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
@ -277,6 +285,36 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
<action name="actionCopy_Scheme">
|
||||||
|
<property name="text">
|
||||||
|
<string>Duplicate...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionRename_Scheme">
|
||||||
|
<property name="text">
|
||||||
|
<string>Rename...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionReset_Scheme">
|
||||||
|
<property name="text">
|
||||||
|
<string>Restore to Default</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionImport_Scheme">
|
||||||
|
<property name="text">
|
||||||
|
<string>Import Scheme...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionExport_Scheme">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionDelete_Scheme">
|
||||||
|
<property name="text">
|
||||||
|
<string>Delete...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
@ -291,6 +329,11 @@
|
||||||
<header location="global">editor.h</header>
|
<header location="global">editor.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>QPatchedComboBox</class>
|
||||||
|
<extends>QComboBox</extends>
|
||||||
|
<header location="global">widgets/qpatchedcombobox.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
@ -46,7 +46,7 @@ QSize ColorEdit::sizeHint() const
|
||||||
{
|
{
|
||||||
QRect rect = fontMetrics().boundingRect(mColor.name());
|
QRect rect = fontMetrics().boundingRect(mColor.name());
|
||||||
return QSize{rect.width()+ 10,
|
return QSize{rect.width()+ 10,
|
||||||
rect.width()+ 6 };
|
rect.height()+ 6 };
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorEdit::paintEvent(QPaintEvent *event)
|
void ColorEdit::paintEvent(QPaintEvent *event)
|
||||||
|
@ -56,7 +56,6 @@ void ColorEdit::paintEvent(QPaintEvent *event)
|
||||||
painter.fillRect(rect,mColor);
|
painter.fillRect(rect,mColor);
|
||||||
painter.setPen(contrast());
|
painter.setPen(contrast());
|
||||||
painter.drawText(rect,Qt::AlignCenter, mColor.name());
|
painter.drawText(rect,Qt::AlignCenter, mColor.name());
|
||||||
qDebug()<<rect<<mColor<<contrast();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ColorEdit::mouseReleaseEvent(QMouseEvent *event)
|
void ColorEdit::mouseReleaseEvent(QMouseEvent *event)
|
||||||
|
@ -76,3 +75,10 @@ void ColorEdit::leaveEvent(QEvent *event)
|
||||||
{
|
{
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSize ColorEdit::minimumSizeHint() const
|
||||||
|
{
|
||||||
|
QRect rect = fontMetrics().boundingRect(mColor.name());
|
||||||
|
return QSize{rect.width(),
|
||||||
|
rect.height()};
|
||||||
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
void mouseReleaseEvent(QMouseEvent *event) override;
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
||||||
void enterEvent(QEvent *event) override;
|
void enterEvent(QEvent *event) override;
|
||||||
void leaveEvent(QEvent *event) override;
|
void leaveEvent(QEvent *event) override;
|
||||||
|
QSize minimumSizeHint() const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COLOREDIT_H
|
#endif // COLOREDIT_H
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include "qpatchedcombobox.h"
|
||||||
|
|
||||||
|
QPatchedComboBox::QPatchedComboBox(QWidget *parent):
|
||||||
|
QComboBox(parent)
|
||||||
|
{
|
||||||
|
setView(new QPatchedComboBoxListView(this));
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
#ifndef QPATCHEDCOMBOBOX_H
|
||||||
|
#define QPATCHEDCOMBOBOX_H
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QListView>
|
||||||
|
#include <QPaintEvent>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
class QPatchedComboBoxListView : public QListView
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
QPatchedComboBoxListView(QComboBox *cmb = nullptr) : combo(cmb) {}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void resizeEvent(QResizeEvent *event) override
|
||||||
|
{
|
||||||
|
resizeContents(viewport()->width(), contentsSize().height());
|
||||||
|
QListView::resizeEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStyleOptionViewItem viewOptions() const override
|
||||||
|
{
|
||||||
|
QStyleOptionViewItem option = QListView::viewOptions();
|
||||||
|
option.showDecorationSelected = true;
|
||||||
|
// if (combo)
|
||||||
|
// option.font = combo->font();
|
||||||
|
return option;
|
||||||
|
}
|
||||||
|
|
||||||
|
void paintEvent(QPaintEvent *e) override
|
||||||
|
{
|
||||||
|
if (combo) {
|
||||||
|
QStyleOptionComboBox opt;
|
||||||
|
opt.initFrom(combo);
|
||||||
|
opt.editable = combo->isEditable();
|
||||||
|
if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)) {
|
||||||
|
//we paint the empty menu area to avoid having blank space that can happen when scrolling
|
||||||
|
QStyleOptionMenuItem menuOpt;
|
||||||
|
menuOpt.initFrom(this);
|
||||||
|
menuOpt.palette = palette();
|
||||||
|
menuOpt.state = QStyle::State_None;
|
||||||
|
menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
|
||||||
|
menuOpt.menuRect = e->rect();
|
||||||
|
menuOpt.maxIconWidth = 0;
|
||||||
|
menuOpt.tabWidth = 0;
|
||||||
|
QPainter p(viewport());
|
||||||
|
combo->style()->drawControl(QStyle::CE_MenuEmptyArea, &menuOpt, &p, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QListView::paintEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QComboBox *combo;
|
||||||
|
};
|
||||||
|
|
||||||
|
class QPatchedComboBox : public QComboBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit QPatchedComboBox(QWidget *parent = nullptr);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // QPATCHEDCOMBOBOX_H
|
Loading…
Reference in New Issue