mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Ref T369, text message style component
This commit is contained in:
77
src/blackgui/components/settingstextmessagestyle.cpp
Normal file
77
src/blackgui/components/settingstextmessagestyle.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/* Copyright (C) 2018
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "settingstextmessagestyle.h"
|
||||
#include "ui_settingstextmessagestyle.h"
|
||||
#include "settingsfontdialog.h"
|
||||
#include "texteditdialog.h"
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CSettingsTextMessageStyle::CSettingsTextMessageStyle(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CSettingsTextMessageStyle)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->pb_Font, &QPushButton::released, this, &CSettingsTextMessageStyle::changeFont);
|
||||
connect(ui->pb_Style, &QPushButton::released, this, &CSettingsTextMessageStyle::changeStyle);
|
||||
connect(ui->pb_Reset, &QPushButton::released, this, &CSettingsTextMessageStyle::resetStyle);
|
||||
connect(ui->pb_Reset, &QPushButton::released, this, &CSettingsTextMessageStyle::changed);
|
||||
}
|
||||
|
||||
CSettingsTextMessageStyle::~CSettingsTextMessageStyle()
|
||||
{ }
|
||||
|
||||
QStringList CSettingsTextMessageStyle::getFamilySizeStyle() const
|
||||
{
|
||||
if (m_fontSettingsDialog) { return m_fontSettingsDialog->getFamilySizeStyle(); }
|
||||
|
||||
static const QStringList empty({"", "", ""});
|
||||
return empty;
|
||||
}
|
||||
|
||||
void CSettingsTextMessageStyle::changeFont()
|
||||
{
|
||||
if (!m_fontSettingsDialog)
|
||||
{
|
||||
m_fontSettingsDialog = new CSettingsFontDialog(this);
|
||||
m_fontSettingsDialog->setWithColorSelection(false);
|
||||
}
|
||||
|
||||
const QDialog::DialogCode r = static_cast<QDialog::DialogCode>(m_fontSettingsDialog->exec());
|
||||
if (r == QDialog::Accepted)
|
||||
{
|
||||
emit this->changed();
|
||||
}
|
||||
}
|
||||
|
||||
void CSettingsTextMessageStyle::changeStyle()
|
||||
{
|
||||
if (!m_textEditDialog)
|
||||
{
|
||||
m_textEditDialog = new CTextEditDialog(this);
|
||||
m_textEditDialog->resize(400, 300);
|
||||
}
|
||||
|
||||
m_textEditDialog->textEdit()->setPlainText(m_style);
|
||||
const QDialog::DialogCode r = static_cast<QDialog::DialogCode>(m_textEditDialog->exec());
|
||||
if (r == QDialog::Accepted)
|
||||
{
|
||||
m_style = m_textEditDialog->textEdit()->toPlainText();
|
||||
emit this->changed();
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
70
src/blackgui/components/settingstextmessagestyle.h
Normal file
70
src/blackgui/components/settingstextmessagestyle.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/* Copyright (C) 2018
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_COMPONENTS_SETTINGSTEXTMESSAGESTYLE_H
|
||||
#define BLACKGUI_COMPONENTS_SETTINGSTEXTMESSAGESTYLE_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QStringList>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CSettingsTextMessageStyle; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
class CSettingsFontDialog;
|
||||
class CTextEditDialog;
|
||||
|
||||
//! Text message style
|
||||
class CSettingsTextMessageStyle : public QFrame
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CSettingsTextMessageStyle(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CSettingsTextMessageStyle();
|
||||
|
||||
//! Fmily, size and style
|
||||
QStringList getFamilySizeStyle() const;
|
||||
|
||||
//! Style
|
||||
const QString &getStyle() { return m_style; }
|
||||
|
||||
//! Style
|
||||
void setStyle(const QString &style) { m_style = style; }
|
||||
|
||||
//! Reset style
|
||||
void resetStyle() { m_style.clear(); }
|
||||
|
||||
signals:
|
||||
//! Font or style changed from within the component
|
||||
void changed();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CSettingsTextMessageStyle> ui;
|
||||
CSettingsFontDialog *m_fontSettingsDialog = nullptr;
|
||||
CTextEditDialog *m_textEditDialog = nullptr;
|
||||
QString m_style;
|
||||
|
||||
//! Change font
|
||||
void changeFont();
|
||||
|
||||
//! Change style
|
||||
void changeStyle();
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
#endif // guard
|
||||
67
src/blackgui/components/settingstextmessagestyle.ui
Normal file
67
src/blackgui/components/settingstextmessagestyle.ui
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSettingsTextMessageStyle</class>
|
||||
<widget class="QFrame" name="CSettingsTextMessageStyle">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>301</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_SettingsTextMessageStyle">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="hs_TextMessageStyle">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_Reset">
|
||||
<property name="text">
|
||||
<string>reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_Style">
|
||||
<property name="text">
|
||||
<string>style</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_Font">
|
||||
<property name="text">
|
||||
<string>font</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user