TDEFontChooser: backport setFamilyList(...) from KOffice

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/171/head
Mavridis Philippe 2 years ago
parent 65ab72853b
commit d633f38f6f
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -473,8 +473,18 @@ TQString TDEFontChooser::style_name(const TQString &style)
void TDEFontChooser::family_chosen_slot(const TQString& family) void TDEFontChooser::family_chosen_slot(const TQString& family)
{ {
TQString currentFamily;
if (family.isEmpty())
{
currentFamily = familyListBox->currentText();
}
else
{
currentFamily = family;
}
TQFontDatabase dbase; TQFontDatabase dbase;
TQStringList styles = dbase.styles(family); TQStringList styles = dbase.styles(currentFamily);
styleListBox->clear(); styleListBox->clear();
currentStyles.clear(); currentStyles.clear();
for ( TQStringList::Iterator it = styles.begin(); it != styles.end(); ++it ) { 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); styleListBox->blockSignals(true);
TQListBoxItem *item = styleListBox->findItem(selectedStyle); TQListBoxItem *item = styleListBox->findItem(selectedStyle);
if (item) if (item)
{
styleListBox->setSelected(styleListBox->findItem(selectedStyle), true); styleListBox->setSelected(styleListBox->findItem(selectedStyle), true);
}
else else
{
styleListBox->setSelected(0, true); styleListBox->setSelected(0, true);
}
styleListBox->blockSignals(false); styleListBox->blockSignals(false);
style_chosen_slot(TQString::null); style_chosen_slot(TQString::null);
if (!family.isEmpty() )
{
selectedFamily = family;
}
} }
void TDEFontChooser::size_chosen_slot(const TQString& size){ void TDEFontChooser::size_chosen_slot(const TQString& size){
@ -685,6 +704,15 @@ void TDEFontChooser::getFontList( TQStringList &list, uint fontListCriteria)
list = lstSys; 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 ) void TDEFontChooser::addFont( TQStringList &list, const char *xfont )
{ {
const char *ptr = strchr( xfont, '-' ); const char *ptr = strchr( xfont, '-' );

@ -249,6 +249,14 @@ public:
*/ */
static void getFontList( TQStringList &list, uint fontListCriteria); 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. * Reimplemented for internal reasons.
*/ */
@ -300,8 +308,9 @@ private:
TQFont selFont; TQFont selFont;
TQString selectedFamily;
TQString selectedStyle; TQString selectedStyle;
int selectedSize; int selectedSize;
TQMap<TQString, TQString> currentStyles; TQMap<TQString, TQString> currentStyles;
bool usingFixed; bool usingFixed;

Loading…
Cancel
Save