71 lines
1.2 KiB
C++
71 lines
1.2 KiB
C++
#include "mainwindow.h"
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
: QGraphicsView(parent)
|
|
{
|
|
scene = new QGraphicsScene;
|
|
chatWidget = new ChatWidget();
|
|
|
|
this->setScene(scene);
|
|
scene->addItem(chatWidget);
|
|
|
|
chatWidget->show();
|
|
|
|
}
|
|
|
|
MainWindow::~MainWindow()
|
|
{
|
|
|
|
}
|
|
|
|
void MainWindow::showContent(Content content, bool hideCurrent)
|
|
{
|
|
if(hideCurrent) {
|
|
while ( ! currentContent.isEmpty() ) {
|
|
hideContent(currentContent.takeFirst());
|
|
}
|
|
}
|
|
|
|
switch (content) {
|
|
case NONE:
|
|
break;
|
|
case CHATWIDGET:
|
|
chatWidget->show();
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
void MainWindow::hideContent(Content content)
|
|
{
|
|
switch (content) {
|
|
case NONE:
|
|
|
|
break;
|
|
case CHATWIDGET:
|
|
chatWidget->hide();
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
QList<Content> MainWindow::getCurrentContent() const
|
|
{
|
|
return currentContent;
|
|
}
|
|
|
|
void MainWindow::keyPressEvent(QKeyEvent *event)
|
|
{
|
|
qDebug( "%s", ("keyPressEvent: " + std::to_string(event->key())).c_str() );
|
|
}
|
|
|
|
void MainWindow::mousePressEvent(QMouseEvent *event)
|
|
{
|
|
qDebug( "%s", ("mousePress: " + std::to_string(event->type())).c_str() );
|
|
|
|
chatWidget->inputLine->sceneMousePressEvent(event);
|
|
QGraphicsView::mousePressEvent(event);
|
|
}
|