diff --git a/README.md b/README.md index 2a9ba8f..e216fca 100644 --- a/README.md +++ b/README.md @@ -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`: diff --git a/src/assets.qrc b/src/assets.qrc index 8cf2d4a..080a833 100644 --- a/src/assets.qrc +++ b/src/assets.qrc @@ -3,11 +3,22 @@ assets/appicon.icns assets/country-codes.csv assets/images/video_tab_icon.svg - chatoverview.qml - chat.qml + + qml/overview.qml + qml/chat/default.qml + qml/chat/whatsapp.qml + qml/chat/uwot.qml + assets/images/avatar.jpeg assets/images/wabbit.png assets/images/wajer.png + assets/images/uvos.png + + assets/images/themes/default.png + assets/images/themes/uwot.png + + assets/images/themes/uwot-bg.jpg + assets/html/chat/colors.css assets/html/chat/SMSConversation.html assets/html/chat/SMSConversation.css diff --git a/src/assets/images/themes/default.png b/src/assets/images/themes/default.png new file mode 100644 index 0000000..6119970 Binary files /dev/null and b/src/assets/images/themes/default.png differ diff --git a/src/assets/images/themes/uwot-bg.jpg b/src/assets/images/themes/uwot-bg.jpg new file mode 100644 index 0000000..1d82293 Binary files /dev/null and b/src/assets/images/themes/uwot-bg.jpg differ diff --git a/src/assets/images/themes/uwot.png b/src/assets/images/themes/uwot.png new file mode 100644 index 0000000..195afd9 Binary files /dev/null and b/src/assets/images/themes/uwot.png differ diff --git a/src/assets/images/uvos.png b/src/assets/images/uvos.png new file mode 100644 index 0000000..4b42e94 Binary files /dev/null and b/src/assets/images/uvos.png differ diff --git a/src/chatwindow.cpp b/src/chatwindow.cpp index 938b14c..d51e474 100644 --- a/src/chatwindow.cpp +++ b/src/chatwindow.cpp @@ -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); } diff --git a/src/chatwindow.h b/src/chatwindow.h index 1aa3da7..527b380 100644 --- a/src/chatwindow.h +++ b/src/chatwindow.h @@ -15,6 +15,7 @@ #include #include "conversations.h" +#include "lib/config.h" #include "models/ChatModel.h" namespace Ui { diff --git a/src/chatwindow.ui b/src/chatwindow.ui index 55a05b7..7a282a4 100644 --- a/src/chatwindow.ui +++ b/src/chatwindow.ui @@ -7,11 +7,11 @@ 0 0 607 - 421 + 431 - + 0 0 @@ -26,7 +26,7 @@ - 6 + 12 0 @@ -56,10 +56,10 @@ - 6 + 14 - 6 + 14 @@ -73,6 +73,22 @@ + + + + Qt::Vertical + + + QSizePolicy::Maximum + + + + 20 + 30 + + + + @@ -88,8 +104,4 @@ - - donateButtonClicked() - calcButtonClicked() - diff --git a/src/conversations.cpp b/src/conversations.cpp index d5a5862..7893d4f 100644 --- a/src/conversations.cpp +++ b/src/conversations.cpp @@ -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() {} diff --git a/src/conversations.h b/src/conversations.h index d59b10b..44356b0 100644 --- a/src/conversations.h +++ b/src/conversations.h @@ -50,7 +50,7 @@ public: WSClient *ws; Countries *countries; - ChatModel *chats; + ChatModel *chatModel; void setWindowTitle(const QString &title); diff --git a/src/lib/config.cpp b/src/lib/config.cpp index e5ac1a7..036d92d 100644 --- a/src/lib/config.cpp +++ b/src/lib/config.cpp @@ -14,15 +14,19 @@ struct ConfigDirective QVariant defaultValue; }; -static const QHash configStrings = { - // General - {Config::MaemoTest,{QS("MaemoTest"), ""}} +static const QHash configStrings = { + // General + {ConfigKeys::MaemoTest,{QS("MaemoTest"), ""}}, + {ConfigKeys::ChatTheme,{QS("ChatTheme"), "default"}}, }; - QPointer 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; diff --git a/src/lib/config.h b/src/lib/config.h index 47a05a6..5b135d0 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -4,8 +4,20 @@ #include #include #include +#include #include +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); diff --git a/src/main.cpp b/src/main.cpp index bf33624..5297e1b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index ed57555..f3d386b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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("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(); diff --git a/src/mainwindow.h b/src/mainwindow.h index a0e9adb..2c58e75 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -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 \ No newline at end of file diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 788d940..2705b21 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -49,6 +49,34 @@ + + + + 0 + 0 + 607 + 22 + + + + + w00t + + + + + + + + + Settings + + + + + About + + @@ -62,8 +90,4 @@ - - donateButtonClicked() - calcButtonClicked() - diff --git a/src/models/ChatModel.cpp b/src/models/ChatModel.cpp index 3459098..f50f757 100644 --- a/src/models/ChatModel.cpp +++ b/src/models/ChatModel.cpp @@ -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 ChatModel::roleNames() const { roles[DateRole] = "datestr"; roles[HourRole] = "hourstr"; roles[MessageRole] = "message"; + roles[isHeadRole] = "isHead"; + roles[isLastRole] = "isLast"; return roles; } diff --git a/src/models/ChatModel.h b/src/models/ChatModel.h index 86f0f92..851757c 100644 --- a/src/models/ChatModel.h +++ b/src/models/ChatModel.h @@ -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 chats; + protected: QHash roleNames() const; - -private: - QList m_chats; }; #endif diff --git a/src/chat.qml b/src/qml/chat/default.qml similarity index 62% rename from src/chat.qml rename to src/qml/chat/default.qml index 31469af..3a97d0c 100644 --- a/src/chat.qml +++ b/src/qml/chat/default.qml @@ -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 { diff --git a/src/qml/chat/uwot.qml b/src/qml/chat/uwot.qml new file mode 100644 index 0000000..d1db4fa --- /dev/null +++ b/src/qml/chat/uwot.qml @@ -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 + } + } + + } + } +} diff --git a/src/chatoverview.qml b/src/qml/overview.qml similarity index 97% rename from src/chatoverview.qml rename to src/qml/overview.qml index 29ce949..edefd4c 100644 --- a/src/chatoverview.qml +++ b/src/qml/overview.qml @@ -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 diff --git a/src/settings.cpp b/src/settings.cpp new file mode 100644 index 0000000..cf0bf40 --- /dev/null +++ b/src/settings.cpp @@ -0,0 +1,63 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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::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; +} diff --git a/src/settings.h b/src/settings.h new file mode 100644 index 0000000..db4f43b --- /dev/null +++ b/src/settings.h @@ -0,0 +1,42 @@ +#ifndef SETTINGSWINDOW_H +#define SETTINGSWINDOW_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#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 diff --git a/src/settings.ui b/src/settings.ui new file mode 100644 index 0000000..c9abeb4 --- /dev/null +++ b/src/settings.ui @@ -0,0 +1,118 @@ + + + Settings + + + + 0 + 0 + 716 + 654 + + + + + 0 + 0 + + + + Settings + + + + :/assets/images/appicons/64x64.png:/assets/images/appicons/64x64.png + + + + + + + Chat theme + + + + + + + + + + + default_img + + + + + + + Default + + + themeRadioGroup + + + + + + + + + + + uwot_img + + + + + + + uwot + + + themeRadioGroup + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + +