Qt launchpad: coding style fixes

Fixes #1221.
This commit is contained in:
Christian Prochaska 2014-08-06 17:44:24 +02:00 committed by Norman Feske
parent ee86b9d47a
commit 2e64a01ea5
9 changed files with 105 additions and 99 deletions

View File

@ -18,10 +18,6 @@ Child_entry::Child_entry(const char *name, int quota_kb, int max_quota_kb,
ui.quotaBar->setValue(quota_kb);
}
Child_entry::~Child_entry()
{
}
void Child_entry::on_exitButton_clicked()
{

View File

@ -24,20 +24,22 @@ class Child_entry : public QWidget
{
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:
Ui::Child_entryClass ui;
Launchpad *_launchpad;
Launchpad_child *_launchpad_child;
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 */

View File

@ -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";
}

View File

@ -21,13 +21,10 @@ class Kbyte_loadbar : public QProgressBar
Q_OBJECT
public:
Kbyte_loadbar(QWidget *parent = 0);
~Kbyte_loadbar();
virtual QString text() const;
protected:
};
#endif // KBYTE_LOADBAR_H
#endif /* KBYTE_LOADBAR_H */

View File

@ -7,9 +7,14 @@
#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);
@ -20,12 +25,10 @@ Launch_entry::Launch_entry(const char *filename, unsigned long default_quota,
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);
}

View File

@ -24,20 +24,26 @@ class Launch_entry : public QWidget
{
Q_OBJECT
public:
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;
const char *_filename;
Genode::Dataspace_capability _config_ds;
Launchpad *_launchpad;
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 */

View File

@ -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;
}

View File

@ -47,16 +47,12 @@ 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;
@ -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,
@ -98,6 +101,7 @@ void Qt_launchpad::add_child(const char *unique_name,
childrenDockWidgetContents->adjustSize();
}
void Qt_launchpad::remove_child(const char *name, Genode::Allocator *alloc)
{
Child_entry *child_entry =

View File

@ -23,24 +23,26 @@ class Qt_launchpad : public QMainWindow, public Launchpad, private Ui::Qt_launch
{
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);
Genode::Allocator *alloc) override;
virtual void remove_child(const char *name, Genode::Allocator *alloc);
private slots:
void avail_quota_update();
virtual void remove_child(const char *name, Genode::Allocator *alloc) override;
};
#endif // QT_LAUNCHPAD_H
#endif /* QT_LAUNCHPAD_H */