1
0
forked from blue/squawk

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);
}
} 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";
}
} 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";
}
}
}
} else {
emit onFileUploadError(data.getId(), "Account is offline or reconnecting");
qDebug() << "An attempt to send message with not connected account " << name << ", skipping";
}
}
@ -1639,6 +1642,7 @@ void Core::Account::onUploadSlotRequestFailed(const QXmppHttpUploadRequestIq& re
} else {
const std::pair<QString, Shared::Message>& pair = uploadingSlotsQueue.front();
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) {
um->requestUploadSlot(uploadingSlotsQueue.front().first);

View File

@ -118,6 +118,7 @@ signals:
void removeRoomParticipant(const QString& jid, const QString& nickName);
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 uploadFileError(const QString& messageId, const QString& error);
private:
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::uploadFileError, this, &Squawk::uploadFileError);
QMap<QString, QVariant> map = {
{"login", login},
{"server", server},

View File

@ -5,77 +5,92 @@
<name>Account</name>
<message>
<location filename="../ui/widgets/account.ui" line="14"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="127"/>
<source>Account</source>
<translatorcomment>Заголовок окна</translatorcomment>
<translation>Учетная запись</translation>
</message>
<message>
<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>
<translation>Имя пользователя Вашей учетной записи</translation>
</message>
<message>
<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>
<translation>ivan_ivanov1987</translation>
</message>
<message>
<location filename="../ui/widgets/account.ui" line="50"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="132"/>
<source>Server</source>
<translation>Сервер</translation>
</message>
<message>
<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>
<translation>Адресс сервера вашей учетной записи (выглядит как 404.city или macaw.me)</translation>
</message>
<message>
<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>
<translation>macaw.me</translation>
</message>
<message>
<location filename="../ui/widgets/account.ui" line="67"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="137"/>
<source>Login</source>
<translation>Имя учетной записи</translation>
</message>
<message>
<location filename="../ui/widgets/account.ui" line="74"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="138"/>
<source>Password</source>
<translation>Пароль</translation>
</message>
<message>
<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>
<translation>Пароль вашей учетной записи</translation>
</message>
<message>
<location filename="../ui/widgets/account.ui" line="103"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="145"/>
<source>Name</source>
<translation>Имя</translation>
</message>
<message>
<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>
<translation>Просто имя, то как Вы называете свою учетную запись, может быть любым</translation>
</message>
<message>
<location filename="../ui/widgets/account.ui" line="113"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="149"/>
<source>John</source>
<translation>Иван</translation>
</message>
<message>
<location filename="../ui/widgets/account.ui" line="120"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="150"/>
<source>Resource</source>
<translation>Ресурс</translation>
</message>
<message>
<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>
<translation>Имя этой программы для ваших контактов, может быть &quot;Home&quot; или &quot;Phone&quot;</translation>
</message>
<message>
<location filename="../ui/widgets/account.ui" line="130"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="154"/>
<source>QXmpp</source>
<translatorcomment>Ресурс по умолчанию</translatorcomment>
<translation>QXmpp</translation>
@ -85,31 +100,37 @@
<name>Accounts</name>
<message>
<location filename="../ui/widgets/accounts.ui" line="14"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="108"/>
<source>Accounts</source>
<translation>Учетные записи</translation>
</message>
<message>
<location filename="../ui/widgets/accounts.ui" line="45"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="109"/>
<source>Delete</source>
<translation>Удалить</translation>
</message>
<message>
<location filename="../ui/widgets/accounts.ui" line="86"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="110"/>
<source>Add</source>
<translation>Добавить</translation>
</message>
<message>
<location filename="../ui/widgets/accounts.ui" line="96"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="111"/>
<source>Edit</source>
<translation>Редактировать</translation>
</message>
<message>
<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>
<translation>Изменить пароль</translation>
</message>
<message>
<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="128"/>
<source>Connect</source>
@ -125,11 +146,12 @@
<name>Conversation</name>
<message>
<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>
<translation>Введите сообщение...</translation>
</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>
<translation>Выберите файл для отправки</translation>
</message>
@ -281,52 +303,62 @@
<name>JoinConference</name>
<message>
<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>
<translatorcomment>Заголовок окна</translatorcomment>
<translation>Присоединиться к новой беседе</translation>
</message>
<message>
<location filename="../ui/widgets/joinconference.ui" line="22"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="117"/>
<source>JID</source>
<translation>JID</translation>
</message>
<message>
<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>
<translation>Jabber-идентификатор беседы</translation>
</message>
<message>
<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>
<translation>identifier@conference.server.org</translation>
</message>
<message>
<location filename="../ui/widgets/joinconference.ui" line="39"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="122"/>
<source>Account</source>
<translation>Учетная запись</translation>
</message>
<message>
<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>
<translation>Автовход</translation>
</message>
<message>
<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>
<translation>Если стоит галочка Squawk автоматически присоединится к этой беседе при подключении</translation>
</message>
<message>
<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>
<translation>Псевдоним</translation>
</message>
<message>
<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>
<translation>Ваш псевдоним в этой беседе, если оставите это поле пустым - будет использовано имя Вашей учетной записи</translation>
</message>
<message>
<location filename="../ui/widgets/joinconference.ui" line="76"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="132"/>
<source>John</source>
<translation>Ivan</translation>
</message>
@ -334,26 +366,58 @@
<context>
<name>Message</name>
<message>
<location filename="../ui/utils/message.cpp" line="119"/>
<source>Download</source>
<translation>Скачать</translation>
</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
You can try again</source>
<translation>Ошибка загрузки файла: %1
<translation>Ошибка скачивания файла:
%1
Вы можете попробовать снова</translation>
</message>
<message>
<location filename="../ui/utils/message.cpp" line="125"/>
<source>%1 is offering you to download a file</source>
<translation>%1 предлагает Вам скачать файл</translation>
</message>
<message>
<location filename="../ui/utils/message.cpp" line="190"/>
<source>Open</source>
<translation>Открыть</translation>
<location filename="../ui/utils/messageline.cpp" line="336"/>
<source>Uploading...</source>
<translation>Загружается...</translation>
</message>
</context>
<context>
@ -470,48 +534,57 @@ You can try again</source>
<name>NewContact</name>
<message>
<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>
<translatorcomment>Заголовок окна</translatorcomment>
<translation>Добавление нового контакта</translation>
</message>
<message>
<location filename="../ui/widgets/newcontact.ui" line="22"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="104"/>
<source>Account</source>
<translation>Учетная запись</translation>
</message>
<message>
<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>
<translation>Учетная запись для которой будет добавлен контакт</translation>
</message>
<message>
<location filename="../ui/widgets/newcontact.ui" line="36"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="108"/>
<source>JID</source>
<translation>JID</translation>
</message>
<message>
<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>
<translation>Jabber-идентификатор нового контакта</translation>
</message>
<message>
<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>
<translatorcomment>Placeholder поля ввода JID</translatorcomment>
<translation>name@server.dmn</translation>
</message>
<message>
<location filename="../ui/widgets/newcontact.ui" line="53"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="113"/>
<source>Name</source>
<translation>Имя</translation>
</message>
<message>
<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>
<translation>То, как будет подписан контакт в вашем списке контактов (не обязательно)</translation>
</message>
<message>
<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>
<translation>Иван Иванов</translation>
</message>
@ -520,36 +593,43 @@ You can try again</source>
<name>Squawk</name>
<message>
<location filename="../ui/squawk.ui" line="14"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="137"/>
<source>squawk</source>
<translation>Squawk</translation>
</message>
<message>
<location filename="../ui/squawk.ui" line="78"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="143"/>
<source>Settings</source>
<translation>Настройки</translation>
</message>
<message>
<location filename="../ui/squawk.ui" line="84"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="144"/>
<source>Squawk</source>
<translation>Squawk</translation>
</message>
<message>
<location filename="../ui/squawk.ui" line="99"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="138"/>
<source>Accounts</source>
<translation>Учетные записи</translation>
</message>
<message>
<location filename="../ui/squawk.ui" line="108"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="139"/>
<source>Quit</source>
<translation>Выйти</translation>
</message>
<message>
<location filename="../ui/squawk.ui" line="120"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="140"/>
<source>Add contact</source>
<translation>Добавить контакт</translation>
</message>
<message>
<location filename="../ui/squawk.ui" line="132"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="141"/>
<source>Add conference</source>
<translation>Присоединиться к беседе</translation>
</message>
@ -559,52 +639,52 @@ You can try again</source>
<translation>Список контактов</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="549"/>
<location filename="../ui/squawk.cpp" line="558"/>
<source>Disconnect</source>
<translation>Отключить</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="555"/>
<location filename="../ui/squawk.cpp" line="564"/>
<source>Connect</source>
<translation>Подключить</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="561"/>
<location filename="../ui/squawk.cpp" line="659"/>
<location filename="../ui/squawk.cpp" line="570"/>
<location filename="../ui/squawk.cpp" line="668"/>
<source>VCard</source>
<translation>Карточка</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="565"/>
<location filename="../ui/squawk.cpp" line="663"/>
<location filename="../ui/squawk.cpp" line="703"/>
<location filename="../ui/squawk.cpp" line="574"/>
<location filename="../ui/squawk.cpp" line="672"/>
<location filename="../ui/squawk.cpp" line="712"/>
<source>Remove</source>
<translation>Удалить</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="577"/>
<location filename="../ui/squawk.cpp" line="586"/>
<source>Open dialog</source>
<translation>Открыть диалог</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="587"/>
<location filename="../ui/squawk.cpp" line="684"/>
<location filename="../ui/squawk.cpp" line="596"/>
<location filename="../ui/squawk.cpp" line="693"/>
<source>Unsubscribe</source>
<translation>Отписаться</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="597"/>
<location filename="../ui/squawk.cpp" line="693"/>
<location filename="../ui/squawk.cpp" line="606"/>
<location filename="../ui/squawk.cpp" line="702"/>
<source>Subscribe</source>
<translation>Подписаться</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="608"/>
<location filename="../ui/squawk.cpp" line="617"/>
<source>Rename</source>
<translation>Переименовать</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="621"/>
<location filename="../ui/squawk.cpp" line="630"/>
<source>Input new name for %1
or leave it empty for the contact
to be displayed as %1</source>
@ -614,47 +694,47 @@ to be displayed as %1</source>
%1</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="622"/>
<location filename="../ui/squawk.cpp" line="631"/>
<source>Renaming %1</source>
<translation>Назначение имени контакту %1</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="628"/>
<location filename="../ui/squawk.cpp" line="637"/>
<source>Groups</source>
<translation>Группы</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="643"/>
<location filename="../ui/squawk.cpp" line="652"/>
<source>New group</source>
<translation>Создать новую группу</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="653"/>
<location filename="../ui/squawk.cpp" line="662"/>
<source>New group name</source>
<translation>Имя группы</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="654"/>
<location filename="../ui/squawk.cpp" line="663"/>
<source>Add %1 to a new group</source>
<translation>Добавление %1 в новую группу</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="675"/>
<location filename="../ui/squawk.cpp" line="684"/>
<source>Open conversation</source>
<translation>Открыть окно беседы</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="780"/>
<location filename="../ui/squawk.cpp" line="789"/>
<source>%1 account card</source>
<translation>Карточка учетной записи %1</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="782"/>
<location filename="../ui/squawk.cpp" line="791"/>
<source>%1 contact card</source>
<translation>Карточка контакта %1</translation>
</message>
<message>
<location filename="../ui/squawk.cpp" line="794"/>
<location filename="../ui/squawk.cpp" line="803"/>
<source>Downloading vCard</source>
<translation>Получение карточки</translation>
</message>
@ -663,119 +743,145 @@ to be displayed as %1</source>
<name>VCard</name>
<message>
<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>
<translation>Не обновлялось</translation>
</message>
<message>
<location filename="../ui/widgets/vcard/vcard.ui" line="100"/>
<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>
<translation>Общее</translation>
</message>
<message>
<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>
<translation>Место работы</translation>
</message>
<message>
<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>
<translation>Среднее имя</translation>
</message>
<message>
<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>
<translation>Имя</translation>
</message>
<message>
<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>
<translation>Фамилия</translation>
</message>
<message>
<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>
<translation>Псевдоним</translation>
</message>
<message>
<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>
<translation>Дата рождения</translation>
</message>
<message>
<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>
<translation>Название организации</translation>
</message>
<message>
<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>
<translation>Отдел</translation>
</message>
<message>
<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>
<translation>Профессия</translation>
</message>
<message>
<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>
<translation>Наименование должности</translation>
</message>
<message>
<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>
<translation>Полное имя</translation>
</message>
<message>
<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>
<translation>Личная информация</translation>
</message>
<message>
<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>
<translation>Адреса</translation>
</message>
<message>
<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>
<translation>Адреса электронной почты</translation>
</message>
<message>
<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>
<translation>Номера телефонов</translation>
</message>
<message>
<location filename="../ui/widgets/vcard/vcard.ui" line="522"/>
<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>
<translation>Контактная информация</translation>
</message>
<message>
<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>
<translation>Jabber ID</translation>
</message>
<message>
<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>
<translation>Веб сайт</translation>
</message>
<message>
<location filename="../ui/widgets/vcard/vcard.ui" line="798"/>
<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>
<translation>Описание</translation>
</message>
<message>
<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>
<translation>Установить иконку</translation>
</message>
<message>
<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>
<translation>Убрать иконку</translation>
</message>

View File

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

View File

@ -49,7 +49,7 @@ public:
QString getFileUrl() 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 hideComment();
void showFile(const QString& path);

View File

@ -253,8 +253,9 @@ void MessageLine::responseLocalFile(const QString& messageId, const QString& pat
}
}
} else {
if (uItr != uploading.end()) {
itr->second->addButton(QIcon::fromTheme("download"), tr("Download"));
if (uItr == uploading.end()) {
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"));
} else {
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"));
}
} 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);
}
}
@ -331,7 +333,7 @@ void MessageLine::appendMessageWithUpload(const Shared::Message& msg, const QStr
Message* ui = messageIndex.find(id)->second;
connect(ui, &Message::buttonClicked, this, &MessageLine::onUpload); //this is in case of retry;
ui->setProgress(0);
ui->showComment("Uploading...");
ui->showComment(tr("Uploading..."));
uploading.insert(std::make_pair(id, ui));
uploadPaths.insert(std::make_pair(id, path));
emit uploadFile(msg, path);

View File

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

View File

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

View File

@ -36,7 +36,8 @@ Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, co
line(new MessageLine(muc)),
m_ui(new Ui::Conversation()),
ker(),
res(),
scrollResizeCatcher(),
attachResizeCatcher(),
vis(),
thread(),
statusIcon(0),
@ -60,7 +61,8 @@ Conversation::Conversation(bool muc, const QString& mJid, const QString mRes, co
statusLabel = m_ui->statusLabel;
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::hidden, this, &Conversation::onScrollResize);
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::requestLocalFile, this, &Conversation::requestLocalFile);
connect(m_ui->attachButton, &QPushButton::clicked, this, &Conversation::onAttach);
connect(m_ui->clearButton, &QPushButton::clicked, this, &Conversation::onClearButton);
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->setAutoFillBackground(true);
connect(vs, &QScrollBar::valueChanged, this, &Conversation::onSliderValueChanged);
m_ui->scrollArea->installEventFilter(&res);
m_ui->scrollArea->installEventFilter(&scrollResizeCatcher);
m_ui->filesPanel->installEventFilter(&attachResizeCatcher);
applyVisualEffects();
}
@ -181,6 +185,10 @@ void Conversation::onEnterPressed()
{
QString body(m_ui->messageEditor->toPlainText());
if (body.size() > 0) {
m_ui->messageEditor->clear();
handleSendMessage(body);
}
if (filesToAttach.size() > 0) {
for (Badge* badge : filesToAttach) {
Shared::Message msg;
@ -196,17 +204,9 @@ void Conversation::onEnterPressed()
msg.setOutgoing(true);
msg.generateRandomId();
msg.setCurrentTime();
if (body.size() > 0) {
msg.setBody(body);
}
line->appendMessageWithUpload(msg, badge->id);
}
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);
}
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)
{
if (event->type() == QEvent::Show) {

View File

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