mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kdeui: format and indent
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
bb11a3e5f4
commit
fc6d82d8cb
7 changed files with 601 additions and 640 deletions
|
@ -27,14 +27,12 @@
|
||||||
|
|
||||||
#ifdef NEVERDEFINE // never true
|
#ifdef NEVERDEFINE // never true
|
||||||
// Font names up for translation, listed for extraction.
|
// Font names up for translation, listed for extraction.
|
||||||
|
|
||||||
// i18n: Generic non-fixed font presented in font choosers. When selected,
|
// i18n: Generic non-fixed font presented in font choosers. When selected,
|
||||||
// the system will choose a real font, mandated by distro settings.
|
// the system will choose a real font, mandated by distro settings.
|
||||||
I18N_NOOP2("@item Font name", "DejaVu Sans")
|
I18N_NOOP2("@item Font name", "DejaVu Sans")
|
||||||
// i18n: Generic fixed font presented in font choosers. When selected,
|
// i18n: Generic fixed font presented in font choosers. When selected,
|
||||||
// the system will choose a real font, mandated by distro settings.
|
// the system will choose a real font, mandated by distro settings.
|
||||||
I18N_NOOP2("@item Font name", "DejaVu Sans Mono")
|
I18N_NOOP2("@item Font name", "DejaVu Sans Mono")
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void splitFontString(const QString &name, QString *family, QString *foundry)
|
void splitFontString(const QString &name, QString *family, QString *foundry)
|
||||||
|
@ -80,8 +78,7 @@ QString translateFontName (const QString &name)
|
||||||
} else {
|
} else {
|
||||||
// i18n: Filter by which the translators can translate, or otherwise
|
// i18n: Filter by which the translators can translate, or otherwise
|
||||||
// operate on the font names not put up for regular translation.
|
// operate on the font names not put up for regular translation.
|
||||||
trfont = i18nc("@item Font name [foundry]", "%1 [%2]",
|
trfont = i18nc("@item Font name [foundry]", "%1 [%2]", trFamily, trFoundry);
|
||||||
trFamily, trFoundry);
|
|
||||||
}
|
}
|
||||||
return trfont;
|
return trfont;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
* @param foundry the storage for foundry name
|
* @param foundry the storage for foundry name
|
||||||
*/
|
*/
|
||||||
void splitFontString(const QString &name,
|
void splitFontString(const QString &name,
|
||||||
QString *family, QString *foundry = NULL);
|
QString *family, QString *foundry = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
|
@ -63,6 +63,6 @@ QString translateFontName (const QString &name);
|
||||||
* @return sorted list of translated font names
|
* @return sorted list of translated font names
|
||||||
*/
|
*/
|
||||||
QStringList translateFontNameList(const QStringList &names,
|
QStringList translateFontNameList(const QStringList &names,
|
||||||
QHash<QString, QString> *trToRawNames = NULL);
|
QHash<QString, QString> *trToRawNames = nullptr);
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -50,26 +50,30 @@ Boston, MA 02110-1301, USA.
|
||||||
static int minimumListWidth(const QListWidget *list)
|
static int minimumListWidth(const QListWidget *list)
|
||||||
{
|
{
|
||||||
int w = 0;
|
int w = 0;
|
||||||
for( int i=0; i<list->count(); i++ )
|
for(int i = 0; i < list->count(); i++) {
|
||||||
{
|
|
||||||
int itemWidth = list->visualItemRect(list->item(i)).width();
|
int itemWidth = list->visualItemRect(list->item(i)).width();
|
||||||
// ...and add a space on both sides for not too tight look.
|
// ...and add a space on both sides for not too tight look.
|
||||||
itemWidth += list->fontMetrics().width(' ') * 2;
|
itemWidth += (list->fontMetrics().width(' ') * 2);
|
||||||
w = qMax(w,itemWidth);
|
w = qMax(w,itemWidth);
|
||||||
}
|
}
|
||||||
if( w == 0 ) { w = 40; }
|
if (w == 0) {
|
||||||
w += list->frameWidth() * 2;
|
w = 40;
|
||||||
|
}
|
||||||
|
w += (list->frameWidth() * 2);
|
||||||
w += list->verticalScrollBar()->sizeHint().width();
|
w += list->verticalScrollBar()->sizeHint().width();
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int minimumListHeight(const QListWidget *list, int numVisibleEntry)
|
static int minimumListHeight(const QListWidget *list, int numVisibleEntry)
|
||||||
{
|
{
|
||||||
int w = list->count() > 0 ? list->visualItemRect(list->item(0)).height() :
|
int w = (list->count() > 0 ? list->visualItemRect(list->item(0)).height() : list->fontMetrics().lineSpacing());
|
||||||
list->fontMetrics().lineSpacing();
|
|
||||||
|
|
||||||
if( w < 0 ) { w = 10; }
|
if (w < 0 ) {
|
||||||
if( numVisibleEntry <= 0 ) { numVisibleEntry = 4; }
|
w = 10;
|
||||||
|
}
|
||||||
|
if (numVisibleEntry <= 0) {
|
||||||
|
numVisibleEntry = 4;
|
||||||
|
}
|
||||||
return (w * numVisibleEntry + 2 * list->frameWidth());
|
return (w * numVisibleEntry + 2 * list->frameWidth());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,9 +114,9 @@ public:
|
||||||
KFontChooser *q;
|
KFontChooser *q;
|
||||||
|
|
||||||
QPalette m_palette;
|
QPalette m_palette;
|
||||||
bool signalsAllowed:1;
|
bool signalsAllowed;
|
||||||
|
|
||||||
bool usingFixed:1;
|
bool usingFixed;
|
||||||
|
|
||||||
KDoubleNumInput *sizeOfFont;
|
KDoubleNumInput *sizeOfFont;
|
||||||
|
|
||||||
|
@ -147,14 +151,14 @@ public:
|
||||||
|
|
||||||
|
|
||||||
KFontChooser::KFontChooser(QWidget *parent,
|
KFontChooser::KFontChooser(QWidget *parent,
|
||||||
const DisplayFlags& flags,
|
const DisplayFlags flags,
|
||||||
const QStringList &fontList,
|
const QStringList &fontList,
|
||||||
int visibleListSize,
|
int visibleListSize,
|
||||||
Qt::CheckState *sizeIsRelativeState)
|
Qt::CheckState *sizeIsRelativeState)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
d(new KFontChooser::Private(this))
|
d(new KFontChooser::Private(this))
|
||||||
{
|
{
|
||||||
d->usingFixed = flags & FixedFontsOnly;
|
d->usingFixed = (flags & FixedFontsOnly);
|
||||||
setWhatsThis(i18nc("@info:whatsthis", "Here you can choose the font to be used."));
|
setWhatsThis(i18nc("@info:whatsthis", "Here you can choose the font to be used."));
|
||||||
|
|
||||||
// The top layout is divided vertically into a splitter with font
|
// The top layout is divided vertically into a splitter with font
|
||||||
|
@ -171,19 +175,15 @@ KFontChooser::KFontChooser( QWidget *parent,
|
||||||
topLayout->addWidget(splitter);
|
topLayout->addWidget(splitter);
|
||||||
|
|
||||||
// Build the grid of font attribute widgets for the upper splitter part.
|
// Build the grid of font attribute widgets for the upper splitter part.
|
||||||
//
|
|
||||||
QWidget *page;
|
QWidget *page;
|
||||||
QGridLayout *gridLayout;
|
QGridLayout *gridLayout;
|
||||||
int row = 0;
|
int row = 0;
|
||||||
if( flags & DisplayFrame )
|
if (flags & DisplayFrame) {
|
||||||
{
|
|
||||||
page = new QGroupBox(i18n("Requested Font"), this);
|
page = new QGroupBox(i18n("Requested Font"), this);
|
||||||
splitter->addWidget(page);
|
splitter->addWidget(page);
|
||||||
gridLayout = new QGridLayout( page );
|
gridLayout = new QGridLayout( page );
|
||||||
row = 1;
|
row = 1;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
page = new QWidget(this);
|
page = new QWidget(this);
|
||||||
splitter->addWidget(page);
|
splitter->addWidget(page);
|
||||||
gridLayout = new QGridLayout(page);
|
gridLayout = new QGridLayout(page);
|
||||||
|
@ -197,14 +197,13 @@ KFontChooser::KFontChooser( QWidget *parent,
|
||||||
familyLayout->addSpacing(checkBoxGap);
|
familyLayout->addSpacing(checkBoxGap);
|
||||||
if (flags & ShowDifferences) {
|
if (flags & ShowDifferences) {
|
||||||
d->familyCheckbox = new QCheckBox(i18nc("@option:check","Font"), page);
|
d->familyCheckbox = new QCheckBox(i18nc("@option:check","Font"), page);
|
||||||
connect(d->familyCheckbox, SIGNAL(toggled(bool)),
|
connect(d->familyCheckbox, SIGNAL(toggled(bool)), this, SLOT(_k_toggled_checkbox()));
|
||||||
this, SLOT(_k_toggled_checkbox()));
|
|
||||||
familyLayout->addWidget(d->familyCheckbox, 0, Qt::AlignLeft);
|
familyLayout->addWidget(d->familyCheckbox, 0, Qt::AlignLeft);
|
||||||
d->familyCheckbox->setWhatsThis(i18nc("@info:whatsthis","Enable this checkbox to change the font family settings."));
|
d->familyCheckbox->setWhatsThis(i18nc("@info:whatsthis","Enable this checkbox to change the font family settings."));
|
||||||
d->familyCheckbox->setToolTip(i18nc("@info:tooltip","Change font family?") );
|
d->familyCheckbox->setToolTip(i18nc("@info:tooltip","Change font family?") );
|
||||||
d->familyLabel = 0;
|
d->familyLabel = nullptr;
|
||||||
} else {
|
} else {
|
||||||
d->familyCheckbox = 0;
|
d->familyCheckbox = nullptr;
|
||||||
d->familyLabel = new QLabel(i18nc("@label","Font:"), page);
|
d->familyLabel = new QLabel(i18nc("@label","Font:"), page);
|
||||||
familyLayout->addWidget(d->familyLabel, 1, Qt::AlignLeft);
|
familyLayout->addWidget(d->familyLabel, 1, Qt::AlignLeft);
|
||||||
}
|
}
|
||||||
|
@ -213,14 +212,13 @@ KFontChooser::KFontChooser( QWidget *parent,
|
||||||
QHBoxLayout *styleLayout = new QHBoxLayout();
|
QHBoxLayout *styleLayout = new QHBoxLayout();
|
||||||
if (flags & ShowDifferences) {
|
if (flags & ShowDifferences) {
|
||||||
d->styleCheckbox = new QCheckBox(i18nc("@option:check","Font style"), page);
|
d->styleCheckbox = new QCheckBox(i18nc("@option:check","Font style"), page);
|
||||||
connect(d->styleCheckbox, SIGNAL(toggled(bool)),
|
connect(d->styleCheckbox, SIGNAL(toggled(bool)), this, SLOT(_k_toggled_checkbox()));
|
||||||
this, SLOT(_k_toggled_checkbox()));
|
|
||||||
styleLayout->addWidget(d->styleCheckbox, 0, Qt::AlignLeft);
|
styleLayout->addWidget(d->styleCheckbox, 0, Qt::AlignLeft);
|
||||||
d->styleCheckbox->setWhatsThis(i18nc("@info:whatsthis","Enable this checkbox to change the font style settings."));
|
d->styleCheckbox->setWhatsThis(i18nc("@info:whatsthis","Enable this checkbox to change the font style settings."));
|
||||||
d->styleCheckbox->setToolTip(i18nc("@info:tooltip","Change font style?"));
|
d->styleCheckbox->setToolTip(i18nc("@info:tooltip","Change font style?"));
|
||||||
d->styleLabel = 0;
|
d->styleLabel = nullptr;
|
||||||
} else {
|
} else {
|
||||||
d->styleCheckbox = 0;
|
d->styleCheckbox = nullptr;
|
||||||
d->styleLabel = new QLabel(i18n("Font style:"), page);
|
d->styleLabel = new QLabel(i18n("Font style:"), page);
|
||||||
styleLayout->addWidget(d->styleLabel, 1, Qt::AlignLeft);
|
styleLayout->addWidget(d->styleLabel, 1, Qt::AlignLeft);
|
||||||
}
|
}
|
||||||
|
@ -230,14 +228,13 @@ KFontChooser::KFontChooser( QWidget *parent,
|
||||||
QHBoxLayout *sizeLayout = new QHBoxLayout();
|
QHBoxLayout *sizeLayout = new QHBoxLayout();
|
||||||
if ( flags & ShowDifferences ) {
|
if ( flags & ShowDifferences ) {
|
||||||
d->sizeCheckbox = new QCheckBox(i18nc("@option:check","Size"),page);
|
d->sizeCheckbox = new QCheckBox(i18nc("@option:check","Size"),page);
|
||||||
connect(d->sizeCheckbox, SIGNAL(toggled(bool)),
|
connect(d->sizeCheckbox, SIGNAL(toggled(bool)), this, SLOT(_k_toggled_checkbox()));
|
||||||
this, SLOT(_k_toggled_checkbox()));
|
|
||||||
sizeLayout->addWidget(d->sizeCheckbox, 0, Qt::AlignLeft);
|
sizeLayout->addWidget(d->sizeCheckbox, 0, Qt::AlignLeft);
|
||||||
d->sizeCheckbox->setWhatsThis(i18nc("@info:whatsthis","Enable this checkbox to change the font size settings."));
|
d->sizeCheckbox->setWhatsThis(i18nc("@info:whatsthis","Enable this checkbox to change the font size settings."));
|
||||||
d->sizeCheckbox->setToolTip(i18nc("@info:tooltip","Change font size?"));
|
d->sizeCheckbox->setToolTip(i18nc("@info:tooltip","Change font size?"));
|
||||||
d->sizeLabel = 0;
|
d->sizeLabel = nullptr;
|
||||||
} else {
|
} else {
|
||||||
d->sizeCheckbox = 0;
|
d->sizeCheckbox = nullptr;
|
||||||
d->sizeLabel = new QLabel(i18nc("@label:listbox Font size", "Size:"), page);
|
d->sizeLabel = new QLabel(i18nc("@label:listbox Font size", "Size:"), page);
|
||||||
sizeLayout->addWidget(d->sizeLabel, 1, Qt::AlignLeft);
|
sizeLayout->addWidget(d->sizeLabel, 1, Qt::AlignLeft);
|
||||||
}
|
}
|
||||||
|
@ -253,8 +250,7 @@ KFontChooser::KFontChooser( QWidget *parent,
|
||||||
d->familyListBox = new KListWidget(page);
|
d->familyListBox = new KListWidget(page);
|
||||||
d->familyListBox->setEnabled(flags ^ ShowDifferences);
|
d->familyListBox->setEnabled(flags ^ ShowDifferences);
|
||||||
gridLayout->addWidget(d->familyListBox, row, 0);
|
gridLayout->addWidget(d->familyListBox, row, 0);
|
||||||
QString fontFamilyWhatsThisText (
|
QString fontFamilyWhatsThisText = i18nc("@info:whatsthis","Here you can choose the font family to be used.");
|
||||||
i18nc("@info:whatsthis","Here you can choose the font family to be used." ));
|
|
||||||
d->familyListBox->setWhatsThis(fontFamilyWhatsThisText);
|
d->familyListBox->setWhatsThis(fontFamilyWhatsThisText);
|
||||||
|
|
||||||
if (flags & ShowDifferences) {
|
if (flags & ShowDifferences) {
|
||||||
|
@ -263,28 +259,24 @@ KFontChooser::KFontChooser( QWidget *parent,
|
||||||
d->familyLabel->setWhatsThis(fontFamilyWhatsThisText);
|
d->familyLabel->setWhatsThis(fontFamilyWhatsThisText);
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(d->familyListBox, SIGNAL(currentTextChanged(QString)),
|
connect(d->familyListBox, SIGNAL(currentTextChanged(QString)), this, SLOT(_k_family_chosen_slot(QString)));
|
||||||
this, SLOT(_k_family_chosen_slot(QString)));
|
|
||||||
if (!fontList.isEmpty()) {
|
if (!fontList.isEmpty()) {
|
||||||
d->setFamilyBoxItems(fontList);
|
d->setFamilyBoxItems(fontList);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
d->fillFamilyListBox(flags & FixedFontsOnly);
|
d->fillFamilyListBox(flags & FixedFontsOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->familyListBox->setMinimumWidth(minimumListWidth(d->familyListBox));
|
d->familyListBox->setMinimumWidth(minimumListWidth(d->familyListBox));
|
||||||
d->familyListBox->setMinimumHeight(
|
d->familyListBox->setMinimumHeight(minimumListHeight(d->familyListBox, visibleListSize));
|
||||||
minimumListHeight( d->familyListBox, visibleListSize ) );
|
|
||||||
|
|
||||||
d->styleListBox = new KListWidget(page);
|
d->styleListBox = new KListWidget(page);
|
||||||
d->styleListBox->setEnabled(flags ^ ShowDifferences);
|
d->styleListBox->setEnabled(flags ^ ShowDifferences);
|
||||||
gridLayout->addWidget(d->styleListBox, row, 1);
|
gridLayout->addWidget(d->styleListBox, row, 1);
|
||||||
d->styleListBox->setWhatsThis(i18nc("@info:whatsthis","Here you can choose the font style to be used."));
|
d->styleListBox->setWhatsThis(i18nc("@info:whatsthis","Here you can choose the font style to be used."));
|
||||||
if ( flags & ShowDifferences) {
|
if ( flags & ShowDifferences) {
|
||||||
((QWidget *)d->styleCheckbox)->setWhatsThis(fontFamilyWhatsThisText );
|
d->styleCheckbox->setWhatsThis(fontFamilyWhatsThisText);
|
||||||
} else {
|
} else {
|
||||||
((QWidget *)d->styleLabel)->setWhatsThis( fontFamilyWhatsThisText );
|
d->styleLabel->setWhatsThis(fontFamilyWhatsThisText);
|
||||||
}
|
}
|
||||||
// Populate usual styles, to determine minimum list width;
|
// Populate usual styles, to determine minimum list width;
|
||||||
// will be replaced later with correct styles.
|
// will be replaced later with correct styles.
|
||||||
|
@ -294,11 +286,9 @@ KFontChooser::KFontChooser( QWidget *parent,
|
||||||
d->styleListBox->addItem(i18nc("@item font","Bold"));
|
d->styleListBox->addItem(i18nc("@item font","Bold"));
|
||||||
d->styleListBox->addItem(i18nc("@item font","Bold Italic"));
|
d->styleListBox->addItem(i18nc("@item font","Bold Italic"));
|
||||||
d->styleListBox->setMinimumWidth(minimumListWidth( d->styleListBox));
|
d->styleListBox->setMinimumWidth(minimumListWidth( d->styleListBox));
|
||||||
d->styleListBox->setMinimumHeight(
|
d->styleListBox->setMinimumHeight(minimumListHeight(d->styleListBox, visibleListSize));
|
||||||
minimumListHeight( d->styleListBox, visibleListSize ) );
|
|
||||||
|
|
||||||
connect(d->styleListBox, SIGNAL(currentTextChanged(QString)),
|
connect(d->styleListBox, SIGNAL(currentTextChanged(QString)), this, SLOT(_k_style_chosen_slot(QString)));
|
||||||
this, SLOT(_k_style_chosen_slot(QString)));
|
|
||||||
|
|
||||||
|
|
||||||
d->sizeListBox = new KListWidget(page);
|
d->sizeListBox = new KListWidget(page);
|
||||||
|
@ -312,16 +302,14 @@ KFontChooser::KFontChooser( QWidget *parent,
|
||||||
d->sizeListBox->setEnabled(flags ^ ShowDifferences);
|
d->sizeListBox->setEnabled(flags ^ ShowDifferences);
|
||||||
d->sizeOfFont->setEnabled(flags ^ ShowDifferences);
|
d->sizeOfFont->setEnabled(flags ^ ShowDifferences);
|
||||||
if( sizeIsRelativeState ) {
|
if( sizeIsRelativeState ) {
|
||||||
QString sizeIsRelativeCBText =
|
QString sizeIsRelativeCBText = i18nc("@item font size","Relative");
|
||||||
i18nc("@item font size","Relative");
|
QString sizeIsRelativeCBToolTipText = i18n("Font size<br /><i>fixed</i> or <i>relative</i><br />to environment");
|
||||||
QString sizeIsRelativeCBToolTipText =
|
QString sizeIsRelativeCBWhatsThisText = i18n(
|
||||||
i18n("Font size<br /><i>fixed</i> or <i>relative</i><br />to environment");
|
"Here you can switch between fixed font size and font size "
|
||||||
QString sizeIsRelativeCBWhatsThisText =
|
|
||||||
i18n("Here you can switch between fixed font size and font size "
|
|
||||||
"to be calculated dynamically and adjusted to changing "
|
"to be calculated dynamically and adjusted to changing "
|
||||||
"environment (e.g. widget dimensions, paper size)." );
|
"environment (e.g. widget dimensions, paper size)."
|
||||||
d->sizeIsRelativeCheckBox = new QCheckBox( sizeIsRelativeCBText,
|
);
|
||||||
page );
|
d->sizeIsRelativeCheckBox = new QCheckBox(sizeIsRelativeCBText, page);
|
||||||
d->sizeIsRelativeCheckBox->setTristate(flags & ShowDifferences);
|
d->sizeIsRelativeCheckBox->setTristate(flags & ShowDifferences);
|
||||||
QGridLayout *sizeLayout2 = new QGridLayout();
|
QGridLayout *sizeLayout2 = new QGridLayout();
|
||||||
sizeLayout2->setSpacing( KDialog::spacingHint() / 2);
|
sizeLayout2->setSpacing( KDialog::spacingHint() / 2);
|
||||||
|
@ -332,45 +320,37 @@ KFontChooser::KFontChooser( QWidget *parent,
|
||||||
sizeLayout2->addWidget(d->sizeIsRelativeCheckBox, 2, 0, Qt::AlignLeft);
|
sizeLayout2->addWidget(d->sizeIsRelativeCheckBox, 2, 0, Qt::AlignLeft);
|
||||||
d->sizeIsRelativeCheckBox->setWhatsThis(sizeIsRelativeCBWhatsThisText);
|
d->sizeIsRelativeCheckBox->setWhatsThis(sizeIsRelativeCBWhatsThisText);
|
||||||
d->sizeIsRelativeCheckBox->setToolTip(sizeIsRelativeCBToolTipText);
|
d->sizeIsRelativeCheckBox->setToolTip(sizeIsRelativeCBToolTipText);
|
||||||
}
|
} else {
|
||||||
else {
|
d->sizeIsRelativeCheckBox = nullptr;
|
||||||
d->sizeIsRelativeCheckBox = 0L;
|
|
||||||
QGridLayout *sizeLayout2 = new QGridLayout();
|
QGridLayout *sizeLayout2 = new QGridLayout();
|
||||||
sizeLayout2->setSpacing( KDialog::spacingHint() / 2);
|
sizeLayout2->setSpacing( KDialog::spacingHint() / 2);
|
||||||
gridLayout->addLayout(sizeLayout2, row, 2);
|
gridLayout->addLayout(sizeLayout2, row, 2);
|
||||||
sizeLayout2->addWidget( d->sizeOfFont, 0, 0);
|
sizeLayout2->addWidget( d->sizeOfFont, 0, 0);
|
||||||
sizeLayout2->addWidget(d->sizeListBox, 1,0);
|
sizeLayout2->addWidget(d->sizeListBox, 1,0);
|
||||||
}
|
}
|
||||||
QString fontSizeWhatsThisText =
|
QString fontSizeWhatsThisText = i18n("Here you can choose the font size to be used.");
|
||||||
i18n("Here you can choose the font size to be used." );
|
|
||||||
d->sizeListBox->setWhatsThis(fontSizeWhatsThisText);
|
d->sizeListBox->setWhatsThis(fontSizeWhatsThisText);
|
||||||
|
|
||||||
if ( flags & ShowDifferences ) {
|
if ( flags & ShowDifferences ) {
|
||||||
((QWidget *)d->sizeCheckbox)->setWhatsThis(fontSizeWhatsThisText );
|
d->sizeCheckbox->setWhatsThis(fontSizeWhatsThisText);
|
||||||
} else {
|
} else {
|
||||||
((QWidget *)d->sizeLabel)->setWhatsThis( fontSizeWhatsThisText );
|
d->sizeLabel->setWhatsThis(fontSizeWhatsThisText);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate with usual sizes, to determine minimum list width;
|
// Populate with usual sizes, to determine minimum list width;
|
||||||
// will be replaced later with correct sizes.
|
// will be replaced later with correct sizes.
|
||||||
d->fillSizeList();
|
d->fillSizeList();
|
||||||
d->sizeListBox->setMinimumWidth( minimumListWidth(d->sizeListBox) +
|
d->sizeListBox->setMinimumWidth(minimumListWidth(d->sizeListBox) + d->sizeListBox->fontMetrics().maxWidth());
|
||||||
d->sizeListBox->fontMetrics().maxWidth() );
|
d->sizeListBox->setMinimumHeight(minimumListHeight(d->sizeListBox, visibleListSize));
|
||||||
d->sizeListBox->setMinimumHeight(
|
|
||||||
minimumListHeight( d->sizeListBox, visibleListSize ) );
|
|
||||||
|
|
||||||
connect( d->sizeOfFont, SIGNAL(valueChanged(double)),
|
connect(d->sizeOfFont, SIGNAL(valueChanged(double)), this, SLOT(_k_size_value_slot(double)));
|
||||||
this, SLOT(_k_size_value_slot(double)));
|
|
||||||
|
|
||||||
connect( d->sizeListBox, SIGNAL(currentTextChanged(QString)),
|
connect(d->sizeListBox, SIGNAL(currentTextChanged(QString)), this, SLOT(_k_size_chosen_slot(QString)) );
|
||||||
this, SLOT(_k_size_chosen_slot(QString)) );
|
|
||||||
|
|
||||||
row++;
|
row++;
|
||||||
//
|
|
||||||
// Completed the font attribute grid.
|
// Completed the font attribute grid.
|
||||||
|
|
||||||
// Add the font preview into the lower part of the splitter.
|
// Add the font preview into the lower part of the splitter.
|
||||||
//
|
|
||||||
d->sampleEdit = new SampleEdit(page);
|
d->sampleEdit = new SampleEdit(page);
|
||||||
d->sampleEdit->setAcceptRichText(false);
|
d->sampleEdit->setAcceptRichText(false);
|
||||||
QFont tmpFont( KGlobalSettings::generalFont().family(), 64, QFont::Black );
|
QFont tmpFont( KGlobalSettings::generalFont().family(), 64, QFont::Black );
|
||||||
|
@ -382,24 +362,24 @@ KFontChooser::KFontChooser( QWidget *parent,
|
||||||
// If you wish, you can input several lines of text separated by \n.
|
// If you wish, you can input several lines of text separated by \n.
|
||||||
setSampleText(i18n("The Quick Brown Fox Jumps Over The Lazy Dog"));
|
setSampleText(i18n("The Quick Brown Fox Jumps Over The Lazy Dog"));
|
||||||
d->sampleEdit->setTextCursor(QTextCursor(d->sampleEdit->document()));
|
d->sampleEdit->setTextCursor(QTextCursor(d->sampleEdit->document()));
|
||||||
QString sampleEditWhatsThisText =
|
QString sampleEditWhatsThisText = i18n(
|
||||||
i18n("This sample text illustrates the current settings. "
|
"This sample text illustrates the current settings. "
|
||||||
"You may edit it to test special characters." );
|
"You may edit it to test special characters."
|
||||||
|
);
|
||||||
d->sampleEdit->setWhatsThis(sampleEditWhatsThisText );
|
d->sampleEdit->setWhatsThis(sampleEditWhatsThisText );
|
||||||
|
|
||||||
connect(this, SIGNAL(fontSelected(QFont)),
|
connect(this, SIGNAL(fontSelected(QFont)), this, SLOT(_k_displaySample(QFont)));
|
||||||
this, SLOT(_k_displaySample(QFont)));
|
|
||||||
|
|
||||||
splitter->addWidget(d->sampleEdit);
|
splitter->addWidget(d->sampleEdit);
|
||||||
//
|
|
||||||
// Finished setting up the splitter.
|
// Finished setting up the splitter.
|
||||||
|
|
||||||
// lets initialize the display if possible
|
// lets initialize the display if possible
|
||||||
setFont(d->usingFixed ? KGlobalSettings::fixedFont() : KGlobalSettings::generalFont(), d->usingFixed);
|
setFont(d->usingFixed ? KGlobalSettings::fixedFont() : KGlobalSettings::generalFont(), d->usingFixed);
|
||||||
|
|
||||||
// check or uncheck or gray out the "relative" checkbox
|
// check or uncheck or gray out the "relative" checkbox
|
||||||
if( sizeIsRelativeState && d->sizeIsRelativeCheckBox )
|
if (sizeIsRelativeState && d->sizeIsRelativeCheckBox) {
|
||||||
setSizeIsRelative(*sizeIsRelativeState);
|
setSizeIsRelative(*sizeIsRelativeState);
|
||||||
|
}
|
||||||
|
|
||||||
// Set focus to the size list as this is the most commonly changed property
|
// Set focus to the size list as this is the most commonly changed property
|
||||||
d->sizeListBox->setFocus();
|
d->sizeListBox->setFocus();
|
||||||
|
@ -440,22 +420,24 @@ QColor KFontChooser::backgroundColor() const
|
||||||
return d->m_palette.color(QPalette::Active, QPalette::Base);
|
return d->m_palette.color(QPalette::Active, QPalette::Base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFontChooser::setSizeIsRelative( Qt::CheckState relative )
|
void KFontChooser::setSizeIsRelative(const Qt::CheckState relative)
|
||||||
{
|
{
|
||||||
// check or uncheck or gray out the "relative" checkbox
|
// check or uncheck or gray out the "relative" checkbox
|
||||||
if (d->sizeIsRelativeCheckBox) {
|
if (d->sizeIsRelativeCheckBox) {
|
||||||
if( Qt::PartiallyChecked == relative )
|
if (Qt::PartiallyChecked == relative) {
|
||||||
d->sizeIsRelativeCheckBox->setCheckState(Qt::PartiallyChecked);
|
d->sizeIsRelativeCheckBox->setCheckState(Qt::PartiallyChecked);
|
||||||
else
|
} else {
|
||||||
d->sizeIsRelativeCheckBox->setCheckState( (Qt::Checked == relative ) ? Qt::Checked : Qt::Unchecked);
|
d->sizeIsRelativeCheckBox->setCheckState(Qt::Checked == relative ? Qt::Checked : Qt::Unchecked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::CheckState KFontChooser::sizeIsRelative() const
|
Qt::CheckState KFontChooser::sizeIsRelative() const
|
||||||
{
|
{
|
||||||
return d->sizeIsRelativeCheckBox
|
if (d->sizeIsRelativeCheckBox) {
|
||||||
? d->sizeIsRelativeCheckBox->checkState()
|
return d->sizeIsRelativeCheckBox->checkState();
|
||||||
: Qt::PartiallyChecked;
|
}
|
||||||
|
return Qt::PartiallyChecked;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KFontChooser::sampleText() const
|
QString KFontChooser::sampleText() const
|
||||||
|
@ -473,24 +455,20 @@ void KFontChooser::setSampleBoxVisible( bool visible )
|
||||||
d->sampleEdit->setVisible(visible);
|
d->sampleEdit->setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize KFontChooser::sizeHint( void ) const
|
QSize KFontChooser::sizeHint() const
|
||||||
{
|
{
|
||||||
return minimumSizeHint();
|
return minimumSizeHint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KFontChooser::enableColumn(int column, bool state)
|
void KFontChooser::enableColumn(int column, bool state)
|
||||||
{
|
{
|
||||||
if( column & FamilyList )
|
if (column & FamilyList) {
|
||||||
{
|
|
||||||
d->familyListBox->setEnabled(state);
|
d->familyListBox->setEnabled(state);
|
||||||
}
|
}
|
||||||
if( column & StyleList )
|
if (column & StyleList) {
|
||||||
{
|
|
||||||
d->styleListBox->setEnabled(state);
|
d->styleListBox->setEnabled(state);
|
||||||
}
|
}
|
||||||
if( column & SizeList )
|
if (column & SizeList) {
|
||||||
{
|
|
||||||
d->sizeListBox->setEnabled(state);
|
d->sizeListBox->setEnabled(state);
|
||||||
d->sizeOfFont->setEnabled(state);
|
d->sizeOfFont->setEnabled(state);
|
||||||
}
|
}
|
||||||
|
@ -505,31 +483,25 @@ void KFontChooser::setFont( const QFont& aFont, bool onlyFixed )
|
||||||
d->selectedSize = d->fontdb.font(aFont.family(), aFont.styleName(), aFont.pointSize()).pointSizeF();
|
d->selectedSize = d->fontdb.font(aFont.family(), aFont.styleName(), aFont.pointSize()).pointSizeF();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( onlyFixed != d->usingFixed)
|
if (onlyFixed != d->usingFixed) {
|
||||||
{
|
|
||||||
d->usingFixed = onlyFixed;
|
d->usingFixed = onlyFixed;
|
||||||
d->fillFamilyListBox(d->usingFixed);
|
d->fillFamilyListBox(d->usingFixed);
|
||||||
}
|
}
|
||||||
d->setupDisplay();
|
d->setupDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
KFontChooser::FontDiffFlags KFontChooser::fontDiffFlags() const
|
KFontChooser::FontDiffFlags KFontChooser::fontDiffFlags() const
|
||||||
{
|
{
|
||||||
FontDiffFlags diffFlags = NoFontDiffFlags;
|
FontDiffFlags diffFlags = NoFontDiffFlags;
|
||||||
|
|
||||||
if (d->familyCheckbox && d->familyCheckbox->isChecked()) {
|
if (d->familyCheckbox && d->familyCheckbox->isChecked()) {
|
||||||
diffFlags |= FontDiffFamily;
|
diffFlags |= FontDiffFamily;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->styleCheckbox && d->styleCheckbox->isChecked()) {
|
if (d->styleCheckbox && d->styleCheckbox->isChecked()) {
|
||||||
diffFlags |= FontDiffStyle;
|
diffFlags |= FontDiffStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->sizeCheckbox && d->sizeCheckbox->isChecked()) {
|
if (d->sizeCheckbox && d->sizeCheckbox->isChecked()) {
|
||||||
diffFlags |= FontDiffSize;
|
diffFlags |= FontDiffSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return diffFlags;
|
return diffFlags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,8 +531,7 @@ void KFontChooser::Private::_k_family_chosen_slot(const QString& family)
|
||||||
if (familyListBox->currentItem()) {
|
if (familyListBox->currentItem()) {
|
||||||
currentFamily = qtFamilies[familyListBox->currentItem()->text()];
|
currentFamily = qtFamilies[familyListBox->currentItem()->text()];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
currentFamily = qtFamilies[family];
|
currentFamily = qtFamilies[family];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -810,7 +781,7 @@ qreal KFontChooser::Private::setupSizeListBox (const QString& family, const QStr
|
||||||
QList<qreal> sizes;
|
QList<qreal> sizes;
|
||||||
if (fontdb.isScalable(family, style)) {
|
if (fontdb.isScalable(family, style)) {
|
||||||
// A vector font.
|
// A vector font.
|
||||||
//>sampleEdit->setPaletteBackgroundPixmap( VectorPixmap ); // TODO
|
// sampleEdit->setPaletteBackgroundPixmap( VectorPixmap ); // TODO
|
||||||
} else {
|
} else {
|
||||||
// A bitmap font.
|
// A bitmap font.
|
||||||
// sampleEdit->setPaletteBackgroundPixmap( BitmapPixmap ); // TODO
|
// sampleEdit->setPaletteBackgroundPixmap( BitmapPixmap ); // TODO
|
||||||
|
@ -825,9 +796,7 @@ qreal KFontChooser::Private::setupSizeListBox (const QString& family, const QStr
|
||||||
qreal bestFitSize = fillSizeList(sizes);
|
qreal bestFitSize = fillSizeList(sizes);
|
||||||
|
|
||||||
// Set the best fit size as current in the listbox if available.
|
// Set the best fit size as current in the listbox if available.
|
||||||
const QList<QListWidgetItem*> selectedSizeList =
|
const QList<QListWidgetItem*> selectedSizeList = sizeListBox->findItems(formatFontSize(bestFitSize), Qt::MatchExactly);
|
||||||
sizeListBox->findItems( formatFontSize(bestFitSize),
|
|
||||||
Qt::MatchExactly );
|
|
||||||
if ( !selectedSizeList.isEmpty() ) {
|
if ( !selectedSizeList.isEmpty() ) {
|
||||||
sizeListBox->setCurrentItem(selectedSizeList.first());
|
sizeListBox->setCurrentItem(selectedSizeList.first());
|
||||||
}
|
}
|
||||||
|
@ -857,10 +826,8 @@ void KFontChooser::Private::setupDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1st family fallback.
|
// 1st family fallback.
|
||||||
if ( i == numEntries )
|
if (i == numEntries) {
|
||||||
{
|
if (family.contains('[')) {
|
||||||
if (family.contains('['))
|
|
||||||
{
|
|
||||||
family = family.left(family.indexOf('[')).trimmed();
|
family = family.left(family.indexOf('[')).trimmed();
|
||||||
for (i = 0; i < numEntries; i++) {
|
for (i = 0; i < numEntries; i++) {
|
||||||
if (family == qtFamilies[familyListBox->item(i)->text()].toLower()) {
|
if (family == qtFamilies[familyListBox->item(i)->text()].toLower()) {
|
||||||
|
@ -872,8 +839,7 @@ void KFontChooser::Private::setupDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2nd family fallback.
|
// 2nd family fallback.
|
||||||
if ( i == numEntries )
|
if (i == numEntries) {
|
||||||
{
|
|
||||||
QString fallback = family+" [";
|
QString fallback = family+" [";
|
||||||
for (i = 0; i < numEntries; i++) {
|
for (i = 0; i < numEntries; i++) {
|
||||||
if (qtFamilies[familyListBox->item(i)->text()].toLower().startsWith(fallback)) {
|
if (qtFamilies[familyListBox->item(i)->text()].toLower().startsWith(fallback)) {
|
||||||
|
@ -884,8 +850,7 @@ void KFontChooser::Private::setupDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3rd family fallback.
|
// 3rd family fallback.
|
||||||
if ( i == numEntries )
|
if (i == numEntries) {
|
||||||
{
|
|
||||||
for (i = 0; i < numEntries; i++) {
|
for (i = 0; i < numEntries; i++) {
|
||||||
if (qtFamilies[familyListBox->item(i)->text()].toLower().startsWith(family)) {
|
if (qtFamilies[familyListBox->item(i)->text()].toLower().startsWith(family)) {
|
||||||
familyListBox->setCurrentRow(i);
|
familyListBox->setCurrentRow(i);
|
||||||
|
@ -929,17 +894,15 @@ void KFontChooser::Private::setupDisplay()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KFontChooser::getFontList( QStringList &list, uint fontListCriteria)
|
void KFontChooser::getFontList(QStringList &list, const uint fontListCriteria)
|
||||||
{
|
{
|
||||||
QFontDatabase fdb;
|
QFontDatabase fdb;
|
||||||
QStringList lstSys(fdb.families());
|
QStringList lstSys(fdb.families());
|
||||||
|
|
||||||
// if we have criteria; then check fonts before adding
|
// if we have criteria; then check fonts before adding
|
||||||
if (fontListCriteria)
|
if (fontListCriteria) {
|
||||||
{
|
|
||||||
QStringList lstFonts;
|
QStringList lstFonts;
|
||||||
for (QStringList::const_iterator it = lstSys.constBegin(); it != lstSys.constEnd(); ++it)
|
for (QStringList::const_iterator it = lstSys.constBegin(); it != lstSys.constEnd(); ++it) {
|
||||||
{
|
|
||||||
if ((fontListCriteria & FixedWidthFonts) > 0 && !fdb.isFixedPitch(*it)) continue;
|
if ((fontListCriteria & FixedWidthFonts) > 0 && !fdb.isFixedPitch(*it)) continue;
|
||||||
if ((fontListCriteria & SmoothScalableFonts) > 0 && !fdb.isScalable(*it)) continue;
|
if ((fontListCriteria & SmoothScalableFonts) > 0 && !fdb.isScalable(*it)) continue;
|
||||||
lstFonts.append(*it);
|
lstFonts.append(*it);
|
||||||
|
@ -948,9 +911,10 @@ void KFontChooser::getFontList( QStringList &list, uint fontListCriteria)
|
||||||
if((fontListCriteria & FixedWidthFonts) > 0) {
|
if((fontListCriteria & FixedWidthFonts) > 0) {
|
||||||
// Fallback.. if there are no fixed fonts found, it's probably a
|
// Fallback.. if there are no fixed fonts found, it's probably a
|
||||||
// bug in the font server or Qt. In this case, just use 'fixed'
|
// bug in the font server or Qt. In this case, just use 'fixed'
|
||||||
if (lstFonts.count() == 0)
|
if (lstFonts.count() == 0) {
|
||||||
lstFonts.append("fixed");
|
lstFonts.append("fixed");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lstSys = lstFonts;
|
lstSys = lstFonts;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
Boston, MA 02110-1301, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
#ifndef K_FONT_CHOOSER_H
|
#ifndef KFONTCHOOSER_H
|
||||||
#define K_FONT_CHOOSER_H
|
#define KFONTCHOOSER_H
|
||||||
|
|
||||||
#include <kdeui_export.h>
|
#include <kdeui_export.h>
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
|
@ -54,23 +54,42 @@ class KDEUI_EXPORT KFontChooser : public QWidget
|
||||||
Q_PROPERTY(QString sampleText READ sampleText WRITE setSampleText)
|
Q_PROPERTY(QString sampleText READ sampleText WRITE setSampleText)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* The selection criteria for the font families shown in the dialog.
|
||||||
|
* @li @p FixedWidthFont when included only fixed-width fonts are returned.
|
||||||
|
* The fonts where the width of every character is equal.
|
||||||
|
* @li @p SmoothScalableFont when included only return smooth scalable fonts.
|
||||||
|
* this will return only non-bitmap fonts which are scalable to any size requested.
|
||||||
|
* Setting this option to true will mean the "scalable" flag is irrelavant.
|
||||||
|
*/
|
||||||
|
enum FontListCriteria {
|
||||||
|
FixedWidthFonts = 0x01,
|
||||||
|
SmoothScalableFonts = 0x02
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @li @p FamilyList - Identifies the family (leftmost) list.
|
* @li @p FamilyList - Identifies the family (leftmost) list.
|
||||||
* @li @p StyleList - Identifies the style (center) list.
|
* @li @p StyleList - Identifies the style (center) list.
|
||||||
* @li @p SizeList - Identifies the size (rightmost) list.
|
* @li @p SizeList - Identifies the size (rightmost) list.
|
||||||
*/
|
*/
|
||||||
enum FontColumn { FamilyList=0x01, StyleList=0x02, SizeList=0x04};
|
enum FontColumn {
|
||||||
|
FamilyList = 0x01,
|
||||||
|
StyleList = 0x02,
|
||||||
|
SizeList = 0x04
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @li @p FontDiffFamily - Identifies a requested change in the font family.
|
* @li @p FontDiffFamily - Identifies a requested change in the font family.
|
||||||
* @li @p FontDiffStyle - Identifies a requested change in the font style.
|
* @li @p FontDiffStyle - Identifies a requested change in the font style.
|
||||||
* @li @p FontDiffSize - Identifies a requested change in the font size.
|
* @li @p FontDiffSize - Identifies a requested change in the font size.
|
||||||
*/
|
*/
|
||||||
enum FontDiff { NoFontDiffFlags = 0,
|
enum FontDiff {
|
||||||
|
NoFontDiffFlags = 0,
|
||||||
FontDiffFamily = 1,
|
FontDiffFamily = 1,
|
||||||
FontDiffStyle = 2,
|
FontDiffStyle = 2,
|
||||||
FontDiffSize = 4,
|
FontDiffSize = 4,
|
||||||
AllFontDiffs = FontDiffFamily | FontDiffStyle | FontDiffSize };
|
AllFontDiffs = FontDiffFamily | FontDiffStyle | FontDiffSize
|
||||||
|
};
|
||||||
Q_DECLARE_FLAGS(FontDiffFlags, FontDiff)
|
Q_DECLARE_FLAGS(FontDiffFlags, FontDiff)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -78,10 +97,12 @@ public:
|
||||||
* @li @p DisplayFrame show a visual frame around the chooser
|
* @li @p DisplayFrame show a visual frame around the chooser
|
||||||
* @li @p ShowDifferences display the font differences interfaces
|
* @li @p ShowDifferences display the font differences interfaces
|
||||||
*/
|
*/
|
||||||
enum DisplayFlag { NoDisplayFlags = 0,
|
enum DisplayFlag {
|
||||||
|
NoDisplayFlags = 0,
|
||||||
FixedFontsOnly = 1,
|
FixedFontsOnly = 1,
|
||||||
DisplayFrame = 2,
|
DisplayFrame = 2,
|
||||||
ShowDifferences = 4 };
|
ShowDifferences = 4
|
||||||
|
};
|
||||||
Q_DECLARE_FLAGS(DisplayFlags, DisplayFlag)
|
Q_DECLARE_FLAGS(DisplayFlags, DisplayFlag)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,11 +132,11 @@ public:
|
||||||
* *sizeIsRelativeState, user choice may be retrieved by
|
* *sizeIsRelativeState, user choice may be retrieved by
|
||||||
* calling sizeIsRelative().
|
* calling sizeIsRelative().
|
||||||
*/
|
*/
|
||||||
explicit KFontChooser( QWidget *parent = 0L,
|
explicit KFontChooser(QWidget *parent = nullptr,
|
||||||
const DisplayFlags& flags = DisplayFrame,
|
const DisplayFlags flags = DisplayFrame,
|
||||||
const QStringList &fontList = QStringList(),
|
const QStringList &fontList = QStringList(),
|
||||||
int visibleListSize = 8,
|
int visibleListSize = 8,
|
||||||
Qt::CheckState *sizeIsRelativeState = 0L );
|
Qt::CheckState *sizeIsRelativeState = nullptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destructs the font chooser.
|
* Destructs the font chooser.
|
||||||
|
@ -125,8 +146,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Enables or disable a font column in the chooser.
|
* Enables or disable a font column in the chooser.
|
||||||
*
|
*
|
||||||
* Use this
|
* Use this function if your application does not need or supports all font
|
||||||
* function if your application does not need or supports all font
|
|
||||||
* properties.
|
* properties.
|
||||||
*
|
*
|
||||||
* @param column Specify the columns. An or'ed combination of
|
* @param column Specify the columns. An or'ed combination of
|
||||||
|
@ -183,7 +203,7 @@ public:
|
||||||
* NOTE: If parameter sizeIsRelative was not set in the constructor
|
* NOTE: If parameter sizeIsRelative was not set in the constructor
|
||||||
* of the widget this setting will be ignored.
|
* of the widget this setting will be ignored.
|
||||||
*/
|
*/
|
||||||
void setSizeIsRelative( Qt::CheckState relative );
|
void setSizeIsRelative(const Qt::CheckState relative);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Whether the font size is to be interpreted as relative size
|
* @return Whether the font size is to be interpreted as relative size
|
||||||
|
@ -191,7 +211,6 @@ public:
|
||||||
*/
|
*/
|
||||||
Qt::CheckState sizeIsRelative() const;
|
Qt::CheckState sizeIsRelative() const;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The current text in the sample text input area.
|
* @return The current text in the sample text input area.
|
||||||
*/
|
*/
|
||||||
|
@ -216,16 +235,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void setSampleBoxVisible(bool visible);
|
void setSampleBoxVisible(bool visible);
|
||||||
|
|
||||||
/**
|
|
||||||
* The selection criteria for the font families shown in the dialog.
|
|
||||||
* @li @p FixedWidthFont when included only fixed-width fonts are returned.
|
|
||||||
* The fonts where the width of every character is equal.
|
|
||||||
* @li @p SmoothScalableFont when included only return smooth scalable fonts.
|
|
||||||
* this will return only non-bitmap fonts which are scalable to any size requested.
|
|
||||||
* Setting this option to true will mean the "scalable" flag is irrelavant.
|
|
||||||
*/
|
|
||||||
enum FontListCriteria { FixedWidthFonts=0x01, SmoothScalableFonts=0x02 };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a list of font strings.
|
* Creates a list of font strings.
|
||||||
*
|
*
|
||||||
|
@ -233,12 +242,12 @@ public:
|
||||||
* @param fontListCriteria should contain all the restrictions for font selection as OR-ed values
|
* @param fontListCriteria should contain all the restrictions for font selection as OR-ed values
|
||||||
* @see KFontChooser::FontListCriteria for the individual values
|
* @see KFontChooser::FontListCriteria for the individual values
|
||||||
*/
|
*/
|
||||||
static void getFontList( QStringList &list, uint fontListCriteria);
|
static void getFontList(QStringList &list, const uint fontListCriteria);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reimplemented for internal reasons.
|
* Reimplemented for internal reasons.
|
||||||
*/
|
*/
|
||||||
virtual QSize sizeHint( void ) const;
|
virtual QSize sizeHint() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
|
@ -247,11 +256,11 @@ Q_SIGNALS:
|
||||||
void fontSelected(const QFont &font);
|
void fontSelected(const QFont &font);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Q_DISABLE_COPY(KFontChooser)
|
||||||
|
|
||||||
class Private;
|
class Private;
|
||||||
Private * const d;
|
Private * const d;
|
||||||
|
|
||||||
Q_DISABLE_COPY(KFontChooser)
|
|
||||||
|
|
||||||
Q_PRIVATE_SLOT(d, void _k_toggled_checkbox())
|
Q_PRIVATE_SLOT(d, void _k_toggled_checkbox())
|
||||||
Q_PRIVATE_SLOT(d, void _k_family_chosen_slot(const QString &))
|
Q_PRIVATE_SLOT(d, void _k_family_chosen_slot(const QString &))
|
||||||
Q_PRIVATE_SLOT(d, void _k_size_chosen_slot(const QString &))
|
Q_PRIVATE_SLOT(d, void _k_size_chosen_slot(const QString &))
|
||||||
|
@ -262,4 +271,4 @@ private:
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(KFontChooser::DisplayFlags)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(KFontChooser::DisplayFlags)
|
||||||
|
|
||||||
#endif
|
#endif // KFONTCHOOSER_H
|
||||||
|
|
|
@ -57,7 +57,7 @@ class KFontDialog::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private()
|
Private()
|
||||||
: chooser( 0 )
|
: chooser(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,17 +65,16 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
KFontDialog::KFontDialog(QWidget *parent,
|
KFontDialog::KFontDialog(QWidget *parent,
|
||||||
const KFontChooser::DisplayFlags& flags,
|
const KFontChooser::DisplayFlags flags,
|
||||||
const QStringList &fontList,
|
const QStringList &fontList,
|
||||||
Qt::CheckState *sizeIsRelativeState)
|
Qt::CheckState *sizeIsRelativeState)
|
||||||
: KDialog(parent),
|
: KDialog(parent),
|
||||||
d( new Private )
|
d(new Private())
|
||||||
{
|
{
|
||||||
setCaption(i18n("Select Font"));
|
setCaption(i18n("Select Font"));
|
||||||
setButtons( Ok | Cancel );
|
setButtons(KDialog::Ok | KDialog::Cancel);
|
||||||
setDefaultButton(Ok);
|
setDefaultButton(KDialog::Ok);
|
||||||
d->chooser = new KFontChooser( this, flags, fontList, 8,
|
d->chooser = new KFontChooser(this, flags, fontList, 8, sizeIsRelativeState);
|
||||||
sizeIsRelativeState );
|
|
||||||
d->chooser->setObjectName("fontChooser");
|
d->chooser->setObjectName("fontChooser");
|
||||||
|
|
||||||
connect(d->chooser , SIGNAL(fontSelected(QFont)), this , SIGNAL(fontSelected(QFont)));
|
connect(d->chooser , SIGNAL(fontSelected(QFont)), this , SIGNAL(fontSelected(QFont)));
|
||||||
|
@ -98,7 +97,7 @@ QFont KFontDialog::font() const
|
||||||
return d->chooser->font();
|
return d->chooser->font();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KFontDialog::setSizeIsRelative( Qt::CheckState relative )
|
void KFontDialog::setSizeIsRelative(const Qt::CheckState relative)
|
||||||
{
|
{
|
||||||
d->chooser->setSizeIsRelative(relative);
|
d->chooser->setSizeIsRelative(relative);
|
||||||
}
|
}
|
||||||
|
@ -108,32 +107,30 @@ Qt::CheckState KFontDialog::sizeIsRelative() const
|
||||||
return d->chooser->sizeIsRelative();
|
return d->chooser->sizeIsRelative();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int KFontDialog::getFontDiff(QFont &theFont,
|
int KFontDialog::getFontDiff(QFont &theFont,
|
||||||
KFontChooser::FontDiffFlags& diffFlags,
|
KFontChooser::FontDiffFlags& diffFlags,
|
||||||
const KFontChooser::DisplayFlags& flags,
|
const KFontChooser::DisplayFlags flags,
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
Qt::CheckState *sizeIsRelativeState )
|
Qt::CheckState *sizeIsRelativeState )
|
||||||
{
|
{
|
||||||
KFontDialog dlg( parent, flags | KFontChooser::ShowDifferences,
|
KFontDialog dlg(parent, flags | KFontChooser::ShowDifferences, QStringList(), sizeIsRelativeState);
|
||||||
QStringList(), sizeIsRelativeState );
|
|
||||||
dlg.setModal(true);
|
dlg.setModal(true);
|
||||||
dlg.setObjectName("Font Selector");
|
dlg.setObjectName("Font Selector");
|
||||||
dlg.setFont(theFont, flags & KFontChooser::FixedFontsOnly);
|
dlg.setFont(theFont, flags & KFontChooser::FixedFontsOnly);
|
||||||
|
|
||||||
int result = dlg.exec();
|
const int result = dlg.exec();
|
||||||
if( result == Accepted )
|
if (result == KDialog::Accepted) {
|
||||||
{
|
|
||||||
theFont = dlg.d->chooser->font();
|
theFont = dlg.d->chooser->font();
|
||||||
diffFlags = dlg.d->chooser->fontDiffFlags();
|
diffFlags = dlg.d->chooser->fontDiffFlags();
|
||||||
if( sizeIsRelativeState )
|
if (sizeIsRelativeState) {
|
||||||
*sizeIsRelativeState = dlg.d->chooser->sizeIsRelative();
|
*sizeIsRelativeState = dlg.d->chooser->sizeIsRelative();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int KFontDialog::getFont(QFont &theFont,
|
int KFontDialog::getFont(QFont &theFont,
|
||||||
const KFontChooser::DisplayFlags& flags,
|
const KFontChooser::DisplayFlags flags,
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
Qt::CheckState *sizeIsRelativeState)
|
Qt::CheckState *sizeIsRelativeState)
|
||||||
{
|
{
|
||||||
|
@ -142,36 +139,34 @@ int KFontDialog::getFont( QFont &theFont,
|
||||||
dlg.setObjectName("Font Selector");
|
dlg.setObjectName("Font Selector");
|
||||||
dlg.setFont(theFont, flags & KFontChooser::FixedFontsOnly);
|
dlg.setFont(theFont, flags & KFontChooser::FixedFontsOnly);
|
||||||
|
|
||||||
int result = dlg.exec();
|
const int result = dlg.exec();
|
||||||
if( result == Accepted )
|
if (result == KDialog::Accepted) {
|
||||||
{
|
|
||||||
theFont = dlg.d->chooser->font();
|
theFont = dlg.d->chooser->font();
|
||||||
if( sizeIsRelativeState )
|
if (sizeIsRelativeState) {
|
||||||
*sizeIsRelativeState = dlg.d->chooser->sizeIsRelative();
|
*sizeIsRelativeState = dlg.d->chooser->sizeIsRelative();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int KFontDialog::getFontAndText(QFont &theFont, QString &theString,
|
int KFontDialog::getFontAndText(QFont &theFont, QString &theString,
|
||||||
const KFontChooser::DisplayFlags& flags,
|
const KFontChooser::DisplayFlags flags,
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
Qt::CheckState *sizeIsRelativeState)
|
Qt::CheckState *sizeIsRelativeState)
|
||||||
{
|
{
|
||||||
KFontDialog dlg( parent, flags,
|
KFontDialog dlg(parent, flags, QStringList(), sizeIsRelativeState );
|
||||||
QStringList(), sizeIsRelativeState );
|
|
||||||
dlg.setModal(true);
|
dlg.setModal(true);
|
||||||
dlg.setObjectName("Font and Text Selector");
|
dlg.setObjectName("Font and Text Selector");
|
||||||
dlg.setFont(theFont, flags & KFontChooser::FixedFontsOnly);
|
dlg.setFont(theFont, flags & KFontChooser::FixedFontsOnly);
|
||||||
|
|
||||||
int result = dlg.exec();
|
const int result = dlg.exec();
|
||||||
if( result == Accepted )
|
if( result == KDialog::Accepted) {
|
||||||
{
|
|
||||||
theFont = dlg.d->chooser->font();
|
theFont = dlg.d->chooser->font();
|
||||||
theString = dlg.d->chooser->sampleText();
|
theString = dlg.d->chooser->sampleText();
|
||||||
if( sizeIsRelativeState )
|
if (sizeIsRelativeState) {
|
||||||
*sizeIsRelativeState = dlg.d->chooser->sizeIsRelative();
|
*sizeIsRelativeState = dlg.d->chooser->sizeIsRelative();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
Boston, MA 02110-1301, USA.
|
Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
#ifndef K_FONT_DIALOG_H
|
#ifndef KFONTDIALOG_H
|
||||||
#define K_FONT_DIALOG_H
|
#define KFONTDIALOG_H
|
||||||
|
|
||||||
#include <kdialog.h>
|
#include <kdialog.h>
|
||||||
#include <kfontchooser.h>
|
#include <kfontchooser.h>
|
||||||
|
@ -53,9 +53,9 @@
|
||||||
*
|
*
|
||||||
* @author Preston Brown <pbrown@kde.org>, Bernd Wuebben <wuebben@kde.org>
|
* @author Preston Brown <pbrown@kde.org>, Bernd Wuebben <wuebben@kde.org>
|
||||||
*/
|
*/
|
||||||
class KDEUI_EXPORT KFontDialog : public KDialog {
|
class KDEUI_EXPORT KFontDialog : public KDialog
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Constructs a font selection dialog.
|
* Constructs a font selection dialog.
|
||||||
|
@ -75,13 +75,13 @@ public:
|
||||||
* calling sizeIsRelative().
|
* calling sizeIsRelative().
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
explicit KFontDialog( QWidget *parent = 0,
|
explicit KFontDialog(QWidget *parent = nullptr,
|
||||||
const KFontChooser::DisplayFlags& flags =
|
const KFontChooser::DisplayFlags flags = KFontChooser::NoDisplayFlags,
|
||||||
KFontChooser::NoDisplayFlags,
|
|
||||||
const QStringList &fontlist = QStringList(),
|
const QStringList &fontlist = QStringList(),
|
||||||
Qt::CheckState *sizeIsRelativeState = 0 );
|
Qt::CheckState *sizeIsRelativeState = nullptr);
|
||||||
|
|
||||||
~KFontDialog();
|
~KFontDialog();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the currently selected font in the dialog.
|
* Sets the currently selected font in the dialog.
|
||||||
*
|
*
|
||||||
|
@ -102,7 +102,7 @@ public:
|
||||||
* NOTE: If parameter sizeIsRelative was not set in the constructor
|
* NOTE: If parameter sizeIsRelative was not set in the constructor
|
||||||
* of the dialog this setting will be ignored.
|
* of the dialog this setting will be ignored.
|
||||||
*/
|
*/
|
||||||
void setSizeIsRelative( Qt::CheckState relative );
|
void setSizeIsRelative(const Qt::CheckState relative);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Whether the font size is to be interpreted as relative size
|
* @return Whether the font size is to be interpreted as relative size
|
||||||
|
@ -131,10 +131,9 @@ public:
|
||||||
* @return QDialog::result().
|
* @return QDialog::result().
|
||||||
*/
|
*/
|
||||||
static int getFont(QFont &theFont,
|
static int getFont(QFont &theFont,
|
||||||
const KFontChooser::DisplayFlags& flags =
|
const KFontChooser::DisplayFlags flags = KFontChooser::NoDisplayFlags,
|
||||||
KFontChooser::NoDisplayFlags,
|
QWidget *parent = nullptr,
|
||||||
QWidget *parent = 0L,
|
Qt::CheckState *sizeIsRelativeState = nullptr);
|
||||||
Qt::CheckState *sizeIsRelativeState = 0L );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a modal font difference dialog, lets the user choose a selection
|
* Creates a modal font difference dialog, lets the user choose a selection
|
||||||
|
@ -170,10 +169,9 @@ public:
|
||||||
*/
|
*/
|
||||||
static int getFontDiff(QFont &theFont,
|
static int getFontDiff(QFont &theFont,
|
||||||
KFontChooser::FontDiffFlags& diffFlags,
|
KFontChooser::FontDiffFlags& diffFlags,
|
||||||
const KFontChooser::DisplayFlags& flags =
|
const KFontChooser::DisplayFlags flags = KFontChooser::NoDisplayFlags,
|
||||||
KFontChooser::NoDisplayFlags,
|
QWidget *parent = nullptr,
|
||||||
QWidget *parent = 0L,
|
Qt::CheckState *sizeIsRelativeState = nullptr);
|
||||||
Qt::CheckState *sizeIsRelativeState = 0L );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When you are not only interested in the font selected, but also
|
* When you are not only interested in the font selected, but also
|
||||||
|
@ -195,10 +193,9 @@ public:
|
||||||
* @return The result of the dialog.
|
* @return The result of the dialog.
|
||||||
*/
|
*/
|
||||||
static int getFontAndText(QFont &theFont, QString &theString,
|
static int getFontAndText(QFont &theFont, QString &theString,
|
||||||
const KFontChooser::DisplayFlags& flags =
|
const KFontChooser::DisplayFlags flags = KFontChooser::NoDisplayFlags,
|
||||||
KFontChooser::NoDisplayFlags,
|
QWidget *parent = nullptr,
|
||||||
QWidget *parent = 0L,
|
Qt::CheckState *sizeIsRelativeState = nullptr);
|
||||||
Qt::CheckState *sizeIsRelativeState = 0L );
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
|
@ -209,10 +206,9 @@ Q_SIGNALS:
|
||||||
void fontSelected(const QFont &font);
|
void fontSelected(const QFont &font);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Q_DISABLE_COPY(KFontDialog)
|
||||||
class Private;
|
class Private;
|
||||||
Private * const d;
|
Private * const d;
|
||||||
|
|
||||||
Q_DISABLE_COPY(KFontDialog)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // KFONTDIALOG_H
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
* @param onlyFixed Only display fonts which have fixed-width character
|
* @param onlyFixed Only display fonts which have fixed-width character
|
||||||
* sizes.
|
* sizes.
|
||||||
*/
|
*/
|
||||||
explicit KFontRequester(QWidget *parent = 0L, bool onlyFixed = false);
|
explicit KFontRequester(QWidget *parent = nullptr, bool onlyFixed = false);
|
||||||
|
|
||||||
~KFontRequester();
|
~KFontRequester();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue