input of channel names

This commit is contained in:
fourtf
2017-01-17 00:15:44 +01:00
parent f227b998a3
commit 91e3976a09
16 changed files with 302 additions and 134 deletions
+51 -5
View File
@@ -1,14 +1,21 @@
#include "chatwidget.h"
#include "QFont"
#include "QFontDatabase"
#include "QPainter"
#include "QVBoxLayout"
#include "channels.h"
#include "colorscheme.h"
#include "textinputdialog.h"
#include <QFont>
#include <QFontDatabase>
#include <QPainter>
#include <QVBoxLayout>
ChatWidget::ChatWidget(QWidget *parent)
: QWidget(parent)
, m_header(this)
, m_channel(NULL)
, m_channelName(QString())
, m_vbox(this)
, m_header(this)
, m_view(this)
, m_input()
{
m_vbox.setSpacing(0);
m_vbox.setMargin(1);
@@ -22,6 +29,45 @@ ChatWidget::~ChatWidget()
{
}
void
ChatWidget::setChannelName(const QString &name)
{
QString channel = name.trimmed();
if (QString::compare(channel, m_channelName, Qt::CaseInsensitive) == 0) {
m_channelName = channel;
m_header.updateChannelText();
return;
}
m_channelName = channel;
m_header.updateChannelText();
m_view.layoutMessages();
if (!m_channelName.isEmpty()) {
Channels::removeChannel(m_channelName);
}
if (channel.isEmpty()) {
m_channel = NULL;
} else {
m_channel = Channels::addChannel(channel);
}
}
void
ChatWidget::showChangeChannelPopup()
{
TextInputDialog dialog(this);
dialog.setText(m_channelName);
if (dialog.exec() == QDialog::Accepted) {
setChannelName(dialog.text());
}
}
void
ChatWidget::paintEvent(QPaintEvent *)
{