diff options
author | Mavridis Philippe <mavridisf@gmail.com> | 2022-06-08 14:46:24 +0300 |
---|---|---|
committer | Mavridis Philippe <mavridisf@gmail.com> | 2022-06-08 15:03:39 +0300 |
commit | d633f38f6ffd57c5d03aa0eaf37dc0f6d5c42fad (patch) | |
tree | 252cd864bb8436fdb504ec46e1cd780ede04bbb3 | |
parent | 65ab72853b27a5f49b2de0a12cdcb4b33756a7e1 (diff) | |
download | tdelibs-d633f38f6ffd57c5d03aa0eaf37dc0f6d5c42fad.tar.gz tdelibs-d633f38f6ffd57c5d03aa0eaf37dc0f6d5c42fad.zip |
TDEFontChooser: backport setFamilyList(...) from KOffice
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
-rw-r--r-- | tdeui/tdefontdialog.cpp | 30 | ||||
-rw-r--r-- | tdeui/tdefontdialog.h | 11 |
2 files changed, 39 insertions, 2 deletions
diff --git a/tdeui/tdefontdialog.cpp b/tdeui/tdefontdialog.cpp index 0da56a93b..d29ea60be 100644 --- a/tdeui/tdefontdialog.cpp +++ b/tdeui/tdefontdialog.cpp @@ -473,8 +473,18 @@ TQString TDEFontChooser::style_name(const TQString &style) void TDEFontChooser::family_chosen_slot(const TQString& family) { + TQString currentFamily; + if (family.isEmpty()) + { + currentFamily = familyListBox->currentText(); + } + else + { + currentFamily = family; + } + TQFontDatabase dbase; - TQStringList styles = dbase.styles(family); + TQStringList styles = dbase.styles(currentFamily); styleListBox->clear(); currentStyles.clear(); for ( TQStringList::Iterator it = styles.begin(); it != styles.end(); ++it ) { @@ -492,12 +502,21 @@ void TDEFontChooser::family_chosen_slot(const TQString& family) styleListBox->blockSignals(true); TQListBoxItem *item = styleListBox->findItem(selectedStyle); if (item) + { styleListBox->setSelected(styleListBox->findItem(selectedStyle), true); + } else + { styleListBox->setSelected(0, true); + } styleListBox->blockSignals(false); style_chosen_slot(TQString::null); + + if (!family.isEmpty() ) + { + selectedFamily = family; + } } void TDEFontChooser::size_chosen_slot(const TQString& size){ @@ -685,6 +704,15 @@ void TDEFontChooser::getFontList( TQStringList &list, uint fontListCriteria) list = lstSys; } +void TDEFontChooser::setFamilyList( TQStringList list ) +{ + familyListBox->blockSignals(true); + familyListBox->clear(); + familyListBox->insertStringList(list); + setFont( TDEGlobalSettings::generalFont(), usingFixed ); + familyListBox->blockSignals(false); +} + void TDEFontChooser::addFont( TQStringList &list, const char *xfont ) { const char *ptr = strchr( xfont, '-' ); diff --git a/tdeui/tdefontdialog.h b/tdeui/tdefontdialog.h index 66d202700..de966d47d 100644 --- a/tdeui/tdefontdialog.h +++ b/tdeui/tdefontdialog.h @@ -250,6 +250,14 @@ public: static void getFontList( TQStringList &list, uint fontListCriteria); /** + * + * Fill the font family list of the TDEFontChooser + * + * @param list The font list. + */ + void setFamilyList( TQStringList list ); + + /** * Reimplemented for internal reasons. */ virtual TQSize sizeHint( void ) const; @@ -300,8 +308,9 @@ private: TQFont selFont; + TQString selectedFamily; TQString selectedStyle; - int selectedSize; + int selectedSize; TQMap<TQString, TQString> currentStyles; bool usingFixed; |