Port the app itself.

parent 64c90af0
......@@ -21,22 +21,32 @@
#include "historyAction.h"
#include <KAction>
#include <KActionCollection>
#include <KConfig>
#include <KConfigGroup>
#include <KLocale>
#include <KStandardShortcut>
inline HistoryAction::HistoryAction(const KIcon &icon, const QString &text, KActionCollection *ac)
: KAction(icon, text, ac)
#include <QIcon>
#include <QAction>
inline HistoryAction::HistoryAction(const QIcon& icon, const QString& text, KActionCollection* ac)
: QAction(icon, text, ac)
, m_text(text)
{
// .ui files make this false, but we can't rely on UI file as it isn't compiled in :(
setEnabled(false);
}
void HistoryAction::push(const QString &path)
void HistoryAction::setHelpText(const QUrl& url)
{
QString text = url.path();
setStatusTip(text);
setToolTip(text);
setWhatsThis(text);
}
void HistoryAction::push(const QUrl &path)
{
if (path.isEmpty()) return;
......@@ -47,9 +57,9 @@ void HistoryAction::push(const QString &path)
setEnabled(true);
}
QString HistoryAction::pop()
QUrl HistoryAction::pop()
{
const QString s = m_list.takeLast();
const QUrl s = m_list.takeLast();
if (!m_list.isEmpty())
setHelpText(m_list.last());
......@@ -61,8 +71,8 @@ QString HistoryAction::pop()
HistoryCollection::HistoryCollection(KActionCollection *ac, QObject *parent)
: QObject(parent)
, m_b(new HistoryAction(KIcon(QLatin1String( "go-previous" )), i18nc("Go to the last path viewed", "Back"), ac))
, m_f(new HistoryAction(KIcon(QLatin1String( "go-next" )), i18nc("Go to forward in the history of paths viewed", "Forward"), ac))
, m_b(new HistoryAction(QIcon(QLatin1String( "go-previous" )), tr("Back", "Go to the last path viewed"), ac))
, m_f(new HistoryAction(QIcon(QLatin1String( "go-next" )), tr("Forward", "Go to forward in the history of paths viewed"), ac))
, m_receiver(0)
{
ac->addAction(QLatin1String( "go_back" ), m_b);
......@@ -71,7 +81,7 @@ HistoryCollection::HistoryCollection(KActionCollection *ac, QObject *parent)
connect(m_f, SIGNAL(triggered(bool)), SLOT(pop()));
}
void HistoryCollection::push(const KUrl &url) //slot
void HistoryCollection::push(const QUrl& url) //slot
{
if (!url.isEmpty())
{
......@@ -81,16 +91,14 @@ void HistoryCollection::push(const KUrl &url) //slot
m_receiver = m_b;
}
m_receiver->push(url.path(KUrl::AddTrailingSlash));
m_receiver->push(url.path());
}
m_receiver = 0;
}
void HistoryCollection::pop() //slot
{
KUrl url;
const QString path = ((HistoryAction*)sender())->pop(); //FIXME here we remove the constness
url.setPath(path);
QUrl url = ((HistoryAction*)sender())->pop();
m_receiver = (sender() == m_b) ? m_f : m_b;
......@@ -99,14 +107,14 @@ void HistoryCollection::pop() //slot
void HistoryCollection::save(KConfigGroup &configgroup)
{
configgroup.writePathEntry("backHistory", m_b->m_list);
configgroup.writePathEntry("forwardHistory", m_f->m_list);
configgroup.writePathEntry("backHistory", QUrl::toStringList(m_b->m_list));
configgroup.writePathEntry("forwardHistory", QUrl::toStringList(m_f->m_list));
}
void HistoryCollection::restore(const KConfigGroup &configgroup)
{
m_b->m_list = configgroup.readPathEntry("backHistory", QStringList());
m_f->m_list = configgroup.readPathEntry("forwardHistory", QStringList());
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
}
......
/***********************************************************************
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
* Copyright 2008-2009 Martin Sandsmark <martin.sandsmark@kde.org>
* Copyright 2008-2014 Martin Sandsmark <martin.sandsmark@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -22,38 +22,38 @@
#ifndef HISTORYACTION_H
#define HISTORYACTION_H
#include <KAction>
#include <QAction>
#include <QStringList>
#include <KUrl>
#include <QUrl>
class KConfigGroup;
class KActionCollection;
class HistoryAction : KAction
class HistoryAction : QAction
{
HistoryAction(const KIcon &icon, const QString &text, KActionCollection *ac);
HistoryAction(const QIcon &icon, const QString &text, KActionCollection *ac);
friend class HistoryCollection;
public:
virtual void setEnabled(bool b = true) {
KAction::setEnabled(b && !m_list.isEmpty());
QAction::setEnabled(b && !m_list.isEmpty());
}
void clear() {
m_list.clear();
setEnabled(false);
KAction::setText(m_text);
QAction::setText(m_text);
}
private:
void setText();
void setHelpText(const QUrl& url);
void push(const QString &path);
QString pop();
void push(const QUrl &url);
QUrl pop();
const QString m_text;
QStringList m_list;
QList<QUrl> m_list;
};
......@@ -68,13 +68,13 @@ public:
void restore(const KConfigGroup &configgroup);
public slots:
void push(const KUrl&);
void push(const QUrl& url);
void stop() {
m_receiver = 0;
}
signals:
void activated(const KUrl&);
void activated(const QUrl&);
private slots:
void pop();
......
/***********************************************************************
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
* Copyright 2008-2009 Martin Sandsmark <martin.sandsmark@kde.org>
* Copyright 2008-2014 Martin Sandsmark <martin.sandsmark@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
......@@ -23,52 +23,54 @@
#include "mainWindow.h"
#include <KAboutData>
#include <KApplication>
#include <KCmdLineArgs>
#include <KLocale>
#include <KUrl>
#include <QApplication>
#include <QCommandLineParser>
#include <QUrl>
static KAboutData about(
APP_NAME,
0,
ki18n(APP_PRETTYNAME),
APP_VERSION,
ki18n("Graphical disk-usage information"),
KAboutData::License_GPL,
ki18n("(C) 2006 Max Howell\n\
(C) 2008-2013 Martin Sandsmark"),
KLocalizedString(),
"http://utils.kde.org/projects/filelight");
QLatin1String(APP_NAME),
QObject::tr(APP_PRETTYNAME),
QLatin1String(APP_VERSION),
QObject::tr("Graphical disk-usage information"),
KAboutLicense::GPL,
QObject::tr("(C) 2006 Max Howell\n\
(C) 2008-2014 Martin Sandsmark"),
QString(),
QLatin1String("http://utils.kde.org/projects/filelight")
);
int main(int argc, char *argv[])
{
using Filelight::MainWindow;
about.addAuthor(ki18n("Martin Sandsmark"), ki18n("Maintainer"), "martin.sandsmark@kde.org", "http://iskrembilen.com/");
about.addAuthor(ki18n("Max Howell"), ki18n("Original author"), "max.howell@methylblue.com", "http://www.methylblue.com/");
about.addCredit(ki18n("Lukas Appelhans"), ki18n("Help and support"));
about.addCredit(ki18n("Steffen Gerlach"), ki18n("Inspiration"), 0, "http://www.steffengerlach.de/");
about.addCredit(ki18n("Mike Diehl"), ki18n("Original documentation"), 0, 0);
about.addCredit(ki18n("Sune Vuorela"), ki18n("Icon"), 0, 0);
about.addCredit(ki18n("Nuno Pinheiro"), ki18n("Icon"), 0, 0);
about.addAuthor(QObject::tr("Martin Sandsmark"), QObject::tr("Maintainer"), QLatin1String("martin.sandsmark@kde.org"), QLatin1String("http://iskrembilen.com/"));
about.addAuthor(QObject::tr("Max Howell"), QObject::tr("Original author"), QLatin1String("max.howell@methylblue.com"), QLatin1String("http://www.methylblue.com/"));
about.addCredit(QObject::tr("Lukas Appelhans"), QObject::tr("Help and support"));
about.addCredit(QObject::tr("Steffen Gerlach"), QObject::tr("Inspiration"), QString(), QLatin1String("http://www.steffengerlach.de/"));
about.addCredit(QObject::tr("Mike Diehl"), QObject::tr("Original documentation"));
about.addCredit(QObject::tr("Sune Vuorela"), QObject::tr("Icon"));
about.addCredit(QObject::tr("Nuno Pinheiro"), QObject::tr("Icon"));
KCmdLineArgs::init(argc, argv, &about);
QApplication app(argc, argv);
app.setApplicationName(QLatin1String(APP_NAME));
app.setApplicationDisplayName(QObject::tr(APP_PRETTYNAME));
app.setApplicationVersion(QLatin1String(APP_VERSION));
app.setOrganizationDomain(QLatin1String("kde.org"));
app.setOrganizationName(QLatin1String("KDE"));
KCmdLineOptions options;
KLocale *tmpLocale = new KLocale(QLatin1String(APP_NAME));
options.add(ki18nc("Path in the file system to scan", "+[path]").toString(tmpLocale).toLocal8Bit(), ki18n("Scan 'path'"));
delete tmpLocale;
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
QCommandLineParser options;
options.setApplicationDescription(QObject::tr("Graphical disk-usage information"));
options.addHelpOption();
options.addVersionOption();
options.addPositionalArgument(QLatin1String("url"), QObject::tr("Path or URL to scan"), QObject::tr("[url]"));
options.process(app);
if (!app.isSessionRestored()) {
MainWindow *mw = new MainWindow();
KCmdLineArgs* const args = KCmdLineArgs::parsedArgs();
if (args->count() > 0) mw->scan(args->url(0));
args->clear();
QStringList args = options.positionalArguments();
if (args.count() > 0) mw->scan(args.at(0));
mw->show();
}
......
......@@ -24,32 +24,32 @@
#include "historyAction.h"
#include <cstdlib> //std::exit()
#include <KApplication> //setupActions()
#include <QApplication> //setupActions()
#include <KComboBox> //locationbar
#include <KHistoryComboBox>
#include <KRecentFilesAction>
#include <QFileDialog>
#include <KConfig>
#include <KDirSelectDialog> //slotScanFolder
#include <KEditToolBar> //for editToolbar dialog
#include <QLineEdit>
#include <KStandardShortcut>
#include <KFileDialog>
#include <KLibLoader>
#include <KLocale>
#include <KPluginFactory>
#include <KPluginLoader>
#include <KMessageBox>
#include <KShell>
#include <KStatusBar>
#include <QStatusBar>
#include <KToolBar>
#include <KUrl>
#include <QUrl>
#include <KUrlCompletion> //locationbar
#include <QObject>
#include <QToolTip>
#include <KGlobal>
#include <QPluginLoader>
#include <KConfigGroup>
#include <KShortcutsDialog>
#include <KSharedConfig>
#include <KStandardAction>
#include <KActionCollection>
#include <KIO/Global> // upUrl
namespace Filelight {
......@@ -59,7 +59,7 @@ MainWindow::MainWindow() : KParts::MainWindow(), m_part(0)
KPluginFactory *factory = KPluginLoader(QLatin1String( "filelightpart" )).factory();
if (!factory) {
KMessageBox::error(this, i18n("Unable to load the Filelight Part.\nPlease make sure Filelight was correctly installed."));
KMessageBox::error(this, tr("Unable to load the Filelight Part.\nPlease make sure Filelight was correctly installed."));
std::exit(1);
return;
}
......@@ -81,17 +81,17 @@ MainWindow::MainWindow() : KParts::MainWindow(), m_part(0)
connect(m_part, SIGNAL(canceled(QString)), m_histories, SLOT(stop()));
connect(BrowserExtension::childObject(m_part), SIGNAL(openUrlNotify()), SLOT(urlAboutToChange()));
const KConfigGroup config = KGlobal::config()->group("general");
const KConfigGroup config = KSharedConfig::openConfig()->group("general");
m_combo->setHistoryItems(config.readPathEntry("comboHistory", QStringList()));
} else {
KMessageBox::error(this, i18n("Unable to create part widget."));
KMessageBox::error(this, tr("Unable to create Filelight part widget.\nPlease ensure that Filelight is correctly installed."));
std::exit(1);
}
setAutoSaveSettings(QLatin1String( "window" ));
}
inline void MainWindow::setupActions() //singleton function
void MainWindow::setupActions() //singleton function
{
KActionCollection *const ac = actionCollection();
......@@ -107,55 +107,55 @@ inline void MainWindow::setupActions() //singleton function
KStandardAction::configureToolbars(this, SLOT(configToolbars()), ac);
KStandardAction::keyBindings(this, SLOT(configKeys()), ac);
KAction* action;
QAction* action;
action = ac->addAction(QLatin1String( "scan_home" ), this, SLOT(slotScanHomeFolder()));
action->setText(i18n("Scan &Home Folder"));
action->setIcon(KIcon(QLatin1String( "user-home" )));
action = ac->addAction(QLatin1String("scan_home"), this, SLOT(slotScanHomeFolder()));
action->setText(tr("Scan &Home Folder"));
action->setIcon(QIcon(QLatin1String("user-home")));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Home));
action = ac->addAction(QLatin1String( "scan_root" ), this, SLOT(slotScanRootFolder()));
action->setText(i18n("Scan &Root Folder"));
action->setIcon(KIcon(QLatin1String( "folder-red" )));
action = ac->addAction(QLatin1String("scan_root"), this, SLOT(slotScanRootFolder()));
action->setText(tr("Scan &Root Folder"));
action->setIcon(QIcon(QLatin1String("folder-red")));
action = ac->addAction(QLatin1String( "scan_rescan" ), m_part, SLOT(rescan()));
action->setText(i18n("Rescan"));
action->setIcon(KIcon(QLatin1String( "view-refresh" )));
action->setShortcut(KStandardShortcut::reload());
action = ac->addAction(QLatin1String("scan_rescan"), m_part, SLOT(rescan()));
action->setText(tr("Rescan"));
action->setIcon(QIcon(QLatin1String("view-refresh")));
action->setShortcut(QKeySequence::Refresh);
action = ac->addAction(QLatin1String( "scan_stop" ), this, SLOT(slotAbortScan()));
action->setText(i18n("Stop"));
action->setIcon(KIcon(QLatin1String( "process-stop" )));
action = ac->addAction(QLatin1String("scan_stop"), this, SLOT(slotAbortScan()));
action->setText(tr("Stop"));
action->setIcon(QIcon(QLatin1String("process-stop")));
action->setShortcut(Qt::Key_Escape);
action = ac->addAction(QLatin1String( "go" ), m_combo, SIGNAL(returnPressed()));
action->setText(i18n("Go"));
action->setIcon(KIcon(QLatin1String( "go-jump-locationbar" )));
action = ac->addAction(QLatin1String( "location_bar" ), 0, 0);
action->setText(i18n("Location Bar"));
action->setDefaultWidget(m_combo);
action = ac->addAction(QLatin1String("go"), m_combo, SIGNAL(returnPressed()));
action->setText(tr("Go"));
action->setIcon(QIcon(QLatin1String("go-jump-locationbar")));
action = ac->addAction(QLatin1String( "scan_folder" ), this, SLOT(slotScanFolder()));
action->setText(i18n("Scan Folder"));
action->setIcon(KIcon(QLatin1String( "folder" )));
action->setText(tr("Scan Folder"));
action->setIcon(QIcon(QLatin1String( "folder" )));
QWidgetAction *locationAction = ac->add<QWidgetAction>(QLatin1String("location_bar"), 0, 0);
locationAction->setText(tr("Location Bar"));
locationAction->setDefaultWidget(m_combo);
m_recentScans = new KRecentFilesAction(i18n("&Recent Scans"), ac);
m_recentScans = new KRecentFilesAction(tr("&Recent Scans"), ac);
m_recentScans->setMaxItems(8);
m_histories = new HistoryCollection(ac, this);
m_recentScans->loadEntries(KGlobal::config()->group("general"));
m_recentScans->loadEntries(KSharedConfig::openConfig()->group("general"));
connect(m_recentScans, SIGNAL(urlSelected(KUrl)), SLOT(slotScanUrl(KUrl)));
connect(m_recentScans, SIGNAL(urlSelected(QUrl)), SLOT(slotScanUrl(QUrl)));
connect(m_combo, SIGNAL(returnPressed()), SLOT(slotComboScan()));
connect(m_histories, SIGNAL(activated(KUrl)), SLOT(slotScanUrl(KUrl)));
connect(m_histories, SIGNAL(activated(QUrl)), SLOT(slotScanUrl(QUrl)));
}
void MainWindow::closeEvent(QCloseEvent *event)
{
KConfigGroup config = KGlobal::config()->group("general");
KConfigGroup config = KSharedConfig::openConfig()->group("general");
m_recentScans->saveEntries(config);
config.writePathEntry("comboHistory", m_combo->historyItems());
......@@ -164,42 +164,42 @@ void MainWindow::closeEvent(QCloseEvent *event)
KParts::MainWindow::closeEvent(event);
}
inline void MainWindow::configToolbars() //slot
void MainWindow::configToolbars() //slot
{
KEditToolBar dialog(factory(), this);
if (dialog.exec()) //krazy:exclude=crashy
{
createGUI(m_part);
applyMainWindowSettings(KGlobal::config()->group("window"));
applyMainWindowSettings(KSharedConfig::openConfig()->group("window"));
}
}
inline void MainWindow::configKeys() //slot
void MainWindow::configKeys() //slot
{
KShortcutsDialog::configure(actionCollection(), KShortcutsEditor::LetterShortcutsAllowed, this, true);
}
inline void MainWindow::slotScanFolder()
void MainWindow::slotScanFolder()
{
slotScanUrl(KFileDialog::getExistingDirectoryUrl(m_part->url(), this, i18n("Select Folder to Scan")));
slotScanUrl(QFileDialog::getExistingDirectoryUrl(this, tr("Select Folder to Scan"), m_part->url()));
}
inline void MainWindow::slotScanHomeFolder() {
void MainWindow::slotScanHomeFolder() {
slotScanPath(QDir::homePath());
}
inline void MainWindow::slotScanRootFolder() {
void MainWindow::slotScanRootFolder() {
slotScanPath(QDir::rootPath());
}
inline void MainWindow::slotUp() {
slotScanUrl(m_part->url().upUrl());
void MainWindow::slotUp() {
slotScanUrl(KIO::upUrl(m_part->url()));
}
inline void MainWindow::slotComboScan()
void MainWindow::slotComboScan()
{
QString path = m_combo->lineEdit()->text();
KUrl url = KUrl(path);
QUrl url = QUrl::fromUserInput(path);
if (url.isRelative())
path = QLatin1String( "~/" ) + path; // KUrlCompletion completes relative to ~, not CWD
......@@ -210,14 +210,14 @@ inline void MainWindow::slotComboScan()
m_combo->addToHistory(path);
}
inline bool MainWindow::slotScanPath(const QString &path)
bool MainWindow::slotScanPath(const QString &path)
{
return slotScanUrl(KUrl(path));
return slotScanUrl(QUrl::fromUserInput(path));
}
bool MainWindow::slotScanUrl(const KUrl &url)
bool MainWindow::slotScanUrl(const QUrl &url)
{
const KUrl oldUrl = m_part->url();
const QUrl oldUrl = m_part->url();
if (m_part->openUrl(url))
{
......@@ -228,44 +228,47 @@ bool MainWindow::slotScanUrl(const KUrl &url)
return false;
}
inline void MainWindow::slotAbortScan()
void MainWindow::slotAbortScan()
{
if (m_part->closeUrl()) action("scan_stop")->setEnabled(false);
}
inline void MainWindow::scanStarted()
void MainWindow::scanStarted()
{
stateChanged(QLatin1String( "scan_started" ));
m_combo->clearFocus();
}
inline void MainWindow::scanFailed()
void MainWindow::scanFailed()
{
stateChanged(QLatin1String( "scan_failed" ));
qobject_cast<KAction*>(action("go_up"))->setHelpText(QString());
action("go_up")->setStatusTip(QString());
action("go_up")->setToolTip(QString());
m_combo->lineEdit()->clear();
}
void MainWindow::scanCompleted()
{
KAction *goUp = qobject_cast<KAction *>(action("go_up"));
const KUrl url = m_part->url();
const QUrl url = m_part->url();
stateChanged(QLatin1String( "scan_complete" ));
stateChanged(QLatin1String("scan_complete"));
m_combo->lineEdit()->setText(m_part->prettyUrl());
if (url.path(KUrl::LeaveTrailingSlash) == QLatin1String( "/" )) {
goUp->setEnabled(false);
goUp->setHelpText(QString());
if (url.toLocalFile() == QLatin1String( "/" )) {
action("go_up")->setEnabled(false);
action("go_up")->setStatusTip(QString());
action("go_up")->setToolTip(QString());
}
else {
action("go_up")->setStatusTip(KIO::upUrl(url).toString());
action("go_up")->setToolTip(KIO::upUrl(url).toString());
}
else
goUp->setHelpText(url.upUrl().path(KUrl::LeaveTrailingSlash));
m_recentScans->addUrl(url); //FIXME doesn't set the tick
}
inline void MainWindow::urlAboutToChange()
void MainWindow::urlAboutToChange()
{
//called when part's URL is about to change internally
//the part will then create the Map and emit completed()
......
......@@ -42,7 +42,7 @@ class MainWindow : public KParts::MainWindow
public:
MainWindow();
void scan(const KUrl &u) {
void scan(const QUrl &u) {
slotScanUrl(u);
}
......@@ -52,7 +52,7 @@ private slots:
void slotScanFolder();
void slotScanHomeFolder();
void slotScanRootFolder();
bool slotScanUrl(const KUrl&);
bool slotScanUrl(const QUrl&);
bool slotScanPath(const QString&);
void slotAbortScan();
......
......@@ -30,7 +30,7 @@
#undef PRETTYNAME
#define APP_NAME "filelight"
#define APP_VERSION "1.20"
#define APP_VERSION "1.21"
#define APP_PRETTYNAME "Filelight"
#endif
......@@ -18,9 +18,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#######################################################################
add_subdirectory(radialMap)
set(filelight_PART_SRCS
radialMap/widget.cpp
radialMap/builder.cpp
radialMap/map.cpp
radialMap/widgetEvents.cpp
radialMap/labels.cpp
part.cpp
scan.cpp
progressBox.cpp
......@@ -31,17 +34,10 @@ set(filelight_PART_SRCS
remoteLister.cpp
summaryWidget.cpp)
kde4_add_ui_files(filelight_PART_SRCS dialog.ui)
kde4_add_plugin(filelightpart ${filelight_PART_SRCS})
QT5_WRAP_UI(filelight_PART_SRCS dialog.ui)
target_link_libraries(filelightpart radialmap
${KDE4_KDECORE_LIBS}
${KDE4_KPARTS_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${KDE4_KFILE_LIBS}
${KDE4_SOLID_LIBS})
add_library(filelightpart MODULE ${filelight_PART_SRCS})
target_link_libraries(filelightpart radialmap KF5::Parts KF5::KIOCore KF5::Solid)
install(TARGETS filelightpart DESTINATION ${PLUGIN_INSTALL_DIR})
......@@ -25,9 +25,9 @@
#include <KParts/BrowserExtension>
#include <KParts/StatusBarExtension>
#include <KParts/Part>
#include <KUrl>