forked from qt-creator/qt-creator
TextEditor: inline fontsettingspage.ui
Change-Id: I6bcfa9135ad66146850b0500c6d35889ab5c5df7 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -57,7 +57,7 @@ add_qtc_plugin(TextEditor
|
|||||||
findinfiles.cpp findinfiles.h
|
findinfiles.cpp findinfiles.h
|
||||||
findinopenfiles.cpp findinopenfiles.h
|
findinopenfiles.cpp findinopenfiles.h
|
||||||
fontsettings.cpp fontsettings.h
|
fontsettings.cpp fontsettings.h
|
||||||
fontsettingspage.cpp fontsettingspage.h fontsettingspage.ui
|
fontsettingspage.cpp fontsettingspage.h
|
||||||
formatter.h
|
formatter.h
|
||||||
formattexteditor.cpp formattexteditor.h
|
formattexteditor.cpp formattexteditor.h
|
||||||
highlighter.cpp highlighter.h
|
highlighter.cpp highlighter.h
|
||||||
|
|||||||
@@ -25,17 +25,21 @@
|
|||||||
|
|
||||||
#include "fontsettingspage.h"
|
#include "fontsettingspage.h"
|
||||||
|
|
||||||
|
#include "colorschemeedit.h"
|
||||||
#include "fontsettings.h"
|
#include "fontsettings.h"
|
||||||
#include "texteditorsettings.h"
|
#include "texteditorsettings.h"
|
||||||
#include "ui_fontsettingspage.h"
|
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <utils/fileutils.h>
|
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
#include <utils/stringutils.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
#include <QDebug>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
@@ -44,17 +48,30 @@
|
|||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QDebug>
|
|
||||||
|
#include <QtCore/QVariant>
|
||||||
|
#include <QtWidgets/QApplication>
|
||||||
|
#include <QtWidgets/QCheckBox>
|
||||||
|
#include <QtWidgets/QComboBox>
|
||||||
|
#include <QtWidgets/QFontComboBox>
|
||||||
|
#include <QtWidgets/QGridLayout>
|
||||||
|
#include <QtWidgets/QGroupBox>
|
||||||
|
#include <QtWidgets/QLabel>
|
||||||
|
#include <QtWidgets/QPushButton>
|
||||||
|
#include <QtWidgets/QSpacerItem>
|
||||||
|
#include <QtWidgets/QSpinBox>
|
||||||
|
#include <QtWidgets/QVBoxLayout>
|
||||||
|
#include <QtWidgets/QWidget>
|
||||||
|
|
||||||
using namespace TextEditor::Internal;
|
using namespace TextEditor::Internal;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
struct ColorSchemeEntry
|
struct ColorSchemeEntry
|
||||||
{
|
{
|
||||||
ColorSchemeEntry(const QString &fileName,
|
ColorSchemeEntry(const QString &fileName, bool readOnly) :
|
||||||
bool readOnly):
|
|
||||||
fileName(fileName),
|
fileName(fileName),
|
||||||
name(ColorScheme::readNameOfScheme(fileName)),
|
name(ColorScheme::readNameOfScheme(fileName)),
|
||||||
readOnly(readOnly)
|
readOnly(readOnly)
|
||||||
@@ -66,7 +83,6 @@ struct ColorSchemeEntry
|
|||||||
bool readOnly;
|
bool readOnly;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SchemeListModel : public QAbstractListModel
|
class SchemeListModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -119,45 +135,87 @@ public:
|
|||||||
{
|
{
|
||||||
m_lastValue = m_value;
|
m_lastValue = m_value;
|
||||||
|
|
||||||
m_ui.setupUi(this);
|
resize(639, 306);
|
||||||
m_ui.colorSchemeGroupBox->setTitle(
|
|
||||||
tr("Color Scheme for Theme \"%1\"")
|
|
||||||
.arg(Utils::creatorTheme()->displayName()));
|
|
||||||
m_ui.schemeComboBox->setModel(&m_schemeListModel);
|
|
||||||
|
|
||||||
m_ui.fontComboBox->setCurrentFont(m_value.family());
|
m_antialias = new QCheckBox(tr("Antialias"));
|
||||||
|
m_antialias->setChecked(m_value.antialias());
|
||||||
|
|
||||||
m_ui.antialias->setChecked(m_value.antialias());
|
m_zoomSpinBox = new QSpinBox;
|
||||||
m_ui.zoomSpinBox->setValue(m_value.fontZoom());
|
m_zoomSpinBox->setSuffix(tr("%"));
|
||||||
|
m_zoomSpinBox->setRange(10, 3000);
|
||||||
|
m_zoomSpinBox->setSingleStep(10);
|
||||||
|
m_zoomSpinBox->setValue(m_value.fontZoom());
|
||||||
|
|
||||||
m_ui.schemeEdit->setFormatDescriptions(fd);
|
m_fontComboBox = new QFontComboBox;
|
||||||
m_ui.schemeEdit->setBaseFont(m_value.font());
|
m_fontComboBox->setCurrentFont(m_value.family());
|
||||||
m_ui.schemeEdit->setColorScheme(m_value.colorScheme());
|
|
||||||
|
|
||||||
auto sizeValidator = new QIntValidator(m_ui.sizeComboBox);
|
m_sizeComboBox = new QComboBox;
|
||||||
|
m_sizeComboBox->setEditable(true);
|
||||||
|
auto sizeValidator = new QIntValidator(m_sizeComboBox);
|
||||||
sizeValidator->setBottom(0);
|
sizeValidator->setBottom(0);
|
||||||
m_ui.sizeComboBox->setValidator(sizeValidator);
|
m_sizeComboBox->setValidator(sizeValidator);
|
||||||
|
|
||||||
connect(m_ui.fontComboBox, &QFontComboBox::currentFontChanged,
|
m_copyButton = new QPushButton(tr("Copy..."));
|
||||||
|
|
||||||
|
m_deleteButton = new QPushButton(tr("Delete"));
|
||||||
|
m_deleteButton->setEnabled(false);
|
||||||
|
|
||||||
|
auto importButton = new QPushButton(tr("Import"));
|
||||||
|
auto exportButton = new QPushButton(tr("Export"));
|
||||||
|
|
||||||
|
m_schemeComboBox = new QComboBox;
|
||||||
|
m_schemeComboBox->setModel(&m_schemeListModel);
|
||||||
|
m_schemeComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
|
||||||
|
m_schemeEdit = new ColorSchemeEdit;
|
||||||
|
m_schemeEdit->setFormatDescriptions(fd);
|
||||||
|
m_schemeEdit->setBaseFont(m_value.font());
|
||||||
|
m_schemeEdit->setColorScheme(m_value.colorScheme());
|
||||||
|
|
||||||
|
using namespace Layouting;
|
||||||
|
|
||||||
|
Column {
|
||||||
|
Group {
|
||||||
|
title(tr("Font")),
|
||||||
|
Column {
|
||||||
|
Row {
|
||||||
|
tr("Family:"), m_fontComboBox, Space(20),
|
||||||
|
tr("Size:"), m_sizeComboBox, Space(20),
|
||||||
|
tr("Zoom:"), m_zoomSpinBox, st
|
||||||
|
},
|
||||||
|
m_antialias
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Group {
|
||||||
|
title(tr("Color Scheme for Theme \"%1\"")
|
||||||
|
.arg(Utils::creatorTheme()->displayName())),
|
||||||
|
Column {
|
||||||
|
Row { m_schemeComboBox, m_copyButton, m_deleteButton, importButton, exportButton },
|
||||||
|
m_schemeEdit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
|
connect(m_fontComboBox, &QFontComboBox::currentFontChanged,
|
||||||
this, &FontSettingsPageWidget::fontSelected);
|
this, &FontSettingsPageWidget::fontSelected);
|
||||||
connect(m_ui.sizeComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
connect(m_sizeComboBox, &QComboBox::currentIndexChanged,
|
||||||
this, &FontSettingsPageWidget::fontSizeSelected);
|
this, &FontSettingsPageWidget::fontSizeSelected);
|
||||||
connect(m_ui.zoomSpinBox, QOverload<int>::of(&QSpinBox::valueChanged),
|
connect(m_zoomSpinBox, &QSpinBox::valueChanged,
|
||||||
this, &FontSettingsPageWidget::fontZoomChanged);
|
this, &FontSettingsPageWidget::fontZoomChanged);
|
||||||
connect(m_ui.antialias, &QCheckBox::toggled,
|
connect(m_antialias, &QCheckBox::toggled,
|
||||||
this, &FontSettingsPageWidget::antialiasChanged);
|
this, &FontSettingsPageWidget::antialiasChanged);
|
||||||
connect(m_ui.schemeComboBox,
|
connect(m_schemeComboBox, &QComboBox::currentIndexChanged,
|
||||||
QOverload<int>::of(&QComboBox::currentIndexChanged),
|
|
||||||
this, &FontSettingsPageWidget::colorSchemeSelected);
|
this, &FontSettingsPageWidget::colorSchemeSelected);
|
||||||
connect(m_ui.copyButton, &QPushButton::clicked,
|
connect(m_copyButton, &QPushButton::clicked,
|
||||||
this, &FontSettingsPageWidget::openCopyColorSchemeDialog);
|
this, &FontSettingsPageWidget::openCopyColorSchemeDialog);
|
||||||
connect(m_ui.schemeEdit, &ColorSchemeEdit::copyScheme,
|
connect(m_schemeEdit, &ColorSchemeEdit::copyScheme,
|
||||||
this, &FontSettingsPageWidget::openCopyColorSchemeDialog);
|
this, &FontSettingsPageWidget::openCopyColorSchemeDialog);
|
||||||
connect(m_ui.deleteButton, &QPushButton::clicked,
|
connect(m_deleteButton, &QPushButton::clicked,
|
||||||
this, &FontSettingsPageWidget::confirmDeleteColorScheme);
|
this, &FontSettingsPageWidget::confirmDeleteColorScheme);
|
||||||
connect(m_ui.importButton, &QPushButton::clicked,
|
connect(importButton, &QPushButton::clicked,
|
||||||
this, &FontSettingsPageWidget::importScheme);
|
this, &FontSettingsPageWidget::importScheme);
|
||||||
connect(m_ui.exportButton, &QPushButton::clicked,
|
connect(exportButton, &QPushButton::clicked,
|
||||||
this, &FontSettingsPageWidget::exportScheme);
|
this, &FontSettingsPageWidget::exportScheme);
|
||||||
|
|
||||||
updatePointSizes();
|
updatePointSizes();
|
||||||
@@ -186,12 +244,20 @@ public:
|
|||||||
void refreshColorSchemeList();
|
void refreshColorSchemeList();
|
||||||
|
|
||||||
FontSettingsPage *q;
|
FontSettingsPage *q;
|
||||||
Ui::FontSettingsPage m_ui;
|
|
||||||
bool m_refreshingSchemeList = false;
|
bool m_refreshingSchemeList = false;
|
||||||
FontSettings &m_value;
|
FontSettings &m_value;
|
||||||
FontSettings m_lastValue;
|
FontSettings m_lastValue;
|
||||||
SchemeListModel m_schemeListModel;
|
SchemeListModel m_schemeListModel;
|
||||||
FormatDescriptions m_descriptions;
|
FormatDescriptions m_descriptions;
|
||||||
|
|
||||||
|
QCheckBox *m_antialias;
|
||||||
|
QSpinBox *m_zoomSpinBox;
|
||||||
|
QFontComboBox *m_fontComboBox;
|
||||||
|
QComboBox *m_sizeComboBox;
|
||||||
|
QComboBox *m_schemeComboBox;
|
||||||
|
ColorSchemeEdit *m_schemeEdit;
|
||||||
|
QPushButton *m_deleteButton;
|
||||||
|
QPushButton *m_copyButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
@@ -370,20 +436,20 @@ bool FormatDescription::showControl(FormatDescription::ShowControls showControl)
|
|||||||
return m_showControls & showControl;
|
return m_showControls & showControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
void FontSettingsPageWidget::fontSelected(const QFont &font)
|
void FontSettingsPageWidget::fontSelected(const QFont &font)
|
||||||
{
|
{
|
||||||
m_value.setFamily(font.family());
|
m_value.setFamily(font.family());
|
||||||
m_ui.schemeEdit->setBaseFont(font);
|
m_schemeEdit->setBaseFont(font);
|
||||||
updatePointSizes();
|
updatePointSizes();
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
void FontSettingsPageWidget::updatePointSizes()
|
void FontSettingsPageWidget::updatePointSizes()
|
||||||
{
|
{
|
||||||
// Update point sizes
|
// Update point sizes
|
||||||
const int oldSize = m_value.fontSize();
|
const int oldSize = m_value.fontSize();
|
||||||
m_ui.sizeComboBox->clear();
|
m_sizeComboBox->clear();
|
||||||
const QList<int> sizeLst = pointSizesForSelectedFont();
|
const QList<int> sizeLst = pointSizesForSelectedFont();
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -391,18 +457,18 @@ void FontSettingsPageWidget::updatePointSizes()
|
|||||||
if (idx == -1 && sizeLst.at(i) >= oldSize) {
|
if (idx == -1 && sizeLst.at(i) >= oldSize) {
|
||||||
idx = i;
|
idx = i;
|
||||||
if (sizeLst.at(i) != oldSize)
|
if (sizeLst.at(i) != oldSize)
|
||||||
m_ui.sizeComboBox->addItem(QString::number(oldSize));
|
m_sizeComboBox->addItem(QString::number(oldSize));
|
||||||
}
|
}
|
||||||
m_ui.sizeComboBox->addItem(QString::number(sizeLst.at(i)));
|
m_sizeComboBox->addItem(QString::number(sizeLst.at(i)));
|
||||||
}
|
}
|
||||||
if (idx != -1)
|
if (idx != -1)
|
||||||
m_ui.sizeComboBox->setCurrentIndex(idx);
|
m_sizeComboBox->setCurrentIndex(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<int> FontSettingsPageWidget::pointSizesForSelectedFont() const
|
QList<int> FontSettingsPageWidget::pointSizesForSelectedFont() const
|
||||||
{
|
{
|
||||||
QFontDatabase db;
|
QFontDatabase db;
|
||||||
const QString familyName = m_ui.fontComboBox->currentFont().family();
|
const QString familyName = m_fontComboBox->currentFont().family();
|
||||||
QList<int> sizeLst = db.pointSizes(familyName);
|
QList<int> sizeLst = db.pointSizes(familyName);
|
||||||
if (!sizeLst.isEmpty())
|
if (!sizeLst.isEmpty())
|
||||||
return sizeLst;
|
return sizeLst;
|
||||||
@@ -418,24 +484,24 @@ QList<int> FontSettingsPageWidget::pointSizesForSelectedFont() const
|
|||||||
|
|
||||||
void FontSettingsPageWidget::fontSizeSelected(int index)
|
void FontSettingsPageWidget::fontSizeSelected(int index)
|
||||||
{
|
{
|
||||||
const QString sizeString = m_ui.sizeComboBox->itemText(index);
|
const QString sizeString = m_sizeComboBox->itemText(index);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
const int size = sizeString.toInt(&ok);
|
const int size = sizeString.toInt(&ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
m_value.setFontSize(size);
|
m_value.setFontSize(size);
|
||||||
m_ui.schemeEdit->setBaseFont(m_value.font());
|
m_schemeEdit->setBaseFont(m_value.font());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontSettingsPageWidget::fontZoomChanged()
|
void FontSettingsPageWidget::fontZoomChanged()
|
||||||
{
|
{
|
||||||
m_value.setFontZoom(m_ui.zoomSpinBox->value());
|
m_value.setFontZoom(m_zoomSpinBox->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontSettingsPageWidget::antialiasChanged()
|
void FontSettingsPageWidget::antialiasChanged()
|
||||||
{
|
{
|
||||||
m_value.setAntialias(m_ui.antialias->isChecked());
|
m_value.setAntialias(m_antialias->isChecked());
|
||||||
m_ui.schemeEdit->setBaseFont(m_value.font());
|
m_schemeEdit->setBaseFont(m_value.font());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontSettingsPageWidget::colorSchemeSelected(int index)
|
void FontSettingsPageWidget::colorSchemeSelected(int index)
|
||||||
@@ -449,16 +515,16 @@ void FontSettingsPageWidget::colorSchemeSelected(int index)
|
|||||||
const ColorSchemeEntry &entry = m_schemeListModel.colorSchemeAt(index);
|
const ColorSchemeEntry &entry = m_schemeListModel.colorSchemeAt(index);
|
||||||
readOnly = entry.readOnly;
|
readOnly = entry.readOnly;
|
||||||
m_value.loadColorScheme(entry.fileName, m_descriptions);
|
m_value.loadColorScheme(entry.fileName, m_descriptions);
|
||||||
m_ui.schemeEdit->setColorScheme(m_value.colorScheme());
|
m_schemeEdit->setColorScheme(m_value.colorScheme());
|
||||||
}
|
}
|
||||||
m_ui.copyButton->setEnabled(index != -1);
|
m_copyButton->setEnabled(index != -1);
|
||||||
m_ui.deleteButton->setEnabled(!readOnly);
|
m_deleteButton->setEnabled(!readOnly);
|
||||||
m_ui.schemeEdit->setReadOnly(readOnly);
|
m_schemeEdit->setReadOnly(readOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontSettingsPageWidget::openCopyColorSchemeDialog()
|
void FontSettingsPageWidget::openCopyColorSchemeDialog()
|
||||||
{
|
{
|
||||||
QInputDialog *dialog = new QInputDialog(m_ui.copyButton->window());
|
QInputDialog *dialog = new QInputDialog(m_copyButton->window());
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
dialog->setInputMode(QInputDialog::TextInput);
|
dialog->setInputMode(QInputDialog::TextInput);
|
||||||
dialog->setWindowTitle(tr("Copy Color Scheme"));
|
dialog->setWindowTitle(tr("Copy Color Scheme"));
|
||||||
@@ -471,7 +537,7 @@ void FontSettingsPageWidget::openCopyColorSchemeDialog()
|
|||||||
|
|
||||||
void FontSettingsPageWidget::copyColorScheme(const QString &name)
|
void FontSettingsPageWidget::copyColorScheme(const QString &name)
|
||||||
{
|
{
|
||||||
int index = m_ui.schemeComboBox->currentIndex();
|
int index = m_schemeComboBox->currentIndex();
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -486,7 +552,7 @@ void FontSettingsPageWidget::copyColorScheme(const QString &name)
|
|||||||
maybeSaveColorScheme();
|
maybeSaveColorScheme();
|
||||||
|
|
||||||
// Make sure we're copying the current version
|
// Make sure we're copying the current version
|
||||||
m_value.setColorScheme(m_ui.schemeEdit->colorScheme());
|
m_value.setColorScheme(m_schemeEdit->colorScheme());
|
||||||
|
|
||||||
ColorScheme scheme = m_value.colorScheme();
|
ColorScheme scheme = m_value.colorScheme();
|
||||||
scheme.setDisplayName(name);
|
scheme.setDisplayName(name);
|
||||||
@@ -499,7 +565,7 @@ void FontSettingsPageWidget::copyColorScheme(const QString &name)
|
|||||||
|
|
||||||
void FontSettingsPageWidget::confirmDeleteColorScheme()
|
void FontSettingsPageWidget::confirmDeleteColorScheme()
|
||||||
{
|
{
|
||||||
const int index = m_ui.schemeComboBox->currentIndex();
|
const int index = m_schemeComboBox->currentIndex();
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -511,7 +577,7 @@ void FontSettingsPageWidget::confirmDeleteColorScheme()
|
|||||||
tr("Delete Color Scheme"),
|
tr("Delete Color Scheme"),
|
||||||
tr("Are you sure you want to delete this color scheme permanently?"),
|
tr("Are you sure you want to delete this color scheme permanently?"),
|
||||||
QMessageBox::Discard | QMessageBox::Cancel,
|
QMessageBox::Discard | QMessageBox::Cancel,
|
||||||
m_ui.deleteButton->window());
|
m_deleteButton->window());
|
||||||
|
|
||||||
// Change the text and role of the discard button
|
// Change the text and role of the discard button
|
||||||
auto deleteButton = static_cast<QPushButton*>(messageBox->button(QMessageBox::Discard));
|
auto deleteButton = static_cast<QPushButton*>(messageBox->button(QMessageBox::Discard));
|
||||||
@@ -526,7 +592,7 @@ void FontSettingsPageWidget::confirmDeleteColorScheme()
|
|||||||
|
|
||||||
void FontSettingsPageWidget::deleteColorScheme()
|
void FontSettingsPageWidget::deleteColorScheme()
|
||||||
{
|
{
|
||||||
const int index = m_ui.schemeComboBox->currentIndex();
|
const int index = m_schemeComboBox->currentIndex();
|
||||||
QTC_ASSERT(index != -1, return);
|
QTC_ASSERT(index != -1, return);
|
||||||
|
|
||||||
const ColorSchemeEntry &entry = m_schemeListModel.colorSchemeAt(index);
|
const ColorSchemeEntry &entry = m_schemeListModel.colorSchemeAt(index);
|
||||||
@@ -553,7 +619,7 @@ void FontSettingsPageWidget::importScheme()
|
|||||||
// Ask about saving any existing modifications
|
// Ask about saving any existing modifications
|
||||||
maybeSaveColorScheme();
|
maybeSaveColorScheme();
|
||||||
|
|
||||||
QInputDialog *dialog = new QInputDialog(m_ui.copyButton->window());
|
QInputDialog *dialog = new QInputDialog(m_copyButton->window());
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
dialog->setInputMode(QInputDialog::TextInput);
|
dialog->setInputMode(QInputDialog::TextInput);
|
||||||
dialog->setWindowTitle(tr("Import Color Scheme"));
|
dialog->setWindowTitle(tr("Import Color Scheme"));
|
||||||
@@ -561,7 +627,7 @@ void FontSettingsPageWidget::importScheme()
|
|||||||
dialog->setTextValue(importedFile.baseName());
|
dialog->setTextValue(importedFile.baseName());
|
||||||
|
|
||||||
connect(dialog, &QInputDialog::textValueSelected, this, [this, fileName](const QString &name) {
|
connect(dialog, &QInputDialog::textValueSelected, this, [this, fileName](const QString &name) {
|
||||||
m_value.setColorScheme(m_ui.schemeEdit->colorScheme());
|
m_value.setColorScheme(m_schemeEdit->colorScheme());
|
||||||
|
|
||||||
ColorScheme scheme = m_value.colorScheme();
|
ColorScheme scheme = m_value.colorScheme();
|
||||||
scheme.setDisplayName(name);
|
scheme.setDisplayName(name);
|
||||||
@@ -575,7 +641,7 @@ void FontSettingsPageWidget::importScheme()
|
|||||||
|
|
||||||
void FontSettingsPageWidget::exportScheme()
|
void FontSettingsPageWidget::exportScheme()
|
||||||
{
|
{
|
||||||
int index = m_ui.schemeComboBox->currentIndex();
|
int index = m_schemeComboBox->currentIndex();
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -593,16 +659,16 @@ void FontSettingsPageWidget::exportScheme()
|
|||||||
|
|
||||||
void FontSettingsPageWidget::maybeSaveColorScheme()
|
void FontSettingsPageWidget::maybeSaveColorScheme()
|
||||||
{
|
{
|
||||||
if (m_value.colorScheme() == m_ui.schemeEdit->colorScheme())
|
if (m_value.colorScheme() == m_schemeEdit->colorScheme())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QMessageBox
|
QMessageBox
|
||||||
messageBox(QMessageBox::Warning,
|
messageBox(QMessageBox::Warning,
|
||||||
tr("Color Scheme Changed"),
|
tr("Color Scheme Changed"),
|
||||||
tr("The color scheme \"%1\" was modified, do you want to save the changes?")
|
tr("The color scheme \"%1\" was modified, do you want to save the changes?")
|
||||||
.arg(m_ui.schemeEdit->colorScheme().displayName()),
|
.arg(m_schemeEdit->colorScheme().displayName()),
|
||||||
QMessageBox::Discard | QMessageBox::Save,
|
QMessageBox::Discard | QMessageBox::Save,
|
||||||
m_ui.schemeComboBox->window());
|
m_schemeComboBox->window());
|
||||||
|
|
||||||
// Change the text of the discard button
|
// Change the text of the discard button
|
||||||
auto discardButton = static_cast<QPushButton*>(messageBox.button(QMessageBox::Discard));
|
auto discardButton = static_cast<QPushButton*>(messageBox.button(QMessageBox::Discard));
|
||||||
@@ -611,7 +677,7 @@ void FontSettingsPageWidget::maybeSaveColorScheme()
|
|||||||
messageBox.setDefaultButton(QMessageBox::Save);
|
messageBox.setDefaultButton(QMessageBox::Save);
|
||||||
|
|
||||||
if (messageBox.exec() == QMessageBox::Save) {
|
if (messageBox.exec() == QMessageBox::Save) {
|
||||||
const ColorScheme &scheme = m_ui.schemeEdit->colorScheme();
|
const ColorScheme &scheme = m_schemeEdit->colorScheme();
|
||||||
scheme.save(m_value.colorSchemeFileName(), Core::ICore::dialogParent());
|
scheme.save(m_value.colorSchemeFileName(), Core::ICore::dialogParent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -652,27 +718,27 @@ void FontSettingsPageWidget::refreshColorSchemeList()
|
|||||||
|
|
||||||
m_refreshingSchemeList = true;
|
m_refreshingSchemeList = true;
|
||||||
m_schemeListModel.setColorSchemes(colorSchemes);
|
m_schemeListModel.setColorSchemes(colorSchemes);
|
||||||
m_ui.schemeComboBox->setCurrentIndex(selected);
|
m_schemeComboBox->setCurrentIndex(selected);
|
||||||
m_refreshingSchemeList = false;
|
m_refreshingSchemeList = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontSettingsPageWidget::apply()
|
void FontSettingsPageWidget::apply()
|
||||||
{
|
{
|
||||||
if (m_value.colorScheme() != m_ui.schemeEdit->colorScheme()) {
|
if (m_value.colorScheme() != m_schemeEdit->colorScheme()) {
|
||||||
// Update the scheme and save it under the name it already has
|
// Update the scheme and save it under the name it already has
|
||||||
m_value.setColorScheme(m_ui.schemeEdit->colorScheme());
|
m_value.setColorScheme(m_schemeEdit->colorScheme());
|
||||||
const ColorScheme &scheme = m_value.colorScheme();
|
const ColorScheme &scheme = m_value.colorScheme();
|
||||||
scheme.save(m_value.colorSchemeFileName(), Core::ICore::dialogParent());
|
scheme.save(m_value.colorSchemeFileName(), Core::ICore::dialogParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
int fontSize = m_ui.sizeComboBox->currentText().toInt(&ok);
|
int fontSize = m_sizeComboBox->currentText().toInt(&ok);
|
||||||
if (ok && m_value.fontSize() != fontSize) {
|
if (ok && m_value.fontSize() != fontSize) {
|
||||||
m_value.setFontSize(fontSize);
|
m_value.setFontSize(fontSize);
|
||||||
m_ui.schemeEdit->setBaseFont(m_value.font());
|
m_schemeEdit->setBaseFont(m_value.font());
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = m_ui.schemeComboBox->currentIndex();
|
int index = m_schemeComboBox->currentIndex();
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
const ColorSchemeEntry &entry = m_schemeListModel.colorSchemeAt(index);
|
const ColorSchemeEntry &entry = m_schemeListModel.colorSchemeAt(index);
|
||||||
if (entry.fileName != m_value.colorSchemeFileName())
|
if (entry.fileName != m_value.colorSchemeFileName())
|
||||||
@@ -719,7 +785,7 @@ FontSettingsPage::FontSettingsPage(FontSettings *fontSettings, const FormatDescr
|
|||||||
void FontSettingsPage::setFontZoom(int zoom)
|
void FontSettingsPage::setFontZoom(int zoom)
|
||||||
{
|
{
|
||||||
if (m_widget)
|
if (m_widget)
|
||||||
static_cast<FontSettingsPageWidget *>(m_widget.data())->m_ui.zoomSpinBox->setValue(zoom);
|
static_cast<FontSettingsPageWidget *>(m_widget.data())->m_zoomSpinBox->setValue(zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // TextEditor
|
} // TextEditor
|
||||||
|
|||||||
@@ -1,226 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>TextEditor::Internal::FontSettingsPage</class>
|
|
||||||
<widget class="QWidget" name="TextEditor::Internal::FontSettingsPage">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>639</width>
|
|
||||||
<height>306</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="fontGroupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Font</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="4">
|
|
||||||
<widget class="QLabel" name="sizeLabel">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Size:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="7">
|
|
||||||
<widget class="QLabel" name="zoomLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Zoom:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="familyLabel">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Family:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="6">
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Preferred</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="9">
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<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="1" column="0" colspan="3">
|
|
||||||
<widget class="QCheckBox" name="antialias">
|
|
||||||
<property name="text">
|
|
||||||
<string>Antialias</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="3">
|
|
||||||
<spacer>
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Preferred</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="8">
|
|
||||||
<widget class="QSpinBox" name="zoomSpinBox">
|
|
||||||
<property name="suffix">
|
|
||||||
<string>%</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>3000</number>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>100</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QFontComboBox" name="fontComboBox"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="5">
|
|
||||||
<widget class="QComboBox" name="sizeComboBox">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="editable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="colorSchemeGroupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Color Scheme</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
|
||||||
<item row="0" column="5">
|
|
||||||
<widget class="QPushButton" name="exportButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Export</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QComboBox" name="schemeComboBox">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
|
||||||
<horstretch>1</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="3">
|
|
||||||
<widget class="QPushButton" name="deleteButton">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Delete</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QPushButton" name="copyButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Copy...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="4">
|
|
||||||
<widget class="QPushButton" name="importButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Import</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0" colspan="6">
|
|
||||||
<widget class="TextEditor::Internal::ColorSchemeEdit" name="schemeEdit" native="true">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>1</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>TextEditor::Internal::ColorSchemeEdit</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header location="global">texteditor/colorschemeedit.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<tabstops>
|
|
||||||
<tabstop>fontComboBox</tabstop>
|
|
||||||
<tabstop>sizeComboBox</tabstop>
|
|
||||||
<tabstop>zoomSpinBox</tabstop>
|
|
||||||
<tabstop>antialias</tabstop>
|
|
||||||
<tabstop>schemeComboBox</tabstop>
|
|
||||||
<tabstop>copyButton</tabstop>
|
|
||||||
<tabstop>deleteButton</tabstop>
|
|
||||||
<tabstop>importButton</tabstop>
|
|
||||||
<tabstop>exportButton</tabstop>
|
|
||||||
</tabstops>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@@ -78,7 +78,6 @@ Project {
|
|||||||
"fontsettings.h",
|
"fontsettings.h",
|
||||||
"fontsettingspage.cpp",
|
"fontsettingspage.cpp",
|
||||||
"fontsettingspage.h",
|
"fontsettingspage.h",
|
||||||
"fontsettingspage.ui",
|
|
||||||
"formatter.h",
|
"formatter.h",
|
||||||
"formattexteditor.cpp",
|
"formattexteditor.cpp",
|
||||||
"formattexteditor.h",
|
"formattexteditor.h",
|
||||||
|
|||||||
Reference in New Issue
Block a user