parent
ee86b9d47a
commit
2e64a01ea5
|
@ -7,21 +7,17 @@
|
||||||
#include "child_entry.h"
|
#include "child_entry.h"
|
||||||
|
|
||||||
Child_entry::Child_entry(const char *name, int quota_kb, int max_quota_kb,
|
Child_entry::Child_entry(const char *name, int quota_kb, int max_quota_kb,
|
||||||
Launchpad *launchpad, Launchpad_child *launchpad_child,
|
Launchpad *launchpad, Launchpad_child *launchpad_child,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QWidget(parent), _launchpad(launchpad), _launchpad_child(launchpad_child)
|
: QWidget(parent), _launchpad(launchpad), _launchpad_child(launchpad_child)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
ui.nameLabel->setText(name);
|
ui.nameLabel->setText(name);
|
||||||
ui.quotaBar->setMaximum(max_quota_kb);
|
ui.quotaBar->setMaximum(max_quota_kb);
|
||||||
ui.quotaBar->setValue(quota_kb);
|
ui.quotaBar->setValue(quota_kb);
|
||||||
}
|
}
|
||||||
|
|
||||||
Child_entry::~Child_entry()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Child_entry::on_exitButton_clicked()
|
void Child_entry::on_exitButton_clicked()
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,22 +22,24 @@
|
||||||
|
|
||||||
class Child_entry : public QWidget
|
class Child_entry : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
private:
|
||||||
Child_entry(const char *name, int quota_kb, int max_quota_kb,
|
|
||||||
Launchpad *launchpad, Launchpad_child *launchpad_child,
|
|
||||||
QWidget *parent = 0);
|
|
||||||
~Child_entry();
|
|
||||||
|
|
||||||
private:
|
Ui::Child_entryClass ui;
|
||||||
Ui::Child_entryClass ui;
|
|
||||||
|
|
||||||
Launchpad *_launchpad;
|
Launchpad *_launchpad;
|
||||||
Launchpad_child *_launchpad_child;
|
Launchpad_child *_launchpad_child;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void on_exitButton_clicked();
|
void on_exitButton_clicked();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Child_entry(const char *name, int quota_kb, int max_quota_kb,
|
||||||
|
Launchpad *launchpad, Launchpad_child *launchpad_child,
|
||||||
|
QWidget *parent = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHILD_ENTRY_H
|
#endif /* CHILD_ENTRY_H */
|
||||||
|
|
|
@ -6,19 +6,13 @@
|
||||||
|
|
||||||
#include "kbyte_loadbar.h"
|
#include "kbyte_loadbar.h"
|
||||||
|
|
||||||
|
|
||||||
Kbyte_loadbar::Kbyte_loadbar(QWidget *parent)
|
Kbyte_loadbar::Kbyte_loadbar(QWidget *parent)
|
||||||
: QProgressBar(parent)
|
: QProgressBar(parent) { }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Kbyte_loadbar::~Kbyte_loadbar()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QString Kbyte_loadbar::text() const
|
QString Kbyte_loadbar::text() const
|
||||||
{
|
{
|
||||||
return QString::number(value()) + " KByte / " +
|
return QString::number(value()) + " KByte / " +
|
||||||
QString::number(maximum()) + " KByte";
|
QString::number(maximum()) + " KByte";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,13 @@
|
||||||
|
|
||||||
class Kbyte_loadbar : public QProgressBar
|
class Kbyte_loadbar : public QProgressBar
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Kbyte_loadbar(QWidget *parent = 0);
|
|
||||||
~Kbyte_loadbar();
|
|
||||||
|
|
||||||
virtual QString text() const;
|
Kbyte_loadbar(QWidget *parent = 0);
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
|
virtual QString text() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // KBYTE_LOADBAR_H
|
#endif /* KBYTE_LOADBAR_H */
|
||||||
|
|
|
@ -7,25 +7,28 @@
|
||||||
#include "launch_entry.h"
|
#include "launch_entry.h"
|
||||||
|
|
||||||
Launch_entry::Launch_entry(const char *filename, unsigned long default_quota,
|
Launch_entry::Launch_entry(const char *filename, unsigned long default_quota,
|
||||||
unsigned long max_quota, Launchpad *launchpad,
|
unsigned long max_quota,
|
||||||
|
Genode::Dataspace_capability config_ds,
|
||||||
|
Launchpad *launchpad,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QWidget(parent), _filename(filename), _launchpad(launchpad)
|
: QWidget(parent),
|
||||||
|
_filename(filename),
|
||||||
|
_config_ds(config_ds),
|
||||||
|
_launchpad(launchpad)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
ui.launchButton->setText(filename);
|
ui.launchButton->setText(filename);
|
||||||
|
|
||||||
ui.quotaDial->setMaximum(max_quota);
|
ui.quotaDial->setMaximum(max_quota);
|
||||||
ui.quotaDial->setSingleStep(max_quota / 100);
|
ui.quotaDial->setSingleStep(max_quota / 100);
|
||||||
ui.quotaDial->setValue(default_quota);
|
ui.quotaDial->setValue(default_quota);
|
||||||
}
|
}
|
||||||
|
|
||||||
Launch_entry::~Launch_entry()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Launch_entry::on_launchButton_clicked()
|
void Launch_entry::on_launchButton_clicked()
|
||||||
{
|
{
|
||||||
_launchpad->start_child(_filename, 1024 * ui.quotaDial->value(), Genode::Dataspace_capability());
|
_launchpad->start_child(_filename,
|
||||||
|
1024 * ui.quotaDial->value(),
|
||||||
|
_config_ds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,22 +22,28 @@
|
||||||
|
|
||||||
class Launch_entry : public QWidget
|
class Launch_entry : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
private:
|
||||||
Launch_entry(const char *filename, unsigned long default_quota,
|
|
||||||
unsigned long max_quota, Launchpad *launchpad,
|
|
||||||
QWidget *parent = 0);
|
|
||||||
~Launch_entry();
|
|
||||||
|
|
||||||
private:
|
Ui::Launch_entryClass ui;
|
||||||
Ui::Launch_entryClass ui;
|
|
||||||
|
|
||||||
const char *_filename;
|
const char *_filename;
|
||||||
|
Genode::Dataspace_capability _config_ds;
|
||||||
Launchpad *_launchpad;
|
Launchpad *_launchpad;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void on_launchButton_clicked();
|
void on_launchButton_clicked();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Launch_entry(const char *filename,
|
||||||
|
unsigned long default_quota,
|
||||||
|
unsigned long max_quota,
|
||||||
|
Genode::Dataspace_capability config_ds,
|
||||||
|
Launchpad *launchpad,
|
||||||
|
QWidget *parent = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LAUNCH_ENTRY_H
|
#endif /* LAUNCH_ENTRY_H */
|
||||||
|
|
|
@ -25,22 +25,24 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
QApplication *a = new QApplication(argc, argv);
|
static QApplication a(argc, argv);
|
||||||
|
|
||||||
Qt_launchpad *launchpad = new Qt_launchpad(Genode::env()->ram_session()->quota());
|
static Qt_launchpad launchpad(Genode::env()->ram_session()->quota());
|
||||||
|
|
||||||
launchpad->add_launcher("calculatorform", 30*1024*1024);
|
launchpad.add_launcher("calculatorform",
|
||||||
launchpad->add_launcher("tetrix", 40*1024*1024);
|
30*1024*1024,
|
||||||
|
Genode::Dataspace_capability());
|
||||||
|
|
||||||
launchpad->move(300,100);
|
launchpad.add_launcher("tetrix",
|
||||||
launchpad->show();
|
40*1024*1024,
|
||||||
|
Genode::Dataspace_capability());
|
||||||
|
|
||||||
a->connect(a, SIGNAL(lastWindowClosed()), a, SLOT(quit()));
|
launchpad.move(300,100);
|
||||||
|
launchpad.show();
|
||||||
|
|
||||||
result = a->exec();
|
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
|
||||||
|
|
||||||
delete launchpad;
|
result = a.exec();
|
||||||
delete a;
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "child_entry.h"
|
#include "child_entry.h"
|
||||||
|
|
||||||
Qt_launchpad::Qt_launchpad(unsigned long initial_quota, QWidget *parent)
|
Qt_launchpad::Qt_launchpad(unsigned long initial_quota, QWidget *parent)
|
||||||
: QMainWindow(parent), Launchpad(initial_quota)
|
: QMainWindow(parent), Launchpad(initial_quota)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
|
@ -22,24 +22,24 @@ Qt_launchpad::Qt_launchpad(unsigned long initial_quota, QWidget *parent)
|
||||||
setWindowFlags(flags);
|
setWindowFlags(flags);
|
||||||
|
|
||||||
// put a QScrollArea into launcherDockWidget for scrolling of launcher entries
|
// put a QScrollArea into launcherDockWidget for scrolling of launcher entries
|
||||||
QScrollArea *launcherScrollArea = new QScrollArea;
|
QScrollArea *launcherScrollArea = new QScrollArea;
|
||||||
launcherScrollArea->setFrameStyle(QFrame::NoFrame);
|
launcherScrollArea->setFrameStyle(QFrame::NoFrame);
|
||||||
launcherScrollArea->setWidget(launcherDockWidgetContents);
|
launcherScrollArea->setWidget(launcherDockWidgetContents);
|
||||||
|
|
||||||
launcherDockWidget->setWidget(launcherScrollArea);
|
launcherDockWidget->setWidget(launcherScrollArea);
|
||||||
|
|
||||||
QVBoxLayout *launcherDockWidgetLayout = new QVBoxLayout;
|
QVBoxLayout *launcherDockWidgetLayout = new QVBoxLayout;
|
||||||
launcherDockWidgetLayout->setContentsMargins(2, 2, 2, 2);
|
launcherDockWidgetLayout->setContentsMargins(2, 2, 2, 2);
|
||||||
launcherDockWidgetLayout->setSpacing(2);
|
launcherDockWidgetLayout->setSpacing(2);
|
||||||
launcherDockWidgetContents->setLayout(launcherDockWidgetLayout);
|
launcherDockWidgetContents->setLayout(launcherDockWidgetLayout);
|
||||||
|
|
||||||
// put a QScrollArea into childrenDockWidget for scrolling of child entries
|
// put a QScrollArea into childrenDockWidget for scrolling of child entries
|
||||||
QScrollArea *childrenScrollArea = new QScrollArea;
|
QScrollArea *childrenScrollArea = new QScrollArea;
|
||||||
childrenScrollArea->setFrameStyle(QFrame::NoFrame);
|
childrenScrollArea->setFrameStyle(QFrame::NoFrame);
|
||||||
childrenScrollArea->setWidget(childrenDockWidgetContents);
|
childrenScrollArea->setWidget(childrenDockWidgetContents);
|
||||||
|
|
||||||
childrenDockWidget->setWidget(childrenScrollArea);
|
childrenDockWidget->setWidget(childrenScrollArea);
|
||||||
|
|
||||||
QVBoxLayout *childrenDockWidgetLayout = new QVBoxLayout;
|
QVBoxLayout *childrenDockWidgetLayout = new QVBoxLayout;
|
||||||
childrenDockWidgetLayout->setContentsMargins(2, 2, 2, 2);
|
childrenDockWidgetLayout->setContentsMargins(2, 2, 2, 2);
|
||||||
childrenDockWidgetLayout->setSpacing(2);
|
childrenDockWidgetLayout->setSpacing(2);
|
||||||
|
@ -47,19 +47,15 @@ Qt_launchpad::Qt_launchpad(unsigned long initial_quota, QWidget *parent)
|
||||||
|
|
||||||
// update the available quota bar every 200ms
|
// update the available quota bar every 200ms
|
||||||
QTimer *avail_quota_timer = new QTimer(this);
|
QTimer *avail_quota_timer = new QTimer(this);
|
||||||
connect(avail_quota_timer, SIGNAL(timeout()), this, SLOT(avail_quota_update()));
|
connect(avail_quota_timer, SIGNAL(timeout()), this, SLOT(_avail_quota_update()));
|
||||||
avail_quota_timer->start(200);
|
avail_quota_timer->start(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt_launchpad::~Qt_launchpad()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
void Qt_launchpad::_avail_quota_update()
|
||||||
|
|
||||||
void Qt_launchpad::avail_quota_update()
|
|
||||||
{
|
{
|
||||||
static Genode::size_t _avail = 0;
|
static Genode::size_t _avail = 0;
|
||||||
|
|
||||||
Genode::size_t new_avail = Genode::env()->ram_session()->avail();
|
Genode::size_t new_avail = Genode::env()->ram_session()->avail();
|
||||||
|
|
||||||
if (new_avail != _avail)
|
if (new_avail != _avail)
|
||||||
|
@ -68,22 +64,29 @@ void Qt_launchpad::avail_quota_update()
|
||||||
_avail = new_avail;
|
_avail = new_avail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Qt_launchpad::quota(unsigned long quota)
|
void Qt_launchpad::quota(unsigned long quota)
|
||||||
{
|
{
|
||||||
totalQuotaProgressBar->setMaximum(initial_quota() / 1024);
|
totalQuotaProgressBar->setMaximum(initial_quota() / 1024);
|
||||||
totalQuotaProgressBar->setValue(quota / 1024);
|
totalQuotaProgressBar->setValue(quota / 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Qt_launchpad::add_launcher(const char *filename,
|
void Qt_launchpad::add_launcher(const char *filename,
|
||||||
unsigned long default_quota)
|
unsigned long default_quota,
|
||||||
|
Genode::Dataspace_capability config_ds)
|
||||||
{
|
{
|
||||||
Launch_entry *launch_entry = new Launch_entry(filename, default_quota / 1024,
|
Launch_entry *launch_entry = new Launch_entry(filename,
|
||||||
initial_quota() / 1024, this);
|
default_quota / 1024,
|
||||||
|
initial_quota() / 1024,
|
||||||
|
config_ds,
|
||||||
|
this);
|
||||||
launcherDockWidgetContents->layout()->addWidget(launch_entry);
|
launcherDockWidgetContents->layout()->addWidget(launch_entry);
|
||||||
launch_entry->show();
|
launch_entry->show();
|
||||||
launcherDockWidgetContents->adjustSize();
|
launcherDockWidgetContents->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Qt_launchpad::add_child(const char *unique_name,
|
void Qt_launchpad::add_child(const char *unique_name,
|
||||||
unsigned long quota,
|
unsigned long quota,
|
||||||
Launchpad_child *launchpad_child,
|
Launchpad_child *launchpad_child,
|
||||||
|
@ -97,19 +100,20 @@ void Qt_launchpad::add_child(const char *unique_name,
|
||||||
child_entry->show();
|
child_entry->show();
|
||||||
childrenDockWidgetContents->adjustSize();
|
childrenDockWidgetContents->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Qt_launchpad::remove_child(const char *name, Genode::Allocator *alloc)
|
void Qt_launchpad::remove_child(const char *name, Genode::Allocator *alloc)
|
||||||
{
|
{
|
||||||
Child_entry *child_entry =
|
Child_entry *child_entry =
|
||||||
childrenDockWidgetContents->findChild<Child_entry*>(QString(name) + "_child_entry");
|
childrenDockWidgetContents->findChild<Child_entry*>(QString(name) + "_child_entry");
|
||||||
|
|
||||||
if (!child_entry) {
|
if (!child_entry) {
|
||||||
PWRN("child entry lookup failed");
|
PWRN("child entry lookup failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// still in "button clicked" event handler
|
// still in "button clicked" event handler
|
||||||
child_entry->deleteLater();
|
child_entry->deleteLater();
|
||||||
|
|
||||||
childrenDockWidgetContents->adjustSize();
|
childrenDockWidgetContents->adjustSize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,26 +21,28 @@
|
||||||
|
|
||||||
class Qt_launchpad : public QMainWindow, public Launchpad, private Ui::Qt_launchpadClass
|
class Qt_launchpad : public QMainWindow, public Launchpad, private Ui::Qt_launchpadClass
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
private slots:
|
||||||
Qt_launchpad(unsigned long initial_quota, QWidget *parent = 0);
|
|
||||||
~Qt_launchpad();
|
|
||||||
|
|
||||||
virtual void quota(unsigned long quota);
|
void _avail_quota_update();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Qt_launchpad(unsigned long initial_quota, QWidget *parent = 0);
|
||||||
|
|
||||||
|
virtual void quota(unsigned long quota) override;
|
||||||
|
|
||||||
virtual void add_launcher(const char *filename,
|
virtual void add_launcher(const char *filename,
|
||||||
unsigned long default_quota);
|
unsigned long default_quota,
|
||||||
|
Genode::Dataspace_capability config_ds) override;
|
||||||
|
|
||||||
virtual void add_child(const char *unique_name,
|
virtual void add_child(const char *unique_name,
|
||||||
unsigned long quota,
|
unsigned long quota,
|
||||||
Launchpad_child *launchpad_child,
|
Launchpad_child *launchpad_child,
|
||||||
Genode::Allocator *alloc);
|
Genode::Allocator *alloc) override;
|
||||||
|
|
||||||
virtual void remove_child(const char *name, Genode::Allocator *alloc);
|
virtual void remove_child(const char *name, Genode::Allocator *alloc) override;
|
||||||
|
|
||||||
private slots:
|
|
||||||
void avail_quota_update();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QT_LAUNCHPAD_H
|
#endif /* QT_LAUNCHPAD_H */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user