Skip to content

Commit

Permalink
Block statusbar via presenter
Browse files Browse the repository at this point in the history
  • Loading branch information
MishkaRogachev committed Oct 19, 2017
1 parent 8aff352 commit 3257544
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,18 @@ MainPresenter::Mode MainPresenter::mode() const

void MainPresenter::setMode(int iMode)
{
Mode mode = static_cast<Mode>(iMode);
if (mode == d->mode) return;
d->mode = mode;
d->statusbar->setStatusbarEnabled(false);

d->mode = static_cast<Mode>(iMode);

if (d->modePresenter)
{
delete d->modePresenter;
d->modePresenter = nullptr;
}

this->setViewProperty(PROPERTY(mode), d->mode);

switch (d->mode) {
case Control:
d->modePresenter = new ControlPresenter(this);
Expand All @@ -67,7 +69,7 @@ void MainPresenter::setMode(int iMode)
break;
}

this->setViewProperty(PROPERTY(mode), d->mode);
d->statusbar->setStatusbarEnabled(true);
}

void MainPresenter::connectView(QObject* view)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ StatusbarPresenter::StatusbarPresenter(QObject* parent):
StatusbarPresenter::~StatusbarPresenter()
{}

void StatusbarPresenter::setStatusbarEnabled(bool enabled)
{
this->setViewProperty(PROPERTY(enabled), enabled);
}

void StatusbarPresenter::connectView(QObject* view)
{
d->radio->setView(view->findChild<QObject*>(NAME(radio)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace presentation
explicit StatusbarPresenter(QObject* parent = nullptr);
~StatusbarPresenter() override;

public slots:
void setStatusbarEnabled(bool enabled);

signals:
void setMode(int mode);

Expand Down
8 changes: 1 addition & 7 deletions sources/presentation/qml/Views/Status/StatusModeButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ Controls.Button {

property int mode: MainPresenter.NoMode

onClicked: {
if (highlighted) return;

parent.enabled = false;
setMode(mode);
}
onClicked: if (!highlighted) setMode(mode)
highlighted: main.mode === mode
onHighlightedChanged: if (highlighted) parent.enabled = true;
flat: true
}

0 comments on commit 3257544

Please sign in to comment.