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.

106 lines
2.8 KiB

#include <QPixmap>
#include <QMessageBox>
#include <QDesktopServices>
#include <QCoreApplication>
#include <QSystemTrayIcon>
#include <QMessageBox>
//#include <QWebEnginePage>
#include <QGroupBox>
#include <QFileDialog>
#include <QQuickWidget>
#include <QQuickView>
#include <QQmlContext>
#include "mainwindow.h"
#include "config-conversations.h"
#include "lib/globals.h"
#include "ui_mainwindow.h"
MainWindow * MainWindow::pMainWindow = nullptr;
MainWindow::MainWindow(Conversations *ctx, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
m_ctx(ctx) {
pMainWindow = this;
ui->setupUi(this);
#ifdef MAEMO
setProperty("X-Maemo-StackedWindow", 1);
#endif
this->screenDpiRef = 128;
this->screenGeo = QApplication::primaryScreen()->availableGeometry();
this->screenRect = QGuiApplication::primaryScreen()->geometry();
this->screenDpi = QGuiApplication::primaryScreen()->logicalDotsPerInch();
this->screenDpiPhysical = QGuiApplication::primaryScreen()->physicalDotsPerInch();
this->screenRatio = this->screenDpiPhysical / this->screenDpiRef;
qInfo()
<< QString("%1x%2 (%3 DPI)").arg(this->screenRect.width()).arg(this->screenRect.height()).arg(this->screenDpi);
connect(m_ctx, &Conversations::setTitle, this, &QMainWindow::setWindowTitle);
//connect(ui->btn, &QPushButton::clicked, this, &MainWindow::bla);
qmlRegisterUncreatableMetaObject(
ConfigKeys::staticMetaObject,
"MaemoConfig",
1, 0,
"Config",
"Error: only enums"
);
//qmlRegisterType<MyEnum>("MaemoConfig", 1, 0, "Config");
auto *qctx = ui->quick->rootContext();
qctx->setContextProperty("cfg", config());
ui->quick->setSource(QUrl("qrc:/overview.qml"));
ui->menuBar->hide();
connect(ui->actionSettings, &QAction::triggered, this, &MainWindow::openSettingsWindow);
connect((QObject*)ui->quick->rootObject(), SIGNAL(rowClicked(QString)), this, SLOT(rowClicked(QString)));
connect(this, &MainWindow::requestChatWindow, this, &MainWindow::openChatWindow);
this->show();
}
void MainWindow::openSettingsWindow() {
m_settings = new Settings(m_ctx, this);
m_settings->show();
}
void MainWindow::openChatWindow(const QString &uid) {
m_chatWindow = new ChatWindow(m_ctx, this);
m_chatWindow->show();
connect(m_chatWindow, &ChatWindow::sendMessage, this->m_ctx, &Conversations::onSendMessage);
}
void MainWindow::onChatWindowClosed() {
int wegewg = 1;
}
void MainWindow::showDebugInfo() {
// auto *dialog = new DebugInfoDialog(m_ctx, this);
// dialog->exec();
// dialog->deleteLater();
printf("oki\n");
}
MainWindow *MainWindow::getInstance() {
return pMainWindow;
}
Conversations *MainWindow::getContext(){
return pMainWindow->m_ctx;
}
void MainWindow::closeEvent(QCloseEvent *event) {
QWidget::closeEvent(event);
}
MainWindow::~MainWindow() {
delete ui;
}