summaryrefslogtreecommitdiffstats
path: root/tdeui
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2022-05-05 17:11:21 +0300
committerMavridis Philippe <mavridisf@gmail.com>2022-05-06 10:35:17 +0300
commite90218719458ce6fe37a2c5c23c9eb6f9eee43a2 (patch)
treed9820becf7d8af65c58c1bfdcbe9c92f0deeee58 /tdeui
parent32fc7e3ee3420999caa233209749c440e2cb0015 (diff)
downloadtdelibs-e90218719458ce6fe37a2c5c23c9eb6f9eee43a2.tar.gz
tdelibs-e90218719458ce6fe37a2c5c23c9eb6f9eee43a2.zip
TDEFontDialog: Fix font style matching.
This resolves issue TDE/tde#81. Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
Diffstat (limited to 'tdeui')
-rw-r--r--tdeui/tdefontdialog.cpp38
-rw-r--r--tdeui/tdefontdialog.h1
2 files changed, 27 insertions, 12 deletions
diff --git a/tdeui/tdefontdialog.cpp b/tdeui/tdefontdialog.cpp
index fcd50b16e..0da56a93b 100644
--- a/tdeui/tdefontdialog.cpp
+++ b/tdeui/tdefontdialog.cpp
@@ -1,3 +1,4 @@
+
/*
Requires the Qt widget libraries, available at no cost at
@@ -461,23 +462,26 @@ void TDEFontChooser::toggled_checkbox()
sizeOfFont->setEnabled( sizeCheckbox->isChecked() );
}
+TQString TDEFontChooser::style_name(const TQString &style)
+{
+ return i18n(
+ TQString(style).replace("Plain", "Regular")
+ .replace("Normal", "Regular")
+ .replace("Oblique", "Italic")
+ .utf8());
+}
+
void TDEFontChooser::family_chosen_slot(const TQString& family)
{
TQFontDatabase dbase;
- TQStringList styles = TQStringList(dbase.styles(family));
+ TQStringList styles = dbase.styles(family);
styleListBox->clear();
currentStyles.clear();
for ( TQStringList::Iterator it = styles.begin(); it != styles.end(); ++it ) {
- TQString style = *it;
- int pos = style.find("Plain");
- if(pos >=0) style = style.replace(pos,5,i18n("Regular"));
- pos = style.find("Normal");
- if(pos >=0) style = style.replace(pos,6,i18n("Regular"));
- pos = style.find("Oblique");
- if(pos >=0) style = style.replace(pos,7,i18n("Italic"));
+ TQString style = style_name(*it);
if(!styleListBox->findItem(style)) {
- styleListBox->insertItem(i18n(style.utf8()));
- currentStyles.insert(i18n(style.utf8()), *it);
+ styleListBox->insertItem(style);
+ currentStyles.insert(style, *it);
}
}
if(styleListBox->count()==0) {
@@ -565,8 +569,9 @@ void TDEFontChooser::setupDisplay()
{
// Calling familyListBox->setCurrentItem() causes the value of selFont
// to change, so we save the family, style and size beforehand.
+ TQFontDatabase dbase;
TQString family = TQString(selFont.family()).lower();
- int style = (selFont.bold() ? 2 : 0) + (selFont.italic() ? 1 : 0);
+ TQString style = style_name(dbase.styleString(selFont));
int size = selFont.pointSize();
if (size == -1)
size = TQFontInfo(selFont).pointSize();
@@ -624,7 +629,16 @@ void TDEFontChooser::setupDisplay()
if ( i == numEntries )
familyListBox->setCurrentItem( 0 );
- styleListBox->setCurrentItem(style);
+ int item = 0;
+ for (int i = 0; i < (int)styleListBox->count(); ++i)
+ {
+ if (styleListBox->text(i) == style)
+ {
+ item = i;
+ break;
+ }
+ }
+ styleListBox->setCurrentItem(item);
numEntries = sizeListBox->count();
for (i = 0; i < numEntries; i++){
diff --git a/tdeui/tdefontdialog.h b/tdeui/tdefontdialog.h
index 0f4a56f77..66d202700 100644
--- a/tdeui/tdefontdialog.h
+++ b/tdeui/tdefontdialog.h
@@ -271,6 +271,7 @@ private slots:
private:
void fillFamilyListBox(bool onlyFixedFonts = false);
void fillSizeList();
+ TQString style_name(const TQString &name);
// This one must be static since getFontList( TQStringList, char*) is so
static void addFont( TQStringList &list, const char *xfont );