void OnyxDictFrame::createTtsButtonView() { const int height = defaultItemHeight(); tts_button_view_.setPreferItemSize(QSize(height, height)); OData *dd = new OData; QPixmap tts_pixmap(":/images/tts_icon.png"); dd->insert(TAG_COVER, tts_pixmap); dd->insert(TAG_MENU_TYPE, MENU_TTS); tts_button_datas_.push_back(dd); tts_button_view_.setFixedGrid(1, 1); tts_button_view_.setMargin(OnyxKeyboard::CATALOG_MARGIN); tts_button_view_.setFixedHeight(defaultItemHeight()+5*SPACING); tts_button_view_.setFixedWidth(defaultItemHeight()+7*SPACING); tts_button_view_.setData(tts_button_datas_); tts_button_view_.setNeighbor(&sub_menu_, CatalogView::UP); tts_button_view_.setNeighbor(keyboard_.top(), CatalogView::DOWN); tts_button_view_.setNeighbor(&dictionary_menu_, CatalogView::LEFT); tts_button_view_.setNeighbor(&dictionary_menu_, CatalogView::RECYCLE_LEFT); if((qgetenv("DISABLE_TTS").toInt() == 1)) { tts_button_view_.hide(); } }
void OnyxPlayerView::createSongListView(int view_width) { const int height = defaultItemHeight()+4*SPACING; song_list_view_.setPreferItemSize(QSize(-1, height)); QStandardItemModel * item_model = model_->standardItemModel(); int rows = item_model->rowCount(); song_list_data_.clear(); for (int i=0; i<rows; i++) { QStandardItem *item = item_model->item(i); OData *dd = new OData; dd->insert(TAG_TITLE, item->text()); dd->insert(TAG_FONT_SIZE, 22); int alignment = Qt::AlignLeft | Qt::AlignVCenter; dd->insert(TAG_ALIGN, alignment); dd->insert(TAG_ROW, i); song_list_data_.push_back(dd); } song_list_view_.setSpacing(2); int total_height = safeParentWidget(parentWidget())->height(); setSongListViewFixedGrid(total_height); song_list_view_.setFixedWidth(view_width); song_list_view_.setData(song_list_data_); song_list_view_.setNeighbor(&menu_view_, CatalogView::DOWN); song_list_view_.setNeighbor(&menu_view_, CatalogView::RECYCLE_DOWN); }
void SettingsView::createButtonView() { const static QSize MENU_ITEM_SIZE = QSize(60, 60); button_view_.setSubItemType(ButtonView::type()); // button_view_.setBackgroundColor(QColor(151, 151, 151)); // button_view_.setSubItemBkColor(QColor(151, 151, 151)); button_view_.setPreferItemSize(MENU_ITEM_SIZE); OData * dd = new OData; dd->insert(TAG_TITLE, tr("Add New")); dd->insert(TAG_ID, ADD); button_data_.push_back(dd); dd = new OData; dd->insert(TAG_TITLE, tr("Restore Factory")); dd->insert(TAG_ID, RESTORE); button_data_.push_back(dd); dd = new OData; dd->insert(TAG_TITLE, tr("OK")); dd->insert(TAG_ID, OK); button_data_.push_back(dd); button_view_.setSpacing(2); button_view_.setFixedGrid(1, 3); // button_view_.setFixedHeight(MENU_ITEM_SIZE.height() + 6 * SPACING); button_view_.setData(button_data_); button_view_.setSearchPolicy(CatalogView::NeighborFirst | CatalogView::AutoHorRecycle); button_view_.setNeighbor(&list_view_, CatalogView::RECYCLE_UP); onyx::screen::watcher().enqueue(this, onyx::screen::ScreenProxy::GC); //button_view_.setBackgroundColor(QColor(229, 229, 229)); }
void OnyxDictFrame::createLineEdit() { line_edit_.setSubItemType(LineEditView::type()); line_edit_.setPreferItemSize(QSize(rect().width(), defaultItemHeight())); OData *dd = new OData; dd->insert(TAG_TITLE, ""); line_edit_datas_.push_back(dd); line_edit_.setFixedGrid(1, 1); line_edit_.setFixedHeight(defaultItemHeight()+2*SPACING); line_edit_.setMargin(OnyxKeyboard::CATALOG_MARGIN); line_edit_.setData(line_edit_datas_); line_edit_.setNeighbor(&dictionary_menu_, CatalogView::DOWN); line_edit_.setNeighbor(keyboard_.menu(), CatalogView::RECYCLE_DOWN); line_edit_.setNeighbor(&sub_menu_, CatalogView::RIGHT); line_edit_.setNeighbor(&sub_menu_, CatalogView::RECYCLE_RIGHT); }
void OnyxDictFrame::createSubMenu() { const int height = defaultItemHeight(); sub_menu_.setPreferItemSize(QSize(height, height)); OData *dd = new OData; dd->insert(TAG_TITLE, tr("Clear")); dd->insert(TAG_MENU_TYPE, OnyxKeyboard::KEYBOARD_MENU_CLEAR); sub_menu_datas_.push_back(dd); sub_menu_.setFixedGrid(1, 1); sub_menu_.setMargin(OnyxKeyboard::CATALOG_MARGIN); sub_menu_.setFixedHeight(defaultItemHeight()+2*SPACING); sub_menu_.setFixedWidth(defaultItemHeight()*3); sub_menu_.setData(sub_menu_datas_); sub_menu_.setNeighbor(&line_edit_, CatalogView::RECYCLE_LEFT); sub_menu_.setNeighbor(&dictionary_menu_, CatalogView::DOWN); sub_menu_.setNeighbor(keyboard_.menu(), CatalogView::RECYCLE_DOWN); }
void PowerManagementDialog::onButtonChanged(CatalogView *catalog, ContentView *item, int user_data) { if (!item || !item->data()) { return; } OData *selected = item->data(); if(interval_selected_) { interval_selected_->insert(TAG_CHECKED, false); } selected->insert(TAG_CHECKED, true); interval_selected_ = selected; catalog->update(); onyx::screen::watcher().enqueue(catalog, onyx::screen::ScreenProxy::GU); int i = interval_selected_->value(TITLE_INDEX).toInt(); standby_interval_ = DISPLAY_ITEMS[i].standby_seconds; shutdown_interval_ = DISPLAY_ITEMS[i].shutdown_seconds; onOkClicked(); }
void Calculator::createLineButtons(const QVector< QPair<QString, int> > & button_list, CatalogView &view) { ODatas button_data; view.setSubItemType(ButtonView::type()); view.setPreferItemSize(QSize(80, 80)); for (int i = 0; i < button_list.size(); ++i) { OData * dd = new OData; dd->insert(TAG_TITLE, button_list[i].first); dd->insert(TAG_ID, button_list[i].second); dd->insert(TAG_FONT_SIZE, 32); button_data.push_back(dd); } view.setData(button_data); view.setFixedGrid(1, button_list.size()); view.setSpacing(10); view.setMinimumHeight(85); view.setSearchPolicy(CatalogView::AutoHorRecycle|CatalogView::NeighborFirst); connect(&view, SIGNAL(itemActivated(CatalogView*,ContentView*,int)), this, SLOT(onItemActivated(CatalogView *, ContentView *, int))); }
void TTSWidget::createLayout() { // top box layout_.setSizeConstraint(QLayout::SetMinAndMaxSize); layout_.setContentsMargins(2, 2, 2, 2); layout_.setSpacing(10); ODatas button_data; buttons_.setSubItemType(CoverView::type()); buttons_.setPreferItemSize(play_icon.size()); // menu button. { OData * dd = new OData; QPixmap menu_map(":/images/tts_menu.png"); dd->insert(TAG_COVER, menu_map); dd->insert(TAG_ID, MENU_); button_data.push_back(dd); } // play button { play_data = new OData; play_data->insert(TAG_COVER, play_icon); play_data->insert(TAG_ID, PLAY_); button_data.push_back(play_data); } // volume button { OData * dd = new OData; QPixmap volume_map(":/images/tts_volume.png"); dd->insert(TAG_COVER, volume_map); dd->insert(TAG_ID, VOLUME_); button_data.push_back(dd); } // close button { OData * dd = new OData; QPixmap close_map(":/images/tts_close.png"); dd->insert(TAG_COVER, close_map); dd->insert(TAG_ID, CLOSE_); button_data.push_back(dd); } buttons_.setData(button_data); buttons_.setFixedGrid(1, 4); buttons_.setSpacing(5); buttons_.setMinimumHeight(play_icon.height()+10); buttons_.setMinimumWidth(play_icon.width()*4+30); buttons_.setCheckedTo(0, 0); // Setup connection. connect(&tts_, SIGNAL(speakDone()), this, SLOT(onTextPlayed())); connect(&buttons_, SIGNAL(itemActivated(CatalogView*,ContentView*,int)), this, SLOT(onItemActivated(CatalogView *, ContentView *, int)), Qt::QueuedConnection); layout_.addWidget(&buttons_); }
void SettingsView::onItemActivated(CatalogView* catalog, ContentView* item, int user_data) { OData * item_data = item->data(); if (item_data->contains(TAG_ROW)) { CRSSFeedInfo* feedInfo = (CRSSFeedInfo *) item_data->value(TAG_POINTER).toInt(); if (user_data == EditView::CHECKBOX) { if (feedInfo->Selected) { num_selected_ ++; } else { num_selected_ --; } if (num_selected_ > ROWS) { QKeyEvent keyEvent(QEvent::KeyRelease, Qt::Key_Return, Qt::NoModifier); QApplication::sendEvent(item, &keyEvent); } } else if (user_data == EditView::EDIT) { RssFeedDialog dialog(tr("Edit Feed"), this); dialog.setTitle(feedInfo->Title); dialog.setUrl(feedInfo->Url.toString()); int ret = dialog.popup(); if (ret == QDialog::Accepted) { // TODO, not good feedInfo->Title = dialog.title(); feedInfo->Title_for_save = dialog.title(); feedInfo->Url = QUrl(dialog.url()); OData *dd = feedInfo->GetAssociatedListItem(); dd->insert(TAG_TITLE, feedInfo->Title); dd->insert(TAG_URL, feedInfo->Url.toString()); item->updateView(); } } else if (user_data == EditView::REMOVE) { DeleteRssDialog dialog(feedInfo->Title, this); int ret = dialog.exec(); if (ret != QMessageBox::Yes) { return ; } for (int i = 0; i < rss_feeds_.size(); ++i) { if (rss_feeds_.at(i) == feedInfo) { emit removeFeed(i); createListView(); if (i >= list_data_.size()) { list_view_.select(list_data_.at(i-1)); } else if(i > 0) { list_view_.select(list_data_.at(i)); } break; } } } } else { int flag = item_data->value(::TAG_ID).toInt(); if (flag == OK) { accept(); } else if (flag == ADD) { RssFeedDialog dialog(tr("Add Feed"), this); dialog.setUrl("http://"); int ret = dialog.popup(); if (ret == QDialog::Accepted && !dialog.title().isEmpty() && !dialog.url().isEmpty()) { // TODO, not good CRSSFeedInfo feedInfo; feedInfo.Title = dialog.title(); feedInfo.Title_for_save = dialog.title(); feedInfo.Url = QUrl(dialog.url()); emit addFeed(feedInfo); createListView(); list_view_.select(rss_feeds_.last()->GetAssociatedListItem()); } } else if (flag == RESTORE) { emit reloadFeedList(); createListView(); } } onyx::screen::instance().flush(this, onyx::screen::ScreenProxy::GU, false, onyx::screen::ScreenCommand::WAIT_ALL); }
void OnyxDictFrame::createDictionaryMenu() { const int height = defaultItemHeight(); dictionary_menu_.setPreferItemSize(QSize(height, height)); OData *dd = new OData; dd->insert(TAG_COVER, QPixmap(":/images/dictionary_list.png")); dd->insert(TAG_MENU_TYPE, MENU_DICTIONARIES); dd->insert(TAG_FONT_SIZE, DICT_MENU_FONT_SIZE); dictionary_menu_datas_.push_back(dd); dd = new OData; dd->insert(TAG_COVER, QPixmap(":/images/similar_words.png")); dd->insert(TAG_MENU_TYPE, MENU_SIMILAR_WORDS); dd->insert(TAG_FONT_SIZE, DICT_MENU_FONT_SIZE); dictionary_menu_datas_.push_back(dd); dd = new OData; dd->insert(TAG_COVER, QPixmap(":/images/explanation.png")); dd->insert(TAG_MENU_TYPE, MENU_EXPLANATION); dd->insert(TAG_FONT_SIZE, DICT_MENU_FONT_SIZE); dictionary_menu_datas_.push_back(dd); dd = new OData; dd->insert(TAG_COVER, QPixmap(":/images/lookup.png")); dd->insert(TAG_MENU_TYPE, MENU_LOOKUP); dd->insert(TAG_FONT_SIZE, DICT_MENU_FONT_SIZE); dictionary_menu_datas_.push_back(dd); dictionary_menu_.setFixedGrid(1, 4); dictionary_menu_.setMargin(OnyxKeyboard::CATALOG_MARGIN); dictionary_menu_.setFixedHeight(defaultItemHeight()+5*SPACING); dictionary_menu_.setData(dictionary_menu_datas_); dictionary_menu_.setNeighbor(&line_edit_, CatalogView::UP); dictionary_menu_.setNeighbor(&sub_menu_, CatalogView::UP); dictionary_menu_.setNeighbor(keyboard_.top(), CatalogView::DOWN); dictionary_menu_.setNeighbor(&tts_button_view_, CatalogView::RIGHT); dictionary_menu_.setNeighbor(&tts_button_view_, CatalogView::RECYCLE_RIGHT); }
void PowerManagementDialog::createLayout() { content_widget_.setBackgroundRole(QPalette::Button); // Retrieve the values from system status. sys_standby_interval_ = status_.suspendInterval(); standby_interval_ = sys_standby_interval_; sys_shutdown_interval_ = status_.shutdownInterval(); shutdown_interval_ = sys_shutdown_interval_; updateTitle(QApplication::tr("Power Management")); updateTitleIcon(QPixmap(":/images/power.png")); // The big layout. ver_layout_.setContentsMargins(SPACING, 0, SPACING, 0); ver_layout_.addSpacing(10); QString t(tr("Battery remaining %1%")); int left = 100, status = 0; status_.batteryStatus(left, status); t = t.arg(left); if (isPmExclusive()) { t.clear(); } battery_power_.setText(t); ver_layout_.addWidget(&battery_power_); // Create display items buttons_.setSubItemType(CheckBoxView::type()); buttons_.setMargin(2, 2, 2, 2); buttons_.setPreferItemSize(QSize(0, ITEM_HEIGHT)); ODatas d; const ItemStruct *ITEMS; int display_cout; if ( qgetenv("CUSTOM_PM").toInt() == 1 ) { display_cout = isPmExclusive() ? 4: ICARUS_DISPLAY_COUNT; ITEMS = ICARUS_DISPLAY_ITEMS; } else { display_cout = isPmExclusive() ? 4: DISPLAY_COUNT; ITEMS = DISPLAY_ITEMS; } for (int row = 0; row < display_cout; ++row) { if ( qgetenv("DISABLE_NEVER_STANDBY_SHUTDOWN").toInt() > 0 && ITEMS[row].standby_seconds == 0 && ITEMS[row].shutdown_seconds == 0) { continue; } OData * item = new OData; item->insert(TAG_TITLE, qApp->translate(SCOPE, ITEMS[row].title)); item->insert(TITLE_INDEX, row); if ( (sys_standby_interval_ == ITEMS[row].standby_seconds) && (sys_shutdown_interval_ == ITEMS[row].shutdown_seconds) ) { interval_selected_ = item; item->insert(TAG_CHECKED, true); } d.push_back(item); } buttons_.setData(d, true); buttons_.setMinimumHeight( (ITEM_HEIGHT+2)*d.size()); buttons_.setFixedGrid(d.size(), 1); buttons_.setSpacing(3); QObject::connect(&buttons_, SIGNAL(itemActivated(CatalogView *, ContentView *, int)), this, SLOT(onButtonChanged(CatalogView *, ContentView *, int)), Qt::QueuedConnection); ver_layout_.addWidget(&buttons_); // OK cancel buttons. ok_.setSubItemType(ui::CoverView::type()); ok_.setPreferItemSize(QSize(100, 60)); ODatas d2; OData * item = new OData; item->insert(TAG_TITLE, tr("OK")); item->insert(TITLE_INDEX, 1); d2.push_back(item); ok_.setData(d2, true); ok_.setMinimumHeight( 60 ); ok_.setMinimumWidth(100); ok_.setFocusPolicy(Qt::TabFocus); ok_.setNeighbor(&buttons_, CatalogView::UP); connect(&ok_, SIGNAL(itemActivated(CatalogView *, ContentView *, int)), this, SLOT(onOkClicked())); hor_layout_.addStretch(0); hor_layout_.addWidget(&ok_); ver_layout_.addStretch(0); ver_layout_.addLayout(&hor_layout_); ver_layout_.addSpacing(8); }
void OnyxPlayerView::createMenuView() { menu_view_.setPreferItemSize(MENU_ITEM_SIZE); OData *dd = new OData; dd->insert(TAG_COVER, normal_mode_pixmap_); dd->insert(TAG_MENU_TYPE, MENU_MODE); menu_view_datas_.push_back(dd); dd = new OData; QPixmap prev_pixmap(":/player_icons/previous.png"); dd->insert(TAG_COVER, prev_pixmap); dd->insert(TAG_MENU_TYPE, MENU_PREVIOUS); menu_view_datas_.push_back(dd); dd = new OData; dd->insert(TAG_COVER, pause_pixmap_); dd->insert(TAG_MENU_TYPE, MENU_PLAY); menu_view_datas_.push_back(dd); dd = new OData; QPixmap next_pixmap(":/player_icons/next.png"); dd->insert(TAG_COVER, next_pixmap); dd->insert(TAG_MENU_TYPE, MENU_NEXT); menu_view_datas_.push_back(dd); dd = new OData; QPixmap vol_pixmap(":/player_icons/volume.png"); dd->insert(TAG_COVER, vol_pixmap); dd->insert(TAG_MENU_TYPE, MENU_VOLUME); menu_view_datas_.push_back(dd); dd = new OData; QPixmap exit_pixmap(":/player_icons/exit.png"); dd->insert(TAG_COVER, exit_pixmap); dd->insert(TAG_MENU_TYPE, MENU_EXIT); menu_view_datas_.push_back(dd); menu_view_.setSpacing(2); menu_view_.setFixedGrid(1, 6); menu_view_.setFixedHeight(MENU_ITEM_SIZE.height() + 2 * SPACING); menu_view_.setData(menu_view_datas_); menu_view_.setSearchPolicy(CatalogView::NeighborFirst | CatalogView::AutoHorRecycle); menu_view_.setNeighbor(&song_list_view_, CatalogView::RECYCLE_UP); }