Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Buho
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
KDE
Buho
Commits
ca7387f5
Commit
ca7387f5
authored
Oct 02, 2018
by
Camilo higuita
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multiple fixes on linker, linkcarddelegate, etc...
parent
aee1f97a
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
300 additions
and
59 deletions
+300
-59
main.qml
main.qml
+1
-2
qml.qrc
qml.qrc
+1
-0
src/linker.cpp
src/linker.cpp
+19
-16
src/models/links/links.cpp
src/models/links/links.cpp
+3
-2
src/models/links/linksmodel.cpp
src/models/links/linksmodel.cpp
+6
-3
src/views/links/LinksView.qml
src/views/links/LinksView.qml
+29
-2
src/views/links/Previewer.qml
src/views/links/Previewer.qml
+2
-2
src/views/notes/NotesView.qml
src/views/notes/NotesView.qml
+28
-1
src/widgets/CardsView.qml
src/widgets/CardsView.qml
+0
-28
src/widgets/LinkCardDelegate.qml
src/widgets/LinkCardDelegate.qml
+206
-0
src/widgets/NewLinkDialog.qml
src/widgets/NewLinkDialog.qml
+3
-3
src/widgets/linkcarddelegate.qrc
src/widgets/linkcarddelegate.qrc
+2
-0
No files found.
main.qml
View file @
ca7387f5
...
...
@@ -135,8 +135,7 @@ Maui.ApplicationWindow
NewLinkDialog
{
id
:
newLinkDialog
onLinkSaved
:
if
(
owl
.
insertLink
(
link
))
linksView
.
cardsView
.
currentItem
.
update
(
note
)
onLinkSaved
:
linksView
.
model
.
insert
(
link
)
}
...
...
qml.qrc
View file @
ca7387f5
...
...
@@ -17,5 +17,6 @@
<file>src/widgets/CardsList.qml</file>
<file>src/widgets/CardMenu.qml</file>
<file>src/utils/owl.js</file>
<file>src/widgets/LinkCardDelegate.qml</file>
</qresource>
</RCC>
src/linker.cpp
View file @
ca7387f5
...
...
@@ -45,31 +45,34 @@ void Linker::extract(const QString &url)
{
auto
data
=
getUrl
(
url
);
QString
title
=
url
;
auto
titles
=
query
(
data
,
HtmlTag
::
TITLE
);
QStringList
imgs
;
// auto tags = query(data, HtmlTag::META);
if
(
!
titles
.
isEmpty
())
title
=
titles
[
0
];
title
=
title
.
isEmpty
()
?
url
:
title
;
QStringList
imgs
;
// auto tags = query(data, HtmlTag::META);
for
(
auto
img
:
query
(
data
,
HtmlTag
::
IMG
,
"src"
))
{
if
(
imgs
.
contains
(
img
)
||
img
.
isEmpty
())
continue
;
qDebug
()
<<
"IMGAE URL"
<<
img
;
if
((
img
.
startsWith
(
"http"
)
||
img
.
startsWith
(
"https"
))
&&
(
img
.
endsWith
(
".png"
,
Qt
::
CaseInsensitive
)
||
img
.
endsWith
(
".jpg"
,
Qt
::
CaseInsensitive
)
||
img
.
endsWith
(
".gif"
,
Qt
::
CaseInsensitive
)
||
img
.
endsWith
(
".jpeg"
,
Qt
::
CaseInsensitive
)))
if
(
url
.
at
(
url
.
length
()
-
1
)
==
"/"
)
{
if
(
img
.
startsWith
(
"http"
))
imgs
<<
img
;
else
imgs
<<
url
+
img
;
}
else
{
if
(
img
.
startsWith
(
"http"
))
imgs
<<
img
;
else
imgs
<<
url
+
"/"
+
img
;
else
continue
;
}
}
LINK
link_data
{{
OWL
::
KEYMAP
[
OWL
::
KEY
::
TITLE
],
title
s
},
LINK
link_data
{{
OWL
::
KEYMAP
[
OWL
::
KEY
::
TITLE
],
title
.
trimmed
()
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
BODY
],
data
},
{
OWL
::
KEYMAP
[
OWL
::
KEY
::
IMAGE
],
imgs
}};
emit
previewReady
(
link_data
);
...
...
src/models/links/links.cpp
View file @
ca7387f5
...
...
@@ -57,12 +57,13 @@ bool Links::insertLink(const QVariantMap &link)
for
(
auto
tg
:
tags
)
this
->
tag
->
tagAbstract
(
tg
,
OWL
::
TABLEMAP
[
OWL
::
TABLE
::
LINKS
],
url
,
color
);
this
->
links
<<
OWL
::
DB
({
{
OWL
::
KEY
::
LINK
,
url
},
{
OWL
::
KEY
::
TITLE
,
title
},
{
OWL
::
KEY
::
COLOR
,
color
},
{
OWL
::
KEY
::
PREVIEW
,
preview
},
{
OWL
::
KEY
::
PREVIEW
,
image_path
},
{
OWL
::
KEY
::
PIN
,
QString
::
number
(
pin
)},
{
OWL
::
KEY
::
FAV
,
QString
::
number
(
fav
)},
{
OWL
::
KEY
::
UPDATED
,
QDateTime
::
currentDateTime
().
toString
()},
...
...
@@ -70,7 +71,7 @@ bool Links::insertLink(const QVariantMap &link)
});
return
true
;
}
}
else
qDebug
()
<<
"LINK COULD NTO BE INSTED"
;
return
false
;
}
...
...
src/models/links/linksmodel.cpp
View file @
ca7387f5
...
...
@@ -42,9 +42,12 @@ void LinksModel::sortBy(const int &index, const QString &order)
bool
LinksModel
::
insert
(
const
QVariantMap
&
link
)
{
const
int
index
=
mLinks
->
items
().
size
();
if
(
this
->
mLinks
->
insertLink
(
link
))
{
beginInsertRows
(
QModelIndex
(),
index
,
index
);
this
->
mLinks
->
insertLink
(
link
);
endInsertRows
();
}
return
false
;
}
...
...
src/views/links/LinksView.qml
View file @
ca7387f5
import
QtQuick
2.9
import
QtQuick
.
Controls
2.3
import
org
.
kde
.
mauikit
1.0
as
Maui
import
org
.
kde
.
kirigami
2.2
as
Kirigami
import
"
../../widgets
"
import
"
../../utils/owl.js
"
as
O
...
...
@@ -109,7 +110,6 @@ Maui.Page
{
id
:
cardsView
anchors.fill
:
parent
onItemClicked
:
linkClicked
(
cardsView
.
model
.
get
(
index
))
holder.emoji
:
"
qrc:/Astronaut.png
"
holder.isMask
:
false
holder.title
:
"
No Links!
"
...
...
@@ -117,6 +117,33 @@ Maui.Page
holder.emojiSize
:
iconSizes
.
huge
itemHeight
:
unit
*
250
model
:
linksModel
delegate
:
LinkCardDelegate
{
id
:
delegate
cardWidth
:
Math
.
min
(
cardsView
.
cellWidth
,
cardsView
.
itemWidth
)
-
Kirigami
.
Units
.
largeSpacing
*
2
cardHeight
:
cardsView
.
itemHeight
anchors.left
:
parent
.
left
anchors.leftMargin
:
cardsView
.
width
<=
cardsView
.
itemWidth
?
0
:
(
index
%
2
===
0
?
Math
.
max
(
0
,
cardsView
.
cellWidth
-
cardsView
.
itemWidth
)
:
cardsView
.
cellWidth
)
onClicked
:
{
currentIndex
=
index
linkClicked
(
cardsView
.
model
.
get
(
index
))
}
onRightClicked
:
{
currentIndex
=
index
cardsView
.
menu
.
popup
()
}
onPressAndHold
:
{
currentIndex
=
index
cardsView
.
menu
.
popup
()
}
}
Connections
{
...
...
src/views/links/Previewer.qml
View file @
ca7387f5
...
...
@@ -7,8 +7,8 @@ import "../../widgets"
Maui.Popup
{
parent
:
parent
heightHint
:
0.9
5
widthHint
:
0.9
5
heightHint
:
0.9
7
widthHint
:
0.9
7
maxWidth
:
800
*
unit
maxHeight
:
maxWidth
...
...
src/views/notes/NotesView.qml
View file @
ca7387f5
...
...
@@ -145,7 +145,6 @@ Maui.Page
Layout.fillHeight
:
true
Layout.fillWidth
:
true
width
:
parent
.
width
onItemClicked
:
noteClicked
(
notesModel
.
get
(
index
))
holder.emoji
:
"
qrc:/Type.png
"
holder.emojiSize
:
iconSizes
.
huge
holder.isMask
:
false
...
...
@@ -153,6 +152,34 @@ Maui.Page
holder.body
:
"
Click here to create a new note
"
model
:
notesModel
delegate
:
CardDelegate
{
id
:
delegate
cardWidth
:
Math
.
min
(
cardsView
.
cellWidth
,
cardsView
.
itemWidth
)
-
Kirigami
.
Units
.
largeSpacing
*
2
cardHeight
:
cardsView
.
itemHeight
anchors.left
:
parent
.
left
anchors.leftMargin
:
cardsView
.
width
<=
cardsView
.
itemWidth
?
0
:
(
index
%
2
===
0
?
Math
.
max
(
0
,
cardsView
.
cellWidth
-
cardsView
.
itemWidth
)
:
cardsView
.
cellWidth
)
onClicked
:
{
currentIndex
=
index
noteClicked
(
notesModel
.
get
(
index
))
}
onRightClicked
:
{
currentIndex
=
index
cardsView
.
menu
.
popup
()
}
onPressAndHold
:
{
currentIndex
=
index
cardsView
.
menu
.
popup
()
}
}
Connections
{
target
:
cardsView
.
holder
...
...
src/widgets/CardsView.qml
View file @
ca7387f5
...
...
@@ -36,33 +36,5 @@ GridView
id
:
cardMenu
}
delegate
:
CardDelegate
{
id
:
delegate
cardWidth
:
Math
.
min
(
control
.
cellWidth
,
control
.
itemWidth
)
-
Kirigami
.
Units
.
largeSpacing
*
2
cardHeight
:
itemHeight
anchors.left
:
parent
.
left
anchors.leftMargin
:
control
.
width
<=
control
.
itemWidth
?
0
:
(
index
%
2
===
0
?
Math
.
max
(
0
,
control
.
cellWidth
-
control
.
itemWidth
)
:
control
.
cellWidth
)
onClicked
:
{
currentIndex
=
index
itemClicked
(
index
)
}
onRightClicked
:
{
currentIndex
=
index
cardMenu
.
popup
()
}
onPressAndHold
:
{
currentIndex
=
index
cardMenu
.
popup
()
}
}
ScrollBar.vertical
:
ScrollBar
{
id
:
scrollBar
;
visible
:
!
isMobile
}
}
src/widgets/LinkCardDelegate.qml
0 → 100644
View file @
ca7387f5
import
QtQuick
2.9
import
QtQuick
.
Controls
2.2
import
QtQuick
.
Layouts
1.3
import
QtGraphicalEffects
1.0
import
org
.
kde
.
kirigami
2.2
as
Kirigami
ItemDelegate
{
id
:
control
property
string
noteColor
:
model
.
color
?
model
.
color
:
viewBackgroundColor
property
int
cardWidth
:
visible
?
unit
*
200
:
0
property
int
cardHeight
:
visible
?
unit
*
120
:
0
property
int
cardRadius
:
radiusV
property
bool
condition
:
true
signal
rightClicked
();
visible
:
condition
width
:
cardWidth
height
:
cardHeight
hoverEnabled
:
!
isMobile
background
:
Rectangle
{
color
:
"
transparent
"
}
MouseArea
{
anchors.fill
:
parent
acceptedButtons
:
Qt
.
RightButton
onClicked
:
{
if
(
!
isMobile
&&
mouse
.
button
===
Qt
.
RightButton
)
rightClicked
()
}
}
Rectangle
{
id
:
card
z
:
-
999
anchors.centerIn
:
control
anchors.fill
:
control
border.color
:
Qt
.
darker
(
noteColor
,
1.2
)
color
:
noteColor
radius
:
cardRadius
Loader
{
id
:
imgLoader
anchors.fill
:
parent
anchors.margins
:
space
.
small
clip
:
true
sourceComponent
:
typeof
model
.
preview
!==
'
undefined
'
?
imgComponent
:
undefined
}
}
Rectangle
{
anchors.fill
:
parent
color
:
hovered
?
"
#333
"
:
"
transparent
"
z
:
999
opacity
:
0.2
radius
:
cardRadius
}
Item
{
visible
:
title
.
text
.
length
>
0
height
:
layout
.
implicitHeight
+
space
.
big
anchors.right
:
parent
.
right
anchors.left
:
parent
.
left
anchors.bottom
:
parent
.
bottom
anchors.margins
:
unit
ColumnLayout
{
id
:
layout
anchors.fill
:
parent
anchors.margins
:
space
.
small
spacing
:
0
Label
{
id
:
date
Layout.fillWidth
:
true
Layout.fillHeight
:
true
padding
:
0
visible
:
date
.
text
.
length
>
0
text
:
Qt
.
formatDateTime
(
new
Date
(
model
.
updated
),
"
d MMM h:mm
"
)
color
:
model
.
color
?
Qt
.
darker
(
model
.
color
)
:
textColor
elide
:
Qt
.
ElideRight
wrapMode
:
TextEdit
.
WrapAnywhere
font.weight
:
Font
.
Bold
font.bold
:
true
font.pointSize
:
fontSizes
.
small
}
Label
{
id
:
title
padding
:
0
Layout.fillWidth
:
true
Layout.fillHeight
:
true
text
:
model
.
title
?
model
.
title
:
""
color
:
model
.
color
?
Qt
.
darker
(
model
.
color
,
3
)
:
textColor
elide
:
Qt
.
ElideRight
wrapMode
:
TextEdit
.
WrapAnywhere
font.weight
:
Font
.
Bold
font.bold
:
true
font.pointSize
:
fontSizes
.
large
clip
:
true
}
}
Rectangle
{
anchors.fill
:
parent
color
:
noteColor
z
:
-
1
}
}
Component
{
id
:
bodyComponent
TextArea
{
id
:
body
padding
:
0
visible
:
typeof
model
.
body
!==
'
undefined
'
enabled
:
false
text
:
model
.
body
?
model
.
body
:
""
color
:
model
.
color
?
Qt
.
darker
(
model
.
color
,
3
)
:
textColor
wrapMode
:
TextEdit
.
WrapAnywhere
textFormat
:
TextEdit
.
RichText
font.pointSize
:
fontSizes
.
big
background
:
Rectangle
{
color
:
"
transparent
"
}
}
}
Component
{
id
:
imgComponent
Image
{
id
:
img
visible
:
status
===
Image
.
Ready
asynchronous
:
true
horizontalAlignment
:
Qt
.
AlignHCenter
verticalAlignment
:
Qt
.
AlignVCenter
height
:
parent
.
height
width
:
parent
.
width
sourceSize.height
:
height
sourceSize.width
:
width
fillMode
:
Image
.
PreserveAspectCrop
source
:
model
.
preview
?
"
file://
"
+
encodeURIComponent
(
model
.
preview
)
:
''
layer.enabled
:
img
.
visible
layer.effect
:
OpacityMask
{
maskSource
:
Item
{
width
:
img
.
width
height
:
img
.
height
Rectangle
{
anchors.centerIn
:
parent
width
:
img
.
width
height
:
img
.
height
radius
:
cardRadius
// radius: Math.min(width, height)
}
}
}
}
}
function
update
(
item
)
{
console
.
log
(
"
update link color
"
,
item
.
color
,
item
.
tag
)
model
.
title
=
item
.
title
model
.
body
=
item
.
body
model
.
color
=
item
.
color
model
.
pin
=
item
.
pin
?
1
:
0
model
.
fav
=
item
.
fav
?
1
:
0
model
.
updated
=
item
.
updated
model
.
tag
=
item
.
tag
.
join
(
"
,
"
)
}
}
src/widgets/NewLinkDialog.qml
View file @
ca7387f5
...
...
@@ -235,7 +235,7 @@ Maui.Popup
function
fill
(
link
)
{
title
.
text
=
link
.
title
[
0
]
title
.
text
=
link
.
title
populatePreviews
(
link
.
image
)
open
()
...
...
@@ -254,7 +254,7 @@ Maui.Popup
{
var
data
=
({
link
:
link
.
text
,
title
:
title
.
text
.
trim
()
,
title
:
title
.
text
,
preview
:
previewList
.
count
>
0
?
previewList
.
model
.
get
(
previewList
.
currentIndex
).
url
:
""
,
color
:
selectedColor
,
tag
:
tagBar
.
getTags
(),
...
...
src/widgets/linkcarddelegate.qrc
0 → 100644
View file @
ca7387f5
<!DOCTYPE RCC>
<RCC
version=
"1.0"
/>
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