Skip to content

Commit

Permalink
Current version of Psi+ is 1.5.1867
Browse files Browse the repository at this point in the history
It is based on:
* psi: 4bb0335f
* plugins: c7a95ca
* psimedia: 478567e
* resources: c35f1e3
  • Loading branch information
tehnick committed May 10, 2024
1 parent 3c173f8 commit 715081c
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 24 deletions.
1 change: 0 additions & 1 deletion iris/src/xmpp/sasl/scramsha1response.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ QCA::SecureArray HMAC_SHA_1(const QCA::SecureArray &key, const QCA::SecureArray
SCRAMSHA1Response::SCRAMSHA1Response(const QByteArray &server_first_message, const QByteArray &password_in,
const QByteArray &client_first_message, const QString &salted_password_base64)
{
Q_UNUSED(rand);
QString pass_in = QString::fromUtf8(password_in);
QString pass_out;

Expand Down
2 changes: 1 addition & 1 deletion plugins/generic/juickplugin/juickplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ bool JuickPlugin::enable()
{
enabled = true;

QVariant v = psiOptions->getPluginOption(constVersionOpt, QVariant::Invalid);
QVariant v = psiOptions->getPluginOption(constVersionOpt, {});

// Проверяем, обновился ли плагин
if (!v.isValid() || v.toString() != constVersion) {
Expand Down
4 changes: 2 additions & 2 deletions src/contactmanager/contactmanagermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class ContactManagerModel::Private {

void contactAdded(const RosterItem &ri)
{
q->beginInsertRows({}, userList.size(), userList.size());
q->beginInsertRows({}, int(userList.size()), int(userList.size()));
userList.push_back(ri);
q->endInsertRows();
}
Expand Down Expand Up @@ -205,7 +205,7 @@ int ContactManagerModel::rowCount(const QModelIndex &parent) const
{
if (parent.isValid())
return 0;
return d->userList.size();
return int(d->userList.size());
}

int ContactManagerModel::columnCount(const QModelIndex &parent) const
Expand Down
2 changes: 1 addition & 1 deletion src/textutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ QString TextUtil::emoticonify(const QString &in)
if (!closest)
break;

p.putRich(QString("<icon name=\"%1\" text=\"%2\" min-height=\"1.2em\" max-height=\"2em\" type=\"smiley\">")
p.putRich(QString("<icon name=\"%1\" text=\"%2\" min-height=\"1em\" max-height=\"1.5em\" type=\"smiley\">")
.arg(TextUtil::escape(closest->name()), TextUtil::escape(str.mid(foundPos, foundLen))));
i = foundPos + foundLen;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/emojimodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ int EmojiModel::rowCount(const QModelIndex &parent) const
int sum = 0;
auto const &group = EmojiRegistry::instance().groups[id >> 24];
for (auto const &subGroup : group.subGroups) {
sum += subGroup.emojis.size();
sum += int(subGroup.emojis.size());
}
return sum;
}
Expand Down
17 changes: 11 additions & 6 deletions src/tools/globalshortcut/globalshortcutmanager_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,21 @@ class GlobalShortcutManager::KeyTrigger::Impl : public QWidget {

static bool convertKeySequence(const QKeySequence &ks, UINT *mod_, UINT *key_)
{
int code = ks[0];

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
auto modifiers = Qt::KeyboardModifiers(ks[0] & Qt::KeyboardModifierMask);
int code = modifiers & ~Qt::KeyboardModifierMask;
#else
auto modifiers = ks[0].keyboardModifiers();
int code = ks[0].key();
#endif
UINT mod = 0;
if (code & Qt::META)
if (modifiers & Qt::MetaModifier)
mod |= MOD_WIN;
if (code & Qt::SHIFT)
if (modifiers & Qt::ShiftModifier)
mod |= MOD_SHIFT;
if (code & Qt::CTRL)
if (modifiers & Qt::ControlModifier)
mod |= MOD_CONTROL;
if (code & Qt::ALT)
if (modifiers & Qt::AltModifier)
mod |= MOD_ALT;

UINT key = 0;
Expand Down
56 changes: 45 additions & 11 deletions src/widgets/psirichtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ int htmlSizeToPixels(const HtmlSize &size, const QTextCharFormat &format)
return pointToPixel(size.size);
}
if (size.unit == HtmlSize::Em) {
return int(size.size * pointToPixel(format.fontPointSize()) + 0.5);
auto fs = format.fontPointSize() ? format.fontPointSize() : format.font().pointSize();
return int(size.size * pointToPixel(fs) + 0.5);
}
return size.size;
}
Expand All @@ -102,21 +103,25 @@ int htmlSizeToPixels(const HtmlSize &size, const QTextCharFormat &format)
class TextIconFormat : public QTextCharFormat {
public:
TextIconFormat(const QString &iconName, const QString &text, std::optional<HtmlSize> width = {},
std::optional<HtmlSize> height = {}, std::optional<HtmlSize> maxWidth = {},
std::optional<HtmlSize> height = {}, std::optional<HtmlSize> minWidth = {},
std::optional<HtmlSize> minHeight = {}, std::optional<HtmlSize> maxWidth = {},
std::optional<HtmlSize> maxHeight = {}, std::optional<VerticalAlignment> valign = {});

enum Property {
IconName = QTextFormat::UserProperty + 1,
IconText = QTextFormat::UserProperty + 2,
IconWidth = QTextFormat::UserProperty + 3,
IconHeight = QTextFormat::UserProperty + 4,
IconMaxWidth = QTextFormat::UserProperty + 5,
IconMaxHeight = QTextFormat::UserProperty + 6
IconMinWidth = QTextFormat::UserProperty + 5,
IconMinHeight = QTextFormat::UserProperty + 6,
IconMaxWidth = QTextFormat::UserProperty + 7,
IconMaxHeight = QTextFormat::UserProperty + 8
};
};

TextIconFormat::TextIconFormat(const QString &iconName, const QString &text, std::optional<HtmlSize> width,
std::optional<HtmlSize> height, std::optional<HtmlSize> maxWidth,
std::optional<HtmlSize> height, std::optional<HtmlSize> minWidth,
std::optional<HtmlSize> minHeight, std::optional<HtmlSize> maxWidth,
std::optional<HtmlSize> maxHeight,
std::optional<QTextCharFormat::VerticalAlignment> valign) : QTextCharFormat()
{
Expand All @@ -129,13 +134,19 @@ TextIconFormat::TextIconFormat(const QString &iconName, const QString &text, std
QTextFormat::setProperty(IconWidth, QVariant::fromValue<HtmlSize>(*width));
}
if (height) {
QTextFormat::setProperty(IconWidth, QVariant::fromValue<HtmlSize>(*height));
QTextFormat::setProperty(IconHeight, QVariant::fromValue<HtmlSize>(*height));
}
if (minWidth) {
QTextFormat::setProperty(IconMinWidth, QVariant::fromValue<HtmlSize>(*minWidth));
}
if (minHeight) {
QTextFormat::setProperty(IconMinHeight, QVariant::fromValue<HtmlSize>(*minHeight));
}
if (maxWidth) {
QTextFormat::setProperty(IconWidth, QVariant::fromValue<HtmlSize>(*maxWidth));
QTextFormat::setProperty(IconMaxWidth, QVariant::fromValue<HtmlSize>(*maxWidth));
}
if (maxHeight) {
QTextFormat::setProperty(IconWidth, QVariant::fromValue<HtmlSize>(*maxHeight));
QTextFormat::setProperty(IconMaxHeight, QVariant::fromValue<HtmlSize>(*maxHeight));
}

if (valign) {
Expand Down Expand Up @@ -182,24 +193,36 @@ QSizeF TextIconHandler::intrinsicSize(QTextDocument *doc, int posInDocument, con

auto propWidth = charFormat.property(TextIconFormat::IconWidth);
auto propHeight = charFormat.property(TextIconFormat::IconHeight);
auto propMinWidth = charFormat.property(TextIconFormat::IconMinWidth);
auto propMinHeight = charFormat.property(TextIconFormat::IconMinHeight);
auto propMaxWidth = charFormat.property(TextIconFormat::IconMaxWidth);
auto propMaxHeight = charFormat.property(TextIconFormat::IconMaxHeight);

std::optional<int> width;
std::optional<int> height;
std::optional<int> minWidth;
std::optional<int> minHeight;
QSize maxSize { 20000, 20000 }; // should be enough fow a few decades

if (propMinWidth.isValid()) {
minWidth = htmlSizeToPixels(propMinWidth.value<HtmlSize>(), charFormat);
}
if (propMinHeight.isValid()) {
minHeight = htmlSizeToPixels(propMinHeight.value<HtmlSize>(), charFormat);
}
if (propMaxWidth.isValid()) {
maxSize.setWidth(htmlSizeToPixels(propMaxWidth.value<HtmlSize>(), charFormat));
}
if (propMaxHeight.isValid()) {
maxSize.setHeight(htmlSizeToPixels(propMaxHeight.value<HtmlSize>(), charFormat));
}
if (propWidth.isValid()) {
width = qMin(maxSize.width(), htmlSizeToPixels(propWidth.value<HtmlSize>(), charFormat));
int limitMin = minWidth ? *minWidth : 8;
width = qMax(qMin(maxSize.width(), htmlSizeToPixels(propWidth.value<HtmlSize>(), charFormat)), limitMin);
}
if (propHeight.isValid()) { // we want to scale ignoring aspect ratio
height = qMin(maxSize.height(), htmlSizeToPixels(propHeight.value<HtmlSize>(), charFormat));
int limitMin = minHeight ? *minHeight : 8;
height = qMax(qMin(maxSize.height(), htmlSizeToPixels(propHeight.value<HtmlSize>(), charFormat)), limitMin);
}

QSize ret;
Expand All @@ -224,6 +247,10 @@ QSizeF TextIconHandler::intrinsicSize(QTextDocument *doc, int posInDocument, con
ret = icon->size();
if (ret.width() > maxSize.width() || ret.height() > maxSize.height()) {
ret.scale(maxSize, Qt::KeepAspectRatio);
} else if (minWidth && ret.width() < *minWidth) {
ret.scale(QSize { *minWidth, maxSize.width() }, Qt::KeepAspectRatio);
} else if (minHeight && ret.height() < *minHeight) {
ret.scale(QSize { maxSize.width(), *minHeight }, Qt::KeepAspectRatio);
}
}
return ret;
Expand Down Expand Up @@ -399,6 +426,8 @@ static QString convertIconsToObjectReplacementCharacters(const QStringView &text

std::optional<HtmlSize> width;
std::optional<HtmlSize> height;
std::optional<HtmlSize> minWidth;
std::optional<HtmlSize> minHeight;
std::optional<HtmlSize> maxWidth;
std::optional<HtmlSize> maxHeight;
QString iconName;
Expand All @@ -419,6 +448,10 @@ static QString convertIconsToObjectReplacementCharacters(const QStringView &text
width = parseSize(match.capturedView(2));
} else if (match.capturedView(1) == QLatin1String("height")) {
height = parseSize(match.capturedView(2));
} else if (match.capturedView(1) == QLatin1String("min-width")) {
minWidth = parseSize(match.capturedView(2));
} else if (match.capturedView(1) == QLatin1String("min-height")) {
minHeight = parseSize(match.capturedView(2));
} else if (match.capturedView(1) == QLatin1String("max-width")) {
maxWidth = parseSize(match.capturedView(2));
} else if (match.capturedView(1) == QLatin1String("max-height")) {
Expand All @@ -442,7 +475,8 @@ static QString convertIconsToObjectReplacementCharacters(const QStringView &text

if (!iconName.isEmpty()) {
queue->enqueue(new TextIconFormat(iconName, iconText, std::move(width), std::move(height),
std::move(maxWidth), std::move(maxHeight), std::move(valign)));
std::move(minWidth), std::move(minHeight), std::move(maxWidth),
std::move(maxHeight), std::move(valign)));
result += QChar::ObjectReplacementCharacter;
}

Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.1865 (2024-05-10, f9245654)
1.5.1867 (2024-05-10, 4bb0335f)

0 comments on commit 715081c

Please sign in to comment.