diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index fe4f69af..a16f0f72 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -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 \ diff --git a/RedPandaIDE/iconsmanager.cpp b/RedPandaIDE/iconsmanager.cpp index 21c70d03..9a0f3728 100644 --- a/RedPandaIDE/iconsmanager.cpp +++ b/RedPandaIDE/iconsmanager.cpp @@ -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)); diff --git a/RedPandaIDE/iconsmanager.h b/RedPandaIDE/iconsmanager.h index 5991469d..23abab54 100644 --- a/RedPandaIDE/iconsmanager.h +++ b/RedPandaIDE/iconsmanager.h @@ -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, diff --git a/RedPandaIDE/resources/iconsets/bluesky/actions/00Misc-17MoveTop.svg b/RedPandaIDE/resources/iconsets/bluesky/actions/00Misc-17MoveTop.svg new file mode 100644 index 00000000..2e3457fb --- /dev/null +++ b/RedPandaIDE/resources/iconsets/bluesky/actions/00Misc-17MoveTop.svg @@ -0,0 +1 @@ + diff --git a/RedPandaIDE/resources/iconsets/bluesky/actions/00Misc-18MoveBottom.svg b/RedPandaIDE/resources/iconsets/bluesky/actions/00Misc-18MoveBottom.svg new file mode 100644 index 00000000..8c05e81c --- /dev/null +++ b/RedPandaIDE/resources/iconsets/bluesky/actions/00Misc-18MoveBottom.svg @@ -0,0 +1 @@ + diff --git a/RedPandaIDE/resources/iconsets/contrast/actions/00Misc-17MoveTop.svg b/RedPandaIDE/resources/iconsets/contrast/actions/00Misc-17MoveTop.svg new file mode 100644 index 00000000..3a91ceb8 --- /dev/null +++ b/RedPandaIDE/resources/iconsets/contrast/actions/00Misc-17MoveTop.svg @@ -0,0 +1 @@ + diff --git a/RedPandaIDE/resources/iconsets/contrast/actions/00Misc-18MoveBottom.svg b/RedPandaIDE/resources/iconsets/contrast/actions/00Misc-18MoveBottom.svg new file mode 100644 index 00000000..98c1a293 --- /dev/null +++ b/RedPandaIDE/resources/iconsets/contrast/actions/00Misc-18MoveBottom.svg @@ -0,0 +1 @@ + diff --git a/RedPandaIDE/resources/iconsets/newlook/actions/00Misc-17MoveTop.svg b/RedPandaIDE/resources/iconsets/newlook/actions/00Misc-17MoveTop.svg new file mode 100644 index 00000000..7107f4ed --- /dev/null +++ b/RedPandaIDE/resources/iconsets/newlook/actions/00Misc-17MoveTop.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/RedPandaIDE/resources/iconsets/newlook/actions/00Misc-18MoveBottom.svg b/RedPandaIDE/resources/iconsets/newlook/actions/00Misc-18MoveBottom.svg new file mode 100644 index 00000000..04c683fa --- /dev/null +++ b/RedPandaIDE/resources/iconsets/newlook/actions/00Misc-18MoveBottom.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/RedPandaIDE/settingsdialog/editorfontwidget.cpp b/RedPandaIDE/settingsdialog/editorfontwidget.cpp index f5abc821..70ffa2cf 100644 --- a/RedPandaIDE/settingsdialog/editorfontwidget.cpp +++ b/RedPandaIDE/settingsdialog/editorfontwidget.cpp @@ -22,107 +22,35 @@ #include "../iconsmanager.h" #include "utils.h" #include "utils/font.h" +#include "widgets/editorfontdialog.h" +#include -void EditorFontModel::addFont(const QString& font) +Qt::ItemFlags EditorFontModel::flags(const QModelIndex &index) const { - beginInsertRows(QModelIndex(),mFonts.size(),mFonts.size()); - mFonts.append(font); - endInsertRows(); -} - -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; + 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; } - 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); } diff --git a/RedPandaIDE/settingsdialog/editorfontwidget.h b/RedPandaIDE/settingsdialog/editorfontwidget.h index 1464b110..7c07f176 100644 --- a/RedPandaIDE/settingsdialog/editorfontwidget.h +++ b/RedPandaIDE/settingsdialog/editorfontwidget.h @@ -18,7 +18,7 @@ #define EDITORFONTWIDGET_H #include -#include +#include #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); diff --git a/RedPandaIDE/settingsdialog/editorfontwidget.ui b/RedPandaIDE/settingsdialog/editorfontwidget.ui index 6e1e7e9e..327822f7 100644 --- a/RedPandaIDE/settingsdialog/editorfontwidget.ui +++ b/RedPandaIDE/settingsdialog/editorfontwidget.ui @@ -17,28 +17,15 @@ - Font: + Font - - - - - - - Add - - - Add - - - - - + + Remove @@ -48,27 +35,17 @@ - - + + - Move up + Modify - Move up + Modify - - - - Move down - - - Move down - - - - + Reset @@ -78,7 +55,17 @@ - + + + + Add + + + Add + + + + Qt::Vertical @@ -91,6 +78,46 @@ + + + + Move down + + + Move down + + + + + + + Move up + + + Move up + + + + + + + Move to top + + + Move to top + + + + + + + Move to bottom + + + Move to bottom + + + diff --git a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts index f4686305..ec75a814 100644 --- a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts +++ b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts @@ -1862,6 +1862,19 @@ Esquema '%1' será removido!<br />Quer mesmo continuar? + + EditorFontDialog + + + Choose Font + + + + + Show only monospaced fonts + Mostrar apenas fontes com espaçamento único + + EditorFontWidget @@ -1870,8 +1883,13 @@ Configuração - - + + + Modify + + + + Font: Fonte @@ -1950,7 +1968,24 @@ - + + Font + Fonte + + + + + Move to top + + + + + + Move to bottom + + + + Line Spacing: @@ -1989,31 +2024,31 @@ - + Add - + Remove - + Move up - + Move down - + Reset Reset @@ -5688,12 +5723,22 @@ Propriedades... - + + Line: %1/%2 Col: %3 Sel: %4 + + + + Line: %1/%2 Col: %3 - + + Line: %1/%2 Char: %3/%4 Sel: %5 + + + + Open Source File Abrir arquivo fonte @@ -6064,12 +6109,7 @@ Quer mesmo fazer isso? - - Line: %1/%2 Col: %3 Sel:%4 - - - - + Compile Failed Falha ao compilar @@ -6995,12 +7035,7 @@ - - Line: %1/%2 Char: %3/%4 Sel:%5 - - - - + Line: %1/%2 Char: %3/%4 @@ -8339,7 +8374,7 @@ - + Can't open file '%1' for read. @@ -9156,7 +9191,7 @@ - + Error executing platform compiler hint add-on @@ -10080,7 +10115,7 @@ Settings - + Error Erro diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts index e3f06567..b8046486 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts @@ -2112,6 +2112,19 @@ p, li { white-space: pre-wrap; } 配色方案'%1'将会被删除!<br />您确认要继续吗? + + EditorFontDialog + + + Choose Font + 选择字体 + + + + Show only monospaced fonts + 只显示等宽字体 + + EditorFontWidget @@ -2124,41 +2137,51 @@ p, li { white-space: pre-wrap; } *需要重启之后生效 - + Size: 大小: - - + Font: 字体: - + Add 添加 - + + Font + 字体 + + + Remove 删除 - + Move up 上移 - + Move down 下移 + + + + Modify + 修改 + @@ -2166,7 +2189,19 @@ p, li { white-space: pre-wrap; } 恢复默认 - + + + Move to top + 移至顶部 + + + + + Move to bottom + 移至底部 + + + Show only monospaced fonts 只显示等宽字体 @@ -6371,12 +6406,11 @@ p, li { white-space: pre-wrap; } %1版 - Line: %1/%2 Char: %3/%4 Sel:%5 - 行: %1/%2 字符: %3/%4 选中:%5 + 行: %1/%2 字符: %3/%4 选中:%5 - + Line: %1/%2 Char: %3/%4 行: %1/%2 字符: %3/%4 @@ -6562,12 +6596,22 @@ p, li { white-space: pre-wrap; } %1版 - + + Line: %1/%2 Col: %3 Sel: %4 + + + + Line: %1/%2 Col: %3 行: %1/%2 列: %3 - + + Line: %1/%2 Char: %3/%4 Sel: %5 + + + + Remove All Bookmarks 删除全部书签 @@ -6731,12 +6775,11 @@ p, li { white-space: pre-wrap; } 请取消该设置,重新编译然后重新启动调试。 - Line: %1/%2 Col: %3 Sel:%4 - 行: %1/%2 字符: %3 选中:%4 + 行: %1/%2 字符: %3 选中:%4 - + Goto Url 跳转到试题网址 @@ -9191,7 +9234,7 @@ p, li { white-space: pre-wrap; } 生成调试信息(-g3) - + Would you like Red Panda C++ to search for compilers in PATH? 您同意小熊猫C++在PATH路径中寻找gcc编译器吗? @@ -9853,7 +9896,7 @@ p, li { white-space: pre-wrap; } 无法检测适用于 “%1” 的终端参数模式。 - + Error executing platform compiler hint add-on 执行平台编译器提示附加组件错误 @@ -10825,7 +10868,7 @@ p, li { white-space: pre-wrap; } Settings - + Error 错误 diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts index ac91aabc..5c722779 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts @@ -1703,6 +1703,19 @@ + + EditorFontDialog + + + Choose Font + + + + + Show only monospaced fonts + + + EditorFontWidget @@ -1711,8 +1724,7 @@ - - + Font: @@ -1728,7 +1740,24 @@ - + + Font + + + + + + Move to top + + + + + + Move to bottom + + + + Gutter @@ -1783,7 +1812,13 @@ - + + + Modify + + + + Line Spacing: @@ -1818,31 +1853,31 @@ - + Add - + Remove - + Move up - + Move down - + Reset @@ -5311,12 +5346,7 @@ - - Line: %1/%2 Col: %3 Sel:%4 - - - - + Read Only @@ -5414,12 +5444,22 @@ - + + Line: %1/%2 Col: %3 Sel: %4 + + + + Line: %1/%2 Col: %3 - + + Line: %1/%2 Char: %3/%4 Sel: %5 + + + + Open Source File @@ -6696,12 +6736,7 @@ - - Line: %1/%2 Char: %3/%4 Sel:%5 - - - - + Line: %1/%2 Char: %3/%4 @@ -7967,7 +8002,7 @@ - + Can't open file '%1' for read. @@ -8644,7 +8679,7 @@ - + Error executing platform compiler hint add-on @@ -9389,7 +9424,7 @@ Settings - + Error diff --git a/RedPandaIDE/widgets/editorfontdialog.cpp b/RedPandaIDE/widgets/editorfontdialog.cpp new file mode 100644 index 00000000..d28952cf --- /dev/null +++ b/RedPandaIDE/widgets/editorfontdialog.cpp @@ -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(); +} + diff --git a/RedPandaIDE/widgets/editorfontdialog.h b/RedPandaIDE/widgets/editorfontdialog.h new file mode 100644 index 00000000..1239e78d --- /dev/null +++ b/RedPandaIDE/widgets/editorfontdialog.h @@ -0,0 +1,30 @@ +#ifndef EDITORFONTDIALOG_H +#define EDITORFONTDIALOG_H + +#include + +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 diff --git a/RedPandaIDE/widgets/editorfontdialog.ui b/RedPandaIDE/widgets/editorfontdialog.ui new file mode 100644 index 00000000..1afae595 --- /dev/null +++ b/RedPandaIDE/widgets/editorfontdialog.ui @@ -0,0 +1,87 @@ + + + EditorFontDialog + + + + 0 + 0 + 369 + 152 + + + + Choose Font + + + + + + + + + Show only monospaced fonts + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + EditorFontDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + EditorFontDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/RedPandaIDE/xmake.lua b/RedPandaIDE/xmake.lua index f714faa0..26328299 100644 --- a/RedPandaIDE/xmake.lua +++ b/RedPandaIDE/xmake.lua @@ -161,6 +161,7 @@ target("RedPandaIDE") "widgets/choosethemedialog", "widgets/cpudialog", "widgets/custommakefileinfodialog", + "widgets/editorfontdialog", "widgets/filepropertiesdialog", "widgets/infomessagebox", "widgets/newclassdialog",