Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Hadi Charara
Dolphin
Commits
b3df7c60
Commit
b3df7c60
authored
Jun 19, 2021
by
Hadi Charara
Browse files
Better show/hide logic
parent
8a5f426c
Pipeline
#66655
passed with stage
in 5 minutes and 53 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/panels/readme/readmepanel.cpp
View file @
b3df7c60
...
...
@@ -11,7 +11,8 @@ ReadmePanel::ReadmePanel ( QWidget* parent ) :
m_layout
(
nullptr
),
m_readmeWidget
(
nullptr
),
m_markdownPart
(
nullptr
),
m_readmeUrl
()
m_readmeUrl
(),
m_textBrowser
(
nullptr
)
{
m_layout
=
new
QVBoxLayout
(
this
);
m_layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
...
...
@@ -27,7 +28,7 @@ void ReadmePanel::showEvent ( QShowEvent* event )
}
m_markdownPart
=
factory
?
(
factory
->
create
<
KParts
::
ReadOnlyPart
>
(
this
))
:
nullptr
;
m_readmeWidget
=
m_markdownPart
->
widget
();
configureTextBrowser
(
m_readmeWidget
->
findChild
<
QTextBrowser
*>
()
);
configureTextBrowser
();
setFocusProxy
(
m_readmeWidget
);
m_layout
->
addWidget
(
m_readmeWidget
);
}
...
...
@@ -35,11 +36,13 @@ void ReadmePanel::showEvent ( QShowEvent* event )
Panel
::
showEvent
(
event
);
}
inline
void
ReadmePanel
::
configureTextBrowser
(
QTextBrowser
*
browser
)
inline
void
ReadmePanel
::
configureTextBrowser
()
{
browser
->
setFrameStyle
(
0
);
browser
->
setStyleSheet
(
"QTextEdit { background-color: transparent; }"
);
browser
->
scroll
(
0
,
0
);
if
(
!
m_textBrowser
)
m_textBrowser
=
m_readmeWidget
->
findChild
<
QTextBrowser
*>
();
if
(
!
m_textBrowser
)
return
;
m_textBrowser
->
setFrameStyle
(
0
);
m_textBrowser
->
setStyleSheet
(
"QTextEdit { background-color: transparent; }"
);
}
...
...
@@ -53,10 +56,10 @@ bool ReadmePanel::urlChanged()
m_readmeUrl
=
QUrl
(
url
().
toString
().
append
(
"/README.md"
));
QFileInfo
check_file
(
m_readmeUrl
.
path
());
if
(
!
m_readmeUrl
.
isValid
()
||
!
check_file
.
exists
())
{
this
->
hide
();
this
->
parentWidget
()
->
hide
();
return
false
;
}
this
->
show
();
this
->
parentWidget
()
->
show
();
m_markdownPart
->
openUrl
(
m_readmeUrl
);
return
true
;
}
src/panels/readme/readmepanel.h
View file @
b3df7c60
...
...
@@ -28,13 +28,14 @@ protected:
void
hideEvent
(
QHideEvent
*
event
)
override
;
private:
inline
void
configureTextBrowser
(
QTextBrowser
*
browser
);
inline
void
configureTextBrowser
();
private:
QVBoxLayout
*
m_layout
;
QWidget
*
m_readmeWidget
;
KParts
::
ReadOnlyPart
*
m_markdownPart
;
QUrl
m_readmeUrl
;
QTextBrowser
*
m_textBrowser
;
};
#endif // READMEPANEL_H
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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