master
dsc 2 years ago
parent 5dc0a776eb
commit cc151341ed

@ -2,7 +2,7 @@
op Maemo:
```
sudo apt install -y cmake build-essential libx11-dev zlib1g-dev libpng-dev qtbase5-dev libqt5svg5-dev qtwebengine5-dev libqt5webchannel5-dev libqt5svg5-dev libqt5maemo5-dev libqt5x11extras5-dev gdb libqt5quickcontrols2-5 qtquickcontrols2-5-dev qml-module-qtquick-controls2 qml-module-qtquick2 qml-module-qtquick-layouts qml-module-qtquick-controls qml-module-qtquick-extras qml-module-qtquick-dialogs libqt5websockets5-dev
sudo apt install -y ccache cmake build-essential libx11-dev zlib1g-dev libpng-dev qtbase5-dev libqt5svg5-dev libqt5svg5-dev libqt5maemo5-dev libqt5x11extras5-dev gdb libqt5quickcontrols2-5 qtquickcontrols2-5-dev qml-module-qtquick-controls2 qml-module-qtquick2 qml-module-qtquick-layouts qml-module-qtquick-controls qml-module-qtquick-extras qml-module-qtquick-dialogs libqt5websockets5-dev libqt5x11extras5-dev qml-module-qtquick-controls qml-module-qtquick-layouts qtquickcontrols2-5-dev
```
Als `user`:

@ -3,11 +3,22 @@
<file>assets/appicon.icns</file>
<file>assets/country-codes.csv</file>
<file>assets/images/video_tab_icon.svg</file>
<file>chatoverview.qml</file>
<file>chat.qml</file>
<file alias="overview.qml">qml/overview.qml</file>
<file alias="chat/default.qml">qml/chat/default.qml</file>
<file alias="chat/whatsapp.qml">qml/chat/whatsapp.qml</file>
<file alias="chat/uwot.qml">qml/chat/uwot.qml</file>
<file alias="avatar.jpg">assets/images/avatar.jpeg</file>
<file alias="wabbit.png">assets/images/wabbit.png</file>
<file alias="wajer.png">assets/images/wajer.png</file>
<file alias="uvos.png">assets/images/uvos.png</file>
<file alias="theme_default.png">assets/images/themes/default.png</file>
<file alias="theme_uwot.png">assets/images/themes/uwot.png</file>
<file alias="uwot-bg.jpg">assets/images/themes/uwot-bg.jpg</file>
<file alias="chat/colors.css">assets/html/chat/colors.css</file>
<file alias="chat/conversation.html">assets/html/chat/SMSConversation.html</file>
<file alias="chat/conversation.css">assets/html/chat/SMSConversation.css</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

@ -34,8 +34,13 @@ ChatWindow::ChatWindow(Conversations *ctx, QWidget *parent) :
// m_webChannel->registerObject(QString("Conversations"), this->m_ctx);
auto *qctx = ui->quick->rootContext();
qctx->setContextProperty("chatModel", m_ctx->chats);
ui->quick->setSource(QUrl("qrc:/chat.qml"));
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);
}

