random shit changes

This commit is contained in:
Rasmus Karlsson 2017-06-10 22:48:28 +02:00
parent 6898f9c2db
commit 1472471ddb
5 changed files with 37 additions and 30 deletions

View file

@ -82,7 +82,7 @@ void ChatWidget::setChannelName(const QString &name)
printf("Set channel name xD %s\n", qPrintable(name));
if (channelName.isEmpty()) {
_channel = NULL;
_channel = nullptr;
} else {
_channel = ChannelManager::getInstance().addChannel(channelName);
printf("Created channel FeelsGoodMan %p\n", _channel.get());

View file

@ -18,12 +18,22 @@
namespace chatterino {
namespace widgets {
// Each ChatWidget consists of three sub-elements that handle their own part of the chat widget:
// ChatWidgetHeader
// - Responsible for rendering which channel the ChatWidget is in, and the menu in the top-left of
// the chat widget
// ChatWidgetView
// - Responsible for rendering all chat messages, and the scrollbar
// ChatWidgetInput
// - Responsible for rendering and handling user text input
//
// Each sub-element has a reference to the parent Chat Widget
class ChatWidget : public QWidget
{
Q_OBJECT
public:
ChatWidget(QWidget *parent = 0);
ChatWidget(QWidget *parent = nullptr);
~ChatWidget();
SharedChannel getChannel() const;

View file

@ -11,9 +11,9 @@
namespace chatterino {
namespace widgets {
ChatWidgetHeader::ChatWidgetHeader(ChatWidget *parent)
: QWidget()
, _chatWidget(parent)
ChatWidgetHeader::ChatWidgetHeader(ChatWidget *_chatWidget)
: QWidget(_chatWidget)
, chatWidget(_chatWidget)
, _dragStart()
, _dragging(false)
, _leftLabel()
@ -82,7 +82,7 @@ void ChatWidgetHeader::updateColors()
void ChatWidgetHeader::updateChannelText()
{
const QString &c = _chatWidget->getChannelName();
const QString &c = this->chatWidget->getChannelName();
_middleLabel.setText(c.isEmpty() ? "<no channel>" : c);
}
@ -108,18 +108,17 @@ void ChatWidgetHeader::mouseMoveEvent(QMouseEvent *event)
if (_dragging) {
if (std::abs(_dragStart.x() - event->pos().x()) > 12 ||
std::abs(_dragStart.y() - event->pos().y()) > 12) {
auto chatWidget = _chatWidget;
auto page = static_cast<NotebookPage *>(chatWidget->parentWidget());
auto page = static_cast<NotebookPage *>(this->chatWidget->parentWidget());
if (page != NULL) {
if (page != nullptr) {
NotebookPage::isDraggingSplit = true;
NotebookPage::draggingSplit = chatWidget;
NotebookPage::draggingSplit = this->chatWidget;
auto originalLocation = page->removeFromLayout(chatWidget);
auto originalLocation = page->removeFromLayout(this->chatWidget);
// page->update();
QDrag *drag = new QDrag(chatWidget);
QDrag *drag = new QDrag(this->chatWidget);
QMimeData *mimeData = new QMimeData;
mimeData->setData("chatterino/split", "xD");
@ -129,7 +128,7 @@ void ChatWidgetHeader::mouseMoveEvent(QMouseEvent *event)
Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
if (dropAction == Qt::IgnoreAction) {
page->addToLayout(chatWidget, originalLocation);
page->addToLayout(this->chatWidget, originalLocation);
}
NotebookPage::isDraggingSplit = false;
@ -141,7 +140,7 @@ void ChatWidgetHeader::mouseMoveEvent(QMouseEvent *event)
void ChatWidgetHeader::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
_chatWidget->showChangeChannelPopup();
this->chatWidget->showChangeChannelPopup();
}
}
@ -157,7 +156,7 @@ void ChatWidgetHeader::rightButtonClicked()
void ChatWidgetHeader::menuAddSplit()
{
auto page = static_cast<NotebookPage *>(_chatWidget->parentWidget());
auto page = static_cast<NotebookPage *>(this->chatWidget->parentWidget());
page->addChat();
}
void ChatWidgetHeader::menuCloseSplit()
@ -170,12 +169,12 @@ void ChatWidgetHeader::menuMoveSplit()
void ChatWidgetHeader::menuPopup()
{
auto widget = new ChatWidget();
widget->setChannelName(_chatWidget->getChannelName());
widget->setChannelName(this->chatWidget->getChannelName());
widget->show();
}
void ChatWidgetHeader::menuChangeChannel()
{
_chatWidget->showChangeChannelPopup();
this->chatWidget->showChangeChannelPopup();
}
void ChatWidgetHeader::menuClearChat()
{

View file

@ -21,24 +21,22 @@ class ChatWidgetHeader : public QWidget
Q_OBJECT
public:
explicit ChatWidgetHeader(ChatWidget *parent);
ChatWidget *getChatWidget() const
{
return _chatWidget;
}
explicit ChatWidgetHeader(ChatWidget *_chatWidget);
// Update palette from global color scheme
void updateColors();
// Update channel text from chat widget
void updateChannelText();
protected:
void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
virtual void paintEvent(QPaintEvent *) override;
virtual void mousePressEvent(QMouseEvent *event) override;
virtual void mouseMoveEvent(QMouseEvent *event) override;
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
private:
ChatWidget *const _chatWidget;
ChatWidget *chatWidget;
QPoint _dragStart;
bool _dragging;

View file

@ -16,7 +16,7 @@ namespace chatterino {
namespace widgets {
bool NotebookPage::isDraggingSplit = false;
ChatWidget *NotebookPage::draggingSplit = NULL;
ChatWidget *NotebookPage::draggingSplit = nullptr;
std::pair<int, int> NotebookPage::dropPosition = std::pair<int, int>(-1, -1);
NotebookPage::NotebookPage(QWidget *parent, NotebookTab *tab)
@ -80,7 +80,7 @@ std::pair<int, int> NotebookPage::removeFromLayout(ChatWidget *widget)
continue;
}
widget->setParent(NULL);
widget->setParent(nullptr);
bool isLastItem = vbox->count() == 0;