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