* work save: color scheme options
This commit is contained in:
parent
9390545641
commit
021873a9d6
|
@ -46,7 +46,8 @@ SOURCES += \
|
|||
systemconsts.cpp \
|
||||
utils.cpp \
|
||||
widgets/coloredit.cpp \
|
||||
widgets/issuestable.cpp
|
||||
widgets/issuestable.cpp \
|
||||
widgets/qpatchedcombobox.cpp
|
||||
|
||||
HEADERS += \
|
||||
HighlighterManager.h \
|
||||
|
@ -87,7 +88,8 @@ HEADERS += \
|
|||
utils.h \
|
||||
common.h \
|
||||
widgets/coloredit.h \
|
||||
widgets/issuestable.h
|
||||
widgets/issuestable.h \
|
||||
widgets/qpatchedcombobox.h
|
||||
|
||||
FORMS += \
|
||||
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);
|
||||
}
|
||||
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());
|
||||
}
|
||||
return ColorScheme::fromJson(doc.object());
|
||||
|
@ -68,8 +68,10 @@ QMap<QString, PColorSchemeItem> ColorScheme::items()
|
|||
void ColorScheme::save(const QString &filename)
|
||||
{
|
||||
QFile file(filename);
|
||||
QFileInfo info(filename);
|
||||
info.dir().mkpath(info.dir().absolutePath());
|
||||
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;
|
||||
toJson(json);
|
||||
|
@ -249,11 +251,11 @@ void ColorManager::reload()
|
|||
{
|
||||
mSchemes.clear();
|
||||
//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)
|
||||
loadSchemesInDir(pSettings->dirs().config(Settings::Dirs::DataType::ColorSheme),false);
|
||||
loadSchemesInDir(pSettings->dirs().config(Settings::Dirs::DataType::ColorSheme),false,false);
|
||||
//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)
|
||||
|
@ -309,15 +311,16 @@ QString ColorManager::generateFilename(const QString &name, bool isCustomed)
|
|||
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);
|
||||
dir.setFilter(QDir::Files);
|
||||
QFileInfoList list = dir.entryInfoList();
|
||||
QString suffix;
|
||||
QString customSuffix = EXT_PREFIX_CUSTOM;
|
||||
customSuffix += EXT_COLOR_SCHEME;
|
||||
if (isCustomed) {
|
||||
suffix = EXT_PREFIX_CUSTOM;
|
||||
suffix = suffix + EXT_COLOR_SCHEME;
|
||||
suffix = customSuffix;
|
||||
} else {
|
||||
suffix = EXT_COLOR_SCHEME;
|
||||
}
|
||||
|
@ -325,9 +328,25 @@ void ColorManager::loadSchemesInDir(const QString &dirName, bool isCustomed)
|
|||
QFileInfo fileInfo = list[i];
|
||||
QString name = fileInfo.fileName();
|
||||
if (name.toLower().endsWith(suffix)) {
|
||||
if (!isCustomed && name.toLower().endsWith(customSuffix))
|
||||
continue;
|
||||
PColorScheme scheme = ColorScheme::load(fileInfo.absoluteFilePath());
|
||||
name.remove(name.length()-suffix.length(),suffix.length());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -547,10 +566,19 @@ PColorSchemeItemDefine ColorManager::getDefine(const QString &name)
|
|||
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 filename = generateFilename(name,isCustomed);
|
||||
if (isBundled) {
|
||||
if (isBundled && !isCustomed) {
|
||||
return includeTrailingPathDelimiter(pSettings->dirs().data(Settings::Dirs::DataType::ColorSheme))+filename;
|
||||
} else {
|
||||
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);
|
||||
bool removeDefine(const QString &name);
|
||||
PColorSchemeItemDefine getDefine(const QString& name);
|
||||
bool saveScheme(const QString &name);
|
||||
private:
|
||||
QString generateFullPathname(const QString& name, bool isBundled, 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();
|
||||
private:
|
||||
QMap<QString,PColorSchemeItemDefine> mSchemeItemDefines;
|
||||
|
|
|
@ -49,11 +49,11 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
|||
bool inProject, bool isNew,
|
||||
QTabWidget* parentPageControl):
|
||||
SynEdit(parent),
|
||||
mFilename(filename),
|
||||
mEncodingOption(encoding),
|
||||
mFilename(filename),
|
||||
mParentPageControl(parentPageControl),
|
||||
mInProject(inProject),
|
||||
mIsNew(isNew),
|
||||
mParentPageControl(parentPageControl)
|
||||
mIsNew(isNew)
|
||||
{
|
||||
if (mFilename.isEmpty()) {
|
||||
newfileCount++;
|
||||
|
@ -84,6 +84,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
|
|||
}
|
||||
|
||||
applySettings();
|
||||
applyColorScheme(pSettings->editor().colorScheme());
|
||||
|
||||
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) {
|
||||
beginUpdate();
|
||||
auto end = finally([this] {
|
||||
|
|
|
@ -39,6 +39,7 @@ public:
|
|||
void beginUpdate();
|
||||
void endUpdate();
|
||||
void applySettings();
|
||||
void applyColorSchemes(const QString& name);
|
||||
|
||||
private:
|
||||
QTabWidget* getNewEditorPageControl() const;
|
||||
|
|
|
@ -63,17 +63,18 @@ int main(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
auto settings = std::unique_ptr<Settings>(pSettings);
|
||||
settings->environment().load();
|
||||
settings->compilerSets().loadSets();
|
||||
settings->editor().load();
|
||||
settings->environment().load();
|
||||
|
||||
pColorManager = new ColorManager();
|
||||
|
||||
//load translations
|
||||
//Translation must be loaded after language setting is loaded
|
||||
QTranslator trans;
|
||||
trans.load("RedPandaIDE_"+pSettings->environment().language(),":/translations");
|
||||
app.installTranslator(&trans);
|
||||
|
||||
//Color scheme settings must be loaded after translation
|
||||
pColorManager = new ColorManager();
|
||||
|
||||
MainWindow mainWindow;
|
||||
pMainWindow = &mainWindow;
|
||||
mainWindow.show();
|
||||
|
|
|
@ -157,6 +157,11 @@ void MainWindow::updateEditorActions()
|
|||
|
||||
}
|
||||
|
||||
void MainWindow::updateEditorColorSchemes()
|
||||
{
|
||||
mEditorList->applyColorSchemes(pSettings->editor().colorScheme());
|
||||
}
|
||||
|
||||
void MainWindow::applySettings()
|
||||
{
|
||||
changeTheme(pSettings->environment().theme());
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
void updateForStatusbarModeInfo();
|
||||
void updateEditorSettings();
|
||||
void updateEditorActions();
|
||||
void updateEditorColorSchemes();
|
||||
|
||||
void applySettings();
|
||||
|
||||
|
|
|
@ -159,31 +159,18 @@ void SynEditKeyStrokes::clear()
|
|||
|
||||
void SynEditKeyStrokes::resetDefaults()
|
||||
{
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults ";
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: clear ";
|
||||
clear();
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start ";
|
||||
add(SynEditorCommand::ecUp, Qt::Key_Up, Qt::NoModifier);
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 0";
|
||||
add(SynEditorCommand::ecSelUp, Qt::Key_Up, Qt::ShiftModifier);
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 01";
|
||||
add(SynEditorCommand::ecScrollUp, Qt::Key_Up, Qt::ControlModifier);
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 02";
|
||||
add(SynEditorCommand::ecDown, Qt::Key_Down, Qt::NoModifier);
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 03";
|
||||
add(SynEditorCommand::ecSelDown, Qt::Key_Down, Qt::ShiftModifier);
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 04";
|
||||
add(SynEditorCommand::ecScrollDown, Qt::Key_Down, Qt::ControlModifier);
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 05";
|
||||
add(SynEditorCommand::ecLeft, Qt::Key_Left, Qt::NoModifier);
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 06";
|
||||
add(SynEditorCommand::ecSelLeft, Qt::Key_Left, Qt::ShiftModifier);
|
||||
add(SynEditorCommand::ecWordLeft, Qt::Key_Left, Qt::ControlModifier);
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 1";
|
||||
add(SynEditorCommand::ecSelWordLeft, Qt::Key_Left, Qt::ShiftModifier|Qt::ControlModifier);
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 2 ";
|
||||
add(SynEditorCommand::ecRight, Qt::Key_Right, Qt::NoModifier);
|
||||
qDebug()<<"SynEditKeyStrokes: resetDefaults: add start 3";
|
||||
|
||||
add(SynEditorCommand::ecSelRight, Qt::Key_Right, Qt::ShiftModifier);
|
||||
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::ecLineSelect, Qt::Key_L, 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)
|
||||
{
|
||||
if (mColor!=value) {
|
||||
qDebug()<<"mColor"<<value;
|
||||
mColor = value;
|
||||
setChanged();
|
||||
}
|
||||
|
|
|
@ -19,12 +19,10 @@
|
|||
|
||||
SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
||||
{
|
||||
qDebug()<<"init SynEdit:";
|
||||
mPaintLock = 0;
|
||||
mPainterLock = 0;
|
||||
mPainting = false;
|
||||
mLines = std::make_shared<SynEditStringList>(this);
|
||||
qDebug()<<"init SynEdit: 1";
|
||||
mOrigLines = mLines;
|
||||
//fPlugins := TList.Create;
|
||||
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::inserted, this, &SynEdit::linesInserted);
|
||||
mLines->connect(mLines.get(), &SynEditStringList::putted, this, &SynEdit::linesPutted);
|
||||
qDebug()<<"init SynEdit: 2";
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
mFontDummy = QFont("Consolas",12);
|
||||
|
@ -46,7 +43,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
|||
#endif
|
||||
mFontDummy.setStyleStrategy(QFont::PreferAntialias);
|
||||
setFont(mFontDummy);
|
||||
qDebug()<<"init SynEdit:3";
|
||||
|
||||
mUndoList = std::make_shared<SynEditUndoList>();
|
||||
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->connect(mRedoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::redoAdded);
|
||||
mOrigRedoList = mRedoList;
|
||||
qDebug()<<"init SynEdit: 4";
|
||||
|
||||
mCaretColor = QColorConstants::Red;
|
||||
mActiveLineColor = QColorConstants::Svg::lightblue;
|
||||
|
@ -64,7 +59,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
|||
mBookMarkOpt.connect(&mBookMarkOpt, &SynBookMarkOpt::changed, this, &SynEdit::bookMarkOptionsChanged);
|
||||
// fRightEdge has to be set before FontChanged is called for the first time
|
||||
mRightEdge = 80;
|
||||
qDebug()<<"init SynEdit: 5";
|
||||
|
||||
mGutter.setRightOffset(21);
|
||||
mGutter.connect(&mGutter, &SynGutter::changed, this, &SynEdit::gutterChanged);
|
||||
|
@ -77,7 +71,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
|||
mInserting = true;
|
||||
mScrollBars = SynScrollStyle::ssBoth;
|
||||
mExtraLineSpacing = 0;
|
||||
qDebug()<<"init SynEdit: 6";
|
||||
|
||||
this->setFrameShape(QFrame::Panel);
|
||||
this->setFrameShadow(QFrame::Sunken);
|
||||
|
@ -87,18 +80,14 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
|||
mSelectionMode = SynSelectionMode::smNormal;
|
||||
mActiveSelectionMode = SynSelectionMode::smNormal;
|
||||
mReadOnly = false;
|
||||
qDebug()<<"init SynEdit: 7";
|
||||
|
||||
//stop qt to auto fill background
|
||||
setAutoFillBackground(false);
|
||||
//fFocusList := TList.Create;
|
||||
//fKbdHandler := TSynEditKbdHandler.Create;
|
||||
//fMarkList.OnChange := MarkListChange;
|
||||
qDebug()<<"init SynEdit: 7-1";
|
||||
setDefaultKeystrokes();
|
||||
qDebug()<<"init SynEdit: 7-2";
|
||||
mRightEdgeColor = QColorConstants::Svg::silver;
|
||||
qDebug()<<"init SynEdit: 8";
|
||||
|
||||
/* IME input */
|
||||
mImeCount = 0;
|
||||
|
@ -118,7 +107,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
|||
mOptions = eoAutoIndent | eoAddIndent
|
||||
| eoDragDropEditing | eoEnhanceEndKey | eoTabIndent |
|
||||
eoGroupUndo | eoKeepCaretX | eoSelectWordByDblClick;
|
||||
qDebug()<<"init SynEdit: 9";
|
||||
|
||||
mScrollTimer = new QTimer(this);
|
||||
mScrollTimer->setInterval(100);
|
||||
|
@ -132,10 +120,8 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
|
|||
mUseCodeFolding = true;
|
||||
m_blinkTimerId = 0;
|
||||
m_blinkStatus = 0;
|
||||
qDebug()<<"init SynEdit: 10";
|
||||
|
||||
synFontChanged();
|
||||
qDebug()<<"init SynEdit: done";
|
||||
|
||||
showCaret();
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ const char ValueToChar[28] = {'0', '1', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
|
|||
Settings* pSettings;
|
||||
|
||||
Settings::Settings(const QString &filename):
|
||||
mFilename(filename),
|
||||
mSettings(filename,QSettings::IniFormat),
|
||||
mDirs(this),
|
||||
mEditor(this),
|
||||
|
@ -282,14 +283,24 @@ void Settings::Editor::setCopyWithFormatAs(int 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
|
||||
|
@ -312,14 +323,14 @@ void Settings::Editor::setCopyHTMLUseBackground(bool 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
|
||||
|
@ -591,11 +602,14 @@ void Settings::Editor::doSave()
|
|||
saveValue("copy_line_limits",mCopyLineLimits);
|
||||
saveValue("copy_with_format_as",mCopyWithFormatAs);
|
||||
saveValue("copy_rtf_use_background",mCopyRTFUseBackground);
|
||||
saveValue("copy_rtf_use_editor_color_schema",mCopyRTFUseEditorColor);
|
||||
saveValue("copy_rtf_color_schema",mCopyRTFColorSchema);
|
||||
saveValue("copy_rtf_use_editor_color_scheme",mCopyRTFUseEditorColor);
|
||||
saveValue("copy_rtf_color_scheme",mCopyRTFColorScheme);
|
||||
saveValue("copy_html_use_background",mCopyHTMLUseBackground);
|
||||
saveValue("copy_html_use_editor_color_schema",mCopyHTMLUseEditorColor);
|
||||
saveValue("copy_html_color_schema", mCopyHTMLColorSchema);
|
||||
saveValue("copy_html_use_editor_color_scheme",mCopyHTMLUseEditorColor);
|
||||
saveValue("copy_html_color_scheme", mCopyHTMLColorScheme);
|
||||
|
||||
//color scheme
|
||||
saveValue("color_scheme", mColorScheme);
|
||||
}
|
||||
|
||||
void Settings::Editor::doLoad()
|
||||
|
@ -649,12 +663,14 @@ void Settings::Editor::doLoad()
|
|||
mCopyLineLimits = intValue("copy_line_limits",100000);
|
||||
mCopyWithFormatAs = intValue("copy_with_format_as",0);
|
||||
mCopyRTFUseBackground = boolValue("copy_rtf_use_background",false);
|
||||
mCopyRTFUseEditorColor = boolValue("copy_rtf_use_editor_color_schema",true);
|
||||
mCopyRTFColorSchema = stringValue("copy_rtf_color_schema","");
|
||||
mCopyRTFUseEditorColor = boolValue("copy_rtf_use_editor_color_scheme",true);
|
||||
mCopyRTFColorScheme = stringValue("copy_rtf_color_scheme","");
|
||||
mCopyHTMLUseBackground = boolValue("copy_html_use_background",false);
|
||||
mCopyHTMLUseEditorColor = boolValue("copy_html_use_editor_color_schema",true);
|
||||
mCopyHTMLColorSchema = stringValue("copy_html_color_schema","");
|
||||
mCopyHTMLUseEditorColor = boolValue("copy_html_use_editor_color_scheme",true);
|
||||
mCopyHTMLColorScheme = stringValue("copy_html_color_scheme","");
|
||||
|
||||
//color
|
||||
mColorScheme = stringValue("color_scheme", "VS Code");
|
||||
}
|
||||
|
||||
SynEditCaretType Settings::Editor::caretForOverwrite() const
|
||||
|
|
|
@ -200,8 +200,8 @@ public:
|
|||
bool copyRTFUseEditorColor() const;
|
||||
void setCopyRTFUseEditorColor(bool copyRTFUseEditorColor);
|
||||
|
||||
QString copyRTFColorSchema() const;
|
||||
void setCopyRTFColorSchema(const QString ©RTFColorSchema);
|
||||
QString copyRTFColorScheme() const;
|
||||
void setCopyRTFColorScheme(const QString ©RTFColorScheme);
|
||||
|
||||
bool copyHTMLUseBackground() const;
|
||||
void setCopyHTMLUseBackground(bool copyHTMLUseBackground);
|
||||
|
@ -209,12 +209,15 @@ public:
|
|||
bool copyHTMLUseEditorColor() const;
|
||||
void setCopyHTMLUseEditorColor(bool copyHTMLUseEditorColor);
|
||||
|
||||
QString copyHTMLColorSchema() const;
|
||||
void setCopyHTMLColorSchema(const QString ©HTMLColorSchema);
|
||||
QString copyHTMLColorScheme() const;
|
||||
void setCopyHTMLColorScheme(const QString ©HTMLColorScheme);
|
||||
|
||||
int copyWithFormatAs() const;
|
||||
void setCopyWithFormatAs(int copyWithFormatAs);
|
||||
|
||||
QString colorScheme() const;
|
||||
void setColorScheme(const QString &colorScheme);
|
||||
|
||||
private:
|
||||
QByteArray mDefaultEncoding;
|
||||
//General
|
||||
|
@ -266,10 +269,13 @@ public:
|
|||
int mCopyWithFormatAs;
|
||||
bool mCopyRTFUseBackground;
|
||||
bool mCopyRTFUseEditorColor;
|
||||
QString mCopyRTFColorSchema;
|
||||
QString mCopyRTFColorScheme;
|
||||
bool mCopyHTMLUseBackground;
|
||||
bool mCopyHTMLUseEditorColor;
|
||||
QString mCopyHTMLColorSchema;
|
||||
QString mCopyHTMLColorScheme;
|
||||
|
||||
//Color
|
||||
QString mColorScheme;
|
||||
|
||||
// _Base interface
|
||||
protected:
|
||||
|
|
|
@ -21,7 +21,7 @@ void EditorClipboardWidget::doLoad()
|
|||
{
|
||||
//pSettings->editor().load();
|
||||
//copy
|
||||
QString mCopyHTMLColorSchema;
|
||||
QString mCopyHTMLColorScheme;
|
||||
|
||||
ui->grpCopySizeLimit->setChecked(pSettings->editor().copySizeLimit());
|
||||
ui->spinCopyCharLimits->setValue(pSettings->editor().copyCharLimits());
|
||||
|
@ -31,11 +31,11 @@ void EditorClipboardWidget::doLoad()
|
|||
ui->chkCopyRTFUseBackground->setChecked(pSettings->editor().copyRTFUseBackground());
|
||||
ui->chkCopyRTFUseEditorColor->setChecked(pSettings->editor().copyRTFUseEditorColor());
|
||||
//todo
|
||||
//ui->cbCopyRTFColorSchema
|
||||
//ui->cbCopyRTFColorScheme
|
||||
ui->chkCopyHTMLUseBackground->setChecked(pSettings->editor().copyHTMLUseBackground());
|
||||
ui->chkCopyHTMLUseEditorColor->setChecked(pSettings->editor().copyHTMLUseEditorColor());
|
||||
//todo
|
||||
//ui->cbCopyHTMLColorSchema
|
||||
//ui->cbCopyHTMLColorScheme
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>429</height>
|
||||
<height>470</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -150,7 +150,7 @@
|
|||
<item>
|
||||
<widget class="QCheckBox" name="chkCopyHTMLUseEditorColor">
|
||||
<property name="text">
|
||||
<string>Use editor's color schema</string>
|
||||
<string>Use editor's color scheme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -172,12 +172,12 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Color schema</string>
|
||||
<string>Color scheme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbCopyHTMLColorSchema"/>
|
||||
<widget class="QComboBox" name="cbHTMLColorScheme"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
|
@ -217,7 +217,7 @@
|
|||
<item>
|
||||
<widget class="QCheckBox" name="chkCopyRTFUseEditorColor">
|
||||
<property name="text">
|
||||
<string>Use editor's color schema</string>
|
||||
<string>Use editor's color scheme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -239,12 +239,12 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Color schema</string>
|
||||
<string>Color scheme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbCopyRTFColorSchema"/>
|
||||
<widget class="QComboBox" name="cbRTFColorScheme"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
#include "ui_editorcolorschemewidget.h"
|
||||
#include "../settings.h"
|
||||
#include "../colorscheme.h"
|
||||
#include "../mainwindow.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMessageBox>
|
||||
|
||||
EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QString& group, QWidget *parent) :
|
||||
SettingsWidget(name,group,parent),
|
||||
|
@ -9,8 +13,18 @@ EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QStr
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
mDefaultSchemeComboFont = ui->cbScheme->font();
|
||||
mModifiedSchemeComboFont = mDefaultSchemeComboFont;
|
||||
mModifiedSchemeComboFont.setBold(true);
|
||||
int schemeCount=0;
|
||||
for (QString schemeName: pColorManager->getSchemes()) {
|
||||
PColorScheme scheme = pColorManager->get(schemeName);
|
||||
if (!scheme)
|
||||
return;
|
||||
ui->cbScheme->addItem(schemeName);
|
||||
if (scheme->customed())
|
||||
ui->cbScheme->setItemData(schemeCount,mModifiedSchemeComboFont,Qt::FontRole);
|
||||
schemeCount++;
|
||||
}
|
||||
ui->treeItems->setModel(&mDefinesModel);
|
||||
mDefinesModel.setHorizontalHeaderLabels(QStringList());
|
||||
|
@ -18,29 +32,17 @@ EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QStr
|
|||
addDefine(defineName, pColorManager->getDefine(defineName));
|
||||
}
|
||||
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 index = mDefinesModel.index(0,0,groupIndex);
|
||||
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(
|
||||
"#include <iostream>\n"
|
||||
"#include <conio.h>\n"
|
||||
|
@ -62,6 +64,7 @@ EditorColorSchemeWidget::EditorColorSchemeWidget(const QString& name, const QStr
|
|||
"}\n"
|
||||
);
|
||||
ui->editDemo->setReadOnly(true);
|
||||
onItemSelectionChanged();
|
||||
}
|
||||
|
||||
void EditorColorSchemeWidget::addDefine(const QString& name, PColorSchemeItemDefine define)
|
||||
|
@ -94,6 +97,63 @@ PColorScheme EditorColorSchemeWidget::getCurrentScheme()
|
|||
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()
|
||||
{
|
||||
delete ui;
|
||||
|
@ -112,6 +172,7 @@ static void setColorProp(ColorEdit* ce, QCheckBox* cb, const QColor& color) {
|
|||
|
||||
void EditorColorSchemeWidget::onItemSelectionChanged()
|
||||
{
|
||||
disconnectModificationSlots();
|
||||
QItemSelectionModel * selectionModel = ui->treeItems->selectionModel();
|
||||
QString name =mDefinesModel.data(selectionModel->currentIndex(),NameRole).toString();
|
||||
bool found = false;
|
||||
|
@ -150,8 +211,9 @@ void EditorColorSchemeWidget::onItemSelectionChanged()
|
|||
}
|
||||
}
|
||||
}
|
||||
// not found
|
||||
|
||||
ui->widgetSchemeItem->setEnabled(found);
|
||||
connectModificationSlots();
|
||||
}
|
||||
|
||||
void EditorColorSchemeWidget::onSettingChanged()
|
||||
|
@ -169,10 +231,7 @@ void EditorColorSchemeWidget::onForegroundChanged()
|
|||
} else {
|
||||
item->setForeground(QColor());
|
||||
}
|
||||
PColorScheme scheme = getCurrentScheme();
|
||||
if (scheme) {
|
||||
scheme->setCustomed(true);
|
||||
}
|
||||
setCurrentSchemeModified();
|
||||
}
|
||||
|
||||
void EditorColorSchemeWidget::onBackgroundChanged()
|
||||
|
@ -185,10 +244,7 @@ void EditorColorSchemeWidget::onBackgroundChanged()
|
|||
} else {
|
||||
item->setBackground(QColor());
|
||||
}
|
||||
PColorScheme scheme = getCurrentScheme();
|
||||
if (scheme) {
|
||||
scheme->setCustomed(true);
|
||||
}
|
||||
setCurrentSchemeModified();
|
||||
}
|
||||
|
||||
void EditorColorSchemeWidget::onFontStyleChanged()
|
||||
|
@ -200,18 +256,67 @@ void EditorColorSchemeWidget::onFontStyleChanged()
|
|||
item->setItalic(ui->cbItalic->isChecked());
|
||||
item->setStrikeout(ui->cbStrikeout->isChecked());
|
||||
item->setUnderlined(ui->cbUnderlined->isChecked());
|
||||
PColorScheme scheme = getCurrentScheme();
|
||||
if (scheme) {
|
||||
scheme->setCustomed(true);
|
||||
setCurrentSchemeModified();
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
ui->cbScheme->setCurrentText(pSettings->editor().colorScheme());
|
||||
}
|
||||
|
||||
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 "../colorscheme.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
namespace Ui {
|
||||
|
@ -27,21 +28,32 @@ public slots:
|
|||
void onForegroundChanged();
|
||||
void onBackgroundChanged();
|
||||
void onFontStyleChanged();
|
||||
void changeSchemeComboFont();
|
||||
|
||||
private:
|
||||
void addDefine(const QString& name, PColorSchemeItemDefine define);
|
||||
PColorSchemeItem getCurrentItem();
|
||||
PColorScheme getCurrentScheme();
|
||||
void connectModificationSlots();
|
||||
void disconnectModificationSlots();
|
||||
void setCurrentSchemeModified();
|
||||
|
||||
private:
|
||||
Ui::EditorColorSchemeWidget *ui;
|
||||
QStandardItemModel mDefinesModel;
|
||||
QFont mDefaultSchemeComboFont;
|
||||
QFont mModifiedSchemeComboFont;
|
||||
QSet<QString> mModifiedSchemes;
|
||||
QMenu mMenu;
|
||||
|
||||
// SettingsWidget interface
|
||||
protected:
|
||||
void doLoad() override;
|
||||
void doSave() override;
|
||||
|
||||
private slots:
|
||||
void on_actionCopy_Scheme_triggered();
|
||||
void on_btnSchemeMenu_pressed();
|
||||
};
|
||||
|
||||
#endif // EDITORCOLORSCHEMEWIDGET_H
|
||||
|
|
|
@ -46,10 +46,10 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbScheme"/>
|
||||
<widget class="QPatchedComboBox" name="cbScheme"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton">
|
||||
<widget class="QToolButton" name="btnSchemeMenu">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
|
@ -108,7 +108,16 @@
|
|||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>7</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -124,7 +133,7 @@
|
|||
<item>
|
||||
<widget class="QTreeView" name="treeItems">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
@ -171,6 +180,12 @@
|
|||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="ColorEdit" name="colorForeground">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
|
@ -179,8 +194,27 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<widget class="ColorEdit" name="colorBackground">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
|
@ -189,7 +223,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<item row="2" column="1">
|
||||
<widget class="QGroupBox" name="grpFontStyles">
|
||||
<property name="title">
|
||||
<string>Font Styles</string>
|
||||
|
@ -223,35 +257,9 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -260,7 +268,7 @@
|
|||
<widget class="Editor" name="editDemo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
|
@ -277,6 +285,36 @@
|
|||
</widget>
|
||||
</item>
|
||||
</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>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -291,6 +329,11 @@
|
|||
<header location="global">editor.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QPatchedComboBox</class>
|
||||
<extends>QComboBox</extends>
|
||||
<header location="global">widgets/qpatchedcombobox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -46,7 +46,7 @@ QSize ColorEdit::sizeHint() const
|
|||
{
|
||||
QRect rect = fontMetrics().boundingRect(mColor.name());
|
||||
return QSize{rect.width()+ 10,
|
||||
rect.width()+ 6 };
|
||||
rect.height()+ 6 };
|
||||
}
|
||||
|
||||
void ColorEdit::paintEvent(QPaintEvent *event)
|
||||
|
@ -56,7 +56,6 @@ void ColorEdit::paintEvent(QPaintEvent *event)
|
|||
painter.fillRect(rect,mColor);
|
||||
painter.setPen(contrast());
|
||||
painter.drawText(rect,Qt::AlignCenter, mColor.name());
|
||||
qDebug()<<rect<<mColor<<contrast();
|
||||
}
|
||||
|
||||
void ColorEdit::mouseReleaseEvent(QMouseEvent *event)
|
||||
|
@ -76,3 +75,10 @@ void ColorEdit::leaveEvent(QEvent *event)
|
|||
{
|
||||
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 enterEvent(QEvent *event) override;
|
||||
void leaveEvent(QEvent *event) override;
|
||||
QSize minimumSizeHint() const override;
|
||||
};
|
||||
|
||||
#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