forked from blue/squawk
Compare commits
4 Commits
master
...
feat/adapt
Author | SHA1 | Date | |
---|---|---|---|
faa7d396a5 | |||
c55b7c6baf | |||
6764d8ea11 | |||
5fbb96618f |
@ -19,8 +19,8 @@ if(NOT CMAKE_BUILD_TYPE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra")
|
set(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -Wextra")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
||||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
|
||||||
message("Build type: ${CMAKE_BUILD_TYPE}")
|
message("Build type: ${CMAKE_BUILD_TYPE}")
|
||||||
@ -42,6 +42,7 @@ else (WIN32)
|
|||||||
list(APPEND squawk_SRC signalcatcher.cpp)
|
list(APPEND squawk_SRC signalcatcher.cpp)
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
|
|
||||||
|
|
||||||
set(squawk_HEAD
|
set(squawk_HEAD
|
||||||
exception.h
|
exception.h
|
||||||
signalcatcher.h
|
signalcatcher.h
|
||||||
@ -55,29 +56,25 @@ set(squawk_HEAD
|
|||||||
)
|
)
|
||||||
|
|
||||||
configure_file(resources/images/logo.svg squawk.svg COPYONLY)
|
configure_file(resources/images/logo.svg squawk.svg COPYONLY)
|
||||||
configure_file(squawk.rc squawk.rc COPYONLY)
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
execute_process(COMMAND magick convert -background none -size 48x48 squawk.svg squawk48.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
set(CONVERT_BIN magick convert)
|
||||||
execute_process(COMMAND magick convert -background none -size 64x64 squawk.svg squawk64.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
else(WIN32)
|
||||||
execute_process(COMMAND magick convert -background none -size 128x128 squawk.svg squawk128.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
set(CONVERT_BIN convert)
|
||||||
execute_process(COMMAND magick convert -background none -size 256x256 squawk.svg squawk256.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
endif(WIN32)
|
||||||
execute_process(COMMAND magick convert squawk48.png squawk64.png squawk256.png squawk.ico WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
|
execute_process(COMMAND ${CONVERT_BIN} -background none -size 48x48 squawk.svg squawk48.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
execute_process(COMMAND ${CONVERT_BIN} -background none -size 64x64 squawk.svg squawk64.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
execute_process(COMMAND ${CONVERT_BIN} -background none -size 128x128 squawk.svg squawk128.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
execute_process(COMMAND ${CONVERT_BIN} -background none -size 256x256 squawk.svg squawk256.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
execute_process(COMMAND ${CONVERT_BIN} squawk48.png squawk64.png squawk256.png squawk.ico WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
set(SQUAWK_WIN_RC "${CMAKE_CURRENT_BINARY_DIR}/squawk.rc")
|
set(SQUAWK_WIN_RC "${CMAKE_CURRENT_BINARY_DIR}/squawk.rc")
|
||||||
else (WIN32)
|
endif(WIN32)
|
||||||
execute_process(COMMAND convert -background none -size 48x48 squawk.svg squawk48.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
execute_process(COMMAND convert -background none -size 64x64 squawk.svg squawk64.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
execute_process(COMMAND convert -background none -size 128x128 squawk.svg squawk128.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
execute_process(COMMAND convert -background none -size 256x256 squawk.svg squawk256.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
endif (WIN32)
|
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/icns.iconset")
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/icns.iconset")
|
||||||
execute_process(COMMAND which convert WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} RESULT_VARIABLE ret)
|
execute_process(COMMAND convert -background none -size 16x16 squawk.svg icns.iconset/icon_16x16.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
message("AAA ${ret}")
|
|
||||||
execute_process(COMMAND echo $PATH WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} RESULT_VARIABLE ret)
|
|
||||||
message("AAA ${ret} $ENV{PATH}")
|
|
||||||
execute_process(COMMAND convert -background none -size 16x16 squawk.svg icns.iconset/icon_16x16.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} RESULT_VARIABLE ret)
|
|
||||||
message("AAA ${ret}")
|
|
||||||
execute_process(COMMAND convert -background none -resize !32x32 squawk.svg "icns.iconset/icon_16x16@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
execute_process(COMMAND convert -background none -resize !32x32 squawk.svg "icns.iconset/icon_16x16@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
execute_process(COMMAND convert -background none -resize !32x32 squawk.svg "icns.iconset/icon_32x32.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
execute_process(COMMAND convert -background none -resize !32x32 squawk.svg "icns.iconset/icon_32x32.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
execute_process(COMMAND convert -background none -resize !64x64 squawk.svg "icns.iconset/icon_32x32@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
execute_process(COMMAND convert -background none -resize !64x64 squawk.svg "icns.iconset/icon_32x32@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
@ -134,7 +131,13 @@ if (WITH_KWALLET)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(squawk WIN32 ${squawk_SRC} ${squawk_HEAD} ${RCC} ${SQUAWK_WIN_RC} ${APP_ICON_MACOSX})
|
set(WIN32_FLAG "")
|
||||||
|
if (WIN32)
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
|
set(WIN32_FLAG WIN32)
|
||||||
|
endif()
|
||||||
|
endif(WIN32)
|
||||||
|
add_executable(squawk ${WIN32_FLAG} ${squawk_SRC} ${squawk_HEAD} ${RCC} ${SQUAWK_WIN_RC} ${APP_ICON_MACOSX})
|
||||||
target_link_libraries(squawk Qt5::Widgets)
|
target_link_libraries(squawk Qt5::Widgets)
|
||||||
|
|
||||||
add_subdirectory(ui)
|
add_subdirectory(ui)
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- QT 5.12 *(lower versions might work but it wasn't tested)*
|
- QT 5.12 *(lower versions might work but it wasn't tested)*
|
||||||
- uuid _(usually included in some other package, for example it's ***libutil-linux*** in archlinux)_
|
|
||||||
- lmdb
|
- lmdb
|
||||||
- CMake 3.0 or higher
|
- CMake 3.0 or higher
|
||||||
- qxmpp 1.1.0 or higher
|
- qxmpp 1.1.0 or higher
|
||||||
@ -44,7 +43,7 @@ $ git clone https://git.macaw.me/blue/squawk
|
|||||||
$ cd squawk
|
$ cd squawk
|
||||||
$ mkdir build
|
$ mkdir build
|
||||||
$ cd build
|
$ cd build
|
||||||
$ cmake ..
|
$ cmake .. [-DLMDB_DIR:PATH=/path/to/lmdb]
|
||||||
$ cmake --build .
|
$ cmake --build .
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -57,7 +56,7 @@ $ git clone --recurse-submodules https://git.macaw.me/blue/squawk
|
|||||||
$ cd squawk
|
$ cd squawk
|
||||||
$ mkdir build
|
$ mkdir build
|
||||||
$ cd build
|
$ cd build
|
||||||
$ cmake .. -D SYSTEM_QXMPP=False
|
$ cmake .. -D SYSTEM_QXMPP=False [-DLMDB_DIR:PATH=/path/to/lmdb]
|
||||||
$ cmake --build .
|
$ cmake --build .
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -8,11 +8,18 @@ find_package(Qt5Gui CONFIG REQUIRED)
|
|||||||
find_package(Qt5Network CONFIG REQUIRED)
|
find_package(Qt5Network CONFIG REQUIRED)
|
||||||
find_package(Qt5Xml CONFIG REQUIRED)
|
find_package(Qt5Xml CONFIG REQUIRED)
|
||||||
|
|
||||||
find_path(LMDB_INCLUDE_DIR NAMES lmdb.h PATHS "${LMDB_DIR}/include")
|
# Find LMDB from system or ${LMDB_DIR}
|
||||||
set(LMDB_LIBRARIES "${LMDB_DIR}/lib/liblmdb.a" )
|
find_path(LMDB_INCLUDE_DIR NAMES lmdb.h PATHS "${LMDB_DIR}/include")
|
||||||
|
|
||||||
message(${LMDB_INCLUDE_DIR})
|
if (UNIX AND NOT APPLE)
|
||||||
message(${LMDB_LIBRARIES})
|
# Linux
|
||||||
|
find_library(sudo rLMDB_LIBRARIES NAMES liblmdb.a liblmdb.so PATHS ${LMDB_DIR})
|
||||||
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
else (UNIX AND NOT APPLE)
|
||||||
|
# Windows / macOS: LMDB_DIR has to be specified
|
||||||
|
set(LMDB_LIBRARIES "${LMDB_DIR}/lib/liblmdb.a")
|
||||||
|
endif (UNIX AND NOT APPLE)
|
||||||
|
|
||||||
set(squawkCORE_SRC
|
set(squawkCORE_SRC
|
||||||
squawk.cpp
|
squawk.cpp
|
||||||
@ -46,8 +53,13 @@ target_link_libraries(squawkCORE Qt5::Network)
|
|||||||
target_link_libraries(squawkCORE Qt5::Gui)
|
target_link_libraries(squawkCORE Qt5::Gui)
|
||||||
target_link_libraries(squawkCORE Qt5::Xml)
|
target_link_libraries(squawkCORE Qt5::Xml)
|
||||||
target_link_libraries(squawkCORE qxmpp)
|
target_link_libraries(squawkCORE qxmpp)
|
||||||
# target_link_libraries(squawkCORE lmdb)
|
|
||||||
target_link_libraries(squawkCORE ${LMDB_LIBRARIES})
|
target_link_libraries(squawkCORE ${LMDB_LIBRARIES})
|
||||||
|
if (UNIX AND NOT APPLE)
|
||||||
|
# Linux
|
||||||
|
target_link_libraries(squawkCORE Threads::Threads)
|
||||||
|
endif (UNIX AND NOT APPLE)
|
||||||
|
|
||||||
target_link_libraries(squawkCORE simpleCrypt)
|
target_link_libraries(squawkCORE simpleCrypt)
|
||||||
if (WITH_KWALLET)
|
if (WITH_KWALLET)
|
||||||
target_link_libraries(squawkCORE kwalletPSE)
|
target_link_libraries(squawkCORE kwalletPSE)
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include "account.h"
|
#include "account.h"
|
||||||
#include <QXmppMessage.h>
|
#include <QXmppMessage.h>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include "shared/utils.h"
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
@ -406,13 +405,9 @@ void Core::Account::sendMessage(const Shared::Message& data) {
|
|||||||
void Core::Account::sendMessage(const Shared::Message& data, const QString& path) {
|
void Core::Account::sendMessage(const Shared::Message& data, const QString& path) {
|
||||||
mh->sendMessage(data, path);}
|
mh->sendMessage(data, path);}
|
||||||
|
|
||||||
void Core::Account::onMamMessageReceived(const QString& queryId, const QXmppMessage& msgConst)
|
void Core::Account::onMamMessageReceived(const QString& queryId, const QXmppMessage& msg)
|
||||||
{
|
{
|
||||||
QXmppMessage msg(msgConst);
|
if (msg.id().size() > 0 && (msg.body().size() > 0 || msg.outOfBandUrl().size() > 0)) {
|
||||||
if (msg.id().size() == 0) {
|
|
||||||
msg.setId(Shared::generateUUID() + QStringLiteral("-squawkgenerated"));
|
|
||||||
}
|
|
||||||
if ((msg.body().size() > 0 || msg.outOfBandUrl().size() > 0)) {
|
|
||||||
std::map<QString, QString>::const_iterator itr = archiveQueries.find(queryId);
|
std::map<QString, QString>::const_iterator itr = archiveQueries.find(queryId);
|
||||||
if (itr != archiveQueries.end()) {
|
if (itr != archiveQueries.end()) {
|
||||||
QString jid = itr->second;
|
QString jid = itr->second;
|
||||||
|
@ -58,7 +58,7 @@ void Core::Archive::open(const QString& account)
|
|||||||
}
|
}
|
||||||
|
|
||||||
mdb_env_set_maxdbs(environment, 5);
|
mdb_env_set_maxdbs(environment, 5);
|
||||||
mdb_env_set_mapsize(environment, 16UL * 1024UL * 1024UL);
|
mdb_env_set_mapsize(environment, 512UL * 1024UL * 1024UL);
|
||||||
mdb_env_open(environment, path.toStdString().c_str(), 0, 0664);
|
mdb_env_open(environment, path.toStdString().c_str(), 0, 0664);
|
||||||
|
|
||||||
MDB_txn *txn;
|
MDB_txn *txn;
|
||||||
|
@ -119,9 +119,8 @@ void Core::Squawk::newAccountRequest(const QMap<QString, QVariant>& map)
|
|||||||
QString server = map.value("server").toString();
|
QString server = map.value("server").toString();
|
||||||
QString password = map.value("password").toString();
|
QString password = map.value("password").toString();
|
||||||
QString resource = map.value("resource").toString();
|
QString resource = map.value("resource").toString();
|
||||||
int passwordType = map.value("passwordType").toInt();
|
|
||||||
|
|
||||||
addAccount(login, server, password, name, resource, Shared::Global::fromInt<Shared::AccountPassword>(passwordType));
|
addAccount(login, server, password, name, resource, Shared::AccountPassword::plain);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::addAccount(
|
void Core::Squawk::addAccount(
|
||||||
|
@ -171,7 +171,7 @@ private:
|
|||||||
Shared::AccountPassword passwordType
|
Shared::AccountPassword passwordType
|
||||||
);
|
);
|
||||||
|
|
||||||
static const quint64 passwordHash = 0x3c5bb27570f50e11;
|
static const quint64 passwordHash = 0x08d054225ac4871d;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
1
main.cpp
1
main.cpp
@ -40,7 +40,6 @@ int main(int argc, char *argv[])
|
|||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
SignalCatcher sc(&app);
|
SignalCatcher sc(&app);
|
||||||
|
|
||||||
QApplication::setOrganizationName("squawk");
|
|
||||||
QApplication::setApplicationName("squawk");
|
QApplication::setApplicationName("squawk");
|
||||||
QApplication::setApplicationDisplayName("Squawk");
|
QApplication::setApplicationDisplayName("Squawk");
|
||||||
QApplication::setApplicationVersion("0.1.5");
|
QApplication::setApplicationVersion("0.1.5");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Squawk messenger.
|
* Squawk messenger.
|
||||||
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
|
* Copyright (C) 2021 Shunf4 <shun1048576@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -36,6 +36,7 @@ set(squawkUI_SRC
|
|||||||
utils/dropshadoweffect.cpp
|
utils/dropshadoweffect.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add squawk.ui to squawkUI_SRC so that the .ui files are displayed in Qt Creator
|
||||||
qt5_wrap_ui(squawkUI_SRC
|
qt5_wrap_ui(squawkUI_SRC
|
||||||
squawk.ui
|
squawk.ui
|
||||||
)
|
)
|
||||||
|
@ -982,7 +982,6 @@ void Squawk::readSettings()
|
|||||||
void Squawk::writeSettings()
|
void Squawk::writeSettings()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
qDebug() << "settings.fileName: " << settings.fileName();
|
|
||||||
settings.beginGroup("ui");
|
settings.beginGroup("ui");
|
||||||
settings.beginGroup("window");
|
settings.beginGroup("window");
|
||||||
settings.setValue("geometry", saveGeometry());
|
settings.setValue("geometry", saveGeometry());
|
||||||
@ -1024,7 +1023,6 @@ void Squawk::writeSettings()
|
|||||||
}
|
}
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Squawk::onItemCollepsed(const QModelIndex& index)
|
void Squawk::onItemCollepsed(const QModelIndex& index)
|
||||||
|
@ -33,9 +33,6 @@ Badge::Badge(const QString& p_id, const QString& p_text, const QIcon& icon, QWid
|
|||||||
|
|
||||||
image->setPixmap(icon.pixmap(25, 25));
|
image->setPixmap(icon.pixmap(25, 25));
|
||||||
closeButton->setIcon(QIcon::fromTheme("tab-close"));
|
closeButton->setIcon(QIcon::fromTheme("tab-close"));
|
||||||
QIcon qIcon;
|
|
||||||
qIcon.addFile(QString::fromUtf8(":/images/fallback/dark/big/edit-none.svg"), QSize(), QIcon::Normal, QIcon::Off);
|
|
||||||
closeButton->setIcon(qIcon);
|
|
||||||
closeButton->setMaximumHeight(25);
|
closeButton->setMaximumHeight(25);
|
||||||
closeButton->setMaximumWidth(25);
|
closeButton->setMaximumWidth(25);
|
||||||
|
|
||||||
|
@ -203,23 +203,16 @@ void Message::showFile(const QString& path)
|
|||||||
file = new Image(path);
|
file = new Image(path);
|
||||||
} else {
|
} else {
|
||||||
file = new QLabel();
|
file = new QLabel();
|
||||||
QIcon qIcon = QIcon::fromTheme(type.iconName());
|
file->setPixmap(QIcon::fromTheme(type.iconName()).pixmap(50));
|
||||||
if (qIcon.isNull()) {
|
|
||||||
qIcon.addFile(QString::fromUtf8(":/images/fallback/dark/big/mail-attachment.svg"), QSize(), QIcon::Normal, QIcon::Off);
|
|
||||||
}
|
|
||||||
file->setPixmap(qIcon.pixmap(50));
|
|
||||||
file->setAlignment(Qt::AlignCenter);
|
file->setAlignment(Qt::AlignCenter);
|
||||||
showComment(info.fileName(), true);
|
showComment(info.fileName(), true);
|
||||||
}
|
}
|
||||||
file->setContextMenuPolicy(Qt::ActionsContextMenu);
|
file->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||||
QAction* openAction = new QAction(QIcon::fromTheme("document-new-from-template"), tr("Open"), this);
|
QAction* openAction = new QAction(QIcon::fromTheme("document-new-from-template"), tr("Open"), file);
|
||||||
connect(openAction, &QAction::triggered, [path]() { //TODO need to get rid of this shame
|
connect(openAction, &QAction::triggered, [path]() { //TODO need to get rid of this shame
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||||
});
|
});
|
||||||
file->addAction(openAction);
|
file->addAction(openAction);
|
||||||
fileComment->setContextMenuPolicy(Qt::ActionsContextMenu);
|
|
||||||
fileComment->addAction(openAction);
|
|
||||||
|
|
||||||
bodyLayout->insertWidget(2, file);
|
bodyLayout->insertWidget(2, file);
|
||||||
hasFile = true;
|
hasFile = true;
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,7 @@ MessageLine::MessageLine(bool p_room, QWidget* parent):
|
|||||||
downloading(),
|
downloading(),
|
||||||
room(p_room),
|
room(p_room),
|
||||||
busyShown(false),
|
busyShown(false),
|
||||||
progress(),
|
progress()
|
||||||
lastHeight(0)
|
|
||||||
{
|
{
|
||||||
setContentsMargins(0, 0, 0, 0);
|
setContentsMargins(0, 0, 0, 0);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
@ -164,7 +163,6 @@ MessageLine::Position MessageLine::message(const Shared::Message& msg, bool forc
|
|||||||
emit requestLocalFile(msg.getId(), msg.getOutOfBandUrl());
|
emit requestLocalFile(msg.getId(), msg.getOutOfBandUrl());
|
||||||
connect(message, &Message::buttonClicked, this, &MessageLine::onDownload);
|
connect(message, &Message::buttonClicked, this, &MessageLine::onDownload);
|
||||||
}
|
}
|
||||||
qDebug() << "inserted message " << id;
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -311,11 +309,7 @@ void MessageLine::movePalAvatarToEx(const QString& name)
|
|||||||
void MessageLine::resizeEvent(QResizeEvent* event)
|
void MessageLine::resizeEvent(QResizeEvent* event)
|
||||||
{
|
{
|
||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
|
emit resize(event->size().height() - event->oldSize().height());
|
||||||
qDebug() << "Resize(unordered): " << event->size().height() << event->oldSize().height();
|
|
||||||
qDebug() << "Resize: " << height() << lastHeight;
|
|
||||||
emit resize(height() - lastHeight);
|
|
||||||
lastHeight = height();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -334,7 +328,6 @@ void MessageLine::showBusyIndicator()
|
|||||||
layout->insertWidget(0, &progress);
|
layout->insertWidget(0, &progress);
|
||||||
progress.start();
|
progress.start();
|
||||||
busyShown = true;
|
busyShown = true;
|
||||||
qDebug() << "showBusyIndicator";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,7 +337,6 @@ void MessageLine::hideBusyIndicator()
|
|||||||
progress.stop();
|
progress.stop();
|
||||||
layout->removeWidget(&progress);
|
layout->removeWidget(&progress);
|
||||||
busyShown = false;
|
busyShown = false;
|
||||||
qDebug() << "hideBusyIndicator";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +103,6 @@ private:
|
|||||||
bool room;
|
bool room;
|
||||||
bool busyShown;
|
bool busyShown;
|
||||||
Progress progress;
|
Progress progress;
|
||||||
int lastHeight;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGELINE_H
|
#endif // MESSAGELINE_H
|
||||||
|
@ -21,6 +21,7 @@ set(squawkWidgets_SRC
|
|||||||
joinconference.cpp
|
joinconference.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add to squawkUI_SRC so that the .ui files are displayed in Qt Creator
|
||||||
qt5_wrap_ui(squawkWidgets_SRC
|
qt5_wrap_ui(squawkWidgets_SRC
|
||||||
account.ui
|
account.ui
|
||||||
accounts.ui
|
accounts.ui
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include "ui/utils/dropshadoweffect.h"
|
#include "ui/utils/dropshadoweffect.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QClipboard>
|
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@ -29,9 +28,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <QAbstractTextDocumentLayout>
|
#include <QAbstractTextDocumentLayout>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QTemporaryFile>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QMenu>
|
|
||||||
|
|
||||||
Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, const QString pRes, QWidget* parent):
|
Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, const QString pRes, QWidget* parent):
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
@ -54,8 +50,7 @@ Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, c
|
|||||||
manualSliderChange(false),
|
manualSliderChange(false),
|
||||||
requestingHistory(false),
|
requestingHistory(false),
|
||||||
everShown(false),
|
everShown(false),
|
||||||
tsb(QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient) == 1),
|
tsb(QApplication::style()->styleHint(QStyle::SH_ScrollBar_Transient) == 1)
|
||||||
pasteImageAction(nullptr)
|
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
@ -68,7 +63,6 @@ Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, c
|
|||||||
statusLabel = m_ui->statusLabel;
|
statusLabel = m_ui->statusLabel;
|
||||||
|
|
||||||
connect(&ker, &KeyEnterReceiver::enterPressed, this, &Conversation::onEnterPressed);
|
connect(&ker, &KeyEnterReceiver::enterPressed, this, &Conversation::onEnterPressed);
|
||||||
connect(&ker, &KeyEnterReceiver::imagePasted, this, &Conversation::onImagePasted);
|
|
||||||
connect(&scrollResizeCatcher, &Resizer::resized, this, &Conversation::onScrollResize);
|
connect(&scrollResizeCatcher, &Resizer::resized, this, &Conversation::onScrollResize);
|
||||||
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);
|
||||||
@ -83,20 +77,6 @@ Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, c
|
|||||||
this, &Conversation::onTextEditDocSizeChanged);
|
this, &Conversation::onTextEditDocSizeChanged);
|
||||||
|
|
||||||
m_ui->messageEditor->installEventFilter(&ker);
|
m_ui->messageEditor->installEventFilter(&ker);
|
||||||
|
|
||||||
QAction* pasteImageAction = new QAction(tr("Paste Image"), this);
|
|
||||||
connect(pasteImageAction, &QAction::triggered, this, &Conversation::onImagePasted);
|
|
||||||
|
|
||||||
m_ui->messageEditor->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
connect(m_ui->messageEditor, &QTextEdit::customContextMenuRequested, this, [this, pasteImageAction](const QPoint &pos) {
|
|
||||||
pasteImageAction->setEnabled(Conversation::checkClipboardImage());
|
|
||||||
|
|
||||||
QMenu *editorMenu = m_ui->messageEditor->createStandardContextMenu();
|
|
||||||
editorMenu->addSeparator();
|
|
||||||
editorMenu->addAction(pasteImageAction);
|
|
||||||
|
|
||||||
editorMenu->exec(this->m_ui->messageEditor->mapToGlobal(pos));
|
|
||||||
});
|
|
||||||
|
|
||||||
QScrollBar* vs = m_ui->scrollArea->verticalScrollBar();
|
QScrollBar* vs = m_ui->scrollArea->verticalScrollBar();
|
||||||
m_ui->scrollArea->setWidget(line);
|
m_ui->scrollArea->setWidget(line);
|
||||||
@ -224,20 +204,10 @@ bool KeyEnterReceiver::eventFilter(QObject* obj, QEvent* event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (k == Qt::Key_V && key->modifiers() & Qt::CTRL) {
|
|
||||||
if (Conversation::checkClipboardImage()) {
|
|
||||||
emit imagePasted();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return QObject::eventFilter(obj, event);
|
return QObject::eventFilter(obj, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Conversation::checkClipboardImage() {
|
|
||||||
return !QApplication::clipboard()->image().isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Conversation::getPalResource() const
|
QString Conversation::getPalResource() const
|
||||||
{
|
{
|
||||||
return activePalResource;
|
return activePalResource;
|
||||||
@ -269,20 +239,6 @@ void Conversation::onEnterPressed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Conversation::onImagePasted()
|
|
||||||
{
|
|
||||||
QImage image = QApplication::clipboard()->image();
|
|
||||||
if (image.isNull()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QTemporaryFile *tempFile = new QTemporaryFile(QDir::tempPath() + QStringLiteral("/squawk_img_attach_XXXXXX.png"), QApplication::instance());
|
|
||||||
tempFile->open();
|
|
||||||
image.save(tempFile, "PNG");
|
|
||||||
tempFile->close();
|
|
||||||
qDebug() << "image on paste temp file: " << tempFile->fileName();
|
|
||||||
addAttachedFile(tempFile->fileName());
|
|
||||||
}
|
|
||||||
|
|
||||||
void Conversation::appendMessageWithUpload(const Shared::Message& data, const QString& path)
|
void Conversation::appendMessageWithUpload(const Shared::Message& data, const QString& path)
|
||||||
{
|
{
|
||||||
line->appendMessageWithUploadNoSiganl(data, path);
|
line->appendMessageWithUploadNoSiganl(data, path);
|
||||||
@ -291,28 +247,18 @@ void Conversation::appendMessageWithUpload(const Shared::Message& data, const QS
|
|||||||
void Conversation::onMessagesResize(int amount)
|
void Conversation::onMessagesResize(int amount)
|
||||||
{
|
{
|
||||||
manualSliderChange = true;
|
manualSliderChange = true;
|
||||||
qDebug() << "Scroll: " << scroll;
|
|
||||||
switch (scroll) {
|
switch (scroll) {
|
||||||
case down:
|
case down:
|
||||||
qDebug() << "setValue 1: " << m_ui->scrollArea->verticalScrollBar()->maximum();
|
|
||||||
m_ui->scrollArea->verticalScrollBar()->setValue(m_ui->scrollArea->verticalScrollBar()->maximum());
|
m_ui->scrollArea->verticalScrollBar()->setValue(m_ui->scrollArea->verticalScrollBar()->maximum());
|
||||||
break;
|
break;
|
||||||
case keep: {
|
case keep: {
|
||||||
int max = m_ui->scrollArea->verticalScrollBar()->maximum();
|
int max = m_ui->scrollArea->verticalScrollBar()->maximum();
|
||||||
int value = m_ui->scrollArea->verticalScrollBar()->value() + amount;
|
int value = m_ui->scrollArea->verticalScrollBar()->value() + amount;
|
||||||
m_ui->scrollArea->verticalScrollBar()->setValue(value);
|
m_ui->scrollArea->verticalScrollBar()->setValue(value);
|
||||||
qDebug() << "setValue 2 max: " << max;
|
|
||||||
qDebug() << "setValue 2 value: " << m_ui->scrollArea->verticalScrollBar()->value();
|
|
||||||
qDebug() << "setValue 2 amount: " << amount;
|
|
||||||
qDebug() << "setValue 2: " << value;
|
|
||||||
qDebug() << "isMax: " << (value > max);
|
|
||||||
|
|
||||||
if (value > max) {
|
if (value == max) {
|
||||||
qDebug() << "setValue 2 scroll = down";
|
|
||||||
scroll = down;
|
scroll = down;
|
||||||
m_ui->scrollArea->verticalScrollBar()->setValue(max);
|
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "setValue 2 scroll = nothing";
|
|
||||||
scroll = nothing;
|
scroll = nothing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,17 +273,14 @@ void Conversation::onSliderValueChanged(int value)
|
|||||||
{
|
{
|
||||||
if (!manualSliderChange) {
|
if (!manualSliderChange) {
|
||||||
if (value == m_ui->scrollArea->verticalScrollBar()->maximum()) {
|
if (value == m_ui->scrollArea->verticalScrollBar()->maximum()) {
|
||||||
qDebug() << "onSliderValueChanged: scroll = down";
|
|
||||||
scroll = down;
|
scroll = down;
|
||||||
} else {
|
} else {
|
||||||
if (!requestingHistory && value == 0) {
|
if (!requestingHistory && value == 0) {
|
||||||
requestingHistory = true;
|
requestingHistory = true;
|
||||||
line->showBusyIndicator();
|
line->showBusyIndicator();
|
||||||
emit requestArchive(line->firstMessageId());
|
emit requestArchive(line->firstMessageId());
|
||||||
qDebug() << "onSliderValueChanged: scroll = keep";
|
|
||||||
scroll = keep;
|
scroll = keep;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "onSliderValueChanged: scroll = nothing";
|
|
||||||
scroll = nothing;
|
scroll = nothing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,7 +290,6 @@ void Conversation::onSliderValueChanged(int value)
|
|||||||
void Conversation::responseArchive(const std::list<Shared::Message> list)
|
void Conversation::responseArchive(const std::list<Shared::Message> list)
|
||||||
{
|
{
|
||||||
requestingHistory = false;
|
requestingHistory = false;
|
||||||
qDebug() << "responseArchive scroll = keep";
|
|
||||||
scroll = keep;
|
scroll = keep;
|
||||||
|
|
||||||
line->hideBusyIndicator();
|
line->hideBusyIndicator();
|
||||||
@ -362,7 +304,6 @@ void Conversation::showEvent(QShowEvent* event)
|
|||||||
everShown = true;
|
everShown = true;
|
||||||
line->showBusyIndicator();
|
line->showBusyIndicator();
|
||||||
requestingHistory = true;
|
requestingHistory = true;
|
||||||
qDebug() << "showEvent scroll = keep";
|
|
||||||
scroll = keep;
|
scroll = keep;
|
||||||
emit requestArchive(line->firstMessageId());
|
emit requestArchive(line->firstMessageId());
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,6 @@ protected:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void enterPressed();
|
void enterPressed();
|
||||||
void imagePasted();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class VisibilityCatcher : public QObject {
|
class VisibilityCatcher : public QObject {
|
||||||
@ -91,7 +90,6 @@ public:
|
|||||||
void changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
void changeMessage(const QString& id, const QMap<QString, QVariant>& data);
|
||||||
void setFeedFrames(bool top, bool right, bool bottom, bool left);
|
void setFeedFrames(bool top, bool right, bool bottom, bool left);
|
||||||
virtual void appendMessageWithUpload(const Shared::Message& data, const QString& path);
|
virtual void appendMessageWithUpload(const Shared::Message& data, const QString& path);
|
||||||
static bool checkClipboardImage();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sendMessage(const Shared::Message& message);
|
void sendMessage(const Shared::Message& message);
|
||||||
@ -115,7 +113,6 @@ protected:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void onEnterPressed();
|
void onEnterPressed();
|
||||||
void onImagePasted();
|
|
||||||
void onMessagesResize(int amount);
|
void onMessagesResize(int amount);
|
||||||
void onSliderValueChanged(int value);
|
void onSliderValueChanged(int value);
|
||||||
void onAttach();
|
void onAttach();
|
||||||
@ -154,7 +151,6 @@ protected:
|
|||||||
bool requestingHistory;
|
bool requestingHistory;
|
||||||
bool everShown;
|
bool everShown;
|
||||||
bool tsb; //transient scroll bars
|
bool tsb; //transient scroll bars
|
||||||
QAction *pasteImageAction;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONVERSATION_H
|
#endif // CONVERSATION_H
|
||||||
|
@ -243,7 +243,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>520</width>
|
<width>520</width>
|
||||||
<height>380</height>
|
<height>385</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
@ -325,8 +325,8 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../resources/resources.qrc">
|
<iconset theme="smiley-shape">
|
||||||
<normaloff>:/images/fallback/dark/big/unfavorite.svg</normaloff>:/images/fallback/dark/big/unfavorite.svg</iconset>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="flat">
|
<property name="flat">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -352,8 +352,8 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../resources/resources.qrc">
|
<iconset theme="mail-attachment-symbolic">
|
||||||
<normaloff>:/images/fallback/dark/big/mail-attachment.svg</normaloff>:/images/fallback/dark/big/mail-attachment.svg</iconset>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="flat">
|
<property name="flat">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -366,8 +366,8 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../resources/resources.qrc">
|
<iconset theme="edit-clear-all">
|
||||||
<normaloff>:/images/fallback/dark/big/clean.svg</normaloff>:/images/fallback/dark/big/clean.svg</iconset>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="flat">
|
<property name="flat">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -386,8 +386,8 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../../resources/resources.qrc">
|
<iconset theme="document-send">
|
||||||
<normaloff>:/images/fallback/dark/big/send.svg</normaloff>:/images/fallback/dark/big/send.svg</iconset>
|
<normaloff>.</normaloff>.</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="flat">
|
<property name="flat">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -454,8 +454,8 @@ background-color: transparent
|
|||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
p, li { white-space: pre-wrap; }
|
p, li { white-space: pre-wrap; }
|
||||||
</style></head><body style=" font-family:'SimSun'; font-size:9pt; font-weight:400; font-style:normal;">
|
</style></head><body style=" font-family:'Liberation Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Liberation Sans'; font-size:10pt;"><br /></p></body></html></string>
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="acceptRichText">
|
<property name="acceptRichText">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
@ -473,8 +473,6 @@ p, li { white-space: pre-wrap; }
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources/>
|
||||||
<include location="../../resources/resources.qrc"/>
|
|
||||||
</resources>
|
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
Loading…
Reference in New Issue
Block a user