Improve font list interaction (#279)

* add icons

* improve font list interaction
This commit is contained in:
Cyano Hao 2024-03-17 11:18:09 +08:00 committed by GitHub
parent fa1828e225
commit 3e58c52046
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 491 additions and 222 deletions

View File

@ -212,6 +212,7 @@ SOURCES += \
widgets/customfilesystemmodel.cpp \
widgets/custommakefileinfodialog.cpp \
widgets/darkfusionstyle.cpp \
widgets/editorfontdialog.cpp \
widgets/editorstabwidget.cpp \
widgets/filenameeditdelegate.cpp \
widgets/filepropertiesdialog.cpp \
@ -345,6 +346,7 @@ HEADERS += \
widgets/customfilesystemmodel.h \
widgets/custommakefileinfodialog.h \
widgets/darkfusionstyle.h \
widgets/editorfontdialog.h \
widgets/editorstabwidget.h \
widgets/filenameeditdelegate.h \
widgets/filepropertiesdialog.h \
@ -416,6 +418,7 @@ FORMS += \
settingsdialog/executorgeneralwidget.ui \
settingsdialog/settingsdialog.ui \
widgets/custommakefileinfodialog.ui \
widgets/editorfontdialog.ui \
widgets/filepropertiesdialog.ui \
widgets/infomessagebox.ui \
widgets/newclassdialog.ui \

View File

@ -100,6 +100,8 @@ void IconsManager::updateActionIcons(const QString& iconSet, int size)
mIconPixmaps.insert(ACTION_MISC_MOVEUP, createSVGIcon(iconFolder+"00Misc-14MoveUp.svg",size,size));
mIconPixmaps.insert(ACTION_MISC_MOVEDOWN, createSVGIcon(iconFolder+"00Misc-15MoveDown.svg",size,size));
mIconPixmaps.insert(ACTION_MISC_RESET, createSVGIcon(iconFolder+"00Misc-16Reset.svg",size,size));
mIconPixmaps.insert(ACTION_MISC_MOVETOP, createSVGIcon(iconFolder+"00Misc-17MoveTop.svg",size,size));
mIconPixmaps.insert(ACTION_MISC_MOVEBOTTOM, createSVGIcon(iconFolder+"00Misc-18MoveBottom.svg",size,size));
mIconPixmaps.insert(ACTION_FILE_NEW, createSVGIcon(iconFolder+"01File-01New.svg",size,size));
mIconPixmaps.insert(ACTION_FILE_OPEN, createSVGIcon(iconFolder+"01File-02Open.svg",size,size));

View File

@ -116,6 +116,8 @@ public:
ACTION_MISC_MOVEUP,
ACTION_MISC_MOVEDOWN,
ACTION_MISC_RESET,
ACTION_MISC_MOVETOP,
ACTION_MISC_MOVEBOTTOM,
ACTION_FILE_NEW,
ACTION_FILE_OPEN,

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg width="35" height="35" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><path d="M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z" fill="#90b9ff" stroke="#1f74fe" stroke-width="3" stroke-linejoin="round"/><path d="M16 24L24 16L32 24M16 32L24 24L32 32" stroke="#ffffff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>

After

Width:  |  Height:  |  Size: 530 B

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg width="35" height="35" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><path d="M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z" fill="#90b9ff" stroke="#1f74fe" stroke-width="3" stroke-linejoin="round"/><path d="M16 16L24 24L32 16M16 24L24 32L32 24" stroke="#ffffff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>

After

Width:  |  Height:  |  Size: 530 B

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg width="35" height="35" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><rect x="6" y="6" width="36" height="36" rx="3" fill="none" stroke="#ffffff" stroke-width="3" stroke-linejoin="round"/><path d="M16 24L24 16L32 24M16 32L24 24L32 32" stroke="#ffffff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>

After

Width:  |  Height:  |  Size: 451 B

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg width="35" height="35" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="48" height="48" fill="white" fill-opacity="0.01"/><rect x="6" y="6" width="36" height="36" rx="3" fill="none" stroke="#ffffff" stroke-width="3" stroke-linejoin="round"/><path d="M16 16L24 24L32 16M16 24L24 32L32 24" stroke="#ffffff" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/></svg>

After

Width:  |  Height:  |  Size: 451 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path fill="#FFF200" stroke="#000" stroke-miterlimit="10" stroke-width="3" d="m50 5 45 40v50L50 55 5 95V45Zm0 0"/><path fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="3" d="m5 70 45-40 45 40"/></svg>

After

Width:  |  Height:  |  Size: 280 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><path fill="#FFF200" stroke="#000" stroke-miterlimit="10" stroke-width="3" d="m50 95 45-40V5L50 45 5 5v50Zm0 0"/><path fill="none" stroke="#000" stroke-miterlimit="10" stroke-width="3" d="m5 30 45 40 45-40"/></svg>

After

Width:  |  Height:  |  Size: 279 B

View File

@ -22,107 +22,35 @@
#include "../iconsmanager.h"
#include "utils.h"
#include "utils/font.h"
#include "widgets/editorfontdialog.h"
#include <qabstractitemmodel.h>
void EditorFontModel::addFont(const QString& font)
Qt::ItemFlags EditorFontModel::flags(const QModelIndex &index) const
{
beginInsertRows(QModelIndex(),mFonts.size(),mFonts.size());
mFonts.append(font);
endInsertRows();
Qt::ItemFlags flags = Qt::NoItemFlags;
if (index.isValid()) {
flags = Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable ;
} else if (index.row() == -1) {
// -1 means it's a drop target?
flags = Qt::ItemIsDropEnabled;
}
void EditorFontModel::remove(int index)
{
beginRemoveRows(QModelIndex(),index,index);
mFonts.removeAt(index);
endRemoveRows();
}
void EditorFontModel::clear()
{
beginResetModel();
mFonts.clear();
endResetModel();
}
void EditorFontModel::moveUp(int index)
{
if (index == 0)
return;
beginMoveRows(QModelIndex(),index,index,QModelIndex(),index - 1);
mFonts.move(index,index - 1);
endMoveRows();
}
void EditorFontModel::moveDown(int index)
{
if (index == mFonts.size() - 1)
return;
beginMoveRows(QModelIndex(),index,index,QModelIndex(),index + 2);
mFonts.move(index,index + 1);
endMoveRows();
}
QModelIndex EditorFontModel::lastFont()
{
return index(mFonts.size() - 1,0);
}
const QStringList &EditorFontModel::fonts() const
{
return mFonts;
}
void EditorFontModel::updateFonts(const QStringList& fonts)
{
beginResetModel();
mFonts = fonts;
endResetModel();
}
int EditorFontModel::rowCount(const QModelIndex &parent) const
{
if (parent.isValid())
return 0;
return mFonts.size();
}
int EditorFontModel::columnCount(const QModelIndex &parent) const
{
if (parent.isValid())
return 0;
return 1;
}
QVariant EditorFontModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (role == Qt::DisplayRole)
return mFonts.at(index.row());
return QVariant();
}
bool EditorFontModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
if (!index.isValid())
return false;
if (role == Qt::EditRole) {
mFonts[index.row()] = value.toString();
emit dataChanged(index,index);
return true;
}
return false;
return flags;
}
EditorFontWidget::EditorFontWidget(const QString& name, const QString& group, QWidget *parent) :
SettingsWidget(name,group,parent),
ui(new Ui::EditorFontWidget)
ui(new Ui::EditorFontWidget),
mModel(pSettings->editor().fontFamilies())
{
ui->setupUi(this);
QItemSelectionModel *m = ui->lstFontList->selectionModel();
ui->lstFontList->setModel(&mModel);
delete m;
ui->lstFontList->setDragEnabled(true);
ui->lstFontList->setAcceptDrops(true);
ui->lstFontList->setDropIndicatorShown(true);
ui->lstFontList->setDragDropMode(QAbstractItemView::InternalMove);
}
EditorFontWidget::~EditorFontWidget()
@ -141,7 +69,14 @@ void EditorFontWidget::on_chkGutterOnlyMonospacedFonts_stateChanged(int)
void EditorFontWidget::on_btnAddFont_clicked()
{
mModel.addFont(ui->cbNewFont->currentFont().family());
QModelIndex index = ui->lstFontList->currentIndex();
int insertPos = index.isValid() ? index.row() + 1 : mModel.rowCount();
EditorFontDialog dlg(this);
if (dlg.exec() == QDialog::Accepted) {
mModel.insertRow(insertPos);
mModel.setData(mModel.index(insertPos), dlg.fontFamily());
ui->lstFontList->setCurrentIndex(mModel.index(insertPos));
}
}
void EditorFontWidget::on_btnRemoveFont_clicked()
@ -149,7 +84,34 @@ void EditorFontWidget::on_btnRemoveFont_clicked()
QModelIndex index = ui->lstFontList->currentIndex();
if (!index.isValid())
return;
mModel.remove(index.row());
mModel.removeRow(index.row());
}
void EditorFontWidget::on_btnModifyFont_clicked()
{
QModelIndex index = ui->lstFontList->currentIndex();
if (!index.isValid())
return;
EditorFontDialog dlg(this);
dlg.setFontFamily(mModel.data(index, Qt::DisplayRole).toString());
if (dlg.exec() == QDialog::Accepted) {
mModel.setData(index, dlg.fontFamily());
}
}
void EditorFontWidget::on_btnResetFonts_clicked()
{
mModel.setStringList(defaultEditorFonts());
}
void EditorFontWidget::on_btnMoveFontToTop_clicked()
{
QModelIndex index = ui->lstFontList->currentIndex();
if (!index.isValid())
return;
if (index.row() == 0)
return;
mModel.moveRow(QModelIndex(), index.row(), QModelIndex(), 0);
}
void EditorFontWidget::on_btnMoveFontUp_clicked()
@ -157,7 +119,9 @@ void EditorFontWidget::on_btnMoveFontUp_clicked()
QModelIndex index = ui->lstFontList->currentIndex();
if (!index.isValid())
return;
mModel.moveUp(index.row());
if (index.row() == 0)
return;
mModel.moveRow(QModelIndex(), index.row(), QModelIndex(), index.row() - 1);
}
void EditorFontWidget::on_btnMoveFontDown_clicked()
@ -165,21 +129,25 @@ void EditorFontWidget::on_btnMoveFontDown_clicked()
QModelIndex index = ui->lstFontList->currentIndex();
if (!index.isValid())
return;
mModel.moveDown(index.row());
if (index.row() == mModel.rowCount() - 1)
return;
mModel.moveRow(QModelIndex(), index.row(), QModelIndex(), index.row() + 2);
}
void EditorFontWidget::on_btnResetFonts_clicked()
void EditorFontWidget::on_btnMoveFontToBottom_clicked()
{
mModel.updateFonts(defaultEditorFonts());
QModelIndex index = ui->lstFontList->currentIndex();
if (!index.isValid())
return;
if (index.row() == mModel.rowCount() - 1)
return;
mModel.moveRow(QModelIndex(), index.row(), QModelIndex(), mModel.rowCount());
}
void EditorFontWidget::doLoad()
{
//pSettings->editor().load();
//font
ui->cbNewFont->setCurrentFont(QFont(defaultMonoFont()));
mModel.updateFonts(pSettings->editor().fontFamilies());
ui->spinFontSize->setValue(pSettings->editor().fontSize());
ui->spinLineSpacing->setValue(pSettings->editor().lineSpacing());
ui->chkLigature->setChecked(pSettings->editor().enableLigaturesSupport());
@ -206,7 +174,7 @@ void EditorFontWidget::doLoad()
void EditorFontWidget::doSave()
{
//font
pSettings->editor().setFontFamilies(mModel.fonts());
pSettings->editor().setFontFamilies(mModel.stringList());
pSettings->editor().setFontSize(ui->spinFontSize->value());
pSettings->editor().setLineSpacing(ui->spinLineSpacing->value());
@ -238,7 +206,10 @@ void EditorFontWidget::doSave()
void EditorFontWidget::updateIcons(const QSize &/*size*/) {
pIconsManager->setIcon(ui->btnAddFont, IconsManager::ACTION_MISC_ADD);
pIconsManager->setIcon(ui->btnRemoveFont, IconsManager::ACTION_MISC_REMOVE);
pIconsManager->setIcon(ui->btnModifyFont, IconsManager::ACTION_MISC_RENAME);
pIconsManager->setIcon(ui->btnResetFonts, IconsManager::ACTION_MISC_RESET);
pIconsManager->setIcon(ui->btnMoveFontToTop, IconsManager::ACTION_MISC_MOVETOP);
pIconsManager->setIcon(ui->btnMoveFontUp, IconsManager::ACTION_MISC_MOVEUP);
pIconsManager->setIcon(ui->btnMoveFontDown, IconsManager::ACTION_MISC_MOVEDOWN);
pIconsManager->setIcon(ui->btnResetFonts, IconsManager::ACTION_MISC_RESET);
pIconsManager->setIcon(ui->btnMoveFontToBottom, IconsManager::ACTION_MISC_MOVEBOTTOM);
}

View File

@ -18,7 +18,7 @@
#define EDITORFONTWIDGET_H
#include <QWidget>
#include <QAbstractListModel>
#include <QStringListModel>
#include "settingswidget.h"
#include "utils/font.h"
@ -26,28 +26,12 @@ namespace Ui {
class EditorFontWidget;
}
class EditorFontModel : public QAbstractListModel
class EditorFontModel : public QStringListModel
{
Q_OBJECT
public:
void addFont(const QString& font);
void remove(int index);
void clear();
void moveUp(int index);
void moveDown(int index);
QModelIndex lastFont();
const QStringList &fonts() const;
void updateFonts(const QStringList& fonts);
// QAbstractItemModel interface
public:
int rowCount(const QModelIndex &parent) const override;
int columnCount(const QModelIndex &parent) const override;
QVariant data(const QModelIndex &index, int role) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
private:
QStringList mFonts;
using QStringListModel::QStringListModel;
Qt::ItemFlags flags(const QModelIndex &index) const;
};
class EditorFontWidget : public SettingsWidget
@ -62,9 +46,12 @@ private slots:
void on_chkGutterOnlyMonospacedFonts_stateChanged(int arg1);
void on_btnAddFont_clicked();
void on_btnRemoveFont_clicked();
void on_btnModifyFont_clicked();
void on_btnResetFonts_clicked();
void on_btnMoveFontToTop_clicked();
void on_btnMoveFontUp_clicked();
void on_btnMoveFontDown_clicked();
void on_btnResetFonts_clicked();
void on_btnMoveFontToBottom_clicked();
// void on_chkLigature_toggled(bool checked);

View File

@ -17,28 +17,15 @@
<item>
<widget class="QGroupBox" name="groupFontFamilies">
<property name="title">
<string>Font:</string>
<string>Font</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QFontComboBox" name="cbNewFont"/>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="btnAddFont">
<property name="toolTip">
<string>Add</string>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QListView" name="lstFontList"/>
</item>
<item row="1" column="1">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QGridLayout" name="layoutFontListActions">
<item row="1" column="0">
<widget class="QToolButton" name="btnRemoveFont">
<property name="toolTip">
<string>Remove</string>
@ -48,27 +35,17 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnMoveFontUp">
<item row="2" column="0">
<widget class="QToolButton" name="btnModifyFont">
<property name="toolTip">
<string>Move up</string>
<string>Modify</string>
</property>
<property name="text">
<string>Move up</string>
<string>Modify</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnMoveFontDown">
<property name="toolTip">
<string>Move down</string>
</property>
<property name="text">
<string>Move down</string>
</property>
</widget>
</item>
<item>
<item row="3" column="0">
<widget class="QToolButton" name="btnResetFonts">
<property name="toolTip">
<string>Reset</string>
@ -78,7 +55,17 @@
</property>
</widget>
</item>
<item>
<item row="0" column="0">
<widget class="QToolButton" name="btnAddFont">
<property name="toolTip">
<string>Add</string>
</property>
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -91,6 +78,46 @@
</property>
</spacer>
</item>
<item row="2" column="1">
<widget class="QToolButton" name="btnMoveFontDown">
<property name="toolTip">
<string>Move down</string>
</property>
<property name="text">
<string>Move down</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QToolButton" name="btnMoveFontUp">
<property name="toolTip">
<string>Move up</string>
</property>
<property name="text">
<string>Move up</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="btnMoveFontToTop">
<property name="toolTip">
<string>Move to top</string>
</property>
<property name="text">
<string>Move to top</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QToolButton" name="btnMoveFontToBottom">
<property name="toolTip">
<string>Move to bottom</string>
</property>
<property name="text">
<string>Move to bottom</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@ -1862,6 +1862,19 @@
<translation>Esquema &apos;%1&apos; será removido!&lt;br /&gt;Quer mesmo continuar?</translation>
</message>
</context>
<context>
<name>EditorFontDialog</name>
<message>
<location filename="../widgets/editorfontdialog.ui" line="+14"/>
<source>Choose Font</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+9"/>
<source>Show only monospaced fonts</source>
<translation>Mostrar apenas fontes com espaçamento único</translation>
</message>
</context>
<context>
<name>EditorFontWidget</name>
<message>
@ -1870,8 +1883,13 @@
<translation>Configuração</translation>
</message>
<message>
<location line="+6"/>
<location line="+488"/>
<location line="+27"/>
<location line="+3"/>
<source>Modify</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+491"/>
<source>Font:</source>
<translation>Fonte</translation>
</message>
@ -1950,7 +1968,24 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+30"/>
<location line="-133"/>
<source>Font</source>
<translation type="unfinished">Fonte</translation>
</message>
<message>
<location line="+84"/>
<location line="+3"/>
<source>Move to top</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<location line="+3"/>
<source>Move to bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+66"/>
<source>Line Spacing:</source>
<translation type="unfinished"></translation>
</message>
@ -1989,31 +2024,31 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-104"/>
<location line="-99"/>
<location line="+3"/>
<source>Add</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+12"/>
<location line="-33"/>
<location line="+3"/>
<source>Remove</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<location line="+60"/>
<location line="+3"/>
<source>Move up</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<location line="-13"/>
<location line="+3"/>
<source>Move down</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<location line="-36"/>
<location line="+3"/>
<source>Reset</source>
<translation type="unfinished">Reset</translation>
@ -5688,12 +5723,22 @@
<translation>Propriedades...</translation>
</message>
<message>
<location line="-1274"/>
<location line="-1280"/>
<source>Line: %1/%2 Col: %3 Sel: %4</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+6"/>
<source>Line: %1/%2 Col: %3</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1253"/>
<location line="+7"/>
<source>Line: %1/%2 Char: %3/%4 Sel: %5</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1246"/>
<source>Open Source File</source>
<translation>Abrir arquivo fonte</translation>
</message>
@ -6064,12 +6109,7 @@
<translation>Quer mesmo fazer isso?</translation>
</message>
<message>
<location line="-4320"/>
<source>Line: %1/%2 Col: %3 Sel:%4</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+4475"/>
<location line="+155"/>
<location line="+105"/>
<source>Compile Failed</source>
<translation>Falha ao compilar</translation>
@ -6995,12 +7035,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-5594"/>
<source>Line: %1/%2 Char: %3/%4 Sel:%5</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<location line="-5587"/>
<source>Line: %1/%2 Char: %3/%4</source>
<translation type="unfinished"></translation>
</message>
@ -8339,7 +8374,7 @@
<location filename="../autolinkmanager.cpp" line="+54"/>
<location line="+16"/>
<location line="+19"/>
<location filename="../settings.cpp" line="+4050"/>
<location filename="../settings.cpp" line="+4057"/>
<location filename="../widgets/ojproblemsetmodel.cpp" line="-401"/>
<location line="+61"/>
<source>Can&apos;t open file &apos;%1&apos; for read.</source>
@ -9156,7 +9191,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings.cpp" line="-138"/>
<location filename="../settings.cpp" line="-141"/>
<source>Error executing platform compiler hint add-on</source>
<translation type="unfinished"></translation>
</message>
@ -10080,7 +10115,7 @@
<context>
<name>Settings</name>
<message>
<location filename="../settings.cpp" line="+724"/>
<location filename="../settings.cpp" line="+727"/>
<source>Error</source>
<translation type="unfinished">Erro</translation>
</message>

View File

@ -2112,6 +2112,19 @@ p, li { white-space: pre-wrap; }
<translation>&apos;%1&apos;&lt;br /&gt;</translation>
</message>
</context>
<context>
<name>EditorFontDialog</name>
<message>
<location filename="../widgets/editorfontdialog.ui" line="+14"/>
<source>Choose Font</source>
<translation></translation>
</message>
<message>
<location line="+9"/>
<source>Show only monospaced fonts</source>
<translation></translation>
</message>
</context>
<context>
<name>EditorFontWidget</name>
<message>
@ -2124,41 +2137,51 @@ p, li { white-space: pre-wrap; }
<translation type="vanished">*</translation>
</message>
<message>
<location line="+149"/>
<location line="+176"/>
<location line="+352"/>
<source>Size:</source>
<translation>:</translation>
</message>
<message>
<location line="-495"/>
<location line="+488"/>
<location line="-7"/>
<source>Font:</source>
<translation>:</translation>
</message>
<message>
<location line="-479"/>
<location line="-474"/>
<location line="+3"/>
<source>Add</source>
<translation></translation>
</message>
<message>
<location line="+12"/>
<location line="-44"/>
<source>Font</source>
<translation></translation>
</message>
<message>
<location line="+11"/>
<location line="+3"/>
<source>Remove</source>
<translation></translation>
</message>
<message>
<location line="+7"/>
<location line="+60"/>
<location line="+3"/>
<source>Move up</source>
<translation></translation>
</message>
<message>
<location line="+7"/>
<location line="-13"/>
<location line="+3"/>
<source>Move down</source>
<translation></translation>
</message>
<message>
<location line="-46"/>
<location line="+3"/>
<source>Modify</source>
<translation></translation>
</message>
<message>
<location line="+7"/>
<location line="+3"/>
@ -2166,7 +2189,19 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location line="+526"/>
<location line="+50"/>
<location line="+3"/>
<source>Move to top</source>
<translation></translation>
</message>
<message>
<location line="+7"/>
<location line="+3"/>
<source>Move to bottom</source>
<translation></translation>
</message>
<message>
<location line="+513"/>
<source>Show only monospaced fonts</source>
<translation></translation>
</message>
@ -6371,12 +6406,11 @@ p, li { white-space: pre-wrap; }
<translation type="vanished">%1</translation>
</message>
<message>
<location line="-1246"/>
<source>Line: %1/%2 Char: %3/%4 Sel:%5</source>
<translation>: %1/%2 : %3/%4 :%5</translation>
<translation type="vanished">: %1/%2 : %3/%4 :%5</translation>
</message>
<message>
<location line="+7"/>
<location line="-1239"/>
<source>Line: %1/%2 Char: %3/%4</source>
<translation>: %1/%2 : %3/%4</translation>
</message>
@ -6562,12 +6596,22 @@ p, li { white-space: pre-wrap; }
<translation> %1</translation>
</message>
<message>
<location line="+271"/>
<location line="+265"/>
<source>Line: %1/%2 Col: %3 Sel: %4</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+6"/>
<source>Line: %1/%2 Col: %3</source>
<translation>: %1/%2 : %3</translation>
</message>
<message>
<location line="+1333"/>
<location line="+7"/>
<source>Line: %1/%2 Char: %3/%4 Sel: %5</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1326"/>
<source>Remove All Bookmarks</source>
<translation></translation>
</message>
@ -6731,12 +6775,11 @@ p, li { white-space: pre-wrap; }
<translation type="vanished"></translation>
</message>
<message>
<location line="-640"/>
<source>Line: %1/%2 Col: %3 Sel:%4</source>
<translation>: %1/%2 : %3 :%4</translation>
<translation type="vanished">: %1/%2 : %3 :%4</translation>
</message>
<message>
<location line="+1273"/>
<location line="+633"/>
<source>Goto Url</source>
<translation></translation>
</message>
@ -9191,7 +9234,7 @@ p, li { white-space: pre-wrap; }
<translation>(-g3)</translation>
</message>
<message>
<location filename="../settings.cpp" line="+3448"/>
<location filename="../settings.cpp" line="+3455"/>
<source>Would you like Red Panda C++ to search for compilers in PATH?</source>
<translation>C++PATH路径中寻找gcc编译器吗</translation>
</message>
@ -9853,7 +9896,7 @@ p, li { white-space: pre-wrap; }
<translation> %1 </translation>
</message>
<message>
<location filename="../settings.cpp" line="-742"/>
<location filename="../settings.cpp" line="-745"/>
<source>Error executing platform compiler hint add-on</source>
<translation></translation>
</message>
@ -10825,7 +10868,7 @@ p, li { white-space: pre-wrap; }
<context>
<name>Settings</name>
<message>
<location filename="../settings.cpp" line="+724"/>
<location filename="../settings.cpp" line="+727"/>
<source>Error</source>
<translation></translation>
</message>

View File

@ -1703,6 +1703,19 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditorFontDialog</name>
<message>
<location filename="../widgets/editorfontdialog.ui" line="+14"/>
<source>Choose Font</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+9"/>
<source>Show only monospaced fonts</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditorFontWidget</name>
<message>
@ -1711,8 +1724,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+6"/>
<location line="+488"/>
<location line="+521"/>
<source>Font:</source>
<translation type="unfinished"></translation>
</message>
@ -1728,7 +1740,24 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-220"/>
<location line="-522"/>
<source>Font</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+84"/>
<location line="+3"/>
<source>Move to top</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<location line="+3"/>
<source>Move to bottom</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+205"/>
<source>Gutter</source>
<translation type="unfinished"></translation>
</message>
@ -1783,7 +1812,13 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+30"/>
<location line="-112"/>
<location line="+3"/>
<source>Modify</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+139"/>
<source>Line Spacing:</source>
<translation type="unfinished"></translation>
</message>
@ -1818,31 +1853,31 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-104"/>
<location line="-99"/>
<location line="+3"/>
<source>Add</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+12"/>
<location line="-33"/>
<location line="+3"/>
<source>Remove</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<location line="+60"/>
<location line="+3"/>
<source>Move up</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<location line="-13"/>
<location line="+3"/>
<source>Move down</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<location line="-36"/>
<location line="+3"/>
<source>Reset</source>
<translation type="unfinished"></translation>
@ -5311,12 +5346,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="+104"/>
<source>Line: %1/%2 Col: %3 Sel:%4</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+44"/>
<location line="+148"/>
<source>Read Only</source>
<translation type="unfinished"></translation>
</message>
@ -5414,12 +5444,22 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-1274"/>
<location line="-1280"/>
<source>Line: %1/%2 Col: %3 Sel: %4</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+6"/>
<source>Line: %1/%2 Col: %3</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1253"/>
<location line="+7"/>
<source>Line: %1/%2 Char: %3/%4 Sel: %5</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+1246"/>
<source>Open Source File</source>
<translation type="unfinished"></translation>
</message>
@ -6696,12 +6736,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location line="-5594"/>
<source>Line: %1/%2 Char: %3/%4 Sel:%5</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+7"/>
<location line="-5587"/>
<source>Line: %1/%2 Char: %3/%4</source>
<translation type="unfinished"></translation>
</message>
@ -7967,7 +8002,7 @@
<location filename="../autolinkmanager.cpp" line="+54"/>
<location line="+16"/>
<location line="+19"/>
<location filename="../settings.cpp" line="+4050"/>
<location filename="../settings.cpp" line="+4057"/>
<location filename="../widgets/ojproblemsetmodel.cpp" line="-401"/>
<location line="+61"/>
<source>Can&apos;t open file &apos;%1&apos; for read.</source>
@ -8644,7 +8679,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../settings.cpp" line="-140"/>
<location filename="../settings.cpp" line="-143"/>
<source>Error executing platform compiler hint add-on</source>
<translation type="unfinished"></translation>
</message>
@ -9389,7 +9424,7 @@
<context>
<name>Settings</name>
<message>
<location filename="../settings.cpp" line="+724"/>
<location filename="../settings.cpp" line="+727"/>
<source>Error</source>
<translation type="unfinished"></translation>
</message>

View File

@ -0,0 +1,40 @@
#include "editorfontdialog.h"
#include "ui_editorfontdialog.h"
EditorFontDialog::EditorFontDialog(QWidget *parent)
: QDialog(parent)
, ui(new Ui::EditorFontDialog)
{
ui->setupUi(this);
}
EditorFontDialog::~EditorFontDialog()
{
delete ui;
}
QString EditorFontDialog::fontFamily() const
{
return mFontFamily;
}
void EditorFontDialog::setFontFamily(const QString &fontFamily)
{
mFontFamily = fontFamily;
ui->fontComboBox->setCurrentFont(QFont(mFontFamily));
}
void EditorFontDialog::on_chkMonoOnly_toggled(bool checked)
{
QString savedFont = ui->fontComboBox->currentFont().family();
ui->fontComboBox->setFontFilters(checked ? QFontComboBox::MonospacedFonts : QFontComboBox::AllFonts);
ui->fontComboBox->setCurrentFont(QFont(savedFont));
ui->fontComboBox->adjustSize();
}
void EditorFontDialog::on_buttonBox_accepted()
{
mFontFamily = ui->fontComboBox->currentFont().family();
}

View File

@ -0,0 +1,30 @@
#ifndef EDITORFONTDIALOG_H
#define EDITORFONTDIALOG_H
#include <QDialog>
namespace Ui {
class EditorFontDialog;
}
class EditorFontDialog : public QDialog
{
Q_OBJECT
public:
explicit EditorFontDialog(QWidget *parent = nullptr);
~EditorFontDialog();
QString fontFamily() const;
void setFontFamily(const QString &fontFamily);
private slots:
void on_chkMonoOnly_toggled(bool checked);
void on_buttonBox_accepted();
private:
Ui::EditorFontDialog *ui;
QString mFontFamily;
};
#endif // EDITORFONTDIALOG_H

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditorFontDialog</class>
<widget class="QDialog" name="EditorFontDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>369</width>
<height>152</height>
</rect>
</property>
<property name="windowTitle">
<string>Choose Font</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFontComboBox" name="fontComboBox"/>
</item>
<item>
<widget class="QCheckBox" name="chkMonoOnly">
<property name="text">
<string>Show only monospaced fonts</string>
</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>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>EditorFontDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>EditorFontDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -161,6 +161,7 @@ target("RedPandaIDE")
"widgets/choosethemedialog",
"widgets/cpudialog",
"widgets/custommakefileinfodialog",
"widgets/editorfontdialog",
"widgets/filepropertiesdialog",
"widgets/infomessagebox",
"widgets/newclassdialog",