2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-06-08 21:41:42 +08:00
|
|
|
#ifndef EDITORFONTWIDGET_H
|
|
|
|
#define EDITORFONTWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
2024-03-13 19:17:25 +08:00
|
|
|
#include <QAbstractListModel>
|
2021-06-08 21:41:42 +08:00
|
|
|
#include "settingswidget.h"
|
2024-03-13 19:17:25 +08:00
|
|
|
#include "utils/font.h"
|
2021-06-08 21:41:42 +08:00
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class EditorFontWidget;
|
|
|
|
}
|
|
|
|
|
2024-03-13 19:17:25 +08:00
|
|
|
class EditorFontModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2021-06-08 21:41:42 +08:00
|
|
|
class EditorFontWidget : public SettingsWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit EditorFontWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
|
|
|
|
~EditorFontWidget();
|
|
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void on_chkGutterOnlyMonospacedFonts_stateChanged(int arg1);
|
2024-03-13 19:17:25 +08:00
|
|
|
void on_btnAddFont_clicked();
|
|
|
|
void on_btnRemoveFont_clicked();
|
|
|
|
void on_btnMoveFontUp_clicked();
|
|
|
|
void on_btnMoveFontDown_clicked();
|
|
|
|
void on_btnResetFonts_clicked();
|
2021-06-08 21:41:42 +08:00
|
|
|
|
2024-02-28 11:51:02 +08:00
|
|
|
// void on_chkLigature_toggled(bool checked);
|
|
|
|
|
|
|
|
// void on_chkForceFixedFontWidth_toggled(bool checked);
|
|
|
|
|
2021-06-08 21:41:42 +08:00
|
|
|
private:
|
|
|
|
Ui::EditorFontWidget *ui;
|
2024-03-13 19:17:25 +08:00
|
|
|
EditorFontModel mModel;
|
2021-06-08 21:41:42 +08:00
|
|
|
|
|
|
|
// SettingsWidget interface
|
|
|
|
protected:
|
|
|
|
void doLoad() override;
|
|
|
|
void doSave() override;
|
2024-03-13 19:17:25 +08:00
|
|
|
void updateIcons(const QSize &size) override;
|
2021-06-08 21:41:42 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // EDITORFONTWIDGET_H
|