added message-sending through channel->sendMessage

doesn't do anything with the user input box on enter yet though
This commit is contained in:
Rasmus Karlsson
2017-05-27 17:45:40 +02:00
parent c4de5c806a
commit d113115822
12 changed files with 91 additions and 50 deletions
+6 -6
View File
@@ -7,10 +7,10 @@
namespace chatterino {
namespace widgets {
AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> &&channel)
AccountPopupWidget::AccountPopupWidget(SharedChannel &channel)
: QWidget(nullptr)
, _ui(new Ui::AccountPopup)
, _channel(std::move(channel))
, _channel(channel)
{
_ui->setupUi(this);
@@ -25,10 +25,10 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr<Channel> &&channel)
connect(_ui->btnPurge, &QPushButton::clicked, [=]() {
qDebug() << "xD: " << _channel->getName();
/*
_channel->sendMessage(
QString(".timeout %1 0").arg(_ui->lblUsername->text()));
*/
printf("Channel pointer in dialog: %p\n", _channel.get());
//_channel->sendMessage(QString(".timeout %1 0").arg(_ui->lblUsername->text()));
_channel->sendMessage("xD");
});
}
+2 -2
View File
@@ -19,14 +19,14 @@ class AccountPopupWidget : public QWidget
{
Q_OBJECT
public:
AccountPopupWidget(std::shared_ptr<Channel> &&_channel);
AccountPopupWidget(std::shared_ptr<Channel> &channel);
void setName(const QString &name);
private:
Ui::AccountPopup *_ui;
std::shared_ptr<Channel> _channel;
std::shared_ptr<Channel> &_channel;
};
} // namespace widgets
+14 -6
View File
@@ -43,6 +43,11 @@ std::shared_ptr<Channel> ChatWidget::getChannel() const
return _channel;
}
std::shared_ptr<Channel> &ChatWidget::getChannelRef()
{
return _channel;
}
const QString &ChatWidget::getChannelName() const
{
return _channelName;
@@ -50,11 +55,11 @@ const QString &ChatWidget::getChannelName() const
void ChatWidget::setChannelName(const QString &name)
{
QString channel = name.trimmed();
QString channelName = name.trimmed();
// return if channel name is the same
if (QString::compare(channel, _channelName, Qt::CaseInsensitive) == 0) {
_channelName = channel;
if (QString::compare(channelName, _channelName, Qt::CaseInsensitive) == 0) {
_channelName = channelName;
_header.updateChannelText();
return;
@@ -68,15 +73,18 @@ void ChatWidget::setChannelName(const QString &name)
}
// update members
_channelName = channel;
_channelName = channelName;
// update messages
_messages.clear();
if (channel.isEmpty()) {
printf("Set channel name xD %s\n", qPrintable(name));
if (channelName.isEmpty()) {
_channel = NULL;
} else {
_channel = ChannelManager::getInstance().addChannel(channel);
_channel = ChannelManager::getInstance().addChannel(channelName);
printf("Created channel FeelsGoodMan %p\n", _channel.get());
attachChannel(_channel);
}
+1
View File
@@ -28,6 +28,7 @@ public:
~ChatWidget();
SharedChannel getChannel() const;
SharedChannel &getChannelRef();
const QString &getChannelName() const;
void setChannelName(const QString &name);
+1 -1
View File
@@ -22,7 +22,7 @@ ChatWidgetView::ChatWidgetView(ChatWidget *parent)
: QWidget()
, _chatWidget(parent)
, _scrollbar(this)
, _userPopupWidget(_chatWidget->getChannel())
, _userPopupWidget(_chatWidget->getChannelRef())
, _onlyUpdateEmotes(false)
, _mouseDown(false)
, _lastPressPosition()