diff --git a/plugins/aspeller/aspeller.qbs b/plugins/aspeller/aspeller.qbs index 97f0e13f8..fef9dca87 100644 --- a/plugins/aspeller/aspeller.qbs +++ b/plugins/aspeller/aspeller.qbs @@ -2,6 +2,9 @@ import "../UreenPlugin.qbs" as UreenPlugin UreenPlugin { pluginTags: 'linux' - Depends { name: "aspell" } + cpp.dynamicLibraries: ["aspell"] + condition: qbs.targetOS.contains("linux") + + //Depends { name: "aspell" } // condition: aspell.found // Doesn't work for now } diff --git a/plugins/aspeller/src/aspellchecker.cpp b/plugins/aspeller/src/aspellchecker.cpp index 589e5af5a..3f48058de 100644 --- a/plugins/aspeller/src/aspellchecker.cpp +++ b/plugins/aspeller/src/aspellchecker.cpp @@ -185,7 +185,7 @@ void ASpellChecker::loadSettings(const QString &lang) AspellCanHaveError * possible_err = new_aspell_speller(m_config); if (aspell_error_number(possible_err) != 0) { - warning()<< "Error : "<< aspell_error_message(possible_err); + qWarning() << "Error : " << aspell_error_message(possible_err); } else { m_speller = to_aspell_speller(possible_err); } diff --git a/plugins/aspeller/src/aspellplugin.h b/plugins/aspeller/src/aspellplugin.h index a871ccfe9..8ac50edff 100644 --- a/plugins/aspeller/src/aspellplugin.h +++ b/plugins/aspeller/src/aspellplugin.h @@ -32,7 +32,10 @@ using namespace qutim_sdk_0_3; class ASpellPlugin : public Plugin { -Q_OBJECT + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qutim.Plugin") + Q_CLASSINFO("DebugName", "ASpell") + Q_CLASSINFO("Uses", "ChatLayer") public: explicit ASpellPlugin(); virtual void init(); diff --git a/plugins/blogimprover/src/blogimproverhandler.cpp b/plugins/blogimprover/src/blogimproverhandler.cpp index 052dcfab6..7fd28d099 100644 --- a/plugins/blogimprover/src/blogimproverhandler.cpp +++ b/plugins/blogimprover/src/blogimproverhandler.cpp @@ -61,7 +61,10 @@ void BlogImproverHandler::loadSettings() MessageHandlerAsyncResult BlogImproverHandler::doHandle(Message &message) { - if (message.isIncoming()) + qutim_sdk_0_3::MessageHandler::traceHandlers(); + + + if (!message.isIncoming()) return makeAsyncResult(Accept, QString()); ChatSession *session = ChatLayer::get(message.chatUnit(), false); diff --git a/plugins/hunspeller/hunspeller.qbs b/plugins/hunspeller/hunspeller.qbs index 9e2dcc6a7..d4bcbe282 100644 --- a/plugins/hunspeller/hunspeller.qbs +++ b/plugins/hunspeller/hunspeller.qbs @@ -2,5 +2,6 @@ import "../UreenPlugin.qbs" as UreenPlugin UreenPlugin { pluginTags: 'linux' - Depends { name: "hunspell" } + cpp.dynamicLibraries: ["hunspell"] + condition: qbs.targetOS.contains("linux") } diff --git a/plugins/hunspeller/src/hunspellchecker.cpp b/plugins/hunspeller/src/hunspellchecker.cpp index 29c4db698..9bcfbda2f 100644 --- a/plugins/hunspeller/src/hunspellchecker.cpp +++ b/plugins/hunspeller/src/hunspellchecker.cpp @@ -93,7 +93,7 @@ void HunSpellChecker::storeReplacement(const QString &bad, const QString &good) { Q_UNUSED(bad); Q_UNUSED(good); - debug() << "HunSpellChecker::storeReplacement not implemented"; + qDebug() << "HunSpellChecker::storeReplacement not implemented"; } QStringList HunSpellChecker::languages() const diff --git a/plugins/hunspeller/src/hunspellplugin.h b/plugins/hunspeller/src/hunspellplugin.h index 2bf554bcc..938b2766a 100644 --- a/plugins/hunspeller/src/hunspellplugin.h +++ b/plugins/hunspeller/src/hunspellplugin.h @@ -32,7 +32,10 @@ using namespace qutim_sdk_0_3; class HunSpellPlugin : public Plugin { -Q_OBJECT + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qutim.Plugin") + Q_CLASSINFO("DebugName", "HunSpell") + Q_CLASSINFO("Uses", "ChatLayer") public: explicit HunSpellPlugin(); virtual void init(); diff --git a/plugins/metamenu/metamenu.qbs b/plugins/metamenu/metamenu.qbs new file mode 100644 index 000000000..7525ae9a4 --- /dev/null +++ b/plugins/metamenu/metamenu.qbs @@ -0,0 +1,5 @@ +import "../UreenPlugin.qbs" as UreenPlugin + +UreenPlugin { + condition: qbs.getenv("XDG_CURRENT_DESKTOP") === "Unity" +} diff --git a/plugins/metamenu/src/metamenu.cpp b/plugins/metamenu/src/metamenu.cpp new file mode 100644 index 000000000..24b6a880a --- /dev/null +++ b/plugins/metamenu/src/metamenu.cpp @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** qutIM - instant messenger +** +** Copyright © 2014 Nicolay Izoderov +** Copyright © 2014 Ivan Vizir +** +***************************************************************************** +** +** $QUTIM_BEGIN_LICENSE$ +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +** See the GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see http://www.gnu.org/licenses/. +** $QUTIM_END_LICENSE$ +** +****************************************************************************/ + +#include "metamenu.h" +#include +#include +#include +#include +#include + +MetamenuPlugin::MetamenuPlugin () +{ +} + +void MetamenuPlugin::init () +{ + qutim_sdk_0_3::ExtensionIcon icon("info"); + addAuthor(QLatin1String("nicoizo")); + setInfo(QT_TRANSLATE_NOOP("Plugin", "MetaMenu"), + QT_TRANSLATE_NOOP("Plugin", "Ubuntu metamenu integration"), + PLUGIN_VERSION(0, 0, 1, 1), + icon + ); + setCapabilities(Loadable); +} + +bool MetamenuPlugin::load () +{ + QTimer::singleShot(2000, this, SLOT(shot())); + m_menu = new MetaMenuController(this); + return true; +} + +bool MetamenuPlugin::unload () +{ + return true; +} + +/*! + * \brief MetamenuPlugin::oneOfChatWindows + * \author viv + * \return QMainWindow + */ +QWidget* MetamenuPlugin::oneOfChatWindows() +{ + QObject* obj = ServiceManager::getByName("ChatForm"); + QWidget *widget = 0; + bool metZero = false; + QWidgetList list; + QMetaObject::invokeMethod(obj, "chatWidgets", Q_RETURN_ARG(QWidgetList, list)); + if(!list.size()) + return 0; + foreach (QWidget *w, list) + if (w) { + widget = w->window(); + break; + } else + metZero = true; + if (metZero) // TODO: this block should dissapear sometimes as well as variables used here + qWarning() << "Zeros still appear in ChatForm's chatWidgets list."; + return widget; +} + +void MetamenuPlugin::shot() { + QWidget* window = oneOfChatWindows(); + + if(!m_menuBar && window) + QMetaObject::invokeMethod(window, "getMenuBar", Q_RETURN_ARG(QMenuBar*, m_menuBar)); + + QMenu* mainMenu = m_menu->menu(false); + + mainMenu->setTitle("&qutIM"); + + if(m_menuBar && !m_added) { + qDebug() << mainMenu; + m_menuBar->addMenu(mainMenu); + m_added = true; + } + + if(!m_added) + QTimer::singleShot(1000, this, SLOT(shot())); + else + connect(window, SIGNAL(destroyed()), this, SLOT(onDestroyed())); +} + +void MetamenuPlugin::onDestroyed() +{ + m_added = false; + m_menuBar = 0; + delete m_menu; + m_menu = new MetaMenuController(this); + QTimer::singleShot(1000, this, SLOT(shot())); +} + + + +QUTIM_EXPORT_PLUGIN(MetamenuPlugin) diff --git a/plugins/metamenu/src/metamenu.h b/plugins/metamenu/src/metamenu.h new file mode 100644 index 000000000..da589c537 --- /dev/null +++ b/plugins/metamenu/src/metamenu.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** qutIM - instant messenger +** +** Copyright © 2014 Nicolay Izoderov +** +***************************************************************************** +** +** $QUTIM_BEGIN_LICENSE$ +** This program is free software: you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation, either version 3 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +** See the GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program. If not, see http://www.gnu.org/licenses/. +** $QUTIM_END_LICENSE$ +** +****************************************************************************/ + +#ifndef METAMENU_METAMENU_H +#define METAMENU_METAMENU_H + +#include +#include +#include +#include +#include + +using namespace qutim_sdk_0_3; + +class MetaMenuController : public MenuController +{ + Q_OBJECT +public: + MetaMenuController(QObject *parent) : MenuController(parent) + { + if (MenuController *contactList = ServiceManager::getByName("ContactList")) + setMenuOwner(contactList); + } +}; + +class MetamenuPlugin : public qutim_sdk_0_3::Plugin +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qutim.Plugin") + Q_CLASSINFO("DebugName", "Metamenu") + Q_CLASSINFO("Uses", "ChatLayer") +public: + explicit MetamenuPlugin (); + virtual void init(); + virtual bool load(); + virtual bool unload(); +public slots: + void shot(); + void onDestroyed(); +private: + QWidget* oneOfChatWindows(); + QMenuBar* m_menuBar = 0; + MenuController* m_menu; + bool m_added = false; +}; + +#endif /* end of include guard: METAMENU_METAMENU_H */ + diff --git a/plugins/plugins.qbs b/plugins/plugins.qbs index 8bea04ca7..ca8b2ce2b 100755 --- a/plugins/plugins.qbs +++ b/plugins/plugins.qbs @@ -35,7 +35,10 @@ Project { "quickcontactlist/quickcontactlist.qbs", "indicator/indicator.qbs", "winintegration/winintegration.qbs", + "metamenu/metamenu.qbs", + "aspeller/aspeller.qbs", + "hunspeller/hunspeller.qbs", "keychain/keychain.qbs", - "quickchat/quickchat.qbs", + "quickchat/quickchat.qbs" ] } diff --git a/plugins/quickchat/qml/chatstyle/gajim/ActionMessage.qml b/plugins/quickchat/qml/chatstyle/gajim/ActionMessage.qml new file mode 100644 index 000000000..5ef01f37c --- /dev/null +++ b/plugins/quickchat/qml/chatstyle/gajim/ActionMessage.qml @@ -0,0 +1,82 @@ +import QtQuick 2.3 +import org.qutim 0.4 +import org.qutim.quickchat 0.4 +import "../default" as Default + + +MessageBase { + id: root + height: messageItem.height + + readonly property var message: messages[0] + + Default.SelectableText { + id: messageItem + anchors { + top: parent.top + left: parent.left + margins: 4 + } + renderType: Text.NativeRendering + textFormat: Text.RichText + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + + + + readonly property string timeText: Qt.formatDateTime(message.time, '[hh:mm:ss]') + readonly property string timeColor: { + var incoming = message.incoming; + var success = messageReceipts[message.id]; + var history = message.property("history", false); + var color = undefined; + if (history) + color = "gray"; + else if (incoming || success === true) + color = "black"; + else if (success === false) + color = "red"; + else + color = "orange"; + return color; + } + + readonly property string timeHtml: "" + timeText + ""; + + + property variant nickColorsArray: ["#4e9a06", "#f57900", "#ce5c00", "#3465a4", "#204a87", "#75507b", "#5c3566", "#c17d11", "#8f5902", "#ef2929", "#cc0000", "#a40000"] + readonly property string incomingNickColor: { + return nickColorsArray[root.session.hashOf(nick, nickColorsArray.length)]; + } + readonly property string nick: message.unitData.title + readonly property url appendNickUrl: session.appendNickUrl(nick) + "#do-not-style" + readonly property string nickHtml: { + return "" + + session.htmlEscape(nick) + ""; + } + + readonly property string fontWeight: { + return message.property("mention", false) ? "bold" : "normal"; + } + + readonly property string nickColor: message.incoming ? incomingNickColor : "#437ee0" + + readonly property string messageFormattedHtml: "" + message.formattedHtml().substr(4) + ""; + readonly property string messageColor: { + return nickColor + } + + text: timeHtml + " " + nickHtml + " " + messageFormattedHtml + + property AnchorsHighlighter highlighter: AnchorsHighlighter { + Component.onCompleted: { + // TextEdit.textDocument is non-notifyable property + textDocument = messageItem.textDocument; + hoverColor = "#07A"; + activeColor = "#09C"; + } + } + } + + +} diff --git a/plugins/quickchat/qml/chatstyle/gajim/Message.qml b/plugins/quickchat/qml/chatstyle/gajim/Message.qml new file mode 100644 index 000000000..f3d7a15c1 --- /dev/null +++ b/plugins/quickchat/qml/chatstyle/gajim/Message.qml @@ -0,0 +1,78 @@ +import QtQuick 2.3 +import org.qutim 0.4 +import org.qutim.quickchat 0.4 +import "../default" as Default + +MessageBase { + id: root + height: messageItem.height + + readonly property var message: messages[0] + + Default.SelectableText { + id: messageItem + anchors { + top: parent.top + left: parent.left + margins: 4 + } + renderType: Text.NativeRendering + textFormat: Text.RichText + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + + readonly property string timeText: Qt.formatDateTime(message.time, '[hh:mm:ss]') + readonly property string timeColor: { + var incoming = message.incoming; + var success = messageReceipts[message.id]; + var history = message.property("history", false); + var color = undefined; + if (history) + color = "gray"; + else if (incoming || success === true) + color = "black"; + else if (success === false) + color = "red"; + else + color = "orange"; + return color; + } + + readonly property string timeHtml: "" + timeText + ""; + + + property variant nickColorsArray: ["#4e9a06", "#f57900", "#ce5c00", "#3465a4", "#204a87", "#75507b", "#5c3566", "#c17d11", "#8f5902", "#ef2929", "#cc0000", "#a40000"] + readonly property string incomingNickColor: { + return nickColorsArray[root.session.hashOf(nick, nickColorsArray.length)]; + } + readonly property string nick: message.unitData.title + readonly property url appendNickUrl: session.appendNickUrl(nick) + "#do-not-style" + readonly property string nickHtml: { + return "" + + session.htmlEscape(nick) + ":"; + } + + readonly property string fontWeight: { + return message.property("mention", false) ? "bold" : "normal"; + } + + readonly property string nickColor: message.incoming ? incomingNickColor : "#437ee0" + + readonly property string messageFormattedHtml: "" + message.formattedHtml() + ""; + readonly property string messageColor: { + return message.property("mention", false) ? "#ff8482": "black" + } + + text: timeHtml + " " + nickHtml + " " + messageFormattedHtml + + property AnchorsHighlighter highlighter: AnchorsHighlighter { + Component.onCompleted: { + textDocument = messageItem.textDocument; + hoverColor = "#07A"; + activeColor = "#09C"; + } + } + } + + +} diff --git a/plugins/quickchat/qml/chatstyle/gajim/MessageBase.qml b/plugins/quickchat/qml/chatstyle/gajim/MessageBase.qml new file mode 100644 index 000000000..8833adffe --- /dev/null +++ b/plugins/quickchat/qml/chatstyle/gajim/MessageBase.qml @@ -0,0 +1,20 @@ +import QtQuick 2.3 +import org.qutim 0.4 +import org.qutim.quickchat 0.4 + +Item { + id: root + + property var messages + property var messageReceipts: { return {}; } + property QtObject session + + function handleReceipt(id, success) { + var newMessageReceipts = {}; + for (var i in messageReceipts) + newMessageReceipts[i] = messageReceipts[i]; + newMessageReceipts[id] = success; + + messageReceipts = newMessageReceipts; + } +} diff --git a/plugins/quickchat/qml/chatstyle/gajim/QuickMessagesLayout.qml b/plugins/quickchat/qml/chatstyle/gajim/QuickMessagesLayout.qml new file mode 100644 index 000000000..15537e084 --- /dev/null +++ b/plugins/quickchat/qml/chatstyle/gajim/QuickMessagesLayout.qml @@ -0,0 +1,167 @@ +import QtQuick 2.3 +import org.qutim.quickchat 0.4 + +Item { + id: root + + property Component messageComponent + property Component actionComponent + property Component serviceComponent + property QtObject session + property var items: [] + property var itemMessages: [] + property var messageReceiptes: { return {}; } + property var itemById: { return {}; } + property SelectableMouseArea __selectableMouseArea: mouseArea + property bool doNotRelayout: false + property bool hoverEnabled: mouseArea.hoverEnabled + + function updateHover() { + mouseArea.updateHover(); + } + + function copy() { + mouseArea.copy(); + } + + Connections { + target: session + onReceivedMessageReceipt: { + messageReceiptes[id] = success; + + if (!itemById.hasOwnProperty(id)) + return; + var item = itemById[id]; + if (!item.hasOwnProperty('handleReceipt')) + return; + item.handleReceipt(id, success); + } + onClearRequested: { + var oldItems = items; + + messageReceiptes = {}; + itemById = {}; + itemMessages = []; + items = []; + + for (var i = 1; i <= oldItems.length; ++i) { + var currentItem = i < oldItems.length ? oldItems[i] : undefined; + var previousItem = oldItems[i - 1]; + if (previousItem !== currentItem) { + previousItem.parent = null; + previousItem.visible = false; + previousItem.destroy(); + } + } + + doLayout(); + } + } + + function appendMessage(message) { + var index = findIndex(itemMessages, message); + doNotRelayout = true; + + items.splice(index, 0, undefined); + itemMessages.splice(index, 0, message); + + /* if (index > 0 && isContentSimiliar(itemMessages[index - 1], message)) { + items[index] = items[index - 1]; + insertMessage(items[index], message); + } else if (index + 1 < itemMessages.length && isContentSimiliar(message, itemMessages[index + 1])) { + items[index] = items[index + 1]; + insertMessage(items[index], message); + } else {*/ + if(true) { + items[index] = createItem([message]); + + if (index > 0 && index + 1 < items.length && items[index - 1] === items[index + 1]) { + var messages = items[index - 1].messages; + var messageIndex = messages.indexOf(itemMessages[index + 1]); + var firstMessages = messages.slice(0, messageIndex); + var secondMessages = messages.slice(messageIndex); + items[index - 1].messages = firstMessages; + items[index + 1] = createItem(secondMessages); + for (var i = 1; i < secondMessages.length; ++i) + items[index + 1 + i] = items[index + 1]; + } + } + + itemById[message.id] = items[index]; + + doNotRelayout = false; + doLayout(); + } + + function findIndex(messages, message) { + var index = 0; + for (index = 0; index < messages.length; ++index) { + if (message.time.getTime() < messages[index].time.getTime()) { + break; + } + } + return index; + } + + function insertMessage(item, message) { + var messages = item.messages.slice(); + var index = findIndex(messages, message); + messages.splice(index, 0, message); + item.messages = messages; + } + + function isContentSimiliar(first, second) { + return !first.property("service", false) + && !second.property("service", false) + && first.isSimiliar(second); + } + + function createItem(messages) { + var message = messages[0]; + var properties = { + messages: messages, + session: Qt.binding(function () { return root.session; }), + width: Qt.binding(function () { return root.width; }), + }; + var component = messageComponent; + if (message.action && actionComponent) + component = actionComponent; + if (message.property("service", false) && serviceComponent) + component = serviceComponent; + var item = component.createObject(root, properties); + + item.heightChanged.connect(function () { + root.onItemHeightChanged(item); + }); + + return item; + } + + function doLayout() { + if (doNotRelayout) + return; + + var y = 0; + for (var i = 0; i < items.length; ++i) { + var item = items[i]; + if (i > 0 && item === items[i - 1]) + continue; + + item.y = y; + y += item.height; + } + root.height = y; + } + + function onItemHeightChanged(item) { + doLayout(); + } + + SelectableMouseArea { + id: mouseArea + anchors.fill: root + z: 10 + hoverEnabled: true + onLinkActivated: Qt.openUrlExternally(link) + } +} diff --git a/plugins/quickchat/qml/chatstyle/gajim/QuickMessagesView.qml b/plugins/quickchat/qml/chatstyle/gajim/QuickMessagesView.qml new file mode 100644 index 000000000..5dcd50697 --- /dev/null +++ b/plugins/quickchat/qml/chatstyle/gajim/QuickMessagesView.qml @@ -0,0 +1,87 @@ +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import org.qutim 0.4 as Base + +Rectangle { + id: root + color: "white" + + readonly property QtObject session: chatSession + property string topic: "" + + onSessionChanged: session.loadHistory() + + signal appendTextRequested(string text) + signal appendNickRequested(string nick) + + function copy() { + layout.copy(); + } + + Connections { + target: session + onMessageAppended: root.appendMessage(message) + onAppendTextRequested: root.appendTextRequested(text) + onAppendNickRequested: root.appendNickRequested(nick) + } + + Base.ControlledMenu { + id: menu + } + + function appendMessage(message) { + if (message.property("topic", false)) { + root.topic = message.html; + return; + } + + var keepEnd = flickable.shouldKeepEnd(); + + layout.appendMessage(message); + + if (keepEnd) + flickable.moveToEnd(); + } + + ScrollView { + id: scrollView + anchors.fill: parent + frameVisible: false + + Flickable { + id: flickable + contentWidth: layout.width + contentHeight: layout.height + + function shouldKeepEnd() { + return Math.abs((contentY + height - contentHeight) / height) < 0.25; + } + + function moveToEnd() { + var newContentY = Math.max(0, contentHeight - height); + if (contentY !== newContentY) + contentY = newContentY; + } + + onContentHeightChanged: if (shouldKeepEnd()) moveToEnd() + onContentYChanged: hoverDelay.restart() + + QuickMessagesLayout { + id: layout + width: scrollView.viewport.width + session: root.session + + messageComponent: Message {} + actionComponent: ActionMessage {} + serviceComponent: ServiceMessage {} + } + + Timer { + id: hoverDelay + interval: 200 + + onTriggered: layout.updateHover() + } + } + } +} diff --git a/plugins/quickchat/qml/chatstyle/gajim/ServiceMessage.qml b/plugins/quickchat/qml/chatstyle/gajim/ServiceMessage.qml new file mode 100644 index 000000000..8f19c5ac2 --- /dev/null +++ b/plugins/quickchat/qml/chatstyle/gajim/ServiceMessage.qml @@ -0,0 +1,81 @@ +import QtQuick 2.3 +import org.qutim 0.4 +import org.qutim.quickchat 0.4 +import "../default" as Default + +MessageBase { + id: root + height: messageItem.height + + readonly property var message: messages[0] + + Default.SelectableText { + id: messageItem + anchors { + top: parent.top + left: parent.left + margins: 4 + } + renderType: Text.NativeRendering + textFormat: Text.RichText + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + + + + readonly property string timeText: Qt.formatDateTime(message.time, '[hh:mm:ss]') + readonly property string timeColor: { + var incoming = message.incoming; + var success = messageReceipts[message.id]; + var history = message.property("history", false); + var color = undefined; + if (history) + color = "gray"; + else if (incoming || success === true) + color = "black"; + else if (success === false) + color = "red"; + else + color = "orange"; + return color; + } + + readonly property string timeHtml: "" + timeText + ""; + + + property variant nickColorsArray: ["#4e9a06", "#f57900", "#ce5c00", "#3465a4", "#204a87", "#75507b", "#5c3566", "#c17d11", "#8f5902", "#ef2929", "#cc0000", "#a40000"] + readonly property string incomingNickColor: { + return nickColorsArray[root.session.hashOf(nick, nickColorsArray.length)]; + } + readonly property string nick: message.unitData.title + readonly property url appendNickUrl: session.appendNickUrl(nick) + "#do-not-style" + readonly property string nickHtml: { + return "" + + session.htmlEscape(nick) + ""; + } + + readonly property string fontWeight: { + return message.property("mention", false) ? "bold" : "normal"; + } + + readonly property string nickColor: message.incoming ? incomingNickColor : "#437ee0" + + readonly property string messageFormattedHtml: "" + message.formattedHtml() + ""; + readonly property string messageColor: { + return "#509d1f" + } + + text: timeHtml + " " + messageFormattedHtml + + property AnchorsHighlighter highlighter: AnchorsHighlighter { + Component.onCompleted: { + // TextEdit.textDocument is non-notifyable property + textDocument = messageItem.textDocument; + hoverColor = "#07A"; + activeColor = "#09C"; + } + } + } + + +} diff --git a/plugins/quickchat/qml/chatstyle/gajim/main.qml b/plugins/quickchat/qml/chatstyle/gajim/main.qml new file mode 100644 index 000000000..6ba3393a2 --- /dev/null +++ b/plugins/quickchat/qml/chatstyle/gajim/main.qml @@ -0,0 +1,4 @@ +import QtQuick 2.3 + +QuickMessagesView { +} diff --git a/plugins/quickchat/src/chatchannel.cpp b/plugins/quickchat/src/chatchannel.cpp index 668a5fc63..07e647d01 100644 --- a/plugins/quickchat/src/chatchannel.cpp +++ b/plugins/quickchat/src/chatchannel.cpp @@ -207,6 +207,11 @@ void ChatChannel::appendNick(const QString &nick) emit appendNickRequested(nick); } +int ChatChannel::hashOf(const QString &nick, int max) +{ + return qHash(nick) % max; +} + void ChatChannel::loadHistory() { Config config(QStringLiteral("appearance")); diff --git a/plugins/quickchat/src/chatchannel.h b/plugins/quickchat/src/chatchannel.h index b1af2b589..bd8d63793 100644 --- a/plugins/quickchat/src/chatchannel.h +++ b/plugins/quickchat/src/chatchannel.h @@ -78,6 +78,8 @@ public slots: QUrl appendTextUrl(const QString &text); QUrl appendNickUrl(const QString &nick); + + int hashOf(const QString &nick, int max); protected: QUrl commandUrl(const QString &method, const QString &arg) const; diff --git a/plugins/urlpreview/qml/settings/urlpreview/main.qml b/plugins/urlpreview/qml/settings/urlpreview/main.qml index 7d8cb2305..4e753a3c4 100644 --- a/plugins/urlpreview/qml/settings/urlpreview/main.qml +++ b/plugins/urlpreview/qml/settings/urlpreview/main.qml @@ -13,7 +13,7 @@ SettingsItem { function save() { - config.setValue("maxFileSize", maxFileSizeEdit.checked); + config.setValue("maxFileSize", maxFileSizeEdit.value); config.setValue("maxWidth", maxWidthEdit.value); config.setValue("maxHeight", maxHeightEdit.value); config.setValue("youtubePreview", youtubePreviewEdit.checked); @@ -25,7 +25,7 @@ SettingsItem { } function load() { - maxFileSizeEdit.value = config.value("maxFileSize", 100000); + maxFileSizeEdit.value = config.value("maxFileSize", 1000000); maxWidthEdit.value = config.value("maxWidth", 800); maxHeightEdit.value = config.value("maxHeight", 600); youtubePreviewEdit.checked = config.value("youtubePreview", true); @@ -43,10 +43,10 @@ SettingsItem { } SpinBox { id: maxFileSizeEdit - suffix: qsTr(" kb.") - stepSize: 10 - minimumValue: 100 - maximumValue: 1000000 + suffix: qsTr(" bytes") + stepSize: 1000 + minimumValue: 1000 + maximumValue: 1000000000 Layout.fillWidth: true enabled: true onValueChanged: root.modify() diff --git a/plugins/urlpreview/src/messagehandler.cpp b/plugins/urlpreview/src/messagehandler.cpp index 5977a959d..8213f6dc0 100644 --- a/plugins/urlpreview/src/messagehandler.cpp +++ b/plugins/urlpreview/src/messagehandler.cpp @@ -72,10 +72,10 @@ void UrlHandler::loadSettings() m_imageTemplate = "%MAXW%) this.style.maxWidth='%MAXW%px';" "if (this.height>%MAXH%) { this.style.maxWidth=''; this.style.maxHeight='%MAXH%px'; } " - "this.style.display=''; document.body.scrollTop = document.body.offsetHeight; \">
"; + "this.style.display=''; if(nearBottom() || this.parentNode.getAttribute('data-wasnearbottom') == 'true' ){scrollToBottom();} \">
"; m_youtubeTemplate = "" "" - "
"; + "
"; m_html5AudioTemplate = ""; @@ -84,7 +84,7 @@ void UrlHandler::loadSettings() "" "%TITLE%" "
" - "%CONTENT%" + "%CONTENT%
" ""; m_enableYoutubePreview = cfg.value("youtubePreview", true); m_enableImagesPreview = cfg.value("imagesPreview", true); @@ -171,8 +171,14 @@ void UrlHandler::checkLink(const QStringRef &originalLink, QString &link, ChatUn reply->setProperty("uid", uid); reply->setProperty("unit", qVariantFromValue(from)); - link = QString::fromLatin1("%1 ") - .arg(originalLink.toString(), uid); + ChatSession *session = ChatLayer::get(from); + + QVariant val; + QMetaObject::invokeMethod(session, "evaluateJavaScript", Q_RETURN_ARG(QVariant, val), Q_ARG(QString, "nearBottom();")); + qDebug() << val; + + link = QString::fromLatin1("%1 ") + .arg(originalLink.toString(), uid, val.toString()); } void UrlHandler::netmanFinished(QNetworkReply *reply) @@ -200,7 +206,7 @@ void UrlHandler::netmanFinished(QNetworkReply *reply) QByteArray typeheader; QString type; QByteArray sizeheader; - quint64 size=0; + quint64 size = 0; QRegExp hrx; hrx.setCaseSensitivity(Qt::CaseInsensitive); foreach (QString header, reply->rawHeaderList()) { if (type.isEmpty()) { @@ -318,8 +324,8 @@ void UrlHandler::updateData(ChatUnit *unit, const QString &uid, const QString &h % QLatin1Literal(".innerHTML = \"") % QString(html).replace("\"", "\\\"") % QLatin1Literal("\";") - % QLatin1Literal("document.body.scrollTop = document.body.offsetHeight;"); - ChatSession *session = ChatLayer::get(unit); + % QLatin1Literal("if(nearBottom() || urlpreview") % uid % QLatin1Literal(".getAttribute('data-wasnearbottom') == 'true'){scrollToBottom();}"); + ChatSession *session = ChatLayer::get(unit); QMetaObject::invokeMethod(session, "evaluateJavaScript", Q_ARG(QString, js)); }