Commit 1894a2a8 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Create font select widget

parent bb9f7b4d
Pipeline #27377 failed with stage
in 28 minutes and 3 seconds
......@@ -80,6 +80,7 @@
#include <QTimeEdit>
#include <KAboutData>
#include <QButtonGroup>
#include <QFontDialog>
#ifdef WITH_KUSERFEEDBACK
#include <KUserFeedback/FeedbackConfigWidget>
......@@ -895,6 +896,48 @@ Q_DECL_EXPORT KCModule *create_korganizerconfigviews(QWidget *parent, const char
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
FontPreviewButton::FontPreviewButton(const QString &labelStr, QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *mainLayout = new QHBoxLayout(this);
mainLayout->setContentsMargins(0, 0, 0, 0);
QLabel *label = new QLabel(labelStr, this);
mainLayout->addWidget(label);
mPreview = new QLabel(parent);
mPreview->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
mainLayout->addWidget(mPreview);
QPushButton *button = new QPushButton(i18n("Choose..."), this);
mainLayout->addWidget(button);
connect(button, &QPushButton::clicked, this, &FontPreviewButton::selectFont);
}
void FontPreviewButton::setFont(const QFont &font)
{
mPreview->setFont(font);
}
QFont FontPreviewButton::font() const
{
return mPreview->font();
}
void FontPreviewButton::setPreviewText(const QString &str)
{
mPreview->setText(str);
}
void FontPreviewButton::selectFont()
{
bool ok;
QFont myFont = QFontDialog::getFont(&ok, mPreview->font());
if (ok) {
mPreview->setFont(myFont);
Q_EMIT changed();
}
}
KOPrefsDialogColorsAndFonts::KOPrefsDialogColorsAndFonts(QWidget *parent)
: KPIM::KPrefsModule(KOPrefs::instance(), parent)
{
......@@ -1060,6 +1103,8 @@ KOPrefsDialogColorsAndFonts::KOPrefsDialogColorsAndFonts(QWidget *parent)
load();
}
void KOPrefsDialogColorsAndFonts::usrWriteConfig()
{
QHash<QString, QColor>::const_iterator i = mCategoryDict.constBegin();
......
......@@ -66,6 +66,21 @@ private:
QCheckBox *mShowReminderDaemonCheckBox = nullptr;
};
class FontPreviewButton : public QWidget
{
Q_OBJECT
public:
explicit FontPreviewButton(const QString &labelStr, QWidget *parent = nullptr);
void setFont(const QFont &font);
Q_REQUIRED_RESULT QFont font() const;
void setPreviewText(const QString &str);
Q_SIGNALS:
void changed();
private:
void selectFont();
QLabel *mPreview = nullptr;
};
class KCM_KORGANIZER_EXPORT KOPrefsDialogColorsAndFonts : public KPIM::KPrefsModule
{
Q_OBJECT
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment