Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Kaidan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
46
Issues
46
List
Boards
Labels
Service Desk
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Network
Kaidan
Commits
2db4c8f6
Verified
Commit
2db4c8f6
authored
Dec 15, 2019
by
Linus Jahn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QmlUtils: Make singleton and use directly, without the kaidan object in QML
parent
199556fe
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
57 additions
and
37 deletions
+57
-37
src/Kaidan.cpp
src/Kaidan.cpp
+0
-1
src/Kaidan.h
src/Kaidan.h
+0
-8
src/QmlUtils.cpp
src/QmlUtils.cpp
+18
-1
src/QmlUtils.h
src/QmlUtils.h
+4
-1
src/main.cpp
src/main.cpp
+4
-2
src/qml/AboutDialog.qml
src/qml/AboutDialog.qml
+4
-2
src/qml/ChatPage.qml
src/qml/ChatPage.qml
+1
-1
src/qml/EmptyChatPage.qml
src/qml/EmptyChatPage.qml
+3
-1
src/qml/GlobalDrawer.qml
src/qml/GlobalDrawer.qml
+3
-3
src/qml/UserProfilePage.qml
src/qml/UserProfilePage.qml
+4
-4
src/qml/elements/ChatMessage.qml
src/qml/elements/ChatMessage.qml
+5
-5
src/qml/elements/MediaPreviewOther.qml
src/qml/elements/MediaPreviewOther.qml
+2
-2
src/qml/elements/RosterListItem.qml
src/qml/elements/RosterListItem.qml
+5
-4
src/qml/elements/TextAvatar.qml
src/qml/elements/TextAvatar.qml
+4
-2
No files found.
src/Kaidan.cpp
View file @
2db4c8f6
...
...
@@ -52,7 +52,6 @@ Kaidan *Kaidan::s_instance = nullptr;
Kaidan
::
Kaidan
(
QGuiApplication
*
app
,
bool
enableLogging
,
QObject
*
parent
)
:
QObject
(
parent
),
m_utils
(
new
QmlUtils
(
this
)),
m_database
(
new
Database
()),
m_dbThrd
(
new
QThread
()),
m_msgDb
(
new
MessageDb
()),
...
...
src/Kaidan.h
View file @
2db4c8f6
...
...
@@ -43,7 +43,6 @@
class
QGuiApplication
;
class
Database
;
class
QXmppClient
;
class
QmlUtils
;
using
namespace
Enums
;
...
...
@@ -60,7 +59,6 @@ class Kaidan : public QObject
{
Q_OBJECT
Q_PROPERTY
(
QmlUtils
*
utils
READ
getUtils
CONSTANT
)
Q_PROPERTY
(
RosterModel
*
rosterModel
READ
getRosterModel
CONSTANT
)
Q_PROPERTY
(
MessageModel
*
messageModel
READ
getMessageModel
CONSTANT
)
Q_PROPERTY
(
AvatarFileStorage
*
avatarStorage
READ
getAvatarStorage
NOTIFY
avatarStorageChanged
)
...
...
@@ -189,11 +187,6 @@ public:
return
m_caches
->
settings
;
}
QmlUtils
*
getUtils
()
const
{
return
m_utils
;
}
ClientWorker
*
getClient
()
const
;
/**
...
...
@@ -422,7 +415,6 @@ private:
*/
void
notifyLoginUriNotFound
();
QmlUtils
*
m_utils
;
Database
*
m_database
;
QThread
*
m_dbThrd
;
MessageDb
*
m_msgDb
;
...
...
src/QmlUtils.cpp
View file @
2db4c8f6
...
...
@@ -43,9 +43,26 @@
// QXmpp
#include "qxmpp-exts/QXmppColorGenerator.h"
static
QmlUtils
*
s_instance
;
QmlUtils
*
QmlUtils
::
instance
()
{
if
(
!
s_instance
)
return
new
QmlUtils
(
QGuiApplication
::
instance
());
return
s_instance
;
}
QmlUtils
::
QmlUtils
(
QObject
*
parent
)
:
QObject
(
parent
)
:
QObject
(
parent
)
{
Q_ASSERT
(
!
s_instance
);
s_instance
=
this
;
}
QmlUtils
::~
QmlUtils
()
{
s_instance
=
nullptr
;
}
QString
QmlUtils
::
presenceTypeToIcon
(
Enums
::
AvailabilityTypes
type
)
...
...
src/QmlUtils.h
View file @
2db4c8f6
...
...
@@ -48,7 +48,10 @@ class QmlUtils : public QObject
Q_OBJECT
public:
static
QmlUtils
*
instance
();
QmlUtils
(
QObject
*
parent
=
nullptr
);
~
QmlUtils
();
/**
* Returns the icon belonging to the given presence status type
...
...
@@ -79,7 +82,7 @@ public:
*/
Q_INVOKABLE
static
QString
getVersionString
()
{
return
VERSION_STRING
;
return
QStringLiteral
(
VERSION_STRING
)
;
}
/**
...
...
src/main.cpp
View file @
2db4c8f6
...
...
@@ -199,7 +199,7 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
qputenv
(
"GST_PLUGIN_PATH_1_0"
,
QByteArray
());
qputenv
(
"GST_PLUGIN_SYSTEM_PATH_1_0"
,
gstreamerPluginsPath
.
toLocal8Bit
());
qputenv
(
"GST_PLUGIN_SCANNER_1_0"
,
QString
::
fromLatin1
(
"%1/gst-plugin-scanner"
).
arg
(
gstreamerPluginsPath
).
toLocal8Bit
());
#endif
#endif
// APPIMAGE
// register qMetaTypes
qRegisterMetaType
<
RosterItem
>
(
"RosterItem"
);
...
...
@@ -227,7 +227,6 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
qRegisterMetaType
<
CameraInfo
>
();
qRegisterMetaType
<
AudioDeviceInfo
>
();
qRegisterMetaType
<
MediaSettings
>
();
// qRegisterMetaType<CommonEncoderSettings>();
qRegisterMetaType
<
ImageEncoderSettings
>
();
qRegisterMetaType
<
AudioEncoderSettings
>
();
qRegisterMetaType
<
VideoEncoderSettings
>
();
...
...
@@ -370,6 +369,9 @@ Q_DECL_EXPORT int main(int argc, char *argv[])
QObject
*
instance
=
new
MediaUtils
(
qApp
);
return
instance
;
});
qmlRegisterSingletonType
<
QmlUtils
>
(
APPLICATION_ID
,
1
,
0
,
"Utils"
,
[](
QQmlEngine
*
,
QJSEngine
*
)
{
return
static_cast
<
QObject
*>
(
QmlUtils
::
instance
());
});
engine
.
rootContext
()
->
setContextProperty
(
"kaidan"
,
&
kaidan
);
engine
.
load
(
QUrl
(
"qrc:/qml/main.qml"
));
...
...
src/qml/AboutDialog.qml
View file @
2db4c8f6
...
...
@@ -33,6 +33,8 @@ import QtQuick.Layouts 1.3
import
QtQuick
.
Controls
2.3
as
Controls
import
org
.
kde
.
kirigami
2.8
as
Kirigami
import
im
.
kaidan
.
kaidan
1.0
Controls.Dialog
{
id
:
aboutDialog
modal
:
true
...
...
@@ -46,7 +48,7 @@ Controls.Dialog {
rowSpacing
:
20
Image
{
source
:
kaidan
.
u
tils
.
getResourcePath
(
"
images/kaidan.svg
"
)
source
:
U
tils
.
getResourcePath
(
"
images/kaidan.svg
"
)
Layout.preferredWidth
:
Kirigami
.
Units
.
gridUnit
*
9
Layout.preferredHeight
:
Kirigami
.
Units
.
gridUnit
*
9
Layout.fillWidth
:
true
...
...
@@ -63,7 +65,7 @@ Controls.Dialog {
spacing
:
Kirigami
.
gridUnit
*
0.6
Kirigami.Heading
{
text
:
"
Kaidan
"
+
kaidan
.
u
tils
.
getVersionString
()
text
:
"
Kaidan
"
+
U
tils
.
getVersionString
()
textFormat
:
Text
.
PlainText
wrapMode
:
Text
.
WordWrap
Layout.fillWidth
:
true
...
...
src/qml/ChatPage.qml
View file @
2db4c8f6
...
...
@@ -393,7 +393,7 @@ Kirigami.ScrollablePage {
background
:
Image
{
id
:
bgimage
source
:
kaidan
.
u
tils
.
getResourcePath
(
"
images/chat.png
"
)
source
:
U
tils
.
getResourcePath
(
"
images/chat.png
"
)
anchors.fill
:
parent
fillMode
:
Image
.
Tile
horizontalAlignment
:
Image
.
AlignLeft
...
...
src/qml/EmptyChatPage.qml
View file @
2db4c8f6
...
...
@@ -32,10 +32,12 @@ import QtQuick.Controls 2.3 as Controls
import
org
.
kde
.
kirigami
2.8
as
Kirigami
import
QtQuick
2.7
import
im
.
kaidan
.
kaidan
1.0
Kirigami.Page
{
background
:
Image
{
id
:
bgimage
source
:
kaidan
.
u
tils
.
getResourcePath
(
"
images/chat.png
"
)
source
:
U
tils
.
getResourcePath
(
"
images/chat.png
"
)
anchors.fill
:
parent
fillMode
:
Image
.
Tile
horizontalAlignment
:
Image
.
AlignLeft
...
...
src/qml/GlobalDrawer.qml
View file @
2db4c8f6
...
...
@@ -35,8 +35,8 @@ import "settings"
Kirigami.GlobalDrawer
{
id
:
globalDrawer
title
:
"
Kaidan
"
titleIcon
:
kaidan
.
u
tils
.
getResourcePath
(
"
images/kaidan.svg
"
)
bannerImageSource
:
kaidan
.
u
tils
.
getResourcePath
(
"
images/banner.png
"
)
titleIcon
:
U
tils
.
getResourcePath
(
"
images/kaidan.svg
"
)
bannerImageSource
:
U
tils
.
getResourcePath
(
"
images/banner.png
"
)
SettingsSheet
{
id
:
settingsSheet
...
...
@@ -47,7 +47,7 @@ Kirigami.GlobalDrawer {
text
:
qsTr
(
"
Invite friends
"
)
iconName
:
"
mail-invitation
"
onTriggered
:
{
kaidan
.
u
tils
.
copyToClipboard
(
U
tils
.
copyToClipboard
(
"
https://i.kaidan.im/#
"
+
kaidan
.
jid
)
passiveNotification
(
qsTr
(
"
Invitation link copied to clipboard
"
))
...
...
src/qml/UserProfilePage.qml
View file @
2db4c8f6
...
...
@@ -146,15 +146,15 @@ Kirigami.Page {
spacing
:
Kirigami
.
Units
.
smallSpacing
Kirigami.Icon
{
source
:
kaidan
.
u
tils
.
presenceTypeToIcon
(
presenceType
)
source
:
U
tils
.
presenceTypeToIcon
(
presenceType
)
width
:
26
height
:
26
}
Controls.Label
{
Layout.alignment
:
Qt
.
AlignVCenter
text
:
kaidan
.
u
tils
.
presenceTypeToText
(
presenceType
)
color
:
kaidan
.
u
tils
.
presenceTypeToColor
(
presenceType
)
text
:
U
tils
.
presenceTypeToText
(
presenceType
)
color
:
U
tils
.
presenceTypeToColor
(
presenceType
)
textFormat
:
Text
.
PlainText
}
...
...
@@ -174,7 +174,7 @@ Kirigami.Page {
Layout.fillWidth
:
true
Controls.Label
{
text
:
kaidan
.
u
tils
.
formatMessage
(
model
.
value
)
text
:
U
tils
.
formatMessage
(
model
.
value
)
onLinkActivated
:
Qt
.
openUrlExternally
(
link
)
textFormat
:
Text
.
StyledText
}
...
...
src/qml/elements/ChatMessage.qml
View file @
2db4c8f6
...
...
@@ -125,9 +125,9 @@ RowLayout {
enabled
:
bodyLabel
.
visible
onTriggered
:
{
if
(
!
isSpoiler
||
isShowingSpoiler
)
kaidan
.
u
tils
.
copyToClipboard
(
messageBody
);
U
tils
.
copyToClipboard
(
messageBody
);
else
kaidan
.
u
tils
.
copyToClipboard
(
spoilerHint
);
U
tils
.
copyToClipboard
(
spoilerHint
);
}
}
...
...
@@ -140,7 +140,7 @@ RowLayout {
Controls.MenuItem
{
text
:
qsTr
(
"
Copy download URL
"
)
enabled
:
mediaGetUrl
onTriggered
:
kaidan
.
u
tils
.
copyToClipboard
(
mediaGetUrl
)
onTriggered
:
U
tils
.
copyToClipboard
(
mediaGetUrl
)
}
}
}
...
...
@@ -254,7 +254,7 @@ RowLayout {
Controls.Label
{
id
:
bodyLabel
visible
:
(
root
.
mediaType
===
Enums
.
MessageType
.
MessageText
||
messageBody
!==
mediaGetUrl
)
&&
messageBody
!==
""
text
:
kaidan
.
u
tils
.
formatMessage
(
messageBody
)
text
:
U
tils
.
formatMessage
(
messageBody
)
textFormat
:
Text
.
StyledText
wrapMode
:
Text
.
Wrap
color
:
sentByMe
?
Kirigami
.
Theme
.
textColor
...
...
@@ -288,7 +288,7 @@ RowLayout {
Image
{
id
:
checkmark
visible
:
(
sentByMe
&&
isDelivered
)
source
:
kaidan
.
u
tils
.
getResourcePath
(
"
images/message_checkmark.svg
"
)
source
:
U
tils
.
getResourcePath
(
"
images/message_checkmark.svg
"
)
Layout.preferredHeight
:
Kirigami
.
Units
.
gridUnit
*
0.65
Layout.preferredWidth
:
Kirigami
.
Units
.
gridUnit
*
0.65
sourceSize.height
:
Kirigami
.
Units
.
gridUnit
*
0.65
...
...
src/qml/elements/MediaPreviewOther.qml
View file @
2db4c8f6
...
...
@@ -108,7 +108,7 @@ MediaPreview {
Controls.Label
{
id
:
fileNameLabel
Layout.fillWidth
:
true
text
:
kaidan
.
u
tils
.
fileNameFromUrl
(
root
.
mediaSource
)
text
:
U
tils
.
fileNameFromUrl
(
root
.
mediaSource
)
textFormat
:
Text
.
PlainText
elide
:
Text
.
ElideRight
maximumLineCount
:
1
...
...
@@ -130,7 +130,7 @@ MediaPreview {
id
:
fileSizeLabel
Layout.fillWidth
:
true
text
:
kaidan
.
u
tils
.
fileSizeFromUrl
(
root
.
mediaSource
)
text
:
U
tils
.
fileSizeFromUrl
(
root
.
mediaSource
)
textFormat
:
Text
.
PlainText
elide
:
Text
.
ElideRight
maximumLineCount
:
1
...
...
src/qml/elements/RosterListItem.qml
View file @
2db4c8f6
...
...
@@ -33,6 +33,7 @@ import QtQuick.Layouts 1.3
import
QtQuick
.
Controls
2.3
as
Controls
import
QtGraphicalEffects
1.0
import
org
.
kde
.
kirigami
2.8
as
Kirigami
import
im
.
kaidan
.
kaidan
1.0
Kirigami.SwipeListItem
{
...
...
@@ -62,7 +63,7 @@ Kirigami.SwipeListItem {
width
:
Kirigami
.
Units
.
gridUnit
*
0.3
height
:
parent
.
height
color
:
kaidan
.
u
tils
.
presenceTypeToColor
(
presenceType
)
color
:
U
tils
.
presenceTypeToColor
(
presenceType
)
}
// left: avatar
...
...
@@ -126,7 +127,7 @@ Kirigami.SwipeListItem {
text
:
{
presenceType
===
Enums
.
PresError
?
// error presence type
qsTr
(
"
Error: Please check the JID.
"
)
:
kaidan
.
u
tils
.
removeNewLinesFromString
(
lastMessage
)
U
tils
.
removeNewLinesFromString
(
lastMessage
)
}
textFormat
:
Text
.
PlainText
font.pixelSize
:
Kirigami
.
Units
.
gridUnit
*
0.8
...
...
@@ -159,8 +160,8 @@ Kirigami.SwipeListItem {
}
// presence status type
string
+=
"
<font color='
"
+
kaidan
.
u
tils
.
presenceTypeToColor
(
statusType
)
+
"
'>
"
string
+=
kaidan
.
u
tils
.
presenceTypeToText
(
statusType
)
string
+=
"
<font color='
"
+
U
tils
.
presenceTypeToColor
(
statusType
)
+
"
'>
"
string
+=
U
tils
.
presenceTypeToText
(
statusType
)
string
+=
"
</font>
"
// presence status message
...
...
src/qml/elements/TextAvatar.qml
View file @
2db4c8f6
...
...
@@ -28,16 +28,18 @@
* along with Kaidan. If not, see <http://www.gnu.org/licenses/>.
*/
import
org
.
kde
.
kirigami
2.8
as
Kirigami
import
QtQuick
2.7
import
QtQuick
.
Layouts
1.3
import
org
.
kde
.
kirigami
2.8
as
Kirigami
import
im
.
kaidan
.
kaidan
1.0
Rectangle
{
id
:
avatar
property
string
name
color
:
Qt
.
lighter
(
kaidan
.
u
tils
.
getUserColor
(
name
))
color
:
Qt
.
lighter
(
U
tils
.
getUserColor
(
name
))
radius
:
width
*
0.5
Text
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment