Commit 0251f56e authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark
Browse files

WIP, still won't load the KPart

parent 12e90a0f
......@@ -45,8 +45,6 @@ find_package(KF5 REQUIRED
CoreAddons
)
set(CMAKE_AUTOMOC ON)
add_definitions(
-DQT_USE_FAST_CONCATENATION
-DQT_USE_FAST_OPERATOR_PLUS
......
......@@ -25,7 +25,7 @@ install(FILES filelightpartui.rc DESTINATION ${DATA_INSTALL_DIR}/filelightpart)
install(FILES filelightui.rc DESTINATION ${DATA_INSTALL_DIR}/filelight)
ecm_install_icons(ICONS
hi32-actions-view_filelight.png
hi32-action-views_filelight.png
hi16-apps-filelight.png
hi22-apps-filelight.png
hi32-apps-filelight.png
......
......@@ -28,6 +28,7 @@
#include <QIcon>
#include <QAction>
#include <QDebug>
inline HistoryAction::HistoryAction(const QIcon& icon, const QString& text, KActionCollection* ac)
: QAction(icon, text, ac)
......@@ -113,6 +114,11 @@ void HistoryCollection::save(KConfigGroup &configgroup)
void HistoryCollection::restore(const KConfigGroup &configgroup)
{
if (!m_b || !m_f) {
qWarning() << "what the actual fuck";
return;
}
m_b->m_list = QUrl::fromStringList(configgroup.readPathEntry("backHistory", QStringList()));
m_f->m_list = QUrl::fromStringList(configgroup.readPathEntry("forwardHistory", QStringList()));
//TODO texts are not updated - no matter
......
......@@ -53,7 +53,7 @@
namespace Filelight {
MainWindow::MainWindow() : KParts::MainWindow(), m_part(0)
MainWindow::MainWindow() : KParts::MainWindow(), m_part(0), m_histories(0)
{
// setXMLFile("filelightui.rc");
KPluginFactory *factory = KPluginLoader(QLatin1String( "filelightpart" )).factory();
......@@ -283,6 +283,8 @@ void MainWindow::urlAboutToChange()
void MainWindow::saveProperties(KConfigGroup &configgroup) //virtual
{
if (!m_histories) return;
m_histories->save(configgroup);
configgroup.writeEntry("currentMap", m_part->url().path());
}
......
......@@ -38,6 +38,6 @@ QT5_WRAP_UI(filelight_PART_SRCS dialog.ui)
add_library(filelightpart MODULE ${filelight_PART_SRCS})
target_link_libraries(filelightpart radialmap KF5::Parts KF5::KIOCore KF5::Solid)
target_link_libraries(filelightpart KF5::Parts KF5::KIOCore KF5::KIOWidgets KF5::Solid KF5::CoreAddons KF5::Service)
install(TARGETS filelightpart DESTINATION ${PLUGIN_INSTALL_DIR})
......@@ -23,9 +23,9 @@
#include <KConfig>
#include <KConfigGroup>
#include <KGlobal>
#include <KSharedConfig>
#include <KSharedPtr>
#include <QFont>
bool Config::scanAcrossMounts;
bool Config::scanRemoteMounts;
......@@ -42,7 +42,7 @@ QStringList Config::skipList;
void
Filelight::Config::read()
{
const KConfigGroup config = KGlobal::config()->group("filelight_part");
const KConfigGroup config = KSharedConfig::openConfig()->group("filelight_part");
scanAcrossMounts = config.readEntry("scanAcrossMounts", false);
scanRemoteMounts = config.readEntry("scanRemoteMounts", false);
......@@ -61,7 +61,7 @@ Filelight::Config::read()
void
Filelight::Config::write()
{
KConfigGroup config = KGlobal::config()->group("filelight_part");
KConfigGroup config = KSharedConfig::openConfig()->group("filelight_part");
config.writeEntry("scanAcrossMounts", scanAcrossMounts);
config.writeEntry("scanRemoteMounts", scanRemoteMounts);
......
......@@ -18,7 +18,7 @@
<number>0</number>
</property>
<item>
<widget class="KTabWidget" name="tabWidget">
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
......@@ -226,7 +226,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="KButtonGroup" name="colourSchemeGroup"/>
<widget class="QGroupBox" name="colourSchemeGroup"/>
</item>
<item>
<layout class="QHBoxLayout">
......@@ -399,20 +399,6 @@
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>KButtonGroup</class>
<extends>QGroupBox</extends>
<header>kbuttongroup.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>KTabWidget</class>
<extends>QTabWidget</extends>
<header>ktabwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>varyLabelFontSizes</tabstop>
......
......@@ -21,9 +21,6 @@
#include "fileTree.h"
#include <KGlobal>
#include <KLocale>
QString
File::fullPath(const Folder *root /*= 0*/) const
{
......
......@@ -22,11 +22,11 @@
#ifndef FILETREE_H
#define FILETREE_H
#include <QtCore/QByteArray> //qstrdup
#include <QtCore/QFile> //decodeName()
#include <QtCore/QDebug>
#include <kglobal.h>
#include <klocale.h>
#include <QByteArray> //qstrdup
#include <QFile> //decodeName()
#include <QDebug>
#include <QLocale>
#include <KFormat>
#include <stdlib.h>
......@@ -252,7 +252,7 @@ public:
QString fullPath(const Folder* = 0) const;
QString humanReadableSize() const {
return KGlobal::locale()->formatByteSize(m_size);
return KFormat().formatByteSize(m_size);
}
protected:
......
......@@ -25,14 +25,13 @@
#include "fileTree.h"
#include "scan.h"
#include <KDebug>
#include <Solid/StorageVolume>
#include <Solid/StorageAccess>
#include <Solid/Device>
#include <QtGui/QApplication> //postEvent()
#include <QtCore/QFile>
#include <QtCore/QByteArray>
#include <QGuiApplication> //postEvent()
#include <QFile>
#include <QByteArray>
#include <kde_file.h>
#include <dirent.h>
......@@ -87,13 +86,13 @@ LocalLister::run()
if (m_parent->m_abort) //scan was cancelled
{
kDebug() << "Scan successfully aborted";
qDebug() << "Scan successfully aborted";
delete tree;
tree = 0;
}
kDebug() << "Emitting signal to cache results ...";
qDebug() << "Emitting signal to cache results ...";
emit branchCompleted(tree, true);
kDebug() << "Thread terminating ...";
qDebug() << "Thread terminating ...";
}
#ifndef S_BLKSIZE
......@@ -107,7 +106,7 @@ outputError(QByteArray path)
{
///show error message that stat or opendir may give
#define out(s) kError() << s ": " << path; break
#define out(s) qWarning() << s ": " << path; break
switch (errno) {
case EACCES:
......@@ -204,7 +203,7 @@ LocalLister::scan(const QByteArray &path, const QByteArray &dirname)
{
if (new_path == (*it)->name8Bit())
{
kDebug() << "Tree pre-completed: " << (*it)->name();
qDebug() << "Tree pre-completed: " << (*it)->name();
d = it.remove();
m_parent->m_files += d->children();
//**** ideally don't have this redundant extra somehow
......@@ -250,8 +249,8 @@ void LocalLister::readMounts()
}
}
kDebug() << "Found the following remote filesystems: " << s_remoteMounts;
kDebug() << "Found the following local filesystems: " << s_localMounts;
qDebug() << "Found the following remote filesystems: " << s_remoteMounts;
qDebug() << "Found the following local filesystems: " << s_localMounts;
}
}//namespace Filelight
......
......@@ -31,19 +31,18 @@
#include "summaryWidget.h"
#include <KAboutData> //::createAboutData()
#include <KAction>
#include <QAction>
#include <KActionCollection>
#include <KLocale>
#include <KMessageBox> //::start()
#include <KStandardAction>
#include <KStatusBar>
#include <QStatusBar>
#include <KPluginFactory>
#include <QtCore/QFile> //encodeName()
#include <QtCore/QTimer> //postInit() hack
#include <QtCore/QByteArray>
#include <QtCore/QDir>
#include <QtGui/QScrollArea>
#include <QFile> //encodeName()
#include <QTimer> //postInit() hack
#include <QByteArray>
#include <QDir>
#include <QScrollArea>
#include <unistd.h> //access()
#include <iostream>
......@@ -51,20 +50,6 @@
namespace Filelight {
K_PLUGIN_FACTORY(filelightPartFactory, registerPlugin<Part>();) // produce a factory
K_EXPORT_PLUGIN(filelightPartFactory(KAboutData(
"filelightpart",
0,
ki18n(APP_PRETTYNAME),
APP_VERSION,
ki18n("Displays file usage in an easy to understand way."),
KAboutData::License_GPL,
ki18n("(c) 2002-2004 Max Howell\n\
(c) 2008-2013 Martin T. Sandsmark"),
KLocalizedString(),
"http://utils.kde.org/projects/filelight",
"martin.sandsmark@kde.org").
setProgramIconName(QLatin1String(APP_NAME)).
setCatalogName(APP_NAME)))
BrowserExtension::BrowserExtension(Part *parent)
: KParts::BrowserExtension(parent)
......@@ -80,7 +65,21 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&)
, m_started(false)
{
Config::read();
setComponentData(filelightPartFactory::componentData());
KAboutData aboutData(
QLatin1String("filelightpart"),
tr(APP_PRETTYNAME),
QLatin1String(APP_VERSION),
tr("Displays file usage in an easy to understand way."),
KAboutLicense::GPL,
tr("(c) 2002-2004 Max Howell\n\
(c) 2008-2014 Martin T. Sandsmark"),
QString(),
QLatin1String("http://utils.kde.org/projects/filelight"),
QLatin1String("martin.sandsmark@kde.org"));
aboutData.setProgramIconName(QLatin1String(APP_NAME));
setComponentData(aboutData);
setXMLFile(QLatin1String( "filelightpartui.rc" ));
QScrollArea *scrollArea = new QScrollArea(parentWidget);
......@@ -110,18 +109,18 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&)
KStandardAction::zoomIn(m_map, SLOT(zoomIn()), actionCollection());
KStandardAction::zoomOut(m_map, SLOT(zoomOut()), actionCollection());
KAction *action = actionCollection()->addAction(QLatin1String("configure_filelight"));
action->setText(i18n("Configure Filelight..."));
action->setIcon(KIcon(QLatin1String("configure")));
QAction *action = actionCollection()->addAction(QLatin1String("configure_filelight"));
action->setText(tr("Configure Filelight..."));
action->setIcon(QIcon(QLatin1String("configure")));
connect(action, SIGNAL(triggered()), this, SLOT(configFilelight()));
connect(m_map, SIGNAL(created(const Folder*)), SIGNAL(completed()));
connect(m_map, SIGNAL(created(const Folder*)), SLOT(mapChanged(const Folder*)));
connect(m_map, SIGNAL(activated(KUrl)), SLOT(updateURL(KUrl)));
connect(m_map, SIGNAL(activated(QUrl)), SLOT(updateURL(QUrl)));
// TODO make better system
connect(m_map, SIGNAL(giveMeTreeFor(KUrl)), SLOT(updateURL(KUrl)));
connect(m_map, SIGNAL(giveMeTreeFor(KUrl)), SLOT(openUrl(KUrl)));
connect(m_map, SIGNAL(giveMeTreeFor(QUrl)), SLOT(updateURL(QUrl)));
connect(m_map, SIGNAL(giveMeTreeFor(QUrl)), SLOT(openUrl(QUrl)));
connect(m_manager, SIGNAL(completed(Folder*)), SLOT(scanCompleted(Folder*)));
connect(m_manager, SIGNAL(aboutToEmptyCache()), m_map, SLOT(invalidate()));
......@@ -144,20 +143,19 @@ Part::postInit()
}
bool
Part::openUrl(const KUrl &u)
Part::openUrl(const QUrl &u)
{
//TODO everyone hates dialogs, instead render the text in big fonts on the Map
//TODO should have an empty KUrl until scan is confirmed successful
//TODO should have an empty QUrl until scan is confirmed successful
//TODO probably should set caption to QString::null while map is unusable
#define KMSG(s) KMessageBox::information(widget(), s)
KUrl uri = u;
uri.cleanPath(KUrl::SimplifyDirSeparators);
const QString path = uri.path(KUrl::AddTrailingSlash);
QUrl uri = u.adjusted(QUrl::NormalizePathSegments);
const QString path = uri.path();
const QByteArray path8bit = QFile::encodeName(path);
const bool isLocal = uri.protocol() == QLatin1String( "file" );
const bool isLocal = uri.scheme() == QLatin1String( "file" );
if (uri.isEmpty())
{
......@@ -165,19 +163,19 @@ Part::openUrl(const KUrl &u)
}
else if (!uri.isValid())
{
KMSG(i18n("The entered URL cannot be parsed; it is invalid."));
KMSG(tr("The entered URL cannot be parsed; it is invalid."));
}
else if ((!isLocal && path[0] != QLatin1Char( '/' )) || (isLocal && !QDir::isAbsolutePath(path)))
{
KMSG(i18n("Filelight only accepts absolute paths, eg. /%1", path));
KMSG(tr("Filelight only accepts absolute paths, eg. /%1").arg(path));
}
else if (isLocal && access(path8bit, F_OK) != 0) //stat(path, &statbuf) == 0
{
KMSG(i18n("Folder not found: %1", path));
KMSG(tr("Folder not found: %1").arg(path));
}
else if (isLocal && !QDir(path).isReadable()) //access(path8bit, R_OK | X_OK) != 0 doesn't work on win32
{
KMSG(i18n("Unable to enter: %1\nYou do not have access rights to this location.", path));
KMSG(tr("Unable to enter: %1\nYou do not have access rights to this location.").arg(path));
}
else
{
......@@ -198,7 +196,7 @@ bool
Part::closeUrl()
{
if (m_manager->abort())
statusBar()->showMessage(i18n("Aborting Scan..."));
statusBar()->showMessage(tr("Aborting Scan..."));
m_map->hide();
m_stateWidget->hide();
......@@ -209,11 +207,11 @@ Part::closeUrl()
}
void
Part::updateURL(const KUrl &u)
Part::updateURL(const QUrl &u)
{
//the map has changed internally, update the interface to reflect this
emit m_ext->openUrlNotify(); //must be done first
emit m_ext->setLocationBarUrl(u.prettyUrl());
emit m_ext->setLocationBarUrl(u.toString(QUrl::PreferLocalFile));
if (m_manager->running())
m_manager->abort();
......@@ -237,7 +235,7 @@ Part::configFilelight()
}
bool
Part::start(const KUrl &url)
Part::start(const QUrl &url)
{
if (!m_started) {
connect(m_map, SIGNAL(mouseHover(QString)), statusBar(), SLOT(message(QString)));
......@@ -253,7 +251,7 @@ Part::start(const KUrl &url)
if (m_manager->start(url)) {
setUrl(url);
const QString s = i18n("Scanning: %1", prettyUrl());
const QString s = tr("Scanning: %1").arg(prettyUrl());
stateChanged(QLatin1String( "scan_started" ));
emit started(0); //as a Part, we have to do this
emit setWindowCaption(s);
......@@ -289,7 +287,7 @@ void
Part::scanCompleted(Folder *tree)
{
if (tree) {
statusBar()->showMessage(i18n("Scan completed, generating map..."));
statusBar()->showMessage(tr("Scan completed, generating map..."));
m_stateWidget->hide();
m_map->show();
......@@ -299,12 +297,12 @@ Part::scanCompleted(Folder *tree)
}
else {
stateChanged(QLatin1String( "scan_failed" ));
emit canceled(i18n("Scan failed: %1", prettyUrl()));
emit canceled(tr("Scan failed: %1").arg(prettyUrl()));
emit setWindowCaption(QString());
statusBar()->clearMessage();
setUrl(KUrl());
setUrl(QUrl());
}
}
......@@ -317,8 +315,8 @@ Part::mapChanged(const Folder *tree)
const int fileCount = tree->children();
const QString text = ( fileCount == 0 ) ?
i18n("No files.") :
i18np("1 file", "%1 files",fileCount);
tr("No files.") :
tr("%n file(s)", "number of files found", fileCount);
m_numberOfFiles->setText(text);
}
......@@ -329,7 +327,7 @@ Part::showSummary()
if (m_summary == 0) {
m_summary = new SummaryWidget(widget());
m_summary->setObjectName(QLatin1String( "summaryWidget" ));
connect(m_summary, SIGNAL(activated(KUrl)), SLOT(openUrl(KUrl)));
connect(m_summary, SIGNAL(activated(QUrl)), SLOT(openUrl(QUrl)));
m_summary->show();
m_layout->addWidget(m_summary);
}
......
......@@ -23,15 +23,14 @@
#include "scan.h"
#include <KGlobal>
#include <KGlobalSettings>
#include <KColorScheme>
#include <KIO/Job>
#include <KLocale>
#include <QtGui/QLabel>
#include <QLabel>
#include <QPainter>
#include <QtCore/QDebug>
#include <QDebug>
#include <QFontDatabase>
#include <math.h>
......@@ -44,7 +43,7 @@ ProgressBox::ProgressBox(QWidget *parent, QObject *part, Filelight::ScanManager
setObjectName(QLatin1String( "ProgressBox" ));
setFont(KGlobalSettings::fixedFont());
setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
setText(999999);
......@@ -89,7 +88,7 @@ ProgressBox::halt()
void
ProgressBox::setText(int files)
{
m_text = i18np("%1 File", "%1 Files", files);
m_text = tr("%n file(s)", "files found so far during scan", files);
m_textWidth = fontMetrics().width(m_text);
m_textHeight = fontMetrics().height();
}
......
......@@ -22,8 +22,8 @@
#ifndef PROGRESSBOX_H
#define PROGRESSBOX_H
#include <QtGui/QLabel>
#include <QtCore/QTimer>
#include <QLabel>
#include <QTimer>
namespace Filelight {
class ScanManager;
......
......@@ -24,10 +24,7 @@
#include "widget.h"
#include <part/Config.h>
#include <part/fileTree.h>
#include <KGlobal> //locale object
#include <KLocale>
#include <KFormat>
//**** REMOVE NEED FOR the +1 with MAX_RING_DEPTH uses
//**** add some angle bounds checking (possibly in Segment ctor? can I delete in a ctor?)
......@@ -149,10 +146,9 @@ RadialMap::Builder::build(const Folder* const dir, const unsigned int depth, uns
{
//append a segment for unrepresented space - a "fake" segment
const QString s = i18np("1 file, with an average size of %2",
"%1 files, with an average size of %2",
hiddenFileCount,
KGlobal::locale()->formatByteSize(hiddenSize/hiddenFileCount));
const QString s = QObject::tr("%n file(s), with an average size of %1",
"description of a segment of several smaller files",
hiddenFileCount).arg(KFormat().formatByteSize(hiddenSize/hiddenFileCount));
(m_signature + depth)->append(new Segment(new File(s.toUtf8(), hiddenSize), a_start, a_end - a_start, true));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment