1
0
forked from blue/squawk

tooltips, status text fetching, window titles, app icon

This commit is contained in:
Blue 2019-06-21 22:33:38 +03:00
parent 3d15682b37
commit e456ba980d
13 changed files with 206 additions and 15 deletions

View File

@ -8,6 +8,8 @@ set(CMAKE_AUTOMOC ON)
# Instruct CMake to create code from Qt designer ui files # Instruct CMake to create code from Qt designer ui files
set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5Widgets CONFIG REQUIRED) find_package(Qt5Widgets CONFIG REQUIRED)
set(squawk_SRC set(squawk_SRC
main.cpp main.cpp
@ -16,8 +18,7 @@ set(squawk_SRC
signalcatcher.cpp signalcatcher.cpp
) )
# Tell CMake to create the helloworld executable add_executable(squawk ${squawk_SRC} resources/resources.qrc)
add_executable(squawk ${squawk_SRC})
target_link_libraries(squawk Qt5::Widgets) target_link_libraries(squawk Qt5::Widgets)
add_subdirectory(ui) add_subdirectory(ui)

View File

@ -52,6 +52,7 @@ static const std::deque<QString> availabilityThemeIcons = {
static const std::deque<QString> availabilityNames = {"Online", "Away", "Absent", "Busy", "Chatty", "Offline"}; static const std::deque<QString> availabilityNames = {"Online", "Away", "Absent", "Busy", "Chatty", "Offline"};
static const std::deque<QString> subscriptionStateThemeIcons = {"edit-none", "arrow-down-double", "arrow-up-double", "dialog-ok", "question"}; static const std::deque<QString> subscriptionStateThemeIcons = {"edit-none", "arrow-down-double", "arrow-up-double", "dialog-ok", "question"};
static const std::deque<QString> subscriptionStateNames = {"None", "From", "To", "Both", "Unknown"};
QString generateUUID(); QString generateUUID();

30
resources/images/logo.svg Normal file
View File

@ -0,0 +1,30 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!-- Created using Karbon, part of Calligra: http://www.calligra.org/karbon -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="226.772pt" height="226.772pt">
<defs>
<radialGradient id="gradient0" gradientTransform="" gradientUnits="objectBoundingBox" cx="0.58615583000" cy="0.59764384000" fx="0.50130301000" fy="0.61237523000" r="0.20615528000" spreadMethod="pad">
<stop stop-color="#ffffff" offset="0.00000000000" stop-opacity="1.00000000000"/>
<stop stop-color="#000000" offset="1.00000000000" stop-opacity="1.00000000000"/>
</radialGradient>
</defs>
<g id="layer0">
<circle id="shape0" transform="" r="141.77696241071pt" cx="141.77696241071pt" cy="141.77696241071pt" fill="#eeeb1d" fill-rule="evenodd" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="1.98425543308"/>
<g id="group1" transform="translate(9.42515, 20.0683)" fill="none">
<path id="shape011" transform="translate(2.52126, 94.3639)" fill="#000000" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="1.98425543308" d="M13.7868 0C-20.9371 78.2947 12.9209 116.755 81.8766 143.344C48.803 118.318 32.2243 85.1265 48.5476 54.976C64.273 54.0712 74.4022 43.6486 80.7554 6.77087C33.4537 22.7045 23.9698 15.2213 13.7868 0Z"/>
<path id="shape11" transform="translate(53.5583, 120.504)" fill="#000000" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="1.98425543308" d="M0.0390336 58.446C-0.508311 75.2636 4.7451 82.4194 13.0006 85.5591C34.384 87.3033 50.5845 94.036 74.434 80.7171C57.4285 30.9273 43.246 -6.13342 33.0083 0.845797C16.5859 22.1898 11.1668 38.7359 12.8331 45.1781C13.5421 59.3808 8.40203 61.4802 0.0390336 58.446Z"/>
<path id="shape21" transform="translate(83.7751, 97.1079)" fill="#000000" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="1.98425543308" d="M0 3.78934C43.6707 -12.5736 40.4801 24.6091 44.0695 104.631C34.8369 79.9436 14.9955 14.3809 2.59232 24.4808C7.7105 16.3152 11.2991 -0.457864 0 3.78934Z"/>
<path id="shape0111" transform="translate(15.3567, 2.5221)" fill="#000000" fill-rule="evenodd" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="1.98425543308" d="M1.23284 90.4967C-14.9544 20.581 131.833 -73.2611 231.831 92.5541C242.22 109.781 258.019 153.619 219.727 200.121C193.561 231.085 113.877 219.786 112.107 198.418C104.974 126.503 110.945 79.4203 67.6202 98.7319C16.153 116.631 5.48982 104.606 1.23284 90.4967Z"/>
<path id="shape41" transform="matrix(0.999941 -0.0542578 -0.0233262 1.00088 63.2155 35.119)" fill="#000000" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="1.98425543308" d="M56.4822 20.8524C37.7279 17.7726 29.039 -0.164137 21.1057 0.00113486C9.2061 0.249044 -0.226559 10.6804 0.00414314 21.5251C0.234845 32.3699 5.76072 43.0697 20.4852 43.049C35.2097 43.0283 37.8631 26.2335 56.4822 20.8524Z"/>
<ellipse id="shape31" transform="matrix(0.970618 -0.245439 0.175175 0.985449 71.9055 47.4623)" rx="8.09592848986pt" ry="9.16421234126pt" cx="8.09592848986pt" cy="9.16421234126pt" fill="#000000" fill-rule="evenodd" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="1.98425543308"/>
</g>
<g id="group11" transform="translate(17.2933, 13.7078)" fill="none">
<path id="shape01111" transform="translate(3.18245, 95.0383)" fill="#2e2e2e" stroke="#000000" stroke-width="1.41732529000" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="2.00000000000" d="M13.6826 0C-20.7789 78.0736 12.8233 116.425 81.2579 142.939C48.4342 117.984 31.9808 84.8861 48.1808 54.8208C63.7873 53.9186 73.84 43.5254 80.1452 6.75174C33.201 22.6404 23.7886 15.1784 13.6826 0Z"/>
<path id="shape111" transform="translate(54.2195, 121.178)" fill="#2e2e2e" stroke="#000000" stroke-width="1.41732529000" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="2.00000000000" d="M0.038739 58.4844C-0.504475 75.313 4.70929 82.4735 12.9025 85.6153C34.1245 87.3606 50.2028 94.0977 73.8723 80.7701C56.9951 30.9477 42.9197 -6.13745 32.7592 0.846351C16.4607 22.2043 11.0825 38.7613 12.7363 45.2078C13.4399 59.4199 8.33862 61.5206 0.038739 58.4844Z"/>
<path id="shape211" transform="translate(84.4363, 97.7813)" fill="#dfa700" stroke="#000000" stroke-width="1.41732529000" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="2.00000000000" d="M0 3.77601C43.9897 -12.5294 40.7758 24.5227 44.3914 104.264C35.0913 79.6628 15.105 14.3304 2.61126 24.3949C7.76681 16.2578 11.3816 -0.456263 0 3.77601Z"/>
<path id="shape01111" transform="translate(16.0179, 3.1963)" fill="#005ddf" fill-rule="evenodd" stroke="#000000" stroke-width="1.41732529000" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="2.00000000000" d="M1.2344 90.6784C-14.9734 20.6224 132.001 -73.4083 232.126 92.7399C242.528 110.001 258.347 153.927 220.006 200.523C193.807 231.549 114.022 220.226 112.25 198.816C105.108 126.757 111.086 79.5798 67.7062 98.9302C16.1735 116.865 5.4968 104.817 1.2344 90.6784Z"/>
<path id="shape411" transform="translate(63.3722, 34.6296)" fill="#dfa700" stroke="#000000" stroke-width="1.41732529000" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="2.00000000000" d="M56.7239 19.2268C37.966 17.1261 29.6656 -0.584886 21.6961 0.0148868C9.74219 0.914534 0.0246784 12.0039 8.52215e-05 22.9858C-0.0245092 33.9678 5.27104 44.5144 20.0558 43.6912C34.8409 42.868 37.9017 25.6966 56.7239 19.2268Z"/>
<path id="shape311" transform="matrix(0.970618 -0.245439 0.175175 0.985449 72.5667 48.1365)" fill="url(#gradient0)" fill-rule="evenodd" stroke="#000000" stroke-width="1.25000000000" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="2.00000000000" d="M20.2398 11.4553C20.2398 5.1287 15.709 3.87391e-16 10.1199 0C4.53084 -3.87391e-16 6.84464e-16 5.1287 0 11.4553C-6.84464e-16 17.7818 4.53084 22.9105 10.1199 22.9105C15.709 22.9105 20.2398 17.7818 20.2398 11.4553"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@ -0,0 +1,30 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<!-- Created using Karbon, part of Calligra: http://www.calligra.org/karbon -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="226.772pt" height="226.772pt">
<defs>
<radialGradient id="gradient0" gradientTransform="" gradientUnits="objectBoundingBox" cx="0.58615583000" cy="0.59764384000" fx="0.50130301000" fy="0.61237523000" r="0.20615528000" spreadMethod="pad">
<stop stop-color="#ffffff" offset="0.00000000000" stop-opacity="1.00000000000"/>
<stop stop-color="#000000" offset="1.00000000000" stop-opacity="1.00000000000"/>
</radialGradient>
</defs>
<g id="layer0">
<circle id="shape0" transform="" r="141.77696241071pt" cx="141.77696241071pt" cy="141.77696241071pt" fill="#eeeb1d" fill-rule="evenodd" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="1.98425543308"/>
<g id="group1" transform="translate(9.42515, 20.0683)" fill="none">
<path id="shape011" transform="translate(2.52126, 94.3639)" fill="#000000" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="1.98425543308" d="M13.7868 0C-20.9371 78.2947 12.9209 116.755 81.8766 143.344C48.803 118.318 32.2243 85.1265 48.5476 54.976C64.273 54.0712 74.4022 43.6486 80.7554 6.77087C33.4537 22.7045 23.9698 15.2213 13.7868 0Z"/>
<path id="shape11" transform="translate(53.5583, 120.504)" fill="#000000" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="1.98425543308" d="M0.0390336 58.446C-0.508311 75.2636 4.7451 82.4194 13.0006 85.5591C34.384 87.3033 50.5845 94.036 74.434 80.7171C57.4285 30.9273 43.246 -6.13342 33.0083 0.845797C16.5859 22.1898 11.1668 38.7359 12.8331 45.1781C13.5421 59.3808 8.40203 61.4802 0.0390336 58.446Z"/>
<path id="shape21" transform="translate(83.7751, 97.1079)" fill="#000000" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="1.98425543308" d="M0 3.78934C43.6707 -12.5736 40.4801 24.6091 44.0695 104.631C34.8369 79.9436 14.9955 14.3809 2.59232 24.4808C7.7105 16.3152 11.2991 -0.457864 0 3.78934Z"/>
<path id="shape0111" transform="translate(15.3567, 2.5221)" fill="#000000" fill-rule="evenodd" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="1.98425543308" d="M1.23284 90.4967C-14.9544 20.581 131.833 -73.2611 231.831 92.5541C242.22 109.781 258.019 153.619 219.727 200.121C193.561 231.085 113.877 219.786 112.107 198.418C104.974 126.503 110.945 79.4203 67.6202 98.7319C16.153 116.631 5.48982 104.606 1.23284 90.4967Z"/>
<path id="shape41" transform="matrix(0.999941 -0.0542578 -0.0233262 1.00088 63.2155 35.119)" fill="#000000" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="1.98425543308" d="M56.4822 20.8524C37.7279 17.7726 29.039 -0.164137 21.1057 0.00113486C9.2061 0.249044 -0.226559 10.6804 0.00414314 21.5251C0.234845 32.3699 5.76072 43.0697 20.4852 43.049C35.2097 43.0283 37.8631 26.2335 56.4822 20.8524Z"/>
<ellipse id="shape31" transform="matrix(0.970618 -0.245439 0.175175 0.985449 71.9055 47.4623)" rx="8.09592848986pt" ry="9.16421234126pt" cx="8.09592848986pt" cy="9.16421234126pt" fill="#000000" fill-rule="evenodd" stroke="#000000" stroke-width="0.08503951740" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="1.98425543308"/>
</g>
<g id="group11" transform="translate(17.2933, 13.7078)" fill="none">
<path id="shape01111" transform="translate(3.18245, 95.0383)" fill="#2e2e2e" stroke="#000000" stroke-width="1.41732529000" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="2.00000000000" d="M13.6826 0C-20.7789 78.0736 12.8233 116.425 81.2579 142.939C48.4342 117.984 31.9808 84.8861 48.1808 54.8208C63.7873 53.9186 73.84 43.5254 80.1452 6.75174C33.201 22.6404 23.7886 15.1784 13.6826 0Z"/>
<path id="shape111" transform="translate(54.2195, 121.178)" fill="#2e2e2e" stroke="#000000" stroke-width="1.41732529000" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="2.00000000000" d="M0.038739 58.4844C-0.504475 75.313 4.70929 82.4735 12.9025 85.6153C34.1245 87.3606 50.2028 94.0977 73.8723 80.7701C56.9951 30.9477 42.9197 -6.13745 32.7592 0.846351C16.4607 22.2043 11.0825 38.7613 12.7363 45.2078C13.4399 59.4199 8.33862 61.5206 0.038739 58.4844Z"/>
<path id="shape211" transform="translate(84.4363, 97.7813)" fill="#dfa700" stroke="#000000" stroke-width="1.41732529000" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="2.00000000000" d="M0 3.77601C43.9897 -12.5294 40.7758 24.5227 44.3914 104.264C35.0913 79.6628 15.105 14.3304 2.61126 24.3949C7.76681 16.2578 11.3816 -0.456263 0 3.77601Z"/>
<path id="shape01111" transform="translate(16.1292, 11.8595)" fill="#005ddf" fill-rule="evenodd" stroke="#000000" stroke-width="1.41732529000" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="2.00000000000" d="M1.12308 82.0153C-15.0847 11.9593 148.305 -64.3242 222.188 89.9488C228.508 107.46 218.746 127.737 205.802 147.297C179.603 178.323 164.705 188.623 112.139 190.153C104.997 118.094 110.975 70.9167 67.5949 90.2671C16.0622 108.202 5.38548 96.1539 1.12308 82.0153Z"/>
<path id="shape411" transform="translate(63.3722, 34.6296)" fill="#dfa700" stroke="#000000" stroke-width="1.41732529000" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="2.00000000000" d="M56.7239 19.2268C37.966 17.1261 29.6656 -0.584886 21.6961 0.0148868C9.74219 0.914534 0.0246784 12.0039 8.52215e-05 22.9858C-0.0245092 33.9678 5.27104 44.5144 20.0558 43.6912C34.8409 42.868 37.9017 25.6966 56.7239 19.2268Z"/>
<path id="shape311" transform="matrix(0.970618 -0.245439 0.175175 0.985449 72.5667 48.1365)" fill="url(#gradient0)" fill-rule="evenodd" stroke="#000000" stroke-width="1.25000000000" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="2.00000000000" d="M20.2398 11.4553C20.2398 5.1287 15.709 3.87391e-16 10.1199 0C4.53084 -3.87391e-16 6.84464e-16 5.1287 0 11.4553C-6.84464e-16 17.7818 4.53084 22.9105 10.1199 22.9105C15.709 22.9105 20.2398 17.7818 20.2398 11.4553"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.2 KiB

5
resources/resources.qrc Normal file
View File

@ -0,0 +1,5 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>images/logo.svg</file>
</qresource>
</RCC>

View File

@ -22,6 +22,7 @@
#include <QScrollBar> #include <QScrollBar>
#include <QTimer> #include <QTimer>
#include <QGraphicsDropShadowEffect> #include <QGraphicsDropShadowEffect>
#include <QFileDialog>
Conversation::Conversation(Models::Contact* p_contact, QWidget* parent): Conversation::Conversation(Models::Contact* p_contact, QWidget* parent):
QWidget(parent), QWidget(parent),
@ -42,10 +43,12 @@ Conversation::Conversation(Models::Contact* p_contact, QWidget* parent):
setName(p_contact->getContactName()); setName(p_contact->getContactName());
setState(p_contact->getAvailability()); setState(p_contact->getAvailability());
setStatus(p_contact->getStatus());
connect(contact, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onContactChanged(Models::Item*, int, int))); connect(contact, SIGNAL(childChanged(Models::Item*, int, int)), this, SLOT(onContactChanged(Models::Item*, int, int)));
connect(&ker, SIGNAL(enterPressed()), this, SLOT(onEnterPressed())); connect(&ker, SIGNAL(enterPressed()), this, SLOT(onEnterPressed()));
connect(m_ui->sendButton, SIGNAL(clicked(bool)), this, SLOT(onEnterPressed())); connect(m_ui->sendButton, SIGNAL(clicked(bool)), this, SLOT(onEnterPressed()));
//connect(m_ui->attachButton, SIGNAL(clicked(bool)), this, SLOT(onAttach()));
m_ui->messageEditor->installEventFilter(&ker); m_ui->messageEditor->installEventFilter(&ker);
@ -99,6 +102,7 @@ void Conversation::applyVisualEffects()
void Conversation::setName(const QString& name) void Conversation::setName(const QString& name)
{ {
m_ui->nameLabel->setText(name); m_ui->nameLabel->setText(name);
setWindowTitle(name);
line->setPalName(getJid(), name); line->setPalName(getJid(), name);
} }
@ -133,6 +137,9 @@ void Conversation::onContactChanged(Models::Item* item, int row, int col)
case 3: case 3:
setState(contact->getAvailability()); setState(contact->getAvailability());
break; break;
case 5:
setStatus(contact->getStatus());
break;
} }
} }
} }
@ -279,3 +286,23 @@ void Conversation::showEvent(QShowEvent* event)
QWidget::showEvent(event); QWidget::showEvent(event);
} }
void Conversation::onAttach()
{
QFileDialog* d = new QFileDialog(this, "Chose a file to send");
d->setFileMode(QFileDialog::ExistingFile);
connect(d, SIGNAL(accepted()), this, SLOT(onFileSelected()));
connect(d, SIGNAL(rejected()), d, SLOT(deleteLater()));
d->show();
}
void Conversation::onFileSelected()
{
QFileDialog* d = static_cast<QFileDialog*>(sender());
qDebug() << d->selectedFiles();
d->deleteLater();
}

View File

@ -75,6 +75,8 @@ protected slots:
void onEnterPressed(); void onEnterPressed();
void onMessagesResize(int amount); void onMessagesResize(int amount);
void onSliderValueChanged(int value); void onSliderValueChanged(int value);
void onAttach();
void onFileSelected();
private: private:
enum Scroll { enum Scroll {

View File

@ -94,6 +94,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="nameLabel"> <widget class="QLabel" name="nameLabel">
<property name="text"> <property name="text">
@ -108,6 +116,8 @@
</property> </property>
</widget> </widget>
</item> </item>
</layout>
</item>
<item> <item>
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
@ -192,7 +202,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>572</width> <width>572</width>
<height>111</height> <height>128</height>
</rect> </rect>
</property> </property>
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">

View File

@ -20,6 +20,9 @@
#include <QDebug> #include <QDebug>
#include <QGraphicsDropShadowEffect> #include <QGraphicsDropShadowEffect>
const QRegExp urlReg("^(?!<img\\ssrc=\")((?:https?|ftp)://\\S+)");
const QRegExp imgReg("((?:https?|ftp)://\\S+\\.(?:jpg|jpeg|png|svg|gif))");
MessageLine::MessageLine(QWidget* parent): MessageLine::MessageLine(QWidget* parent):
QWidget(parent), QWidget(parent),
messageIndex(), messageIndex(),
@ -75,7 +78,11 @@ MessageLine::Position MessageLine::message(const Shared::Message& msg)
message->setBackgroundRole(QPalette::AlternateBase); message->setBackgroundRole(QPalette::AlternateBase);
message->setAutoFillBackground(true); message->setAutoFillBackground(true);
QLabel* body = new QLabel(msg.getBody());
QString bd = msg.getBody();
//bd.replace(imgReg, "<img src=\"\\1\"/>");
bd.replace(urlReg, "<a href=\"\\1\">\\1</a>");
QLabel* body = new QLabel(bd);
body->setTextInteractionFlags(body->textInteractionFlags() | Qt::TextSelectableByMouse); body->setTextInteractionFlags(body->textInteractionFlags() | Qt::TextSelectableByMouse);
QLabel* sender = new QLabel(); QLabel* sender = new QLabel();
QLabel* time = new QLabel(msg.getTime().toLocalTime().toString()); QLabel* time = new QLabel(msg.getTime().toLocalTime().toString());
@ -89,6 +96,7 @@ MessageLine::Position MessageLine::message(const Shared::Message& msg)
sender->setFont(f); sender->setFont(f);
body->setWordWrap(true); body->setWordWrap(true);
body->setOpenExternalLinks(true);
vBox->addWidget(sender); vBox->addWidget(sender);
vBox->addWidget(body); vBox->addWidget(body);

View File

@ -67,9 +67,22 @@ void Models::Contact::setAvailability(Shared::Availability p_state)
} }
} }
QString Models::Contact::getStatus() const
{
return status;
}
void Models::Contact::setStatus(const QString& p_state)
{
if (status != p_state) {
status = p_state;
changed(5);
}
}
int Models::Contact::columnCount() const int Models::Contact::columnCount() const
{ {
return 5; return 6;
} }
QVariant Models::Contact::data(int column) const QVariant Models::Contact::data(int column) const
@ -85,6 +98,8 @@ QVariant Models::Contact::data(int column) const
return availability; return availability;
case 4: case 4:
return getMessagesCount(); return getMessagesCount();
case 5:
return getStatus();
default: default:
return QVariant(); return QVariant();
} }
@ -161,8 +176,10 @@ void Models::Contact::refresh()
if (presence != 0) { if (presence != 0) {
setAvailability(presence->getAvailability()); setAvailability(presence->getAvailability());
setStatus(presence->getStatus());
} else { } else {
setAvailability(Shared::offline); setAvailability(Shared::offline);
setStatus("");
} }
if (childMessages != count) { if (childMessages != count) {

View File

@ -37,6 +37,7 @@ public:
QString getAccountJid() const; QString getAccountJid() const;
QString getAccountResource() const; QString getAccountResource() const;
QString getContactName() const; QString getContactName() const;
QString getStatus() const;
void addMessage(const Shared::Message& data); void addMessage(const Shared::Message& data);
unsigned int getMessagesCount() const; unsigned int getMessagesCount() const;
@ -56,6 +57,7 @@ protected:
void setState(Shared::SubscriptionState p_state); void setState(Shared::SubscriptionState p_state);
void setState(unsigned int p_state); void setState(unsigned int p_state);
void setJid(const QString p_jid); void setJid(const QString p_jid);
void setStatus(const QString& p_state);
private: private:
QString jid; QString jid;
@ -64,6 +66,7 @@ private:
QMap<QString, Presence*> presences; QMap<QString, Presence*> presences;
Messages messages; Messages messages;
unsigned int childMessages; unsigned int childMessages;
QString status;
}; };
} }

