mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-06-20 22:39:00 -04:00
Apply new style
This commit is contained in:
committed by
Radosław Wicik
parent
82b718e8d4
commit
a8573a404c
@@ -21,78 +21,91 @@
|
||||
#include "NotesMainWindow.hpp"
|
||||
#include <Style.hpp>
|
||||
|
||||
namespace gui {
|
||||
namespace gui
|
||||
{
|
||||
|
||||
NotesMainWindow::NotesMainWindow(app::Application *app) : AppWindow(app, gui::name::window::main_window), notesModel{new NotesModel(app)}
|
||||
NotesMainWindow::NotesMainWindow(app::Application *app)
|
||||
: AppWindow(app, gui::name::window::main_window), notesModel{new NotesModel(app)}
|
||||
{
|
||||
buildInterface();
|
||||
}
|
||||
|
||||
void NotesMainWindow::rebuild() {
|
||||
destroyInterface();
|
||||
buildInterface();
|
||||
}
|
||||
void NotesMainWindow::buildInterface() {
|
||||
AppWindow::buildInterface();
|
||||
void NotesMainWindow::rebuild()
|
||||
{
|
||||
destroyInterface();
|
||||
buildInterface();
|
||||
}
|
||||
void NotesMainWindow::buildInterface()
|
||||
{
|
||||
AppWindow::buildInterface();
|
||||
|
||||
list = new gui::ListView(this, 16, 105, 480-32, 440 );
|
||||
list->setMaxElements(3);
|
||||
list->setPageSize(3);
|
||||
list->setPenFocusWidth(0);
|
||||
list->setPenWidth(0);
|
||||
list->setProvider( notesModel );
|
||||
list = new gui::ListView(this, 16, 105, 480 - 32, 440);
|
||||
list->setMaxElements(3);
|
||||
list->setPageSize(3);
|
||||
list->setPenFocusWidth(0);
|
||||
list->setPenWidth(0);
|
||||
list->setProvider(notesModel);
|
||||
|
||||
setFocusItem(list);
|
||||
setFocusItem(list);
|
||||
|
||||
setTitle(utils::localize.get("app_notes_title_main"));
|
||||
setTitle(utils::localize.get("app_notes_title_main"));
|
||||
|
||||
bottomBar->setActive( BottomBar::Side::CENTER, true );
|
||||
bottomBar->setActive( BottomBar::Side::RIGHT, true );
|
||||
bottomBar->setText( BottomBar::Side::CENTER, utils::localize.get("common_open"));
|
||||
bottomBar->setText( BottomBar::Side::RIGHT, utils::localize.get("common_back"));
|
||||
bottomBar->setActive(BottomBar::Side::CENTER, true);
|
||||
bottomBar->setActive(BottomBar::Side::RIGHT, true);
|
||||
bottomBar->setText(BottomBar::Side::CENTER, utils::localize.get("common_open"));
|
||||
bottomBar->setText(BottomBar::Side::RIGHT, utils::localize.get("common_back"));
|
||||
|
||||
topBar->setActive(TopBar::Elements::TIME, true );
|
||||
topBar->setActive(TopBar::Elements::TIME, true);
|
||||
}
|
||||
void NotesMainWindow::destroyInterface()
|
||||
{
|
||||
AppWindow::destroyInterface();
|
||||
|
||||
}
|
||||
void NotesMainWindow::destroyInterface() {
|
||||
AppWindow::destroyInterface();
|
||||
if (list) {
|
||||
removeWidget(list);
|
||||
delete list;
|
||||
list = nullptr;
|
||||
};
|
||||
|
||||
if( list ) { removeWidget(list); delete list; list= nullptr; };
|
||||
children.clear();
|
||||
delete notesModel;
|
||||
}
|
||||
|
||||
children.clear();
|
||||
delete notesModel;
|
||||
}
|
||||
NotesMainWindow::~NotesMainWindow()
|
||||
{
|
||||
destroyInterface();
|
||||
}
|
||||
|
||||
NotesMainWindow::~NotesMainWindow() {
|
||||
destroyInterface();
|
||||
}
|
||||
void NotesMainWindow::onBeforeShow(ShowMode mode, SwitchData *data)
|
||||
{
|
||||
notesModel->clear();
|
||||
notesModel->requestRecordsCount();
|
||||
list->clear();
|
||||
list->setElementsCount(notesModel->getItemCount());
|
||||
}
|
||||
|
||||
void NotesMainWindow::onBeforeShow( ShowMode mode, SwitchData* data ) {
|
||||
notesModel->clear();
|
||||
notesModel->requestRecordsCount();
|
||||
list->clear();
|
||||
list->setElementsCount( notesModel->getItemCount() );
|
||||
}
|
||||
bool NotesMainWindow::onInput(const InputEvent &inputEvent)
|
||||
{
|
||||
|
||||
bool NotesMainWindow::onInput( const InputEvent& inputEvent ) {
|
||||
// process only if key is released
|
||||
if ((inputEvent.state != InputEvent::State::keyReleasedShort) ||
|
||||
(inputEvent.state != InputEvent::State::keyReleasedLong)) {
|
||||
if (inputEvent.keyCode == KeyCode::KEY_LEFT) {
|
||||
application->switchWindow("EditWindow");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//process only if key is released
|
||||
if(( inputEvent.state != InputEvent::State::keyReleasedShort ) || ( inputEvent.state != InputEvent::State::keyReleasedLong )) {
|
||||
if( inputEvent.keyCode == KeyCode::KEY_LEFT ) {
|
||||
application->switchWindow( "EditWindow" );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return AppWindow::onInput(inputEvent);
|
||||
}
|
||||
|
||||
return AppWindow::onInput( inputEvent );
|
||||
}
|
||||
bool NotesMainWindow::onDatabaseMessage(sys::Message *msgl)
|
||||
{
|
||||
DBNotesResponseMessage *msg = reinterpret_cast<DBNotesResponseMessage *>(msgl);
|
||||
if (notesModel->updateRecords(std::move(msg->records), msg->offset, msg->limit, msg->count))
|
||||
return true;
|
||||
|
||||
bool NotesMainWindow::onDatabaseMessage( sys::Message* msgl ) {
|
||||
DBNotesResponseMessage* msg = reinterpret_cast<DBNotesResponseMessage*>( msgl );
|
||||
if( notesModel->updateRecords( std::move(msg->records), msg->offset, msg->limit, msg->count ) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} /* namespace gui */
|
||||
|
||||
Reference in New Issue
Block a user