void HWindow::_InitGUI() { fEventList = new HEventList(); fEventList->SetType(BMediaFiles::B_SOUNDS); fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST); BMenu* menu = new BMenu("file"); menu->SetRadioMode(true); menu->SetLabelFromMarked(true); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"), new BMessage(M_NONE_MESSAGE))); menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS), new BMessage(M_OTHER_MESSAGE))); BString label(B_TRANSLATE("Sound file:")); BMenuField* menuField = new BMenuField("filemenu", label, menu); menuField->SetDivider(menuField->StringWidth(label) + 10); BSize buttonsSize(be_plain_font->Size() * 2.5, be_plain_font->Size() * 2.5); BButton* stopbutton = new BButton("stop", "\xE2\x96\xA0", new BMessage(M_STOP_MESSAGE)); stopbutton->SetEnabled(false); stopbutton->SetExplicitSize(buttonsSize); // We need at least one view to trigger B_PULSE_NEEDED events which we will // intercept in DispatchMessage to trigger the buttons enabling or disabling. stopbutton->SetFlags(stopbutton->Flags() | B_PULSE_NEEDED); BButton* playbutton = new BButton("play", "\xE2\x96\xB6", new BMessage(M_PLAY_MESSAGE)); playbutton->SetEnabled(false); playbutton->SetExplicitSize(buttonsSize); BLayoutBuilder::Group<>(this, B_VERTICAL) .SetInsets(B_USE_WINDOW_SPACING) .Add(fEventList) .AddGroup(B_HORIZONTAL) .Add(menuField) .AddGroup(B_HORIZONTAL, 0) .Add(playbutton) .Add(stopbutton) .End() .End(); // setup file menu _SetupMenuField(); BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>")); if (noneItem != NULL) noneItem->SetMarked(true); _UpdateZoomLimits(); }
MediaButton::MediaButton(QWidget *parent) : QPushButton(parent) { auto settings = Settings::instance(); this->setMaximumWidth(settings->buttonsSize() + 10); connect(settings, &Settings::themeHasChanged, this, &MediaButton::setIconFromTheme); connect(settings, &Settings::mediaButtonVisibilityChanged, this, [=](const QString &buttonName, bool value) { if (buttonName == objectName()) { this->setVisible(value); } }); connect(SettingsPrivate::instance(), &SettingsPrivate::customIconForMediaButtonChanged, this, [=](const QString &button) { if (button == objectName()) { this->setIconFromTheme(settings->theme()); } }); }