some fixes about uploading, some error handling

This commit is contained in:
Blue 2019-11-14 14:43:43 +03:00
parent 166a7ac83a
commit 326eef864b
11 changed files with 200 additions and 56 deletions

View File

@ -662,14 +662,17 @@ void Core::Account::sendMessage(const Shared::Message& data, const QString& path
um->requestUploadSlot(file); um->requestUploadSlot(file);
} }
} else { } else {
emit onFileUploadError(data.getId(), "Uploading file dissapeared or your system user has no permission to read it");
qDebug() << "Requested upload slot in account" << name << "for file" << path << "but the file doesn't exist or is not readable"; qDebug() << "Requested upload slot in account" << name << "for file" << path << "but the file doesn't exist or is not readable";
} }
} else { } else {
emit onFileUploadError(data.getId(), "Your server doesn't support file upload service, or it's prohibited for your account");
qDebug() << "Requested upload slot in account" << name << "for file" << path << "but upload manager didn't discover any upload services"; qDebug() << "Requested upload slot in account" << name << "for file" << path << "but upload manager didn't discover any upload services";
} }
} }
} }
} else { } else {
emit onFileUploadError(data.getId(), "Account is offline or reconnecting");
qDebug() << "An attempt to send message with not connected account " << name << ", skipping"; qDebug() << "An attempt to send message with not connected account " << name << ", skipping";
} }
} }
@ -1639,6 +1642,7 @@ void Core::Account::onUploadSlotRequestFailed(const QXmppHttpUploadRequestIq& re
} else { } else {
const std::pair<QString, Shared::Message>& pair = uploadingSlotsQueue.front(); const std::pair<QString, Shared::Message>& pair = uploadingSlotsQueue.front();
qDebug() << "Error requesting upload slot for file" << pair.first << "in account" << name << ":" << request.error().text(); qDebug() << "Error requesting upload slot for file" << pair.first << "in account" << name << ":" << request.error().text();
emit uploadFileError(pair.second.getId(), "Error requesting slot to upload file: " + request.error().text());
if (uploadingSlotsQueue.size() > 0) { if (uploadingSlotsQueue.size() > 0) {
um->requestUploadSlot(uploadingSlotsQueue.front().first); um->requestUploadSlot(uploadingSlotsQueue.front().first);

View File

@ -118,6 +118,7 @@ signals:
void removeRoomParticipant(const QString& jid, const QString& nickName); void removeRoomParticipant(const QString& jid, const QString& nickName);
void receivedVCard(const QString& jid, const Shared::VCard& card); void receivedVCard(const QString& jid, const Shared::VCard& card);
void uploadFile(const QFileInfo& file, const QUrl& set, const QUrl& get, QMap<QString, QString> headers); void uploadFile(const QFileInfo& file, const QUrl& set, const QUrl& get, QMap<QString, QString> headers);
void uploadFileError(const QString& messageId, const QString& error);
private: private:
QString name; QString name;

View File

@ -137,6 +137,8 @@ void Core::Squawk::addAccount(const QString& login, const QString& server, const
connect(acc, &Account::receivedVCard, this, &Squawk::responseVCard); connect(acc, &Account::receivedVCard, this, &Squawk::responseVCard);
connect(acc, &Account::uploadFileError, this, &Squawk::uploadFileError);
QMap<QString, QVariant> map = { QMap<QString, QVariant> map = {
{"login", login}, {"login", login},
{"server", server}, {"server", server},

View File

@ -5,77 +5,92 @@
<name>Account</name> <name>Account</name>
<message> <message>
<location filename="../ui/widgets/account.ui" line="14"/> <location filename="../ui/widgets/account.ui" line="14"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="127"/>
<source>Account</source> <source>Account</source>
<translatorcomment>Заголовок окна</translatorcomment> <translatorcomment>Заголовок окна</translatorcomment>
<translation>Учетная запись</translation> <translation>Учетная запись</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="40"/> <location filename="../ui/widgets/account.ui" line="40"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="129"/>
<source>Your account login</source> <source>Your account login</source>
<translation>Имя пользователя Вашей учетной записи</translation> <translation>Имя пользователя Вашей учетной записи</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="43"/> <location filename="../ui/widgets/account.ui" line="43"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="131"/>
<source>john_smith1987</source> <source>john_smith1987</source>
<translation>ivan_ivanov1987</translation> <translation>ivan_ivanov1987</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="50"/> <location filename="../ui/widgets/account.ui" line="50"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="132"/>
<source>Server</source> <source>Server</source>
<translation>Сервер</translation> <translation>Сервер</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="57"/> <location filename="../ui/widgets/account.ui" line="57"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="134"/>
<source>A server address of your account. Like 404.city or macaw.me</source> <source>A server address of your account. Like 404.city or macaw.me</source>
<translation>Адресс сервера вашей учетной записи (выглядит как 404.city или macaw.me)</translation> <translation>Адресс сервера вашей учетной записи (выглядит как 404.city или macaw.me)</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="60"/> <location filename="../ui/widgets/account.ui" line="60"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="136"/>
<source>macaw.me</source> <source>macaw.me</source>
<translation>macaw.me</translation> <translation>macaw.me</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="67"/> <location filename="../ui/widgets/account.ui" line="67"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="137"/>
<source>Login</source> <source>Login</source>
<translation>Имя учетной записи</translation> <translation>Имя учетной записи</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="74"/> <location filename="../ui/widgets/account.ui" line="74"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="138"/>
<source>Password</source> <source>Password</source>
<translation>Пароль</translation> <translation>Пароль</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="81"/> <location filename="../ui/widgets/account.ui" line="81"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="140"/>
<source>Password of your account</source> <source>Password of your account</source>
<translation>Пароль вашей учетной записи</translation> <translation>Пароль вашей учетной записи</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="103"/> <location filename="../ui/widgets/account.ui" line="103"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="145"/>
<source>Name</source> <source>Name</source>
<translation>Имя</translation> <translation>Имя</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="110"/> <location filename="../ui/widgets/account.ui" line="110"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="147"/>
<source>Just a name how would you call this account, doesn&apos;t affect anything</source> <source>Just a name how would you call this account, doesn&apos;t affect anything</source>
<translation>Просто имя, то как Вы называете свою учетную запись, может быть любым</translation> <translation>Просто имя, то как Вы называете свою учетную запись, может быть любым</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="113"/> <location filename="../ui/widgets/account.ui" line="113"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="149"/>
<source>John</source> <source>John</source>
<translation>Иван</translation> <translation>Иван</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="120"/> <location filename="../ui/widgets/account.ui" line="120"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="150"/>
<source>Resource</source> <source>Resource</source>
<translation>Ресурс</translation> <translation>Ресурс</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="127"/> <location filename="../ui/widgets/account.ui" line="127"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="152"/>
<source>A resource name like &quot;Home&quot; or &quot;Work&quot;</source> <source>A resource name like &quot;Home&quot; or &quot;Work&quot;</source>
<translation>Имя этой программы для ваших контактов, может быть &quot;Home&quot; или &quot;Phone&quot;</translation> <translation>Имя этой программы для ваших контактов, может быть &quot;Home&quot; или &quot;Phone&quot;</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="130"/> <location filename="../ui/widgets/account.ui" line="130"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="154"/>
<source>QXmpp</source> <source>QXmpp</source>
<translatorcomment>Ресурс по умолчанию</translatorcomment> <translatorcomment>Ресурс по умолчанию</translatorcomment>
<translation>QXmpp</translation> <translation>QXmpp</translation>
@ -85,31 +100,37 @@
<name>Accounts</name> <name>Accounts</name>
<message> <message>
<location filename="../ui/widgets/accounts.ui" line="14"/> <location filename="../ui/widgets/accounts.ui" line="14"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="108"/>
<source>Accounts</source> <source>Accounts</source>
<translation>Учетные записи</translation> <translation>Учетные записи</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/accounts.ui" line="45"/> <location filename="../ui/widgets/accounts.ui" line="45"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="109"/>
<source>Delete</source> <source>Delete</source>
<translation>Удалить</translation> <translation>Удалить</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/accounts.ui" line="86"/> <location filename="../ui/widgets/accounts.ui" line="86"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="110"/>
<source>Add</source> <source>Add</source>
<translation>Добавить</translation> <translation>Добавить</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/accounts.ui" line="96"/> <location filename="../ui/widgets/accounts.ui" line="96"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="111"/>
<source>Edit</source> <source>Edit</source>
<translation>Редактировать</translation> <translation>Редактировать</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/accounts.ui" line="106"/> <location filename="../ui/widgets/accounts.ui" line="106"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="112"/>
<source>Change password</source> <source>Change password</source>
<translation>Изменить пароль</translation> <translation>Изменить пароль</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/accounts.ui" line="129"/> <location filename="../ui/widgets/accounts.ui" line="129"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="113"/>
<location filename="../ui/widgets/accounts.cpp" line="125"/> <location filename="../ui/widgets/accounts.cpp" line="125"/>
<location filename="../ui/widgets/accounts.cpp" line="128"/> <location filename="../ui/widgets/accounts.cpp" line="128"/>
<source>Connect</source> <source>Connect</source>
@ -125,11 +146,12 @@
<name>Conversation</name> <name>Conversation</name>
<message> <message>
<location filename="../ui/widgets/conversation.ui" line="449"/> <location filename="../ui/widgets/conversation.ui" line="449"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_conversation.h" line="324"/>
<source>Type your message here...</source> <source>Type your message here...</source>
<translation>Введите сообщение...</translation> <translation>Введите сообщение...</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/conversation.cpp" line="260"/> <location filename="../ui/widgets/conversation.cpp" line="284"/>
<source>Chose a file to send</source> <source>Chose a file to send</source>
<translation>Выберите файл для отправки</translation> <translation>Выберите файл для отправки</translation>
</message> </message>
@ -281,52 +303,62 @@
<name>JoinConference</name> <name>JoinConference</name>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="14"/> <location filename="../ui/widgets/joinconference.ui" line="14"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="116"/>
<source>Join new conference</source> <source>Join new conference</source>
<translatorcomment>Заголовок окна</translatorcomment> <translatorcomment>Заголовок окна</translatorcomment>
<translation>Присоединиться к новой беседе</translation> <translation>Присоединиться к новой беседе</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="22"/> <location filename="../ui/widgets/joinconference.ui" line="22"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="117"/>
<source>JID</source> <source>JID</source>
<translation>JID</translation> <translation>JID</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="29"/> <location filename="../ui/widgets/joinconference.ui" line="29"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="119"/>
<source>Room JID</source> <source>Room JID</source>
<translation>Jabber-идентификатор беседы</translation> <translation>Jabber-идентификатор беседы</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="32"/> <location filename="../ui/widgets/joinconference.ui" line="32"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="121"/>
<source>identifier@conference.server.org</source> <source>identifier@conference.server.org</source>
<translation>identifier@conference.server.org</translation> <translation>identifier@conference.server.org</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="39"/> <location filename="../ui/widgets/joinconference.ui" line="39"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="122"/>
<source>Account</source> <source>Account</source>
<translation>Учетная запись</translation> <translation>Учетная запись</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="49"/> <location filename="../ui/widgets/joinconference.ui" line="49"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="123"/>
<source>Join on login</source> <source>Join on login</source>
<translation>Автовход</translation> <translation>Автовход</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="56"/> <location filename="../ui/widgets/joinconference.ui" line="56"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="125"/>
<source>If checked Squawk will try to join this conference on login</source> <source>If checked Squawk will try to join this conference on login</source>
<translation>Если стоит галочка Squawk автоматически присоединится к этой беседе при подключении</translation> <translation>Если стоит галочка Squawk автоматически присоединится к этой беседе при подключении</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="66"/> <location filename="../ui/widgets/joinconference.ui" line="66"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="128"/>
<source>Nick name</source> <source>Nick name</source>
<translation>Псевдоним</translation> <translation>Псевдоним</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="73"/> <location filename="../ui/widgets/joinconference.ui" line="73"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="130"/>
<source>Your nick name for that conference. If you leave this field empty your account name will be used as a nick name</source> <source>Your nick name for that conference. If you leave this field empty your account name will be used as a nick name</source>
<translation>Ваш псевдоним в этой беседе, если оставите это поле пустым - будет использовано имя Вашей учетной записи</translation> <translation>Ваш псевдоним в этой беседе, если оставите это поле пустым - будет использовано имя Вашей учетной записи</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="76"/> <location filename="../ui/widgets/joinconference.ui" line="76"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="132"/>
<source>John</source> <source>John</source>
<translation>Ivan</translation> <translation>Ivan</translation>
</message> </message>
@ -334,26 +366,58 @@
<context> <context>
<name>Message</name> <name>Message</name>
<message> <message>
<location filename="../ui/utils/message.cpp" line="119"/>
<source>Download</source> <source>Download</source>
<translation>Скачать</translation> <translation>Скачать</translation>
</message> </message>
<message> <message>
<location filename="../ui/utils/message.cpp" line="123"/> <location filename="../ui/utils/message.cpp" line="172"/>
<source>Open</source>
<translation>Открыть</translation>
</message>
</context>
<context>
<name>MessageLine</name>
<message>
<location filename="../ui/utils/messageline.cpp" line="146"/>
<source>Downloading...</source>
<translation>Скачивается...</translation>
</message>
<message>
<location filename="../ui/utils/messageline.cpp" line="258"/>
<location filename="../ui/utils/messageline.cpp" line="324"/>
<source>Download</source>
<translation>Скачать</translation>
</message>
<message>
<location filename="../ui/utils/messageline.cpp" line="259"/>
<source>Push the button to daownload the file</source>
<translation>Нажмите на кнопку что бы загрузить файл</translation>
</message>
<message>
<location filename="../ui/utils/messageline.cpp" line="319"/>
<source>Error uploading file: %1
You can try again</source>
<translation>Ошибка загрузки файла на сервер:
%1
Для того, что бы попробовать снова нажмите на кнопку</translation>
</message>
<message>
<location filename="../ui/utils/messageline.cpp" line="320"/>
<source>Upload</source>
<translation>Загрузить</translation>
</message>
<message>
<location filename="../ui/utils/messageline.cpp" line="325"/>
<source>Error downloading file: %1 <source>Error downloading file: %1
You can try again</source> You can try again</source>
<translation>Ошибка загрузки файла: %1 <translation>Ошибка скачивания файла:
%1
Вы можете попробовать снова</translation> Вы можете попробовать снова</translation>
</message> </message>
<message> <message>
<location filename="../ui/utils/message.cpp" line="125"/> <location filename="../ui/utils/messageline.cpp" line="336"/>
<source>%1 is offering you to download a file</source> <source>Uploading...</source>
<translation>%1 предлагает Вам скачать файл</translation> <translation>Загружается...</translation>
</message>
<message>
<location filename="../ui/utils/message.cpp" line="190"/>
<source>Open</source>
<translation>Открыть</translation>
</message> </message>
</context> </context>
<context> <context>
@ -470,48 +534,57 @@ You can try again</source>
<name>NewContact</name> <name>NewContact</name>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="14"/> <location filename="../ui/widgets/newcontact.ui" line="14"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="103"/>
<source>Add new contact</source> <source>Add new contact</source>
<translatorcomment>Заголовок окна</translatorcomment> <translatorcomment>Заголовок окна</translatorcomment>
<translation>Добавление нового контакта</translation> <translation>Добавление нового контакта</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="22"/> <location filename="../ui/widgets/newcontact.ui" line="22"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="104"/>
<source>Account</source> <source>Account</source>
<translation>Учетная запись</translation> <translation>Учетная запись</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="29"/> <location filename="../ui/widgets/newcontact.ui" line="29"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="106"/>
<source>An account that is going to have new contact</source> <source>An account that is going to have new contact</source>
<translation>Учетная запись для которой будет добавлен контакт</translation> <translation>Учетная запись для которой будет добавлен контакт</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="36"/> <location filename="../ui/widgets/newcontact.ui" line="36"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="108"/>
<source>JID</source> <source>JID</source>
<translation>JID</translation> <translation>JID</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="43"/> <location filename="../ui/widgets/newcontact.ui" line="43"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="110"/>
<source>Jabber id of your new contact</source> <source>Jabber id of your new contact</source>
<translation>Jabber-идентификатор нового контакта</translation> <translation>Jabber-идентификатор нового контакта</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="46"/> <location filename="../ui/widgets/newcontact.ui" line="46"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="112"/>
<source>name@server.dmn</source> <source>name@server.dmn</source>
<translatorcomment>Placeholder поля ввода JID</translatorcomment> <translatorcomment>Placeholder поля ввода JID</translatorcomment>
<translation>name@server.dmn</translation> <translation>name@server.dmn</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="53"/> <location filename="../ui/widgets/newcontact.ui" line="53"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="113"/>
<source>Name</source> <source>Name</source>
<translation>Имя</translation> <translation>Имя</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="60"/> <location filename="../ui/widgets/newcontact.ui" line="60"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="115"/>
<source>The way this new contact will be labeled in your roster (optional)</source> <source>The way this new contact will be labeled in your roster (optional)</source>
<translation>То, как будет подписан контакт в вашем списке контактов (не обязательно)</translation> <translation>То, как будет подписан контакт в вашем списке контактов (не обязательно)</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="63"/> <location filename="../ui/widgets/newcontact.ui" line="63"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="117"/>
<source>John Smith</source> <source>John Smith</source>
<translation>Иван Иванов</translation> <translation>Иван Иванов</translation>
</message> </message>
@ -520,36 +593,43 @@ You can try again</source>
<name>Squawk</name> <name>Squawk</name>
<message> <message>
<location filename="../ui/squawk.ui" line="14"/> <location filename="../ui/squawk.ui" line="14"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="137"/>
<source>squawk</source> <source>squawk</source>
<translation>Squawk</translation> <translation>Squawk</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.ui" line="78"/> <location filename="../ui/squawk.ui" line="78"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="143"/>
<source>Settings</source> <source>Settings</source>
<translation>Настройки</translation> <translation>Настройки</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.ui" line="84"/> <location filename="../ui/squawk.ui" line="84"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="144"/>
<source>Squawk</source> <source>Squawk</source>
<translation>Squawk</translation> <translation>Squawk</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.ui" line="99"/> <location filename="../ui/squawk.ui" line="99"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="138"/>
<source>Accounts</source> <source>Accounts</source>
<translation>Учетные записи</translation> <translation>Учетные записи</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.ui" line="108"/> <location filename="../ui/squawk.ui" line="108"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="139"/>
<source>Quit</source> <source>Quit</source>
<translation>Выйти</translation> <translation>Выйти</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.ui" line="120"/> <location filename="../ui/squawk.ui" line="120"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="140"/>
<source>Add contact</source> <source>Add contact</source>
<translation>Добавить контакт</translation> <translation>Добавить контакт</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.ui" line="132"/> <location filename="../ui/squawk.ui" line="132"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="141"/>
<source>Add conference</source> <source>Add conference</source>
<translation>Присоединиться к беседе</translation> <translation>Присоединиться к беседе</translation>
</message> </message>
@ -559,52 +639,52 @@ You can try again</source>
<translation>Список контактов</translation> <translation>Список контактов</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="549"/> <location filename="../ui/squawk.cpp" line="558"/>
<source>Disconnect</source> <source>Disconnect</source>
<translation>Отключить</translation> <translation>Отключить</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="555"/> <location filename="../ui/squawk.cpp" line="564"/>
<source>Connect</source> <source>Connect</source>
<translation>Подключить</translation> <translation>Подключить</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="561"/> <location filename="../ui/squawk.cpp" line="570"/>
<location filename="../ui/squawk.cpp" line="659"/> <location filename="../ui/squawk.cpp" line="668"/>
<source>VCard</source> <source>VCard</source>
<translation>Карточка</translation> <translation>Карточка</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="565"/> <location filename="../ui/squawk.cpp" line="574"/>
<location filename="../ui/squawk.cpp" line="663"/> <location filename="../ui/squawk.cpp" line="672"/>
<location filename="../ui/squawk.cpp" line="703"/> <location filename="../ui/squawk.cpp" line="712"/>
<source>Remove</source> <source>Remove</source>
<translation>Удалить</translation> <translation>Удалить</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="577"/> <location filename="../ui/squawk.cpp" line="586"/>
<source>Open dialog</source> <source>Open dialog</source>
<translation>Открыть диалог</translation> <translation>Открыть диалог</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="587"/> <location filename="../ui/squawk.cpp" line="596"/>
<location filename="../ui/squawk.cpp" line="684"/> <location filename="../ui/squawk.cpp" line="693"/>
<source>Unsubscribe</source> <source>Unsubscribe</source>
<translation>Отписаться</translation> <translation>Отписаться</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="597"/> <location filename="../ui/squawk.cpp" line="606"/>
<location filename="../ui/squawk.cpp" line="693"/> <location filename="../ui/squawk.cpp" line="702"/>
<source>Subscribe</source> <source>Subscribe</source>
<translation>Подписаться</translation> <translation>Подписаться</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="608"/> <location filename="../ui/squawk.cpp" line="617"/>
<source>Rename</source> <source>Rename</source>
<translation>Переименовать</translation> <translation>Переименовать</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="621"/> <location filename="../ui/squawk.cpp" line="630"/>
<source>Input new name for %1 <source>Input new name for %1
or leave it empty for the contact or leave it empty for the contact
to be displayed as %1</source> to be displayed as %1</source>
@ -614,47 +694,47 @@ to be displayed as %1</source>
%1</translation> %1</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="622"/> <location filename="../ui/squawk.cpp" line="631"/>
<source>Renaming %1</source> <source>Renaming %1</source>
<translation>Назначение имени контакту %1</translation> <translation>Назначение имени контакту %1</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="628"/> <location filename="../ui/squawk.cpp" line="637"/>
<source>Groups</source> <source>Groups</source>
<translation>Группы</translation> <translation>Группы</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="643"/> <location filename="../ui/squawk.cpp" line="652"/>
<source>New group</source> <source>New group</source>
<translation>Создать новую группу</translation> <translation>Создать новую группу</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="653"/> <location filename="../ui/squawk.cpp" line="662"/>
<source>New group name</source> <source>New group name</source>
<translation>Имя группы</translation> <translation>Имя группы</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="654"/> <location filename="../ui/squawk.cpp" line="663"/>
<source>Add %1 to a new group</source> <source>Add %1 to a new group</source>
<translation>Добавление %1 в новую группу</translation> <translation>Добавление %1 в новую группу</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="675"/> <location filename="../ui/squawk.cpp" line="684"/>
<source>Open conversation</source> <source>Open conversation</source>
<translation>Открыть окно беседы</translation> <translation>Открыть окно беседы</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="780"/> <location filename="../ui/squawk.cpp" line="789"/>
<source>%1 account card</source> <source>%1 account card</source>
<translation>Карточка учетной записи %1</translation> <translation>Карточка учетной записи %1</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="782"/> <location filename="../ui/squawk.cpp" line="791"/>
<source>%1 contact card</source> <source>%1 contact card</source>
<translation>Карточка контакта %1</translation> <translation>Карточка контакта %1</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="794"/> <location filename="../ui/squawk.cpp" line="803"/>
<source>Downloading vCard</source> <source>Downloading vCard</source>
<translation>Получение карточки</translation> <translation>Получение карточки</translation>
</message> </message>
@ -663,119 +743,145 @@ to be displayed as %1</source>
<name>VCard</name> <name>VCard</name>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="65"/> <location filename="../ui/widgets/vcard/vcard.ui" line="65"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="612"/>
<source>Received 12.07.2007 at 17.35</source> <source>Received 12.07.2007 at 17.35</source>
<translation>Не обновлялось</translation> <translation>Не обновлялось</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="100"/> <location filename="../ui/widgets/vcard/vcard.ui" line="100"/>
<location filename="../ui/widgets/vcard/vcard.ui" line="425"/> <location filename="../ui/widgets/vcard/vcard.ui" line="425"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="624"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="627"/>
<source>General</source> <source>General</source>
<translation>Общее</translation> <translation>Общее</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="130"/> <location filename="../ui/widgets/vcard/vcard.ui" line="130"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="613"/>
<source>Organization</source> <source>Organization</source>
<translation>Место работы</translation> <translation>Место работы</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="180"/> <location filename="../ui/widgets/vcard/vcard.ui" line="180"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="614"/>
<source>Middle name</source> <source>Middle name</source>
<translation>Среднее имя</translation> <translation>Среднее имя</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="190"/> <location filename="../ui/widgets/vcard/vcard.ui" line="190"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="615"/>
<source>First name</source> <source>First name</source>
<translation>Имя</translation> <translation>Имя</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="200"/> <location filename="../ui/widgets/vcard/vcard.ui" line="200"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="616"/>
<source>Last name</source> <source>Last name</source>
<translation>Фамилия</translation> <translation>Фамилия</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="226"/> <location filename="../ui/widgets/vcard/vcard.ui" line="226"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="617"/>
<source>Nick name</source> <source>Nick name</source>
<translation>Псевдоним</translation> <translation>Псевдоним</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="252"/> <location filename="../ui/widgets/vcard/vcard.ui" line="252"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="618"/>
<source>Birthday</source> <source>Birthday</source>
<translation>Дата рождения</translation> <translation>Дата рождения</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="272"/> <location filename="../ui/widgets/vcard/vcard.ui" line="272"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="619"/>
<source>Organization name</source> <source>Organization name</source>
<translation>Название организации</translation> <translation>Название организации</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="298"/> <location filename="../ui/widgets/vcard/vcard.ui" line="298"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="620"/>
<source>Unit / Department</source> <source>Unit / Department</source>
<translation>Отдел</translation> <translation>Отдел</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="324"/> <location filename="../ui/widgets/vcard/vcard.ui" line="324"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="621"/>
<source>Role / Profession</source> <source>Role / Profession</source>
<translation>Профессия</translation> <translation>Профессия</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="350"/> <location filename="../ui/widgets/vcard/vcard.ui" line="350"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="622"/>
<source>Job title</source> <source>Job title</source>
<translation>Наименование должности</translation> <translation>Наименование должности</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="390"/> <location filename="../ui/widgets/vcard/vcard.ui" line="390"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="623"/>
<source>Full name</source> <source>Full name</source>
<translation>Полное имя</translation> <translation>Полное имя</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="460"/> <location filename="../ui/widgets/vcard/vcard.ui" line="460"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="625"/>
<source>Personal information</source> <source>Personal information</source>
<translation>Личная информация</translation> <translation>Личная информация</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="653"/> <location filename="../ui/widgets/vcard/vcard.ui" line="653"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="629"/>
<source>Addresses</source> <source>Addresses</source>
<translation>Адреса</translation> <translation>Адреса</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="682"/> <location filename="../ui/widgets/vcard/vcard.ui" line="682"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="630"/>
<source>E-Mail addresses</source> <source>E-Mail addresses</source>
<translation>Адреса электронной почты</translation> <translation>Адреса электронной почты</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="767"/> <location filename="../ui/widgets/vcard/vcard.ui" line="767"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="633"/>
<source>Phone numbers</source> <source>Phone numbers</source>
<translation>Номера телефонов</translation> <translation>Номера телефонов</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="522"/> <location filename="../ui/widgets/vcard/vcard.ui" line="522"/>
<location filename="../ui/widgets/vcard/vcard.ui" line="546"/> <location filename="../ui/widgets/vcard/vcard.ui" line="546"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="628"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="634"/>
<source>Contact</source> <source>Contact</source>
<translation>Контактная информация</translation> <translation>Контактная информация</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="713"/> <location filename="../ui/widgets/vcard/vcard.ui" line="713"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="631"/>
<source>Jabber ID</source> <source>Jabber ID</source>
<translation>Jabber ID</translation> <translation>Jabber ID</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="739"/> <location filename="../ui/widgets/vcard/vcard.ui" line="739"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="632"/>
<source>Web site</source> <source>Web site</source>
<translation>Веб сайт</translation> <translation>Веб сайт</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="798"/> <location filename="../ui/widgets/vcard/vcard.ui" line="798"/>
<location filename="../ui/widgets/vcard/vcard.ui" line="822"/> <location filename="../ui/widgets/vcard/vcard.ui" line="822"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="635"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="636"/>
<source>Description</source> <source>Description</source>
<translation>Описание</translation> <translation>Описание</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="859"/> <location filename="../ui/widgets/vcard/vcard.ui" line="859"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="610"/>
<source>Set avatar</source> <source>Set avatar</source>
<translation>Установить иконку</translation> <translation>Установить иконку</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="868"/> <location filename="../ui/widgets/vcard/vcard.ui" line="868"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="611"/>
<source>Clear avatar</source> <source>Clear avatar</source>
<translation>Убрать иконку</translation> <translation>Убрать иконку</translation>
</message> </message>

View File

@ -109,7 +109,7 @@ void Message::setSender(const QString& p_sender)
sender->setText(p_sender); sender->setText(p_sender);
} }
void Message::addButton(const QIcon& icon, const QString& buttonText) void Message::addButton(const QIcon& icon, const QString& buttonText, const QString& tooltip)
{ {
hideFile(); hideFile();
hideProgress(); hideProgress();
@ -120,7 +120,7 @@ void Message::addButton(const QIcon& icon, const QString& buttonText)
text->hide(); text->hide();
} }
button = new QPushButton(icon, buttonText); button = new QPushButton(icon, buttonText);
button->setToolTip("<a href=\"" + msg.getOutOfBandUrl() + "\">" + msg.getOutOfBandUrl() + "</a>"); button->setToolTip(tooltip);
connect(button, &QPushButton::clicked, this, &Message::buttonClicked); connect(button, &QPushButton::clicked, this, &Message::buttonClicked);
bodyLayout->insertWidget(2, button); bodyLayout->insertWidget(2, button);
hasButton = true; hasButton = true;

View File

@ -49,7 +49,7 @@ public:
QString getFileUrl() const; QString getFileUrl() const;
const Shared::Message& getMessage() const; const Shared::Message& getMessage() const;
void addButton(const QIcon& icon, const QString& buttonText); void addButton(const QIcon& icon, const QString& buttonText, const QString& tooltip = "");
void showComment(const QString& comment, bool wordWrap = false); void showComment(const QString& comment, bool wordWrap = false);
void hideComment(); void hideComment();
void showFile(const QString& path); void showFile(const QString& path);

View File

@ -253,8 +253,9 @@ void MessageLine::responseLocalFile(const QString& messageId, const QString& pat
} }
} }
} else { } else {
if (uItr != uploading.end()) { if (uItr == uploading.end()) {
itr->second->addButton(QIcon::fromTheme("download"), tr("Download")); const Shared::Message& msg = itr->second->getMessage();
itr->second->addButton(QIcon::fromTheme("download"), tr("Download"), "<a href=\"" + msg.getOutOfBandUrl() + "\">" + msg.getOutOfBandUrl() + "</a>");
itr->second->showComment(tr("Push the button to daownload the file")); itr->second->showComment(tr("Push the button to daownload the file"));
} else { } else {
qDebug() << "An unhandled state for file uploading - empty path"; qDebug() << "An unhandled state for file uploading - empty path";
@ -319,7 +320,8 @@ void MessageLine::fileError(const QString& messageId, const QString& error)
itr->second->addButton(QIcon::fromTheme("upload"), tr("Upload")); itr->second->addButton(QIcon::fromTheme("upload"), tr("Upload"));
} }
} else { } else {
itr->second->addButton(QIcon::fromTheme("download"), tr("Download")); const Shared::Message& msg = itr->second->getMessage();
itr->second->addButton(QIcon::fromTheme("download"), tr("Download"), "<a href=\"" + msg.getOutOfBandUrl() + "\">" + msg.getOutOfBandUrl() + "</a>");
itr->second->showComment(tr("Error downloading file: %1\nYou can try again").arg(QCoreApplication::translate("NetworkErrors", error.toLatin1())), true); itr->second->showComment(tr("Error downloading file: %1\nYou can try again").arg(QCoreApplication::translate("NetworkErrors", error.toLatin1())), true);
} }
} }
@ -331,7 +333,7 @@ void MessageLine::appendMessageWithUpload(const Shared::Message& msg, const QStr
Message* ui = messageIndex.find(id)->second; Message* ui = messageIndex.find(id)->second;
connect(ui, &Message::buttonClicked, this, &MessageLine::onUpload); //this is in case of retry; connect(ui, &Message::buttonClicked, this, &MessageLine::onUpload); //this is in case of retry;
ui->setProgress(0); ui->setProgress(0);
ui->showComment("Uploading..."); ui->showComment(tr("Uploading..."));
uploading.insert(std::make_pair(id, ui)); uploading.insert(std::make_pair(id, ui));
uploadPaths.insert(std::make_pair(id, path)); uploadPaths.insert(std::make_pair(id, path));
emit uploadFile(msg, path); emit uploadFile(msg, path);

View File

@ -27,7 +27,8 @@ QObject(parent)
bool Resizer::eventFilter(QObject* obj, QEvent* event) bool Resizer::eventFilter(QObject* obj, QEvent* event)
{ {
if (event->type() == QEvent::Resize) { if (event->type() == QEvent::Resize) {
emit resized(); QResizeEvent* ev = static_cast<QResizeEvent*>(event);
emit resized(ev->oldSize(), ev->size());
} }
return false; return false;

View File

@ -22,6 +22,7 @@
#include <QObject> #include <QObject>
#include <QWidget> #include <QWidget>
#include <QEvent> #include <QEvent>
#include <QResizeEvent>
/** /**
* @todo write docs * @todo write docs
@ -35,7 +36,7 @@ protected:
bool eventFilter(QObject* obj, QEvent* event) override; bool eventFilter(QObject* obj, QEvent* event) override;
signals: signals:
void resized(); void resized(const QSize& oldSize, const QSize& newSize);
}; };
#endif // RESIZER_H #endif // RESIZER_H

View File

@ -36,7 +36,8 @@ Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, co
line(new MessageLine(muc)), line(new MessageLine(muc)),
m_ui(new Ui::Conversation()), m_ui(new Ui::Conversation()),
ker(), ker(),
res(), scrollResizeCatcher(),
attachResizeCatcher(),
vis(), vis(),
thread(), thread(),
statusIcon(0), statusIcon(0),
@ -60,7 +61,8 @@ Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, co
statusLabel = m_ui->statusLabel; statusLabel = m_ui->statusLabel;
connect(&ker, &KeyEnterReceiver::enterPressed, this, &Conversation::onEnterPressed); connect(&ker, &KeyEnterReceiver::enterPressed, this, &Conversation::onEnterPressed);
connect(&res, &Resizer::resized, this, &Conversation::onScrollResize); connect(&scrollResizeCatcher, &Resizer::resized, this, &Conversation::onScrollResize);
connect(&attachResizeCatcher, &Resizer::resized, this, &Conversation::onAttachResize);
connect(&vis, &VisibilityCatcher::shown, this, &Conversation::onScrollResize); connect(&vis, &VisibilityCatcher::shown, this, &Conversation::onScrollResize);
connect(&vis, &VisibilityCatcher::hidden, this, &Conversation::onScrollResize); connect(&vis, &VisibilityCatcher::hidden, this, &Conversation::onScrollResize);
connect(m_ui->sendButton, &QPushButton::clicked, this, &Conversation::onEnterPressed); connect(m_ui->sendButton, &QPushButton::clicked, this, &Conversation::onEnterPressed);
@ -69,6 +71,7 @@ Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, co
connect(line, &MessageLine::uploadFile, this, qOverload<const Shared::Message&, const QString&>(&Conversation::sendMessage)); connect(line, &MessageLine::uploadFile, this, qOverload<const Shared::Message&, const QString&>(&Conversation::sendMessage));
connect(line, &MessageLine::requestLocalFile, this, &Conversation::requestLocalFile); connect(line, &MessageLine::requestLocalFile, this, &Conversation::requestLocalFile);
connect(m_ui->attachButton, &QPushButton::clicked, this, &Conversation::onAttach); connect(m_ui->attachButton, &QPushButton::clicked, this, &Conversation::onAttach);
connect(m_ui->clearButton, &QPushButton::clicked, this, &Conversation::onClearButton);
m_ui->messageEditor->installEventFilter(&ker); m_ui->messageEditor->installEventFilter(&ker);
@ -78,7 +81,8 @@ Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, co
vs->setBackgroundRole(QPalette::Base); vs->setBackgroundRole(QPalette::Base);
vs->setAutoFillBackground(true); vs->setAutoFillBackground(true);
connect(vs, &QScrollBar::valueChanged, this, &Conversation::onSliderValueChanged); connect(vs, &QScrollBar::valueChanged, this, &Conversation::onSliderValueChanged);
m_ui->scrollArea->installEventFilter(&res); m_ui->scrollArea->installEventFilter(&scrollResizeCatcher);
m_ui->filesPanel->installEventFilter(&attachResizeCatcher);
applyVisualEffects(); applyVisualEffects();
} }
@ -181,6 +185,10 @@ void Conversation::onEnterPressed()
{ {
QString body(m_ui->messageEditor->toPlainText()); QString body(m_ui->messageEditor->toPlainText());
if (body.size() > 0) {
m_ui->messageEditor->clear();
handleSendMessage(body);
}
if (filesToAttach.size() > 0) { if (filesToAttach.size() > 0) {
for (Badge* badge : filesToAttach) { for (Badge* badge : filesToAttach) {
Shared::Message msg; Shared::Message msg;
@ -196,17 +204,9 @@ void Conversation::onEnterPressed()
msg.setOutgoing(true); msg.setOutgoing(true);
msg.generateRandomId(); msg.generateRandomId();
msg.setCurrentTime(); msg.setCurrentTime();
if (body.size() > 0) {
msg.setBody(body);
}
line->appendMessageWithUpload(msg, badge->id); line->appendMessageWithUpload(msg, badge->id);
} }
clearAttachedFiles(); clearAttachedFiles();
} else {
if (body.size() > 0) {
m_ui->messageEditor->clear();
handleSendMessage(body);
}
} }
} }
@ -376,6 +376,30 @@ void Conversation::clearAttachedFiles()
filesLayout->setContentsMargins(0, 0, 0, 0); filesLayout->setContentsMargins(0, 0, 0, 0);
} }
void Conversation::onClearButton()
{
clearAttachedFiles();
m_ui->messageEditor->clear();
}
void Conversation::onAttachResize(const QSize& oldSize, const QSize& newSize)
{
int oh = oldSize.height();
int nh = newSize.height();
int d = oh - nh;
if (d != 0) {
QList<int> cs = m_ui->splitter->sizes();
cs.first() += d;
cs.last() -=d;
m_ui->splitter->setSizes(cs);
m_ui->scrollArea->verticalScrollBar()->setValue(m_ui->scrollArea->verticalScrollBar()->maximum());
}
}
bool VisibilityCatcher::eventFilter(QObject* obj, QEvent* event) bool VisibilityCatcher::eventFilter(QObject* obj, QEvent* event)
{ {
if (event->type() == QEvent::Show) { if (event->type() == QEvent::Show) {

View File

@ -102,7 +102,9 @@ protected slots:
void onAttach(); void onAttach();
void onFileSelected(); void onFileSelected();
void onScrollResize(); void onScrollResize();
void onAttachResize(const QSize& oldSize, const QSize& newSize);
void onBadgeClose(); void onBadgeClose();
void onClearButton();
public: public:
const bool isMuc; const bool isMuc;
@ -121,7 +123,8 @@ protected:
MessageLine* line; MessageLine* line;
QScopedPointer<Ui::Conversation> m_ui; QScopedPointer<Ui::Conversation> m_ui;
KeyEnterReceiver ker; KeyEnterReceiver ker;
Resizer res; Resizer scrollResizeCatcher;
Resizer attachResizeCatcher;
VisibilityCatcher vis; VisibilityCatcher vis;
QString thread; QString thread;
QLabel* statusIcon; QLabel* statusIcon;