View File

@ -93,6 +93,61 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
default: default:
break; break;
} }
break;
case Qt::ToolTipRole:
switch (item->type) {
case Item::account: {
Account* acc = static_cast<Account*>(item);
result = QString(Shared::connectionStateNames[acc->getAvailability()]);
}
break;
case Item::contact: {
Contact* contact = static_cast<Contact*>(item);
QString str = QString("");
int mc = contact->getMessagesCount();
if (mc > 0) {
str += QString("New messages: ") + std::to_string(mc).c_str() + "\n";
}
Shared::SubscriptionState ss = contact->getState();
if (ss == Shared::both) {
Shared::Availability av = contact->getAvailability();
str += "Availability: " + Shared::availabilityNames[av];
if (av != Shared::offline) {
QString s = contact->getStatus();
if (s.size() > 0) {
str += "\nStatus: " + s;
}
}
str += "\nSubscription: " + Shared::subscriptionStateNames[ss];
} else {
str += "Subscription: " + Shared::subscriptionStateNames[ss];
}
result = str;
}
break;
case Item::presence: {
Presence* contact = static_cast<Presence*>(item);
QString str = QString("");
int mc = contact->getMessagesCount();
if (mc > 0) {
str += QString("New messages: ") + std::to_string(mc).c_str() + "\n";
}
Shared::Availability av = contact->getAvailability();
str += "Availability: " + Shared::availabilityNames[av];
QString s = contact->getStatus();
if (s.size() > 0) {
str += "\nStatus: " + s;
}
result = str;
}
break;
default:
result = "";
break;
}
break;
default: default:
break; break;
} }

View File

@ -12,6 +12,8 @@ Squawk::Squawk(QWidget *parent) :
contextMenu(new QMenu()), contextMenu(new QMenu()),
dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus()) dbus("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", QDBusConnection::sessionBus())
{ {
setWindowIcon(QIcon(":images/logo.svg"));
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->roster->setModel(&rosterModel); m_ui->roster->setModel(&rosterModel);
m_ui->roster->setContextMenuPolicy(Qt::CustomContextMenu); m_ui->roster->setContextMenuPolicy(Qt::CustomContextMenu);