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

View File

@ -15,7 +15,20 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <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>
<item> <item>
<widget class="QCheckBox" name="chkMonoOnly"> <widget class="QCheckBox" name="chkMonoOnly">
@ -39,6 +52,12 @@
</item> </item>
<item> <item>
<widget class="QDialogButtonBox" name="buttonBox"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>