mirror of
https://github.com/fergalmoran/flameshot.git
synced 2026-01-06 17:13:58 +00:00
reformatted to Mozilla code style
This commit is contained in:
committed by
borgmanJeremy
parent
c0e2e48db4
commit
c8d15205be
@@ -18,86 +18,108 @@
|
||||
#include "textconfig.h"
|
||||
#include "src/utils/colorutils.h"
|
||||
#include "src/utils/pathinfo.h"
|
||||
#include <QFontDatabase>
|
||||
#include <QComboBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFontDatabase>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
TextConfig::TextConfig(QWidget *parent) : QWidget(parent) {
|
||||
m_layout = new QVBoxLayout(this);
|
||||
TextConfig::TextConfig(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_layout = new QVBoxLayout(this);
|
||||
|
||||
QFontDatabase fontDB;
|
||||
QComboBox *fontsCB = new QComboBox();
|
||||
connect(fontsCB, &QComboBox::currentTextChanged,
|
||||
this, &TextConfig::fontFamilyChanged);
|
||||
fontsCB->addItems(fontDB.families());
|
||||
// TODO save family in config
|
||||
int index = fontsCB->findText(font().family());
|
||||
fontsCB->setCurrentIndex(index);
|
||||
QFontDatabase fontDB;
|
||||
QComboBox* fontsCB = new QComboBox();
|
||||
connect(fontsCB,
|
||||
&QComboBox::currentTextChanged,
|
||||
this,
|
||||
&TextConfig::fontFamilyChanged);
|
||||
fontsCB->addItems(fontDB.families());
|
||||
// TODO save family in config
|
||||
int index = fontsCB->findText(font().family());
|
||||
fontsCB->setCurrentIndex(index);
|
||||
|
||||
QColor bgColor(palette().windowText().color());
|
||||
QString iconPrefix = ColorUtils::colorIsDark(bgColor) ?
|
||||
PathInfo::whiteIconPath() :
|
||||
PathInfo::blackIconPath();
|
||||
QColor bgColor(palette().windowText().color());
|
||||
QString iconPrefix = ColorUtils::colorIsDark(bgColor)
|
||||
? PathInfo::whiteIconPath()
|
||||
: PathInfo::blackIconPath();
|
||||
|
||||
m_strikeOutButton = new QPushButton(
|
||||
QIcon(iconPrefix + "format_strikethrough.svg"), QLatin1String(""));
|
||||
m_strikeOutButton->setCheckable(true);
|
||||
connect(m_strikeOutButton, &QPushButton::clicked,
|
||||
this, &TextConfig::fontStrikeOutChanged);
|
||||
m_strikeOutButton->setToolTip(tr("StrikeOut"));
|
||||
m_strikeOutButton = new QPushButton(
|
||||
QIcon(iconPrefix + "format_strikethrough.svg"), QLatin1String(""));
|
||||
m_strikeOutButton->setCheckable(true);
|
||||
connect(m_strikeOutButton,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&TextConfig::fontStrikeOutChanged);
|
||||
m_strikeOutButton->setToolTip(tr("StrikeOut"));
|
||||
|
||||
m_underlineButton = new QPushButton(
|
||||
QIcon(iconPrefix + "format_underlined.svg"), QLatin1String(""));
|
||||
m_underlineButton->setCheckable(true);
|
||||
connect(m_underlineButton, &QPushButton::clicked,
|
||||
this, &TextConfig::fontUnderlineChanged);
|
||||
m_underlineButton->setToolTip(tr("Underline"));
|
||||
m_underlineButton = new QPushButton(
|
||||
QIcon(iconPrefix + "format_underlined.svg"), QLatin1String(""));
|
||||
m_underlineButton->setCheckable(true);
|
||||
connect(m_underlineButton,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&TextConfig::fontUnderlineChanged);
|
||||
m_underlineButton->setToolTip(tr("Underline"));
|
||||
|
||||
m_weightButton = new QPushButton(
|
||||
QIcon(iconPrefix + "format_bold.svg"), QLatin1String(""));
|
||||
m_weightButton->setCheckable(true);
|
||||
connect(m_weightButton, &QPushButton::clicked,
|
||||
this, &TextConfig::weightButtonPressed);
|
||||
m_weightButton->setToolTip(tr("Bold"));
|
||||
m_weightButton =
|
||||
new QPushButton(QIcon(iconPrefix + "format_bold.svg"), QLatin1String(""));
|
||||
m_weightButton->setCheckable(true);
|
||||
connect(m_weightButton,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&TextConfig::weightButtonPressed);
|
||||
m_weightButton->setToolTip(tr("Bold"));
|
||||
|
||||
m_italicButton = new QPushButton(
|
||||
QIcon(iconPrefix + "format_italic.svg"), QLatin1String(""));
|
||||
m_italicButton->setCheckable(true);
|
||||
connect(m_italicButton, &QPushButton::clicked,
|
||||
this, &TextConfig::fontItalicChanged);
|
||||
m_italicButton->setToolTip(tr("Italic"));
|
||||
QHBoxLayout *modifiersLayout = new QHBoxLayout();
|
||||
m_italicButton =
|
||||
new QPushButton(QIcon(iconPrefix + "format_italic.svg"), QLatin1String(""));
|
||||
m_italicButton->setCheckable(true);
|
||||
connect(m_italicButton,
|
||||
&QPushButton::clicked,
|
||||
this,
|
||||
&TextConfig::fontItalicChanged);
|
||||
m_italicButton->setToolTip(tr("Italic"));
|
||||
QHBoxLayout* modifiersLayout = new QHBoxLayout();
|
||||
|
||||
m_layout->addWidget(fontsCB);
|
||||
modifiersLayout->addWidget(m_strikeOutButton);
|
||||
modifiersLayout->addWidget(m_underlineButton);
|
||||
modifiersLayout->addWidget(m_weightButton);
|
||||
modifiersLayout->addWidget(m_italicButton);
|
||||
m_layout->addLayout(modifiersLayout);
|
||||
m_layout->addWidget(fontsCB);
|
||||
modifiersLayout->addWidget(m_strikeOutButton);
|
||||
modifiersLayout->addWidget(m_underlineButton);
|
||||
modifiersLayout->addWidget(m_weightButton);
|
||||
modifiersLayout->addWidget(m_italicButton);
|
||||
m_layout->addLayout(modifiersLayout);
|
||||
}
|
||||
|
||||
void TextConfig::setUnderline(const bool u) {
|
||||
m_underlineButton->setChecked(u);
|
||||
void
|
||||
TextConfig::setUnderline(const bool u)
|
||||
{
|
||||
m_underlineButton->setChecked(u);
|
||||
}
|
||||
|
||||
void TextConfig::setStrikeOut(const bool s) {
|
||||
m_strikeOutButton->setChecked(s);
|
||||
void
|
||||
TextConfig::setStrikeOut(const bool s)
|
||||
{
|
||||
m_strikeOutButton->setChecked(s);
|
||||
}
|
||||
|
||||
void TextConfig::setWeight(const int w) {
|
||||
m_weightButton->setChecked(static_cast<QFont::Weight>(w) == QFont::Bold);
|
||||
void
|
||||
TextConfig::setWeight(const int w)
|
||||
{
|
||||
m_weightButton->setChecked(static_cast<QFont::Weight>(w) == QFont::Bold);
|
||||
}
|
||||
|
||||
void TextConfig::setItalic(const bool i) {
|
||||
m_italicButton->setChecked(i);
|
||||
void
|
||||
TextConfig::setItalic(const bool i)
|
||||
{
|
||||
m_italicButton->setChecked(i);
|
||||
}
|
||||
|
||||
void TextConfig::weightButtonPressed(const bool w) {
|
||||
if (w) {
|
||||
emit fontWeightChanged(QFont::Bold);
|
||||
} else {
|
||||
emit fontWeightChanged(QFont::Normal);
|
||||
}
|
||||
void
|
||||
TextConfig::weightButtonPressed(const bool w)
|
||||
{
|
||||
if (w) {
|
||||
emit fontWeightChanged(QFont::Bold);
|
||||
} else {
|
||||
emit fontWeightChanged(QFont::Normal);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user