@ -15,6 +15,7 @@
#include <iostream>
#include "conversations.h"
#include "lib/config.h"
#include "models/ChatModel.h"
namespace Ui {

@ -7,11 +7,11 @@
<x>0</x>
<y>0</y>
<width>607</width>
<height>421</height>
<height>431</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -26,7 +26,7 @@
<widget class="QWidget" name="centralWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
<number>12</number>
</property>
<property name="leftMargin">
<number>0</number>
@ -56,10 +56,10 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>6</number>
<number>14</number>
</property>
<property name="rightMargin">
<number>6</number>
<number>14</number>
</property>
<item>
<widget class="QLineEdit" name="chatBox"/>
@ -73,6 +73,22 @@
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>30</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
@ -88,8 +104,4 @@
<include location="assets.qrc"/>
</resources>
<connections/>
<slots>
<slot>donateButtonClicked()</slot>
<slot>calcButtonClicked()</slot>
</slots>
</ui>

@ -12,44 +12,33 @@
Conversations::Conversations(QCommandLineParser *cmdargs) {
this->cmdargs = 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());
// 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);
// Create some directories
createConfigDirectory(configDirectory);
// flags, iso codes, etc
countries = new Countries();
// flags, iso codes, etc
countries = new Countries();
if(this->isDebug) {
qDebug() << "configRoot: " << configRoot;
qDebug() << "homeDir: " << homeDir;
qDebug() << "configDirectory: " << configDirectory;
}
//==
QString date_string_on_db = "20/12/2015 03:05";
QDateTime berfbe = QDateTime::fromString(date_string_on_db,"dd/MM/yyyy hh:mm");
QString weoignweg = berfbe.toString("dd/MM/yyyy hh:mm");
qCritical() << weoignweg;
chats = new ChatModel();
// m_animals->addAnimal(ChatMessage("Wolf", "14:03", "lol message 3"));
// m_animals->addAnimal(ChatMessage("Polar bear", "14:02", "lol message 2"));
// m_animals->addAnimal(ChatMessage("Quoll", "14:01", "lol message 1"));
if(this->isDebug) {
qDebug() << "configRoot: " << configRoot;
qDebug() << "homeDir: " << homeDir;
qDebug() << "configDirectory: " << configDirectory;
}
// https://stackoverflow.com/q/53018492
this->ws = new WSClient(this, "135.125.235.26:7000");
this->ws->start();
chatModel = new ChatModel();
// https://stackoverflow.com/q/53018492
this->ws = new WSClient(this, "135.125.235.26:7000");
this->ws->start();
connect(this->ws, &WSClient::WSMessage, this, &Conversations::onWSMessage);
connect(this->ws, &WSClient::WSMessage, this, &Conversations::onWSMessage);
}
void Conversations::onWSMessage(const QJsonObject &msg) {
@ -61,8 +50,8 @@ void Conversations::onWSMessage(const QJsonObject &msg) {
auto date = obj.value("date").toInt();
auto date_t = QDateTime::fromTime_t(date);
auto chat_obj = ChatMessage(nick, date_t, message);
chats->addMessage(chat_obj);
auto *chat_obj = new ChatMessage(nick, date_t, message);
chatModel->appendMessage(chat_obj);
//qDebug() << nick << " [" << date << "]: " << message;
}
}
@ -71,8 +60,8 @@ void Conversations::onSendMessage(const QString &message) {
auto _msg = message.toUtf8();
auto date_t = QDateTime::currentDateTime();
auto chat_obj = ChatMessage("_self", date_t, _msg);
chats->addMessage(chat_obj);
auto *chat_obj = new ChatMessage("_self", date_t, _msg);
chatModel->appendMessage(chat_obj);
this->ws->sendMsg(_msg);
}
@ -82,18 +71,18 @@ void Conversations::getMessages(const QString &contact_uid, int limit, int offse
}
void Conversations::setWindowTitle(const QString &title) {
emit setTitle(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());
}
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() {}

@ -50,7 +50,7 @@ public:
WSClient *ws;
Countries *countries;
ChatModel *chats;
ChatModel *chatModel;
void setWindowTitle(const QString &title);

