Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Utilities
Filelight
Commits
f25988dc
Commit
f25988dc
authored
Dec 24, 2019
by
Martin Tobias Holmedahl Sandsmark
Committed by
Martin Tobias Holmedahl Sandsmark
Oct 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for saving result as SVG.
parent
30c12371
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
47 additions
and
11 deletions
+47
-11
CMakeLists.txt
CMakeLists.txt
+1
-1
src/CMakeLists.txt
src/CMakeLists.txt
+1
-0
src/mainWindow.cpp
src/mainWindow.cpp
+13
-0
src/mainWindow.h
src/mainWindow.h
+1
-0
src/radialMap/map.cpp
src/radialMap/map.cpp
+25
-8
src/radialMap/map.h
src/radialMap/map.h
+3
-1
src/radialMap/widget.cpp
src/radialMap/widget.cpp
+1
-1
src/radialMap/widget.h
src/radialMap/widget.h
+2
-0
No files found.
CMakeLists.txt
View file @
f25988dc
...
...
@@ -49,7 +49,7 @@ include(KDECMakeSettings)
include
(
KDEFrameworkCompilerSettings NO_POLICY_SCOPE
)
include
(
ECMQtDeclareLoggingCategory
)
find_package
(
Qt5
${
QT_REQUIRED_VERSION
}
CONFIG REQUIRED Core Widgets
)
find_package
(
Qt5
${
QT_REQUIRED_VERSION
}
CONFIG REQUIRED Core Widgets
Svg
)
find_package
(
KF5
${
KF5_MIN_VERSION
}
REQUIRED
XmlGui
# For app
KIO
# For part
...
...
src/CMakeLists.txt
View file @
f25988dc
...
...
@@ -58,6 +58,7 @@ target_link_libraries(filelight
KF5::I18n
KF5::XmlGui
KF5::KIOWidgets
# Only used for KDirLister, may be able to move away from that.
Qt5::Svg
)
if
(
WIN32
)
find_package
(
KDEWin REQUIRED
)
...
...
src/mainWindow.cpp
View file @
f25988dc
...
...
@@ -140,6 +140,7 @@ void MainWindow::setupActions() //singleton function
m_combo
->
setDuplicatesEnabled
(
false
);
KStandardAction
::
open
(
this
,
SLOT
(
slotScanFolder
()),
ac
);
KStandardAction
::
save
(
this
,
SLOT
(
slotSaveSvg
()),
ac
)
->
setEnabled
(
false
);
KStandardAction
::
quit
(
this
,
SLOT
(
close
()),
ac
);
KStandardAction
::
up
(
this
,
SLOT
(
slotUp
()),
ac
);
KStandardAction
::
configureToolbars
(
this
,
SLOT
(
configToolbars
()),
ac
);
...
...
@@ -229,6 +230,16 @@ void MainWindow::slotScanHomeFolder()
slotScanPath
(
QDir
::
homePath
());
}
void
MainWindow
::
slotSaveSvg
()
{
QString
path
=
QFileDialog
::
getSaveFileName
(
this
,
i18n
(
"Save to SVG"
));
if
(
path
.
isEmpty
())
{
return
;
}
m_map
->
saveSvg
(
path
);
}
void
MainWindow
::
slotScanRootFolder
()
{
slotScanPath
(
QDir
::
rootPath
());
...
...
@@ -297,6 +308,8 @@ void MainWindow::scanCompleted()
stateChanged
(
QStringLiteral
(
"scan_complete"
));
action
(
"file_save"
)
->
setEnabled
(
true
);
m_combo
->
lineEdit
()
->
setText
(
prettyUrl
());
if
(
url
.
toLocalFile
()
==
QLatin1String
(
"/"
))
{
...
...
src/mainWindow.h
View file @
f25988dc
...
...
@@ -66,6 +66,7 @@ private Q_SLOTS:
void
slotComboScan
();
void
slotScanFolder
();
void
slotScanHomeFolder
();
void
slotSaveSvg
();
void
slotScanRootFolder
();
bool
slotScanUrl
(
const
QUrl
&
);
bool
slotScanPath
(
const
QString
&
);
...
...
src/radialMap/map.cpp
View file @
f25988dc
...
...
@@ -25,6 +25,7 @@
#include <QFontMetrics> //ctor
#include <QPainter>
#include <QBrush>
#include <QSvgGenerator>
#include "filelight_debug.h"
#include <KCursor> //make()
...
...
@@ -69,6 +70,13 @@ void RadialMap::Map::invalidate()
m_visibleDepth
=
Config
::
defaultRingDepth
;
}
void
RadialMap
::
Map
::
saveSvg
(
const
QString
&
path
)
{
QSvgGenerator
svgGenerator
;
svgGenerator
.
setFileName
(
path
);
paint
(
&
svgGenerator
);
}
void
RadialMap
::
Map
::
make
(
const
Folder
*
tree
,
bool
refresh
)
{
//slow operation so set the wait cursor
...
...
@@ -356,7 +364,7 @@ void RadialMap::Map::colorise()
}
}
void
RadialMap
::
Map
::
paint
(
bool
antialias
)
void
RadialMap
::
Map
::
paint
(
QPaintDevice
*
paintDevice
)
{
KColorScheme
scheme
(
QPalette
::
Active
,
KColorScheme
::
View
);
...
...
@@ -364,7 +372,14 @@ void RadialMap::Map::paint(bool antialias)
QRectF
rect
=
m_rect
;
rect
.
adjust
(
MAP_HIDDEN_TRIANGLE_SIZE
,
MAP_HIDDEN_TRIANGLE_SIZE
,
-
MAP_HIDDEN_TRIANGLE_SIZE
,
-
MAP_HIDDEN_TRIANGLE_SIZE
);
m_pixmap
.
fill
(
Qt
::
transparent
);
if
(
!
paintDevice
)
{
if
(
m_pixmap
.
isNull
())
{
return
;
}
m_pixmap
.
fill
(
Qt
::
transparent
);
paintDevice
=
&
m_pixmap
;
}
//m_rect.moveRight(1); // Uncommenting this breaks repainting when recreating map from cache
...
...
@@ -372,15 +387,12 @@ void RadialMap::Map::paint(bool antialias)
//**** best option you can think of is to make the circles slightly less perfect,
// ** i.e. slightly eliptic when resizing inbetween
if
(
m_pixmap
.
isNull
())
return
;
if
(
!
paint
.
begin
(
&
m_pixmap
))
{
qCWarning
(
FILELIGHT_LOG
)
<<
"Filelight::RadialMap Failed to initialize painting, returning..."
;
if
(
!
paint
.
begin
(
paintDevice
))
{
qWarning
()
<<
"Filelight::RadialMap Failed to initialize painting, returning..."
;
return
;
}
if
(
antialias
&&
Config
::
antialias
)
{
if
(
Config
::
antialias
)
{
paint
.
translate
(
0.7
,
0.7
);
paint
.
setRenderHint
(
QPainter
::
Antialiasing
);
}
...
...
@@ -394,6 +406,11 @@ void RadialMap::Map::paint(bool antialias)
++
step
;
}
if
(
m_signature
.
isEmpty
())
{
qWarning
()
<<
"Map not created yet"
;
return
;
}
for
(
int
x
=
m_visibleDepth
;
x
>=
0
;
--
x
)
{
int
width
=
rect
.
width
()
/
2
;
...
...
src/radialMap/map.h
View file @
f25988dc
...
...
@@ -57,11 +57,13 @@ public:
return
m_pixmap
;
}
void
saveSvg
(
const
QString
&
path
);
friend
class
Widget
;
private:
void
paint
(
bool
antialias
=
true
);
void
paint
(
QPaintDevice
*
paintDevice
=
nullptr
);
void
colorise
();
void
setRingBreadth
();
void
findVisibleDepth
(
const
Folder
*
dir
,
uint
currentDepth
=
0
);
...
...
src/radialMap/widget.cpp
View file @
f25988dc
...
...
@@ -174,7 +174,7 @@ RadialMap::Widget::refresh(int filth)
break
;
case
2
:
m_map
.
paint
(
true
);
//antialiased painting
m_map
.
paint
(
);
break
;
case
3
:
...
...
src/radialMap/widget.h
View file @
f25988dc
...
...
@@ -66,6 +66,8 @@ public:
friend
class
Label
;
//FIXME badness
void
saveSvg
(
const
QString
&
path
)
{
m_map
.
saveSvg
(
path
);
}
public
Q_SLOTS
:
void
zoomIn
();
void
zoomOut
();
...
...
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