Commit 98943bcb authored by Harald Sitter's avatar Harald Sitter 🚔

fully port away from using kparts (still including tho)

parent 990e3280
......@@ -57,7 +57,8 @@
namespace Filelight {
MainWindow::MainWindow()
: KParts::MainWindow()
// : KParts::MainWindow()
: KXmlGuiWindow()
, m_part(new Part(nullptr, this, QList<QVariant>()))
, m_histories(0)
{
......@@ -66,7 +67,9 @@ MainWindow::MainWindow()
setStandardToolBarMenuEnabled(true);
setupActions();
createGUI(m_part);
#warning port
setXMLFile(QStringLiteral( "filelightpartui.rc" ));
// createGUI(m_part);
setCentralWidget(m_part->widget());
stateChanged(QStringLiteral( "scan_failed" )); //bah! doesn't affect the parts' actions, should I add them to the actionCollection here?
......@@ -76,7 +79,8 @@ MainWindow::MainWindow()
connect(m_part, &Part::canceled, this, &MainWindow::scanFailed);
connect(m_part, &Part::canceled, m_histories, &HistoryCollection::stop);
connect(BrowserExtension::childObject(m_part), &KParts::BrowserExtension::openUrlNotify, this, &MainWindow::urlAboutToChange);
#warning port
// connect(BrowserExtension::childObject(m_part), &KParts::BrowserExtension::openUrlNotify, this, &MainWindow::urlAboutToChange);
const KConfigGroup config = KSharedConfig::openConfig()->group("general");
m_combo->setHistoryItems(config.readPathEntry("comboHistory", QStringList()));
......@@ -154,7 +158,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
config.writePathEntry("comboHistory", m_combo->historyItems());
config.sync();
KParts::MainWindow::closeEvent(event);
KXmlGuiWindow::closeEvent(event);
}
void MainWindow::configToolbars() //slot
......@@ -163,7 +167,8 @@ void MainWindow::configToolbars() //slot
if (dialog.exec()) //krazy:exclude=crashy
{
createGUI(m_part);
#warning port
// createGUI(m_part);
applyMainWindowSettings(KSharedConfig::openConfig()->group("window"));
}
}
......
......@@ -35,7 +35,7 @@ namespace Filelight {
class Part;
class MainWindow : public KParts::MainWindow
class MainWindow : public KXmlGuiWindow // Maybe use qmainwindow
{
Q_OBJECT
......
......@@ -50,37 +50,26 @@
namespace Filelight {
K_PLUGIN_FACTORY(filelightPartFactory, registerPlugin<Part>();) // produce a factory
BrowserExtension::BrowserExtension(Part *parent)
: KParts::BrowserExtension(parent)
// : KParts::BrowserExtension(parent)
: QObject(parent)
{}
Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&)
: ReadOnlyPart(parent)
// : ReadOnlyPart(parent)
: QObject(parent)
, m_summary(0)
, m_ext(new BrowserExtension(this))
, m_statusbar(new StatusBarExtension(this))
, m_map(0)
, m_started(false)
, m_widget(nullptr)
{
Config::read();
KAboutData aboutData(
QStringLiteral("filelightpart"),
i18n(APP_PRETTYNAME),
QStringLiteral(APP_VERSION),
i18n("Displays file usage in an easy to understand way."),
KAboutLicense::GPL,
i18n("(c) 2002-2004 Max Howell\n"
"(c) 2008-2014 Martin T. Sandsmark"),
QString(),
QStringLiteral("http://utils.kde.org/projects/filelight"),
QStringLiteral("martin.sandsmark@kde.org"));
setComponentData(aboutData);
setXMLFile(QStringLiteral( "filelightpartui.rc" ));
// Q_ASSERT(false); // todo
// setXMLFile(QStringLiteral( "filelightpartui.rc" ));
QScrollArea *scrollArea = new QScrollArea(parentWidget);
scrollArea->setWidgetResizable(true);
......@@ -107,12 +96,14 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&)
m_numberOfFiles = new QLabel();
m_statusbar->addStatusBarItem(m_numberOfFiles, 0, true);
KStandardAction::zoomIn(m_map, SLOT(zoomIn()), actionCollection());
KStandardAction::zoomOut(m_map, SLOT(zoomOut()), actionCollection());
QAction *action = actionCollection()->addAction(QStringLiteral("configure_filelight"));
action->setText(i18n("Configure Filelight..."));
action->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
connect(action, &QAction::triggered, this, &Part::configFilelight);
#warning port
// Q_ASSERT(false); // todo
// KStandardAction::zoomIn(m_map, SLOT(zoomIn()), actionCollection());
// KStandardAction::zoomOut(m_map, SLOT(zoomOut()), actionCollection());
// QAction *action = actionCollection()->addAction(QStringLiteral("configure_filelight"));
// action->setText(i18n("Configure Filelight..."));
// action->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
// connect(action, &QAction::triggered, this, &Part::configFilelight);
connect(m_map, &RadialMap::Widget::folderCreated, this, static_cast<void (Part::*)()>(&Part::completed));
connect(m_map, &RadialMap::Widget::folderCreated, this, &Part::mapChanged);
......@@ -203,7 +194,9 @@ Part::closeUrl()
showSummary();
return ReadOnlyPart::closeUrl();
Q_ASSERT(false); // todo
return false;
// return ReadOnlyPart::closeUrl();
}
QString Part::prettyUrl() const {
......@@ -227,6 +220,32 @@ Part::updateURL(const QUrl &u)
setUrl(u);
}
QUrl Part::url() const
{
return m_url;
}
void Part::setUrl(const QUrl &url)
{
m_url = url;
}
void Part::stateChanged(const QString &state)
{
#warning port this calls xmlguiclient::stateChanged in parts
// Q_ASSERT(false);
}
void Part::setWidget(QWidget *widget)
{
m_widget = widget;
}
QWidget *Part::widget() const
{
return m_widget;
}
void
Part::configFilelight()
{
......@@ -330,6 +349,10 @@ Part::mapChanged(const Folder *tree)
m_numberOfFiles->setText(text);
}
QStatusBar *Part::statusBar() {
return m_statusbar->statusBar();
}
void
Part::showSummary()
{
......@@ -350,3 +373,31 @@ bool Filelight::Part::openFile() {
} //namespace Filelight
#include "part.moc"
StatusBarExtension::StatusBarExtension(QObject *parent)
: QObject(parent)
, m_statusBar(new QStatusBar)
{
}
StatusBarExtension::~StatusBarExtension()
{
delete m_statusBar;
}
QStatusBar *StatusBarExtension::statusBar() const
{
return m_statusBar;
}
void StatusBarExtension::addStatusBarItem(QWidget *widget, int stretch, bool permanent)
{
// Q_ASSERT(false);
#warning port
}
void StatusBarExtension::removeStatusBarItem(QWidget *widget)
{
// Q_ASSERT(false);
#warning port
}
......@@ -29,7 +29,23 @@
#include <QLabel>
using KParts::StatusBarExtension;
// COMPAT
//using KParts::StatusBarExtension;
class StatusBarExtension : public QObject
{
Q_OBJECT
public:
StatusBarExtension(QObject *parent = nullptr);
~StatusBarExtension();
QStatusBar *statusBar() const;
void addStatusBarItem(QWidget *widget, int stretch, bool permanent);
void removeStatusBarItem(QWidget *widget);
private:
QStatusBar *m_statusBar;
};
namespace RadialMap {
class Widget;
}
......@@ -41,16 +57,26 @@ namespace Filelight
class Part;
class SummaryWidget;
class BrowserExtension : public KParts::BrowserExtension
// COMPAT
class BrowserExtension : public
// KParts::BrowserExtension
QObject
{
Q_OBJECT
public:
explicit BrowserExtension(Part*);
signals:
void openUrlNotify();
void setLocationBarUrl(QString);
};
class Part : public KParts::ReadOnlyPart
class Part : public
// KParts::ReadOnlyPart
QObject
{
Q_OBJECT
......@@ -62,6 +88,12 @@ public:
QString prettyUrl() const;
signals:
void started(KJob *);
void completed();
void canceled(QString);
void setWindowCaption(QString);
public slots:
virtual bool openUrl(const QUrl&);
void configFilelight();
......@@ -73,9 +105,7 @@ private slots:
void mapChanged(const Folder*);
private:
QStatusBar *statusBar() {
return m_statusbar->statusBar();
}
QStatusBar *statusBar();
void showSummary();
QLayout *m_layout;
......@@ -94,6 +124,18 @@ private:
private slots:
void updateURL(const QUrl &);
// Compat
public:
QUrl url() const;
QWidget *widget() const;
private:
void setUrl(const QUrl &url);
void stateChanged(const QString &state);
void setWidget(QWidget *widget);
QWidget *m_widget = nullptr;
QUrl m_url;
};
}
......
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