You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.6 KiB
69 lines
1.6 KiB
#include <QPixmap>
|
|
#include <QMessageBox>
|
|
#include <QDesktopServices>
|
|
#include <QCoreApplication>
|
|
#include <QSystemTrayIcon>
|
|
#include <QQmlContext>
|
|
#include <QMessageBox>
|
|
#include <QGroupBox>
|
|
#include <QFileDialog>
|
|
|
|
#include "chatwindow.h"
|
|
#include "config-conversations.h"
|
|
#include "lib/globals.h"
|
|
#include "wsclient.h"
|
|
|
|
#include "ui_chatwindow.h"
|
|
|
|
|
|
ChatWindow * ChatWindow::pChatWindow = nullptr;
|
|
|
|
ChatWindow::ChatWindow(Conversations *ctx, QWidget *parent) :
|
|
QMainWindow(parent),
|
|
ui(new Ui::ChatWindow),
|
|
m_ctx(ctx) {
|
|
pChatWindow = this;
|
|
ui->setupUi(this);
|
|
|
|
#ifdef MAEMO
|
|
setProperty("X-Maemo-StackedWindow", 1);
|
|
#endif
|
|
|
|
// ui->webWidget->load(QUrl("qrc:/chat/conversation.html"));
|
|
// ui->webWidget->page()->setWebChannel(m_webChannel);
|
|
// m_webChannel->registerObject(QString("Conversations"), this->m_ctx);
|
|
|
|
auto *qctx = ui->quick->rootContext();
|
|
qctx->setContextProperty("chatModel", m_ctx->chatModel);
|
|
|
|
auto theme = config()->get(ConfigKeys::ChatTheme).toString();
|
|
if(theme == "uwot")
|
|
ui->quick->setSource(QUrl("qrc:/chat/uwot.qml"));
|
|
else
|
|
ui->quick->setSource(QUrl("qrc:/chat/default.qml"));
|
|
|
|
connect(this->ui->btnSend, &QPushButton::clicked, this, &ChatWindow::onGatherMessage);
|
|
}
|
|
|
|
void ChatWindow::onGatherMessage() {
|
|
QString _msg = this->ui->chatBox->text();
|
|
_msg = _msg.trimmed();
|
|
if(_msg.isEmpty())
|
|
return;
|
|
emit sendMessage(_msg);
|
|
|
|
this->ui->chatBox->clear();
|
|
}
|
|
|
|
Conversations *ChatWindow::getContext(){
|
|
return pChatWindow->m_ctx;
|
|
}
|
|
|
|
void ChatWindow::closeEvent(QCloseEvent *event) {
|
|
QWidget::closeEvent(event);
|
|
}
|
|
|
|
ChatWindow::~ChatWindow() {
|
|
delete ui;
|
|
}
|