parent
4faa041150
commit
b64d0ddb28
@ -0,0 +1,46 @@
|
||||
#include <QPixmap>
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QCoreApplication>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMessageBox>
|
||||
#include <QWebEnginePage>
|
||||
#include <QGroupBox>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "chatwindow.h"
|
||||
#include "config-conversations.h"
|
||||
#include "lib/globals.h"
|
||||
|
||||
#include "ui_chatwindow.h"
|
||||
|
||||
ChatWindow * ChatWindow::pChatWindow = nullptr;
|
||||
|
||||
ChatWindow::ChatWindow(Conversations *ctx, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::ChatWindow),
|
||||
m_webChannel(new QWebChannel(this)),
|
||||
m_ctx(ctx) {
|
||||
pChatWindow = this;
|
||||
ui->setupUi(this);
|
||||
|
||||
#ifdef Q_WS_MAEMO_5
|
||||
window->setProperty("X-Maemo-Orientation", 2); // XXX: 2 = auto orientation
|
||||
#endif
|
||||
|
||||
ui->webWidget->load(QUrl("qrc:/chat/conversation.html"));
|
||||
ui->webWidget->page()->setWebChannel(m_webChannel);
|
||||
m_webChannel->registerObject(QString("ChatWindow"), this);
|
||||
}
|
||||
|
||||
Conversations *ChatWindow::getContext(){
|
||||
return pChatWindow->m_ctx;
|
||||
}
|
||||
|
||||
void ChatWindow::closeEvent(QCloseEvent *event) {
|
||||
QWidget::closeEvent(event);
|
||||
}
|
||||
|
||||
ChatWindow::~ChatWindow() {
|
||||
delete ui;
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
#ifndef CHATWINDOW_H
|
||||
#define CHATWINDOW_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QResource>
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QtWidgets/QMenu>
|
||||
#include <QMainWindow>
|
||||
#include <QWebChannel>
|
||||
#include <QObject>
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "conversations.h"
|
||||
|
||||
namespace Ui {
|
||||
class ChatWindow;
|
||||
}
|
||||
|
||||
class ChatWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ChatWindow(Conversations *ctx, QWidget *parent = nullptr);
|
||||
static Conversations *getContext();
|
||||
~ChatWindow() override;
|
||||
Ui::ChatWindow *ui;
|
||||
|
||||
Q_INVOKABLE QString loltest() {
|
||||
QString aosidga = QString("loltest");
|
||||
return aosidga;
|
||||
}
|
||||
|
||||
private:
|
||||
Conversations *m_ctx;
|
||||
QWebChannel *m_webChannel;
|
||||
static ChatWindow *pChatWindow;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
};
|
||||
|
||||
#endif
|
@ -0,0 +1,309 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ChatWindow</class>
|
||||
<widget class="QMainWindow" name="ChatWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>607</width>
|
||||
<height>421</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Conversations</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
<normaloff>:/assets/images/appicons/64x64.png</normaloff>:/assets/images/appicons/64x64.png</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QWebEngineView" name="webWidget"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionQuit">
|
||||
<property name="text">
|
||||
<string>Quit application</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action">
|
||||
<property name="text">
|
||||
<string>Network</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSignVerify">
|
||||
<property name="text">
|
||||
<string>Sign/verify message</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
<property name="text">
|
||||
<string>About</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOfficialWebsite">
|
||||
<property name="text">
|
||||
<string>Official website</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSettings">
|
||||
<property name="text">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCalculator">
|
||||
<property name="text">
|
||||
<string>Calculator</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInformation">
|
||||
<property name="text">
|
||||
<string>Information</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPassword">
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSeed">
|
||||
<property name="text">
|
||||
<string>Seed</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReport_bug">
|
||||
<property name="text">
|
||||
<string>Report bug</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDonate_to_Wowlet">
|
||||
<property name="text">
|
||||
<string>Donate to WOWlet</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExport_CSV">
|
||||
<property name="text">
|
||||
<string>Export CSV</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShow_Coins">
|
||||
<property name="text">
|
||||
<string>Show Coins</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShow_xmr_to">
|
||||
<property name="text">
|
||||
<string>Show XMR.to</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShow_calc">
|
||||
<property name="text">
|
||||
<string>Show Calc</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClose">
|
||||
<property name="text">
|
||||
<string>Close current wallet</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionVerifyTxProof">
|
||||
<property name="text">
|
||||
<string>Verify transaction proof</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStore_wallet">
|
||||
<property name="text">
|
||||
<string>Save wallet</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUpdate_balance">
|
||||
<property name="text">
|
||||
<string>Update balance</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRefresh_tabs">
|
||||
<property name="text">
|
||||
<string>Refresh models</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionImportContactsCSV">
|
||||
<property name="text">
|
||||
<string>Import CSV</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExportContactsCSV">
|
||||
<property name="text">
|
||||
<string>Export CSV</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionChange_restore_height">
|
||||
<property name="text">
|
||||
<string>Change restore height</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionKeys">
|
||||
<property name="text">
|
||||
<string>Keys</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreateDesktopEntry">
|
||||
<property name="text">
|
||||
<string>Create desktop entry</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShow_debug_info">
|
||||
<property name="text">
|
||||
<string>Debug info</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreate_view_only_details">
|
||||
<property name="text">
|
||||
<string>Details</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreate_view_only_wallet_file">
|
||||
<property name="text">
|
||||
<string>Export wallet file</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionViewOnly">
|
||||
<property name="text">
|
||||
<string>View-Only</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExport_key_images">
|
||||
<property name="text">
|
||||
<string>Export key images</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionImport_key_images">
|
||||
<property name="text">
|
||||
<string>Import key images</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExport_outputs">
|
||||
<property name="text">
|
||||
<string>Export outputs</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionImport_outputs">
|
||||
<property name="text">
|
||||
<string>Import outputs</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExportKeyImages">
|
||||
<property name="text">
|
||||
<string>Key Images</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionExportOutputs">
|
||||
<property name="text">
|
||||
<string>Outputs</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionImportKeyImages">
|
||||
<property name="text">
|
||||
<string>Key images</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionImportOutputs">
|
||||
<property name="text">
|
||||
<string>Outputs</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShow_XMRig">
|
||||
<property name="text">
|
||||
<string>Show Mining</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionImportTransaction">
|
||||
<property name="text">
|
||||
<string>Transaction</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSubmitTransaction">
|
||||
<property name="text">
|
||||
<string>Submit transaction file</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLoadUnsignedTxFromFile">
|
||||
<property name="text">
|
||||
<string>From file</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLoadSignedTxFromFile">
|
||||
<property name="text">
|
||||
<string>From file</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLoadUnsignedTxFromClipboard">
|
||||
<property name="text">
|
||||
<string>From clipboard</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLoadSignedTxFromText">
|
||||
<property name="text">
|
||||
<string>From text</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionImport_transaction">
|
||||
<property name="text">
|
||||
<string>Import transaction</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRescan_spent">
|
||||
<property name="text">
|
||||
<string>Rescan spent</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShow_Home">
|
||||
<property name="text">
|
||||
<string>Show Home</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionWallet_cache_debug">
|
||||
<property name="text">
|
||||
<string>Wallet cache debug</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPay_to_many">
|
||||
<property name="text">
|
||||
<string>Pay to many</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>QWebEngineView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">QtWebEngineWidgets/QWebEngineView</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="assets.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
<slots>
|
||||
<slot>donateButtonClicked()</slot>
|
||||
<slot>calcButtonClicked()</slot>
|
||||
</slots>
|
||||
</ui>
|
@ -0,0 +1,56 @@
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QCommandLineParser>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "conversations.h"
|
||||
#include "lib/utils.h"
|
||||
#include "lib/globals.h"
|
||||
|
||||
|
||||
Conversations::Conversations(QCommandLineParser *cmdargs) {
|
||||
this->cmdargs = cmdargs;
|
||||
|
||||
// Paths
|
||||
pathGenericData = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
||||
configRoot = QDir::homePath();
|
||||
accountName = Utils::getUnixAccountName();
|
||||
homeDir = QDir::homePath();
|
||||
configDirectory = QString("%1/.config/%2/").arg(configRoot, QCoreApplication::applicationName());
|
||||
|
||||
// Create some directories
|
||||
createConfigDirectory(configDirectory);
|
||||
|
||||
// flags, iso codes, etc
|
||||
countries = new Countries();
|
||||
|
||||
if(this->isDebug) {
|
||||
qDebug() << "configRoot: " << configRoot;
|
||||
qDebug() << "homeDir: " << homeDir;
|
||||
qDebug() << "configDirectory: " << configDirectory;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/q/53018492
|
||||
}
|
||||
|
||||
void Conversations::getMessages(const QString &contact_uid, int limit, int offset) {
|
||||
|
||||
}
|
||||
|
||||
void Conversations::setWindowTitle(const QString &title) {
|
||||
emit setTitle(title);
|
||||
}
|
||||
|
||||
void Conversations::createConfigDirectory(const QString &dir) {
|
||||
QStringList createDirs({dir});
|
||||
for(const auto &d: createDirs) {
|
||||
if(!Utils::dirExists(d)) {
|
||||
qDebug() << QString("Creating directory: %1").arg(d);
|
||||
if (!QDir().mkpath(d))
|
||||
throw std::runtime_error("Could not create directory " + d.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Conversations::~Conversations() {}
|
@ -1,68 +0,0 @@
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// Copyright (c) 2020-2021, The Monero Project.
|
||||
|
||||
#include <QObject>
|
||||
#include <QDir>
|
||||
#include <QMessageBox>
|
||||
#include <QCommandLineParser>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include "ctx.h"
|
||||
#include "lib/utils.h"
|
||||
#include "lib/globals.h"
|
||||
|
||||
|
||||
ConvContext::ConvContext(QCommandLineParser *cmdargs) {
|
||||
this->network = new QNetworkAccessManager();
|
||||
this->cmdargs = cmdargs;
|
||||
|
||||
// Paths
|
||||
pathGenericData = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
||||
configRoot = QDir::homePath();
|
||||
accountName = Utils::getUnixAccountName();
|
||||
homeDir = QDir::homePath();
|
||||
configDirectory = QString("%1/.config/%2/").arg(configRoot, QCoreApplication::applicationName());
|
||||
|
||||
// Create some directories
|
||||
createConfigDirectory(configDirectory);
|
||||
|
||||
qDebug() << "configRoot: " << configRoot;
|
||||
qDebug() << "homeDir: " << homeDir;
|
||||
qDebug() << "configDirectory: " << configDirectory;
|
||||
|
||||
countries = new Countries();
|
||||
|
||||
// If system clock skewed for >= 300 seconds, assume a wake-up from hibernate and reload the websocket connection
|
||||
m_hibernateTimer.start(3 * 1000);
|
||||
|
||||
m_hibernatePreviousTime = std::chrono::steady_clock::now();
|
||||
connect(&m_hibernateTimer, &QTimer::timeout, [this]() {
|
||||
const auto now = std::chrono::steady_clock::now();
|
||||
const auto elapsed = now - m_hibernatePreviousTime;
|
||||
|
||||
if(elapsed >= m_hibernateDetectInterval) {
|
||||
qCritical() << "Clock skew detected";
|
||||
emit clockSkewDetected();
|
||||
}
|
||||
|
||||
m_hibernatePreviousTime = now;
|
||||
});
|
||||
}
|
||||
|
||||
void ConvContext::setWindowTitle(bool mining) {
|
||||
auto title = QString("Conversations");
|
||||
emit setTitle(title);
|
||||
}
|
||||
|
||||
void ConvContext::createConfigDirectory(const QString &dir) {
|
||||
QStringList createDirs({dir});
|
||||
for(const auto &d: createDirs) {
|
||||
if(!Utils::dirExists(d)) {
|
||||
qDebug() << QString("Creating directory: %1").arg(d);
|
||||
if (!QDir().mkpath(d))
|
||||
throw std::runtime_error("Could not create directory " + d.toStdString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ConvContext::~ConvContext() {}
|
Loading…
Reference in new issue