diff --git a/core/account.cpp b/core/account.cpp index c238a23..492ebdc 100644 --- a/core/account.cpp +++ b/core/account.cpp @@ -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& 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); diff --git a/core/account.h b/core/account.h index 38631af..ff77455 100644 --- a/core/account.h +++ b/core/account.h @@ -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 headers); + void uploadFileError(const QString& messageId, const QString& error); private: QString name; diff --git a/core/squawk.cpp b/core/squawk.cpp index 1842367..7ca41e3 100644 --- a/core/squawk.cpp +++ b/core/squawk.cpp @@ -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 map = { {"login", login}, {"server", server}, diff --git a/translations/squawk.ru.ts b/translations/squawk.ru.ts index e7bae69..412b6d8 100644 --- a/translations/squawk.ru.ts +++ b/translations/squawk.ru.ts @@ -5,77 +5,92 @@ Account + Account Заголовок окна Учетная запись + Your account login Имя пользователя Вашей учетной записи + john_smith1987 ivan_ivanov1987 + Server Сервер + A server address of your account. Like 404.city or macaw.me Адресс сервера вашей учетной записи (выглядит как 404.city или macaw.me) + macaw.me macaw.me + Login Имя учетной записи + Password Пароль + Password of your account Пароль вашей учетной записи + Name Имя + Just a name how would you call this account, doesn't affect anything Просто имя, то как Вы называете свою учетную запись, может быть любым + John Иван + Resource Ресурс + A resource name like "Home" or "Work" Имя этой программы для ваших контактов, может быть "Home" или "Phone" + QXmpp Ресурс по умолчанию QXmpp @@ -85,31 +100,37 @@ Accounts + Accounts Учетные записи + Delete Удалить + Add Добавить + Edit Редактировать + Change password Изменить пароль + Connect @@ -125,11 +146,12 @@ Conversation + Type your message here... Введите сообщение... - + Chose a file to send Выберите файл для отправки @@ -281,52 +303,62 @@ JoinConference + Join new conference Заголовок окна Присоединиться к новой беседе + JID JID + Room JID Jabber-идентификатор беседы + identifier@conference.server.org identifier@conference.server.org + Account Учетная запись + Join on login Автовход + If checked Squawk will try to join this conference on login Если стоит галочка Squawk автоматически присоединится к этой беседе при подключении + Nick name Псевдоним + Your nick name for that conference. If you leave this field empty your account name will be used as a nick name Ваш псевдоним в этой беседе, если оставите это поле пустым - будет использовано имя Вашей учетной записи + John Ivan @@ -334,26 +366,58 @@ Message - Download Скачать - + + Open + Открыть + + + + MessageLine + + + Downloading... + Скачивается... + + + + + Download + Скачать + + + + Push the button to daownload the file + Нажмите на кнопку что бы загрузить файл + + + + Error uploading file: %1 +You can try again + Ошибка загрузки файла на сервер: +%1 +Для того, что бы попробовать снова нажмите на кнопку + + + + Upload + Загрузить + + + Error downloading file: %1 You can try again - Ошибка загрузки файла: %1 + Ошибка скачивания файла: +%1 Вы можете попробовать снова - - %1 is offering you to download a file - %1 предлагает Вам скачать файл - - - - Open - Открыть + + Uploading... + Загружается... @@ -470,48 +534,57 @@ You can try again NewContact + Add new contact Заголовок окна Добавление нового контакта + Account Учетная запись + An account that is going to have new contact Учетная запись для которой будет добавлен контакт + JID JID + Jabber id of your new contact Jabber-идентификатор нового контакта + name@server.dmn Placeholder поля ввода JID name@server.dmn + Name Имя + The way this new contact will be labeled in your roster (optional) То, как будет подписан контакт в вашем списке контактов (не обязательно) + John Smith Иван Иванов @@ -520,36 +593,43 @@ You can try again Squawk + squawk Squawk + Settings Настройки + Squawk Squawk + Accounts Учетные записи + Quit Выйти + Add contact Добавить контакт + Add conference Присоединиться к беседе @@ -559,52 +639,52 @@ You can try again Список контактов - + Disconnect Отключить - + Connect Подключить - - + + VCard Карточка - - - + + + Remove Удалить - + Open dialog Открыть диалог - - + + Unsubscribe Отписаться - - + + Subscribe Подписаться - + Rename Переименовать - + Input new name for %1 or leave it empty for the contact to be displayed as %1 @@ -614,47 +694,47 @@ to be displayed as %1 %1 - + Renaming %1 Назначение имени контакту %1 - + Groups Группы - + New group Создать новую группу - + New group name Имя группы - + Add %1 to a new group Добавление %1 в новую группу - + Open conversation Открыть окно беседы - + %1 account card Карточка учетной записи %1 - + %1 contact card Карточка контакта %1 - + Downloading vCard Получение карточки @@ -663,119 +743,145 @@ to be displayed as %1 VCard + Received 12.07.2007 at 17.35 Не обновлялось + + General Общее + Organization Место работы + Middle name Среднее имя + First name Имя + Last name Фамилия + Nick name Псевдоним + Birthday Дата рождения + Organization name Название организации + Unit / Department Отдел + Role / Profession Профессия + Job title Наименование должности + Full name Полное имя + Personal information Личная информация + Addresses Адреса + E-Mail addresses Адреса электронной почты + Phone numbers Номера телефонов + + Contact Контактная информация + Jabber ID Jabber ID + Web site Веб сайт + + Description Описание + Set avatar Установить иконку + Clear avatar Убрать иконку diff --git a/ui/utils/message.cpp b/ui/utils/message.cpp index d826436..db517e9 100644 --- a/ui/utils/message.cpp +++ b/ui/utils/message.cpp @@ -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("" + msg.getOutOfBandUrl() + ""); + button->setToolTip(tooltip); connect(button, &QPushButton::clicked, this, &Message::buttonClicked); bodyLayout->insertWidget(2, button); hasButton = true; diff --git a/ui/utils/message.h b/ui/utils/message.h index 4147178..6bea433 100644 --- a/ui/utils/message.h +++ b/ui/utils/message.h @@ -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); diff --git a/ui/utils/messageline.cpp b/ui/utils/messageline.cpp index c17baca..dc3eeda 100644 --- a/ui/utils/messageline.cpp +++ b/ui/utils/messageline.cpp @@ -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"), "" + msg.getOutOfBandUrl() + ""); 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"), "" + msg.getOutOfBandUrl() + ""); 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); diff --git a/ui/utils/resizer.cpp b/ui/utils/resizer.cpp index 45a21e8..8691400 100644 --- a/ui/utils/resizer.cpp +++ b/ui/utils/resizer.cpp @@ -27,7 +27,8 @@ QObject(parent) bool Resizer::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::Resize) { - emit resized(); + QResizeEvent* ev = static_cast(event); + emit resized(ev->oldSize(), ev->size()); } return false; diff --git a/ui/utils/resizer.h b/ui/utils/resizer.h index 85fc97e..735b2fb 100644 --- a/ui/utils/resizer.h +++ b/ui/utils/resizer.h @@ -22,6 +22,7 @@ #include #include #include +#include /** * @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 diff --git a/ui/widgets/conversation.cpp b/ui/widgets/conversation.cpp index b18d3b2..07a160f 100644 --- a/ui/widgets/conversation.cpp +++ b/ui/widgets/conversation.cpp @@ -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(&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 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) { diff --git a/ui/widgets/conversation.h b/ui/widgets/conversation.h index 386e20a..cf9585b 100644 --- a/ui/widgets/conversation.h +++ b/ui/widgets/conversation.h @@ -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 m_ui; KeyEnterReceiver ker; - Resizer res; + Resizer scrollResizeCatcher; + Resizer attachResizeCatcher; VisibilityCatcher vis; QString thread; QLabel* statusIcon;