@ -14,15 +14,19 @@ struct ConfigDirective
QVariant defaultValue;
};
static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
// General
{Config::MaemoTest,{QS("MaemoTest"), ""}}
static const QHash<ConfigKeys::ConfigKey, ConfigDirective> configStrings = {
// General
{ConfigKeys::MaemoTest,{QS("MaemoTest"), ""}},
{ConfigKeys::ChatTheme,{QS("ChatTheme"), "default"}},
};
QPointer<Config> Config::m_instance(nullptr);
QVariant Config::get(ConfigKey key)
Q_INVOKABLE QVariant Config::get(unsigned int key) {
return this->get(ConfigKeys::ConfigKey(key));
}
QVariant Config::get(ConfigKeys::ConfigKey key)
{
auto cfg = configStrings[key];
auto defaultValue = configStrings[key].defaultValue;
@ -35,7 +39,7 @@ QString Config::getFileName()
return m_settings->fileName();
}
void Config::set(ConfigKey key, const QVariant& value)
void Config::set(ConfigKeys::ConfigKey key, const QVariant& value)
{
if (get(key) == value) {
return;

@ -4,8 +4,20 @@
#include <QObject>
#include <QSettings>
#include <QPointer>
#include <QQmlEngine>
#include <QDir>
namespace ConfigKeys
{
Q_NAMESPACE
enum ConfigKey {
MaemoTest,
ChatTheme,
FooBar
};
Q_ENUM_NS(ConfigKey)
}
class Config : public QObject
{
Q_OBJECT
@ -13,22 +25,18 @@ class Config : public QObject
public:
Q_DISABLE_COPY(Config)
enum ConfigKey
{
MaemoTest,
};
~Config() override;
QVariant get(ConfigKey key);
Q_INVOKABLE QVariant get(unsigned int configKey);
QVariant get(ConfigKeys::ConfigKey key);
QString getFileName();
void set(ConfigKey key, const QVariant& value);
void set(ConfigKeys::ConfigKey key, const QVariant& value);
void sync();
void resetToDefaults();
static Config* instance();
signals:
void changed(ConfigKey key);
void changed(ConfigKeys::ConfigKey key);
private:
Config(const QString& fileName, QObject* parent = nullptr);

@ -15,8 +15,12 @@
int main(int argc, char *argv[]) {
Q_INIT_RESOURCE(assets);
#ifdef MAEMO
Q_INIT_RESOURCE(assets_maemo);
#endif
intl("conversations-ui");
qputenv("QML_DISABLE_DISK_CACHE", "1");
//QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setApplicationName("conversations");
QApplication::setOrganizationDomain("https://maemo-leste.github.io/");
@ -56,8 +60,6 @@ int main(int argc, char *argv[]) {
const QStringList args = parser.positionalArguments();
bool debugMode = parser.isSet(debugModeOption);
if(debugMode)
qputenv("QTWEBENGINE_REMOTE_DEBUGGING", "9000");
parser.process(app);
auto *ctx = new Conversations(&parser);

@ -42,8 +42,22 @@ MainWindow::MainWindow(Conversations *ctx, QWidget *parent) :
connect(m_ctx, &Conversations::setTitle, this, &QMainWindow::setWindowTitle);
//connect(ui->btn, &QPushButton::clicked, this, &MainWindow::bla);
ui->quick->setSource(QUrl("qrc:/chatoverview.qml"));
//ui->quick->rootContext()->set
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);
@ -51,6 +65,11 @@ MainWindow::MainWindow(Conversations *ctx, QWidget *parent) :
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();

@ -16,7 +16,9 @@
#include "conversations.h"
#include "chatwindow.h"
#include "settings.h"
#include "wsclient.h"
#include "lib/config.h"
namespace Ui {
class MainWindow;
@ -29,8 +31,6 @@ public:
explicit MainWindow(Conversations *ctx, QWidget *parent = nullptr);
static MainWindow *getInstance();
static Conversations *getContext();
void openChatWindow(const QString &uid);
~MainWindow() override;
Ui::MainWindow *ui;
@ -45,6 +45,8 @@ signals:
void requestChatWindow(QString uid);
private slots:
void openChatWindow(const QString &uid);
void openSettingsWindow();
void onChatWindowClosed();
void rowClicked(QString uid) {
emit requestChatWindow(uid);
@ -56,6 +58,7 @@ private:
void closeEvent(QCloseEvent *event) override;
void showDebugInfo();
ChatWindow *m_chatWindow = nullptr;
Settings *m_settings = nullptr;
};
#endif

@ -49,6 +49,34 @@
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>607</width>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuw00t">
<property name="title">
<string>w00t</string>
</property>
<addaction name="actionSettings"/>
<addaction name="actionAbout"/>
</widget>
<addaction name="menuw00t"/>
</widget>
<action name="actionSettings">
<property name="text">
<string>Settings</string>
</property>
</action>
<action name="actionAbout">
<property name="text">
<string>About</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
@ -62,8 +90,4 @@
<include location="assets.qrc"/>
</resources>
<connections/>
<slots>
<slot>donateButtonClicked()</slot>
<slot>calcButtonClicked()</slot>
</slots>
</ui>

@ -3,8 +3,7 @@
#include "models/ChatModel.h"
ChatMessage::ChatMessage(const QString &name, const QDateTime &date, const QString &message) :
m_date(date),
ChatMessage::ChatMessage(const QString &name, const QDateTime &date, const QString &message) : m_date(date),
m_message(message) {
if(name == "ferdi" || name == "d4irc") m_name = "_self";
else m_name = name;
@ -12,42 +11,61 @@ ChatMessage::ChatMessage(const QString &name, const QDateTime &date, const QStri
QString ChatMessage::name() const { return m_name; }
QDateTime ChatMessage::date() const { return m_date; }
QString ChatMessage::hourstr() const {
return m_date.toString("hh:mm");
QString ChatMessage::hourstr() const { return m_date.toString("hh:mm"); }
QString ChatMessage::datestr() const { return m_date.toString("dd/MM/yyyy"); }
QString ChatMessage::message() const { return m_message; }
bool ChatMessage::isHead() const {
if(previous == nullptr) return true;
if(previous->name() == m_name) return false;
return true;
}
QString ChatMessage::datestr() const {
return m_date.toString("dd/MM/yyyy");
bool ChatMessage::isLast() const {
if(previous == nullptr || next == nullptr) return false;
if(previous->name() == m_name && next->name() != m_name) {
return true;
}
return false;
}
QString ChatMessage::message() const { return m_message; }
ChatModel::ChatModel(QObject *parent)
: QAbstractListModel(parent) {
}
void ChatModel::addMessage(const ChatMessage &message) {
beginInsertRows(QModelIndex(), rowCount(), rowCount());
m_chats << message;
void ChatModel::appendMessage(ChatMessage *message) {
int idx = rowCount();
if(idx != 0 && !chats.isEmpty()) {
auto *prev = chats.at(idx - 1);
prev->next = message;
message->previous = prev;
}
beginInsertRows(QModelIndex(), idx, rowCount());
chats << message;
endInsertRows();
}
int ChatModel::rowCount(const QModelIndex & parent) const {
Q_UNUSED(parent);
return m_chats.count();
return chats.count();
}
QVariant ChatModel::data(const QModelIndex &index, int role) const {
if (index.row() < 0 || index.row() >= m_chats.count())
if (index.row() < 0 || index.row() >= chats.count())
return QVariant();
const ChatMessage &animal = m_chats[index.row()];
const ChatMessage *message = chats[index.row()];
if (role == NameRole)
return animal.name();
return message->name();
else if (role == DateRole)
return animal.datestr();
return message->datestr();
else if (role == HourRole)
return animal.hourstr();
return message->hourstr();
else if (role == MessageRole)
return animal.message();
return message->message();
else if (role == isHeadRole)
return message->isHead();
else if (role == isLastRole)
return message->isLast();
return QVariant();
}
@ -57,5 +75,7 @@ QHash<int, QByteArray> ChatModel::roleNames() const {
roles[DateRole] = "datestr";
roles[HourRole] = "hourstr";
roles[MessageRole] = "message";
roles[isHeadRole] = "isHead";
roles[isLastRole] = "isLast";
return roles;
}

@ -14,6 +14,11 @@ public:
QString message() const;
QString datestr() const;
QString hourstr() const;
bool isHead() const;
bool isLast() const;
ChatMessage *previous = nullptr;
ChatMessage *next = nullptr;
private:
QString m_name;
@ -28,24 +33,25 @@ class ChatModel : public QAbstractListModel
{
Q_OBJECT
public:
enum AnimalRoles {
enum ChatModelRoles {
NameRole = Qt::UserRole + 1,
DateRole,
HourRole,
MessageRole
MessageRole,
isHeadRole,
isLastRole
};
ChatModel(QObject *parent = nullptr);
void addMessage(const ChatMessage &message);
void appendMessage(ChatMessage *message);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QList<ChatMessage*> chats;
protected:
QHash<int, QByteArray> roleNames() const;
private:
QList<ChatMessage> m_chats;
};
#endif

@ -3,13 +3,15 @@ import QtQuick.Controls 2.3
import QtQuick.Layouts 1.0
Rectangle {
id: appWindow
id: root
visible: true
color: "black"
property int itemHeight: 68;
property string avatarBorderColor: "#999999"
property string chatBorderColor: "#30302f"
property string nickColor: "#86d5fc"
property string dividerColor: "#2c2c2c"
property int itemHeightDefault: 68
property int itemHeightSmall: 32
ListView {
id: chatListView
@ -26,8 +28,10 @@ Rectangle {
}
delegate: Rectangle {
property int itemHeight: isHead ? root.itemHeightDefault : root.itemHeightSmall;
height: {
var dynamic_height = textChatMessage.implicitHeight + 4;
var implicit = isHead ? textChatMessage.implicitHeight : textChatMessage2.implicitHeight;
var dynamic_height = implicit + 4;
if(dynamic_height > itemHeight) return dynamic_height;
return itemHeight;
}
@ -40,23 +44,24 @@ Rectangle {
Rectangle {
Layout.alignment: Qt.AlignVCenter
color: avatarBorderColor
Layout.preferredWidth: itemHeight
color: "transparent"
Layout.preferredWidth: itemHeightDefault
Layout.minimumHeight: itemHeight
Image {
width: itemHeight - 2
height: itemHeight - 2
visible: isHead
width: root.itemHeightDefault - 4
height: root.itemHeightDefault - 4
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
id: imgStatus
source: {
if(name == "_self") return "qrc:///avatar.jpg"
else if(name == "Wizzup") return "qrc:///wajer.png"
else if(name == "uvos") return "qrc:///uvos.png"
return "qrc:///wabbit.png"
}
smooth: true
visible: true
}
}
@ -75,6 +80,7 @@ Rectangle {
Layout.minimumWidth: chatListView.nickWidth
textFormat: Text.PlainText
text: {
if(!isHead) return "";
if(name == "_self") return "d4irc";
return name
}
@ -89,15 +95,46 @@ Rectangle {
Text {
id: textChatMessage
visible: isHead
Layout.fillWidth: true
Layout.leftMargin: 8
Layout.alignment: Qt.AlignVCenter
Layout.alignment: isHead ? Qt.AlignVCenter : Qt.AlignTop
textFormat: Text.PlainText
text: message
color: "white"
wrapMode: Text.WordWrap
font.pointSize: 14
font.bold: name == "dsc" ? true : false;
font.bold: name == "_self" ? true : false;
}
ColumnLayout {
id: textChatMessage2
spacing: 6
Layout.fillWidth: true
Layout.leftMargin: 8
visible: !isHead
Text {
Layout.fillWidth: true
textFormat: Text.PlainText
text: message
color: "white"
wrapMode: Text.WordWrap
font.pointSize: 14
font.bold: name == "_self" ? true : false;
}
Rectangle {
Layout.fillWidth: true
Layout.preferredHeight: 1
visible: !isHead && !isLast
color: root.dividerColor
}
Item {
Layout.fillHeight: true
Layout.fillWidth: true
}
}
Item {

@ -0,0 +1,125 @@
import QtQuick 2.0
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.0
Rectangle {
id: root
visible: true
color: "grey"
property string chatBackgroundSelf: "#056162"
property string chatBackgroundThem: "#262d31"
property int itemHeightDefault: 68
property int itemHeightSmall: 32
Image {
source: "qrc:/uwot-bg.jpg"
anchors.fill: parent
}
ListModel {
id: xxx
ListElement {
name: "Wizzup"
datestr: "11:44 pm"
message: "I made this thing"
isHead: true
isLast: false
}
ListElement {
name: "Wizzup"
datestr: "11:44 pm"
message: "it kinda works"
isHead: false
isLast: false
}
ListElement {
name: "Wizzup"
datestr: "11:44 pm"
message: "you should look at it"
isHead: false
isLast: false
}
ListElement {
datestr: "11:32 pm"
name: "dsc"
message: "Yeah, that works pretty well!"
isHead: true
isLast: false
}
ListElement {
datestr: "10:04 pm"
name: "Wizzup"
message: "Agree, but here is a long line, you should wrap this! Please fix this ASAP when you have time!"
status: "sent"
isHead: true
isLast: false
}
ListElement {
datestr: "10:02 pm"
name: "dsc"
message: "Bla bla bla :D"
status: "read"
isHead: true
isLast: false
}
ListElement {
datestr: "10:02 pm"
name: "wtf"
message: "Noooooooo"
status: "read"
isHead: true
isLast: false
}
}
ListView {
id: chatListView
anchors.fill: parent
anchors.topMargin: 10
anchors.leftMargin: 20
anchors.rightMargin: 20
model: xxx
delegate: Rectangle {
color: "transparent"
height: 48
width: parent.width
RowLayout {
height: 32
width: parent.width
spacing: 0
Item {
visible: name == "dsc"
Layout.fillWidth: true
Layout.preferredHeight: 32
}
Rectangle {
Layout.minimumHeight: 32
Layout.fillWidth: true
color: name == "dsc" ? root.chatBackgroundSelf : root.chatBackgroundThem
Text {
text: message
color: "white"
Layout.alignment: Qt.AlignVCenter
Layout.fillHeight: true
Layout.fillWidth: true
textFormat: Text.PlainText
wrapMode: Text.WordWrap
font.pointSize: 18
}
}
Item {
visible: name != "dsc"
Layout.fillWidth: true
Layout.preferredHeight: 48
}
}
}
}
}

@ -1,6 +1,7 @@
import QtQuick 2.0
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.0
import MaemoConfig 1.0
Rectangle {
id: appWindow
@ -154,7 +155,11 @@ Rectangle {
Layout.preferredHeight: itemHeight / 2
Text {
text: name
text: {
//return cfg.get(Config.MaemoTest);
return "yay"
}
textFormat: Text.PlainText
color: "white"
font.pointSize: 18

@ -0,0 +1,63 @@
#include <QPixmap>
#include <QMessageBox>
#include <QDesktopServices>
#include <QCoreApplication>
#include <QSystemTrayIcon>
#include <QQmlContext>
#include <QMessageBox>
#include <QGroupBox>
#include <QFileDialog>
#include "settings.h"
#include "config-conversations.h"
#include "lib/globals.h"
#include "ui_settings.h"
Settings * Settings::pSettings = nullptr;
Settings::Settings(Conversations *ctx, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Settings),
m_ctx(ctx) {
pSettings = this;
ui->setupUi(this);
#ifdef MAEMO
setProperty("X-Maemo-StackedWindow", 1);
#endif
QPixmap p_theme_default(":theme_default.png");
QPixmap p_theme_uwot(":theme_uwot.png");
ui->label_default_img->setPixmap(p_theme_default);
ui->label_uwot_img->setPixmap(p_theme_uwot);
auto theme = config()->get(ConfigKeys::ChatTheme).toString();
if(theme == "uwot")
ui->radio_theme_uwot->setChecked(true);
else
ui->radio_theme_default->setChecked(true);
connect(ui->themeRadioGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked), [=](QAbstractButton *button) {
auto name = button->objectName();
if(name == "radio_theme_default") {
config()->set(ConfigKeys::ChatTheme, "default");
} else if(name == "radio_theme_uwot") {
config()->set(ConfigKeys::ChatTheme, "uwot");
}
});
//connect(this->ui->btnSend, &QPushButton::clicked, this, &Settings::onGatherMessage);
}
Conversations *Settings::getContext(){
return pSettings->m_ctx;
}
void Settings::closeEvent(QCloseEvent *event) {
QWidget::closeEvent(event);
}
Settings::~Settings() {
delete ui;
}

@ -0,0 +1,42 @@
#ifndef SETTINGSWINDOW_H
#define SETTINGSWINDOW_H
#include <QtGlobal>
#include <QResource>
#include <QApplication>
#include <QScreen>
#include <QtWidgets/QMenu>
#include <QMainWindow>
#include <QObject>
#include <QtCore>
#include <QtGui>
#include <QFileInfo>
#include <iostream>
#include "conversations.h"
#include "lib/config.h"
namespace Ui {
class Settings;
}
class Settings : public QMainWindow {
Q_OBJECT
public:
explicit Settings(Conversations *ctx, QWidget *parent = nullptr);
static Conversations *getContext();
~Settings() override;
Ui::Settings *ui;
signals:
void lol(const QString &message);
private:
Conversations *m_ctx;
static Settings *pSettings;
void closeEvent(QCloseEvent *event) override;
};
#endif

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Settings</class>
<widget class="QMainWindow" name="Settings">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>716</width>
<height>654</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Settings</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_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Chat theme</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_default_img">
<property name="text">
<string>default_img</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_theme_default">
<property name="text">
<string>Default</string>
</property>
<attribute name="buttonGroup">
<string notr="true">themeRadioGroup</string>
</attribute>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label_uwot_img">
<property name="text">
<string>uwot_img</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_theme_uwot">
<property name="text">
<string>uwot</string>
</property>
<attribute name="buttonGroup">
<string notr="true">themeRadioGroup</string>
</attribute>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="assets.qrc"/>
</resources>
<connections/>
<buttongroups>
<buttongroup name="themeRadioGroup"/>
</buttongroups>
</ui>
Loading…
Cancel
Save