forked from blue/squawk
Merge branch 'build-refactor' into maybe-omemo
This commit is contained in:
commit
f94c3dac14
31 changed files with 366 additions and 420 deletions
|
@ -1,45 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.3)
|
||||
project(squawkUI)
|
||||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
# Instruct CMake to create code from Qt designer ui files
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
# Find the QtWidgets library
|
||||
find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets DBus Core)
|
||||
find_package(Boost 1.36.0 REQUIRED)
|
||||
if(Boost_FOUND)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
endif()
|
||||
target_sources(squawk PRIVATE squawk.cpp squawk.h squawk.ui)
|
||||
|
||||
add_subdirectory(models)
|
||||
add_subdirectory(utils)
|
||||
add_subdirectory(widgets)
|
||||
|
||||
set(squawkUI_SRC
|
||||
squawk.cpp
|
||||
squawk.h
|
||||
squawk.ui
|
||||
models/accounts.cpp
|
||||
models/roster.cpp
|
||||
models/item.cpp
|
||||
models/account.cpp
|
||||
models/contact.cpp
|
||||
models/presence.cpp
|
||||
models/group.cpp
|
||||
models/room.cpp
|
||||
models/abstractparticipant.cpp
|
||||
models/participant.cpp
|
||||
models/reference.cpp
|
||||
models/messagefeed.cpp
|
||||
models/element.cpp
|
||||
)
|
||||
|
||||
# Tell CMake to create the helloworld executable
|
||||
add_library(squawkUI STATIC ${squawkUI_SRC})
|
||||
|
||||
# Use the Widgets module from Qt 5.
|
||||
target_link_libraries(squawkUI squawkWidgets)
|
||||
target_link_libraries(squawkUI squawkUIUtils)
|
||||
target_link_libraries(squawkUI Qt5::Widgets)
|
||||
target_link_libraries(squawkUI Qt5::DBus)
|
||||
|
|
28
ui/models/CMakeLists.txt
Normal file
28
ui/models/CMakeLists.txt
Normal file
|
@ -0,0 +1,28 @@
|
|||
target_sources(squawk PRIVATE
|
||||
abstractparticipant.cpp
|
||||
abstractparticipant.h
|
||||
account.cpp
|
||||
account.h
|
||||
accounts.cpp
|
||||
accounts.h
|
||||
contact.cpp
|
||||
contact.h
|
||||
element.cpp
|
||||
element.h
|
||||
group.cpp
|
||||
group.h
|
||||
item.cpp
|
||||
item.h
|
||||
messagefeed.cpp
|
||||
messagefeed.h
|
||||
participant.cpp
|
||||
participant.h
|
||||
presence.cpp
|
||||
presence.h
|
||||
reference.cpp
|
||||
reference.h
|
||||
room.cpp
|
||||
room.h
|
||||
roster.cpp
|
||||
roster.h
|
||||
)
|
|
@ -532,20 +532,23 @@ QModelIndex Models::MessageFeed::modelIndexById(const QString& id) const
|
|||
|
||||
QModelIndex Models::MessageFeed::modelIndexByTime(const QString& id, const QDateTime& time) const
|
||||
{
|
||||
StorageByTime::const_iterator tItr = indexByTime.upper_bound(time);
|
||||
StorageByTime::const_iterator tBeg = indexByTime.begin();
|
||||
bool found = false;
|
||||
while (tItr != tBeg) {
|
||||
if (id == (*tItr)->getId()) {
|
||||
found = true;
|
||||
break;
|
||||
if (indexByTime.size() > 0) {
|
||||
StorageByTime::const_iterator tItr = indexByTime.upper_bound(time);
|
||||
StorageByTime::const_iterator tBeg = indexByTime.begin();
|
||||
StorageByTime::const_iterator tEnd = indexByTime.end();
|
||||
bool found = false;
|
||||
while (tItr != tBeg) {
|
||||
if (tItr != tEnd && id == (*tItr)->getId()) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
--tItr;
|
||||
}
|
||||
|
||||
if (found && tItr != tEnd && id == (*tItr)->getId()) {
|
||||
int position = indexByTime.rank(tItr);
|
||||
return createIndex(position, 0, *tItr);
|
||||
}
|
||||
--tItr;
|
||||
}
|
||||
|
||||
if (found || id == (*tItr)->getId()) {
|
||||
int position = indexByTime.rank(tItr);
|
||||
return createIndex(position, 0, *tItr);
|
||||
}
|
||||
|
||||
return QModelIndex();
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "models/roster.h"
|
||||
#include "widgets/vcard/vcard.h"
|
||||
|
||||
#include "shared.h"
|
||||
#include "shared/shared.h"
|
||||
|
||||
namespace Ui {
|
||||
class Squawk;
|
||||
|
|
|
@ -1,32 +1,26 @@
|
|||
cmake_minimum_required(VERSION 3.3)
|
||||
project(squawkUIUtils)
|
||||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
# Instruct CMake to create code from Qt designer ui files
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
# Find the QtWidgets library
|
||||
find_package(Qt5 CONFIG REQUIRED COMPONENTS Widgets Core)
|
||||
|
||||
set(squawkUIUtils_SRC
|
||||
# messageline.cpp
|
||||
# message.cpp
|
||||
resizer.cpp
|
||||
# image.cpp
|
||||
flowlayout.cpp
|
||||
target_sources(squawk PRIVATE
|
||||
badge.cpp
|
||||
progress.cpp
|
||||
badge.h
|
||||
comboboxdelegate.cpp
|
||||
feedview.cpp
|
||||
messagedelegate.cpp
|
||||
comboboxdelegate.h
|
||||
exponentialblur.cpp
|
||||
exponentialblur.h
|
||||
feedview.cpp
|
||||
feedview.h
|
||||
flowlayout.cpp
|
||||
flowlayout.h
|
||||
image.cpp
|
||||
image.h
|
||||
message.cpp
|
||||
message.h
|
||||
messagedelegate.cpp
|
||||
messagedelegate.h
|
||||
messageline.cpp
|
||||
messageline.h
|
||||
progress.cpp
|
||||
progress.h
|
||||
resizer.cpp
|
||||
resizer.h
|
||||
shadowoverlay.cpp
|
||||
)
|
||||
|
||||
# Tell CMake to create the helloworld executable
|
||||
add_library(squawkUIUtils STATIC ${squawkUIUtils_SRC})
|
||||
|
||||
# Use the Widgets module from Qt 5.
|
||||
target_link_libraries(squawkUIUtils squawkWidgets)
|
||||
target_link_libraries(squawkUIUtils Qt5::Widgets)
|
||||
shadowoverlay.h
|
||||
)
|
||||
|
|
|
@ -307,25 +307,48 @@ void MessageDelegate::paintBar(QProgressBar* bar, QPainter* painter, bool sentBy
|
|||
void MessageDelegate::paintPreview(const Models::FeedItem& data, QPainter* painter, QStyleOptionViewItem& option) const
|
||||
{
|
||||
Shared::Global::FileInfo info = Shared::Global::getFileInfo(data.attach.localPath);
|
||||
if (info.preview == Shared::Global::FileInfo::Preview::picture) {
|
||||
QSize size = constrainAttachSize(info.size, option.rect.size());
|
||||
|
||||
QPoint start;
|
||||
if (data.sentByMe) {
|
||||
start = {option.rect.width() - size.width(), option.rect.top()};
|
||||
start.rx() += margin;
|
||||
} else {
|
||||
start = option.rect.topLeft();
|
||||
}
|
||||
QImage img(data.attach.localPath);
|
||||
if (img.isNull()) {
|
||||
emit invalidPath(data.id);
|
||||
} else {
|
||||
painter->drawImage(QRect(start, size), img);
|
||||
}
|
||||
|
||||
option.rect.adjust(0, size.height() + textMargin, 0, 0);
|
||||
QSize size = constrainAttachSize(info.size, option.rect.size());
|
||||
|
||||
QPoint start;
|
||||
if (data.sentByMe) {
|
||||
start = {option.rect.width() - size.width(), option.rect.top()};
|
||||
start.rx() += margin;
|
||||
} else {
|
||||
start = option.rect.topLeft();
|
||||
}
|
||||
QRect rect(start, size);
|
||||
switch (info.preview) {
|
||||
case Shared::Global::FileInfo::Preview::picture: {
|
||||
QImage img(data.attach.localPath);
|
||||
if (img.isNull()) {
|
||||
emit invalidPath(data.id);
|
||||
} else {
|
||||
painter->drawImage(rect, img);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
QIcon icon = QIcon::fromTheme(info.mime.iconName());
|
||||
|
||||
painter->save();
|
||||
|
||||
painter->setFont(bodyFont);
|
||||
int labelWidth = option.rect.width() - size.width() - margin;
|
||||
QString elidedName = bodyMetrics.elidedText(info.name, Qt::ElideMiddle, labelWidth);
|
||||
QSize nameSize = bodyMetrics.boundingRect(QRect(start, QSize(labelWidth, 0)), 0, elidedName).size();
|
||||
if (data.sentByMe) {
|
||||
start.rx() -= nameSize.width() + margin;
|
||||
}
|
||||
painter->drawPixmap({start, size}, icon.pixmap(info.size));
|
||||
start.rx() += size.width() + margin;
|
||||
start.ry() += nameSize.height() + (size.height() - nameSize.height()) / 2;
|
||||
painter->drawText(start, elidedName);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
|
||||
option.rect.adjust(0, size.height() + textMargin, 0, 0);
|
||||
}
|
||||
|
||||
QPushButton * MessageDelegate::getButton(const Models::FeedItem& data) const
|
||||
|
|
|
@ -1,31 +1,23 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
project(squawkWidgets)
|
||||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
# Instruct CMake to create code from Qt designer ui files
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
# Find the QtWidgets library
|
||||
find_package(Qt5Widgets CONFIG REQUIRED COMPONENTS Widgets Core)
|
||||
target_sources(squawk PRIVATE
|
||||
account.cpp
|
||||
account.h
|
||||
account.ui
|
||||
accounts.cpp
|
||||
accounts.h
|
||||
accounts.ui
|
||||
chat.cpp
|
||||
chat.h
|
||||
conversation.cpp
|
||||
conversation.h
|
||||
conversation.ui
|
||||
joinconference.cpp
|
||||
joinconference.h
|
||||
joinconference.ui
|
||||
newcontact.cpp
|
||||
newcontact.h
|
||||
newcontact.ui
|
||||
room.cpp
|
||||
room.h
|
||||
)
|
||||
|
||||
add_subdirectory(vcard)
|
||||
|
||||
set(squawkWidgets_SRC
|
||||
conversation.cpp
|
||||
chat.cpp
|
||||
room.cpp
|
||||
newcontact.cpp
|
||||
accounts.cpp
|
||||
account.cpp
|
||||
joinconference.cpp
|
||||
)
|
||||
|
||||
add_library(squawkWidgets STATIC ${squawkWidgets_SRC})
|
||||
|
||||
# Use the Widgets module from Qt 5.
|
||||
target_link_libraries(squawkWidgets vCardUI)
|
||||
target_link_libraries(squawkWidgets squawkUIUtils)
|
||||
target_link_libraries(squawkWidgets Qt5::Widgets)
|
||||
|
||||
qt5_use_modules(squawkWidgets Core Widgets)
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <QDesktopServices>
|
||||
|
||||
#include "shared/message.h"
|
||||
#include "order.h"
|
||||
#include "shared/order.h"
|
||||
#include "ui/models/account.h"
|
||||
#include "ui/models/roster.h"
|
||||
#include "ui/utils/flowlayout.h"
|
||||
|
|
|
@ -1,22 +1,9 @@
|
|||
cmake_minimum_required(VERSION 3.0)
|
||||
project(vCardUI)
|
||||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
# Instruct CMake to create code from Qt designer ui files
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
# Find the QtWidgets library
|
||||
find_package(Qt5Widgets CONFIG REQUIRED)
|
||||
|
||||
set(vCardUI_SRC
|
||||
vcard.cpp
|
||||
target_sources(squawk PRIVATE
|
||||
emailsmodel.cpp
|
||||
emailsmodel.h
|
||||
phonesmodel.cpp
|
||||
)
|
||||
|
||||
# Tell CMake to create the helloworld executable
|
||||
add_library(vCardUI STATIC ${vCardUI_SRC})
|
||||
|
||||
# Use the Widgets module from Qt 5.
|
||||
target_link_libraries(vCardUI Qt5::Widgets)
|
||||
phonesmodel.h
|
||||
vcard.cpp
|
||||
vcard.h
|
||||
vcard.ui
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue