editor font list settings:

Items not editable.
 Double click on a item to modify.
This commit is contained in:
Roy Qu 2024-03-17 11:41:40 +08:00
parent 3e58c52046
commit 852a451976
3 changed files with 35 additions and 2 deletions

View File

@ -29,7 +29,7 @@ Qt::ItemFlags EditorFontModel::flags(const QModelIndex &index) const
{
Qt::ItemFlags flags = Qt::NoItemFlags;
if (index.isValid()) {
flags = Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable ;
flags = Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemIsSelectable ;
} else if (index.row() == -1) {
// -1 means it's a drop target?
flags = Qt::ItemIsDropEnabled;
@ -213,3 +213,15 @@ void EditorFontWidget::updateIcons(const QSize &/*size*/) {
pIconsManager->setIcon(ui->btnMoveFontDown, IconsManager::ACTION_MISC_MOVEDOWN);
pIconsManager->setIcon(ui->btnMoveFontToBottom, IconsManager::ACTION_MISC_MOVEBOTTOM);
}
void EditorFontWidget::on_lstFontList_doubleClicked(const QModelIndex &index)
{
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());
}
}

View File

@ -57,6 +57,8 @@ private slots:
// void on_chkForceFixedFontWidth_toggled(bool checked);
void on_lstFontList_doubleClicked(const QModelIndex &index);
private:
Ui::EditorFontWidget *ui;
EditorFontModel mModel;

View File

@ -15,7 +15,20 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFontComboBox" name="fontComboBox"/>
<widget class="QFontComboBox" name="fontComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>false</bool>
</property>
<property name="maxVisibleItems">
<number>15</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkMonoOnly">
@ -39,6 +52,12 @@
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>